MHEG5  18.9.0
MHEG5 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 
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;
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;
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--;
113  {
114  /* invalid value, or 'justified', so just do default */
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--;
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) ||
143  {
144  /* default to STARTCORNERUPPERLEFT if there's a problem */
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));
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...
MHEG5Visible visible
Definition: mh5text.h:62
Basis MHEG5 data types.
#define HJUSTIFICATION_JUSTIFIED
Definition: mh5text.h:42
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...
MHEG5Int verticalJustification
Definition: mh5text.h:71
#define HJUSTIFICATION_START
Definition: mh5text.h:39
MHEG5Int horizontalJustification
Definition: mh5text.h:70
Miscellaneous functions for decoding ASN.1 types.
#define STARTCORNERUPPERLEFT
#define FONTATTS
Definition: vpa1_tgs.h:92
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
#define MHEG5getMem
Definition: glue_memory.h:93
Implement the MHEG5 Text Class 36 Text Class Defines attributes and behaviour of pieces of textual in...
MHEG5Final clazz
Definition: mh5root.h:55
MHEG5Bool characterSetEncoded
Definition: mh5text.h:94
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
#define VJUSTIFICATION_JUSTIFIED
Definition: mh5text.h:47
#define ASN_NO_ERROR
Definition: asn1_sys.h:36
syntaxItemData data
Definition: fpa1_syn.h:57
MHEG5Int characterSet
Definition: mh5text.h:69
#define DPL5(x)
Definition: glue_debug.h:167
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.
MHEG5Bool textWrapping
Definition: mh5text.h:74
#define CHARSET
Definition: vpa1_tgs.h:87
#define MHEG5freeMem
Definition: glue_memory.h:94
MHEG5String originalFontAttributes
Definition: mh5text.h:66
MHEG5FontBody originalFont
Definition: mh5text.h:65
MHEG5Bool boolData
Definition: fpa1_syn.h:44
MHEG5Colour originalTextColour
Definition: mh5text.h:67
#define TCOL
Definition: vpa1_tgs.h:90
#define DPL2(x)
Definition: glue_debug.h:185
asnErr asn1_decodeVisible(fpa1_syntaxList *listPtr, MHEG5Visible *visible)
Decodes Visible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
#define MHEG5TRUE
Definition: mh5base.h:49
#define LINEOR
Definition: vpa1_tgs.h:138
#define OFONT
Definition: vpa1_tgs.h:135
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.
#define BACKCOL
Definition: vpa1_tgs.h:88
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...
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
#define TEXTWRAP
Definition: vpa1_tgs.h:140
MHEG5Int startCorner
Definition: mh5text.h:73
int asnErr
Definition: asn1_sys.h:41
MHEG5Bool verticalLineOrientation
Definition: mh5text.h:72
#define HJUST
Definition: vpa1_tgs.h:136
asnErr asn1_decodeText(fpa1_syntaxList *listPtr, MHEG5Text *text)
Decodes Text class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
#define STARTCORN
Definition: vpa1_tgs.h:139
#define VJUSTIFICATION_START
Definition: mh5text.h:44
MHEG5Int intData
Definition: fpa1_syn.h:45
MHEG5Ingredient * asn1_createText(fpa1_syntaxList *listPtr)
Decodes Text class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
#define STARTCORNERLOWERRIGHT
MHEG5Colour originalBackgroundColour
Definition: mh5text.h:68
#define MHEG5FALSE
Definition: mh5base.h:48
#define VJUST
Definition: vpa1_tgs.h:137