MHEG5  18.9.0
MHEG5 Documentation
mh5audio.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  *******************************************************************************/
33 /*---includes for this file--------------------------------------------------*/
34 #include "mh5audio.h"
35 #include "mh5application.h"
36 #include "mh5object.h" /* for actions */
37 #include "mh5variable.h" /* for actions */
38 #include "mh5memory.h" /* for constructor/destructor */
39 #include "mh5display.h" /* for actions */
40 #include "mh5queue.h"
41 #include "mh5debug.h"
42 
43 #ifdef MH5PRINTOUT
44 #include <string.h>
45 #endif /* #ifdef MH5PRINTOUT */
46 
47 /*---constant definitions for this file--------------------------------------*/
48 
49 
50 /*---local typedef structs for this file-------------------------------------*/
51 
52 /*---local (static) variable declarations for this file----------------------*/
53 
54 /*---local function definitions----------------------------------------------*/
55 
56 /*---global function definitions---------------------------------------------*/
57 
63 /*
64  Debug
65  */
66 #ifdef MH5PRINTOUT
67 
68 void MHEG5audioPrint(MHEG5Audio *audio, char *out)
69 {
70  MHEG5ingredientPrint(&audio->ingredient, out);
71  MHEG5indent(out);
72  MHEG_PRINT(out, ":ComponentTag ");
73  MHEG5intPrint(audio->componentTag, out);
74  MHEG5newLine(out);
75  if (audio->originalVolume != 0)
76  {
77  MHEG5indent(out);
78  MHEG_PRINT(out, ":Volume ");
79  MHEG5intPrint(audio->originalVolume, out);
80  MHEG5newLine(out);
81  }
82 /*
83  MHEG5indent(out);
84  MHEG_PRINT(out,"// Volume:\t");
85  MHEG5intPrint(audio->volume,out);
86  MHEG5newLine(out);
87  */
88 }
89 
90 #endif
91 
98 {
99  assert(audio);
100 
102 }
103 
112 {
113  assert(audio);
114 
116 }
117 
128 {
129  assert(audio);
130 
131  audio->volume = audio->originalVolume;
132 
134 }
135 
145 {
146  assert(audio);
147 
148  if (!audio->ingredient.root.runningStatus)
149  {
150  if (!audio->ingredient.root.availabilityStatus)
151  {
152  MHEG5audioPrepare( audio );
153  }
154 
155  /* If the parent stream is running, start presenting the audio object */
156  if (audio->parent->ingredient.root.runningStatus)
157  {
158  MHEG5displayAudioPlay(audio);
159  }
160 
161  /* Could call the base class activation behaviour, but */
162  MHEG5ingredientActivate(&audio->ingredient); /*<- does nothing, so don't bother */
163 
165  MHEG5sendSync((MHEG5Root *) audio, MHEG5ISRUNNING, 0);
166  }
167 }
168 
178 {
179  assert(audio);
180 
181  if (audio->ingredient.root.runningStatus)
182  {
183  /* Call the base class deactivation behaviour */
185 
186  if ((MHEG5getCurrentApplication() == 0) ||
187  (MHEG5getCurrentApplication()->streamContinuanceFlag == MHEG5FALSE))
188  {
189  /* Stop the audio decoder */
190  if (audio->parent->ingredient.root.runningStatus)
191  {
193  }
194  }
196  }
197 }
198 
206 {
207  assert(audio);
209  MHEG5displayAudioDestroy( audio );
210 }
211 
222 {
223  MHEG5Int volume = 0;
224 
225  assert(target);
226 
227  if (target->clazz != MHEG5AUDIO)
228  {
229  return MHEG5ERR_WRONGTARGET;
230  }
231 
232  if (!params)
233  {
235  }
236  MHEG5resolveGenericInteger(params, &volume);
237 
238  ((MHEG5Audio *) target)->volume = volume;
239  MHEG5displaySetVolume(volume);
240 
241  return MHEG5ERR_NOERROR;
242 }
243 
254 {
255  MHEG5Root *vVar = 0;
256 
257  assert(target);
258 
259  if (target->clazz != MHEG5AUDIO)
260  {
261  return MHEG5ERR_WRONGTARGET;
262  }
263 
264  if (!params)
265  {
267  }
268  MHEG5resolveORef(params, &vVar);
269  if (!vVar)
270  {
272  }
273  if (vVar->clazz != MHEG5INTEGERVARIABLE)
274  {
275  return MHEG5ERR_WRONGPARAM;
276  }
277  if (!vVar->runningStatus)
278  {
280  }
281 
282  ((MHEG5IntegerVariable *) vVar)->value = ((MHEG5Audio *) target)->volume;
283 
284  return MHEG5ERR_NOERROR;
285 }
286 
MHEG5Bool availabilityStatus
Definition: mh5root.h:52
void MHEG5audioDeactivate(MHEG5Audio *audio)
Apply the deactivation behaviour off the audio class. As this class has no own deactivation behaviour...
Definition: mh5audio.c:177
MHEG5Stream * parent
Definition: mh5audio.h:58
void MHEG5ingredientInit(MHEG5Ingredient *ingredient)
Initialise a ingredient object with default values.
MHEG5Int originalVolume
Definition: mh5audio.h:51
MHEG5Ingredient ingredient
Definition: mh5stream.h:65
MHEG5Int volume
Definition: mh5audio.h:55
MHEG5GList * MHEG5resolveGenericInteger(MHEG5GList *params, MHEG5Int *value)
Definition: mh5object.c:510
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5audioPrepare(MHEG5Audio *audio)
Apply the preparation behaviour off the audio class Apply the preparation behaviour off the audio cla...
Definition: mh5audio.c:127
void MHEG5ingredientDestruct(MHEG5Ingredient *ingredient)
Implementation of the Destruction behaviour Execute the following sequence of actions: ...
void MHEG5audioActivate(MHEG5Audio *audio)
Apply the activation behaviour off the audio class. Apply the activation behaviour of the base class...
Definition: mh5audio.c:144
void MHEG5ingredientActivate(MHEG5Ingredient *ingredient)
Implementation of Activate behaviour Inherrited from Root class.
void MHEG5audioInit(MHEG5Audio *audio)
<Function description>="">
Definition: mh5audio.c:97
void MHEG5audioDestruct(MHEG5Audio *audio)
Destruct an audio object.
Definition: mh5audio.c:205
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5displayAudioPlay(MHEG5Audio *audio)
Begin playback of the specified audio object.
Definition: mh5display.c:2150
MHEG5ErrorCode MHEG5getVolume(MHEG5Root *target, MHEG5GList *params)
Returns the volume of an Audio. Implementation of the GetVolume (VolumeVar) action of the audio class...
Definition: mh5audio.c:253
void MHEG5displaySetVolume(MHEG5Int volume)
Volume Control.
Definition: mh5display.c:2974
void MHEG5audioFree(MHEG5Audio *audio)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Definition: mh5audio.c:111
long MHEG5Int
Definition: mh5base.h:73
MHEG5ErrorCode MHEG5setVolume(MHEG5Root *target, MHEG5GList *params)
Change the volume of an audio. Implementation of the SetVolume (NewVolume) action of the audio class...
Definition: mh5audio.c:221
void MHEG5displayAudioStop(void)
Stops playback of the audio media decoder.
Definition: mh5display.c:2450
MHEG5ErrorCode
Definition: mh5base.h:222
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
#define MHEG5TRUE
Definition: mh5base.h:49
void MHEG5ingredientDeactivate(MHEG5Ingredient *ingredient)
Implementation of Deactivate behaviour Inherrited from Root class.
Implement functions to retrieve MHEG5objects by GroupID and ID.
void MHEG5ingredientPrepare(MHEG5Ingredient *ingredient)
Implementation of the Preparation behaviour Inherrited from Root class.
Implementation of the MHEG5 Application Class Defines a set of Ingredient objects, which are shared within an application scope. Base class: Group Subclasses: None Status: Concrete class.
Mheg5 logging and debug printing.
MHEG5Bool runningStatus
Definition: mh5root.h:51
redirection include
void MHEG5displayAudioDestroy(MHEG5Audio *audio)
Definition: mh5display.c:2581
MHEG5Ingredient ingredient
Definition: mh5audio.h:48
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
void MHEG5ingredientFree(MHEG5Ingredient *ingredient)
Free off all memory associated with the specified object, including any exchanged attributes and inte...
Implement the MHEG5 Audio Class Audio Class Defines the attributes and behaviour of an elementary aud...
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
#define MHEG5FALSE
Definition: mh5base.h:48
void MHEG5sendSync(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the synchronous event queue.
Definition: mh5queue.c:1651
MHEG5Int componentTag
Definition: mh5audio.h:52
MHEG5Application * MHEG5getCurrentApplication(void)
<Function description>="">