MHEG5  18.9.0
MHEG5 Documentation
fpa1_typ.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  *******************************************************************************/
26 /*---includes for this file--------------------------------------------------*/
27 #include <stdio.h>
28 #include <stdlib.h>
29 
30 #include "vpa1_tgs.h"
31 #include "vpa1_rdf.h"
32 
33 #include "fpa1_act.h"
34 #include "fpa1_boo.h"
35 #include "fpa1_cho.h"
36 #include "fpa1_con.h"
37 #include "fpa1_enu.h"
38 #include "fpa1_lnk.h"
39 #include "fpa1_ing.h"
40 #include "fpa1_int.h"
41 #include "fpa1_obj.h"
42 #include "fpa1_pos.h"
43 #include "fpa1_rdf.h"
44 #include "fpa1_sce.h"
45 #include "fpa1_seq.h"
46 #include "fpa1_str.h"
47 #include "fpa1_syn.h"
48 #include "fpa1_tok.h"
49 #include "fpa1_typ.h"
50 
51 /*---local typedef structs for this file-------------------------------------*/
52 
53 /*---constant definitions for this file--------------------------------------*/
54 #define NORM_SEQUENCE_TYPE (SEQUENCE_TYPE - MHEG5_TYPE)
55 #define NORM_EXTERNAL_REFERENCE_TYPE (EXTERNAL_REFERENCE_TYPE - MHEG5_TYPE)
56 #define NORM_NEW_REFERENCED_CONTENT (NEW_REFERENCED_CONTENT - MHEG5_TYPE)
57 #define NORM_NEW_TIMER (NEW_TIMER - MHEG5_TYPE)
58 #define NORM_NEXT_SCENE_TYPE (NEXT_SCENE_TYPE - MHEG5_TYPE)
59 #define NORM_POINT_TYPE (POINT_TYPE - MHEG5_TYPE)
60 #define NORM_RATIONAL_TYPE (RATIONAL_TYPE - MHEG5_TYPE)
61 #define NORM_REFERENCED_CONTENT_TYPE (REFERENCED_CONTENT_TYPE - MHEG5_TYPE)
62 #define NORM_TOKEN_GROUP_ITEM_TYPE (TOKEN_GROUP_ITEM_TYPE - MHEG5_TYPE)
63 #define NORM_XY_POSITION_TYPE (XY_POSITION_TYPE - MHEG5_TYPE)
64 #define NORM_SEQ_SIZE_OF_ACTION_SLOT (SEQ_SIZE_OF_ACTION_SLOT - MHEG5_TYPE)
65 #define NORM_SEQ_SIZE_OF_ELEMENTARY_ACTION (SEQ_SIZE_OF_ELEMENTARY_ACTION - MHEG5_TYPE)
66 #define NORM_ACTION_CLASS_TYPE (ACTION_CLASS_TYPE - MHEG5_TYPE)
67 #define NORM_SEQ_SIZE_OF_INTEGER (SEQ_SIZE_OF_INTEGER - MHEG5_TYPE)
68 #define NORM_SEQ_SIZE_OF_PARAMETER (SEQ_SIZE_OF_PARAMETER - MHEG5_TYPE)
69 #define NORM_SEQ_SIZE_OF_POINT (SEQ_SIZE_OF_POINT - MHEG5_TYPE)
70 #define NORM_SEQ_SIZE_OF_OBJECT_REFERENCE (SEQ_SIZE_OF_OBJECT_REFERENCE - MHEG5_TYPE)
71 #define NORM_INVALID_SEQ_TYPE (INVALID_SEQ_TYPE - MHEG5_TYPE)
72 #define NORM_EVENT_TYPE (EVENT_TYPE - MHEG5_TYPE)
73 #define NORM_EVENT_DATA_TYPE (EVENT_DATA_TYPE - MHEG5_TYPE)
74 #define NORM_EVENT_SOURCE_TYPE (EVENT_SOURCE_TYPE - MHEG5_TYPE)
75 #define NORM_OBJECT_REFERENCE_TYPE (OBJECT_REFERENCE_TYPE - MHEG5_TYPE)
76 #define NORM_ACTION_SLOT_TYPE (ACTION_SLOT_TYPE - MHEG5_TYPE)
77 #define NORM_COMPARISON_VALUE_TYPE (COMPARISON_VALUE_TYPE - MHEG5_TYPE)
78 #define NORM_CONN_TAG_OR_NULL_TYPE (CONN_TAG_OR_NULL_TYPE - MHEG5_TYPE)
79 #define NORM_EMULATED_EVENT_DATA (EMULATED_EVENT_DATA - MHEG5_TYPE)
80 #define NORM_GENERIC_BOOLEAN (GENERIC_BOOLEAN - MHEG5_TYPE)
81 #define NORM_GENERIC_CONTENT_REFERENCE (GENERIC_CONTENT_REFERENCE - MHEG5_TYPE)
82 #define NORM_GENERIC_INTEGER (GENERIC_INTEGER - MHEG5_TYPE)
83 #define NORM_GENERIC_OBJECT_REFERENCE (GENERIC_OBJECT_REFERENCE - MHEG5_TYPE)
84 #define NORM_GENERIC_OCTET_STRING (GENERIC_OCTET_STRING - MHEG5_TYPE)
85 #define NORM_NEW_COLOUR (NEW_COLOUR - MHEG5_TYPE)
86 #define NORM_NEW_CONTENT (NEW_CONTENT - MHEG5_TYPE)
87 #define NORM_NEW_FONT (NEW_FONT - MHEG5_TYPE)
88 #define NORM_NEW_VARIABLE_VALUE (NEW_VARIABLE_VALUE - MHEG5_TYPE)
89 #define NORM_PARAMETER_TYPE (PARAMETER_TYPE - MHEG5_TYPE)
90 #define NORM_CONTENT_REFERENCE_TYPE (CONTENT_REFERENCE_TYPE - MHEG5_TYPE)
91 
92 
93 /*---local (static) variable declarations for this file----------------------*/
94 
95 /*---local function definitions----------------------------------------------*/
96 
97 /*---global function definitions---------------------------------------------*/
98 static fpa1_syntaxList* fpa1_typeSequence( int, vpa1_filePos );
99 
104 static fpa1_syntaxList* fpa1_typeSequence( int whichType, vpa1_filePos filePosLimit )
105 {
106  int tag;
107  vpa1_filePos curFilePosition, nextTagPosition;
108 
109  fpa1_syntaxList *itemPtr = NULL;
110  fpa1_syntaxList *childPtr = NULL;
111  unsigned short childCnt[3] = { 0, 0, 0 };
112  unsigned short startGenericDataCnt = fpa1_GenericDataCount;
113 
114  /* save current file position */
115  curFilePosition = fpa1_rdfGetCurrentFilePosition();
116  tag = fpa1_rdfGetTag();
117 
118  /* test for the correct leading tag */
119  if (tag == SEQUENCE)
120  {
121  /* get next tag position */
122  nextTagPosition = fpa1_rdfGetNextTagPosn();
123 
124  /* move to contents */
126 
127  switch (whichType)
128  {
130  childPtr = fpa1_sequenceParse( childCnt, extRefSeqCompArr, filePosLimit );
131  /*extern ref is finally stored as one param, not as 'string' and 'int', so decrement by one */
133  break;
135  childPtr = fpa1_sequenceParse( childCnt, newRefConSeqCompArr, filePosLimit );
136  break;
137  case NORM_NEW_TIMER:
138  childPtr = fpa1_sequenceParse( childCnt, newTimerSeqCompArr, filePosLimit );
139  break;
141  /* has MHEG5BRACKETOPEN, OCTETSTRING, INTEGER, MHEG5BRACKETCLOSE */
143  childPtr = fpa1_sequenceParse( childCnt, nextSceneSeqCompArr, filePosLimit );
144  break;
145  case NORM_POINT_TYPE:
146  /* MHEG5BRACKETOPEN, MHEG5BRACKETCLOSE*/
148  childPtr = fpa1_sequenceParse( childCnt, pointSeqCompArr, filePosLimit );
149  break;
150  case NORM_RATIONAL_TYPE:
151  childPtr = fpa1_sequenceParse( childCnt, rationalSeqCompArr, filePosLimit );
152  break;
154  childPtr = fpa1_sequenceParse( childCnt, refCntSeqCompArr, filePosLimit );
155  break;
157  childPtr = fpa1_sequenceParse( childCnt, tokGrpItmsSeqCompArr, filePosLimit );
158  break;
160  childPtr = fpa1_sequenceParse( childCnt, xyPosSeqCompArr, filePosLimit );
161  break;
162 
163  /* untagged SEQUENCE OF SIZE stuff */
165  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_ACTION_SLOT, filePosLimit );
166  break;
168  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_ELEMENTARY_ACTION, filePosLimit );
169  fpa1_GroupActionCount += *childCnt;
170  fpa1_GroupParamCount += fpa1_GenericDataCount - startGenericDataCnt;
171  break;
173  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_INTEGER, filePosLimit );
174  break;
176  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_PARAMETER, filePosLimit );
177  break;
179  /* MHEG5BRACKETOPEN, MHEG5BRACKETCLOSE*/
181  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_POINT, filePosLimit );
182  break;
184  /* MHEG5BRACKETOPEN, MHEG5BRACKETCLOSE*/
186  childPtr = fpa1_sequenceOfParse( childCnt, SEQ_OF_OBJECT_REFERENCE, filePosLimit );
187  break;
188  default:
189  childPtr = NULL;
190  break;
191  }
192 
193  if (childPtr != NULL)
194  {
195  /* success ! */
196 
197  /* create parent item - use MHEG5_TYPE as tag ID */
198  itemPtr = fpa1_synCreateListItem( whichType + MHEG5_TYPE,
199  curFilePosition,
200  nextTagPosition );
201  if (itemPtr != NULL)
202  {
203  itemPtr->children = childPtr;
204  itemPtr->childCount[0] = childCnt[0];
205  itemPtr->childCount[1] = childCnt[1];
206  itemPtr->childCount[2] = childCnt[2];
207  itemPtr->dataTotal = fpa1_GenericDataCount - startGenericDataCnt;
208  }
209  }
210  }
211 
212  return itemPtr;
213 } /* fpa1_typeSequence() */
214 
219 fpa1_syntaxList* fpa1_typeParse( int whichType, vpa1_filePos filePosLimit )
220 {
221  fpa1_syntaxList *itemPtr;
222 
223  /* normalize whichType */
224  whichType = whichType - MHEG5_TYPE;
225 
226  /* Do SEQUENCE types */
227  if ((whichType > NORM_SEQUENCE_TYPE) &&
228  (whichType < NORM_INVALID_SEQ_TYPE))
229  {
230  itemPtr = fpa1_typeSequence( whichType, filePosLimit );
231  }
232  else
233  {
234  /* do types without leading tag */
235  switch (whichType)
236  {
237  /* ENUMERATED types */
238  case NORM_EVENT_TYPE:
239  itemPtr = fpa1_decodeEnumeratedType( filePosLimit );
240  /* Tagged as Enumerated - distinguish it */
241  if (itemPtr != NULL)
242  {
243  /* use MHEG5_TYPE as tag */
244  itemPtr->tag = whichType + MHEG5_TYPE;
245  }
246  break;
247 
248  /* CHOICE types */
251  /* Untagged - distinguish it */
252  if (itemPtr != NULL)
253  {
254  /* use MHEG5_TYPE as tag */
255  itemPtr->tag = whichType + MHEG5_TYPE;
256  }
257  break;
261  if ((whichType == NORM_EVENT_SOURCE_TYPE) &&
262  (itemPtr != NULL))
263  {
264  /* use MHEG5_TYPE as tag */
265  itemPtr->tag = whichType + MHEG5_TYPE;
266  }
267  break;
270  break;
273  break;
276  break;
279  break;
282  break;
285  break;
288  break;
291  break;
294  break;
295  case NORM_NEW_COLOUR:
297  break;
298  case NORM_NEW_CONTENT:
300  break;
301  case NORM_NEW_FONT:
303  break;
304  case NORM_PARAMETER_TYPE:
306  break;
307 
308  /* STRING types */
310  /* Octet string pretend it's a CHOICE of two elements */
311  /* OCTETSTRING and CONTREF. The latter is due to an anomaly */
312  /* in the Text conversion of GenericObjectReference */
314  if (itemPtr != NULL)
315  {
316  /* force it to a string - due to Text conversion anomaly */
317  /* in GenericContentReference */
318  itemPtr->tag = OCTETSTRING;
319  }
320 
321  break;
322 
323  default:
324  itemPtr = NULL;
325  break;
326  }
327  }
328 
329  return itemPtr;
330 }
331 
#define NORM_GENERIC_OCTET_STRING
Definition: fpa1_typ.c:84
int newContentChoiceCompArr[]
Definition: fpa1_act.c:230
Contains functions to decode MHEG-5 ASN.1 types.
int fpa1_GroupActionCount
Definition: fpa1_rdf.c:67
int paramChoiceCompArr[]
Definition: fpa1_act.c:222
fpa1_syntaxList * fpa1_synCreateListItem(int, vpa1_filePos, vpa1_filePos)
Definition: fpa1_syn.c:161
#define NORM_GENERIC_BOOLEAN
Definition: fpa1_typ.c:80
#define NORM_SEQ_SIZE_OF_INTEGER
Definition: fpa1_typ.c:67
Contains functions to decode MHEG-5 ASN.1 Token Group and Token Manager class components.
vpa1_filePos fpa1_rdfGetCurrentFilePosition(void)
Definition: fpa1_rdf.c:253
void fpa1_rdfMoveToContents(void)
Definition: fpa1_rdf.c:319
fpa1_syntaxList * fpa1_typeParse(int whichType, vpa1_filePos filePosLimit)
Definition: fpa1_typ.c:219
Contains functions/globals used to read MHEG-5 ASN.1 scripts.
int newTimerSeqCompArr[]
Definition: fpa1_act.c:370
#define NORM_NEXT_SCENE_TYPE
Definition: fpa1_typ.c:58
int xyPosSeqCompArr[]
Definition: fpa1_pos.c:44
Contains functions to decode MHEG-5 ASN.1 Integer class component.
int newRefConSeqCompArr[]
Definition: fpa1_act.c:364
#define NORM_CONTENT_REFERENCE_TYPE
Definition: fpa1_typ.c:90
int rationalSeqCompArr[]
Definition: fpa1_act.c:380
Contains functions to decode MHEG-5 ASN.1 Link class components.
#define NORM_NEW_FONT
Definition: fpa1_typ.c:87
fpa1_syntaxList * fpa1_decodeEnumeratedType(vpa1_filePos)
Definition: fpa1_enu.c:53
vpa1_filePos fpa1_rdfGetNextTagPosn(void)
Definition: fpa1_rdf.c:336
int genBooleanChoiceCompArr[]
Definition: fpa1_boo.c:45
int octStrChoiceCompsArr[]
Definition: fpa1_str.c:48
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
#define NORM_COMPARISON_VALUE_TYPE
Definition: fpa1_typ.c:77
#define NORM_EVENT_TYPE
Definition: fpa1_typ.c:72
Contains functions to decode MHEG-5 ASN.1 Generic Boolean type.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
#define NORM_SEQUENCE_TYPE
Definition: fpa1_typ.c:54
#define NORM_EMULATED_EVENT_DATA
Definition: fpa1_typ.c:79
#define NORM_EVENT_SOURCE_TYPE
Definition: fpa1_typ.c:74
Contains functions to decode MHEG-5 ASN.1 XYPosition type.
#define NORM_NEW_REFERENCED_CONTENT
Definition: fpa1_typ.c:56
Contains functions to decode MHEG-5 ASN.1 Generic Octet String type.
Typedefs for script reading functions.
int pointSeqCompArr[]
Definition: fpa1_act.c:375
int newColourChoiceCompArr[]
Definition: fpa1_act.c:253
#define NORM_ACTION_SLOT_TYPE
Definition: fpa1_typ.c:76
unsigned short childCount[3]
Definition: fpa1_syn.h:59
#define OCTETSTRING
Definition: vpa1_tgs.h:41
Contains functions to decode MHEG-5 ASN.1 Generic Content Reference type.
#define NORM_SEQ_SIZE_OF_ELEMENTARY_ACTION
Definition: fpa1_typ.c:65
#define NORM_SEQ_SIZE_OF_OBJECT_REFERENCE
Definition: fpa1_typ.c:70
#define NORM_RATIONAL_TYPE
Definition: fpa1_typ.c:60
int genIntChoiceCompArr[]
Definition: fpa1_int.c:53
Contains functions to decode MHEG-5 ASN.1 Action class components.
int genOctStrChoiceCompArr[]
Definition: fpa1_str.c:53
#define NORM_EVENT_DATA_TYPE
Definition: fpa1_typ.c:73
#define NORM_GENERIC_CONTENT_REFERENCE
Definition: fpa1_typ.c:81
Contains macros for MHEG-5 ASN.1 tags and structures.
int fpa1_GenericDataCount
Definition: fpa1_rdf.c:66
#define NORM_NEW_CONTENT
Definition: fpa1_typ.c:86
#define NORM_PARAMETER_TYPE
Definition: fpa1_typ.c:89
int compValueChoiceCompArr[]
Definition: fpa1_act.c:240
Contains functions to decode MHEG-5 ASN.1 Ingredient class components.
int nextSceneSeqCompArr[]
Definition: fpa1_sce.c:77
#define NORM_SEQ_SIZE_OF_PARAMETER
Definition: fpa1_typ.c:68
int evtDatChoiceCompArr[]
Definition: fpa1_lnk.c:69
#define NORM_TOKEN_GROUP_ITEM_TYPE
Definition: fpa1_typ.c:62
int tokGrpItmsSeqCompArr[]
Definition: fpa1_tok.c:66
fpa1_syntaxList * fpa1_sequenceParse(unsigned short *, int *, vpa1_filePos)
Definition: fpa1_seq.c:65
int actSlotChoiceCompArr[]
Definition: fpa1_tok.c:71
Contains functions to decode MHEG-5 ASN.1 Object Reference, External Reference, Indirect Reference...
int extRefSeqCompArr[]
Definition: fpa1_obj.c:58
#define SEQUENCE
Definition: vpa1_tgs.h:44
#define NORM_NEW_TIMER
Definition: fpa1_typ.c:57
int newFontChoiceCompArr[]
Definition: fpa1_act.c:272
fpa1_syntaxList * fpa1_sequenceOfParse(unsigned short *, int, vpa1_filePos)
Definition: fpa1_seq.c:140
unsigned short dataTotal
Definition: fpa1_syn.h:60
#define NORM_INVALID_SEQ_TYPE
Definition: fpa1_typ.c:71
#define NORM_SEQ_SIZE_OF_ACTION_SLOT
Definition: fpa1_typ.c:64
#define NORM_GENERIC_INTEGER
Definition: fpa1_typ.c:82
Contains functions to decode MHEG-5 ASN.1 Scene class components.
int objRefChoiceCompArr[]
Definition: fpa1_obj.c:49
int emulEvtDatChoiceCompArr[]
Definition: fpa1_act.c:266
int fpa1_rdfGetTag(void)
Definition: fpa1_rdf.c:142
#define NORM_SEQ_SIZE_OF_POINT
Definition: fpa1_typ.c:69
#define NORM_CONN_TAG_OR_NULL_TYPE
Definition: fpa1_typ.c:78
int refCntSeqCompArr[]
Definition: fpa1_ing.c:53
#define NORM_XY_POSITION_TYPE
Definition: fpa1_typ.c:63
long vpa1_filePos
Definition: vpa1_sys.h:47
#define NORM_OBJECT_REFERENCE_TYPE
Definition: fpa1_typ.c:75
#define NORM_EXTERNAL_REFERENCE_TYPE
Definition: fpa1_typ.c:55
Contains functions used to parse MHEG-5 ASN.1 SEQUENCEs. SEQUENCEs have components in order...
int genObjRefChoiceCompArr[]
Definition: fpa1_obj.c:54
#define NORM_GENERIC_OBJECT_REFERENCE
Definition: fpa1_typ.c:83
#define NORM_POINT_TYPE
Definition: fpa1_typ.c:59
#define NORM_REFERENCED_CONTENT_TYPE
Definition: fpa1_typ.c:61
int connTagChoiceCompArr[]
Definition: fpa1_act.c:248
#define NORM_NEW_COLOUR
Definition: fpa1_typ.c:85
int fpa1_GroupParamCount
Definition: fpa1_rdf.c:68
Contains functions to decode MHEG-5 ASN.1 enumerated types.
fpa1_syntaxList * fpa1_choiceParse(int *)
Definition: fpa1_cho.c:67
int genContRefChoiceCompArr[]
Definition: fpa1_con.c:46