MHEG5  18.9.0
MHEG5 Documentation
asn1_createSlider.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 "mh5slider.h"
36 #include "asn1_createExtras.h"
37 #include "asn1_createVisible.h"
39 #include "asn1_createSlider.h"
40 
41 /*---constant definitions for this file--------------------------------------*/
42 
43 
44 /*---local typedef structs for this file-------------------------------------*/
45 
46 /*---local (static) variable declarations for this file----------------------*/
47 #define MAXMH5ORIENTATION 5
48 static MHEG5Orientation mh5Orientations[MAXMH5ORIENTATION] = {
50 };
51 
52 #define MAXMH5SLIDERSTYLE 4
53 static MHEG5SliderStyle mh5SliderStyles[MAXMH5SLIDERSTYLE] = {
55 };
56 
57 
58 
59 /*---local function definitions----------------------------------------------*/
60 
61 /*---global function definitions---------------------------------------------*/
62 
71 {
72  MHEG5Slider *slider;
73  asnErr errVal = 0;
74  fpa1_syntaxList *currItem;
75  MHEG5Int enumIndex;
76 
77  DPL5((">> asn1_decodeSlider(%X,%X)\n", listPtr));
78 
79  assert( listPtr );
80 
81  slider = (MHEG5Slider *)MHEG5getMem( sizeof(MHEG5Slider));
82  if (slider != NULL)
83  {
84  memset(slider, 0, sizeof(MHEG5Slider));
86  /* defaults */
87  slider->originalMinValue = 1;
88  slider->originalStepSize = 1;
89  slider->sliderStyle = MHEG5NORMAL;
90  /* Default value of InitialValue is specified to be MinValue. We cannot know
91  * MinValue yet, so set it to the default value of MinValue.
92  */
93  slider->initialValue = 1;
94 
95  /* searches current set of tags for local tags */
96  currItem = listPtr->children;
97  while (currItem != NULL)
98  {
99  /* most objects will have more than one local tag */
100  switch (currItem->tag)
101  {
102  case ORIENTATION:
103  enumIndex = currItem->data.intData;
104  /* prevent accessing outside array */
105  if ((enumIndex > 0) && (enumIndex < MAXMH5ORIENTATION))
106  {
107  slider->orientation = mh5Orientations[enumIndex];
108  }
109  else
110  {
111  errVal |= 0x01;
112  }
113  break;
114  case MAXVAL:
115  slider->originalMaxValue = currItem->data.intData;
116  break;
117  case MINVAL:
118  slider->originalMinValue = currItem->data.intData;
119 
120  /* The MHEG-5 IS has an irregularity in the slider class. It
121  * requires that the InitialValue exchanged attribute is
122  * initialised to the value of the MinValue exchanged attribute.
123  * This is the only place with the spec that one exchanged attribute
124  * is initialised with the value of another. The MinValue attribute
125  * (where encoded) will always be before the InitialValue attribute
126  * since an ASN.1 sequence is used. Since we know this we can
127  * initialise the InitialValue when the MinValue is decoded.
128  */
129  slider->initialValue = slider->originalMinValue;
130  break;
131  case INITVAL:
132  slider->initialValue = currItem->data.intData;
133  break;
134  case INITPOR:
135  slider->initialPortion = currItem->data.intData;
136  break;
137  case STEPSIZE:
138  slider->originalStepSize = currItem->data.intData;
139  break;
140  case SLSTYLE:
141  enumIndex = currItem->data.intData;
142  /* prevent accessing outside array */
143  if ((enumIndex > 0) && (enumIndex < MAXMH5SLIDERSTYLE))
144  {
145  slider->sliderStyle = mh5SliderStyles[enumIndex];
146  }
147  else
148  {
149  errVal |= 0x01;
150  }
151  break;
152  case SLIDEREFCOL:
153  errVal |= asn1_decodeColour(currItem, &slider->sliderRefColour);
154  break;
155  default:
156  break;
157  }
158  currItem = currItem->next;
159  }
160  /* decode inherited tags */
161  errVal |= asn1_decodeVisible(listPtr, &slider->visible);
162  errVal |= asn1_decodeInteractible(listPtr, &slider->interactible);
163 
164  if (errVal != ASN_NO_ERROR)
165  {
166  #if (DPLEVEL >= 2)
167  DPL2(("WARNING:[ASN.1] asn1_decodeSlider() errVal = %d\n", errVal));
168  #endif /* DPLEVEL >= 2 */
169  MHEG5freeMem( slider );
170  slider = NULL;
171  }
172  }
173 
174  DPL5(("<< asn1_decodeSlider() %X\n", slider));
175  return (MHEG5Ingredient *)slider;
176 }
177 
MHEG5Int initialValue
Definition: mh5slider.h:51
MHEG5Visible visible
Definition: mh5slider.h:46
asnErr asn1_decodeColour(fpa1_syntaxList *listPtr, MHEG5Colour *colour)
Decodes Colour class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Basis MHEG5 data types.
#define SLSTYLE
Definition: vpa1_tgs.h:157
#define MAXMH5ORIENTATION
#define STEPSIZE
Definition: vpa1_tgs.h:156
#define MAXVAL
Definition: vpa1_tgs.h:152
Miscellaneous functions for decoding ASN.1 types.
MHEG5Int originalStepSize
Definition: mh5slider.h:55
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
MHEG5Colour sliderRefColour
Definition: mh5slider.h:57
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
struct fpa1_syntaxItem * children
Definition: fpa1_syn.h:53
MHEG5Ingredient * asn1_createSlider(fpa1_syntaxList *listPtr)
Decodes Slider class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
#define ASN_NO_ERROR
Definition: asn1_sys.h:36
syntaxItemData data
Definition: fpa1_syn.h:57
asnErr asn1_decodeInteractible(fpa1_syntaxList *listPtr, MHEG5Interactible *interactible)
Decodes interactible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Implement the MHEG5 Slider Class. Slider Class. Defines the behaviour of sliders. Base class: Visible...
#define DPL5(x)
Definition: glue_debug.h:167
Functions to create a MHEG5Slider from a MHEG5 script (in the form of a list of fpa1_syntaxList struc...
MHEG5SliderStyle
Definition: mh5base.h:208
typedefs etc for the whole object creation section.
long MHEG5Int
Definition: mh5base.h:73
Contains macros for MHEG-5 ASN.1 tags and structures.
MHEG5Orientation
Definition: mh5base.h:203
Functions to create a MHEG5Interactible from a MHEG5 script (in the form of a list of fpa1_syntaxList...
#define MHEG5freeMem
Definition: glue_memory.h:94
#define MINVAL
Definition: vpa1_tgs.h:153
#define INITPOR
Definition: vpa1_tgs.h:155
#define DPL2(x)
Definition: glue_debug.h:185
asnErr asn1_decodeVisible(fpa1_syntaxList *listPtr, MHEG5Visible *visible)
Decodes Visible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
MHEG5Int originalMinValue
Definition: mh5slider.h:52
#define INITVAL
Definition: vpa1_tgs.h:154
Functions to create a MHEG5Visible from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...
MHEG5Ingredient ingredient
Definition: mh5visible.h:49
MHEG5Int originalMaxValue
Definition: mh5slider.h:53
MHEG5Orientation orientation
Definition: mh5slider.h:50
MHEG5Interactible interactible
Definition: mh5slider.h:47
int asnErr
Definition: asn1_sys.h:41
struct fpa1_syntaxItem * next
Definition: fpa1_syn.h:52
MHEG5Int initialPortion
Definition: mh5slider.h:54
#define SLIDEREFCOL
Definition: vpa1_tgs.h:99
#define ORIENTATION
Definition: vpa1_tgs.h:151
MHEG5Int intData
Definition: fpa1_syn.h:45
#define MAXMH5SLIDERSTYLE
MHEG5SliderStyle sliderStyle
Definition: mh5slider.h:56