MHEG5  18.9.0
MHEG5 Documentation
asn1_createListGroup.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 "mh5listgroup.h"
36 #include "mh5visible.h"
37 #include "asn1_createExtras.h"
38 #include "asn1_createVisible.h"
39 #include "asn1_createTokenGroup.h"
40 #include "asn1_createListGroup.h"
41 
42 
43 /*---constant definitions for this file--------------------------------------*/
44 
45 
46 /*---local typedef structs for this file-------------------------------------*/
47 
48 /*---local (static) variable declarations for this file----------------------*/
49 
50 /*---local function definitions----------------------------------------------*/
51 
52 /*---global function definitions---------------------------------------------*/
53 
62 static asnErr asn1_decodePosList(fpa1_syntaxList *listPtr, MHEG5ListGroup *listGroup)
63 {
64  asnErr errVal = 0;
65  fpa1_syntaxList *currItem;
66  MHEG5Int x, y;
67 
68  DPL5((">> asn1_decodePosList(%X,%X)\n", listPtr, listGroup));
69 
70  assert(listGroup);
71  if (listPtr == NULL)
72  {
73  DPL5(("<< asn1_decodePosList() Returned early\n"));
74  return 1;
75  }
76 
77  currItem = listPtr->children;
78 
79  while (currItem != NULL)
80  {
81  if (currItem->tag == XY_POSITION_TYPE)
82  {
83  if ((currItem->children != NULL) && (currItem->children->next != NULL))
84  {
85  x = currItem->children->data.intData;
86  y = currItem->children->next->data.intData;
87  }
88  else
89  {
90  /* safe default values */
91  x = 0;
92  y = 0;
93  }
94  MHEG5listGroupAddPosition(listGroup, x, y);
95  }
96  else
97  {
98  DPL2(("WARNING:[ASN.1] failed to decode a list group original positions list\n"));
99  errVal |= 0x01;
100  }
101  currItem = currItem->next;
102  }
103 
104 #if (DPLEVEL >= 2)
105  if (errVal != 0)
106  {
107  DPL2(("WARNING:[ASN.1] asn1_decodePosList() returns errVal = %d\n", errVal));
108  }
109 #endif /* DPLEVEL >= 2 */
110 
111  DPL5(("<< asn1_decodePosList() Returns %d\n", errVal));
112  return errVal;
113 }
114 
123 {
124  MHEG5ListGroup *listGroup;
125  asnErr errVal = 0;
126  fpa1_syntaxList *currItem;
127  U32BIT itm_cnt, slt_cnt, size;
128 
129  assert( listPtr );
130 
131  itm_cnt = asn1_getTokenGroupItemCount( listPtr->children );
132  slt_cnt = itm_cnt & 0xffff;
133  itm_cnt >>= 16;
134 
135  size = sizeof(MHEG5ListGroup) +
136  (itm_cnt * sizeof(MHEG5TokenSlot)) +
137  (slt_cnt * sizeof(MHEG5ActionList));
138 
139  listGroup = (MHEG5ListGroup *)MHEG5getMem( size );
140  if (listGroup != NULL)
141  {
142  /* defaults */
143  memset( listGroup, 0, size );
145  listGroup->tokenGroup.tokens_num = itm_cnt;
146  listGroup->tokenGroup.tokens_ptr = (MHEG5TokenSlot *)(listGroup + 1);
147 
148  /* searches current set of tags for local tags */
149  currItem = listPtr->children;
150  while (currItem != NULL)
151  {
152  /* most objects will have more than one local tag */
153  switch (currItem->tag)
154  {
155  case POSITIONS:
156  errVal |= asn1_decodePosList(currItem, listGroup);
157  break;
158  case WRAP:
159  listGroup->wrapAround = (currItem->data.boolData == 0) ? MHEG5FALSE : MHEG5TRUE;
160  break;
161  case MULTIPLE:
162  listGroup->multipleSelection = (currItem->data.boolData == 0) ? MHEG5FALSE : MHEG5TRUE;
163  break;
164  default:
165  break;
166  }
167  currItem = currItem->next;
168  }
169  /* decode inherited tags */
170  errVal |= asn1_decodeTokenGroup(listPtr, &listGroup->tokenGroup);
171  if (errVal != ASN_NO_ERROR)
172  {
173  #if (DPLEVEL >= 2)
174  DPL2(("WARNING:[ASN.1] asn1_decodeListGroup() returns errVal = %d\n", errVal));
175  #endif /* DPLEVEL >= 2 */
176  MHEG5freeMem( listGroup );
177  listGroup = NULL;
178  }
179  }
180 
181  DPL5(("<< asn1_decodeListGroup() Returns %d\n", errVal));
182  return (MHEG5Ingredient *)listGroup;
183 }
184 
void MHEG5listGroupAddPosition(MHEG5ListGroup *listGroup, MHEG5Int x, MHEG5Int y)
Adds a new cell position to the ListGroup.
Definition: mh5listgroup.c:267
Basis MHEG5 data types.
MHEG5TokenGroup tokenGroup
Definition: mh5listgroup.h:66
#define MULTIPLE
Definition: vpa1_tgs.h:124
Miscellaneous functions for decoding ASN.1 types.
#define POSITIONS
Definition: vpa1_tgs.h:122
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
#define MHEG5getMem
Definition: glue_memory.h:93
MHEG5Final clazz
Definition: mh5root.h:55
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
#define ASN_NO_ERROR
Definition: asn1_sys.h:36
syntaxItemData data
Definition: fpa1_syn.h:57
MHEG5Bool multipleSelection
Definition: mh5listgroup.h:71
MHEG5Int tokens_num
Definition: mh5tokengroup.h:65
Functions to create a MHEG5ListGroup from a MHEG5 script (in the form of a list of fpa1_syntaxList st...
#define DPL5(x)
Definition: glue_debug.h:167
typedefs etc for the whole object creation section.
MHEG5Bool wrapAround
Definition: mh5listgroup.h:70
long MHEG5Int
Definition: mh5base.h:73
Contains macros for MHEG-5 ASN.1 tags and structures.
Implement the MHEG5 ListGroup Class Defines the location of list elements on the screen and theire in...
U32BIT asn1_getTokenGroupItemCount(fpa1_syntaxList *listPtr)
Gets total count of TG Items and Action Slots.
#define MHEG5freeMem
Definition: glue_memory.h:94
MHEG5Bool boolData
Definition: fpa1_syn.h:44
MHEG5TokenSlot * tokens_ptr
Definition: mh5tokengroup.h:66
Implement the MHEG5 Visible Class Defines the behaviour of Presentables that have a visual representa...
#define DPL2(x)
Definition: glue_debug.h:185
#define MHEG5TRUE
Definition: mh5base.h:49
#define WRAP
Definition: vpa1_tgs.h:123
Functions to create a MHEG5Visible from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...
MHEG5Ingredient ingredient
Definition: mh5tokengroup.h:61
struct sMHEG5ListGroup MHEG5ListGroup
MHEG5Ingredient * asn1_createListGroup(fpa1_syntaxList *listPtr)
Decodes ListGroup class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
int asnErr
Definition: asn1_sys.h:41
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
Functions to create a MHEG5TokenGroup from a MHEG5 script (in the form of a list of fpa1_syntaxList s...
asnErr asn1_decodeTokenGroup(fpa1_syntaxList *listPtr, MHEG5TokenGroup *tokenGrp)
Decodes TokenGroup class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Int intData
Definition: fpa1_syn.h:45
#define MHEG5FALSE
Definition: mh5base.h:48
uint32_t U32BIT
Definition: techtype.h:86