MHEG5  18.9.0
MHEG5 Documentation
asn1_createIngredient.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 "glue_debug.h"
35 #include "mh5base.h"
36 #include "mh5ingredient.h"
37 #include "asn1_createExtras.h"
38 #include "asn1_createIngredient.h"
39 
40 /*---constant definitions for this file--------------------------------------*/
41 
42 #define MHEG5CP_DEFAULT 127
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 static asnErr asn1_decodeContentBody(fpa1_syntaxList *listPtr, MHEG5ContentBody *contBody)
61 {
62  asnErr errVal = 0;
63  fpa1_syntaxList *currItem;
64 
65  DPL5((">> asn1_decodeContentBody(%X,%X)\n", listPtr, contBody));
66  assert(contBody);
67  assert(listPtr);
68 
69  currItem = listPtr->children;
70  assert(currItem);
71 
72  switch (currItem->tag)
73  {
74  case OCTETSTRING: /* Included */
75  errVal |= asn1_decodeOctetString(currItem, &contBody->ref.included);
76  contBody->referenced = MHEG5FALSE;
77  break;
78 
79  case REFERENCED_CONTENT_TYPE: /* referenced content */
80  currItem = currItem->children;
81  /* default value */
82  contBody->ref.referenced.priority = MHEG5CP_DEFAULT;
83  while (currItem != NULL)
84  {
85  switch (currItem->tag)
86  {
87  case OCTETSTRING:
88  contBody->ref.referenced.reference.len = currItem->data.stringData.len;
89  contBody->ref.referenced.reference.data = currItem->data.stringData.data;
90  currItem->data.stringData.len = 0;
91  currItem->data.stringData.data = NULL;
92  break;
93  case CONTSIZE: /* optional */
94  contBody->ref.referenced.size = currItem->data.intData;
95  break;
96  case CONTPRIO: /* defaults to 127 */
97  contBody->ref.referenced.priority = currItem->data.intData;
98  break;
99  default:
100  break;
101  }
102  currItem = currItem->next;
103  }
104  contBody->referenced = MHEG5TRUE;
105  break;
106 
107  default:
108  DPL2(("WARNING:[ASN.1] Unknown tag in contentBody\n"));
109  errVal |= 0x01;
110  }
111 
112 #if (DPLEVEL >= 2)
113  if (errVal != 0)
114  {
115  DPL2(("WARNING:[ASN.1] asn1_decodeContentBody() returns errVal = %d\n", errVal));
116  }
117 #endif /* DPLEVEL >= 2 */
118 
119  DPL5(("<< asn1_decodeContentBody() Returns %d\n", errVal));
120  return errVal;
121 }
122 
134 {
135  asnErr errVal = 0;
136  fpa1_syntaxList *currItem;
137 
138  DPL5((">> asn1_decodeIngredient(%X,%X)\n", listPtr, ingredient));
139 
140  assert(ingredient);
141  assert(listPtr);
142 
143  currItem = listPtr->children;
144 
145  /* defaults */
146  ingredient->shared = MHEG5FALSE;
147  ingredient->originalContent.ref.referenced.priority = MHEG5CP_DEFAULT;
148  ingredient->contentHook = MHEG5CHOOK_UNDEFINED;
149  ingredient->cloned = MHEG5FALSE;
150 
151  /* searches current set of tags for local tags */
152  while (currItem != NULL)
153  {
154  /* most objects will have more than one local tag */
155  switch (currItem->tag)
156  {
157  /* decode objectReference here rather than calling a decodeRoot function */
159  /* Ignore the GID as MHEG5Root has no element to store it */
160  /* Just get the object ID number */
161  if (currItem->children->next == NULL)
162  {
163  errVal |= 0x01;
164  }
165  else
166  {
167  ingredient->root.id = currItem->children->next->data.intData;
168  }
169  break;
170  case INTEGER: /* internal reference */
171  ingredient->root.id = currItem->data.intData;
172  break;
173 
174  case INITACTIVE:
175  if (currItem->data.boolData == 0)
176  {
177  ingredient->initiallyStopped = MHEG5TRUE;
178  }
179  break;
180  case CHOOK:
181  ingredient->contentHook = currItem->data.intData;
182  break;
183  case OCONTENT:
184  errVal |= asn1_decodeContentBody(currItem, &ingredient->originalContent);
185  break;
186  case SHARED:
187  if (currItem->data.boolData != 0)
188  {
189  ingredient->shared = MHEG5TRUE;
190  }
191  break;
192 
193  default:
194  break;
195  }
196  currItem = currItem->next;
197  }
198  if (ingredient->root.id < 1)
199  {
200  /* illegal to have zero or negative object numbers for an ingredient */
201  errVal |= 0x01;
202  }
203 
204 #if (DPLEVEL >= 2)
205  if (errVal != 0)
206  {
207  DPL2(("WARNING:[ASN.1] asn1_decodeIngredient() returns errVal = %d\n", errVal));
208  }
209 #endif /* DPLEVEL >= 2 */
210 
211  DPL5(("<< asn1_decodeIngredient() Returns %d\n", errVal));
212 
213  return errVal;
214 }
215 
Basis MHEG5 data types.
MHEG5Bool cloned
Definition: mh5ingredient.h:79
#define CONTPRIO
Definition: vpa1_tgs.h:110
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
MHEG5String stringData
Definition: fpa1_syn.h:46
Implementation of the Ingredient class.
Functions to create a MHEG5Ingredient from a MHEG5 script (in the form of a list of fpa1_syntaxList s...
#define INTEGER
Definition: vpa1_tgs.h:40
MHEG5Bool shared
Definition: mh5ingredient.h:72
Miscellaneous functions for decoding ASN.1 types.
Debug tracing.
#define INITACTIVE
Definition: vpa1_tgs.h:105
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
syntaxItemData data
Definition: fpa1_syn.h:57
#define DPL5(x)
Definition: glue_debug.h:167
#define OCTETSTRING
Definition: vpa1_tgs.h:41
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
#define MHEG5CP_DEFAULT
#define SHARED
Definition: vpa1_tgs.h:108
#define OCONTENT
Definition: vpa1_tgs.h:107
MHEG5Bool boolData
Definition: fpa1_syn.h:44
#define CONTSIZE
Definition: vpa1_tgs.h:109
MHEG5Byte * data
Definition: mh5base.h:85
#define DPL2(x)
Definition: glue_debug.h:185
#define MHEG5TRUE
Definition: mh5base.h:49
MHEG5Bool initiallyStopped
Definition: mh5ingredient.h:71
asnErr asn1_decodeIngredient(fpa1_syntaxList *listPtr, MHEG5Ingredient *ingredient)
Decodes Ingredient class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Int id
Definition: mh5root.h:48
int asnErr
Definition: asn1_sys.h:41
union sMHEG5ContentBody::@2 ref
MHEG5Int len
Definition: mh5base.h:84
MHEG5ContentBody originalContent
Definition: mh5ingredient.h:70
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
MHEG5Bool referenced
Definition: mh5ingredient.h:49
#define MHEG5CHOOK_UNDEFINED
Definition: mh5ingredient.h:35
MHEG5Int intData
Definition: fpa1_syn.h:45
MHEG5Int contentHook
Definition: mh5ingredient.h:69
#define CHOOK
Definition: vpa1_tgs.h:106
MHEG5String included
Definition: mh5ingredient.h:52
#define MHEG5FALSE
Definition: mh5base.h:48