MHEG5  18.9.0
MHEG5 Documentation
mh5prgs.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  *******************************************************************************/
152 /*---includes for this file--------------------------------------------------*/
153 #include <stdlib.h> /* for RANDOM function */
154 #include "mh5prgs.h"
155 #include "mh5object.h" /* for actions */
156 #include "mh5variable.h" /* for actions */
157 #include "mh5date.h" /* for Davic-Date functions */
158 #include "mh5memory.h" /* for CastToObjectRef */
159 #include "mh5display.h" /* for VideoToGraphics */
160 #include "mh5fileorm.h"
161 #include "mh5group.h"
162 #include "mh5debug.h"
163 #include "mh5misc.h"
164 #include "mh5final.h"
165 #include "mh5queue.h"
166 #include "mh5profile.h"
167 #include "mh5support.h"
168 #include "mh5keypress.h"
169 #include "mh5control.h"
170 #include "dvb_audio.h"
171 #include "dvb_video.h"
172 #include "mg_video.h"
173 #include "dvb_misc.h"
174 
175 #if defined(INCLUDE_MHEG_PVR) || defined(INCLUDE_PVR_AU)
176 #include "dvb_pvr.h"
177 #include "mh5parse.h"
178 #endif
179 
180 #ifdef INCLUDE_SA_PROFILE
181 #include "dvb_native.h"
182 #endif
183 
184 #ifdef INCLUDE_IC
185 #include "mh5hfs.h"
186 #include "mh5parse.h"
187 #include "mh5cookies.h"
188 #ifdef INCLUDE_ICS
189 #include "mh5streamer.h"
190 #endif
191 #endif
192 
193 #ifndef _WIN32_WCE
194 #include <string.h>
195 #else
196 #include "mh5base.h"
197 #endif
198 
199 #ifdef INCLUDE_SI_EXTENSION
200 #include "dvb_service.h"
201 #endif
202 
203 #ifdef INCLUDE_TPS
204 #include "mh5tps.h"
205 #endif
206 
207 /*---constant definitions for this file--------------------------------------*/
208 
209 
210 /*---local typedef structs for this file-------------------------------------*/
211 
213 {
214  const char *name;
218 
219 /*---local (static) variable declarations for this file----------------------*/
220 
221 #if defined(INCLUDE_MHEG_PVR) || defined(INCLUDE_PVR_AU)
222 static MHEG5Program *pvr_program = NULL;
223 #endif
224 #if defined(INCLUDE_IC) && defined(INCLUDE_ICS)
225 static MHEG5Program *guidance_program = NULL;
226 #endif
227 #if defined(INCLUDE_CONNECTED_TV)
228 static MHEG5Program *application_launch_program = NULL;
229 #endif
230 /*---local function definitions----------------------------------------------*/
231 
232 /*---global function definitions---------------------------------------------*/
233 
234 
235 /*
236  Program Implementations
237  */
238 
239 
240 /*
241  * 3.10.2 Date and Time functions
242  *
243  * 3.10.2.1 DAVIC Day, Date & Time functions
244  *
245  * Some of these functions return textual information. In all cases this shall
246  * use the UTF-8 representation of character codes selected from the character
247  * repertoire in Table 5-18, "Set of characters supported by the engine," on
248  * page 5-23.
249  */
250 
266 static MHEG5ErrorCode MHEG5prgGetCurrentDate(MHEG5Program *program)
267 {
268  MHEG5GList *nextParam;
269  MHEG5Root *callVar = 0, *dateVar, *timeVar;
270  S32BIT day = 0, time = 0;
271 
272  assert(program);
273  nextParam = MHEG5resolveORef(program->parameter, &callVar);
274  if (!nextParam)
275  {
277  }
278  nextParam = MHEG5resolveORef(nextParam, &dateVar);
279  if (!nextParam)
280  {
282  }
283  MHEG5resolveORef(nextParam, &timeVar);
284  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
285  (!dateVar) || (dateVar->clazz != MHEG5INTEGERVARIABLE) ||
286  (!timeVar) || (timeVar->clazz != MHEG5INTEGERVARIABLE))
287  {
288  return MHEG5ERR_WRONGPARAM;
289  }
290 
291  MHEG5getDate((S32BIT *)&day, (S32BIT *)&time);
292  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
293  ((MHEG5IntegerVariable *) dateVar)->value = day;
294  ((MHEG5IntegerVariable *) timeVar)->value = time;
295 
296  #ifdef TRACING
297  if (mheg_trace_debug & (TACTIONS | TEVNTS))
298  {
299  DBG_PRINTF(T_NL "GetCurrentDate( %ld, %ld )", day, time);
300  }
301  #endif
302  return MHEG5ERR_NOERROR;
303 }
304 
347 static MHEG5ErrorCode MHEG5prgFormatDate(MHEG5Program *program)
348 {
349  MHEG5GList *nextParam;
350  MHEG5Root *callVar = 0, *osVar;
351  MHEG5Int day, time;
352  MHEG5String format;
353  MHEG5Bool invalidString;
354 
355  assert(program);
356  nextParam = MHEG5resolveORef(program->parameter, &callVar);
357  if (!nextParam)
358  {
360  }
361  nextParam = MHEG5resolveGenericOctetString(nextParam, &format, &invalidString);
362  if (!nextParam)
363  {
365  }
366  if (invalidString)
367  {
368  /* Parameter was not an octet string */
369  return MHEG5ERR_WRONGPARAM;
370  }
371  nextParam = MHEG5resolveGenericInteger(nextParam, &day);
372  if (!nextParam)
373  {
375  }
376  nextParam = MHEG5resolveGenericInteger(nextParam, &time);
377  if (!nextParam)
378  {
380  }
381  MHEG5resolveORef(nextParam, &osVar);
382 
383  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
384  (!osVar) || (osVar->clazz != MHEG5OCTETSTRINGVARIABLE))
385  {
386  return MHEG5ERR_WRONGPARAM;
387  }
388 
389  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
390  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) osVar)->value);
391  ((MHEG5OctetStringVariable *) osVar)->value =
392  MHEG5formatDate(format, day, time);
393  #ifdef TRACING
394  if (mheg_trace_debug & (TACTIONS | TEVNTS))
395  {
396  char buff[256];
397  strcpy(buff, T_NL "FormatDate( ");
398  MHEG5stringTrace( format, buff, 0, 120 );
399  DBG_PRINTF("%s, %ld, %ld, ", buff, day, time);
400  buff[0] = 0;
401  MHEG5stringTrace(((MHEG5OctetStringVariable *) osVar)->value, buff, 0, 120 );
402  DBG_PRINTF("%s)", buff);
403  }
404  #endif
405  return MHEG5ERR_NOERROR;
406 }
407 
423 static MHEG5ErrorCode MHEG5prgGetDayOfWeek(MHEG5Program *program)
424 {
425  MHEG5GList *nextParam;
426  MHEG5Root *callVar = 0, *intVar;
427  MHEG5Int day = 0;
428 
429  assert(program);
430  nextParam = MHEG5resolveORef(program->parameter, &callVar);
431  if (!nextParam)
432  {
434  }
435  nextParam = MHEG5resolveGenericInteger(nextParam, &day);
436  if (!nextParam)
437  {
439  }
440  MHEG5resolveORef(nextParam, &intVar);
441  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
442  (!intVar) || (intVar->clazz != MHEG5INTEGERVARIABLE))
443  {
444  return MHEG5ERR_WRONGPARAM;
445  }
446 
447  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
448  ((MHEG5IntegerVariable *) intVar)->value = MHEG5getDayOfWeek(day);
449 
450  #ifdef TRACING
451  if (mheg_trace_debug & (TACTIONS | TEVNTS))
452  {
453  DBG_PRINTF(T_NL "GetDayOfWeek( %ld, %ld )", day, ((MHEG5IntegerVariable *) intVar)->value);
454  }
455  #endif
456  return MHEG5ERR_NOERROR;
457 }
458 
459 /* 3.10.3 Random Number function */
460 
475 static MHEG5ErrorCode MHEG5prgRandom(MHEG5Program *program)
476 {
477  MHEG5GList *nextParam;
478  MHEG5Root *callVar = 0, *rndVar;
479  MHEG5Int intVal = 0;
480 
481  assert(program);
482  nextParam = MHEG5resolveORef(program->parameter, &callVar);
483  if (!nextParam)
484  {
486  }
487  nextParam = MHEG5resolveGenericInteger(nextParam, &intVal);
488  if (!nextParam)
489  {
491  }
492  MHEG5resolveORef(nextParam, &rndVar);
493 
494  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
495  (!rndVar) || (rndVar->clazz != MHEG5INTEGERVARIABLE))
496  {
497  return MHEG5ERR_WRONGPARAM;
498  }
499 
500  /* Check the value of intVar passed in. */
501  if (intVal < 1)
502  {
503  /* Behaviour for this condition is not specified. Force program to
504  * always return 1.
505  */
506  intVal = 1;
507  }
508 
509  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
510  ((MHEG5IntegerVariable *) rndVar)->value = MHEG5random() / (0xffffffff / intVal);
511  ((MHEG5IntegerVariable *) rndVar)->value++;
512 
513  if (((MHEG5IntegerVariable *) rndVar)->value < 1)
514  {
515  ((MHEG5IntegerVariable *) rndVar)->value = 1;
516  }
517  if (((MHEG5IntegerVariable *) rndVar)->value > intVal)
518  {
519  ((MHEG5IntegerVariable *) rndVar)->value = intVal;
520  }
521 
522  #ifdef TRACING
523  if (mheg_trace_debug & (TACTIONS | TEVNTS))
524  {
525  DBG_PRINTF(T_NL "Random( %ld, %ld )", intVal, ((MHEG5IntegerVariable *) rndVar)->value);
526  }
527  #endif
528  return MHEG5ERR_NOERROR;
529 }
530 
531 /* 3.10.4 Type Conversion Functions */
532 
545 static MHEG5ErrorCode MHEG5prgCastToContentRef(MHEG5Program *program)
546 {
547  MHEG5GList *nextParam;
548  MHEG5Root *callVar = 0, *osVar = 0;
549  MHEG5String s1;
550  MHEG5Bool invalidString;
551 
552  assert(program);
553  nextParam = MHEG5resolveORef(program->parameter, &callVar);
554  if (!nextParam)
555  {
557  }
558  nextParam = MHEG5resolveGenericOctetString(nextParam, &s1, &invalidString);
559  if (!nextParam)
560  {
562  }
563  if (invalidString)
564  {
565  /* Parameter was not an octet string */
566  return MHEG5ERR_WRONGPARAM;
567  }
568  MHEG5resolveORef(nextParam, &osVar);
569 
570  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
571  (!osVar) || (osVar->clazz != MHEG5CONTENTREFVARIABLE))
572  {
573  return MHEG5ERR_WRONGPARAM;
574  }
575  TRACE(TEVNTS, (" s=%.*s", (int)s1.len, s1.data))
576  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
577  MHEG5stringDestruct(&((MHEG5ContentVariable *) osVar)->contentData);
578  ((MHEG5ContentVariable *) osVar)->contentData = MHEG5stringCopy(s1);
579  #ifdef TRACING
580  if (mheg_trace_debug & (TACTIONS | TEVNTS))
581  {
582  char buff[256];
583  strcpy(buff, T_NL "CastToContentRef( ");
584  MHEG5stringTrace( s1, buff, 0, 120 );
585  DBG_PRINTF("%s )", buff);
586  }
587  #endif
588  return MHEG5ERR_NOERROR;
589 }
590 
591 /* mh5variable.h is included at the top of this file and yet the ST compiler still does not
592  * know about the function MHEG5objRefValueDestruct unless its definition is placed here
593  * ??? - beats me!
594  */
596 
615 static MHEG5ErrorCode MHEG5prgCastToObjectRef(MHEG5Program *program)
616 {
617  MHEG5GList *nextParam;
618  MHEG5Root *callVar = 0, *obVar = 0;
619  MHEG5String s1;
620  MHEG5Int id;
621  MHEG5Bool result = MHEG5TRUE;
622  MHEG5Bool invalidString;
623 
624  assert(program);
625  nextParam = MHEG5resolveORef(program->parameter, &callVar);
626  if (!nextParam)
627  {
629  }
630 
631  nextParam = MHEG5resolveGenericOctetString(nextParam, &s1, &invalidString);
632  if (!nextParam)
633  {
635  }
636  if (invalidString)
637  {
638  /* Parameter was not an octet string */
639  return MHEG5ERR_WRONGPARAM;
640  }
641 
642  nextParam = MHEG5resolveGenericInteger(nextParam, &id);
643  if (!nextParam)
644  {
646  }
647  MHEG5resolveORef(nextParam, &obVar);
648 
649  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
650  (!obVar) || (obVar->clazz != MHEG5OBJECTREFVARIABLE))
651  {
652  return MHEG5ERR_WRONGPARAM;
653  }
654 
656 
657  #ifdef TRACING
658  if (mheg_trace_debug & (TACTIONS | TEVNTS))
659  {
660  char buff[256];
661  strcpy(buff, T_NL "CastToObjectRef( ");
662  MHEG5stringTrace( s1, buff, 0, 120 );
663  DBG_PRINTF("%s, %ld ) result=%s", buff, id, result ? "true" : "false");
664  }
665  #endif
666  ((MHEG5BooleanVariable *) callVar)->value = result;
667 
668  return MHEG5ERR_NOERROR;
669 }
670 
691 static MHEG5ErrorCode MHEG5prgCastToStringInt(MHEG5Program *program)
692 {
693  MHEG5GList *nextParam;
694  MHEG5Root *callVar = 0, *objIdVar = 0, *oStrVar = 0;
695  MH5GroupRef gref;
696  MHEG5String sout;
697  MHEG5Int id;
698  MHEG5Bool result = MHEG5TRUE;
699 
700  assert(program);
701  nextParam = MHEG5resolveORef(program->parameter, &callVar);
702  if (!nextParam)
703  {
705  }
706  nextParam = MHEG5resolveGenericORefProper(nextParam, &gref, &id);
707  if (!nextParam)
708  {
710  }
711  nextParam = MHEG5resolveORef(nextParam, &oStrVar);
712  if (!nextParam)
713  {
715  }
716  MHEG5resolveORef(nextParam, &objIdVar);
717 
718  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
719  (!oStrVar) || (oStrVar->clazz != MHEG5OCTETSTRINGVARIABLE) ||
720  (!objIdVar) || (objIdVar->clazz != MHEG5INTEGERVARIABLE))
721  {
722  return MHEG5ERR_WRONGPARAM;
723  }
724 
725  TRACE(TEVNTS, (" id=%ld gref.len=%d", id, (int)gref.len))
726 
727  if (gref.len == 0)
728  {
729  if (gref.ptr.group != NULL)
730  {
731  /* by definition, this group must exist */
732  sout.len = gref.ptr.group->groupName.len;
733  sout.data = STR_DataAlloc( sout.len );
734  memcpy( sout.data, gref.ptr.group->groupName.data, sout.len + 1 );
735  }
736  else
737  {
738  /* Null string for the name, so cannot exist */
739  sout.len = 0;
740  sout.data = 0;
741  }
742  }
743  else
744  {
745  sout.len = gref.len;
746  sout.data = STR_DataAlloc( sout.len );
747  memcpy( sout.data, gref.ptr.name, gref.len + 1 );
748  }
749 
750  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) oStrVar)->value);
751  ((MHEG5OctetStringVariable *) oStrVar)->value = sout;
752  ((MHEG5IntegerVariable *) objIdVar)->value = id;
753 
754  #ifdef TRACING
755  if (mheg_trace_debug & (TACTIONS | TEVNTS))
756  {
757  char buff[256];
758  strcpy(buff, T_NL "CastToStringInt( ");
759  MHEG5stringTrace( sout, buff, 0, 120 );
760  DBG_PRINTF("%s, %ld ) result=%s", buff, id, result ? "true" : "false");
761  }
762  #endif
763  ((MHEG5BooleanVariable *) callVar)->value = result;
764 
765  return MHEG5ERR_NOERROR;
766 }
767 
768 /*
769  * 3.10.5 UK String manipulation functions
770  *
771  * These resident programs are for the manipulation of OctetStrings, and octet
772  * values in the range 0x00...0xFF are valid and particular values have no
773  * special meaning. In particular the value zero does not indicate a string
774  * termination. The functions are similar to those defined by DAVIC [51] but
775  * with more exact definitions and consideration of the UK string formats. In
776  * summary the issues addressed are:
777  *
778  * * Treatment of mark-up codes & multi-byte UTF-8 characters within
779  * strings. Neither is given special treatment. I.e. they are just
780  * considered as octets within the string. The "octetLengthSearch" bytes
781  * per character switch is not required.
782  *
783  * * Alignment to MHEG-5 corrigenda. I.e. "Output parameters and
784  * Input/Output Parameters shall be encoded as follows: The
785  * IndirectReference option in GenericBoolean, GenericInteger,
786  * GenericOctetString, GenericObjectReference, and GenericContentReference
787  * respectively shall be encoded."
788  *
789  * Range of string index values
790  *
791  * The first octet of any string has is referenced by an index of 1.
792  *
793  * For the input indices beginExtract, endExtract and startIndex the
794  * following bounds checking shall be observed:
795  *
796  * * If the index is < 1 it shall be treated as 1.
797  *
798  * * If the index is > greater than the string length then it shall be
799  * treated as string length.
800  *
801  */
802 
817 static MHEG5ErrorCode MHEG5prgGetStringLength(MHEG5Program *program)
818 {
819  MHEG5GList *nextParam;
820  MHEG5Root *callVar = 0, *intVar;
821  MHEG5String osVal;
822  MHEG5Bool invalidString;
823 
824  assert(program);
825  nextParam = MHEG5resolveORef(program->parameter, &callVar);
826  if (!nextParam)
827  {
829  }
830  nextParam = MHEG5resolveGenericOctetString(nextParam, &osVal, &invalidString);
831  if (!nextParam)
832  {
834  }
835  if (invalidString)
836  {
837  /* Parameter was not an octet string */
838  return MHEG5ERR_WRONGPARAM;
839  }
840  MHEG5resolveORef(nextParam, &intVar);
841  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
842  (!intVar) || (intVar->clazz != MHEG5INTEGERVARIABLE))
843  {
844  return MHEG5ERR_WRONGPARAM;
845  }
846 
847  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
848  ((MHEG5IntegerVariable *) intVar)->value = osVal.len;
849 
850  #ifdef TRACING
851  if (mheg_trace_debug & (TACTIONS | TEVNTS))
852  {
853  char buff[256];
854  strcpy(buff, T_NL "GetStringLength( ");
855  MHEG5stringTrace( osVal, buff, 0, 120 );
856  DBG_PRINTF("%s, %ld )", buff, osVal.len);
857  }
858  #endif
859  return MHEG5ERR_NOERROR;
860 }
861 
881 static MHEG5ErrorCode MHEG5prgGetSubString(MHEG5Program *program)
882 {
883  MHEG5GList *nextParam;
884  MHEG5Root *callVar = 0, *osVar = 0;
885  MHEG5String input;
886  MHEG5Int begin = 0, end = 0;
887  MHEG5String sout = {0, 0};
888  MHEG5Bool invalidString;
889 
890  assert(program);
891 
892  nextParam = MHEG5resolveORef(program->parameter, &callVar);
893  if (!nextParam)
894  {
896  }
897 
898  nextParam = MHEG5resolveGenericOctetString(nextParam, &input, &invalidString);
899  if (!nextParam)
900  {
902  }
903  if (invalidString)
904  {
905  /* Parameter was not an octet string */
906  return MHEG5ERR_WRONGPARAM;
907  }
908 
909  nextParam = MHEG5resolveGenericInteger(nextParam, &begin);
910  if (!nextParam)
911  {
913  }
914 
915  nextParam = MHEG5resolveGenericInteger(nextParam, &end);
916  if (!nextParam)
917  {
919  }
920 
921  MHEG5resolveORef(nextParam, &osVar);
922 
923  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
924  (!osVar) || (osVar->clazz != MHEG5OCTETSTRINGVARIABLE))
925  {
926  return MHEG5ERR_WRONGPARAM;
927  }
928 
929  #ifdef TRACING
930  if (mheg_trace_debug & (TACTIONS | TEVNTS))
931  {
932  char buff[256];
933  strcpy(buff, T_NL "GetSubString( ");
934  MHEG5stringTrace( input, buff, 0, 120 );
935  DBG_PRINTF("%s, %ld, %ld, ", buff, begin, end);
936  }
937  #endif
938 
939  if (input.len > 0)
940  {
941  begin = (begin > input.len) ? input.len : begin;
942  begin = (begin < 1) ? 1 : begin;
943  end = (end > input.len) ? input.len : end;
944  end = (end < 1) ? 1 : end;
945 
946  if (begin <= end)
947  {
948  begin--;
949  sout.data = STR_DataAlloc( end - begin );
950  if (sout.data)
951  {
952  while (begin != end)
953  {
954  sout.data[sout.len] = input.data[begin];
955  sout.len++;
956  begin++;
957  }
958  }
959  }
960  }
961 
962  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
963  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) osVar)->value);
964  ((MHEG5OctetStringVariable *) osVar)->value = sout;
965 
966  #ifdef TRACING
967  if (mheg_trace_debug & (TACTIONS | TEVNTS))
968  {
969  char buff[256];
970  buff[0] = 0;
971  MHEG5stringTrace( sout, buff, 0, 120 );
972  DBG_PRINTF("%s )", buff);
973  }
974  #endif
975  return MHEG5ERR_NOERROR;
976 }
977 
1001 static MHEG5ErrorCode MHEG5prgSearchSubString(MHEG5Program *program)
1002 {
1003  MHEG5GList *nextParam;
1004  MHEG5Root *callVar = 0, *intVar = 0;
1005  MHEG5String string, searchString;
1006  MHEG5Int start = 0, i = 0, rc = -1, j = 0;
1007  MHEG5Bool invalidString;
1008 
1009  assert(program);
1010 
1011  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1012  if (!nextParam)
1013  {
1015  }
1016 
1017  nextParam = MHEG5resolveGenericOctetString(nextParam, &string, &invalidString);
1018  if (!nextParam)
1019  {
1021  }
1022  if (invalidString)
1023  {
1024  /* Parameter was not an octet string */
1025  return MHEG5ERR_WRONGPARAM;
1026  }
1027 
1028  nextParam = MHEG5resolveGenericInteger(nextParam, &start);
1029  if (!nextParam)
1030  {
1032  }
1033 
1034  nextParam = MHEG5resolveGenericOctetString(nextParam, &searchString, &invalidString);
1035  if (!nextParam)
1036  {
1038  }
1039  if (invalidString)
1040  {
1041  /* Parameter was not an octet string */
1042  return MHEG5ERR_WRONGPARAM;
1043  }
1044 
1045  MHEG5resolveORef(nextParam, &intVar);
1046 
1047  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
1048  (!intVar) || (intVar->clazz != MHEG5INTEGERVARIABLE))
1049  {
1050  return MHEG5ERR_WRONGPARAM;
1051  }
1052 
1053  start = (start > string.len) ? string.len : start;
1054  start = (start < 1) ? 1 : start;
1055 
1056  #ifdef TRACING
1057  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1058  {
1059  char buff[256];
1060  strcpy(buff, T_NL "SearchSubString( ");
1061  MHEG5stringTrace( string, buff, 0, 120 );
1062  DBG_PRINTF("%s, %ld, ", buff, start);
1063  MHEG5stringTrace( searchString, buff, 0, 120 );
1064  DBG_PRINTF(buff);
1065  }
1066  #endif
1067 
1068  if (searchString.len == 0)
1069  {
1070  if (string.len == 0)
1071  {
1072  /* Both searchString and string are empty. This is a special case, which
1073  * returns -1, to avoid returning an index out of the string.
1074  */
1075  rc = -1;
1076  }
1077  else
1078  {
1079  /* String to search for is empty. Always match an empty string, so
1080  * return the start position.
1081  */
1082  rc = start;
1083  }
1084  }
1085  else
1086  {
1087  i = (start - 1);
1088  while (i < string.len)
1089  {
1090  if (string.data[i] == searchString.data[j])
1091  {
1092  i++;
1093  if (j == 0)
1094  {
1095  rc = i;
1096  }
1097  j++;
1098  if (j >= searchString.len)
1099  {
1100  break;
1101  }
1102  }
1103  else
1104  {
1105  i = i - j + 1;
1106  j = 0;
1107  }
1108  }
1109  if (j < searchString.len)
1110  {
1111  /* Didn't match the string */
1112  rc = -1;
1113  }
1114  }
1115 
1116  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1117  ((MHEG5IntegerVariable *) intVar)->value = rc;
1118  #ifdef TRACING
1119  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1120  {
1121  DBG_PRINTF(", %ld )", rc);
1122  }
1123  #endif
1124  return MHEG5ERR_NOERROR;
1125 }
1126 
1160 static MHEG5ErrorCode MHEG5prgSearchAndExtractSubString(MHEG5Program *program)
1161 {
1162  MHEG5GList *nextParam;
1163  MHEG5Root *callVar = 0, *intVar = 0, *osVar = 0;
1164  MHEG5String string, searchString;
1165  MHEG5String sout = {0, 0};
1166  MHEG5Int start = 0, i = 0, rc = -1, j = 0;
1167  MHEG5Bool invalidString;
1168 
1169  assert(program);
1170 
1171  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1172  if (!nextParam)
1173  {
1175  }
1176 
1177  nextParam = MHEG5resolveGenericOctetString(nextParam, &string, &invalidString);
1178  if (!nextParam)
1179  {
1181  }
1182  if (invalidString)
1183  {
1184  /* Parameter was not an octet string */
1185  return MHEG5ERR_WRONGPARAM;
1186  }
1187 
1188  nextParam = MHEG5resolveGenericInteger(nextParam, &start);
1189  if (!nextParam)
1190  {
1192  }
1193 
1194  nextParam = MHEG5resolveGenericOctetString( nextParam, &searchString, &invalidString);
1195  if (!nextParam)
1196  {
1198  }
1199  if (invalidString)
1200  {
1201  /* Parameter was not an octet string */
1202  return MHEG5ERR_WRONGPARAM;
1203  }
1204 
1205  nextParam = MHEG5resolveORef(nextParam, &osVar);
1206  if (!nextParam)
1207  {
1209  }
1210 
1211  MHEG5resolveORef(nextParam, &intVar);
1212 
1213  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
1214  (!intVar) || (intVar->clazz != MHEG5INTEGERVARIABLE) ||
1215  (!osVar) || (osVar->clazz != MHEG5OCTETSTRINGVARIABLE))
1216  {
1217  return MHEG5ERR_WRONGPARAM;
1218  }
1219 
1220  start = (start > string.len) ? string.len : start;
1221  start = (start < 1) ? 1 : start;
1222 
1223  #ifdef TRACING
1224  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1225  {
1226  char buff[256];
1227  strcpy(buff, T_NL "SearchAndExtractSubString( ");
1228  MHEG5stringTrace( string, buff, start - 1, 60 );
1229  DBG_PRINTF(buff);
1230  DBG_PRINTF(", %ld, ", start);
1231  buff[0] = 0;
1232  MHEG5stringTrace( searchString, buff, 0, 120 );
1233  DBG_PRINTF(buff);
1234  DBG_PRINTF(" l=%ld", searchString.len);
1235  }
1236  #endif
1237 
1238  if (searchString.len == 0)
1239  {
1240  if (string.len == 0)
1241  {
1242  /* Both searchString and string are empty. This is a special case, which
1243  * returns -1, to avoid returning an index out of the string.
1244  */
1245  rc = -1;
1246  }
1247  else
1248  {
1249  /* String to search for is empty. Always match an empty string, so
1250  * return the start position.
1251  */
1252  rc = start;
1253  }
1254  }
1255  else
1256  {
1257  i = (start - 1);
1258  while (i < string.len)
1259  {
1260  if (string.data[i] == searchString.data[j])
1261  {
1262  i++;
1263  if (j == 0)
1264  {
1265  rc = i;
1266  }
1267  j++;
1268  if (j >= searchString.len)
1269  {
1270  /* String found */
1271  break;
1272  }
1273  }
1274  else
1275  {
1276  i = i - j + 1;
1277  j = 0;
1278  rc = -1;
1279  }
1280  }
1281 
1282  if (j < searchString.len)
1283  {
1284  /* Didn't match the string */
1285  rc = -1;
1286  }
1287  }
1288 
1289  if (rc == start)
1290  {
1291  /* No string to copy */
1292  rc += searchString.len;
1293  }
1294  else if (rc > start)
1295  {
1296  /* Copy string from startIndex to stringPosition */
1297  sout.data = STR_DataAlloc( rc - start );
1298  if (sout.data)
1299  {
1300  i = (start - 1);
1301  while (i < (rc - 1))
1302  {
1303  sout.data[sout.len] = string.data[i++];
1304  sout.len++;
1305  }
1306  }
1307  rc += searchString.len;
1308  }
1309 
1310  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1311  ((MHEG5IntegerVariable *) intVar)->value = rc;
1312  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) osVar)->value);
1313  ((MHEG5OctetStringVariable *) osVar)->value = sout;
1314 
1315  #ifdef TRACING
1316  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1317  {
1318  char buff[256];
1319  strcpy(buff, ", ");
1320  MHEG5stringTrace( sout, buff, 0, 120 );
1321  DBG_PRINTF("%s, %ld )", buff, rc);
1322  }
1323  #endif
1324  return MHEG5ERR_NOERROR;
1325 }
1326 
1327 /* 3.10.6 Service Selection
1328  *
1329  * The text here is based on DAVIC 14B94R10 [52].
1330  */
1331 
1367 static MHEG5ErrorCode MHEG5prgSI_GetServiceIndex(MHEG5Program *program)
1368 {
1369  /*
1370  Can not emulate this one
1371  */
1372  MHEG5GList *nextParam;
1373  MHEG5Root *callVar = 0, *intVar = 0;
1374  MHEG5String s1;
1375  MHEG5Int rc = -1;
1376  MHEG5Bool invalidString;
1377 
1378  assert(program);
1379  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1380  if (!nextParam)
1381  {
1383  }
1384  nextParam = MHEG5resolveGenericOctetString( nextParam, &s1, &invalidString);
1385 
1386  if (!nextParam)
1387  {
1389  }
1390  if (invalidString)
1391  {
1392  /* Parameter was not an octet string */
1393  return MHEG5ERR_WRONGPARAM;
1394  }
1395 
1396  MHEG5resolveORef(nextParam, &intVar);
1397 
1398  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
1399  (!intVar) || (intVar->clazz != MHEG5INTEGERVARIABLE))
1400  {
1401  return MHEG5ERR_WRONGPARAM;
1402  }
1403 
1404  /* check whether DVB URL is available in current stream: */
1405  rc = MHEG5GetServiceIndex(&s1);
1406 
1407  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1408  ((MHEG5IntegerVariable *) intVar)->value = rc;
1409 
1410  #ifdef TRACING
1411  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1412  {
1413  char buff[256];
1414  strcpy(buff, T_NL "SI_GetServiceIndex( ");
1415  MHEG5stringTrace( s1, buff, 0, 120 );
1416  DBG_PRINTF("%s, %ld )", buff, rc);
1417  }
1418  #endif
1419 
1420  return MHEG5ERR_NOERROR;
1421 }
1422 
1423 #ifndef CI_PLUS_ONLY
1424 
1451 static MHEG5ErrorCode MHEG5prgSI_TuneIndex(MHEG5Program *program)
1452 {
1453  /*
1454  Can not emulate this one
1455  */
1456  MHEG5GList *nextParam;
1457  MHEG5Root *callVar = 0;
1458  MHEG5Int serviceIndex;
1459 
1460  assert(program);
1461  nextParam = MHEG5resolveORef( program->parameter, &callVar );
1462  if (!nextParam)
1463  {
1465  }
1466  MHEG5resolveGenericInteger(nextParam, &serviceIndex);
1467 
1468  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
1469  {
1470  return MHEG5ERR_WRONGPARAM;
1471  }
1472 
1473  MHEG5TuneIndex(serviceIndex);
1474 
1475  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1476 
1477  #ifdef TRACING
1478  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1479  {
1480  DBG_PRINTF(T_NL "SI_TuneIndex( %ld )", serviceIndex);
1481  }
1482  #endif
1483 
1484  return MHEG5ERR_NOERROR;
1485 }
1486 
1508 static MHEG5ErrorCode MHEG5prgSI_TuneIndexInfo(MHEG5Program *program)
1509 {
1510  /*
1511  Can not emulate this one
1512  */
1513  MHEG5GList *nextParam;
1514  MHEG5Root *callVar = 0;
1515  MHEG5Int tuneInfo;
1516 
1517  assert(program);
1518  nextParam = MHEG5resolveORef( program->parameter, &callVar );
1519  if (!nextParam)
1520  {
1522  }
1523  MHEG5resolveGenericInteger(nextParam, &tuneInfo);
1524  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
1525  {
1526  return MHEG5ERR_WRONGPARAM;
1527  }
1528 
1529  MHEG5TuneIndexInfo(tuneInfo);
1530  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1531 
1532  #ifdef TRACING
1533  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1534  {
1535  DBG_PRINTF(T_NL "SI_TuneIndexInfo( %ld )", tuneInfo);
1536  }
1537  #endif
1538 
1539  return MHEG5ERR_NOERROR;
1540 }
1541 
1542 #endif /* CI_PLUS_ONLY*/
1543 
1580 static MHEG5ErrorCode MHEG5prgSI_GetBasicSI(MHEG5Program *program)
1581 {
1582  /*
1583  Can not emulate this one
1584  */
1585  MHEG5GList *nextParam;
1586  MHEG5Root *callVar = 0;
1587  MHEG5Root *networkID = 0;
1588  MHEG5Root *origNetworkID = 0;
1589  MHEG5Root *transportStreamID = 0;
1590  MHEG5Root *serviceID = 0;
1591  MHEG5Int serviceIndex;
1592  MHEG5Int networkIDVal;
1593  MHEG5Int origNetworkIDVal;
1594  MHEG5Int transportStreamIDVal;
1595  MHEG5Int serviceIDVal;
1596 
1597  assert(program);
1598  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1599  if (!nextParam)
1600  {
1602  }
1603  nextParam = MHEG5resolveGenericInteger( nextParam, &serviceIndex);
1604  if (!nextParam)
1605  {
1607  }
1608  nextParam = MHEG5resolveORef(nextParam, &networkID);
1609  if (!nextParam)
1610  {
1612  }
1613  nextParam = MHEG5resolveORef(nextParam, &origNetworkID);
1614  if (!nextParam)
1615  {
1617  }
1618  nextParam = MHEG5resolveORef(nextParam, &transportStreamID);
1619  if (!nextParam)
1620  {
1622  }
1623  MHEG5resolveORef(nextParam, &serviceID);
1624 
1625  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
1626  ((!networkID) || (networkID->clazz != MHEG5INTEGERVARIABLE)) ||
1627  ((!origNetworkID) || (origNetworkID->clazz != MHEG5INTEGERVARIABLE)) ||
1628  ((!transportStreamID) || (transportStreamID->clazz != MHEG5INTEGERVARIABLE)) ||
1629  ((!serviceID) || (serviceID->clazz != MHEG5INTEGERVARIABLE)))
1630  {
1631  return MHEG5ERR_WRONGPARAM;
1632  }
1633 
1634  /* check whether DVB URL is available in current stream: */
1635  MHEG5GetBasicSI(serviceIndex, &networkIDVal, &origNetworkIDVal,
1636  &transportStreamIDVal, &serviceIDVal);
1637  ((MHEG5IntegerVariable *) networkID)->value = networkIDVal;
1638  ((MHEG5IntegerVariable *) origNetworkID)->value = origNetworkIDVal;
1639  ((MHEG5IntegerVariable *) transportStreamID)->value = transportStreamIDVal;
1640  ((MHEG5IntegerVariable *) serviceID)->value = serviceIDVal;
1641  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1642 
1643  #ifdef TRACING
1644  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1645  {
1646  DBG_PRINTF(T_NL "SI_GetBasicSI( %ld, %ld, %ld, %ld, %ld )",
1647  serviceIndex, networkIDVal, origNetworkIDVal, transportStreamIDVal, serviceIDVal );
1648  }
1649  #endif
1650 
1651  return MHEG5ERR_NOERROR;
1652 }
1653 
1659 static void ProgramCompleted( MHEG5Program *program )
1660 {
1661  /* Disable the call to stop function since program has finished executing */
1662  program->stopFunc = NULL;
1663 
1664  if (program->forked)
1665  {
1666  if (!program->ingredient.root.runningStatus)
1667  {
1668  /* A forked program has finished before the activation action
1669  * completed. By clearing forkSucceededValue we indicate that
1670  * the program has finished. This will be detected after the
1671  * activation completes and the deactivation and AsyncStopped
1672  * event will occur then.
1673  */
1674  program->forkSucceededValue = NULL;
1675  }
1676  else
1677  {
1678  /* Perform the final steps of the Fork action when the execution of
1679  * a program finishes:
1680  *
1681  * 3. Apply the Deactivation behaviour.
1682  * 4. Generate an AsynchStopped event.
1683  */
1686  }
1687  }
1688  else
1689  {
1690  TRACE(TFILE, (""))
1691  /* For called programs, re-enable engine event processing */
1693  }
1694 }
1695 
1696 /*
1697  * 3.10.7 Checking References
1698  *
1699  * This set of resident programs can be used by applications to determine if
1700  * objects are available before embarking on a course of action that requires
1701  * the objects. The tests serve two functions, first they confirm that the
1702  * "file" implied by the reference is available in the file system, secondly
1703  * the test confirms that, where practical, the file has been brought into the
1704  * receiver’s memory. For the purposes of these Resident Programs the minimum
1705  * condition under which a "file" may be considered as available is when the
1706  * IOR of the corresponding File object has been extracted from the relevant
1707  * parent Directory (or ServiceGateway) object. Further specification work will
1708  * be required to enable application authors to predict the size of objects
1709  * that can reliably be brought into memory by these functions. An authoring
1710  * example is provided under 9.11 on page 9-10 which illustrates the expected
1711  * use of these resident programs.
1712  */
1713 
1714 static void clearOrmHandle(MHEG5Program *program)
1715 {
1716  if (program->ingredient.ormHandle != NULL)
1717  {
1719  program->ingredient.ormHandle = NULL;
1720  }
1721 }
1722 
1730 static void checkRefGood( void *userData, S_CONTENT *content )
1731 {
1732  MHEG5Program *program = (MHEG5Program *)userData;
1733 
1734  *((MHEG5Bool *)(program->resultValue)) = MHEG5TRUE;
1735  *(program->forkSucceededValue) = MHEG5TRUE;
1736 
1737  #ifdef TRACING
1738  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1739  {
1740  DBG_PRINTF(", exists)");
1741  }
1742  #endif
1743 
1744  ProgramCompleted( program );
1745 }
1746 
1758 static void checkRefFail( void *userData )
1759 {
1760  MHEG5Program *program = (MHEG5Program *)userData;
1761 
1762  *((MHEG5Bool *)(program->resultValue)) = MHEG5FALSE;
1763  *(program->forkSucceededValue) = MHEG5TRUE;
1764 
1765  #ifdef TRACING
1766  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1767  {
1768  DBG_PRINTF(", not avl)");
1769  }
1770  #endif
1771 
1772  ProgramCompleted( program );
1773 }
1774 
1807 static MHEG5ErrorCode MHEG5prgCheckContentRef(MHEG5Program *program)
1808 {
1809  MHEG5GList *nextParam;
1810  MHEG5Root *callVar = 0, *rcVar1 = 0, *rcVar2 = 0;
1811  MHEG5String cref_data;
1812  MHEG5Bool cref_referenced = MHEG5FALSE;
1813  MHEG5Bool valid = MHEG5FALSE;
1814  MHEG5BooleanVariable *rc1;
1815  MHEG5ContentVariable *rc2;
1816 
1817  assert(program);
1818  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1819  if (!nextParam)
1820  {
1822  }
1823  nextParam = MHEG5resolveGenericCRef(nextParam, &cref_data, &cref_referenced, &valid);
1824  if (!nextParam)
1825  {
1827  }
1828  nextParam = MHEG5resolveORef(nextParam, &rcVar1);
1829  if (!nextParam)
1830  {
1832  }
1833  MHEG5resolveORef(nextParam, &rcVar2);
1834 
1835  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
1836  (!rcVar1) || (rcVar1->clazz != MHEG5BOOLEANVARIABLE) ||
1837  (!rcVar2) || (rcVar2->clazz != MHEG5CONTENTREFVARIABLE))
1838  {
1839  return MHEG5ERR_WRONGPARAM;
1840  }
1841 
1842  rc1 = (MHEG5BooleanVariable *) rcVar1;
1843  rc2 = (MHEG5ContentVariable *) rcVar2;
1844 
1845  if (rc2->contentData.data != cref_data.data)
1846  {
1848  rc2->contentData = MHEG5stringCopy(cref_data);
1849  }
1850  rc1->value = MHEG5FALSE;
1851 
1852  /* Set the forkSuceeded to default to FALSE */
1853  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
1854 
1855  program->resultValue = &rc1->value;
1856  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
1857 
1858  /* For a called program disable event processing until the program ends */
1859  if (!program->forked)
1860  {
1861  TRACE(TFILE, (""))
1863  }
1864 
1865  #ifdef TRACING
1866  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1867  {
1868  char buff[256];
1869  strcpy(buff, T_NL "CheckContentRef( ");
1870  MHEG5stringTrace( cref_data, buff, 0, 120 );
1871  DBG_PRINTF("%s, ", buff);
1872  }
1873  #endif
1874 
1875  if (!cref_referenced)
1876  {
1877  checkRefFail( program );
1878  }
1879  else
1880  {
1881  program->ingredient.ormHandle =
1883  program, checkRefGood, checkRefFail );
1884  }
1885  return MHEG5ERR_NOERROR;
1886 }
1887 
1921 static MHEG5ErrorCode MHEG5prgCheckGroupIDRef(MHEG5Program *program)
1922 {
1923  MHEG5GList *nextParam;
1924  MHEG5Root *callVar = 0, *rcVar1 = 0, *rcVar2 = 0;
1925  MHEG5BooleanVariable *rc1;
1927  MH5GroupRef gref;
1928  MHEG5Int id;
1929 
1930  assert(program);
1931  nextParam = MHEG5resolveORef(program->parameter, &callVar);
1932  if (!nextParam)
1933  {
1935  }
1936  nextParam = MHEG5resolveGenericORefProper(nextParam, &gref, &id);
1937  if (!nextParam)
1938  {
1940  }
1941  nextParam = MHEG5resolveORef(nextParam, &rcVar1);
1942  if (!nextParam)
1943  {
1945  }
1946  MHEG5resolveORef(nextParam, &rcVar2);
1947 
1948  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
1949  (!rcVar1) || (rcVar1->clazz != MHEG5BOOLEANVARIABLE) ||
1950  (!rcVar2) || (rcVar2->clazz != MHEG5OBJECTREFVARIABLE))
1951  {
1952  return MHEG5ERR_WRONGPARAM;
1953  }
1954 
1955  rc1 = (MHEG5BooleanVariable *) rcVar1;
1956  out = (MHEG5ObjectRefVariable *) rcVar2;
1957 
1958  MHEG5objRefStoreValue( out, gref, id );
1959  if (gref.len == 0)
1960  {
1961  if (gref.ptr.group != NULL)
1962  {
1963  /* by definition, this group must exist */
1964  rc1->value = MHEG5TRUE;
1965  }
1966  else
1967  {
1968  /* Null string for the name, so cannot exist */
1969  rc1->value = MHEG5FALSE;
1970  }
1971  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1972  }
1973  else if (out->valueGrp.data == NULL)
1974  {
1975  rc1->value = MHEG5FALSE;
1976  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
1977  }
1978  else
1979  {
1980  rc1->value = MHEG5FALSE;
1981 
1982  /* Set the forkSuceeded to default to FALSE */
1983  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
1984 
1985  program->resultValue = &rc1->value;
1986  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
1987 
1988  /* For a called program disable event processing until the program ends */
1989  if (!program->forked)
1990  {
1991  TRACE(TFILE, (""))
1993  }
1994 
1995  #ifdef TRACING
1996  if (mheg_trace_debug & (TACTIONS | TEVNTS))
1997  {
1998  char buff[256];
1999  strcpy(buff, T_NL "CheckGroupIDRef( ");
2000  MHEG5stringTrace( out->valueGrp, buff, 0, 120 );
2001  DBG_PRINTF("%s,%ld ", buff, id);
2002  }
2003  #endif
2004 
2005  program->ingredient.ormHandle =
2007  program, checkRefGood, checkRefFail );
2008  }
2009  return MHEG5ERR_NOERROR;
2010 }
2011 
2012 #ifndef CI_PLUS_ONLY
2013 
2033 static MHEG5ErrorCode MHEG5prgGetBootInfo(MHEG5Program *program)
2034 {
2035  MHEG5GList *nextParam;
2036  MHEG5Root *callVar = 0, *bootInfo = 0, *infoResult = 0;
2037  MHEG5Bool infoResultVal;
2038 
2039  assert(program);
2040  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2041  if (!nextParam)
2042  {
2044  }
2045  nextParam = MHEG5resolveORef(nextParam, &infoResult);
2046  if (!nextParam)
2047  {
2049  }
2050  MHEG5resolveORef(nextParam, &bootInfo);
2051 
2052  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
2053  ((!infoResult) || (infoResult->clazz != MHEG5BOOLEANVARIABLE)) ||
2054  ((!bootInfo) || (bootInfo->clazz != MHEG5OCTETSTRINGVARIABLE)))
2055  {
2056  return MHEG5ERR_WRONGPARAM;
2057  }
2058 
2059  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2060  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) bootInfo)->value);
2061  ((MHEG5OctetStringVariable *) bootInfo)->value = MHEG5GetBootInfo(&infoResultVal);
2062  ((MHEG5BooleanVariable *) infoResult)->value = infoResultVal;
2063 
2064  #ifdef TRACING
2065  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2066  {
2067  char buff[256];
2068  strcpy(buff, T_NL "GetBootInfo( ");
2069  MHEG5stringTrace(((MHEG5OctetStringVariable *) bootInfo)->value, buff, 0, 120 );
2070  DBG_PRINTF("%s, %s )", infoResultVal ? "true" : "false", buff);
2071  }
2072  #endif
2073 
2074  return MHEG5ERR_NOERROR;
2075 }
2076 
2077 #endif /* !CI_PLUS_ONLY */
2078 
2079 /* 3.10.8 Presentation information */
2080 
2081 #ifndef CI_PLUS_ONLY
2082 
2100 static MHEG5ErrorCode MHEG5prgVideoToGraphics(MHEG5Program *program)
2101 {
2102  MHEG5GList *nextParam;
2103  MHEG5Root *callVar = 0, *graphicsX = 0, *graphicsY = 0;
2104  MHEG5Int videoXVal, videoYVal, graphicsYVal, graphicsXVal;
2105 
2106  assert(program);
2107 
2108  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2109  if (!nextParam)
2110  {
2112  }
2113  nextParam = MHEG5resolveGenericInteger( nextParam, &videoXVal);
2114  if (!nextParam)
2115  {
2117  }
2118  nextParam = MHEG5resolveGenericInteger( nextParam, &videoYVal);
2119  if (!nextParam)
2120  {
2122  }
2123  nextParam = MHEG5resolveORef(nextParam, &graphicsX);
2124  if (!nextParam)
2125  {
2127  }
2128  MHEG5resolveORef(nextParam, &graphicsY);
2129 
2130  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
2131  ((!graphicsX) || (graphicsX->clazz != MHEG5INTEGERVARIABLE)) ||
2132  ((!graphicsY) || (graphicsY->clazz != MHEG5INTEGERVARIABLE)))
2133  {
2134  return MHEG5ERR_WRONGPARAM;
2135  }
2136 
2137  MG_DisplayVideoToGraphics(videoXVal, videoYVal, &graphicsXVal, &graphicsYVal);
2138 
2139  ((MHEG5IntegerVariable *) graphicsX)->value = graphicsXVal;
2140  ((MHEG5IntegerVariable *) graphicsY)->value = graphicsYVal;
2141  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2142 
2143  #ifdef TRACING
2144  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2145  {
2146  DBG_PRINTF(T_NL "VideoToGraphics( %ld, %ld, %ld, %ld )",
2147  videoXVal, videoYVal, graphicsYVal, graphicsXVal );
2148  }
2149  #endif
2150 
2151  return MHEG5ERR_NOERROR;
2152 }
2153 
2167 static MHEG5ErrorCode MHEG5prgSetWidescreenAlignment(MHEG5Program *program)
2168 {
2169  MHEG5GList *nextParam;
2170  MHEG5Root *callVar = 0;
2171  MHEG5Int modeVal;
2172 
2173  assert(program);
2174 
2175  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2176  if (!nextParam)
2177  {
2179  }
2180  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
2181  {
2182  return MHEG5ERR_WRONGPARAM;
2183  }
2184 
2185  MHEG5resolveGenericInteger( nextParam, &modeVal);
2186 
2187  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2188 
2189  if (modeVal == 1)
2190  {
2191  /* centre cutout */
2193  }
2194  else if (modeVal == 2)
2195  {
2196  /* letter box */
2198  }
2199 #ifdef INCLUDE_FREESAT
2200  else if (modeVal == 0)
2201  {
2203  }
2204 #endif
2205 
2206  #ifdef TRACING
2207  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2208  {
2209  DBG_PRINTF(T_NL "SetWidescreenAlignment( %ld )", modeVal );
2210  }
2211  #endif
2212 
2213  return MHEG5ERR_NOERROR;
2214 }
2215 
2238 static MHEG5ErrorCode MHEG5prgSetSubtitleMode(MHEG5Program *program)
2239 {
2240  MHEG5GList *nextParam;
2241  MHEG5Root *callVar = 0;
2242  MHEG5Bool onVal = 0;
2243 
2244  assert(program);
2245  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2246  if (!nextParam)
2247  {
2249  }
2250  MHEG5resolveGenericBoolean(nextParam, &onVal);
2251 
2252  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
2253  {
2254  return MHEG5ERR_WRONGPARAM;
2255  }
2256 
2257  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2258  MG_SetSubtitleMode(onVal);
2259 
2260  #ifdef TRACING
2261  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2262  {
2263  DBG_PRINTF(T_NL "SetSubtitleMode( %ld )", onVal );
2264  }
2265  #endif
2266 
2267  return MHEG5ERR_NOERROR;
2268 }
2269 
2270 #endif /* CI_PLUS_ONLY*/
2271 
2272 #ifdef INCLUDE_NATIVE_APP
2273 
2291 static MHEG5ErrorCode MHEG5prgSetBroadcasterInterruptions(MHEG5Program *program)
2292 {
2293  MHEG5GList *nextParam;
2294  MHEG5Root *callVar = 0;
2295  MHEG5Bool enable = 0;
2296 
2297  assert(program);
2298  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2299  if (!nextParam)
2300  {
2302  }
2303  MHEG5resolveGenericBoolean(nextParam, &enable);
2304 
2305  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
2306  {
2307  return MHEG5ERR_WRONGPARAM;
2308  }
2309 
2310  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2311 
2313 
2314  #ifdef TRACING
2315  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2316  {
2317  DBG_PRINTF(T_NL "SetBroadcasterInterruptions( %ld )", enable );
2318  }
2319  #endif
2320 
2321  return MHEG5ERR_NOERROR;
2322 }
2323 
2324 #endif /*INCLUDE_NATIVE_APP*/
2325 
2338 static MHEG5ErrorCode MHEG5prgGetDisplayAspectRatio(MHEG5Program *program)
2339 {
2340  MHEG5GList *nextParam;
2341  MHEG5Root *callVar = 0, *aspectRatioVal = 0;
2342 
2343  assert(program);
2344  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2345  if (!nextParam)
2346  {
2348  }
2349  MHEG5resolveORef(nextParam, &aspectRatioVal);
2350 
2351  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
2352  (!aspectRatioVal) || (aspectRatioVal->clazz != MHEG5INTEGERVARIABLE))
2353  {
2354  return MHEG5ERR_WRONGPARAM;
2355  }
2356 
2357  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2358  ((MHEG5IntegerVariable *) aspectRatioVal)->value = MHEG5GetDisplayAspectRatio();
2359 
2360  #ifdef TRACING
2361  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2362  {
2363  DBG_PRINTF(T_NL "GetDisplayAspectRatio( %ld )", ((MHEG5IntegerVariable *) aspectRatioVal)->value );
2364  }
2365  #endif
2366 
2367  return MHEG5ERR_NOERROR;
2368 }
2369 
2370 /* 3.10.9 Conditional Access */
2371 
2372 #ifdef COMMON_INTERFACE
2373 
2381 static void ciSendMessageCallback(void *userData, MHEG5String output, MHEG5Bool success)
2382 {
2383  MHEG5Program *program;
2384 
2385  /* Cast userData to an (MHEG5Program *) */
2386  program = (MHEG5Program *)userData;
2387 
2388  /* Check whether message was sent successfully */
2389  if (success)
2390  {
2391  *((MHEG5String *)(program->resultValue)) = MHEG5stringCopy(output);
2392  *(program->forkSucceededValue) = MHEG5TRUE;
2393  }
2394  else
2395  {
2396  /* An error condition ocurred - forkSucceeded defaults to FALSE, so do
2397  * nothing here.
2398  */
2399  }
2400  ProgramCompleted( program );
2401 }
2402 
2403 #endif /*COMMON_INTERFACE*/
2404 
2425 static MHEG5ErrorCode MHEG5prgCI_SendMessage(MHEG5Program *program)
2426 {
2427  MHEG5GList *nextParam;
2428  MHEG5Root *callVar = 0, *osVar = 0;
2429  MHEG5String input;
2430  MHEG5OctetStringVariable *output;
2431  MHEG5Bool invalidString;
2432 
2433  assert(program);
2434  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2435  if (!nextParam)
2436  {
2438  }
2439  nextParam = MHEG5resolveGenericOctetString( nextParam, &input, &invalidString);
2440  if (!nextParam)
2441  {
2443  }
2444  if (invalidString)
2445  {
2446  /* Parameter was not an octet string */
2447  return MHEG5ERR_WRONGPARAM;
2448  }
2449 
2450  MHEG5resolveORef(nextParam, &osVar);
2451  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
2452  (!osVar) || (osVar->clazz != MHEG5OCTETSTRINGVARIABLE))
2453  {
2454  return MHEG5ERR_WRONGPARAM;
2455  }
2456  output = (MHEG5OctetStringVariable *) osVar;
2457  MHEG5stringDestruct(&output->value);
2458 
2459  /* Set the forkSuceeded to default to FALSE */
2460  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
2461 
2462  program->resultValue = &output->value;
2463  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
2464 
2465  /* For a called program disable event processing until the program ends */
2466  if (!program->forked)
2467  {
2468  TRACE(TFILE, (""))
2470  }
2471 
2472  /* Cannot stop CI_SendMessage */
2473  assert( program->ingredient.ormHandle == NULL );
2474 
2475 #ifdef COMMON_INTERFACE
2476  if (MHEG5FileOrmSendCiMessage(input, ciSendMessageCallback, program) == MHEG5FALSE)
2477 #endif
2478  {
2479  /* If no DVB CI Application MMI session exists then the resident
2480  * program shall have no effect.
2481  */
2482  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2483  if (!program->forked)
2484  {
2485  TRACE(TFILE, (""))
2487  }
2488  }
2489 
2490  #ifdef TRACING
2491  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2492  {
2493  char buff[256];
2494  strcpy(buff, T_NL "CI_SendMessage( ");
2495  MHEG5stringTrace( input, buff, 0, 120 );
2496  strcat(buff, ", n/a )");
2497  DBG_PRINTF(buff);
2498  }
2499  #endif
2500 
2501  return MHEG5ERR_NOERROR;
2502 }
2503 
2504 /* 3.10.10 Developer Utilities */
2517 static MHEG5ErrorCode MHEG5prgWhoAmI(MHEG5Program *program)
2518 {
2519  MHEG5GList *nextParam;
2520  MHEG5Root *callVar = 0, *identVar = 0;
2521 
2522  assert(program);
2523 
2524  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2525  if (!nextParam)
2526  {
2528  }
2529  MHEG5resolveORef(nextParam, &identVar);
2530 
2531  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
2532  ((!identVar) || (identVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
2533  {
2534  return MHEG5ERR_WRONGPARAM;
2535  }
2536 
2537  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) identVar)->value);
2538  ((MHEG5OctetStringVariable *) identVar)->value = MH5_WhoAmI();
2539  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2540 
2541  #ifdef TRACING
2542  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2543  {
2544  char buff[256];
2545  strcpy(buff, T_NL "WhoAmI( ");
2546  MHEG5stringTrace(((MHEG5OctetStringVariable *) identVar)->value, buff, 0, 120 );
2547  strcat(buff, " )");
2548  DBG_PRINTF(buff);
2549  }
2550  #endif
2551 
2552  return MHEG5ERR_NOERROR;
2553 }
2554 
2555 #ifdef INCLUDE_DEBUG_PACKAGE
2556 
2572 static MHEG5ErrorCode MHEG5prgDebug(MHEG5Program *program)
2573 {
2574  MHEG5GList *prevParam, *nextParam;
2575  MHEG5Root *callVar = 0;
2576  MHEG5Generic g;
2577  U8BIT *buffer = 0;
2578  MHEG5Int allocated = 0, used = 0;
2579  MHEG5Bool success;
2580 
2581  assert(program);
2582 
2583  prevParam = MHEG5resolveORef(program->parameter, &callVar);
2584  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
2585  {
2586  return MHEG5ERR_WRONGPARAM;
2587  }
2588 
2589  buffer = NULL;
2590 
2591  while (prevParam)
2592  {
2593  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
2594  success = MHEG5parseEncodeQPrintable(&buffer, &used, &allocated, &g);
2595  if (!success)
2596  {
2597  break;
2598  }
2599 
2600  prevParam = nextParam;
2601  }
2602 
2603  if (buffer != NULL)
2604  {
2605  DVB_MhegOutputDebugString(buffer);
2606  MHEG5freeMem(buffer);
2607  }
2608 
2609  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2610 
2611  return MHEG5ERR_NOERROR;
2612 }
2613 
2614 #endif /* INCLUDE_DEBUG_PACKAGE */
2615 
2616 
2617 #if defined(INCLUDE_MHEG_PVR) || defined(INCLUDE_PVR_AU)
2618 
2628 {
2629  if (pvr_program == NULL)
2630  {
2631  TRACE(TERROR, ("No Program"))
2632  }
2633  else
2634  {
2635  switch (result)
2636  {
2638  *((MHEG5Int *)(pvr_program->resultValue)) = 1;
2639  *(pvr_program->forkSucceededValue) = MHEG5TRUE;
2640  break;
2641 
2642  case MHERR_OK:
2643  *((MHEG5Int *)(pvr_program->resultValue)) = 0;
2644  *(pvr_program->forkSucceededValue) = MHEG5TRUE;
2645  break;
2646 
2647  case MHERR_CONFLICT:
2648  *((MHEG5Int *)(pvr_program->resultValue)) = -1;
2649  *(pvr_program->forkSucceededValue) = MHEG5TRUE;
2650  break;
2651 
2652  case MHERR_REQUEST_IGNORED:
2653  *((MHEG5Int *)(pvr_program->resultValue)) = -4;
2654  *(pvr_program->forkSucceededValue) = MHEG5TRUE;
2655  break;
2656 
2657  default:
2658  TRACE(TERROR, ("Invalid result %d", result))
2659  }
2660 
2661  ProgramCompleted( pvr_program );
2662 
2663  pvr_program = NULL;
2664  }
2665 }
2666 
2667 #endif /*defined(INCLUDE_MHEG_PVR) || defined(INCLUDE_PVR_AU)*/
2668 
2669 #ifdef INCLUDE_MHEG_PVR
2670 
2687 static MHEG5ErrorCode MHEG5prgPVR_MakeBooking(MHEG5Program *program)
2688 {
2689  MHEG5GList *nextParam;
2690  MHEG5Root *callVar = 0, *intgVar = 0;
2691  S_STRING crid;
2692  S_CRID_DETAILS crid_details;
2693  MHEG5Bool invalidString;
2694 
2695  assert(program);
2696  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2697  if (!nextParam)
2698  {
2700  }
2701  nextParam = MHEG5resolveGenericOctetString( nextParam, (MHEG5String *)&crid, &invalidString);
2702  if (!nextParam)
2703  {
2705  }
2706  if (invalidString)
2707  {
2708  /* Parameter was not an octet string */
2709  return MHEG5ERR_WRONGPARAM;
2710  }
2711  nextParam = MHEG5resolveGenericInteger( nextParam, (MHEG5Int *)&crid_details.type);
2712  if (!nextParam)
2713  {
2715  }
2716  if (crid_details.type != 0x31 && crid_details.type != 0x32)
2717  {
2718  return MHEG5ERR_WRONGPARAM;
2719  }
2720  nextParam = MHEG5resolveGenericOctetString( nextParam,
2721  (MHEG5String *)&crid_details.title, &invalidString );
2722  if (!nextParam)
2723  {
2725  }
2726  if (invalidString)
2727  {
2728  /* Parameter was not an octet string */
2729  return MHEG5ERR_WRONGPARAM;
2730  }
2731  nextParam = MHEG5resolveGenericOctetString( nextParam,
2732  (MHEG5String *)&crid_details.description, &invalidString );
2733  if (!nextParam)
2734  {
2736  }
2737  if (invalidString)
2738  {
2739  /* Parameter was not an octet string */
2740  return MHEG5ERR_WRONGPARAM;
2741  }
2742  MHEG5resolveORef(nextParam, &intgVar);
2743 
2744  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
2745  (!intgVar) || (intgVar->clazz != MHEG5INTEGERVARIABLE))
2746  {
2747  return MHEG5ERR_WRONGPARAM;
2748  }
2749 
2750  TRACE(TEVNTS, ("%s", crid.zptr))
2751 
2752  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2753 
2754 
2755  switch (DVB_MhegPvrMakeBooking( crid, &crid_details ))
2756  {
2757  case MHERR_ALTERNATIVE_FOUND: ((MHEG5IntegerVariable *) intgVar)->value = 1; break;
2758  case MHERR_OK: ((MHEG5IntegerVariable *) intgVar)->value = 0; break;
2759  case MHERR_CONFLICT: ((MHEG5IntegerVariable *) intgVar)->value = -1; break;
2760  case MHERR_OBJECT_NOT_FOUND: ((MHEG5IntegerVariable *) intgVar)->value = -2; break;
2761  case MHERR_REQUEST_IGNORED: ((MHEG5IntegerVariable *) intgVar)->value = -3; break;
2762  default:
2763  case MHERR_OTHER: ((MHEG5IntegerVariable *) intgVar)->value = -5; break;
2764 
2765  case MHERR_RESULT_PENDING:
2766  {
2767  pvr_program = program;
2768  if (program->forked)
2769  {
2770  /* Set the forkSuceeded default to FALSE */
2771  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
2772  }
2773  else
2774  {
2775  /* For a called program disable event processing until the program ends */
2776  TRACE(TFILE, (""))
2778  }
2779  program->resultValue = &((MHEG5IntegerVariable *) intgVar)->value;
2780  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
2781  }
2782  }
2783  return MHERR_OK;
2784 }
2785 
2801 static MHEG5ErrorCode MHEG5prgPVR_CancelBooking(MHEG5Program *program)
2802 {
2803  MHEG5GList *nextParam;
2804  MHEG5Root *callVar = 0, *intgVar = 0;
2805  //MHEG5String crid;
2806  S_STRING crid;
2807  MHEG5Int crid_type;
2808  MHEG5Bool invalidString;
2809 
2810  assert(program);
2811  nextParam = MHEG5resolveORef( program->parameter, &callVar );
2812  if (!nextParam)
2813  {
2815  }
2816  nextParam = MHEG5resolveGenericOctetString( nextParam,
2817  (MHEG5String *)&crid, &invalidString );
2818  if (!nextParam)
2819  {
2821  }
2822  if (invalidString)
2823  {
2824  /* Parameter was not an octet string */
2825  return MHEG5ERR_WRONGPARAM;
2826  }
2827  nextParam = MHEG5resolveGenericInteger( nextParam, &crid_type );
2828  if (!nextParam)
2829  {
2831  }
2832  if (crid_type != 0x31 && crid_type != 0x32)
2833  {
2834  return MHEG5ERR_WRONGPARAM;
2835  }
2836  MHEG5resolveORef(nextParam, &intgVar);
2837 
2838  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
2839  (!intgVar) || (intgVar->clazz != MHEG5INTEGERVARIABLE))
2840  {
2841  return MHEG5ERR_WRONGPARAM;
2842  }
2843 
2844  TRACE(TEVNTS, ("%s", crid.zptr))
2845 
2846  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2847 
2848  switch (DVB_MhegPvrCancelBooking( crid, (U16BIT)crid_type ))
2849  {
2850  case MHERR_OK: ((MHEG5IntegerVariable *) intgVar)->value = 0; break;
2851  case MHERR_CONFLICT: ((MHEG5IntegerVariable *) intgVar)->value = -1; break;
2852  case MHERR_OBJECT_NOT_FOUND: ((MHEG5IntegerVariable *) intgVar)->value = -2; break;
2853  default:
2854  case MHERR_REQUEST_IGNORED: ((MHEG5IntegerVariable *) intgVar)->value = -3; break;
2855  }
2856  return MHERR_OK;
2857 }
2858 
2871 static MHEG5ErrorCode MHEG5prgPVR_ListBookings(MHEG5Program *program)
2872 {
2873  MHEG5GList *nextParam;
2874  MHEG5Root *callVar = 0, *ostrVar = 0;
2875  S_CRID_REC *crid_list;
2876  U16BIT number, ndx;
2877  MHEG5String out_str;
2878 
2879  assert(program);
2880  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2881  if (!nextParam)
2882  {
2884  }
2885  MHEG5resolveORef(nextParam, &ostrVar);
2886 
2887  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
2888  (!ostrVar) || (ostrVar->clazz != MHEG5OCTETSTRINGVARIABLE))
2889  {
2890  return MHEG5ERR_WRONGPARAM;
2891  }
2892 
2893  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) ostrVar)->value);
2894  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
2895 
2896  crid_list = DVB_MhegPvrListBookings( &number );
2897  out_str.len = 0;
2898  if (crid_list != NULL)
2899  {
2900  for (ndx = 0; ndx != number; ndx++)
2901  {
2902  out_str.len += crid_list[ndx].crid.zlen + 4; /* 4 for: ' '+('49'||'50')+(' '||'\0') */
2903  }
2904  out_str.data = STR_DataAlloc( out_str.len );
2905  if (out_str.data != NULL)
2906  {
2907  MHEG5Byte *pData = out_str.data;
2908  for (ndx = 0; ndx != number; ndx++)
2909  {
2910  memcpy( pData, crid_list[ndx].crid.zptr, crid_list[ndx].crid.zlen );
2911  pData += crid_list[ndx].crid.zlen;
2912  if (crid_list[ndx].type == 49)
2913  {
2914  memcpy( pData, " 49 ", 4 );
2915  }
2916  else
2917  {
2918  memcpy( pData, " 50 ", 4 );
2919  }
2920  pData += 4;
2921  }
2922  pData--;
2923  *pData = 0;
2924  }
2925  DVB_MhegPvrReleaseList(crid_list);
2926  }
2927  else
2928  {
2929  out_str.data = NULL;
2930  }
2931  ((MHEG5OctetStringVariable *) ostrVar)->value = out_str;
2932 
2933  #ifdef TRACING
2934  if (mheg_trace_debug & (TACTIONS | TEVNTS))
2935  {
2936  char buff[512];
2937  strcpy(buff, T_NL "WhoAmI( ");
2938  MHEG5stringTrace(((MHEG5OctetStringVariable *) ostrVar)->value, buff, 0, 120 );
2939  strcat(buff, " )");
2940  DBG_PRINTF(buff);
2941  }
2942  #endif
2943  return MHERR_OK;
2944 }
2945 
2946 #endif /*INCLUDE_MHEG_PVR*/
2947 
2948 #ifdef INCLUDE_PVR_AU
2949 
2966 static MHEG5ErrorCode MHEG5prgPVR_MakeBooking2(MHEG5Program *program)
2967 {
2968  MHEG5GList *nextParam;
2969  MHEG5Root *callVar = 0, *intgVar = 0;
2970  S_STRING crid;
2971  MHEG5String bookingDetails;
2972  S_CRID_DETAILS crid_details;
2973  MHEG5Bool invalidString;
2974 
2975  assert(program);
2976  nextParam = MHEG5resolveORef(program->parameter, &callVar);
2977  if (!nextParam)
2978  {
2980  }
2981  nextParam = MHEG5resolveGenericOctetString( nextParam, (MHEG5String *)&crid, &invalidString);
2982  if (!nextParam)
2983  {
2985  }
2986  if (invalidString)
2987  {
2988  /* Parameter was not an octet string */
2989  return MHEG5ERR_WRONGPARAM;
2990  }
2991  nextParam = MHEG5resolveGenericOctetString( nextParam, &bookingDetails, &invalidString);
2992  if (!nextParam)
2993  {
2995  }
2996  if (invalidString)
2997  {
2998  /* Parameter was not an octet string */
2999  return MHEG5ERR_WRONGPARAM;
3000  }
3001  MHEG5resolveORef(nextParam, &intgVar);
3002 
3003  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3004  (!intgVar) || (intgVar->clazz != MHEG5INTEGERVARIABLE))
3005  {
3006  return MHEG5ERR_WRONGPARAM;
3007  }
3008 
3009  TRACE(TEVNTS, ("%s", crid.zptr))
3010 
3011  if (!MHEG5parseDecodeBookings( bookingDetails, &crid_details ))
3012  {
3013  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
3014  }
3015  else
3016  {
3017  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3018 
3019  switch (DVB_MhegPvrMakeBooking( crid, &crid_details ))
3020  {
3021  case MHERR_OK: ((MHEG5IntegerVariable *) intgVar)->value = 0; break;
3022  case MHERR_CONFLICT: ((MHEG5IntegerVariable *) intgVar)->value = -1; break;
3023  case MHERR_REQUEST_IGNORED: ((MHEG5IntegerVariable *) intgVar)->value = -4; break;
3024  default:
3025  case MHERR_OTHER: ((MHEG5IntegerVariable *) intgVar)->value = -5; break;
3026  case MHEG5_INSUFFICIENT_SPACE:((MHEG5IntegerVariable *) intgVar)->value = -6; break;
3027  case MHERR_OVERBOOKED: ((MHEG5IntegerVariable *) intgVar)->value = -7; break;
3028  case MHEG5_RESULT_PENDING:
3029  {
3030  pvr_program = program;
3031  if (program->forked)
3032  {
3033  /* Set the forkSuceeded default to FALSE */
3034  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
3035  }
3036  else
3037  {
3038  /* For a called program disable event processing until the program ends */
3039  TRACE(TFILE, (""))
3041  }
3042  program->resultValue = &((MHEG5IntegerVariable *) intgVar)->value;
3043  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
3044  }
3045  }
3046  MHEG5freeDecodeBookings( &crid_details );
3047  }
3048  return MHERR_OK;
3049 }
3050 
3065 static MHEG5ErrorCode MHEG5prgPVR_CancelBooking2(MHEG5Program *program)
3066 {
3067  MHEG5GList *nextParam;
3068  MHEG5Root *callVar = 0, *intgVar = 0;
3069  //MHEG5String crid;
3070  S_STRING crid;
3071  MHEG5Int crid_type;
3072  MHEG5Bool invalidString;
3073 
3074  assert(program);
3075  nextParam = MHEG5resolveORef( program->parameter, &callVar );
3076  if (!nextParam)
3077  {
3079  }
3080  nextParam = MHEG5resolveGenericOctetString( nextParam,
3081  (MHEG5String *)&crid, &invalidString );
3082  if (!nextParam)
3083  {
3085  }
3086  if (invalidString)
3087  {
3088  /* Parameter was not an octet string */
3089  return MHEG5ERR_WRONGPARAM;
3090  }
3091  nextParam = MHEG5resolveGenericInteger( nextParam, &crid_type );
3092  if (!nextParam)
3093  {
3095  }
3096  if (crid_type != 0x31 && crid_type != 0x32)
3097  {
3098  return MHEG5ERR_WRONGPARAM;
3099  }
3100  MHEG5resolveORef(nextParam, &intgVar);
3101 
3102  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3103  (!intgVar) || (intgVar->clazz != MHEG5INTEGERVARIABLE))
3104  {
3105  return MHEG5ERR_WRONGPARAM;
3106  }
3107 
3108  TRACE(TEVNTS, ("%s", crid.zptr))
3109 
3110  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3111 
3112  switch (DVB_MhegPvrCancelBooking( crid, (S32BIT)crid_type ))
3113  {
3114  case MHERR_OK: ((MHEG5IntegerVariable *) intgVar)->value = 0; break;
3115  case MHERR_OBJECT_NOT_FOUND: ((MHEG5IntegerVariable *) intgVar)->value = -2; break;
3116  default:
3117  case MHERR_OTHER: ((MHEG5IntegerVariable *) intgVar)->value = -4; break;
3118  }
3119  return MHERR_OK;
3120 }
3121 
3133 static MHEG5ErrorCode MHEG5prgPVR_ListBookings2(MHEG5Program *program)
3134 {
3135  MHEG5GList *nextParam;
3136  MHEG5Root *callVar = 0, *ostrVar = 0;
3137  S_CRID_REC *crid_list;
3138  U16BIT number, ndx;
3139  MHEG5String out_str;
3140 
3141  assert(program);
3142  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3143  if (!nextParam)
3144  {
3146  }
3147  MHEG5resolveORef(nextParam, &ostrVar);
3148 
3149  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3150  (!ostrVar) || (ostrVar->clazz != MHEG5OCTETSTRINGVARIABLE))
3151  {
3152  return MHEG5ERR_WRONGPARAM;
3153  }
3154 
3155  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) ostrVar)->value);
3156  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3157 
3158  crid_list = DVB_MhegPvrListBookings( &number );
3159  out_str.len = 0;
3160  if (crid_list != NULL)
3161  {
3162  for (ndx = 0; ndx != number; ndx++)
3163  {
3164  out_str.len += crid_list[ndx].crid.zlen + 4; /* 4 for: ' '+('49'||'50')+(' '||'\0') */
3165  }
3166  out_str.data = STR_DataAlloc( out_str.len );
3167  if (out_str.data != NULL)
3168  {
3169  MHEG5Byte *pData = out_str.data;
3170  for (ndx = 0; ndx != number; ndx++)
3171  {
3172  memcpy( pData, crid_list[ndx].crid.zptr, crid_list[ndx].crid.zlen );
3173  pData += crid_list[ndx].crid.zlen;
3174  *pData = ' ';
3175  pData++;
3176  }
3177  pData--;
3178  *pData = 0;
3179  }
3180  DVB_MhegPvrReleaseList(crid_list);
3181  }
3182  else
3183  {
3184  out_str.data = NULL;
3185  }
3186  ((MHEG5OctetStringVariable *) ostrVar)->value = out_str;
3187 
3188  #ifdef TRACING
3189  if (mheg_trace_debug & (TACTIONS | TEVNTS))
3190  {
3191  char buff[512];
3192  strcpy(buff, T_NL "PVR_ListBooking2( ");
3193  MHEG5stringTrace(((MHEG5OctetStringVariable *) ostrVar)->value, buff, 0, 120 );
3194  strcat(buff, " )");
3195  DBG_PRINTF(buff);
3196  }
3197  #endif
3198  return MHERR_OK;
3199 }
3200 
3215 static MHEG5ErrorCode MHEG5prgPVR_GetDetails2(MHEG5Program *program)
3216 {
3217  MHEG5GList *nextParam;
3218  MHEG5Root *callVar = 0, *ostrVar = 0;
3219  S_STRING crid;
3220  S_CRID_DETAILS *pDetails;
3221  MHEG5String out_str;
3222  MHEG5Bool invalidString;
3223 
3224  assert(program);
3225  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3226  if (!nextParam)
3227  {
3229  }
3230  nextParam = MHEG5resolveGenericOctetString( nextParam,
3231  (MHEG5String *)&crid, &invalidString );
3232  if (!nextParam)
3233  {
3235  }
3236  if (invalidString)
3237  {
3238  /* Parameter was not an octet string */
3239  return MHEG5ERR_WRONGPARAM;
3240  }
3241  MHEG5resolveORef(nextParam, &ostrVar);
3242 
3243  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3244  (!ostrVar) || (ostrVar->clazz != MHEG5OCTETSTRINGVARIABLE))
3245  {
3246  return MHEG5ERR_WRONGPARAM;
3247  }
3248 
3249  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) ostrVar)->value);
3250  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3251 
3252  pDetails = DVB_MhegPvrGetDetails( crid );
3253  out_str.len = 0;
3254  out_str.data = NULL;
3255  if (pDetails != NULL)
3256  {
3257  if (pDetails->bookings != NULL)
3258  {
3259  MHEG5parseEncodeBooking( pDetails, out_str );
3260  }
3261  DVB_MhegPvrReleaseDetails( pDetails );
3262  }
3263  ((MHEG5OctetStringVariable *) ostrVar)->value = out_str;
3264 
3265  #ifdef TRACING
3266  if (mheg_trace_debug & (TACTIONS | TEVNTS))
3267  {
3268  char buff[512];
3269  strcpy(buff, T_NL "PVR_GetDetails2( ");
3270  MHEG5stringTrace(((MHEG5OctetStringVariable *) ostrVar)->value, buff, 0, 120 );
3271  strcat(buff, " )");
3272  DBG_PRINTF(buff);
3273  }
3274  #endif
3275  return MHERR_OK;
3276 }
3277 
3278 #endif /*INCLUDE_PVR_AU*/
3279 
3280 
3281 #ifdef INCLUDE_CI_PLUS
3282 /* 12.3.6.1 in CI+ Specification */
3315 static MHEG5ErrorCode MHEG5prgRequestMPEGDecoder(MHEG5Program *program)
3316 {
3317  MHEG5GList *nextParam;
3318  MHEG5Root *callVar = 0, *resultVar = 0;
3319  MHEG5Bool request;
3320 
3321  assert(program);
3322 
3323  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3324  if (!nextParam)
3325  {
3327  }
3328  nextParam = MHEG5resolveGenericBoolean(nextParam, &request);
3329  if (!nextParam)
3330  {
3332  }
3333  MHEG5resolveORef(nextParam, &resultVar);
3334 
3335  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
3336  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)))
3337  {
3338  return MHEG5ERR_WRONGPARAM;
3339  }
3340 
3341  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5RequestMPEGDecoder(request);
3342  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3343 
3344  return MHEG5ERR_NOERROR;
3345 }
3346 
3347 /* 12.8.1.2 in CI+ Specification */
3353 static MHEG5ErrorCode MHEG5prgSuppressMHEGGraphics(MHEG5Program *program)
3354 {
3355  MHEG5GList *nextParam;
3356  MHEG5Root *callVar = 0;
3357  MHEG5Bool request;
3358 
3359  assert(program);
3360 
3361  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3362  if (!nextParam)
3363  {
3365  }
3366  MHEG5resolveGenericBoolean(nextParam, &request);
3367 
3368  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
3369  {
3370  return MHEG5ERR_WRONGPARAM;
3371  }
3372 
3373  MHEG5SuppressMHEGGraphics(request);
3374  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3375 
3376  return MHEG5ERR_NOERROR;
3377 }
3378 
3379 #endif /* INCLUDE_CI_PLUS */
3380 
3386 static MHEG5ErrorCode MHEG5prgTestInputMask(MHEG5Program *program)
3387 {
3388  MHEG5GList *nextParam;
3389  MHEG5Root *callVar = 0, *boolVar;
3390  MHEG5String maskVar;
3391  MHEG5Bool invalidString;
3392 
3393  assert(program);
3394  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3395  if (!nextParam)
3396  {
3398  }
3399  nextParam = MHEG5resolveGenericOctetString(nextParam, &maskVar, &invalidString);
3400  if (!nextParam)
3401  {
3403  }
3404  if (invalidString)
3405  {
3406  /* Parameter was not an octet string */
3407  return MHEG5ERR_WRONGPARAM;
3408  }
3409  MHEG5resolveORef(nextParam, &boolVar);
3410  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3411  (!boolVar) || (boolVar->clazz != MHEG5BOOLEANVARIABLE))
3412  {
3413  return MHEG5ERR_WRONGPARAM;
3414  }
3415 
3416  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3417  ((MHEG5BooleanVariable *) boolVar)->value = MHEG5IsInputMaskSupported(maskVar);
3418  return MHEG5ERR_NOERROR;
3419 }
3420 
3421 #ifdef INCLUDE_IC
3422 
3438 static MHEG5ErrorCode MHEG5prgSetHybridFileSystem(MHEG5Program *program)
3439 {
3440  MHEG5GList *nextParam;
3441  MHEG5Root *callVar = 0;
3442  MHEG5String pathName;
3443  MHEG5String mappingList;
3444  MHEG5Bool invalidString;
3445 
3446  assert(program);
3447  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3448  if (!nextParam)
3449  {
3451  }
3452  nextParam = MHEG5resolveGenericOctetString( nextParam, &pathName, &invalidString);
3453  if (!nextParam)
3454  {
3456  }
3457  if (invalidString)
3458  {
3459  /* Parameter was not an octet string */
3460  return MHEG5ERR_WRONGPARAM;
3461  }
3462  nextParam = MHEG5resolveGenericOctetString( nextParam, &mappingList, &invalidString);
3463  if (invalidString)
3464  {
3465  /* Parameter was not an octet string */
3466  return MHEG5ERR_WRONGPARAM;
3467  }
3468  if (nextParam)
3469  {
3470  /* Should only be 2 parameters */
3472  }
3473 
3474  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
3475  {
3476  return MHEG5ERR_WRONGPARAM;
3477  }
3478 
3479  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3480 
3481  #ifdef TRACING
3482  if ((mheg_trace_debug & (TACTIONS | TEVNTS)) && !(mheg_trace_debug & TFILE))
3483  {
3484  char buff[512];
3485  strcpy(buff, T_NL "SetHybridFileSystem( ");
3486  MHEG5stringTrace(pathName, buff, 0, 120);
3487  strcat(buff, ", ");
3488  MHEG5stringTrace(mappingList, buff, 0, 230);
3489  strcat(buff, " )");
3490  DBG_PRINTF(buff);
3491  }
3492  #endif
3493 
3494  MHEG5SetHybridFileSystem(&pathName, &mappingList);
3495 
3496  return MHEG5ERR_NOERROR;
3497 }
3498 
3509 static MHEG5ErrorCode MHEG5prgGetICStatus(MHEG5Program *program)
3510 {
3511  MHEG5GList *nextParam;
3512  MHEG5Root *callVar = 0, *icStatusVar = 0;
3513  MHEG5Int icStatus;
3514 
3515  assert(program);
3516  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3517  if (!nextParam)
3518  {
3520  }
3521 
3522  MHEG5resolveORef(nextParam, &icStatusVar);
3523 
3524  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3525  (!icStatusVar) || (icStatusVar->clazz != MHEG5INTEGERVARIABLE))
3526  {
3527  return MHEG5ERR_WRONGPARAM;
3528  }
3529  MHEG5getICStatus( &icStatus );
3530  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3531  ((MHEG5IntegerVariable *) icStatusVar)->value = icStatus;
3532 
3533  return MHEG5ERR_NOERROR;
3534 }
3535 
3551 static MHEG5ErrorCode MHEG5prgSetCookie(MHEG5Program *program)
3552 {
3553  MHEG5GList *nextParam;
3554  MHEG5Root *callVar = 0;
3555  MHEG5Bool invalidString;
3556 
3557  MHEG5Int expiryDate;
3558  MHEG5String value;
3559  MHEG5Bool secure;
3560  MHEG5String identity;
3561 
3562  MHEG5cookie_t cookie_data;
3563 
3564  assert(program);
3565  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3566  if (!nextParam)
3567  {
3569  }
3570 
3571  nextParam = MHEG5resolveGenericOctetString( nextParam, &identity, &invalidString);
3572  if (!nextParam)
3573  {
3575  }
3576  if (invalidString)
3577  {
3578  /* Parameter was not an octet string */
3579  return MHEG5ERR_WRONGPARAM;
3580  }
3581 
3582  nextParam = MHEG5resolveGenericInteger( nextParam, &expiryDate );
3583  if (!nextParam)
3584  {
3586  }
3587 
3588  nextParam = MHEG5resolveGenericOctetString( nextParam, &value, &invalidString);
3589  if (!nextParam)
3590  {
3592  }
3593  if (invalidString)
3594  {
3595  /* Parameter was not an octet string */
3596  return MHEG5ERR_WRONGPARAM;
3597  }
3598 
3599  MHEG5resolveGenericBoolean( nextParam, &secure );
3600 
3601  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
3602  {
3603  return MHEG5ERR_WRONGPARAM;
3604  }
3605 
3606  cookie_data.value = value;
3607  cookie_data.secure = secure;
3608  cookie_data.expires = expiryDate;
3609  cookie_data.identity = identity;
3610 
3611  ((MHEG5BooleanVariable *) callVar)->value = MHEG5CookieAdd(&cookie_data);
3612 
3613  return MHEG5ERR_NOERROR;
3614 }
3615 
3632 static MHEG5ErrorCode MHEG5prgGetCookie(MHEG5Program *program)
3633 {
3634  MHEG5GList *nextParam;
3635  MHEG5Root *callVar = 0, *found = 0, *expiryDate = 0,
3636  *value = 0, *secure = 0;
3637  MHEG5String identity;
3638  MHEG5Bool invalidString;
3639 
3640  MHEG5cookie_t cookie_data;
3641 
3642  assert(program);
3643  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3644  if (!nextParam)
3645  {
3647  }
3648  nextParam = MHEG5resolveGenericOctetString( nextParam, &identity, &invalidString);
3649  if (!nextParam)
3650  {
3652  }
3653  if (invalidString)
3654  {
3655  /* Parameter was not an octet string */
3656  return MHEG5ERR_WRONGPARAM;
3657  }
3658 
3659  nextParam = MHEG5resolveORef( nextParam, &found);
3660  if (!nextParam)
3661  {
3663  }
3664  nextParam = MHEG5resolveORef( nextParam, &expiryDate);
3665  if (!nextParam)
3666  {
3668  }
3669  nextParam = MHEG5resolveORef( nextParam, &value);
3670  if (!nextParam)
3671  {
3673  }
3674  MHEG5resolveORef( nextParam, &secure);
3675 
3676 
3677  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
3678  (!found) || (found->clazz != MHEG5BOOLEANVARIABLE) ||
3679  (!expiryDate) || (expiryDate->clazz != MHEG5INTEGERVARIABLE) ||
3680  (!value) || (value->clazz != MHEG5OCTETSTRINGVARIABLE))
3681  {
3682  return MHEG5ERR_WRONGPARAM;
3683  }
3684 
3685  cookie_data.identity = identity;
3686  if (MHEG5CookieRetrieve(&cookie_data) == MHEG5TRUE)
3687  {
3688  ((MHEG5BooleanVariable *) found)->value = MHEG5TRUE;
3689 
3690  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) value)->value);
3691  ((MHEG5OctetStringVariable *) value)->value = MHEG5stringCopy(cookie_data.value);
3692 
3693  ((MHEG5BooleanVariable *) secure)->value = cookie_data.secure;
3694  ((MHEG5IntegerVariable *) expiryDate)->value = cookie_data.expires;
3695  }
3696  else
3697  {
3698  ((MHEG5BooleanVariable *) found)->value = MHEG5FALSE;
3699  }
3700  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
3701 
3702  return MHEG5ERR_NOERROR;
3703 }
3704 
3705 #endif /* INCLUDE_IC */
3706 
3707 
3708 #ifdef INCLUDE_IC
3709 
3718 static void returnDataCallback(void *userData, MHEG5String data, MHEG5Int code)
3719 {
3720  MHEG5Program *program;
3721 
3722  /* Cast userData to an (MHEG5Program *) */
3723  program = (MHEG5Program *)userData;
3724 
3725  *((MHEG5Int *)(program->resultCode)) = code;
3726  *((MHEG5String *)(program->resultValue)) = MHEG5stringCopy(data);
3727  *(program->forkSucceededValue) = MHEG5TRUE;
3728 
3729  ProgramCompleted( program );
3730 }
3731 
3756 static MHEG5ErrorCode MHEG5prgReturnData(MHEG5Program *program)
3757 {
3758  MHEG5GList *nextParam, *prevParam;
3759  MHEG5Root *callVar = 0;
3760  MHEG5Root *codeVar = 0;
3761  MHEG5Root *dataVar = 0;
3762  MHEG5IntegerVariable *rc1;
3764  MHEG5String url;
3765  MHEG5String data;
3766  MHEG5Bool invalidString;
3767  MHEG5String name;
3768  MHEG5Generic g;
3769  U8BIT *buffer = 0;
3770  MHEG5Int allocated = 0, used = 0;
3771  MHEG5Bool success;
3772 
3773  assert(program);
3774 
3775  /* callVar */
3776  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3777  if (!nextParam)
3778  {
3780  }
3781  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
3782  {
3783  return MHEG5ERR_WRONGPARAM;
3784  }
3785 
3786  /* URL */
3787  nextParam = MHEG5resolveGenericOctetString( nextParam, &url, &invalidString);
3788  if (!nextParam)
3789  {
3791  }
3792  if (invalidString)
3793  {
3794  /* Parameter was not an octet string */
3795  return MHEG5ERR_WRONGPARAM;
3796  }
3797 
3798  buffer = NULL;
3799 
3800  /* Next parameter can be either GenericOctetString (name) or
3801  * GenericInteger pointing at IntegerVariable (responseCode)
3802  */
3803  prevParam = nextParam;
3804  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
3805  while (nextParam && g.type == MHEG5OCTETSTRING)
3806  {
3807  name = g.value.s;
3808 
3809  /* Next parameter can be many things. */
3810  prevParam = nextParam;
3811  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
3812  success = MHEG5parseEncodeField(&buffer, &used, &allocated, &name, &g);
3813  if (!success)
3814  {
3815  nextParam = NULL;
3816  break;
3817  }
3818 
3819  /* Next parameter can be either GenericOctetString (name) or
3820  * GenericInteger pointing at IntegerVariable (responseCode)
3821  */
3822  prevParam = nextParam;
3823  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
3824  }
3825 
3826  if (!nextParam)
3827  {
3828  MHEG5freeMem(buffer);
3829  return MHEG5ERR_WRONGPARAM;
3830  }
3831 
3832  /* resolve responseCode */
3833  nextParam = MHEG5resolveORef(prevParam, &codeVar);
3834  if (!nextParam)
3835  {
3836  MHEG5freeMem(buffer);
3838  }
3839  if ((!codeVar) || (codeVar->clazz != MHEG5INTEGERVARIABLE))
3840  {
3841  MHEG5freeMem(buffer);
3842  return MHEG5ERR_WRONGPARAM;
3843  }
3844  rc1 = (MHEG5IntegerVariable *)codeVar;
3845 
3846  /* Resolve responseData */
3847  prevParam = nextParam;
3848  nextParam = MHEG5resolveORef(prevParam, &dataVar);
3849  if (nextParam)
3850  {
3851  MHEG5freeMem(buffer);
3853  }
3854  if ((!dataVar) || (dataVar->clazz != MHEG5OCTETSTRINGVARIABLE))
3855  {
3856  MHEG5freeMem(buffer);
3857  return MHEG5ERR_WRONGPARAM;
3858  }
3859  rc2 = (MHEG5OctetStringVariable *)dataVar;
3860 
3861  /* Make sure any currently stored string in rc2 is destroyed */
3862  MHEG5stringDestruct(&rc2->value);
3863 
3864  /* Set the forkSuceeded to default to FALSE */
3865  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
3866 
3867  program->resultCode = &rc1->value;
3868  program->resultValue = &rc2->value;
3869  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
3870 
3871  /* For a called program disable event processing until the program ends */
3872  if (!program->forked)
3873  {
3875  }
3876 
3877  data.len = used;
3878  data.data = buffer;
3879  MHEG5FileOrmReturnData(url, data, returnDataCallback, program);
3880  MHEG5freeMem(buffer);
3881 
3882  return MHEG5ERR_NOERROR;
3883 }
3884 
3885 #ifdef INCLUDE_ICS
3886 
3891 static void stopMeasurement(MHEG5Program *program)
3892 {
3894 }
3895 
3904 void MHEG5notifyStreamPerformanceMeasurement(MHEG5Root *root, MHEG5Int speed)
3905 {
3906  MHEG5Program *program;
3907 
3908  assert(root->clazz == MHEG5RESIDENTPROGRAM);
3909 
3910  program = (MHEG5Program *)root;
3911 
3912  /* Store speed */
3913  *((MHEG5Int *)(program->resultValue)) = speed;
3914 
3915  /* Call/Fork succeeded */
3916  *(program->forkSucceededValue) = MHEG5TRUE;
3917 
3918  ProgramCompleted( program );
3919 }
3920 
3942 static MHEG5ErrorCode MHEG5prgMeasureStreamPerformance(MHEG5Program *program)
3943 {
3944  MHEG5GList *nextParam;
3945  MHEG5Root *callVar = 0, *rcVar;
3946  MHEG5String url;
3947  MHEG5Int maxBytes;
3948  MHEG5IntegerVariable *speedVar;
3949  MHEG5Bool invalidString;
3950 
3951  assert(program);
3952  nextParam = MHEG5resolveORef(program->parameter, &callVar);
3953  if (!nextParam)
3954  {
3956  }
3957  nextParam = MHEG5resolveGenericOctetString(nextParam, &url, &invalidString);
3958  if (!nextParam)
3959  {
3961  }
3962  if (invalidString)
3963  {
3964  /* Parameter was not an octet string */
3965  return MHEG5ERR_WRONGPARAM;
3966  }
3967  nextParam = MHEG5resolveGenericInteger(nextParam, &maxBytes);
3968  if (!nextParam)
3969  {
3971  }
3972  nextParam = MHEG5resolveORef(nextParam, &rcVar);
3973  if (nextParam)
3974  {
3975  /* Should only be 3 parameters */
3977  }
3978 
3979  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
3980  ((!rcVar) || (rcVar->clazz != MHEG5INTEGERVARIABLE)))
3981  {
3982  return MHEG5ERR_WRONGPARAM;
3983  }
3984 
3985  /* Set speed to "unkown" */
3986  speedVar = (MHEG5IntegerVariable *)rcVar;
3987  speedVar->value = -1;
3988 
3989  /* Set the forkSuceeded to default to FALSE */
3990  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
3991 
3992  program->resultValue = &speedVar->value;
3993  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
3994 
3995  /* Set the function used to abort the performance measurement */
3996  program->stopFunc = stopMeasurement;
3997 
3998  /* For a called program disable event processing until the program ends */
3999  if (!program->forked)
4000  {
4002  }
4003 
4004  MHEG5StreamerMeasurePerformance(&url, maxBytes, program);
4005 
4006  return MHEG5ERR_NOERROR;
4007 }
4008 
4016 void MHEG5notifyGuidanceResponse(MHEG5Bool result)
4017 {
4018  MHEG5Program *program = guidance_program;
4019 
4020  if (program != NULL)
4021  {
4022  TPRINT((TACTIONS | TEVNTS), (T_NL "PIN result %d",result))
4023 
4024  /* Store result */
4025  *((MHEG5Bool *)(program->resultValue)) = result;
4026 
4027  /* Call/Fork succeeded */
4028  *(program->forkSucceededValue) = MHEG5TRUE;
4029 
4030  ProgramCompleted( program );
4031 
4032  guidance_program = NULL;
4033  }
4034 }
4035 
4041 static void stopPrompt(MHEG5Program *program)
4042 {
4043  if (guidance_program != NULL)
4044  {
4045  (void)MHEG5promptForGuidance(NULL, MHEG5FALSE);
4046  guidance_program = NULL;
4047  }
4048 }
4049 
4066 static MHEG5ErrorCode MHEG5prgPromptForGuidance(MHEG5Program *program)
4067 {
4068  MHEG5GList *nextParam;
4069  MHEG5Root *callVar = 0;
4070  MHEG5String restriction;
4071  MHEG5Root *resultVar;
4072  MHEG5Bool invalidString;
4073 
4074  assert(program);
4075  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4076  if (!nextParam)
4077  {
4079  }
4080  nextParam = MHEG5resolveGenericOctetString(nextParam, &restriction, &invalidString);
4081  if (!nextParam)
4082  {
4084  }
4085  if (invalidString)
4086  {
4087  /* Parameter was not an octet string */
4088  return MHEG5ERR_WRONGPARAM;
4089  }
4090 
4091  nextParam = MHEG5resolveORef(nextParam, &resultVar);
4092  if (nextParam)
4093  {
4094  /* Should only be 2 parameters */
4096  }
4097 
4098  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4099  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)))
4100  {
4101  return MHEG5ERR_WRONGPARAM;
4102  }
4103 
4104  if (!MHEG5IsPinRequired())
4105  {
4106  TPRINT((TACTIONS | TEVNTS), (T_NL "PIN not required"))
4107  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4108  ((MHEG5BooleanVariable *)resultVar)->value = MHEG5TRUE;
4109  }
4110  else
4111  {
4112  /* Set the forkSuceeded to default to FALSE */
4113  ((MHEG5BooleanVariable *) callVar)->value = MHEG5FALSE;
4114 
4115  program->resultValue = &(((MHEG5BooleanVariable *)resultVar)->value);
4116  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
4117 
4118  /* Set the function used to abort the performance measurement */
4119  program->stopFunc = stopPrompt;
4120 
4121  /* For a called program disable event processing until the program ends */
4122  if (!program->forked)
4123  {
4125  }
4126 
4127  guidance_program = program;
4128 
4129  TPRINT((TACTIONS | TEVNTS), (T_NL "requesting PIN"))
4130  if (!MHEG5promptForGuidance( &restriction, TRUE ))
4131  {
4132  ProgramCompleted( program );
4133 
4134  guidance_program = NULL;
4135  }
4136  }
4137  return MHEG5ERR_NOERROR;
4138 }
4139 
4153 static MHEG5ErrorCode MHEG5prgGetAudioDescPref(MHEG5Program *program)
4154 {
4155  MHEG5GList *nextParam;
4156  MHEG5Root *callVar = 0;
4157  MHEG5Root *viewerPref;
4158  BOOLEAN audioDescPref;
4159 
4160  assert(program);
4161  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4162  if (!nextParam)
4163  {
4165  }
4166  nextParam = MHEG5resolveORef(nextParam, &viewerPref);
4167  if (nextParam)
4168  {
4169  /* Should only be one parameter */
4171  }
4172 
4173  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4174  ((!viewerPref) || (viewerPref->clazz != MHEG5BOOLEANVARIABLE)))
4175  {
4176  return MHEG5ERR_WRONGPARAM;
4177  }
4178 
4179  audioDescPref = DVB_MhegAudioDescriptionPref();
4180  if (audioDescPref)
4181  {
4182  ((MHEG5BooleanVariable *) viewerPref)->value = MHEG5TRUE;
4183  }
4184  else
4185  {
4186  ((MHEG5BooleanVariable *) viewerPref)->value = MHEG5FALSE;
4187  }
4188  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4189 
4190  return MHEG5ERR_NOERROR;
4191 }
4192 
4206 static MHEG5ErrorCode MHEG5prgGetSubtitlePref(MHEG5Program *program)
4207 {
4208  MHEG5GList *nextParam;
4209  MHEG5Root *callVar = 0;
4210  MHEG5Root *viewerPref;
4211 
4212  assert(program);
4213  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4214  if (!nextParam)
4215  {
4217  }
4218  nextParam = MHEG5resolveORef(nextParam, &viewerPref);
4219  if (nextParam)
4220  {
4221  /* Should only be one parameter */
4223  }
4224 
4225  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4226  ((!viewerPref) || (viewerPref->clazz != MHEG5BOOLEANVARIABLE)))
4227  {
4228  return MHEG5ERR_WRONGPARAM;
4229  }
4230 
4232  {
4233  ((MHEG5BooleanVariable *) viewerPref)->value = MHEG5TRUE;
4234  }
4235  else
4236  {
4237  ((MHEG5BooleanVariable *) viewerPref)->value = MHEG5FALSE;
4238  }
4239  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4240 
4241  return MHEG5ERR_NOERROR;
4242 }
4243 
4244 
4245 #ifdef INCLUDE_IPLAYER
4246 
4259 static MHEG5ErrorCode MHEG5prgGetPINSupport(MHEG5Program *program)
4260 {
4261  MHEG5GList *nextParam;
4262  MHEG5Root *callVar = 0, *supportVar = 0;
4263  MHEG5Int support;
4264  MHEG5Bool success;
4265 
4266  assert(program);
4267  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4268  if (!nextParam)
4269  {
4271  }
4272 
4273  MHEG5resolveORef(nextParam, &supportVar);
4274 
4275  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
4276  (!supportVar) || (supportVar->clazz != MHEG5INTEGERVARIABLE))
4277  {
4278  return MHEG5ERR_WRONGPARAM;
4279  }
4280 
4281  success = MHEG5GetPINSupport(&support);
4282 
4283  ((MHEG5BooleanVariable *) callVar)->value = success;
4284  ((MHEG5IntegerVariable *) supportVar)->value = support;
4285 
4286  return MHEG5ERR_NOERROR;
4287 }
4288 
4289 #endif /* INCLUDE_IPLAYER */
4290 #ifdef INCLUDE_FREESAT
4291 
4304 static MHEG5ErrorCode MHEG5prgGetPINRequirement(MHEG5Program *program)
4305 {
4306  MHEG5GList *nextParam;
4307  MHEG5Root *callVar = 0, *statusVar = 0;
4308  MHEG5Int status;
4309  MHEG5Bool success;
4310 
4311  assert(program);
4312  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4313  if (!nextParam)
4314  {
4316  }
4317 
4318  MHEG5resolveORef(nextParam, &statusVar);
4319 
4320  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
4321  (!statusVar) || (statusVar->clazz != MHEG5INTEGERVARIABLE))
4322  {
4323  return MHEG5ERR_WRONGPARAM;
4324  }
4325 
4326  success = MHEG5GetPINRequirement(&status);
4327 
4328  ((MHEG5BooleanVariable *) callVar)->value = success;
4329  ((MHEG5IntegerVariable *) statusVar)->value = status;
4330 
4331  return MHEG5ERR_NOERROR;
4332 }
4333 
4346 static MHEG5ErrorCode MHEG5prgValidatePIN(MHEG5Program *program)
4347 {
4348  MHEG5GList *nextParam;
4349  MHEG5Root *callVar = 0;
4350  MHEG5String pin;
4351  MHEG5Root *statusVar;
4352  MHEG5Bool invalidString;
4353  MHEG5Int status;
4354  MHEG5Bool success;
4355 
4356  assert(program);
4357  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4358  if (!nextParam)
4359  {
4361  }
4362  nextParam = MHEG5resolveGenericOctetString(nextParam, &pin, &invalidString);
4363  if (!nextParam)
4364  {
4366  }
4367  if (invalidString)
4368  {
4369  /* Parameter was not an octet string */
4370  return MHEG5ERR_WRONGPARAM;
4371  }
4372 
4373  nextParam = MHEG5resolveORef(nextParam, &statusVar);
4374  if (nextParam)
4375  {
4376  /* Should only be 2 parameters */
4378  }
4379 
4380  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4381  ((!statusVar) || (statusVar->clazz != MHEG5INTEGERVARIABLE)))
4382  {
4383  return MHEG5ERR_WRONGPARAM;
4384  }
4385 
4386  success = MHEG5ValidatePIN(&pin, &status);
4387 
4388  ((MHEG5BooleanVariable *) callVar)->value = success;
4389  ((MHEG5IntegerVariable *) statusVar)->value = status;
4390 
4391  return MHEG5ERR_NOERROR;
4392 }
4393 
4406 static MHEG5ErrorCode MHEG5prgComputePrivateSignature(MHEG5Program *program)
4407 {
4408  MHEG5GList *nextParam;
4409  MHEG5Root *callVar = 0;
4410  MHEG5String data;
4411  MHEG5Root *resultVar;
4412  MHEG5Bool invalidString;
4413  MHEG5String result;
4414  MHEG5Bool success;
4415 
4416  assert(program);
4417  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4418  if (!nextParam)
4419  {
4421  }
4422  nextParam = MHEG5resolveGenericOctetString(nextParam, &data, &invalidString);
4423  if (!nextParam)
4424  {
4426  }
4427  if (invalidString)
4428  {
4429  /* Parameter was not an octet string */
4430  return MHEG5ERR_WRONGPARAM;
4431  }
4432 
4433  nextParam = MHEG5resolveORef(nextParam, &resultVar);
4434  if (nextParam)
4435  {
4436  /* Should only be 2 parameters */
4438  }
4439 
4440  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4441  ((!resultVar) || (resultVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
4442  {
4443  return MHEG5ERR_WRONGPARAM;
4444  }
4445 
4446  success = MHEG5ComputePrivateSignature(&data, &result);
4447 
4448  ((MHEG5BooleanVariable *) callVar)->value = success;
4449  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) resultVar)->value);
4450  ((MHEG5OctetStringVariable *) resultVar)->value = result;
4451 
4452  return MHEG5ERR_NOERROR;
4453 }
4454 
4470 static MHEG5ErrorCode MHEG5prgGetFSIServiceReference(MHEG5Program *program)
4471 {
4472  MHEG5GList *nextParam;
4473  MHEG5Root *callVar = 0, *fsi = 0, *fsiString = 0;
4474  MHEG5Int seviceIndex = 0, outputInt;
4475  MHEG5String outputString = {0, 0};
4476  MHEG5Bool rc;
4477 
4478  assert(program);
4479 
4480  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4481  if (!nextParam)
4482  {
4484  }
4485 
4486  nextParam = MHEG5resolveGenericInteger(nextParam, &seviceIndex);
4487  if (!nextParam)
4488  {
4490  }
4491 
4492  nextParam = MHEG5resolveORef(nextParam, &fsi);
4493  if (!nextParam)
4494  {
4496  }
4497 
4498  MHEG5resolveORef(nextParam, &fsiString);
4499 
4500  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
4501  (!fsi) || (fsi->clazz != MHEG5INTEGERVARIABLE) ||
4502  (!fsiString) || (fsiString->clazz != MHEG5OCTETSTRINGVARIABLE))
4503  {
4504  return MHEG5ERR_WRONGPARAM;
4505  }
4506 
4507  rc = MHEG5GetFSIServiceReference(seviceIndex, &outputInt, &outputString);
4508 
4509  ((MHEG5BooleanVariable *) callVar)->value = rc;
4510  ((MHEG5IntegerVariable *) fsi)->value = outputInt;
4511  MHEG5stringDestruct(&((MHEG5OctetStringVariable *) fsiString)->value);
4512  ((MHEG5OctetStringVariable *) fsiString)->value = outputString;
4513 
4514  return MHEG5ERR_NOERROR;
4515 }
4516 
4517 #endif /* INCLUDE_FREESAT */
4518 
4519 #endif /* INCLUDE_ICS */
4520 
4521 #endif /* INCLUDE_IC */
4522 
4523 
4524 #ifdef INCLUDE_SA_PROFILE
4525 
4540 static MHEG5ErrorCode MHEG5prgLNG_GetPreferredLangs(MHEG5Program *program)
4541 {
4542  MHEG5GList *nextParam;
4543  MHEG5Root *callVar = 0;
4544  MHEG5Root *audioVar;
4545  MHEG5Root *subsVar;
4546  MHEG5String *audioStr;
4547  MHEG5String *subsStr;
4549  U32BIT lang;
4550  U8BIT lstr[4] = {0,0,0,0};
4551 
4552  assert(program);
4553  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4554  if (!nextParam)
4555  {
4557  }
4558  nextParam = MHEG5resolveORef(nextParam, &audioVar);
4559  if (!nextParam)
4560  {
4562  }
4563  nextParam = MHEG5resolveORef(nextParam, &subsVar);
4564  if (nextParam)
4565  {
4566  /* Should only be 3 parameters */
4568  }
4569 
4570  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4571  ((!audioVar) || (audioVar->clazz != MHEG5OCTETSTRINGVARIABLE)) ||
4572  ((!subsVar) || (subsVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
4573  {
4574  return MHEG5ERR_WRONGPARAM;
4575  }
4576 
4577  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4578  audioStr = &((MHEG5OctetStringVariable *)audioVar)->value;
4579  subsStr = &((MHEG5OctetStringVariable *)subsVar)->value;
4580 
4581  buffer.data = lstr;
4582  buffer.len = 3;
4583  if (!DVB_MhegPrefAudioLangs(&lang,1))
4584  {
4585  lang = UND_LANGUAGE_CODE;
4586  }
4587  lstr[0] = (U8BIT)(lang >> 16);
4588  lstr[1] = (lang >> 8) & 0xFF;
4589  lstr[2] = lang & 0xFF;
4590  MHEG5stringDestruct(audioStr);
4591  *audioStr = MHEG5stringCopy(buffer);
4592 
4593  if (!DVB_MhegPrefSubtitleLangs(&lang,1))
4594  {
4595  lang = UND_LANGUAGE_CODE;
4596  }
4597  lstr[0] = (U8BIT)(lang >> 16);
4598  lstr[1] = (lang >> 8) & 0xFF;
4599  lstr[2] = lang & 0xFF;
4600  MHEG5stringDestruct(subsStr);
4601  *subsStr = MHEG5stringCopy(buffer);
4602 
4603  #ifdef TRACING
4604  if (mheg_trace_debug & (TACTIONS | TEVNTS))
4605  {
4606  char buff[512];
4607  strcpy(buff, T_NL "GetPreferredLangs( ");
4608  MHEG5stringTrace(*audioStr, buff, 0, 120);
4609  strcat(buff, ", ");
4610  MHEG5stringTrace(*subsStr, buff, 0, 230);
4611  strcat(buff, " )");
4612  DBG_PRINTF(buff);
4613  }
4614  #endif
4615 
4616  return MHEG5ERR_NOERROR;
4617 }
4618 
4619 #endif /* defined(INCLUDE_SA_PROFILE) */
4620 
4621 #ifdef INCLUDE_SA_PROFILE
4622 
4645 static MHEG5ErrorCode MHEG5prgLNG_GetAudioLangs(MHEG5Program *program)
4646 {
4647  MHEG5GList *nextParam;
4648  MHEG5Root *callVar = 0;
4649  MHEG5Int serviceIndex;
4650  MHEG5Int eventIndex;
4651  MHEG5Root *langsVar;
4652  MHEG5String *langsStr;
4654  U8BIT langs[256];
4655  E_MhegErr err;
4656 
4657  assert(program);
4658  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4659  if (!nextParam)
4660  {
4662  }
4663  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
4664  if (!nextParam)
4665  {
4667  }
4668  nextParam = MHEG5resolveGenericInteger(nextParam, &eventIndex);
4669  if (!nextParam)
4670  {
4672  }
4673  nextParam = MHEG5resolveORef(nextParam, &langsVar);
4674  if (nextParam)
4675  {
4676  /* Should only be 4 parameters */
4678  }
4679 
4680  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4681  ((!langsVar) || (langsVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
4682  {
4683  return MHEG5ERR_WRONGPARAM;
4684  }
4685 
4686  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4687  langsStr = &((MHEG5OctetStringVariable *)langsVar)->value;
4688  memset(langs, 0x0, sizeof(langs));
4689 
4690  err = DVB_MhegGetAudioLangs((S32BIT)serviceIndex, (S32BIT)eventIndex, langs);
4691  if (err == MHERR_OK)
4692  {
4693  MHEG5stringDestruct(langsStr);
4694  buffer.data = langs;
4695  buffer.len = strlen((char *)langs);
4696  *langsStr = MHEG5stringCopy(buffer);
4697  }
4698 
4699  #ifdef TRACING
4700  if (mheg_trace_debug & (TACTIONS | TEVNTS))
4701  {
4702  char buff[256];
4703  DBG_PRINTF(T_NL "LNG_GetADLangs( %ld, %ld, ", serviceIndex, eventIndex );
4704  *buff = 0;
4705  MHEG5stringTrace(*langsStr, buff, 0, 230);
4706  strcat(buff, " )");
4707  DBG_PRINTF(buff);
4708  }
4709  #endif
4710 
4711  return MHEG5ERR_NOERROR;
4712 }
4713 
4714 #endif /* defined(INCLUDE_SA_PROFILE) */
4715 
4716 #ifdef INCLUDE_SA_PROFILE
4717 
4741 static MHEG5ErrorCode MHEG5prgLNG_GetSubtitleLangs(MHEG5Program *program)
4742 {
4743  MHEG5GList *nextParam;
4744  MHEG5Root *callVar = 0;
4745  MHEG5Int serviceIndex;
4746  MHEG5Int eventIndex;
4747  MHEG5Root *langsVar;
4748  MHEG5String *langsStr;
4750  U8BIT langs[256];
4751  E_MhegErr err;
4752 
4753  assert(program);
4754  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4755  if (!nextParam)
4756  {
4758  }
4759  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
4760  if (!nextParam)
4761  {
4763  }
4764  nextParam = MHEG5resolveGenericInteger(nextParam, &eventIndex);
4765  if (!nextParam)
4766  {
4768  }
4769  nextParam = MHEG5resolveORef(nextParam, &langsVar);
4770  if (nextParam)
4771  {
4772  /* Should only be 4 parameters */
4774  }
4775 
4776  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4777  ((!langsVar) || (langsVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
4778  {
4779  return MHEG5ERR_WRONGPARAM;
4780  }
4781 
4782  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4783  langsStr = &((MHEG5OctetStringVariable *)langsVar)->value;
4784  memset(langs, 0x0, sizeof(langs));
4785 
4786  err = DVB_MhegGetSubtitleLangs((S32BIT)serviceIndex, (S32BIT)eventIndex,
4787  langs);
4788  if (err == MHERR_OK)
4789  {
4790  MHEG5stringDestruct(langsStr);
4791  buffer.data = langs;
4792  buffer.len = strlen((char *)langs);
4793  *langsStr = MHEG5stringCopy(buffer);
4794  }
4795 
4796  #ifdef TRACING
4797  if (mheg_trace_debug & (TACTIONS | TEVNTS))
4798  {
4799  char buff[256];
4800  DBG_PRINTF(T_NL "LNG_GetAudioLangs( %ld, %ld, ", serviceIndex, eventIndex );
4801  *buff = 0;
4802  MHEG5stringTrace(*langsStr, buff, 0, 230);
4803  strcat(buff, " )");
4804  DBG_PRINTF(buff);
4805  }
4806  #endif
4807 
4808  return MHEG5ERR_NOERROR;
4809 }
4810 
4811 #endif /* defined(INCLUDE_SA_PROFILE) */
4812 
4813 #ifdef INCLUDE_SA_PROFILE
4814 
4839 static MHEG5ErrorCode MHEG5prgLNG_GetADLangs(MHEG5Program *program)
4840 {
4841  MHEG5GList *nextParam;
4842  MHEG5Root *callVar = 0;
4843  MHEG5Int serviceIndex;
4844  MHEG5Int eventIndex;
4845  MHEG5Root *langsVar;
4846  MHEG5String *langsStr;
4848  U8BIT langs[256];
4849  E_MhegErr err;
4850 
4851  assert(program);
4852  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4853  if (!nextParam)
4854  {
4856  }
4857  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
4858  if (!nextParam)
4859  {
4861  }
4862  nextParam = MHEG5resolveGenericInteger(nextParam, &eventIndex);
4863  if (!nextParam)
4864  {
4866  }
4867  nextParam = MHEG5resolveORef(nextParam, &langsVar);
4868  if (nextParam)
4869  {
4870  /* Should only be 4 parameters */
4872  }
4873 
4874  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4875  ((!langsVar) || (langsVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
4876  {
4877  return MHEG5ERR_WRONGPARAM;
4878  }
4879 
4880  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4881  langsStr = &((MHEG5OctetStringVariable *)langsVar)->value;
4882  memset(langs, 0x0, sizeof(langs));
4883 
4884  err = DVB_MhegGetADLangs((S32BIT)serviceIndex, (S32BIT)eventIndex, langs);
4885  if (err == MHERR_OK)
4886  {
4887  MHEG5stringDestruct(langsStr);
4888  buffer.data = langs;
4889  buffer.len = strlen((char *)langs);
4890  *langsStr = MHEG5stringCopy(buffer);
4891  }
4892 
4893  #ifdef TRACING
4894  if (mheg_trace_debug & (TACTIONS | TEVNTS))
4895  {
4896  char buff[256];
4897  DBG_PRINTF(T_NL "LNG_GetSubtitleLangs( %ld, %ld, ", serviceIndex, eventIndex );
4898  *buff = 0;
4899  MHEG5stringTrace(*langsStr, buff, 0, 230);
4900  strcat(buff, " )");
4901  DBG_PRINTF(buff);
4902  }
4903  #endif
4904 
4905  return MHEG5ERR_NOERROR;
4906 }
4907 
4908 #endif /* defined(INCLUDE_SA_PROFILE) */
4909 
4910 #ifdef INCLUDE_SA_PROFILE
4911 
4929 static MHEG5ErrorCode MHEG5prgREM_SetNativeReminder(MHEG5Program *program)
4930 {
4931  MHEG5GList *nextParam;
4932  MHEG5Root *callVar = 0;
4933  MHEG5Int serviceIndex;
4934  MHEG5Int eventId;
4935  MHEG5Root *resultVar;
4936  BOOLEAN result;
4937  E_MhegErr err;
4938 
4939  assert(program);
4940  nextParam = MHEG5resolveORef(program->parameter, &callVar);
4941  if (!nextParam)
4942  {
4944  }
4945  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
4946  if (!nextParam)
4947  {
4949  }
4950  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
4951  if (!nextParam)
4952  {
4954  }
4955  nextParam = MHEG5resolveORef(nextParam, &resultVar);
4956  if (nextParam)
4957  {
4958  /* Should only be 4 parameters */
4960  }
4961 
4962  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
4963  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)))
4964  {
4965  return MHEG5ERR_WRONGPARAM;
4966  }
4967 
4968  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
4969 
4970  err = DVB_MhegSetNativeReminder(serviceIndex, eventId, &result);
4971  if (err == MHERR_OK)
4972  {
4973  if (result)
4974  {
4975  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
4976  }
4977  else
4978  {
4979  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
4980  }
4981  }
4982 
4983  return MHEG5ERR_NOERROR;
4984 }
4985 
4986 #endif /* defined(INCLUDE_SA_PROFILE) */
4987 
4988 #ifdef INCLUDE_SA_PROFILE
4989 
5008 static MHEG5ErrorCode MHEG5prgREM_GetNativeReminder(MHEG5Program *program)
5009 {
5010  MHEG5GList *nextParam;
5011  MHEG5Root *callVar = 0;
5012  MHEG5Int serviceIndex;
5013  MHEG5Int eventId;
5014  MHEG5Root *setVar;
5015  BOOLEAN set;
5016  E_MhegErr err;
5017 
5018  assert(program);
5019  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5020  if (!nextParam)
5021  {
5023  }
5024  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
5025  if (!nextParam)
5026  {
5028  }
5029  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
5030  if (!nextParam)
5031  {
5033  }
5034  nextParam = MHEG5resolveORef(nextParam, &setVar);
5035  if (nextParam)
5036  {
5037  /* Should only be 4 parameters */
5039  }
5040 
5041  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5042  ((!setVar) || (setVar->clazz != MHEG5BOOLEANVARIABLE)))
5043  {
5044  return MHEG5ERR_WRONGPARAM;
5045  }
5046 
5047  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5048 
5049  err = DVB_MhegGetNativeReminder(serviceIndex, eventId, &set);
5050  if (err == MHERR_OK)
5051  {
5052  if (set)
5053  {
5054  ((MHEG5BooleanVariable *) setVar)->value = MHEG5TRUE;
5055  }
5056  else
5057  {
5058  ((MHEG5BooleanVariable *) setVar)->value = MHEG5FALSE;
5059  }
5060  }
5061 
5062  return MHEG5ERR_NOERROR;
5063 }
5064 
5065 #endif /* defined(INCLUDE_SA_PROFILE) */
5066 
5067 #ifdef INCLUDE_SA_PROFILE
5068 
5082 static MHEG5ErrorCode MHEG5prgREM_CancelNativeReminder(MHEG5Program *program)
5083 {
5084  MHEG5GList *nextParam;
5085  MHEG5Root *callVar = 0;
5086  MHEG5Int serviceIndex;
5087  MHEG5Int eventId;
5088 
5089  assert(program);
5090  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5091  if (!nextParam)
5092  {
5094  }
5095  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
5096  if (!nextParam)
5097  {
5099  }
5100  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
5101  if (nextParam)
5102  {
5103  /* Should only be 3 parameters */
5105  }
5106 
5107  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE))
5108  {
5109  return MHEG5ERR_WRONGPARAM;
5110  }
5111 
5112  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5113 
5114  DVB_MhegCancelNativeReminder(serviceIndex, eventId);
5115 
5116  return MHEG5ERR_NOERROR;
5117 }
5118 
5119 #endif /* defined(INCLUDE_SA_PROFILE) */
5120 
5121 #ifdef INCLUDE_SA_PROFILE
5122 
5159 static MHEG5ErrorCode MHEG5prgSA_GetHostSetting(MHEG5Program *program)
5160 {
5161  MHEG5GList *nextParam;
5162  MHEG5Root *callVar = 0;
5163  MHEG5String key;
5164  MHEG5Root *valueVar;
5165  MHEG5String *strVal;
5166  MHEG5Int *intVal;
5167  MHEG5Bool invalidString;
5168  S32BIT ivalue;
5169  U8BIT svalue[4] = { 0, 0, 0, 0 };
5171  E_MhegErr err;
5172 
5173  static char bannerTransparency[] = "BannerTransparency";
5174  static char bannerTimeout[] = "BannerTimeout";
5175  static char osdLanguage[] = "OSDLanguage";
5176  static char serviceMode[] = "ServiceMode";
5177 
5178  assert(program);
5179  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5180  if (!nextParam)
5181  {
5183  }
5184  nextParam = MHEG5resolveGenericOctetString(nextParam, &key,
5185  &invalidString);
5186  if (!nextParam)
5187  {
5189  }
5190  if (invalidString)
5191  {
5192  /* Parameter was not an octet string */
5193  return MHEG5ERR_WRONGPARAM;
5194  }
5195  nextParam = MHEG5resolveORef(nextParam, &valueVar);
5196  if (nextParam)
5197  {
5198  /* Should only be 3 parameters */
5200  }
5201 
5202  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5203  (!valueVar))
5204  {
5205  return MHEG5ERR_WRONGPARAM;
5206  }
5207 
5208  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5209 
5210  if (strcmp((char *)key.data, bannerTransparency) == 0)
5211  {
5212  if (valueVar->clazz != MHEG5INTEGERVARIABLE)
5213  {
5214  return MHEG5ERR_WRONGPARAM;
5215  }
5216  intVal = &((MHEG5IntegerVariable *)valueVar)->value;
5217  err = DVB_MhegGetBannerTransparency(&ivalue);
5218  if (err == MHERR_OK)
5219  {
5220  *intVal = ivalue;
5221  }
5222  }
5223  else if (strcmp((char *)key.data, bannerTimeout) == 0)
5224  {
5225  if (valueVar->clazz != MHEG5INTEGERVARIABLE)
5226  {
5227  return MHEG5ERR_WRONGPARAM;
5228  }
5229  intVal = &((MHEG5IntegerVariable *)valueVar)->value;
5230  err = DVB_MhegGetBannerTimeout(&ivalue);
5231  if (err == MHERR_OK)
5232  {
5233  *intVal = ivalue;
5234  }
5235  }
5236  else if (strcmp((char *)key.data, osdLanguage) == 0)
5237  {
5238  if (valueVar->clazz != MHEG5OCTETSTRINGVARIABLE)
5239  {
5240  return MHEG5ERR_WRONGPARAM;
5241  }
5242  strVal = &((MHEG5OctetStringVariable *)valueVar)->value;
5243  err = DVB_MhegGetOSDLanguage(svalue);
5244  if (err == MHERR_OK)
5245  {
5246  MHEG5stringDestruct(strVal);
5247  buffer.data = svalue;
5248  buffer.len = 3;
5249  *strVal = MHEG5stringCopy(buffer);
5250  }
5251  }
5252  else if (strcmp((char*)key.data, serviceMode) == 0)
5253  {
5254  if (valueVar->clazz != MHEG5INTEGERVARIABLE)
5255  {
5256  return MHEG5ERR_WRONGPARAM;
5257  }
5258  intVal = &((MHEG5IntegerVariable *)valueVar)->value;
5259  switch (DVB_MhegGetServiceMode())
5260  {
5261  default:
5262  case SRV_TYP_TV_DATA: *intVal = 0; break;
5263  case SRV_TYP_RADIO: *intVal = 1; break;
5264  case SRV_TYP_ALL: *intVal = 3; break;
5265  }
5266  }
5267 
5268  return MHEG5ERR_NOERROR;
5269 }
5270 
5271 #endif /* defined(INCLUDE_SA_PROFILE) */
5272 
5273 
5274 
5275 #ifdef INCLUDE_SI_EXTENSION
5276 
5277 static MHEG5Bool GetServiceInfo( MHEG5Int serviceIndex,
5278  MHEG5String *serviceProvider,
5279  MHEG5String *serviceName,
5280  MHEG5Int *serviceType )
5281 {
5282  S_ServiceDetails ServiceInfo;
5284  MHEG5Bool returnCode = MHEG5FALSE;
5285 
5286  MHEG5stringDestruct(serviceName);
5287  MHEG5stringDestruct(serviceProvider);
5288  if (DVB_MhegGetServiceDetails((S32BIT)serviceIndex, &ServiceInfo) == MHERR_OK)
5289  {
5290  returnCode = MHEG5TRUE;
5291  if (ServiceInfo.serviceName.zptr != NULL &&
5292  ServiceInfo.serviceName.zlen != 0)
5293  {
5294  buffer.data = ServiceInfo.serviceName.zptr;
5295  buffer.len = ServiceInfo.serviceName.zlen;
5296 
5297  *serviceName = MHEG5stringCopy(buffer);
5298  }
5299  if (ServiceInfo.serviceProvider.zptr != NULL &&
5300  ServiceInfo.serviceProvider.zlen != 0)
5301  {
5302  buffer.data = ServiceInfo.serviceProvider.zptr;
5303  buffer.len = ServiceInfo.serviceProvider.zlen;
5304 
5305  *serviceProvider = MHEG5stringCopy(buffer);
5306  }
5307  *serviceType = ServiceInfo.serviceType;
5308 
5309  #ifdef TRACING
5310  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5311  {
5312  char buff[124];
5313  DBG_PRINTF(T_NL "SI_GetServiceInfo( %ld ", serviceIndex );
5314  *buff = 0;
5315  MHEG5stringTrace( *serviceName, buff, 0, 120 );
5316  strcat(buff, " ");
5317  MHEG5stringTrace( *serviceProvider, buff, 0, 100 );
5318  DBG_PRINTF(buff);
5319  DBG_PRINTF(" %ld )", ServiceInfo.serviceType );
5320  }
5321  #endif
5322 
5323  DVB_MhegReleaseServiceDetails( &ServiceInfo );
5324  }
5325  else
5326  {
5327  TRACE(TERROR, (" serviceIndex=%d", serviceIndex))
5328  }
5329  return returnCode;
5330 }
5331 
5354 static MHEG5ErrorCode MHEG5prgSI_GetServiceInfo(MHEG5Program *program)
5355 {
5356  MHEG5GList *nextParam;
5357  MHEG5Root *callVar = 0;
5358  MHEG5Int serviceIndex;
5359  MHEG5Root *serviceName;
5360  MHEG5Root *serviceProvider;
5361  MHEG5Root *serviceType;
5362 
5363  MHEG5Bool success;
5364 
5365  assert(program);
5366 
5367  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5368  if (!nextParam)
5369  {
5371  }
5372  nextParam = MHEG5resolveGenericInteger( nextParam, &serviceIndex);
5373  if (!nextParam)
5374  {
5376  }
5377 
5378  nextParam = MHEG5resolveORef(nextParam, &serviceName);
5379  if (!nextParam)
5380  {
5382  }
5383 
5384  nextParam = MHEG5resolveORef(nextParam, &serviceProvider);
5385  if (!nextParam)
5386  {
5388  }
5389 
5390  MHEG5resolveORef(nextParam, &serviceType);
5391 
5392  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
5393  (!serviceProvider) || (serviceProvider->clazz != MHEG5OCTETSTRINGVARIABLE) ||
5394  (!serviceName) || (serviceName->clazz != MHEG5OCTETSTRINGVARIABLE) ||
5395  (!serviceType) || (serviceType->clazz != MHEG5INTEGERVARIABLE))
5396  {
5397  return MHEG5ERR_WRONGPARAM;
5398  }
5399 
5400  success = GetServiceInfo( serviceIndex,
5401  &((MHEG5OctetStringVariable *)serviceProvider)->value,
5402  &((MHEG5OctetStringVariable *)serviceName)->value,
5403  &((MHEG5IntegerVariable *)serviceType)->value );
5404 
5405  ((MHEG5BooleanVariable *) callVar)->value = success;
5406 
5407  return MHEG5ERR_NOERROR;
5408 }
5409 
5410 static void GetEventInfo(S_EventDetails *eventDetails,
5411  MHEG5String *eventName,
5412  MHEG5String *shortDescription,
5413  MHEG5Int *parentalRating,
5414  MHEG5Int *startDate,
5415  MHEG5Int *startTime,
5416  MHEG5Int *duration,
5417  MHEG5String *category,
5418  MHEG5Bool *freeNotCA )
5419 {
5421  U32BIT time;
5422  int i;
5423 
5424  MHEG5stringDestruct(eventName);
5425  MHEG5stringDestruct(shortDescription);
5426  MHEG5stringDestruct(category);
5427 
5428  if (eventDetails->eventName.zlen > 0 &&
5429  eventDetails->eventName.zptr != NULL)
5430  {
5431  buffer.data = eventDetails->eventName.zptr;
5432  buffer.len = eventDetails->eventName.zlen;
5433 
5434  *eventName = MHEG5stringCopy(buffer);
5435  }
5436 
5437  if (eventDetails->shortDescription.zlen > 0 &&
5438  eventDetails->shortDescription.zptr != NULL)
5439  {
5440  buffer.data = eventDetails->shortDescription.zptr;
5441  buffer.len = eventDetails->shortDescription.zlen;
5442 
5443  MHEG5stringDestruct(shortDescription);
5444  *shortDescription = MHEG5stringCopy(buffer);
5445  }
5446  if (eventDetails->category.zlen > 0 &&
5447  eventDetails->category.zptr != NULL)
5448  {
5449  buffer.len = eventDetails->category.zlen * 2;
5450  buffer.data = STR_DataAlloc( buffer.len );
5451  *category = buffer;
5452  for (i = 0; i != buffer.len; i += 2)
5453  {
5454  buffer.data[i] = ((eventDetails->category.zptr[i >> 1] >> 4) & 0xf) + 'A';
5455  buffer.data[i + 1] = (eventDetails->category.zptr[i >> 1] & 0xf) + 'a';
5456  }
5457  }
5458 
5459  *parentalRating = eventDetails->parentalRating;
5460  *startDate = eventDetails->startDate;
5461 
5462  time = eventDetails->startTime.hours;
5463  time *= 60;
5464  time += eventDetails->startTime.minutes;
5465  time *= 60;
5466  time += eventDetails->startTime.seconds;
5467 
5468  *startTime = time;
5469 
5470  time = eventDetails->duration.hours;
5471  time *= 60;
5472  time += eventDetails->duration.minutes;
5473  time *= 60;
5474  time += eventDetails->duration.seconds;
5475 
5476  *duration = time;
5477 
5478  if (eventDetails->freeNotCA == TRUE)
5479  {
5480  *freeNotCA = MHEG5TRUE;
5481  }
5482  else
5483  {
5484  *freeNotCA = MHEG5FALSE;
5485  }
5486 
5487 #ifdef TRACING
5488  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5489  {
5490  char buff[240];
5491  strcpy(buff, " ");
5492  MHEG5stringTrace( *eventName, buff, 0, 120 );
5493  MHEG5stringTrace( *shortDescription, buff, 0, 230 );
5494  strcat(buff, " ");
5495  DBG_PRINTF(buff);
5496  DBG_PRINTF(" %d %d", eventDetails->parentalRating, eventDetails->startDate );
5497  DBG_PRINTF(" %02d:%02d:%02d", eventDetails->startTime.hours,
5498  eventDetails->startTime.minutes, eventDetails->startTime.seconds );
5499  DBG_PRINTF(" %02d:%02d:%02d", eventDetails->startTime.hours,
5500  eventDetails->duration.minutes, eventDetails->duration.seconds );
5501 
5502  DBG_PRINTF(" %s %s )", category->data, *freeNotCA ? "TRUE" : "FALSE" );
5503  }
5504 #endif
5505 }
5506 
5556 static MHEG5ErrorCode MHEG5prgSI_GetEventInfo(MHEG5Program *program)
5557 {
5558  MHEG5GList *nextParam;
5559  MHEG5Root *callVar = 0;
5560 
5561  MHEG5Int serviceIndex;
5562  MHEG5Int porf;
5563  MHEG5Root *eventName;
5564  MHEG5Root *shortDescription;
5565  MHEG5Root *parentalRating;
5566  MHEG5Root *startDate;
5567  MHEG5Root *startTime;
5568  MHEG5Root *duration;
5569  MHEG5Root *category;
5570  MHEG5Root *freeNotCA;
5571 
5572  S_EventDetails eventDetails;
5573  E_MhegErr err;
5574 
5575  assert(program);
5576 
5577  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5578  if (!nextParam)
5579  {
5581  }
5582  nextParam = MHEG5resolveGenericInteger( nextParam, &serviceIndex);
5583  if (!nextParam)
5584  {
5586  }
5587 
5588  nextParam = MHEG5resolveGenericInteger( nextParam, &porf);
5589  if (!nextParam)
5590  {
5592  }
5593 
5594  nextParam = MHEG5resolveORef(nextParam, &eventName);
5595  if (!nextParam)
5596  {
5598  }
5599 
5600  nextParam = MHEG5resolveORef(nextParam, &shortDescription);
5601  if (!nextParam)
5602  {
5604  }
5605 
5606  nextParam = MHEG5resolveORef(nextParam, &parentalRating);
5607  if (!nextParam)
5608  {
5610  }
5611 
5612  nextParam = MHEG5resolveORef(nextParam, &startDate);
5613  if (!nextParam)
5614  {
5616  }
5617 
5618  nextParam = MHEG5resolveORef(nextParam, &startTime);
5619  if (!nextParam)
5620  {
5622  }
5623 
5624  nextParam = MHEG5resolveORef(nextParam, &duration);
5625  if (!nextParam)
5626  {
5628  }
5629 
5630  nextParam = MHEG5resolveORef(nextParam, &category);
5631  if (!nextParam)
5632  {
5634  }
5635 
5636  MHEG5resolveORef(nextParam, &freeNotCA);
5637 
5638  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
5639  (!eventName) || (eventName->clazz != MHEG5OCTETSTRINGVARIABLE) ||
5640  (!shortDescription) || (shortDescription->clazz != MHEG5OCTETSTRINGVARIABLE) ||
5641  (!parentalRating) || (parentalRating->clazz != MHEG5INTEGERVARIABLE) ||
5642  (!startDate) || (startDate->clazz != MHEG5INTEGERVARIABLE) ||
5643  (!startTime) || (startTime->clazz != MHEG5INTEGERVARIABLE) ||
5644  (!duration) || (duration->clazz != MHEG5INTEGERVARIABLE) ||
5645  (!category) || (category->clazz != MHEG5OCTETSTRINGVARIABLE) ||
5646  (!freeNotCA) || (freeNotCA->clazz != MHEG5BOOLEANVARIABLE))
5647  {
5648  return MHEG5ERR_WRONGPARAM;
5649  }
5650 
5651  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5652 
5653  err = DVB_MhegGetEventDetails((S32BIT)serviceIndex, porf ? TRUE : FALSE, &eventDetails);
5654  if (err == MHERR_OK)
5655  {
5656  #ifdef TRACING
5657  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5658  {
5659  DBG_PRINTF(T_NL "SI_GetEventInfo(");
5660  }
5661  #endif
5662  GetEventInfo(&eventDetails,
5663  &((MHEG5OctetStringVariable *)eventName)->value,
5664  &((MHEG5OctetStringVariable *)shortDescription)->value,
5665  &((MHEG5IntegerVariable *)parentalRating)->value,
5666  &((MHEG5IntegerVariable *)startDate)->value,
5667  &((MHEG5IntegerVariable *)startTime)->value,
5668  &((MHEG5IntegerVariable *)duration)->value,
5669  &((MHEG5OctetStringVariable *)category)->value,
5670  &((MHEG5BooleanVariable *)freeNotCA)->value);
5671  DVB_MhegReleaseEventDetails(&eventDetails);
5672  }
5673 
5674  return MHEG5ERR_NOERROR;
5675 }
5676 
5677 #ifdef INCLUDE_SA_PROFILE
5678 
5689 static MHEG5ErrorCode MHEG5prgSEI_GetNumberOfServices(MHEG5Program *program)
5690 {
5691  MHEG5GList *nextParam;
5692  MHEG5Root *callVar = 0;
5693  MHEG5Root *numberVar = 0;
5694  S32BIT number;
5695  E_MhegErr err;
5696 
5697  assert(program);
5698  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5699  if (!nextParam)
5700  {
5702  }
5703  nextParam = MHEG5resolveORef(nextParam, &numberVar);
5704  if (nextParam)
5705  {
5706  /* Should only be 2 parameters */
5708  }
5709 
5710  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5711  ((!numberVar) || (numberVar->clazz != MHEG5INTEGERVARIABLE)))
5712  {
5713  return MHEG5ERR_WRONGPARAM;
5714  }
5715 
5716  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5717 
5718  err = DVB_MhegGetNumberOfServices(&number);
5719  if (err == MHERR_OK)
5720  {
5721  ((MHEG5IntegerVariable *) numberVar)->value = (MHEG5Int)number;
5722  }
5723 
5724 #ifdef TRACING
5725  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5726  {
5727  DBG_PRINTF(T_NL "SEI_GetNumberOfServices( %d )", number);
5728  }
5729 #endif
5730  return MHEG5ERR_NOERROR;
5731 }
5732 
5733 #endif /* defined(INCLUDE_SA_PROFILE) */
5734 
5735 #ifdef INCLUDE_SA_PROFILE
5736 
5763 static MHEG5ErrorCode MHEG5prgSEI_NextServiceIndex(MHEG5Program *program)
5764 {
5765  MHEG5GList *nextParam;
5766  MHEG5Root *callVar = 0;
5767  MHEG5Root *serviceIndexVar = 0;
5768  S32BIT serviceIndex;
5769 #ifdef TRACING
5770  S32BIT oldIndex;
5771 #endif
5772  MHEG5Int updown;
5773  E_ServiceType servType;
5774  E_MhegErr err;
5775 
5776  assert(program);
5777  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5778  if (!nextParam)
5779  {
5781  }
5782  nextParam = MHEG5resolveORef(nextParam, &serviceIndexVar);
5783  if (!nextParam)
5784  {
5786  }
5787  nextParam = MHEG5resolveGenericInteger(nextParam, &updown);
5788  if (nextParam)
5789  {
5791  }
5792  /* use 'serviceIndex' to retreive servType parameter */
5793  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
5794  if (nextParam)
5795  {
5796  /* should be four params */
5798  }
5799  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5800  ((!serviceIndexVar) || (serviceIndexVar->clazz != MHEG5INTEGERVARIABLE)))
5801  {
5802  return MHEG5ERR_WRONGPARAM;
5803  }
5804  /* Set servType from 'serviceIndex' */
5805  switch (serviceIndex)
5806  {
5807  default:
5808  case 0: servType = SRV_TYP_ALL; break;
5809  case 1: servType = SRV_TYP_TV_DATA; break;
5810  case 2: servType = SRV_TYP_RADIO; break;
5811  }
5812  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5813  serviceIndex = (S32BIT)(((MHEG5IntegerVariable *) serviceIndexVar)->value);
5814 
5815 #ifdef TRACING
5816  oldIndex = serviceIndex;
5817 #endif
5818  if (updown == 1)
5819  {
5820  err = DVB_MhegNextServiceIndex(&serviceIndex,servType);
5821  }
5822  else
5823  {
5824  err = DVB_MhegPrevServiceIndex(&serviceIndex,servType);
5825  }
5826  if (err == MHERR_OK)
5827  {
5828  ((MHEG5IntegerVariable *) serviceIndexVar)->value = (MHEG5Int)serviceIndex;
5829  }
5830 #ifdef TRACING
5831  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5832  {
5833  DBG_PRINTF(T_NL "SEI_NextServiceIndex( updown=%d, %d -> %d )", updown, oldIndex, serviceIndex);
5834  }
5835 #endif
5836  return MHEG5ERR_NOERROR;
5837 }
5838 
5839 #endif /* defined(INCLUDE_SA_PROFILE) */
5840 
5841 #ifdef INCLUDE_SA_PROFILE
5842 
5857 static MHEG5ErrorCode MHEG5prgSEI_GetServiceRunningStatus(MHEG5Program *program)
5858 {
5859  MHEG5GList *nextParam;
5860  MHEG5Root *callVar = 0;
5861  MHEG5Root *statusVar = 0;
5862  MHEG5Int serviceIndex;
5863  U8BIT runningStatus;
5864  E_MhegErr err;
5865 
5866  assert(program);
5867  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5868  if (!nextParam)
5869  {
5871  }
5872  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
5873  if (!nextParam)
5874  {
5876  }
5877  nextParam = MHEG5resolveORef(nextParam, &statusVar);
5878  if (nextParam)
5879  {
5880  /* Should only be 3 parameters */
5882  }
5883 
5884  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5885  ((!statusVar) || (statusVar->clazz != MHEG5INTEGERVARIABLE)))
5886  {
5887  return MHEG5ERR_WRONGPARAM;
5888  }
5889 
5890  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5891 
5892  err = DVB_MhegGetServiceRunningStatus((S32BIT)serviceIndex, &runningStatus);
5893  if (err == MHERR_OK)
5894  {
5895  ((MHEG5IntegerVariable *) statusVar)->value = (MHEG5Int)runningStatus;
5896  }
5897 
5898 #ifdef TRACING
5899  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5900  {
5901  DBG_PRINTF(T_NL "SEI_GetServiceRunningStatus( %d )", runningStatus);
5902  }
5903 #endif
5904  return MHEG5ERR_NOERROR;
5905 }
5906 
5907 #endif /* defined(INCLUDE_SA_PROFILE) */
5908 
5909 #ifdef INCLUDE_SA_PROFILE
5910 
5924 static MHEG5ErrorCode MHEG5prgSEI_GetChannelNumber(MHEG5Program *program)
5925 {
5926  MHEG5GList *nextParam;
5927  MHEG5Root *callVar = 0;
5928  MHEG5Root *numVar = 0;
5929  MHEG5Int serviceIndex;
5930  S32BIT channelNum;
5931  E_MhegErr err;
5932 
5933  assert(program);
5934  nextParam = MHEG5resolveORef(program->parameter, &callVar);
5935  if (!nextParam)
5936  {
5938  }
5939  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
5940  if (!nextParam)
5941  {
5943  }
5944  nextParam = MHEG5resolveORef(nextParam, &numVar);
5945  if (nextParam)
5946  {
5947  /* Should only be 3 parameters */
5949  }
5950 
5951  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
5952  ((!numVar) || (numVar->clazz != MHEG5INTEGERVARIABLE)))
5953  {
5954  return MHEG5ERR_WRONGPARAM;
5955  }
5956 
5957  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
5958 
5959  err = DVB_MhegGetChannelNumber((S32BIT)serviceIndex, &channelNum);
5960  if (err == MHERR_OK)
5961  {
5962  ((MHEG5IntegerVariable *) numVar)->value = (MHEG5Int)channelNum;
5963  }
5964 #ifdef TRACING
5965  if (mheg_trace_debug & (TACTIONS | TEVNTS))
5966  {
5967  DBG_PRINTF(T_NL "SEI_GetChannelNumber( -> %d )", channelNum);
5968  }
5969 #endif
5970  return MHEG5ERR_NOERROR;
5971 }
5972 
5973 #endif /* defined(INCLUDE_SA_PROFILE) */
5974 
5975 #ifdef INCLUDE_SA_PROFILE
5976 
5998 static MHEG5ErrorCode MHEG5prgPFEI_GetEventId(MHEG5Program *program)
5999 {
6000  MHEG5GList *nextParam;
6001  MHEG5Root *callVar = 0;
6002  MHEG5Root *resultVar = 0;
6003  MHEG5Root *eventIdVar = 0;
6004  MHEG5Int serviceIndex;
6005  MHEG5Int porf;
6006  S32BIT eventId;
6007  E_MhegErr err;
6008 
6009  assert(program);
6010  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6011  if (!nextParam)
6012  {
6014  }
6015  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6016  if (!nextParam)
6017  {
6019  }
6020  nextParam = MHEG5resolveGenericInteger(nextParam, &porf);
6021  if (!nextParam)
6022  {
6024  }
6025  nextParam = MHEG5resolveORef(nextParam, &resultVar);
6026  if (!nextParam)
6027  {
6029  }
6030  nextParam = MHEG5resolveORef(nextParam, &eventIdVar);
6031  if (nextParam)
6032  {
6033  /* Too many parameters */
6035  }
6036 
6037  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6038  ((!eventIdVar) || (eventIdVar->clazz != MHEG5INTEGERVARIABLE)))
6039  {
6040  return MHEG5ERR_WRONGPARAM;
6041  }
6042 
6043  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6044 
6045  err = DVB_MhegGetEventId((S32BIT)serviceIndex, (porf) ? TRUE : FALSE, &eventId);
6046  if (err == MHERR_OK)
6047  {
6048  ((MHEG5IntegerVariable *) eventIdVar)->value = (MHEG5Int)eventId;
6049  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
6050  }
6051  else
6052  {
6053  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6054  }
6055 #ifdef TRACING
6056  if (mheg_trace_debug & (TACTIONS | TEVNTS))
6057  {
6058  DBG_PRINTF(T_NL "PFEI_GetEventId( %d, %d, -> 0x%x )", serviceIndex, porf, eventId);
6059  }
6060 #endif
6061  return MHEG5ERR_NOERROR;
6062 }
6063 
6064 #endif /* defined(INCLUDE_SA_PROFILE) */
6065 
6066 #ifdef INCLUDE_SA_PROFILE
6067 
6088 static MHEG5ErrorCode MHEG5prgSEI_SetEventIterator(MHEG5Program *program)
6089 {
6090  MHEG5GList *nextParam;
6091  MHEG5Root *callVar = 0;
6092  MHEG5Root *eventIdVar = 0;
6093  MHEG5Int serviceIndex;
6094  MHEG5Int startDate;
6095  MHEG5Int startTime;
6096  S32BIT eventId;
6097  E_MhegErr err;
6098 
6099  assert(program);
6100  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6101  if (!nextParam)
6102  {
6104  }
6105  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6106  if (!nextParam)
6107  {
6109  }
6110  nextParam = MHEG5resolveGenericInteger(nextParam, &startDate);
6111  if (!nextParam)
6112  {
6114  }
6115  nextParam = MHEG5resolveGenericInteger(nextParam, &startTime);
6116  if (!nextParam)
6117  {
6119  }
6120  nextParam = MHEG5resolveORef(nextParam, &eventIdVar);
6121  if (nextParam)
6122  {
6123  /* Too many parameters */
6125  }
6126 
6127  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6128  ((!eventIdVar) || (eventIdVar->clazz != MHEG5INTEGERVARIABLE)))
6129  {
6130  return MHEG5ERR_WRONGPARAM;
6131  }
6132 
6133  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6134 
6135  err = DVB_MhegSetEventIterator((S32BIT)serviceIndex, (S32BIT)startDate,
6136  (S32BIT)startTime, &eventId);
6137  if (err == MHERR_OK)
6138  {
6139  ((MHEG5IntegerVariable *) eventIdVar)->value = (MHEG5Int)eventId;
6140  }
6141 #ifdef TRACING
6142  if (mheg_trace_debug & (TACTIONS | TEVNTS))
6143  {
6144  DBG_PRINTF(T_NL "SEI_SetEventIterator( %d, %d, %02d:%02d:%02d, -> 0x%x )",
6145  serviceIndex, startDate, startTime / 3600, (startTime / 60) % 60, startTime % 60, eventId );
6146  }
6147 #endif
6148  return MHEG5ERR_NOERROR;
6149 }
6150 
6151 #endif /* defined(INCLUDE_SA_PROFILE) */
6152 
6153 #ifdef INCLUDE_SA_PROFILE
6154 
6168 static MHEG5ErrorCode MHEG5prgSEI_IncrementEventIterator(MHEG5Program *program)
6169 {
6170  MHEG5GList *nextParam;
6171  MHEG5Root *callVar = 0;
6172  MHEG5Root *eventIdVar = 0;
6173  E_MhegErr err;
6174  S32BIT eventId;
6175 #ifdef TRACING
6176  S32BIT oldId;
6177 #endif
6178  assert(program);
6179  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6180  if (!nextParam)
6181  {
6183  }
6184  nextParam = MHEG5resolveORef(nextParam, &eventIdVar);
6185  if (nextParam)
6186  {
6187  /* Too many parameters */
6189  }
6190 
6191  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6192  ((!eventIdVar) || (eventIdVar->clazz != MHEG5INTEGERVARIABLE)))
6193  {
6194  return MHEG5ERR_WRONGPARAM;
6195  }
6196 
6197  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6198 
6199  eventId = (S32BIT)((MHEG5IntegerVariable *) eventIdVar)->value;
6200 #ifdef TRACING
6201  oldId = eventId;
6202 #endif
6203  err = DVB_MhegIncrementEventIterator(&eventId);
6204  if (err == MHERR_OK)
6205  {
6206  ((MHEG5IntegerVariable *) eventIdVar)->value = eventId;
6207  }
6208 #ifdef TRACING
6209  if (mheg_trace_debug & (TACTIONS | TEVNTS))
6210  {
6211  DBG_PRINTF(T_NL "SEI_IncrementEventIterator( 0x%x -> 0x%x )", oldId, eventId);
6212  }
6213 #endif
6214  return MHEG5ERR_NOERROR;
6215 }
6216 
6217 #endif /* defined(INCLUDE_SA_PROFILE) */
6218 
6219 #ifdef INCLUDE_SA_PROFILE
6220 
6273 static MHEG5ErrorCode MHEG5prgSEI_GetScheduledEventInfo(MHEG5Program *program)
6274 {
6275  MHEG5GList *nextParam;
6276  MHEG5Root *callVar = 0;
6277 
6278  MHEG5Int serviceIndex;
6279  MHEG5Int eventId;
6280  MHEG5Root *resultVar;
6281  MHEG5Root *eventName;
6282  MHEG5Root *shortDescription;
6283  MHEG5Root *parentalRating;
6284  MHEG5Root *startDate;
6285  MHEG5Root *startTime;
6286  MHEG5Root *duration;
6287  MHEG5Root *category;
6288  MHEG5Root *freeNotCA;
6289 
6290  BOOLEAN result;
6291  S_EventDetails eventDetails;
6292  E_MhegErr err;
6293 
6294  assert(program);
6295 
6296  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6297  if (!nextParam)
6298  {
6300  }
6301  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6302  if (!nextParam)
6303  {
6305  }
6306  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
6307  if (!nextParam)
6308  {
6310  }
6311  nextParam = MHEG5resolveORef(nextParam, &resultVar);
6312  if (!nextParam)
6313  {
6315  }
6316  nextParam = MHEG5resolveORef(nextParam, &eventName);
6317  if (!nextParam)
6318  {
6320  }
6321  nextParam = MHEG5resolveORef(nextParam, &shortDescription);
6322  if (!nextParam)
6323  {
6325  }
6326  nextParam = MHEG5resolveORef(nextParam, &parentalRating);
6327  if (!nextParam)
6328  {
6330  }
6331  nextParam = MHEG5resolveORef(nextParam, &startDate);
6332  if (!nextParam)
6333  {
6335  }
6336  nextParam = MHEG5resolveORef(nextParam, &startTime);
6337  if (!nextParam)
6338  {
6340  }
6341  nextParam = MHEG5resolveORef(nextParam, &duration);
6342  if (!nextParam)
6343  {
6345  }
6346  nextParam = MHEG5resolveORef(nextParam, &category);
6347  if (!nextParam)
6348  {
6350  }
6351  nextParam = MHEG5resolveORef(nextParam, &freeNotCA);
6352  if (nextParam)
6353  {
6354  /* Too many parameters */
6356  }
6357 
6358  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
6359  (!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE) ||
6360  (!eventName) || (eventName->clazz != MHEG5OCTETSTRINGVARIABLE) ||
6361  (!shortDescription) || (shortDescription->clazz != MHEG5OCTETSTRINGVARIABLE) ||
6362  (!parentalRating) || (parentalRating->clazz != MHEG5INTEGERVARIABLE) ||
6363  (!startDate) || (startDate->clazz != MHEG5INTEGERVARIABLE) ||
6364  (!startTime) || (startTime->clazz != MHEG5INTEGERVARIABLE) ||
6365  (!duration) || (duration->clazz != MHEG5INTEGERVARIABLE) ||
6366  (!category) || (category->clazz != MHEG5OCTETSTRINGVARIABLE) ||
6367  (!freeNotCA) || (freeNotCA->clazz != MHEG5BOOLEANVARIABLE))
6368  {
6369  return MHEG5ERR_WRONGPARAM;
6370  }
6371 
6372  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6373 
6374  err = DVB_MhegGetScheduledEventDetails((S32BIT)serviceIndex, (S32BIT)eventId,
6375  &result, &eventDetails);
6376  if (err == MHERR_OK)
6377  {
6378  #ifdef TRACING
6379  if (mheg_trace_debug & (TACTIONS | TEVNTS))
6380  {
6381  DBG_PRINTF(T_NL "SEI_GetScheduledEventInfo( %d, 0x%x, ->%d ", serviceIndex, eventId, result);
6382  }
6383  #endif
6384  if (result)
6385  {
6386  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
6387 
6388  GetEventInfo(&eventDetails,
6389  &((MHEG5OctetStringVariable *)eventName)->value,
6390  &((MHEG5OctetStringVariable *)shortDescription)->value,
6391  &((MHEG5IntegerVariable *)parentalRating)->value,
6392  &((MHEG5IntegerVariable *)startDate)->value,
6393  &((MHEG5IntegerVariable *)startTime)->value,
6394  &((MHEG5IntegerVariable *)duration)->value,
6395  &((MHEG5OctetStringVariable *)category)->value,
6396  &((MHEG5BooleanVariable *)freeNotCA)->value);
6397  DVB_MhegReleaseEventDetails(&eventDetails);
6398  }
6399  else
6400  {
6401  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6402  #ifdef TRACING
6403  if (mheg_trace_debug & (TACTIONS | TEVNTS))
6404  {
6405  DBG_PRINTF(")");
6406  }
6407  #endif
6408  }
6409  }
6410 
6411  return MHEG5ERR_NOERROR;
6412 }
6413 
6414 #endif /* defined(INCLUDE_SA_PROFILE) */
6415 
6416 #ifdef INCLUDE_SA_PROFILE
6417 
6469 static MHEG5ErrorCode MHEG5prgSEI_GetComponentInfo(MHEG5Program *program)
6470 {
6471  MHEG5GList *nextParam;
6472  MHEG5Root *callVar = 0;
6473  MHEG5Int serviceIndex;
6474  MHEG5Int eventId;
6475  MHEG5Root *resultVar;
6476  MHEG5String keyStr;
6477  MHEG5Root *valueVar;
6478  MHEG5Bool invalidString;
6479  BOOLEAN result;
6480  BOOLEAN value;
6481  E_MhegErr err;
6482 
6483  static char subtitles[] = "Subtitles";
6484  static char audioDesc[] = "AudioDesc";
6485  static char altLang[] = "AltLang";
6486  static char dolby[] = "Dolby";
6487  static char hd[] = "HD";
6488 
6489  assert(program);
6490 
6491  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6492  if (!nextParam)
6493  {
6495  }
6496  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6497  if (!nextParam)
6498  {
6500  }
6501  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
6502  if (!nextParam)
6503  {
6505  }
6506  nextParam = MHEG5resolveORef(nextParam, &resultVar);
6507  if (!nextParam)
6508  {
6510  }
6511  nextParam = MHEG5resolveGenericOctetString(nextParam, &keyStr, &invalidString);
6512  if (!nextParam)
6513  {
6515  }
6516  if (invalidString)
6517  {
6518  /* Parameter was not an octet string */
6519  return MHEG5ERR_WRONGPARAM;
6520  }
6521  nextParam = MHEG5resolveORef(nextParam, &valueVar);
6522  if (nextParam)
6523  {
6524  /* Too many parameters */
6526  }
6527 
6528  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6529  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6530  ((!valueVar) || (valueVar->clazz != MHEG5BOOLEANVARIABLE)))
6531  {
6532  return MHEG5ERR_WRONGPARAM;
6533  }
6534 
6535  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6536 
6537  err = MHERR_OTHER;
6538 
6539  if ((keyStr.len != 0) && (keyStr.data != NULL))
6540  {
6541  if (strcmp((char *)keyStr.data, subtitles) == 0)
6542  {
6543  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, (S32BIT)eventId,
6544  &result, MHEG5_COMPONENT_SUBTITLES,
6545  &value);
6546  }
6547  else if (strcmp((char *)keyStr.data, audioDesc) == 0)
6548  {
6549  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, (S32BIT)eventId,
6550  &result, MHEG5_COMPONENT_AUDIO_DESC,
6551  &value);
6552  }
6553  else if (strcmp((char *)keyStr.data, altLang) == 0)
6554  {
6555  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, (S32BIT)eventId,
6556  &result, MHEG5_COMPONENT_ALT_LANG,
6557  &value);
6558  }
6559  else if (strcmp((char *)keyStr.data, dolby) == 0)
6560  {
6561  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, (S32BIT)eventId,
6562  &result, MHEG5_COMPONENT_DOLBY,
6563  &value);
6564  }
6565  else if (strcmp((char *)keyStr.data, hd) == 0)
6566  {
6567  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, (S32BIT)eventId,
6568  &result, MHEG5_COMPONENT_HD,
6569  &value);
6570  }
6571 
6572  if (result)
6573  {
6574  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
6575 
6576  if (err == MHERR_OK)
6577  {
6578  if (value)
6579  {
6580  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5TRUE;
6581  }
6582  else
6583  {
6584  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5FALSE;
6585  }
6586  }
6587  else
6588  {
6589  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5FALSE;
6590  }
6591  }
6592  else
6593  {
6594  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6595  }
6596  }
6597 
6598  return MHEG5ERR_NOERROR;
6599 }
6600 
6601 #endif /* defined(INCLUDE_SA_PROFILE) */
6602 
6603 #ifdef INCLUDE_SA_PROFILE
6604 
6656 static MHEG5ErrorCode MHEG5prgPFEI_GetComponentInfo(MHEG5Program *program)
6657 {
6658  MHEG5GList *nextParam;
6659  MHEG5Root *callVar = 0;
6660  MHEG5Int serviceIndex;
6661  MHEG5Int porf;
6662  S32BIT eventId;
6663  MHEG5Root *resultVar;
6664  MHEG5String keyStr;
6665  MHEG5Root *valueVar;
6666  MHEG5Bool invalidString;
6667  BOOLEAN result;
6668  BOOLEAN value;
6669  E_MhegErr err;
6670 
6671  static char subtitles[] = "Subtitles";
6672  static char audioDesc[] = "AudioDesc";
6673  static char altLang[] = "AltLang";
6674  static char dolby[] = "Dolby";
6675  static char hd[] = "HD";
6676 
6677  assert(program);
6678 
6679  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6680  if (!nextParam)
6681  {
6683  }
6684  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6685  if (!nextParam)
6686  {
6688  }
6689  nextParam = MHEG5resolveGenericInteger(nextParam, &porf);
6690  if (!nextParam)
6691  {
6693  }
6694  nextParam = MHEG5resolveORef(nextParam, &resultVar);
6695  if (!nextParam)
6696  {
6698  }
6699  nextParam = MHEG5resolveGenericOctetString(nextParam, &keyStr, &invalidString);
6700  if (!nextParam)
6701  {
6703  }
6704  if (invalidString)
6705  {
6706  /* Parameter was not an octet string */
6707  return MHEG5ERR_WRONGPARAM;
6708  }
6709  nextParam = MHEG5resolveORef(nextParam, &valueVar);
6710  if (nextParam)
6711  {
6712  /* Too many parameters */
6714  }
6715 
6716  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6717  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6718  ((!valueVar) || (valueVar->clazz != MHEG5BOOLEANVARIABLE)))
6719  {
6720  return MHEG5ERR_WRONGPARAM;
6721  }
6722 
6723  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6724 
6725  err = MHERR_OTHER;
6726 
6727  if ((keyStr.len != 0) && (keyStr.data != NULL))
6728  {
6729  err = DVB_MhegGetEventId((S32BIT)serviceIndex, (porf) ? TRUE : FALSE, &eventId);
6730 
6731  if (err == MHERR_OK)
6732  {
6733  if (strcmp((char *)keyStr.data, subtitles) == 0)
6734  {
6735  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, eventId,
6736  &result, MHEG5_COMPONENT_SUBTITLES,
6737  &value);
6738  }
6739  else if (strcmp((char *)keyStr.data, audioDesc) == 0)
6740  {
6741  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, eventId,
6742  &result, MHEG5_COMPONENT_AUDIO_DESC,
6743  &value);
6744  }
6745  else if (strcmp((char *)keyStr.data, altLang) == 0)
6746  {
6747  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, eventId,
6748  &result, MHEG5_COMPONENT_ALT_LANG,
6749  &value);
6750  }
6751  else if (strcmp((char *)keyStr.data, dolby) == 0)
6752  {
6753  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, eventId,
6754  &result, MHEG5_COMPONENT_DOLBY,
6755  &value);
6756  }
6757  else if (strcmp((char *)keyStr.data, hd) == 0)
6758  {
6759  err = DVB_MhegGetComponentInfo((S32BIT)serviceIndex, eventId,
6760  &result, MHEG5_COMPONENT_HD,
6761  &value);
6762  }
6763 
6764  if (result)
6765  {
6766  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
6767 
6768  if (err == MHERR_OK)
6769  {
6770  if (value)
6771  {
6772  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5TRUE;
6773  }
6774  else
6775  {
6776  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5FALSE;
6777  }
6778  }
6779  else
6780  {
6781  ((MHEG5BooleanVariable *) valueVar)->value = MHEG5FALSE;
6782  }
6783  }
6784  else
6785  {
6786  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6787  }
6788  }
6789  else
6790  {
6791  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6792  }
6793  }
6794 
6795  return MHEG5ERR_NOERROR;
6796 }
6797 
6798 #endif /* defined(INCLUDE_SA_PROFILE) */
6799 
6800 #ifdef INCLUDE_SA_PROFILE
6801 
6836 static MHEG5ErrorCode MHEG5prgSEI_GetComponentData(MHEG5Program *program)
6837 {
6838  MHEG5GList *nextParam;
6839  MHEG5Root *callVar = 0;
6840  MHEG5Int serviceIndex;
6841  MHEG5Int eventId;
6842  MHEG5Root *resultVar;
6843  MHEG5Root *strContVar;
6844  MHEG5Root *contTypeVar;
6845  MHEG5Root *langVar;
6846  MHEG5String *strContStr;
6847  MHEG5String *contTypeStr;
6848  MHEG5String *langStr;
6850  BOOLEAN result;
6851  U8BIT strCont[256];
6852  U8BIT contType[256];
6853  U8BIT lang[256];
6854  E_MhegErr err;
6855 
6856  assert(program);
6857 
6858  nextParam = MHEG5resolveORef(program->parameter, &callVar);
6859  if (!nextParam)
6860  {
6862  }
6863  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
6864  if (!nextParam)
6865  {
6867  }
6868  nextParam = MHEG5resolveGenericInteger(nextParam, &eventId);
6869  if (!nextParam)
6870  {
6872  }
6873  nextParam = MHEG5resolveORef(nextParam, &resultVar);
6874  if (!nextParam)
6875  {
6877  }
6878  nextParam = MHEG5resolveORef(nextParam, &strContVar);
6879  if (!nextParam)
6880  {
6882  }
6883  nextParam = MHEG5resolveORef(nextParam, &contTypeVar);
6884  if (!nextParam)
6885  {
6887  }
6888  nextParam = MHEG5resolveORef(nextParam, &langVar);
6889  if (nextParam)
6890  {
6891  /* Too many parameters */
6893  }
6894  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6895  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)) ||
6896  ((!strContVar) || (strContVar->clazz != MHEG5OCTETSTRINGVARIABLE)) ||
6897  ((!contTypeVar) || (contTypeVar->clazz != MHEG5OCTETSTRINGVARIABLE)) ||
6898  ((!langVar) || (langVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
6899  {
6900  return MHEG5ERR_WRONGPARAM;
6901  }
6902 
6903  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
6904 
6905  strContStr = &((MHEG5OctetStringVariable *)strContVar)->value;
6906  contTypeStr = &((MHEG5OctetStringVariable *)contTypeVar)->value;
6907  langStr = &((MHEG5OctetStringVariable *)langVar)->value;
6908 
6909  err = DVB_MhegGetComponentData((S32BIT)serviceIndex, (S32BIT)eventId,
6910  &result, strCont, contType, lang);
6911  if (err == MHERR_OK && result)
6912  {
6913  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
6914 
6915  MHEG5stringDestruct(strContStr);
6916  MHEG5stringDestruct(contTypeStr);
6917  MHEG5stringDestruct(langStr);
6918 
6919  buffer.len = strlen((char *)strCont);
6920  buffer.data = strCont;
6921  *strContStr = MHEG5stringCopy(buffer);
6922 
6923  buffer.len = strlen((char *)contType);
6924  buffer.data = contType;
6925  *contTypeStr = MHEG5stringCopy(buffer);
6926 
6927  buffer.len = strlen((char *)lang);
6928  buffer.data = lang;
6929  *langStr = MHEG5stringCopy(buffer);
6930  }
6931  else
6932  {
6933  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
6934  }
6935 
6936  return MHEG5ERR_NOERROR;
6937 }
6938 
6939 #endif /* defined(INCLUDE_SA_PROFILE) */
6940 
6941 #ifdef INCLUDE_SA_PROFILE
6942 
6977 static MHEG5ErrorCode MHEG5prgPFEI_GetComponentData(MHEG5Program *program)
6978 {
6979  MHEG5GList *nextParam;
6980  MHEG5Root *callVar = 0;
6981  MHEG5Int serviceIndex;
6982  MHEG5Int porf;
6983  S32BIT eventId;
6984  MHEG5Root *resultVar;
6985  MHEG5Root *strContVar;
6986  MHEG5Root *contTypeVar;
6987  MHEG5Root *langVar;
6988  MHEG5String *strContStr;
6989  MHEG5String *contTypeStr;
6990  MHEG5String *langStr;
6992  BOOLEAN result;
6993  U8BIT strCont[256];
6994  U8BIT contType[256];
6995  U8BIT lang[256];
6996  E_MhegErr err;
6997 
6998  assert(program);
6999 
7000  nextParam = MHEG5resolveORef(program->parameter, &callVar);
7001  if (!nextParam)
7002  {
7004  }
7005  nextParam = MHEG5resolveGenericInteger(nextParam, &serviceIndex);
7006  if (!nextParam)
7007  {
7009  }
7010  nextParam = MHEG5resolveGenericInteger(nextParam, &porf);
7011  if (!nextParam)
7012  {
7014  }
7015  nextParam = MHEG5resolveORef(nextParam, &resultVar);
7016  if (!nextParam)
7017  {
7019  }
7020  nextParam = MHEG5resolveORef(nextParam, &strContVar);
7021  if (!nextParam)
7022  {
7024  }
7025  nextParam = MHEG5resolveORef(nextParam, &contTypeVar);
7026  if (!nextParam)
7027  {
7029  }
7030  nextParam = MHEG5resolveORef(nextParam, &langVar);
7031  if (nextParam)
7032  {
7033  /* Too many parameters */
7035  }
7036  if (((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) ||
7037  ((!resultVar) || (resultVar->clazz != MHEG5BOOLEANVARIABLE)) ||
7038  ((!strContVar) || (strContVar->clazz != MHEG5OCTETSTRINGVARIABLE)) ||
7039  ((!contTypeVar) || (contTypeVar->clazz != MHEG5OCTETSTRINGVARIABLE)) ||
7040  ((!langVar) || (langVar->clazz != MHEG5OCTETSTRINGVARIABLE)))
7041  {
7042  return MHEG5ERR_WRONGPARAM;
7043  }
7044 
7045  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
7046 
7047  strContStr = &((MHEG5OctetStringVariable *)strContVar)->value;
7048  contTypeStr = &((MHEG5OctetStringVariable *)contTypeVar)->value;
7049  langStr = &((MHEG5OctetStringVariable *)langVar)->value;
7050 
7051  err = DVB_MhegGetEventId((S32BIT)serviceIndex, (porf) ? TRUE : FALSE, &eventId);
7052  if (err == MHERR_OK)
7053  {
7054  err = DVB_MhegGetComponentData((S32BIT)serviceIndex, eventId,
7055  &result, strCont, contType, lang);
7056  if (err == MHERR_OK && result)
7057  {
7058  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5TRUE;
7059 
7060  MHEG5stringDestruct(strContStr);
7061  MHEG5stringDestruct(contTypeStr);
7062  MHEG5stringDestruct(langStr);
7063 
7064  buffer.len = strlen((char *)strCont);
7065  buffer.data = strCont;
7066  *strContStr = MHEG5stringCopy(buffer);
7067 
7068  buffer.len = strlen((char *)contType);
7069  buffer.data = contType;
7070  *contTypeStr = MHEG5stringCopy(buffer);
7071 
7072  buffer.len = strlen((char *)lang);
7073  buffer.data = lang;
7074  *langStr = MHEG5stringCopy(buffer);
7075  }
7076  else
7077  {
7078  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
7079  }
7080  }
7081  else
7082  {
7083  ((MHEG5BooleanVariable *) resultVar)->value = MHEG5FALSE;
7084  }
7085  return MHEG5ERR_NOERROR;
7086 }
7087 
7088 #endif /* defined(INCLUDE_SA_PROFILE) */
7089 
7090 #endif /* INCLUDE_SI_EXTENSION */
7091 
7092 #ifdef INCLUDE_TPS
7093 
7104 static MHEG5ErrorCode MHEG5prgPersistentStorageInfo(MHEG5Program *program)
7105 {
7106  MHEG5Root *callVar = 0;
7107  MHEG5GList *nextParam;
7108  MHEG5Root *enabled;
7109 
7110  assert(program);
7111 
7112  nextParam = MHEG5resolveORef(program->parameter, &callVar);
7113  if (!nextParam)
7114  {
7116  }
7117 
7118  MHEG5resolveORef( nextParam, &enabled);
7119  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
7120  (!enabled) || (enabled->clazz != MHEG5BOOLEANVARIABLE))
7121  {
7122  return MHEG5ERR_WRONGPARAM;
7123  }
7124  ((MHEG5BooleanVariable *) enabled)->value = MHEG5GetTpsStatus();
7125  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
7126  return MHEG5ERR_NOERROR;
7127 }
7128 
7129 #endif
7130 
7131 #ifdef INCLUDE_CONNECTED_TV
7132 /*******************************************************************************
7133 *@begin
7134 * NAME: MHEG5notifyApplicationLaunchStatus
7135 * Pass a response from the external application to the ApplicationLaunch
7136 * resident program.
7137 *
7138 * Returns : void
7139 *
7140 * Parameter Flow Description
7141 * ------------------------------------------------------------------------------
7142 * success IN Indicates whether the application was launched
7143 *
7144 * Externals Flow Usage
7145 * ------------------------------------------------------------------------------
7146 *
7147 * Additional information:
7148 *
7149 * This function is invoked as part of the Deactivate action on a resident program.
7150 *
7151 *@end
7152 *******************************************************************************/
7153 void MHEG5notifyApplicationLaunchStatus(MHEG5Bool success)
7154 {
7155  MHEG5Program *program = application_launch_program;
7156  if (program != NULL)
7157  {
7158  /* Store result */
7159  *((MHEG5Bool *)(program->resultValue)) = success;
7160 
7161  /* Call/Fork succeeded */
7162  *(program->forkSucceededValue) = MHEG5TRUE;
7163 
7164  ProgramCompleted( program );
7165 
7166  application_launch_program = NULL;
7167  }
7168 }
7169 
7170 
7171 /*******************************************************************************
7172 *@begin
7173 * NAME: MHEG5prgApplicationLaunch
7174 * Implementation of the ApplicationLaunch (ApL) resident program
7175 *
7176 * Returns : MHEG5ErrorCode - see mh5base.h
7177 *
7178 * Parameter Flow Description
7179 * ------------------------------------------------------------------------------
7180 * program IN/OUT Program object that is running
7181 *
7182 * Externals Flow Usage
7183 * ------------------------------------------------------------------------------
7184 *
7185 * Additional information:
7186 *
7187 * B.4.3.1.2.1 GetLaunchArguments
7188 *
7189 * Synopsis: Hands control of execution to another application of an
7190 * arbitrary type.
7191 *
7192 * Arguments: ApL (location, [name, value]..., success)
7193 *
7194 * Causes a new application to be started with the specified
7195 * arguments. The application to run is specified by the location
7196 * parameter.
7197 *
7198 * The Application launched using this resident program is classified
7199 * as broadcast-related, as described in B.4.2.1.7 Relation of
7200 * Applications to Broadcast.
7201 *
7202 * A side-effect of the resident program may be that the MHEG engine
7203 * is stopped (killing the application). In all cases the state of
7204 * the True Persistent Storage shall not be affected.
7205 *
7206 * Flow Type Name Comment
7207 *
7208 * input GenericOctetString location Location of the application to
7209 * run
7210 * input GenericOctetString name List of name/value pairs to be
7211 * input GenericBoolean or value passed to the application
7212 * GenericInteger or
7213 * GenericOctetString
7214 * output GenericBoolean [1] success True if the application started
7215 * successfully, false otherwise.
7216 *
7217 * [1] (Shall provide an IndirectReference to a BooleanVariable)
7218 *
7219 *@end
7220 *******************************************************************************/
7221 static MHEG5ErrorCode MHEG5prgApplicationLaunch(MHEG5Program *program)
7222 {
7223  MHEG5GList *secondParam = 0, *thirdParam = 0, *prevParam, *nextParam = 0;
7224  MHEG5Root *callVar = 0;
7225  MHEG5Root *successVar = 0;
7227  MHEG5String location;
7228  MHEG5String data;
7229  MHEG5Bool invalidString;
7230  MHEG5String name;
7231  MHEG5Generic g;
7232  U8BIT *buffer = 0;
7233  MHEG5Int allocated = 0, used = 0;
7234  MHEG5Bool success;
7235 
7236  assert(program);
7237 
7238  /* callVar */
7239  secondParam = MHEG5resolveORef(program->parameter, &callVar);
7240  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) {
7241  return MHEG5ERR_WRONGPARAM;
7242  }
7243  if (!secondParam) {
7245  }
7246 
7247  /* Location */
7248  thirdParam = MHEG5resolveGenericOctetString(secondParam, &location,
7249  &invalidString);
7250  if (!thirdParam) {
7252  }
7253  if (invalidString) {
7254  /* Parameter was not an octet string */
7255  return MHEG5ERR_WRONGPARAM;
7256  }
7257 
7258  buffer = NULL;
7259 
7260  /* Next parameter can be either GenericOctetString (name) or
7261  * GenericBoolean pointing at BooleanVariable (success)
7262  */
7263  prevParam = thirdParam;
7264  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
7265  while (nextParam && g.type == MHEG5OCTETSTRING)
7266  {
7267  name = g.value.s;
7268 
7269  /* Next parameter can be many things. */
7270  prevParam = nextParam;
7271  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
7272  success = MHEG5parseEncodeField(&buffer, &used, &allocated, &name, &g);
7273  if (!success)
7274  {
7275  nextParam = NULL;
7276  break;
7277  }
7278 
7279  /* Next parameter can be either GenericOctetString (name) or
7280  * GenericBoolean pointing at BooleanVariable (success)
7281  */
7282  prevParam = nextParam;
7283  nextParam = MHEG5resolveGenericGeneric(prevParam, &g);
7284  }
7285 
7286  /* resolve success */
7287  nextParam = MHEG5resolveORef(prevParam, &successVar);
7288  if (nextParam != NULL) {
7289  MHEG5freeMem(buffer);
7291  }
7292  if ((!successVar) || (successVar->clazz != MHEG5BOOLEANVARIABLE)) {
7293  MHEG5freeMem(buffer);
7294  return MHEG5ERR_WRONGPARAM;
7295  }
7296  rc = (MHEG5BooleanVariable *)successVar;
7297 
7298  program->resultValue = &rc->value;
7299 
7300  /* Set the forkSuceeded to default to FALSE */
7301  program->forkSucceededValue = &((MHEG5BooleanVariable *) callVar)->value;
7302 
7303  /* For a called program disable event processing until the program ends */
7304  if (!program->forked) {
7306  }
7307 
7308  if (success)
7309  {
7310  data.len = used;
7311  data.data = buffer;
7312  }
7313  else
7314  {
7315  data.len = 0;
7316  data.data = NULL;
7317  }
7318 
7319  application_launch_program = program;
7320  MHEG5ApplicationLaunch(&location, &data);
7321  MHEG5freeMem(buffer);
7322 
7323  return MHEG5ERR_NOERROR;
7324 }
7325 
7326 /*******************************************************************************
7327 *@begin
7328 * NAME: MHEG5prgGetLaunchArguments
7329 * Implementation of the GetLaunchArguments (GLA) resident program
7330 *
7331 * Returns : MHEG5ErrorCode - see mh5base.h
7332 *
7333 * Parameter Flow Description
7334 * ------------------------------------------------------------------------------
7335 * program IN/OUT Program object that is running
7336 *
7337 * Externals Flow Usage
7338 * ------------------------------------------------------------------------------
7339 *
7340 * Additional information:
7341 *
7342 * B.4.3.1.2.2 GetLaunchArguments
7343 *
7344 * Synopsis: Retrieves an argument set by another application of an
7345 * arbitrary type.
7346 *
7347 * Arguments: GLA( name, value )
7348 *
7349 * Retrieves the value of the named argument. Arguments can be set by
7350 * applications of an arbitrary type, other than MHEG, when launching
7351 * an MHEG application.
7352 *
7353 * The value of the argument is provided to the application as an
7354 * OctetStringVariable. It is the responsibility of the application
7355 * to convert this value into another type (using the SetVariable
7356 * elementary action or one of the type conversion resident programs)
7357 * if required.
7358 *
7359 * If the argument to be retrieved does not exist then the resident
7360 * program succeeds and the value parameter is a zero length string.
7361 *
7362 * Flow Type Name Comment
7363 * Input GenericOctetString name
7364 * Output GenericOctetString [1] value
7365 *
7366 * [1] (Shall provide an IndirectReference to an OctetStringVariable)
7367 *
7368 *@end
7369 *******************************************************************************/
7370 static MHEG5ErrorCode MHEG5prgGetLaunchArguments(MHEG5Program *program)
7371 {
7372  MHEG5GList *secondParam = 0, *thirdParam = 0;
7373  MHEG5Root *callVar = 0, *osVar = 0;
7374  MHEG5String name;
7375  MHEG5OctetStringVariable *value;
7376  MHEG5Bool invalidString;
7377 
7378  assert(program);
7379 
7380  secondParam = MHEG5resolveORef(program->parameter, &callVar);
7381  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE)) {
7382  return MHEG5ERR_WRONGPARAM;
7383  }
7384  if (!secondParam) {
7386  }
7387  thirdParam = MHEG5resolveGenericOctetString(secondParam, &name, &invalidString);
7388  if (!thirdParam) {
7390  }
7391  if (invalidString) {
7392  /* Parameter was not an octet string */
7393  return MHEG5ERR_WRONGPARAM;
7394  }
7395 
7396  MHEG5resolveORef(thirdParam, &osVar);
7397  if ((!callVar) || (callVar->clazz != MHEG5BOOLEANVARIABLE) ||
7398  (!osVar) || (osVar->clazz != MHEG5OCTETSTRINGVARIABLE)) {
7399  return MHEG5ERR_WRONGPARAM;
7400  }
7401  value = (MHEG5OctetStringVariable *) osVar;
7402  ((MHEG5BooleanVariable *) callVar)->value = MHEG5TRUE;
7403 
7404  MHEG5stringDestruct(&value->value);
7405  value->value.len = 0;
7406  value->value.data = NULL;
7407 
7408  return MHEG5ERR_NOERROR;
7409 }
7410 #endif /* INCLUDE_CONNECTED_TV */
7411 
7412 
7413 
7421 {
7422  S32BIT i;
7423 
7424  /* List of resident programs supported by UK1.05 profile */
7425  static const ResidentProgramTableEntry_t ProgramTable[] = {
7426  /* Short names */
7427  { "GCD", &MHEG5prgGetCurrentDate, NULL },
7428  { "FDa", &MHEG5prgFormatDate, NULL },
7429  { "GDW", &MHEG5prgGetDayOfWeek, NULL },
7430  { "Rnd", &MHEG5prgRandom, NULL },
7431  { "CTC", &MHEG5prgCastToContentRef, NULL },
7432  { "CTO", &MHEG5prgCastToObjectRef, NULL },
7433  { "CSI", &MHEG5prgCastToStringInt, NULL },
7434  { "GSL", &MHEG5prgGetStringLength, NULL },
7435  { "GSS", &MHEG5prgGetSubString, NULL },
7436  { "SSS", &MHEG5prgSearchSubString, NULL },
7437  { "SES", &MHEG5prgSearchAndExtractSubString, NULL },
7438  { "GSI", &MHEG5prgSI_GetServiceIndex, NULL },
7439 #ifndef CI_PLUS_ONLY
7440  { "TIn", &MHEG5prgSI_TuneIndex, NULL },
7441  { "TII", &MHEG5prgSI_TuneIndexInfo, NULL },
7442  { "VTG", &MHEG5prgVideoToGraphics, NULL },
7443  { "SSM", &MHEG5prgSetSubtitleMode, NULL },
7444  { "SWA", &MHEG5prgSetWidescreenAlignment, NULL },
7445 #endif
7446  { "BSI", &MHEG5prgSI_GetBasicSI, NULL },
7447  { "CCR", &MHEG5prgCheckContentRef, &clearOrmHandle },
7448  { "CGR", &MHEG5prgCheckGroupIDRef, &clearOrmHandle },
7449  { "CIS", &MHEG5prgCI_SendMessage, NULL },
7450 #ifndef CI_PLUS_ONLY
7451  { "GBI", &MHEG5prgGetBootInfo, NULL },
7452 #endif /* !CI_PLUS_ONLY */
7453  { "WAI", &MHEG5prgWhoAmI, NULL },
7454 #ifdef INCLUDE_DEBUG_PACKAGE
7455  { "DBG", &MHEG5prgDebug, NULL },
7456 #endif /* INCLUDE_DEBUG_PACKAGE*/
7457  { "GDA", &MHEG5prgGetDisplayAspectRatio, NULL },
7458 #ifdef INCLUDE_NATIVE_APP
7459  { "SBI", &MHEG5prgSetBroadcasterInterruptions, NULL },
7460 #endif /*INCLUDE_NATIVE_APP*/
7461 #ifdef INCLUDE_PVR_AU
7462  { "PMB2", &MHEG5prgPVR_MakeBooking2, NULL },
7463  { "PCB2", &MHEG5prgPVR_CancelBooking2, NULL },
7464  { "PLB2", &MHEG5prgPVR_ListBookings2, NULL },
7465  { "PGD2", &MHEG5prgPVR_GetDetails2, NULL },
7466 #endif /*INCLUDE_PVR_AU*/
7467 #ifdef INCLUDE_MHEG_PVR
7468  { "PMB", &MHEG5prgPVR_MakeBooking, NULL },
7469  { "PCB", &MHEG5prgPVR_CancelBooking, NULL },
7470  { "PLB", &MHEG5prgPVR_ListBookings, NULL },
7471 #endif /*INCLUDE_MHEG_PVR*/
7472 #ifdef INCLUDE_SA_PROFILE
7473  { "GPL", &MHEG5prgLNG_GetPreferredLangs, NULL },
7474  { "GAu", &MHEG5prgLNG_GetAudioLangs, NULL },
7475  { "GSb", &MHEG5prgLNG_GetSubtitleLangs, NULL },
7476  { "GAD", &MHEG5prgLNG_GetADLangs, NULL },
7477  { "GNS", &MHEG5prgSEI_GetNumberOfServices, NULL },
7478  { "NSI", &MHEG5prgSEI_NextServiceIndex, NULL },
7479  { "GSR", &MHEG5prgSEI_GetServiceRunningStatus, NULL },
7480  { "GCN", &MHEG5prgSEI_GetChannelNumber, NULL },
7481  { "SEv", &MHEG5prgSEI_SetEventIterator, NULL },
7482  { "IEI", &MHEG5prgSEI_IncrementEventIterator, NULL },
7483  { "GSE", &MHEG5prgSEI_GetScheduledEventInfo, NULL },
7484  { "SCI", &MHEG5prgSEI_GetComponentInfo, NULL },
7485  { "SCD", &MHEG5prgSEI_GetComponentData, NULL },
7486  { "GID", &MHEG5prgPFEI_GetEventId, NULL },
7487  { "PCI", &MHEG5prgPFEI_GetComponentInfo, NULL },
7488  { "PCD", &MHEG5prgPFEI_GetComponentData, NULL },
7489  { "SNR", &MHEG5prgREM_SetNativeReminder, NULL },
7490  { "GNR", &MHEG5prgREM_GetNativeReminder, NULL },
7491  { "CNR", &MHEG5prgREM_CancelNativeReminder, NULL },
7492  { "GHS", &MHEG5prgSA_GetHostSetting, NULL },
7493 #endif /*INCLUDE_SA_PROFILE*/
7494 #ifdef INCLUDE_CI_PLUS
7495  { "RMD", &MHEG5prgRequestMPEGDecoder, NULL },
7496  { "SMG", &MHEG5prgSuppressMHEGGraphics, NULL },
7497 #endif /*INCLUDE_CI_PLUS*/
7498  { "TIM", &MHEG5prgTestInputMask, NULL },
7499 #ifdef INCLUDE_IC
7500  { "SHF", &MHEG5prgSetHybridFileSystem, NULL },
7501  { "GIS", &MHEG5prgGetICStatus, NULL },
7502  { "RDa", &MHEG5prgReturnData, NULL },
7503  { "GCk", &MHEG5prgGetCookie, NULL },
7504  { "SCk", &MHEG5prgSetCookie, NULL },
7505 #ifdef INCLUDE_ICS
7506  { "PFG", &MHEG5prgPromptForGuidance, &stopPrompt },
7507  { "MSP", &MHEG5prgMeasureStreamPerformance, &stopMeasurement },
7508 #ifdef INCLUDE_IPLAYER
7509  { "GPS", &MHEG5prgGetPINSupport, NULL },
7510 #endif /*INCLUDE_IPLAYER*/
7511 #if defined(INCLUDE_IPLAYER) || defined(INCLUDE_FREESAT)
7512  { "GAP", &MHEG5prgGetAudioDescPref, NULL },
7513  { "GSP", &MHEG5prgGetSubtitlePref, NULL },
7514 #endif /*defined(INCLUDE_IPLAYER) || defined(INCLUDE_FREESAT)*/
7515 #ifdef INCLUDE_FREESAT
7516  { "GPR", &MHEG5prgGetPINRequirement, NULL },
7517  { "VPP", &MHEG5prgValidatePIN, NULL },
7518  { "CPS", &MHEG5prgComputePrivateSignature, NULL },
7519 #endif /*INCLUDE_FREESAT*/
7520 #endif /*INCLUDE_ICS*/
7521 #endif /*INCLUDE_IC*/
7522 #ifdef INCLUDE_FREESAT
7523  { "FSI", &MHEG5prgGetFSIServiceReference, NULL },
7524 #endif /*INCLUDE_FREESAT*/
7525 #ifdef INCLUDE_SI_EXTENSION
7526  { "SeI", &MHEG5prgSI_GetServiceInfo, NULL },
7527  { "GEI", &MHEG5prgSI_GetEventInfo, NULL },
7528 #endif
7529 #ifdef INCLUDE_TPS
7530  { "PST", &MHEG5prgPersistentStorageInfo, NULL },
7531 
7532 #endif
7533 #ifdef INCLUDE_CONNECTED_TV
7534  { "GLA", &MHEG5prgGetLaunchArguments, NULL },
7535  { "ApL", &MHEG5prgApplicationLaunch, NULL },
7536 #endif /*INCLUDE_CONNECTED_TV*/
7537  /* Long names */
7538  { "GetCurrentDate",
7539  &MHEG5prgGetCurrentDate, NULL },
7540  { "FormatDate",
7541  &MHEG5prgFormatDate, NULL },
7542  { "GetDayOfWeek",
7543  &MHEG5prgGetDayOfWeek, NULL },
7544  { "Random",
7545  &MHEG5prgRandom, NULL },
7546  { "CastToContentRef",
7547  &MHEG5prgCastToContentRef, NULL },
7548  { "CastToObjectRef",
7549  &MHEG5prgCastToObjectRef, NULL },
7550  { "CastToStringInt",
7551  &MHEG5prgCastToStringInt, NULL },
7552  { "GetStringLength",
7553  &MHEG5prgGetStringLength, NULL },
7554  { "GetSubString",
7555  &MHEG5prgGetSubString, NULL },
7556  { "SearchSubString",
7557  &MHEG5prgSearchSubString, NULL },
7558  { "SearchAndExtractSubString",
7559  &MHEG5prgSearchAndExtractSubString, NULL },
7560  { "SI_GetServiceIndex",
7561  &MHEG5prgSI_GetServiceIndex, NULL },
7562 #ifndef CI_PLUS_ONLY
7563  { "SI_TuneIndex",
7564  &MHEG5prgSI_TuneIndex, NULL },
7565  { "SI_TuneIndexInfo",
7566  &MHEG5prgSI_TuneIndexInfo, NULL },
7567  { "VideoToGraphics",
7568  &MHEG5prgVideoToGraphics, NULL },
7569  { "SetSubtitleMode",
7570  &MHEG5prgSetSubtitleMode, NULL },
7571  { "SetWidescreenAlignment",
7572  &MHEG5prgSetWidescreenAlignment, NULL },
7573 #endif
7574  { "SI_GetBasicSI",
7575  &MHEG5prgSI_GetBasicSI, NULL },
7576  { "CheckContentRef",
7577  &MHEG5prgCheckContentRef, &clearOrmHandle },
7578  { "CheckGroupIDRef",
7579  &MHEG5prgCheckGroupIDRef, &clearOrmHandle },
7580  { "CI_SendMessage",
7581  &MHEG5prgCI_SendMessage, NULL },
7582 #ifndef CI_PLUS_ONLY
7583  { "GetBootInfo",
7584  &MHEG5prgGetBootInfo, NULL },
7585 #endif /* !CI_PLUS_ONLY */
7586  { "WhoAmI",
7587  &MHEG5prgWhoAmI, NULL },
7588 #ifdef INCLUDE_DEBUG_PACKAGE
7589  { "Debug",
7590  &MHEG5prgDebug, NULL },
7591 #endif /* INCLUDE_DEBUG_PACKAGE */
7592  { "GetDisplayAspectRatio",
7593  &MHEG5prgGetDisplayAspectRatio, NULL },
7594 #ifdef INCLUDE_NATIVE_APP
7595  { "SetBroadcasterInterruptions",
7596  &MHEG5prgSetBroadcasterInterruptions, NULL },
7597 #endif /*INCLUDE_NATIVE_APP*/
7598 #ifdef INCLUDE_PVR_AU
7599  { "PVR_MakeBooking2",
7600  &MHEG5prgPVR_MakeBooking2, NULL },
7601  { "PVR_CancelBooking2",
7602  &MHEG5prgPVR_CancelBooking2, NULL },
7603  { "PVR_ListBooking2",
7604  &MHEG5prgPVR_ListBookings2, NULL },
7605  { "PVR_GetDetails2",
7606  &MHEG5prgPVR_GetDetails2, NULL },
7607 #endif /*INCLUDE_PVR_AU*/
7608 #ifdef INCLUDE_MHEG_PVR
7609  { "PVR_MakeBooking",
7610  &MHEG5prgPVR_MakeBooking, NULL },
7611  { "PVR_CancelBooking",
7612  &MHEG5prgPVR_CancelBooking, NULL },
7613  { "PVR_ListBooking",
7614  &MHEG5prgPVR_ListBookings, NULL },
7615 #endif /*INCLUDE_MHEG_PVR*/
7616 #ifdef INCLUDE_SA_PROFILE
7617  { "LNG_GetPreferredLangs",
7618  &MHEG5prgLNG_GetPreferredLangs, NULL },
7619  { "LNG_GetAudioLangs",
7620  &MHEG5prgLNG_GetAudioLangs, NULL },
7621  { "LNG_GetSubtitleLangs",
7622  &MHEG5prgLNG_GetSubtitleLangs, NULL },
7623  { "LNG_GetADLangs",
7624  &MHEG5prgLNG_GetADLangs, NULL },
7625  { "SEI_GetNumberOfServices",
7626  &MHEG5prgSEI_GetNumberOfServices, NULL },
7627  { "SEI_NextServiceIndex",
7628  &MHEG5prgSEI_NextServiceIndex, NULL },
7629  { "SEI_GetServiceRunningStatus",
7630  &MHEG5prgSEI_GetServiceRunningStatus, NULL },
7631  { "SEI_GetChannelNumber",
7632  &MHEG5prgSEI_GetChannelNumber, NULL },
7633  { "SEI_SetEventIterator",
7634  &MHEG5prgSEI_SetEventIterator, NULL },
7635  { "SEI_IncrementEventIterator",
7636  &MHEG5prgSEI_IncrementEventIterator, NULL },
7637  { "SEI_GetScheduledEventInfo",
7638  &MHEG5prgSEI_GetScheduledEventInfo, NULL },
7639  { "SEI_GetComponentInfo",
7640  &MHEG5prgSEI_GetComponentInfo, NULL },
7641  { "SEI_GetComponentData",
7642  &MHEG5prgSEI_GetComponentData, NULL },
7643  { "PFEI_GetEventId",
7644  &MHEG5prgPFEI_GetEventId, NULL },
7645  { "PFEI_GetComponentInfo",
7646  &MHEG5prgPFEI_GetComponentInfo, NULL },
7647  { "PFEI_GetComponentData",
7648  &MHEG5prgPFEI_GetComponentData, NULL },
7649  { "REM_SetNativeReminder",
7650  &MHEG5prgREM_SetNativeReminder, NULL },
7651  { "REM_GetNativeReminder",
7652  &MHEG5prgREM_GetNativeReminder, NULL },
7653  { "REM_CancelNativeReminder",
7654  &MHEG5prgREM_CancelNativeReminder, NULL },
7655  { "SA_GetHostSetting",
7656  &MHEG5prgSA_GetHostSetting, NULL },
7657 #endif /*INCLUDE_SA_PROFILE*/
7658 #ifdef INCLUDE_CI_PLUS
7659  { "RequestMPEGDecoder",
7660  &MHEG5prgRequestMPEGDecoder, NULL },
7661  { "SuppressMHEGGraphics",
7662  &MHEG5prgSuppressMHEGGraphics, NULL },
7663 #endif /*INCLUDE_CI_PLUS*/
7664  { "TestInputMask",
7665  &MHEG5prgTestInputMask, NULL },
7666 #ifdef INCLUDE_IC
7667  { "SetHybridFileSystem",
7668  &MHEG5prgSetHybridFileSystem, NULL },
7669  { "GetICStatus",
7670  &MHEG5prgGetICStatus, NULL },
7671  { "ReturnData",
7672  &MHEG5prgReturnData, NULL },
7673  { "GetCookie",
7674  &MHEG5prgGetCookie, NULL },
7675  { "SetCookie",
7676  &MHEG5prgSetCookie, NULL },
7677 #ifdef INCLUDE_ICS
7678  { "PromptForGuidance",
7679  &MHEG5prgPromptForGuidance, &stopPrompt },
7680  { "MeasureStreamPerformance",
7681  &MHEG5prgMeasureStreamPerformance, &stopMeasurement },
7682 #ifdef INCLUDE_IPLAYER
7683  { "GetPINSupport",
7684  &MHEG5prgGetPINSupport, NULL },
7685 #endif /*INCLUDE_IPLAYER*/
7686 #if defined(INCLUDE_IPLAYER) || defined(INCLUDE_FREESAT)
7687  { "GetAudioDescPref",
7688  &MHEG5prgGetAudioDescPref, NULL },
7689  { "GetSubtitlePref",
7690  &MHEG5prgGetSubtitlePref, NULL },
7691 #endif /*defined(INCLUDE_IPLAYER) || defined(INCLUDE_FREESAT)*/
7692 #ifdef INCLUDE_FREESAT
7693  { "GetPINRequirement",
7694  &MHEG5prgGetPINRequirement, NULL },
7695  { "ValidatePIN",
7696  &MHEG5prgValidatePIN, NULL },
7697  { "ComputePrivateSignature",
7698  &MHEG5prgComputePrivateSignature, NULL },
7699 #endif /*INCLUDE_FREESAT*/
7700 #endif /*INCLUDE_ICS*/
7701 #endif /*INCLUDE_IC*/
7702 #ifdef INCLUDE_FREESAT
7703  { "GetFSIServiceReference",
7704  &MHEG5prgGetFSIServiceReference, NULL },
7705 #endif /*INCLUDE_FREESAT*/
7706 #ifdef INCLUDE_SI_EXTENSION
7707  { "SI_GetServiceInfo",
7708  &MHEG5prgSI_GetServiceInfo, NULL },
7709  { "SI_GetEventInfo",
7710  &MHEG5prgSI_GetEventInfo, NULL },
7711 #endif
7712 #ifdef INCLUDE_TPS
7713  { "PersistentStorageInfo",
7714  &MHEG5prgPersistentStorageInfo, NULL },
7715 #endif
7716 #ifdef INCLUDE_CONNECTED_TV
7717  { "GetLaunchArguments",
7718  &MHEG5prgGetLaunchArguments, NULL },
7719  { "ApplicationLaunch",
7720  &MHEG5prgApplicationLaunch, NULL },
7721 #endif /*INCLUDE_CONNECTED_TV*/
7722 
7723  { NULL, NULL, NULL } /* End of list */
7724  };
7725 
7726  assert(program);
7727  assert(program->ingredient.root.clazz == MHEG5RESIDENTPROGRAM);
7728  assert(program->startFunc == NULL);
7729 
7730  if (program->name.len == 0)
7731  {
7732  #ifdef MHEG5LOG
7733  MHEG5LogPrintf(MHEG5ERROR, "MHEG5Program - Empty program name\n");
7734  #endif
7735  }
7736  else
7737  {
7738  #ifdef MHEG5LOG
7739  MHEG5LogPrintf(MHEG5MESSAGE, "MHEG5Program - Executing program ");
7740  MHEG5LogPrintString(MHEG5MESSAGE, program->name);
7741  MHEG5LogPrintf(MHEG5MESSAGE, "\n");
7742  #endif
7743 
7744  program->startFunc = NULL;
7745  program->stopFunc = NULL;
7746 
7747  for (i = 0; ProgramTable[i].name != NULL; i++)
7748  {
7749  if (strcmp((char *)program->name.data,
7750  (char *)ProgramTable[i].name) == 0)
7751  {
7752  program->startFunc = ProgramTable[i].startFunction;
7753  program->stopFunc = ProgramTable[i].stopFunction;
7754  return;
7755  }
7756  }
7757  }
7758 }
7759 
#define TPRINT(t, x)
Definition: glue_debug.h:119
const char * name
Definition: mh5prgs.c:214
E_ServiceType
Definition: dvb_service.h:51
U8BIT DVB_MhegPrefSubtitleLangs(U32BIT *langs, U8BIT max)
Get list of preferred subtitle languages. If there is no preference then zero is returned. This only writes into array up to &#39;max&#39; items This MUST be a non-blocking function, returning results immediately.
Date functions.
MHEG5Bool * forkSucceededValue
Definition: mh5program.h:59
void(* stopFunc)(struct MHEG5Program_struct *)
Definition: mh5program.h:63
Implement MHEG5 engine control functions (i.e. start/stop etc)
MHEG5String value
Definition: mh5cookies.h:41
void DVB_MhegSetVideoAlignment(E_VIDEO_ASPECT_MODE mode)
unsigned long MHEG5random(void)
Calculate and return a psuedo random number.
Definition: mh5base.c:1071
Basis MHEG5 data types.
void MG_DisplayVideoToGraphics(MHEG5Int videoXval, MHEG5Int videoYval, MHEG5Int *graphicsXVal, MHEG5Int *graphicsYVal)
Calculate the graphical co-ordinate from a given video coordinate (should take into account the curre...
Definition: mg_video.c:294
E_MhegErr DVB_MhegGetBannerTimeout(S32BIT *timeout)
Return the banner timeout period in seconds. This setting is related to the information banner on the...
Distributor for Prepare, Destruct, Activate, Deactivate and Clone calls. Distribute the +Prepare +Des...
struct ResidentProgramTableEntry_struct ResidentProgramTableEntry_t
void MG_SetSubtitleMode(MHEG5Bool subtitleOn)
Set the current subtitle display mode to be either On or Off, Should only have an impact if subtitles...
Definition: mg_video.c:89
S_STRING description
Definition: dvb_pvr.h:83
MHEG5Bool forked
Definition: mh5program.h:58
#define DBG_PRINTF(...)
Definition: glue_debug.h:127
S32BIT type
Definition: dvb_pvr.h:81
MHEG5GList * parameter
Definition: mh5program.h:57
const char * data
Definition: mh5gate.c:56
True Persistent Storage functions.
MHEG5Int MHEG5GetServiceIndex(MHEG5String *serviceReference)
Ref:[1] - 3.10.6.1 and [1] - 3.10.6.3 Get the serviceIndex, a positive integer which is used to refer...
Definition: mh5misc.c:206
MHEG5String s
Definition: mh5base.h:156
MHEG5String name
Definition: mh5program.h:50
void MHEG5SuppressMHEGGraphics(MHEG5Bool request)
Request that the external application toggles between showing MHEG graphics or subtitles This functio...
S32BIT MHEG5getDayOfWeek(S32BIT day)
Get Day of Week for Davic-Day 0 is Sunday....
Definition: mh5date.c:285
MHEG5String contentData
Definition: mh5variable.h:106
U16BIT type
Definition: mh5base.h:151
E_MhegErr DVB_MhegGetAudioLangs(S32BIT serviceIndex, S32BIT eventIndex, U8BIT *audioLangs)
Return a list of available audio languages for the specified event. The language list is extracted fr...
void(* stopFunction)(MHEG5Program *)
Definition: mh5prgs.c:216
unsigned char * STR_DataAlloc(unsigned int size)
Definition: glue_memory.c:596
MHEG5GList * MHEG5resolveGenericInteger(MHEG5GList *params, MHEG5Int *value)
Definition: mh5object.c:510
MHEG5Final clazz
Definition: mh5root.h:55
void MHEG5StreamerAbortMeasurement(MHEG5Program *program)
Abort streaming performance measurement.
union sMH5GroupRef::@5 ptr
void MHEG5getDate(S32BIT *day, S32BIT *sec)
Modified Julian Date - see Davic 9.2.12.1.
Definition: mh5date.c:111
S_CRID_DETAILS * DVB_MhegPvrGetDetails(S_STRING crid)
Required by Australia profile only. Returns the type, name, description and a single booking section ...
void MHEG5objRefStoreValue(MHEG5ObjectRefVariable *objRef, MH5GroupRef ref, MHEG5Int id)
Definition: mh5variable.c:503
void * MHEG5FileOrmGet(MHEG5String name, U16BIT priority, void *userData, F_CB_Good cbGood, F_CB_Fail cbFail)
Get a file. The file will be loaded and one of the callback functions called when request is resolved...
Definition: mh5fileorm.c:1179
Implementation of the Group class Description Defines the structure and behaviour of objects used as ...
Miscellaneous.
void MHEG5SetHybridFileSystem(MHEG5String *pathName, MHEG5String *mappingList)
Set mapping list in the hybrid file system. This function sets, clears or modifies the list of mappin...
Definition: mh5hfs.c:152
MHEG5Bool MHEG5RequestMPEGDecoder(MHEG5Bool request)
Requests exclusive access to a MPEG decoder and video plane to display I-frames. The MPEG decoder sha...
E_MhegErr DVB_MhegGetBannerTransparency(S32BIT *transparency)
Return the banner transparency as a percentage 0-100, where 100 is fully transparent. This setting is related to the information banner on the native UI of the receiver.
S_STRING title
Definition: dvb_pvr.h:82
union MHEG5Generic::@6 value
MHEG5Ingredient ingredient
Definition: mh5program.h:47
U8BIT * zptr
Definition: dtvstring.h:31
E_MhegErr
Definition: mherrors.h:28
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
Definition: mh5base.c:574
#define FRP_CACHE_DEFAULT
Definition: mh5fileorm.h:38
MHEG5Bool MHEG5CookieRetrieve(MHEG5cookie_t *cookie)
Retrieve a specific cookie from the store, referenced by the identity string.
Definition: mh5cookies.c:368
Implement the MHEG5 Variable Class 21 Variable Class Defines a variable within the context of a Group...
void MHEG5ProgramSetStartFunc(MHEG5Program *program)
Test if the program NAME is included in this profile and get the start function to execute...
Definition: mh5prgs.c:7420
MHEG5Bool MHEG5parseEncodeQPrintable(MHEG5Byte **buffer, MHEG5Int *used, MHEG5Int *allocated, MHEG5Generic *value)
Add a value to the buffer. The value is QPrintable-encoded, which means that printable characters are...
Definition: mh5parse.c:729
S_STRING crid
Definition: dvb_pvr.h:98
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
Definition: mh5base.c:686
#define FRP_EXISTS
Definition: mh5fileorm.h:43
MHEG5String MHEG5GetBootInfo(MHEG5Bool *InfoResultVal)
Tell whether a network_boot_info sub-descriptor has been found and received. If so, returns the value of the NB_info field of the network_boot_info sub-descriptor. This function is used by the GetBootInfo resident program. See UK1.06 profile section 3.10.7.3.
Definition: mh5misc.c:244
uint8_t U8BIT
Definition: techtype.h:82
long MHEG5Int
Definition: mh5base.h:73
E_MhegErr DVB_MhegGetSubtitleLangs(S32BIT serviceIndex, S32BIT eventIndex, U8BIT *subsLangs)
Return a list of available subtitles languages for the specified event. The language list is extracte...
void MHEG5StreamerMeasurePerformance(MHEG5String *url, MHEG5Int maxBytes, MHEG5Program *program)
Measure streaming performance (bytes per second). The result is returned to the resident program...
DVB Video functions are required by MHEG5 engine. All required functions should be non-blocking...
string parsing utility functions for MHEG5
void MHEG5objRefValueDestruct(MHEG5ObjectRefVariable *objRef)
void DVB_MhegPvrReleaseList(S_CRID_REC *crid_array)
MHEG indicates that it is finished using the array returned by DVB_MhegPvrListBookings(). For example, platforms that malloc memory for this, may wish to free the memory here.
MHEG5Bool secure
Definition: mh5cookies.h:43
BOOLEAN DVB_MhegGetSubtitlePref(void)
This function is used by the MHEG-5 engine to determine whether subtitles are currently enabled...
void MHEG5FileOrmClear(void *orm_ref)
Aborts a request for file.
Definition: mh5fileorm.c:979
DVB Service information functions are required by MHEG5 engine. All required functions should be non-...
MHEG5GList * MHEG5resolveGenericCRef(MHEG5GList *params, MHEG5String *data, MHEG5Bool *referenced, MHEG5Bool *valid)
Definition: mh5object.c:299
S_BOOKING * bookings
Definition: dvb_pvr.h:86
#define MHEG5freeMem
Definition: glue_memory.h:94
E_MhegErr DVB_MhegGetNativeReminder(S32BIT serviceIndex, S32BIT eventId, BOOLEAN *set)
Return whether a native reminder has been set for the given event on the given service. This MUST be a non-blocking function, returning results immediately.
MHEG5ErrorCode(* startFunc)(struct MHEG5Program_struct *)
Definition: mh5program.h:62
API for IC streamer.
This file defines the profile for the MHEG engine.
MHEG5GList * MHEG5resolveGenericOctetString(MHEG5GList *params, MHEG5String *value, MHEG5Bool *invalidString)
Resolve a parameter reference to a generic octet string. The reference can be either direct or indire...
Definition: mh5object.c:478
void MHEG5TuneIndexInfo(MHEG5Int tuneInfo)
Sets the way the application expects the receiver is to perform all subsequence application initiated...
Definition: mh5control.c:882
E_MhegErr DVB_MhegGetADLangs(S32BIT serviceIndex, S32BIT eventIndex, U8BIT *adLangs)
Return a list of available audio description languages for the specified event. The language list is ...
MHEG5String MH5_WhoAmI(void)
Used by the WhoAmI resident program to obtain WhoAmI string. See UK1.06 profile section 3...
Definition: mh5support.c:709
Implementation of the resident programs which are defined by the current profile. ...
MHEG5 PVR functions for New Zealand or Australia profile References: [1] UK1 Profile - Digital Terres...
BOOLEAN DVB_MhegAudioDescriptionPref(void)
This function is used by the MHEG-5 engine to determine whether audio description is currently enable...
void DVB_MhegPvrReleaseDetails(S_CRID_DETAILS *details)
Required by Australia profile only. MHEG indicates that it is finished using the CRID details returne...
MHEG5Bool MHEG5CookieAdd(MHEG5cookie_t *cookie)
Directly add a cookie to the store.
Definition: mh5cookies.c:317
void MHEG5objRefStoreString(MHEG5ObjectRefVariable *objRef, MHEG5String ref, MHEG5Int id)
Definition: mh5variable.c:529
E_MhegErr DVB_MhegCancelNativeReminder(S32BIT serviceIndex, S32BIT eventId)
Cancel any native reminder set for the given event on the given service. This MUST be a non-blocking ...
short MHEG5Bool
Definition: mh5base.h:71
MHEG5Int expires
Definition: mh5cookies.h:42
MHEG5ErrorCode
Definition: mh5base.h:222
unsigned char MHEG5Byte
Definition: mh5base.h:74
Native language, reminder and banner functions for South Africa profile.
E_MhegErr DVB_MhegSetNativeReminder(S32BIT serviceIndex, S32BIT eventId, BOOLEAN *result)
Set a native reminder for the given event on the given service. This MUST be a non-blocking function...
Event handling. Implementation of a combined queue for events and actions. This is the eventsystem wh...
MHEG5Byte * data
Definition: mh5base.h:85
int len
Definition: mh5gate.c:57
#define UND_LANGUAGE_CODE
Definition: mh5control.h:39
int32_t S32BIT
Definition: techtype.h:87
#define MHEG5TRUE
Definition: mh5base.h:49
MHEG5Bool MHEG5GetBasicSI(MHEG5Int serviceIndex, MHEG5Int *networkID, MHEG5Int *origNetworkID, MHEG5Int *transportStreamID, MHEG5Int *serviceID)
Returns a series of integers representing basic Service Information (SI) about a service. The service is identified by means of a receiver specific "ServiceIndex". This integer can be determined by means of the SI_GetServiceIndex resident program (see 3.10.6.1, "SI_GetServiceIndex", on page 3-20). This function is used by the SI_TuneIndexInfo resident program. See UK1.06 profile section 3.10.6.3.
Definition: mh5misc.c:311
MHEG5ErrorCode(* startFunction)(MHEG5Program *)
Definition: mh5prgs.c:215
void MHEG5ingredientDeactivate(MHEG5Ingredient *ingredient)
Implementation of Deactivate behaviour Inherrited from Root class.
uint16_t U16BIT
Definition: techtype.h:84
Implement functions to retrieve MHEG5objects by GroupID and ID.
Mheg5 logging and debug printing.
MHEG5Int len
Definition: mh5base.h:99
MHEG5Bool runningStatus
Definition: mh5root.h:51
File interface functions to DSMCC component.
MHEG5Byte * name
Definition: mh5base.h:102
U8BIT DVB_MhegPrefAudioLangs(U32BIT *langs, U8BIT max)
Get list of preferred audio languages. If there is no preference then zero is returned. This only writes into array up to &#39;max&#39; items This MUST be a non-blocking function, returning results immediately.
MHEG5String identity
Definition: mh5cookies.h:40
MHEG5String groupName
Definition: mh5group.h:53
DVB Audio functions are required by MHEG5 engine. All required functions should be non-blocking...
redirection include
E_MhegErr DVB_MhegPvrCancelBooking(S_STRING crid, U16BIT crid_type)
Removes an event from the PVR schedule.
Functions relating to HTTP Cookie Store.
Definition: mg_png.c:52
void MHEG5sendEvent(MHEG5Root *source, MHEG5EventType event, MHEG5Int data)
Store an event in the asynchronous event queue.
Definition: mh5queue.c:1540
#define FALSE
Definition: techtype.h:68
MHEG5Bool MHEG5TuneIndex(MHEG5Int serviceIndex)
Ref: [1] - 3.10.6.2 Tune to the specified service. If the tuner fails to tune to the service it shoul...
Definition: mh5control.c:852
MH5GroupPtr group
Definition: mh5base.h:103
MHEG5String MHEG5formatDate(MHEG5String format, S32BIT day, S32BIT sec)
Format date - See Davic part 9.0 - 9.2.12.1.
Definition: mh5date.c:144
void MHEG5NotifyBookingResult(E_MhegErr result)
This should be called, and only called, when DVB_MhegPvrMakeBooking() has previously returned with MH...
MHEG5GList * MHEG5resolveGenericBoolean(MHEG5GList *params, MHEG5Bool *value)
Definition: mh5object.c:454
MHEG5Int len
Definition: mh5base.h:84
MHEG5String valueGrp
Definition: mh5variable.h:93
U8BIT BOOLEAN
Definition: techtype.h:99
U32BIT zlen
Definition: dtvstring.h:30
MHEG5Bool MHEG5IsInputMaskSupported(MHEG5String query_mask)
Tell whether the set of keys indicated by the input mask is supported by the receiver (this means tha...
Definition: mh5keypress.c:1076
#define TRUE
Definition: techtype.h:69
MHEG5GList * MHEG5resolveORef(MHEG5GList *params, MHEG5Root **object)
Definition: mh5object.c:126
Definition: mh5prgs.c:212
MHEG5Int MHEG5GetDisplayAspectRatio(void)
Reads the format of the connected display (4:3 or 16:9) This function is used by the GetDisplayAspect...
Definition: mh5misc.c:280
MHEG5GList * MHEG5resolveGenericGeneric(MHEG5GList *params, MHEG5Generic *value)
Definition: mh5object.c:364
References: [1] UK1 Profile - Digital Terrestrial Television - Requirements for interoperability (The...
Implement generic MHEG5-display functions - independent from the OSD These are generic functions used...
MHEG5Bool MHEG5GetTpsStatus()
Get the status of the TPS store for the PST resident program. none.
Definition: mh5tps.c:235
Video Scaling / Positioning functionality.
void MHEG5enableEventProcessing(MHEG5Bool enable)
Enable or disable engine event processing. This function is used to implement the Call action for res...
Definition: mh5queue.c:1751
void MHEG5PromotionalLinkControl(BOOLEAN isEnabled)
Definition: mh5keypress.c:1248
E_MhegErr DVB_MhegPvrMakeBooking(S_STRING crid, S_CRID_DETAILS *details)
The function adds an event to the PVR’s list of scheduled events to record. The type of CRID can be a...
#define MHEG5FALSE
Definition: mh5base.h:48
uint32_t U32BIT
Definition: techtype.h:86
E_MhegErr DVB_MhegGetOSDLanguage(U8BIT *language)
Return the language of the native UI (menu etc.) as a three character code as defined by ISO 639-2...
Functions relating to Hybrid file system.
Key Press related functionality.
S_CRID_REC * DVB_MhegPvrListBookings(U16BIT *number)
Returns an array of CRIDs (and CRID types for NZ profile) that are being monitored by the PVR...
MHEG5GList * MHEG5resolveGenericORefProper(MHEG5GList *params, MH5GroupRef *pgroupRef, MHEG5Int *id)
Resolve a generic object reference, returning the object reference. The reference can be direct or in...
Definition: mh5object.c:177
Engine support utility functions for MHEG5.
#define TRACE(t, x)
Definition: glue_debug.h:118