MHEG5  18.9.0
MHEG5 Documentation
asn1_createExtras.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 "vpa1_sys.h"
29 #include "vpa1_tgs.h"
30 #include "fpa1_syn.h"
31 #include "asn1_sys.h"
32 
33 #include "mh5base.h"
34 #include "asn1_createExtras.h"
35 
36 /*---constant definitions for this file--------------------------------------*/
37 
38 
39 /*---local typedef structs for this file-------------------------------------*/
40 
41 /*---local (static) variable declarations for this file----------------------*/
42 
43 /*---local function definitions----------------------------------------------*/
44 
45 /*---global function definitions---------------------------------------------*/
46 
54 {
55  DPL5((">> asn1_decodeInteger(%X,%X)\n", listPtr, decodedInt));
56  assert(decodedInt);
57  if (listPtr == NULL)
58  {
59  DPL5(("<< asn1_decodeInteger() Returned early\n"));
60  *decodedInt = 0;
61  return 1;
62  }
63 
64  *decodedInt = listPtr->data.intData;
65 
66  DPL5(("<< asn1_decodeInteger() Returns 0\n"));
67  return 0;
68 }
69 
79 {
80  asnErr errVal = 0;
81 
82  DPL5((">> asn1_decodeBoolean(%X,%X)\n", listPtr, decodedBool));
83  assert(decodedBool);
84  if (listPtr == NULL)
85  {
86  DPL5(("<< asn1_decodeBoolean() Returned early\n"));
87  *decodedBool = MHEG5FALSE;
88  return 1;
89  }
90 
91  if (listPtr->data.boolData == 0)
92  {
93  *decodedBool = MHEG5FALSE;
94  }
95  else
96  {
97  /* 'true' is encoded as -1 in the ASN.1 */
98  *decodedBool = MHEG5TRUE;
99  }
100 
101 #if (DPLEVEL >= 2)
102  if (errVal != 0)
103  {
104  DPL2(("WARNING:[ASN.1] asn1_decodeBoolean() returns errVal = %d\n", errVal));
105  }
106 #endif /* DPLEVEL >= 2 */
107 
108  DPL5(("<< asn1_decodeBoolean() Returns %d\n", errVal));
109  return errVal;
110 }
111 
119  MHEG5String *decodedString)
120 {
121  DPL5((">> asn1_decodeOctetString(%X,%X)\n", listPtr, decodedString));
122  assert(decodedString);
123  if (listPtr == NULL)
124  {
125  DPL5(("<< asn1_decodeOctetString() Returned early\n"));
126  return 1;
127  }
128 
129  decodedString->len = listPtr->data.stringData.len;
130  decodedString->data = listPtr->data.stringData.data;
131  /* remove the original reference to the string
132  This allows us to delete any strings that are left at the end (as they
133  must therefore be unused)*/
134  listPtr->data.stringData.len = 0;
135  listPtr->data.stringData.data = NULL;
136 
137  DPL5(("<< asn1_decodeOctetString() Returns 0\n"));
138  return 0;
139 }
140 
150 {
151  asnErr errVal = 0;
152  fpa1_syntaxList *currItem;
153 
154  DPL5((">> asn1_decodeColour(%X,%X)\n", listPtr, colour));
155 
156  assert(colour);
157  assert(listPtr != NULL);
158 
159  currItem = listPtr->children;
160  assert(currItem != NULL);
161 
162  /* Either an integer or a string */
163  switch (currItem->tag)
164  {
165  case OCTETSTRING: /* absolute-colour is not a tag itself */
166  colour->value.s.len = currItem->data.stringData.len;
167  colour->value.s.data = currItem->data.stringData.data;
168  /* remove the original reference to the string
169  This allows us to delete any strings that are left at the end (as they
170  must therefore be unused)*/
171  currItem->data.stringData.len = 0;
172  currItem->data.stringData.data = NULL;
173  colour->type = MHEG5OCTETSTRING;
174  colour->indirect = MHEG5FALSE;
175  break;
176 #ifndef ASN1UKPROFILE
177  case INTEGER: /* colour-index not a tag */
178  colour->value.i = currItem->data.intData;
179  colour->type = MHEG5INT;
180  colour->direct = MHEG5TRUE;
181 #endif /* ASN1UKPROFILE */
182  default:
183  DPL2(("WARNING:[ASN.1] unexpected tag found in Colour class\n"));
184  errVal |= 0x01;
185  }
186 
187 #if (DPLEVEL >= 2)
188  if (errVal != 0)
189  {
190  DPL2(("WARNING:[ASN.1] asn1_decodeColour() Returns errVal = %d\n", errVal));
191  }
192 #endif /* DPLEVEL >= 2 */
193 
194  DPL5(("<< asn1_decodeColour() Returns %d\n", errVal));
195 
196  return errVal;
197 }
198 
U8BIT indirect
Definition: mh5base.h:149
Basis MHEG5 data types.
MHEG5String stringData
Definition: fpa1_syn.h:46
MHEG5Int i
Definition: mh5base.h:154
MHEG5String s
Definition: mh5base.h:156
#define INTEGER
Definition: vpa1_tgs.h:40
Miscellaneous functions for decoding ASN.1 types.
U16BIT type
Definition: mh5base.h:151
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
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
union MHEG5Generic::@6 value
#define DPL5(x)
Definition: glue_debug.h:167
#define OCTETSTRING
Definition: vpa1_tgs.h:41
typedefs etc for the whole object creation section.
long MHEG5Int
Definition: mh5base.h:73
Contains macros for MHEG-5 ASN.1 tags and structures.
MHEG5Bool boolData
Definition: fpa1_syn.h:44
short MHEG5Bool
Definition: mh5base.h:71
MHEG5Byte * data
Definition: mh5base.h:85
#define DPL2(x)
Definition: glue_debug.h:185
#define MHEG5TRUE
Definition: mh5base.h:49
int asnErr
Definition: asn1_sys.h:41
MHEG5Int len
Definition: mh5base.h:84
asnErr asn1_decodeInteger(fpa1_syntaxList *listPtr, MHEG5Int *decodedInt)
decodes Integer type
asnErr asn1_decodeColour(fpa1_syntaxList *listPtr, MHEG5Colour *colour)
Decodes Colour class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
asnErr asn1_decodeBoolean(fpa1_syntaxList *listPtr, MHEG5Bool *decodedBool)
decodes Boolean type MHEG5TRUE and MHEG5FALSE macros are used for consistency. will default to MHEG5T...
MHEG5Int intData
Definition: fpa1_syn.h:45
#define MHEG5FALSE
Definition: mh5base.h:48