MHEG-5  19.3.0
MHEG-5 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] = {
49  MHEG5LEFT, MHEG5LEFT, MHEG5RIGHT, MHEG5UP, MHEG5DOWN
50 };
51 
52 #define MAXMH5SLIDERSTYLE 4
53 static MHEG5SliderStyle mh5SliderStyles[MAXMH5SLIDERSTYLE] = {
54  MHEG5NORMAL, MHEG5NORMAL, MHEG5THERMOMETER, MHEG5PROPORTIONAL
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));
85  slider->visible.ingredient.root.clazz = 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 
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.
Miscellaneous functions for decoding ASN.1 types.
Contains functions/structure used to do MHEG-5 ASN.1 syntax parsing.
Typedefs, macros used by all of parser. These may be duplicated elsewhere.
MHEG5Ingredient * asn1_createSlider(fpa1_syntaxList *listPtr)
Decodes Slider class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
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...
Functions to create a MHEG5Slider from a MHEG5 script (in the form of a list of fpa1_syntaxList struc...
typedefs etc for the whole object creation section.
Contains macros for MHEG-5 ASN.1 tags and structures.
Functions to create a MHEG5Interactible from a MHEG5 script (in the form of a list of fpa1_syntaxList...
asnErr asn1_decodeVisible(fpa1_syntaxList *listPtr, MHEG5Visible *visible)
Decodes Visible class. Refer to MHEG5 Specification (ISO/IEC 13522-2:1996), Appendix A...
Functions to create a MHEG5Visible from a MHEG5 script (in the form of a list of fpa1_syntaxList stru...