MHEG-5  19.3.0
MHEG-5 Documentation
asn1_createLink.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 "mh5link.h"
36 #include "asn1_createAction.h"
37 #include "asn1_createExtras.h"
38 #include "asn1_createIngredient.h"
39 #include "asn1_createGroup.h"
40 #include "asn1_createLink.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  Events - IMPORTANT: Do not modify the Sequence - it is very important
50  for the ASN1LinkDecoder that the eventTypes Array is NOT modified!!!
51  */
52 #define EVENTTYPESSIZE 35
53 static MHEG5EventType eventTypes[EVENTTYPESSIZE] = {
54  MHEG5NONEEVENT, MHEG5ISAVAILABLE, MHEG5CONTENTAVAILABLE, MHEG5ISDELETED, MHEG5ISRUNNING,
55  MHEG5ISSTOPPED, MHEG5USERINPUT, MHEG5ANCHORFIRED, MHEG5TIMERFIRED, MHEG5ASYNCHSTOPPED,
56  MHEG5INTERACTIONCOMPLETED, MHEG5TOKENMOVEDFROM, MHEG5TOKENMOVEDTO, MHEG5STREAMEVENT,
57  MHEG5STREAMPLAYING, MHEG5STREAMSTOPPED, MHEG5COUNTERTRIGGER, MHEG5HIGHLIGHTON,
58  MHEG5HIGHLIGHTOFF, MHEG5CURSORENTER, MHEG5CURSORLEAVE, MHEG5ISSELECTED, MHEG5ISDESELECTED,
59  MHEG5TESTEVENT, MHEG5FIRSTITEMPRESENTED, MHEG5LASTITEMPRESENTED, MHEG5HEADITEMS,
60  MHEG5TAILITEMS, MHEG5ITEMSELECTED, MHEG5ITEMDESELECTED, MHEG5ENTRYFIELDFULL,
61  MHEG5ENGINEEVENT, MHEG5FOCUSMOVED, MHEG5SLIDERVALUECHANGED,
62  MHEG5LASTEVENT
63 };
64 
65 /*---local function definitions----------------------------------------------*/
66 
67 /*---global function definitions---------------------------------------------*/
68 
69 MHEG5EventType asn1_decodeEventType( MHEG5Int evt_val )
70 {
71  /* if the event value is invalid, default it to MHEG5LASTEVENT */
72  if ((evt_val <= 0) || (evt_val >= EVENTTYPESSIZE))
73  {
74  evt_val = EVENTTYPESSIZE - 1;
75  }
76  return eventTypes[evt_val];
77 }
78 
86 static asnErr asn1_decodeLinkCondition(fpa1_syntaxList *listPtr, MHEG5Link *link)
87 {
88  asnErr errVal = 0;
89  fpa1_syntaxList *currItem;
90 
91  DPL5((">> asn1_decodeLinkCondition(%X,%X)\n", listPtr, link));
92  assert(link);
93  assert(listPtr);
94 
95  currItem = listPtr->children;
96 
97  while (currItem != NULL)
98  {
99  switch (currItem->tag)
100  {
101  case EVENT_SOURCE_TYPE: /* Object Reference */
102  /* Either an Integer stored in the EVENT_SOURCE_TYPE itself
103  or an OctetString + Integer pair */
104  if (currItem->dataType == 2) /* Integer - Internal ref */
105  {
106  link->source = currItem->data.intData;
107  link->sourcegid.ptr.group = asn1_mainGroupPtr;
108  }
109  else /* External Ref */
110  {
111  if (currItem->children != NULL)
112  {
113  MHEG5String name;
114  errVal |= asn1_decodeOctetString(currItem->children, &name);
115  link->sourcegid.len = name.len;
116  link->sourcegid.ptr.name = name.data;
117  if (currItem->children->next != NULL)
118  link->source = currItem->children->next->data.intData;
119  else
120  errVal |= 0x01;
121  }
122  else
123  {
124  errVal |= 0x01;
125  }
126  }
127  break;
128  case EVENT_TYPE: /* Enumeration */
129  link->eventType = asn1_decodeEventType( currItem->data.intData );
130  existsLinkCount[link->eventType]++;
131  break;
132  case EVENT_DATA_TYPE: /* choice */
133  switch (currItem->dataType)
134  {
135  case 1: /* boolean */
136  link->eventData.value.b = (currItem->data.boolData == 0) ? MHEG5FALSE : MHEG5TRUE;
137  link->eventData.indirect = MHEG5FALSE;
138  link->eventData.type = (U16BIT)MHEG5BOOL;
139  break;
140  case 2: /* Integer */
141  link->eventData.value.i = currItem->data.intData;
142  link->eventData.indirect = MHEG5FALSE;
143  link->eventData.type = (U16BIT)MHEG5INT;
144  break;
145  case 4: /* OctetString */
146  link->eventData.value.i = LNK_RegisterString( currItem->data.stringData );
147  currItem->data.stringData.len = 0;
148  currItem->data.stringData.data = NULL;
149  link->eventData.indirect = MHEG5TRUE;
150  link->eventData.type = (U16BIT)MHEG5INT;
151  break;
152  default:
153  DPL2(("WARNING:[ASN.1] Unexpected tag in LinkCondition\n"));
154  errVal |= 0x01;
155  break;
156  }
157  break;
158  default:
159  break;
160  }
161  currItem = currItem->next;
162  }
163 
164 #if (DPLEVEL >= 2)
165  if (errVal != 0)
166  {
167  DPL2(("WARNING:[ASN.1] asn1_decodeLinkCondition() returns errVal = %d\n", errVal));
168  }
169 #endif /* DPLEVEL >= 2 */
170 
171  DPL5(("<< asn1_decodeLinkCondition() Returns %d\n", errVal));
172  return errVal;
173 }
174 
183 {
184  MHEG5Link *link;
185  asnErr errVal = 0;
186  fpa1_syntaxList *currItem;
187  fpa1_syntaxList *child;
188 
189  DPL5((">> asn1_createLink(%X,%X)\n", listPtr, link));
190 
191  assert(listPtr);
192 
193  link = (MHEG5Link *)MHEG5getMem( sizeof(MHEG5Link));
194  if (link)
195  {
196  memset(link, 0, sizeof(MHEG5Link));
197  link->ingredient.root.clazz = MHEG5LINK;
198  /* default link condition *
199  link->source = 0;
200  link->sourcegid.len = 0;
201  link->sourcegid.ptr.group = 0;
202  link->eventData.type = MHEG5NONE;
203  */
204  link->eventData.indirect = MHEG5FALSE;
205 
206  /* searches current set of tags for local tags */
207  currItem = listPtr->children;
208  while (currItem != NULL)
209  {
210  /* most objects will have more than one local tag */
211  switch (currItem->tag)
212  {
213  case LINKCOND:
214  errVal |= asn1_decodeLinkCondition(currItem, link);
215  break;
216  case EFFECT:
217  asn1_decodeActions( currItem, &link->linkEffect );
218  break;
219 
220  /**** decode inherited tags from Ingredient *****/
221  case EXTERNAL_REFERENCE_TYPE:
222  /* skip the Group ref 'child', as this must always reference current group */
223  assert( currItem->children );
224  child = currItem->children->next;
225  if (child == NULL ||
226  child->data.intData < 1)
227  {
228  /* illegal to have zero or negative object numbers for an ingredient */
229  errVal |= 0x01;
230  }
231  else
232  {
233  link->ingredient.root.id = child->data.intData;
234  }
235  break;
236  case INTEGER: /* internal reference */
237  if (currItem->data.intData < 1)
238  {
239  /* illegal to have zero or negative object numbers for an ingredient */
240  errVal |= 0x01;
241  }
242  else
243  {
244  link->ingredient.root.id = currItem->data.intData;
245  }
246  break;
247  case INITACTIVE:
248  if (currItem->data.boolData == 0)
249  {
250  link->ingredient.initiallyStopped = MHEG5TRUE;
251  }
252  break;
253  case SHARED:
254  if (currItem->data.boolData != 0)
255  {
256  link->ingredient.shared = MHEG5TRUE;
257  }
258  break;
259 
260  default:
261  break;
262  }
263  currItem = currItem->next;
264  }
265  /* decode inherited tags */
266  if (errVal != ASN_NO_ERROR)
267  {
268  #if (DPLEVEL >= 2)
269  DPL2(("WARNING:[ASN.1] asn1_createLink() Fails\n"));
270  #endif /* DPLEVEL >= 2 */
271  MHEG5freeMem(link);
272  link = NULL;
273  }
274  }
275 
276  DPL5(("<< asn1_createLink() Returns %d\n", link));
277 
278  return (MHEG5Ingredient *)link;
279 }
280 
Basis MHEG5 data types.
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
Functions to create a MHEG5Action from a MHEG5 script (in the form of a list of fpa1_syntaxList struc...
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.
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...
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
void asn1_decodeActions(fpa1_syntaxList *listPtr, MHEG5ActionList *p_actions)
Decodes action class Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...