MHEG-5  19.3.0
MHEG-5 Documentation
asn1_createVariable.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 "mh5group.h"
36 #include "mh5variable.h"
37 #include "asn1_createExtras.h"
38 #include "asn1_createIngredient.h"
39 #include "asn1_createGroup.h"
40 #include "asn1_createVariable.h"
41 
42 /*---constant definitions for this file--------------------------------------*/
43 
44 
45 /*---local typedef structs for this file-------------------------------------*/
46 
47 /*---local (static) variable declarations for this file----------------------*/
48 
49 /*---local function definitions----------------------------------------------*/
50 
51 /*---global function definitions---------------------------------------------*/
52 
60 {
61  asnErr errVal = 0;
62  if (ItemPtr != NULL)
63  {
64  if ((ItemPtr->tag == EXTERNAL_REFERENCE_TYPE) && (ItemPtr->children != NULL))
65  {
66  ItemPtr = ItemPtr->children;
67  if (ItemPtr->data.stringData.len == 0)
68  {
69  /* this should not happen, but assume ptr to group */
70  objRefVar->originalValueGid.len = 0;
71  objRefVar->originalValueGid.ptr.group = asn1_mainGroupPtr;
72  }
73  else
74  {
75  objRefVar->originalValueGid.len = ItemPtr->data.stringData.len;
76  objRefVar->originalValueGid.ptr.name = ItemPtr->data.stringData.data;
77 
78  ItemPtr->data.stringData.len = 0;
79  }
80 
81  /* remove the original reference to the string */
82  ItemPtr->data.stringData.data = NULL;
83 
84  ItemPtr = ItemPtr->next;
85  }
86  /* GID defaults to current scene or application */
87  else
88  {
89  objRefVar->originalValueGid.len = 0;
90  objRefVar->originalValueGid.ptr.group = asn1_mainGroupPtr;
91  }
92  if (ItemPtr != NULL)
93  {
94  objRefVar->originalValueId = ItemPtr->data.intData;
95  }
96  else
97  {
98  errVal |= 0x01;
99  }
100  }
101  else
102  {
103  errVal |= 0x01;
104  }
105  return errVal;
106 }
107 
115 {
116  asnErr errVal = 0;
117  fpa1_syntaxList *child;
118 
119  assert(listPtr);
120  assert(var);
121 
122  /* searches current set of tags for local tags */
123  listPtr = listPtr->children;
124  while (listPtr != NULL)
125  {
126  switch (listPtr->tag)
127  {
128  case OVALUE:
129  child = listPtr->children;
130  if (child != NULL)
131  {
132  switch (var->root.clazz)
133  {
134  case MHEG5BOOLEANVARIABLE:
135  if (child->data.boolData)
136  ((MHEG5BooleanVariable *)var)->originalValue = MHEG5TRUE;
137  break;
138 
139  case MHEG5INTEGERVARIABLE:
140  ((MHEG5IntegerVariable *)var)->originalValue = child->data.intData;
141  break;
142 
143  case MHEG5OCTETSTRINGVARIABLE:
144  ((MHEG5OctetStringVariable *)var)->originalValue = child->data.stringData;
145  /* remove the original reference to the string */
146  child->data.stringData.len = 0;
147  child->data.stringData.data = NULL;
148  break;
149 
150  case MHEG5CONTENTREFVARIABLE:
151  if (child->tag == CONTREF)
152  {
153  ((MHEG5ContentVariable *)var)->originalContentData = child->data.stringData;
154  /* remove the original reference to the string */
155  child->data.stringData.len = 0;
156  child->data.stringData.data = NULL;
157  }
158  break;
159 
160  case MHEG5OBJECTREFVARIABLE:
161  if (child->tag == OBJREF)
162  {
163  errVal |= asn1_decodeObjRefVariable( child->children, (MHEG5ObjectRefVariable *)var );
164  }
165  break;
166  default:;
167  }
168  }
169  break;
170 
171  /**** decode inherited tags from Ingredient *****/
172  case EXTERNAL_REFERENCE_TYPE:
173  /* skip the Group ref 'child', as this must always reference current group */
174  assert( listPtr->children );
175  child = listPtr->children->next;
176  if (child == NULL ||
177  child->data.intData < 1)
178  {
179  /* illegal to have zero or negative object numbers for an ingredient */
180  errVal |= 0x01;
181  }
182  else
183  {
184  var->root.id = child->data.intData;
185  }
186  break;
187  case INTEGER: /* internal reference */
188  if (listPtr->data.intData < 1)
189  {
190  /* illegal to have zero or negative object numbers for an ingredient */
191  errVal |= 0x01;
192  }
193  else
194  {
195  var->root.id = listPtr->data.intData;
196  }
197  break;
198  case INITACTIVE:
199  if (listPtr->data.boolData == 0)
200  {
201  var->initiallyStopped = MHEG5TRUE;
202  }
203  break;
204  case SHARED:
205  if (listPtr->data.boolData != 0)
206  {
207  var->shared = MHEG5TRUE;
208  }
209  break;
210  default:;
211  }
212  listPtr = listPtr->next;
213  }
214  return errVal;
215 }
216 
226 {
227  MHEG5BooleanVariable *boolVariable;
228 
229  boolVariable = (MHEG5BooleanVariable *) MHEG5getMem( sizeof(MHEG5BooleanVariable));
230  if (boolVariable)
231  {
232  memset(boolVariable, 0, sizeof(MHEG5BooleanVariable));
233  boolVariable->ingredient.root.clazz = MHEG5BOOLEANVARIABLE;
234 
235  if (asn1_decodeVariable( listPtr, &boolVariable->ingredient ) != ASN_NO_ERROR)
236  {
237  #if (DPLEVEL >= 2)
238  DPL2(("WARNING:[ASN.1] asn1_createIntegerVariable() fails\n"));
239  #endif /* DPLEVEL >= 2 */
240  MHEG5freeMem( boolVariable );
241  boolVariable = NULL;
242  }
243  }
244 
245  return (MHEG5Ingredient *)boolVariable;
246 }
247 
257 {
258  MHEG5IntegerVariable *integerVariable;
259 
260  integerVariable = (MHEG5IntegerVariable *) MHEG5getMem( sizeof(MHEG5IntegerVariable));
261  if (integerVariable)
262  {
263  /* defaults */
264  memset(integerVariable, 0, sizeof(MHEG5IntegerVariable));
265  integerVariable->ingredient.root.clazz = MHEG5INTEGERVARIABLE;
266 
267  if (asn1_decodeVariable(listPtr, &integerVariable->ingredient) != ASN_NO_ERROR)
268  {
269  #if (DPLEVEL >= 2)
270  DPL2(("WARNING:[ASN.1] asn1_createIntegerVariable() fails\n"));
271  #endif /* DPLEVEL >= 2 */
272  MHEG5freeMem( integerVariable );
273  integerVariable = NULL;
274  }
275  }
276  return (MHEG5Ingredient *)integerVariable;
277 }
278 
288 {
289  MHEG5OctetStringVariable *octStrVar;
290 
291  octStrVar = (MHEG5OctetStringVariable *) MHEG5getMem( sizeof(MHEG5OctetStringVariable));
292  if (octStrVar)
293  {
294  /* defaults */
295  memset(octStrVar, 0, sizeof(MHEG5OctetStringVariable));
296  octStrVar->ingredient.root.clazz = MHEG5OCTETSTRINGVARIABLE;
297 
298  if (asn1_decodeVariable(listPtr, &octStrVar->ingredient) != ASN_NO_ERROR)
299  {
300  #if (DPLEVEL >= 2)
301  DPL2(("WARNING:[ASN.1] asn1_createOctetStringVariable() Fails\n"));
302  #endif /* DPLEVEL >= 2 */
303  MHEG5freeMem( octStrVar );
304  octStrVar = NULL;
305  }
306  }
307 
308  return (MHEG5Ingredient *)octStrVar;
309 }
310 
320 {
321  MHEG5ObjectRefVariable *objRefVar;
322 
323  objRefVar = (MHEG5ObjectRefVariable *) MHEG5getMem( sizeof(MHEG5ObjectRefVariable));
324  if (objRefVar)
325  {
326  /* defaults */
327  memset(objRefVar, 0, sizeof(MHEG5ObjectRefVariable));
328  objRefVar->ingredient.root.clazz = MHEG5OBJECTREFVARIABLE;
329 
330  if (asn1_decodeVariable(listPtr, &objRefVar->ingredient) != ASN_NO_ERROR)
331  {
332  #if (DPLEVEL >= 2)
333  DPL2(("WARNING:[ASN.1] asn1_createObjectRefVariable() Fails\n"));
334  #endif /* DPLEVEL >= 2 */
335  MHEG5freeMem( objRefVar );
336  objRefVar = NULL;
337  }
338  }
339 
340  DPL5(("<< asn1_createObjectRefVariable() %X\n", objRefVar));
341 
342  return (MHEG5Ingredient *)objRefVar;
343 }
344 
354 {
355  MHEG5ContentVariable *contentVar;
356 
357  contentVar = (MHEG5ContentVariable *) MHEG5getMem( sizeof(MHEG5ContentVariable));
358  if (contentVar)
359  {
360  /* defaults */
361  memset(contentVar, 0, sizeof(MHEG5ContentVariable));
362  contentVar->ingredient.root.clazz = MHEG5CONTENTREFVARIABLE;
363 
364  if (asn1_decodeVariable( listPtr, &contentVar->ingredient ) != ASN_NO_ERROR)
365  {
366  #if (DPLEVEL >= 2)
367  DPL2(("WARNING:[ASN.1] asn1_createContentVariable() Fails\n"));
368  #endif /* DPLEVEL >= 2 */
369  MHEG5freeMem(contentVar);
370  contentVar = NULL;
371  }
372  }
373 
374  return (MHEG5Ingredient *)contentVar;
375 }
376 
MHEG5Ingredient * asn1_createContentVariable(fpa1_syntaxList *listPtr)
Decodes ContentVariable class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A, section [A.19] for details of ASN.1 representation.
Basis MHEG5 data types.
Functions to create a MHEG5Ingredient from a MHEG5 script (in the form of a list of fpa1_syntaxList s...
Miscellaneous functions for decoding ASN.1 types.
Functions to create a MHEG5Variable from a MHEG5 script (in the form of a list of fpa1_syntaxList str...
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Functions to create a MHEG5Group from a MHEG5 script (in the form of a list of fpa1_syntaxList struct...
MHEG5Ingredient * asn1_createIntegerVariable(fpa1_syntaxList *listPtr)
Decodes IntegerVariable class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A, section [A.16] for details of ASN.1 representation.
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
Implementation of the Group class Description Defines the structure and behaviour of objects used as ...
MHEG5Ingredient * asn1_createBooleanVariable(fpa1_syntaxList *listPtr)
Decodes BooleanVariable class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A, section [A.15] for details of ASN.1 representation.
MHEG5Ingredient * asn1_createObjectRefVariable(fpa1_syntaxList *listPtr)
Decodes ObjectRefVariable class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A, section [A.18] for details of ASN.1 representation.
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
asnErr asn1_decodeObjRefVariable(fpa1_syntaxList *ItemPtr, MHEG5ObjectRefVariable *objRefVar)
Decodes Object Ref Variable class.
MHEG5Ingredient * asn1_createOctetStringVariable(fpa1_syntaxList *listPtr)
Decodes OctetStringVariable class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A, section [A.17] for details of ASN.1 representation.
asnErr asn1_decodeVariable(fpa1_syntaxList *listPtr, MHEG5Ingredient *var)
Decodes Variable classes.