MHEG-5  19.3.0
MHEG-5 Documentation
asn1_createText.c
Go to the documentation of this file.
1 /*******************************************************************************
2  * Copyright © 2014 The DTVKit Open Software Foundation Ltd (www.dtvkit.org)
3  * Copyright © 2004 Ocean Blue Software Ltd
4  * Copyright © 2000 Koninklijke Philips Electronics N.V
5  *
6  * This file is part of a DTVKit Software Component
7  * You are permitted to copy, modify or distribute this file subject to the terms
8  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
9  *
10  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
11  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
12  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
13  *
14  * If you or your organisation is not a member of DTVKit then you have access
15  * to this source code outside of the terms of the licence agreement
16  * and you are expected to delete this and any associated files immediately.
17  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
18  *******************************************************************************/
27 /*---includes for this file--------------------------------------------------*/
28 #include <stdio.h>
29 #include "vpa1_sys.h"
30 #include "vpa1_tgs.h"
31 #include "fpa1_syn.h"
32 #include "asn1_sys.h"
33 
34 #include "mh5base.h"
35 #include "mh5text.h"
36 #include "mh5application.h"
37 #include "asn1_createExtras.h"
38 #include "asn1_createVisible.h"
39 #include "asn1_createApplication.h"
40 #include "asn1_createText.h"
41 
42 /*---constant definitions for this file--------------------------------------*/
43 #define STARTCORNERUPPERLEFT (0)
44 #define STARTCORNERUPPERRIGHT (1)
45 #define STARTCORNERLOWERLEFT (2)
46 #define STARTCORNERLOWERRIGHT (3)
47 
48 
49 /*---local typedef structs for this file-------------------------------------*/
50 
51 /*---local (static) variable declarations for this file----------------------*/
52 
53 /*---local function definitions----------------------------------------------*/
54 
55 /*---global function definitions---------------------------------------------*/
56 
65 asnErr asn1_decodeText(fpa1_syntaxList *listPtr, MHEG5Text *text)
66 {
67  asnErr errVal = 0;
68  fpa1_syntaxList *currItem;
69 
70  DPL5((">> asn1_decodeText(%X,%X)\n", listPtr, text));
71 
72  assert(text);
73  assert(listPtr);
74 
75  currItem = listPtr->children;
76 
77  /* defaults */
78  text->horizontalJustification = 0; /* start */
79  text->verticalJustification = 0; /* start */
80  text->verticalLineOrientation = MHEG5FALSE; /* horizontal */
81 
82  text->startCorner = 0; /* upper left (engine expects this enum to start from 0) */
83  text->textWrapping = MHEG5FALSE;
84  text->characterSetEncoded = MHEG5FALSE;
85  /* searches current set of tags for local tags */
86  while (currItem != NULL)
87  {
88  switch (currItem->tag)
89  {
90  case OFONT:
91  errVal |= asn1_decodeFontBody(currItem, &text->originalFont);
92  break;
93  case FONTATTS:
94  errVal |= asn1_decodeOctetString(currItem, &text->originalFontAttributes);
95  break;
96  case TCOL:
97  errVal |= asn1_decodeColour(currItem, &text->originalTextColour);
98  break;
99  case BACKCOL:
100  errVal |= asn1_decodeColour(currItem, &text->originalBackgroundColour);
101  break;
102  case CHARSET:
103  text->characterSet = currItem->data.intData;
104  text->characterSetEncoded = MHEG5TRUE;
105  break;
106  case HJUST:
107  text->horizontalJustification = currItem->data.intData;
108  /* Justifications need to start from 0, unlike most ASN1 enumeration types. */
109  /* This is a requirement of the engine */
110  text->horizontalJustification--;
111  if ((text->horizontalJustification < HJUSTIFICATION_START) ||
112  (text->horizontalJustification >= HJUSTIFICATION_JUSTIFIED))
113  {
114  /* invalid value, or 'justified', so just do default */
115  text->horizontalJustification = HJUSTIFICATION_START;
116  }
117  break;
118  case VJUST:
119  text->verticalJustification = currItem->data.intData;
120  /* Justifications need to start from 0, unlike most ASN1 enumeration types. */
121  text->verticalJustification--;
122  if ((text->verticalJustification > VJUSTIFICATION_JUSTIFIED) ||
123  (text->verticalJustification < VJUSTIFICATION_START))
124  {
125  text->verticalJustification = VJUSTIFICATION_START; /* default */
126  }
127  break;
128  case LINEOR:
129  /* verticalLineOrientation is bool. */
130  if (currItem->data.intData == 1)
131  {
132  text->verticalLineOrientation = MHEG5TRUE; /* vertical */
133  }
134  /* else defaults to MHEG5FALSE (horizontal)*/
135  break;
136  case STARTCORN:
137  /* engine expects 0 as top-left, 1 as top-right etc */
138  text->startCorner = currItem->data.intData;
139  text->startCorner--;
140  /* bounds check */
141  if ((text->startCorner < STARTCORNERUPPERLEFT) ||
142  (text->startCorner > STARTCORNERLOWERRIGHT))
143  {
144  /* default to STARTCORNERUPPERLEFT if there's a problem */
145  text->startCorner = STARTCORNERUPPERLEFT;
146  }
147  break;
148  case TEXTWRAP:
149  text->textWrapping = (currItem->data.boolData == 0) ? MHEG5FALSE : MHEG5TRUE;
150  break;
151  default:
152  break;
153  }
154  currItem = currItem->next;
155  }
156  /* decode inherited tags */
157  errVal |= asn1_decodeVisible(listPtr, &text->visible);
158 
159 #if (DPLEVEL >= 2)
160  if (errVal != 0)
161  {
162  DPL2(("WARNING:[ASN.1] asn1_decodeText() returns errVal = %d\n", errVal));
163  }
164 #endif /* DPLEVEL >= 2 */
165 
166  DPL5(("<< asn1_decodeText() Returns %d\n", errVal));
167 
168  return errVal;
169 }
170 
179 {
180  MHEG5Text *text;
181 
182  text = (MHEG5Text *)MHEG5getMem( sizeof(MHEG5Text));
183  if (text != NULL)
184  {
185  memset(text, 0, sizeof(MHEG5Text));
186  text->visible.ingredient.root.clazz = MHEG5TEXT;
187  if (asn1_decodeText( listPtr, text ) != ASN_NO_ERROR)
188  {
189  #if (DPLEVEL >= 2)
190  DPL2(("WARNING:[ASN.1] asn1_createText() Fails\n"));
191  #endif /* DPLEVEL >= 2 */
192  MHEG5freeMem( text );
193  text = NULL;
194  }
195  }
196  return (MHEG5Ingredient *)text;
197 }
198 
asnErr asn1_decodeColour(fpa1_syntaxList *listPtr, MHEG5Colour *colour)
Decodes Colour class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Basis MHEG5 data types.
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
asnErr asn1_decodeFontBody(fpa1_syntaxList *listPtr, MHEG5FontBody *fontBody)
Decodes FontBody class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Miscellaneous functions for decoding ASN.1 types.
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Implement the MHEG5 Text Class 36 Text Class Defines attributes and behaviour of pieces of textual in...
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
Functions to create a MHEG5Text from a MHEG5 script (in the form of a list of fpa1_syntaxList structu...
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
asnErr asn1_decodeVisible(fpa1_syntaxList *listPtr, MHEG5Visible *visible)
Decodes Visible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Functions to create a MHEG5Application from a MHEG5 script (in the form of a list of fpa1_syntaxList ...
Functions to create a MHEG5Visible from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...
asnErr asn1_decodeText(fpa1_syntaxList *listPtr, MHEG5Text *text)
Decodes Text class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Ingredient * asn1_createText(fpa1_syntaxList *listPtr)
Decodes Text class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...