MHEG5  18.9.0
MHEG5 Documentation
asn1_createProgram.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 "mh5program.h"
36 #include "asn1_createExtras.h"
37 #include "asn1_createIngredient.h"
38 #include "asn1_createProgram.h"
39 
40 /*---constant definitions for this file--------------------------------------*/
41 
42 
43 /*---local typedef structs for this file-------------------------------------*/
44 
45 /*---local (static) variable declarations for this file----------------------*/
46 
47 /*---local function definitions----------------------------------------------*/
48 
49 /*---global function definitions---------------------------------------------*/
50 
60 {
61  MHEG5Program *program;
62  fpa1_syntaxList *child;
63  asnErr errVal = ASN_NO_ERROR;
64 
65  DPL5((">> asn1_createProgram(%X,%d)\n", listPtr, clazz));
66 
67  assert(listPtr);
68 
69  program = (MHEG5Program *)MHEG5getMem( sizeof(MHEG5Program));
70  if (program)
71  {
72  /* program defaults */
73  memset(program, 0, sizeof(MHEG5Program));
74  program->initiallyAvailable = MHEG5TRUE;
75  program->ingredient.root.clazz = clazz;
76 
77  /* searches current set of tags for local tags */
78  listPtr = listPtr->children;
79  while (listPtr != NULL)
80  {
81  /* most objects will have more than one local tag */
82  switch (listPtr->tag)
83  {
84  case NAME:
85  errVal |= asn1_decodeOctetString(listPtr, &program->name);
86  break;
87  case INITAVAIL:
88  if (listPtr->data.boolData == 0)
89  {
90  program->initiallyAvailable = MHEG5FALSE;
91  }
92  break;
93 
94  /**** decode inherited tags from Ingredient *****/
96  /* skip the Group ref 'child', as this must always reference current group */
97  assert( listPtr->children );
98  child = listPtr->children->next;
99  if (child == NULL ||
100  child->data.intData < 1)
101  {
102  /* illegal to have zero or negative object numbers for an ingredient */
103  errVal |= 0x01;
104  }
105  else
106  {
107  program->ingredient.root.id = child->data.intData;
108  }
109  break;
110  case INTEGER: /* internal reference */
111  if (listPtr->data.intData < 1)
112  {
113  /* illegal to have zero or negative object numbers for an ingredient */
114  errVal |= 0x01;
115  }
116  else
117  {
118  program->ingredient.root.id = listPtr->data.intData;
119  }
120  break;
121  case SHARED:
122  if (listPtr->data.boolData != 0)
123  {
124  program->ingredient.shared = MHEG5TRUE;
125  }
126  break;
127 
128  default:
129  break;
130  }
131  listPtr = listPtr->next;
132  }
133 
134  /* Receiver defensive response - initialise InitiallyActive to false in case
135  * it is not encoded in the script (it should be according to section 14.1.1
136  * of ISC/IEC13522-5
137  */
138  /* Override the default value in the ingredient. Disabled is always 'True' in Program. */
140 
141  if (errVal != ASN_NO_ERROR)
142  {
143  #if (DPLEVEL >= 2)
144  DPL2(("WARNING:[ASN.1] asn1_createProgram() Fails\n"));
145  #endif /* DPLEVEL >= 2 */
146  MHEG5freeMem(program);
147  program = NULL;
148  }
149  }
150 
151 
152  DPL5(("<< asn1_createProgram() %X\n", program));
153 
154  return (MHEG5Ingredient *)program;
155 }
156 
Basis MHEG5 data types.
asnErr asn1_decodeOctetString(fpa1_syntaxList *listPtr, MHEG5String *decodedString)
decodes String type
Functions to create a MHEG5Ingredient from a MHEG5 script (in the form of a list of fpa1_syntaxList s...
MHEG5String name
Definition: mh5program.h:50
#define INTEGER
Definition: vpa1_tgs.h:40
MHEG5Bool shared
Definition: mh5ingredient.h:72
Miscellaneous functions for decoding ASN.1 types.
Implement the MHEG5 Program Class Defines means to handle execution of external pieces of procedural ...
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
MHEG5Final
Definition: mh5base.h:190
MHEG5Ingredient ingredient
Definition: mh5program.h:47
#define DPL5(x)
Definition: glue_debug.h:167
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
MHEG5Ingredient * asn1_createProgram(fpa1_syntaxList *listPtr, MHEG5Final clazz)
Decodes Program class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
#define SHARED
Definition: vpa1_tgs.h:108
MHEG5Bool initiallyAvailable
Definition: mh5program.h:51
#define INITAVAIL
Definition: vpa1_tgs.h:114
#define MHEG5freeMem
Definition: glue_memory.h:94
MHEG5Bool boolData
Definition: fpa1_syn.h:44
#define DPL2(x)
Definition: glue_debug.h:185
#define MHEG5TRUE
Definition: mh5base.h:49
MHEG5Bool initiallyStopped
Definition: mh5ingredient.h:71
MHEG5Int id
Definition: mh5root.h:48
int asnErr
Definition: asn1_sys.h:41
Functions to create a MHEG5Program from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
MHEG5Int intData
Definition: fpa1_syn.h:45
#define NAME
Definition: vpa1_tgs.h:113
#define MHEG5FALSE
Definition: mh5base.h:48