DVBCore  20.3.0
DVBCore Documentation
ap_pvr.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  *
5  * This file is part of a DTVKit Software Component
6  * You are permitted to copy, modify or distribute this file subject to the terms
7  * of the DTVKit 1.0 Licence which can be found in licence.txt or at www.dtvkit.org
8  *
9  * THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
10  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES
11  * OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
12  *
13  * If you or your organisation is not a member of DTVKit then you have access
14  * to this source code outside of the terms of the licence agreement
15  * and you are expected to delete this and any associated files immediately.
16  * Further information on DTVKit, membership and terms can be found at www.dtvkit.org
17  *******************************************************************************/
26 //---includes for this file-------------------------------------------------------------------------
27 // compiler library header files
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <string.h>
31 
32 // third party header files
33 
34 // Ocean Blue Software header files
35 #include "techtype.h" //generic data definitions
36 #include "dbgfuncs.h" //debug functions
37 
38 #include "stbhwos.h"
39 #include "stbhwav.h"
40 #include "stbpvrpr.h"
41 #include "stbhwdsk.h"
42 
43 #include "stbgc.h"
44 #include "stbdpc.h"
45 #include "stbsiflt.h"
46 #include "stbsitab.h"
47 #include "stbpvr.h" // STB PVR
48 #include "stbheap.h" // STB_AppFreeMemory
49 #include "stbuni.h" // STB_ConcatUnicodeStrings()
50 #include "stbdsapi.h"
51 #include "stbpvrmsg.h"
52 #include "stbllist.h"
53 #include "stbebutt.h"
54 #include "stberc.h"
55 #include "ca_glue.h"
56 #include "app.h"
57 
58 #ifdef INTEGRATE_HBBTV
59 #include "hbbtv_api.h"
60 #endif
61 
62 #include "app_nvm.h" // for APP_NvmReadPVRPlaylistCurrentAtTop
63 #include "ap_pvr.h" // for PVR functionality
64 #include "ap_tmr.h" // for timer functionality
65 #include "ap_cfg.h"
66 #include "ap_dbacc.h"
67 #include "ap_dbdef.h"
68 #include "ap_si.h"
69 #include "ap_cntrl.h" // application stb layer control
70 
71 #ifdef COMMON_INTERFACE
72 #include "stbci.h"
73 #include "stbcicc.h"
74 #include "stbcica.h"
75 #include "ap_ci.h"
76 #endif
77 
78 #ifdef PVR_LOG
79 extern FILE *pvr_log;
80 extern void LogDateTime();
81 #endif
82 
83 //---constant definitions for this file-------------------------------------------------------------
84 // enable debug printing remove first comments
85 // NOTE: no brackets around x to allow for multiple line arguments
86 // ap_pvr.c
87 #define APP_PRINT_PVR_REC(x) // STB_SPDebugWrite x // recording
88 #define APP_PRINT_PVR_PAUSE(x) // STB_SPDebugWrite x // pause
89 #define APP_PRINT_PVR_PLAY_STATUS(x) // STB_SPDebugWrite x // play status
90 #define APP_PRINT_PVR_PLAY_TUNE(x) // STB_SPDebugWrite x // play status
91 #define APP_PRINT_PVR_FP(x) // STB_SPDebugWrite x // Freeview+ debug
92 
93 // PVR constants
94 #define PVR_NUM_DUMMY_RECORDINGS 15
95 
96 #define PVR_NORMAL_PLAY_SPEED 100
97 
98 #define RECORD_WAIT_TIMEOUT 1000 // 1 seconds
99 
100 #define MS_DIGIT 0
101 #define LS_DIGIT 1
102 
103 #define PVR_100_PERCENT 100
104 
105 #define CRID_DATE_TIMEOUT 91 /* This is the number of days that a CRID record should
106  * remain in the CRID record list since it was last seen
107  * in the EIT schedule data. */
108 #define CRID_MAX_SIZE 64
109 
110 
111 #define PAT_PID 0
112 #define CAT_PID 1
113 #define EIT_PID 18
114 
115 //---local typedefs, structs, enumerations for this file--------------------------------------------
116 /*#define DEBUG_PVR*/
117 
118 #ifdef DEBUG_PVR
119 #define DBG_PVR(X) STB_SPDebugWrite X
120 #else
121 #define DBG_PVR(X)
122 #endif
123 
124 
125 //---local (static) variable declarations for this file---------------------------------------------
126 // (internal variables declared static to make them local)
127 
128 // ---- services ----
129 static void *tuned_service_ptr;
130 
131 // ---- play ----
132 static BOOLEAN inc_speed;
133 static BOOLEAN is_trick_mode_mute_on;
134 static U8BIT trick_mode_copy_volume_value;
135 static U32BIT playback_handle;
136 static U8BIT playback_path = INVALID_RES_ID;
137 static U8BIT pause_path = INVALID_RES_ID;
138 static U8BIT monitor_si_path = INVALID_RES_ID;
139 
140 // ---- pause ----
141 static U32BIT paused_recording;
142 static U16BIT paused_disk_id;
143 static U16BIT timeshift_buffer_size;
144 
145 static void *eit_update_queue;
146 static void *process_crids_task;
147 
148 static ADB_SERVICE_REC *playback_service = NULL;
149 
150 static BOOLEAN encrypt_recordings;
151 
152 #ifdef COMMON_INTERFACE
153 static U32BIT *cam_record_start_timer;
154 #endif
155 
156 //---local function prototypes for this file--------------------------------------------------------
157 // (internal functions declared static to make them local)
158 
159 // ---- services list ----
160 
161 // ---- services ----
162 
163 // ---- recording ----
164 static BOOLEAN GetRecording(U8BIT tuner_id, U8BIT **name_ptr);
165 static BOOLEAN DestroyRecording(U32BIT recording_handle);
166 static S16BIT IsPidInList(U16BIT pid, S_PVR_PID_INFO *pid_array, U16BIT num_pids);
167 static U16BIT FillPidList(void *service, S_PVR_PID_INFO **pid_array);
168 static void SetupForRecording(U8BIT path, void *service, BOOLEAN update);
169 
170 // ---- playing ----
171 
172 // is a recording being played
173 static BOOLEAN IsPlayingHandle(U32BIT *recording_handle_ptr);
174 
175 static void EitUpdatedTask(void *param);
176 static void ProcessCridRecords(void);
177 
178 static void FreePlaybackService(ADB_SERVICE_REC *service);
179 static ADB_SERVICE_REC* CreatePlaybackService(U16BIT service_id);
180 #ifdef COMMON_INTERFACE
181 static U32BIT NewCountdownTimer(U32BIT seconds);
182 #endif
183 
184 //---local function definitions------------------------------------------------
197 static BOOLEAN GetRecording(U8BIT path, U8BIT **name_ptr)
198 {
199  BOOLEAN recording_ok;
200  U32BIT recording_handle;
201 
202  FUNCTION_START(GetRecording);
203 
204  if (STB_DPIsRecording(path, &recording_handle))
205  {
206  *name_ptr = STB_PVRRecordingGetName(recording_handle);
207  recording_ok = TRUE;
208  }
209  else
210  {
211  *name_ptr = NULL;
212  recording_ok = FALSE;
213  }
214 
215  FUNCTION_FINISH(GetRecording);
216 
217  return(recording_ok);
218 }
219 
232 static BOOLEAN DestroyRecording(U32BIT recording_handle)
233 {
234  U32BIT handle;
235  U8BIT path;
236  BOOLEAN retval;
237 
238  FUNCTION_START(DestroyRecording);
239 
240  retval = FALSE;
241 
242  // stop recording and timers
243  if (recording_handle != 0)
244  {
245  // stop playing
246  if (IsPlayingHandle(&handle) == TRUE)
247  {
248  if (handle == recording_handle)
249  {
250  APP_PRINT_PVR_REC(("DestroyRecording: stop playing recording 0x%x", recording_handle));
251  APVR_StopPlay(FALSE);
252  }
253  }
254 
255  // stop recording
256  for (path = 0; path < STB_DPGetNumPaths(); path++)
257  {
258  if (STB_DPIsRecording(path, &handle))
259  {
260  if (handle == recording_handle)
261  {
262  STB_DPStopRecording(path);
263  ATMR_DeleteRecordingTimer(recording_handle);
264  APP_PRINT_PVR_REC(("DestroyRecording: StopRecordingType for path %d finished", path));
265  }
266  }
267  }
268 
269  retval = STB_PVRDestroyRecording(recording_handle);
270  if (retval && (recording_handle != paused_recording))
271  {
272  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_PVR_RECORDING_DELETED,
273  &recording_handle, sizeof(recording_handle));
274  }
275  }
276 
277  FUNCTION_FINISH(DestroyRecording);
278 
279  return(retval);
280 }
281 
282 // ---- playing ----
283 
295 static BOOLEAN IsPlayingHandle(U32BIT *recording_handle_ptr)
296 {
297  BOOLEAN is_playing;
298  U8BIT path;
299 
300  FUNCTION_START(IsPlayingHandle);
301 
302  is_playing = FALSE;
303 
304  if (playback_path != INVALID_RES_ID)
305  {
306  path = playback_path;
307  }
308  else
309  {
310  path = STB_DPGetLivePath();
311  }
312 
313  if (path != INVALID_RES_ID)
314  {
315  if (STB_PVRIsPlaying(path, recording_handle_ptr) == TRUE)
316  {
317  is_playing = TRUE;
318  }
319  }
320 
321  FUNCTION_FINISH(IsPlayingHandle);
322 
323  return(is_playing);
324 }
325 
326 /*!**************************************************************************
327  * @brief Checks whether the given PID is in the given list
328  * @param pid - PID to be searched for
329  * @param pid_array - array of PIDs to check
330  * @param num_pids - number of PIDs in the array
331  * @return Array index if the pid is found, -1 if not found
332  ****************************************************************************/
333 static S16BIT IsPidInList(U16BIT pid, S_PVR_PID_INFO *pid_array, U16BIT num_pids)
334 {
335  S16BIT i;
336  S16BIT index;
337 
338  index = -1;
339 
340  for (i = 0; i < num_pids; i++)
341  {
342  if (pid_array[i].pid == pid)
343  {
344  index = i;
345  break;
346  }
347  }
348 
349  return(index);
350 }
351 
352 /*!**************************************************************************
353  * @brief Fills the given array with the PIDs that should be recorded for the given service
354  * @param service - the recorded service
355  * @param pid_array - pointer to an array that will be allocated and filled
356  * with the PIDs for recording
357  * @return number of PIDs entered in the array
358  ****************************************************************************/
359 static U16BIT FillPidList(void *service, S_PVR_PID_INFO **pid_array)
360 {
361  U16BIT max_pids;
362  U16BIT num_pids;
363  S_PVR_PID_INFO *rec_pids;
364  U16BIT pid;
365  void **stream_list;
366  U16BIT num_streams;
367  U16BIT i;
368  S16BIT index;
369  U8BIT *pmt_data;
370  U16BIT data_len;
371  U16BIT *ca_pid_array;
372  U16BIT num_ca_pids;
373 
374  FUNCTION_START(FillPidList);
375 
376  /* Find the maximum number of PIDs that will be recorded.
377  * This may not be the number that will actually be recorded because data streams
378  * won't be included in the list */
379  max_pids = ADB_GetNumStreams(service, ADB_STREAM_LIST_ALL);
380 
381  pmt_data = ADB_GetServicePMTData(service, &data_len);
382  if (pmt_data != NULL)
383  {
384  /* Get the array of PIDs the CA system wants to record, this will include ECMs */
385  if ((num_ca_pids = STB_CAGetRecordingPids(pmt_data, &ca_pid_array)) > 0)
386  {
387  max_pids += num_ca_pids;
388  }
389  }
390  else
391  {
392  num_ca_pids = 0;
393  }
394 
395  /* Add the PCR PID and the number of SI/PSI PIDs to be recorded (PAT, CAT, EIT and PMT) */
396  max_pids += 5;
397 
398  num_pids = 0;
399  *pid_array = NULL;
400 
401  if ((rec_pids = (S_PVR_PID_INFO *)STB_AppGetMemory(max_pids * sizeof(S_PVR_PID_INFO))) != NULL)
402  {
403  if ((pid = ADB_GetServicePCRPid(service)) != 0)
404  {
405  rec_pids[num_pids].type = PVR_PID_TYPE_PCR;
406  rec_pids[num_pids].pid = pid;
407  num_pids++;
408  }
409 
410  /* Add all video PIDs to the set of PIDs */
411  ADB_GetStreamList(service, ADB_VIDEO_LIST_STREAM, &stream_list, &num_streams);
412  if ((num_streams > 0) && (stream_list != NULL))
413  {
414  for (i = 0; i < num_streams; i++)
415  {
416  if ((pid = ADB_GetStreamPID(stream_list[i])) != 0)
417  {
418  /* Video PID is often the same as the PCR PID, so check for this and
419  * add it to the list as a video PID too */
420  if ((index = IsPidInList(pid, rec_pids, num_pids)) >= 0)
421  {
422  if (rec_pids[index].type == PVR_PID_TYPE_PCR)
423  {
424  /* Video and PCR PIDs are the same, force the video PID to be added too */
425  index = -1;
426  }
427  }
428 
429  if (index < 0)
430  {
431  rec_pids[num_pids].type = PVR_PID_TYPE_VIDEO;
432  rec_pids[num_pids].pid = pid;
433 
434  switch (ADB_GetStreamType(stream_list[i]))
435  {
436  case ADB_VIDEO_STREAM:
437  rec_pids[num_pids].u.video_codec = AV_VIDEO_CODEC_MPEG2;
438  break;
439 
440  case ADB_H264_VIDEO_STREAM:
441  rec_pids[num_pids].u.video_codec = AV_VIDEO_CODEC_H264;
442  break;
443 
444  case ADB_H265_VIDEO_STREAM:
445  rec_pids[num_pids].u.video_codec = AV_VIDEO_CODEC_H265;
446  break;
447 
448  default:
449  rec_pids[num_pids].u.video_codec = AV_VIDEO_CODEC_AUTO;
450  break;
451  }
452 
453  num_pids++;
454  }
455  }
456  }
457 
458  ADB_ReleaseStreamList(stream_list, num_streams);
459  }
460 
461  /* Add all audio PIDs to the set of PIDs */
462  ADB_GetStreamList(service, ADB_AUDIO_LIST_STREAM, &stream_list, &num_streams);
463  if ((num_streams > 0) && (stream_list != NULL))
464  {
465  for (i = 0; i < num_streams; i++)
466  {
467  if ((pid = ADB_GetStreamPID(stream_list[i])) != 0)
468  {
469  /* Audio PID can be the same as the PCR PID, so check for this and
470  * add it to the list as an audio PID too */
471  if ((index = IsPidInList(pid, rec_pids, num_pids)) >= 0)
472  {
473  if (rec_pids[index].type == PVR_PID_TYPE_PCR)
474  {
475  /* Audio and PCR PIDs are the same, force the audio PID to be added too */
476  index = -1;
477  }
478  }
479 
480  if (index < 0)
481  {
482  rec_pids[num_pids].type = PVR_PID_TYPE_AUDIO;
483  rec_pids[num_pids].pid = pid;
484 
485  switch (ADB_GetStreamType(stream_list[i]))
486  {
487  case ADB_AUDIO_STREAM:
488  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_MP2;
489  break;
490 
491  case ADB_AAC_AUDIO_STREAM:
492  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_AAC;
493  break;
494 
495  case ADB_HEAAC_AUDIO_STREAM:
496  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_HEAAC;
497  break;
498 
499  case ADB_AC3_AUDIO_STREAM:
500  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_AC3;
501  break;
502 
503  case ADB_EAC3_AUDIO_STREAM:
504  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_EAC3;
505  break;
506 
507  default:
508  rec_pids[num_pids].u.audio_codec = AV_AUDIO_CODEC_AUTO;
509  break;
510  }
511 
512  num_pids++;
513  }
514  }
515  }
516 
517  ADB_ReleaseStreamList(stream_list, num_streams);
518  }
519 
520  ADB_GetStreamList(service, ADB_SUBTITLE_LIST_STREAM, &stream_list, &num_streams);
521  if ((num_streams > 0) && (stream_list != NULL))
522  {
523  for (i = 0; i < num_streams; i++)
524  {
525  pid = ADB_GetStreamPID(stream_list[i]);
526  if ((pid != 0) && (IsPidInList(pid, rec_pids, num_pids) < 0))
527  {
528  rec_pids[num_pids].type = PVR_PID_TYPE_SUBTITLES;
529  rec_pids[num_pids].pid = pid;
530  num_pids++;
531  }
532  }
533 
534  ADB_ReleaseStreamList(stream_list, num_streams);
535  }
536 
537  ADB_GetStreamList(service, ADB_TTEXT_LIST_STREAM, &stream_list, &num_streams);
538  if ((num_streams > 0) && (stream_list != NULL))
539  {
540  for (i = 0; i < num_streams; i++)
541  {
542  pid = ADB_GetStreamPID(stream_list[i]);
543  if ((pid != 0) && (IsPidInList(pid, rec_pids, num_pids) < 0))
544  {
545  rec_pids[num_pids].type = PVR_PID_TYPE_TELETEXT;
546  rec_pids[num_pids].pid = pid;
547  num_pids++;
548  }
549  }
550 
551  ADB_ReleaseStreamList(stream_list, num_streams);
552  }
553 
554  rec_pids[num_pids].type = PVR_PID_TYPE_SECTION;
555  rec_pids[num_pids].pid = PAT_PID;
556  num_pids++;
557 
558  rec_pids[num_pids].type = PVR_PID_TYPE_SECTION;
559  rec_pids[num_pids].pid = CAT_PID;
560  num_pids++;
561 
562  rec_pids[num_pids].type = PVR_PID_TYPE_SECTION;
563  rec_pids[num_pids].pid = EIT_PID;
564  num_pids++;
565 
566  pid = ADB_GetServicePmtPid(service);
567  if ((pid != 0) && (pid != 0xFFFF))
568  {
569  rec_pids[num_pids].type = PVR_PID_TYPE_SECTION;
570  rec_pids[num_pids].pid = pid;
571  num_pids++;
572  }
573 
574  if (num_ca_pids > 0)
575  {
576  for (i = 0; i < num_ca_pids; i++)
577  {
578  if (IsPidInList(ca_pid_array[i], rec_pids, num_pids) < 0)
579  {
580  rec_pids[num_pids].type = PVR_PID_TYPE_SECTION;
581  rec_pids[num_pids].pid = ca_pid_array[i];
582  num_pids++;
583  }
584  }
585 
586  STB_CAReleaseRecordingPids(ca_pid_array, num_ca_pids);
587  }
588 
589  *pid_array = rec_pids;
590  }
591 
592 #ifdef PVR_LOG
593  LogDateTime();
594  fprintf(pvr_log, "FillPidList: LCN=%u, num_pids=%u\n", ADB_GetServiceLcn(service), num_pids);
595  fflush(pvr_log);
596 #endif
597 
598  FUNCTION_FINISH(FillPidList);
599 
600  return(num_pids);
601 }
602 
603 /*!**************************************************************************
604  * @brief Setup or update recording info, including the set of PIDs that are to be recorded
605  * @param path - recording path
606  * @param s_ptr - the service to be, or being, recorded
607  * @param update - TRUE if the recording has already been started and so
608  * this is an update on what's being recorded
609  ****************************************************************************/
610 static void SetupForRecording(U8BIT path, void *service, BOOLEAN update)
611 {
612  U16BIT num_pids;
613  S_PVR_PID_INFO *rec_pids;
614  void *t_ptr;
615  U16BIT serv_id, ts_id, onet_id;
616 
617  FUNCTION_START(SetupForRecording);
618 
619  if ((num_pids = FillPidList(service, &rec_pids)) > 0)
620  {
621  /* Set or update the PIDs to be recorded */
622  if (update)
623  {
624  STB_PVRUpdateRecordingPids(path, num_pids, rec_pids);
625  }
626  else
627  {
628  STB_PVRSetRecordingPids(path, num_pids, rec_pids);
629 
630  /* Set the IDs for the service being recorded */
631  t_ptr = ADB_GetServiceTransportPtr(service);
632  if (t_ptr != NULL)
633  {
634  serv_id = ADB_GetServiceId(service);
635  ts_id = ADB_GetTransportTid(t_ptr);
636  onet_id = ADB_GetTransportOriginalNetworkId(t_ptr);
637 
638  STB_PVRSetRecoringTriplet(path, serv_id, ts_id, onet_id);
639  }
640  }
641 
642  STB_AppFreeMemory(rec_pids);
643  }
644 
645  FUNCTION_FINISH(SetupForRecording);
646 }
647 
648 //---global function definitions-----------------------------------------------
649 
653 void APVR_Initialise(void)
654 {
655 #ifdef COMMON_INTERFACE
656  U8BIT i;
657  U8BIT num_paths;
658 #endif
659 
660  FUNCTION_START(APVR_Initialise);
661 
662  inc_speed = TRUE;
663 
664  paused_recording = 0;
665  paused_disk_id = INVALID_DISK_ID;
666  timeshift_buffer_size = (U16BIT)APP_NvmRead(TIMESHIFT_BUFFER_SIZE_NVM);
667 
668  tuned_service_ptr = NULL;
669 
670  is_trick_mode_mute_on = FALSE;
671  trick_mode_copy_volume_value = 0;
672 
673  encrypt_recordings = FALSE;
674 
675  playback_path = INVALID_RES_ID;
676 
677  eit_update_queue = STB_OSCreateQueue(sizeof(U8BIT), 5);
678  if (eit_update_queue != NULL)
679  {
680  process_crids_task = STB_OSCreateTask(EitUpdatedTask, eit_update_queue, 4096, 7, (U8BIT *)"ProcessCrids");
681  }
682 
683  /* Load and import recordings */
685 
686 #ifdef COMMON_INTERFACE
687  num_paths = STB_DPGetNumPaths();
688 
689  if ((cam_record_start_timer = (U32BIT *)STB_AppGetMemory(num_paths * sizeof(U32BIT))) != NULL)
690  {
691  for (i = 0; i < num_paths; i++)
692  {
693  cam_record_start_timer[i] = INVALID_TIMER_HANDLE;
694  }
695  }
696 #endif
697 
698  DBG_PVR(("APVR_Initialise: done"));
699 
700  FUNCTION_FINISH(APVR_Initialise);
701 }
702 
706 void APVR_Terminate(void)
707 {
708  U8BIT q_msg = 0xFF;
709  FUNCTION_START(APVR_Terminate);
710 
711  if (eit_update_queue != NULL)
712  {
713  if (process_crids_task)
714  {
715  do
716  {
717  STB_OSWriteQueue(eit_update_queue, (void *)&q_msg, sizeof(q_msg), TIMEOUT_NOW);
718  STB_OSTaskDelay(8);
719  }
720  while (eit_update_queue != NULL);
721  STB_OSTaskDelay(8);
722  STB_OSDestroyTask( process_crids_task );
723  process_crids_task = 0;
724  }
725  }
726 
727 #ifdef COMMON_INTERFACE
728  if (cam_record_start_timer != NULL)
729  {
730  STB_AppFreeMemory(cam_record_start_timer);
731  }
732 #endif
733 
734  FUNCTION_FINISH(APVR_Terminate);
735 }
736 
741 BOOLEAN APVR_IsInitialised(void)
742 {
743  BOOLEAN initialised_ok;
744 
745  FUNCTION_START(APVR_IsInitialised);
746 
747  initialised_ok = STB_PVRIsInitialised();
748 
749  FUNCTION_FINISH(APVR_IsInitialised);
750 
751  return(initialised_ok);
752 }
753 
762 void APVR_SetNotifyTime(U16BIT notify_time)
763 {
764  FUNCTION_START(APVR_SetNotifyTime);
765 
766  APP_NvmSave(PVR_NOTIFY_TIME_NVM, (U32BIT)notify_time, TRUE);
767 
768  FUNCTION_FINISH(APVR_SetNotifyTime);
769 }
770 
775 U16BIT APVR_GetNotifyTime(void)
776 {
777  FUNCTION_START(APVR_GetNotifyTime);
778  FUNCTION_FINISH(APVR_GetNotifyTime);
779  return((U16BIT)APP_NvmRead(PVR_NOTIFY_TIME_NVM));
780 }
781 
788 void APVR_SetStartPadding(S32BIT padding)
789 {
790  FUNCTION_START(APVR_SetStartPadding);
791 
792  APP_NvmSave(RECORD_START_PADDING_NVM, (U32BIT)padding, TRUE);
793 
794  FUNCTION_FINISH(APVR_SetStartPadding);
795 }
796 
803 void APVR_SetEndPadding(S32BIT padding)
804 {
805  FUNCTION_START(APVR_SetEndPadding);
806 
807  APP_NvmSave(RECORD_END_PADDING_NVM, (U32BIT)padding, TRUE);
808 
809  FUNCTION_FINISH(APVR_SetEndPadding);
810 }
811 
817 {
818  FUNCTION_START(APVR_GetStartPadding);
819  FUNCTION_FINISH(APVR_GetStartPadding);
820  return((S32BIT)APP_NvmRead(RECORD_START_PADDING_NVM));
821 }
822 
827 S32BIT APVR_GetEndPadding(void)
828 {
829  FUNCTION_START(APVR_GetEndPadding);
830  FUNCTION_FINISH(APVR_GetEndPadding);
831  return((S32BIT)APP_NvmRead(RECORD_END_PADDING_NVM));
832 }
833 
834 // ----play list----
835 
853 U16BIT APVR_GetPlayList(U32BIT **handle_list, U8BIT ***name_list, U32BIT **rec_status_list,
854  U32BIT **locked_list, U32BIT **selected_list, U32BIT **split_list)
855 {
856  U16BIT list_size;
857  U16BIT index;
858  U32BIT handle;
859  U8BIT *crid;
860 
861  FUNCTION_START(APVR_GetPlayList);
862 
863  list_size = STB_PVRGetRecordingHandles(handle_list);
864  if (list_size > 0)
865  {
866  /* If timeshift is in progress then the list will contain the recording for this as well,
867  * so remove it if it's present */
868  for (index = 0; index < list_size; index++)
869  {
870  if ((*handle_list)[index] == paused_recording)
871  {
872  /* Remove the timeshift recording from the list by moving all remaining items down 1 */
873  for (index++; index < list_size; index++)
874  {
875  (*handle_list)[index-1] = (*handle_list)[index];
876  }
877  list_size--;
878  break;
879  }
880  }
881 
882  *name_list = (U8BIT **)STB_AppGetMemory(list_size * sizeof(U8BIT*));
883  *rec_status_list = (U32BIT *)STB_AppGetMemory(list_size * sizeof(U32BIT));
884  *locked_list = (U32BIT *)STB_AppGetMemory(list_size * sizeof(U32BIT));
885  *selected_list = (U32BIT *)STB_AppGetMemory(list_size * sizeof(U32BIT));
886  *split_list = (U32BIT *)STB_AppGetMemory(list_size * sizeof(U32BIT));
887 
888  if ((*name_list != NULL) && (*rec_status_list != NULL) &&
889  (*locked_list != NULL) && (*selected_list != NULL) &&
890  (*split_list != NULL))
891  {
892  /* Copy each value into the arrays */
893  for (index = 0; index < list_size; index++)
894  {
895  handle = (*handle_list)[index];
896 
897  (*name_list)[index] = STB_PVRRecordingGetName(handle);
898  (*rec_status_list)[index] = (U32BIT)STB_PVRIsBeingRecorded(handle);
899  (*locked_list)[index] = (U32BIT)STB_PVRRecordingGetLocked(handle);
900  (*selected_list)[index] = (U32BIT)STB_PVRRecordingGetSelected(handle);
901 
902  crid = (U8BIT *)STB_AppGetMemory(CRID_MAX_SIZE);
903  if (crid != NULL)
904  {
905  if (STB_PVRRecordingGetCrid(handle, crid, CRID_MAX_SIZE))
906  {
907  (*split_list)[index] = (U32BIT)ADB_IsSplitProgrammeCrid(crid);
908  }
909  else
910  {
911  (*split_list)[index] = FALSE;
912  }
913  STB_AppFreeMemory(crid);
914  }
915  }
916  }
917  else
918  {
919  STB_PVRReleaseRecordingHandles(*handle_list);
920  *handle_list = NULL;
921 
922  if (*name_list != NULL)
923  {
924  STB_AppFreeMemory(*name_list);
925  *name_list = NULL;
926  }
927 
928  if (*rec_status_list != NULL)
929  {
930  STB_AppFreeMemory(*rec_status_list);
931  *rec_status_list = NULL;
932  }
933 
934  if (*locked_list != NULL)
935  {
936  STB_AppFreeMemory(*locked_list);
937  *locked_list = NULL;
938  }
939 
940  if (*selected_list != NULL)
941  {
942  STB_AppFreeMemory(*selected_list);
943  *selected_list = NULL;
944  }
945 
946  if (*split_list != NULL)
947  {
948  STB_AppFreeMemory(*split_list);
949  *split_list = NULL;
950  }
951 
952  list_size = 0;
953  }
954  }
955  else
956  {
957  *handle_list = NULL;
958  *name_list = NULL;
959  *rec_status_list = NULL;
960  *locked_list = NULL;
961  *selected_list = NULL;
962  *split_list = NULL;
963  }
964 
965  FUNCTION_FINISH(APVR_GetPlayList);
966 
967  return(list_size);
968 }
969 
978 void APVR_ReleasePlayList(U32BIT *handle_list, U8BIT **name_list, U32BIT *rec_status_list,
979  U32BIT *locked_list, U32BIT *selected_list, U32BIT *split_list)
980 {
981  FUNCTION_START(APVR_ReleasePlayList);
982 
983  if (handle_list != NULL)
984  {
985  STB_PVRReleaseRecordingHandles(handle_list);
986  }
987 
988  if (name_list != NULL)
989  {
990  STB_AppFreeMemory(name_list);
991  }
992 
993  if (rec_status_list != NULL)
994  {
995  STB_AppFreeMemory(rec_status_list);
996  }
997 
998  if (locked_list != NULL)
999  {
1000  STB_AppFreeMemory(locked_list);
1001  }
1002 
1003  if (selected_list != NULL)
1004  {
1005  STB_AppFreeMemory(selected_list);
1006  }
1007 
1008  if (split_list != NULL)
1009  {
1010  STB_AppFreeMemory(split_list);
1011  }
1012 
1013  FUNCTION_FINISH(APVR_ReleasePlayList);
1014 }
1015 
1016 // ----playing----
1017 
1031 BOOLEAN APVR_PlayRecording(U32BIT recording_handle, BOOLEAN resume_playback, void *monitor_service)
1032 {
1033  BOOLEAN playback_started;
1034  U8BIT path;
1035  U16BIT serv_id, ts_id, orig_net_id;
1036 
1037  FUNCTION_START(APVR_PlayRecording);
1038 
1039  playback_started = FALSE;
1040 
1041  APP_PRINT_PVR_PLAY_TUNE(("APVR_PlayRecording(0x%lx, resume=%u, monitor_service=%p)",
1042  recording_handle, resume_playback, monitor_service));
1043 
1044  if (STB_PVRIsValidHandle(recording_handle))
1045  {
1046  playback_started = TRUE;
1047  path = STB_DPGetLivePath();
1048 
1049  if (monitor_service == NULL)
1050  {
1051  if (path != INVALID_RES_ID)
1052  {
1053  monitor_service = ADB_GetTunedService(path);
1054 
1055  /* This is the service to return to when playback is stopped */
1056  tuned_service_ptr = monitor_service;
1057  }
1058  else
1059  {
1060  tuned_service_ptr = NULL;
1061  }
1062  }
1063  else if (path != INVALID_RES_ID)
1064  {
1065  /* This is the service to return to when playback is stopped */
1066  tuned_service_ptr = ADB_GetTunedService(path);
1067  }
1068 
1069  APP_PRINT_PVR_PLAY_TUNE(("APVR_PlayRecording: tuned_service_ptr = Ox%x", tuned_service_ptr));
1070 
1071  if (path != INVALID_RES_ID)
1072  {
1073  /* Stop the live path so playback can be started */
1074  ACTL_TuneOff(path);
1075  STB_DPReleasePath(path, RES_OWNER_NONE);
1076  }
1077 
1078  if (playback_path == INVALID_RES_ID)
1079  {
1080  /* Acquire a path to play back the recording */
1081  STB_PVRRecordingGetTriplet(recording_handle, &serv_id, &ts_id, &orig_net_id);
1082  playback_service = CreatePlaybackService(serv_id);
1083  playback_path = STB_DPAcquirePlaybackPath((void *)playback_service);
1084  APP_PRINT_PVR_PLAY_TUNE(("Acquired playback path %u", playback_path));
1085  }
1086 
1087  if (playback_path != INVALID_RES_ID)
1088  {
1089  /* set decoder source */
1090  STB_PVRStartPlayRunning(playback_path);
1091 
1092  playback_handle = recording_handle;
1093 
1094  playback_started = STB_PVRStartPlaying(playback_path, recording_handle, resume_playback);
1095  if (playback_started)
1096  {
1097  ACTL_StartDecoding(playback_path, playback_service);
1098  // STB_AVBlankVideo(0, FALSE);
1099 
1100  APP_PRINT_PVR_PLAY_TUNE(("Setting APP_SI_MODE_UPDATE on playback path %u", playback_path));
1101  ASI_SetAppSiMode(playback_path, APP_SI_MODE_UPDATE);
1102  STB_DPSetSearchMode(playback_path, FALSE);
1103  STB_DPStartSI(playback_path);
1104 
1105  if (monitor_service != NULL)
1106  {
1107  /* Acquire a new path to monitor SI data */
1108  monitor_si_path = ACTL_AcquirePathForService(monitor_service, FALSE, FALSE, NULL);
1109  APP_PRINT_PVR_PLAY_TUNE(("Path for monitoring SI data=%u", monitor_si_path));
1110  if (monitor_si_path != INVALID_RES_ID)
1111  {
1112  ACTL_TuneToService(monitor_si_path, NULL, monitor_service, TRUE, FALSE);
1113  }
1114  }
1115  }
1116  else
1117  {
1118  playback_handle = 0;
1119 
1120  STB_DPReleasePath(playback_path, RES_OWNER_NONE);
1121  playback_path = INVALID_RES_ID;
1122 
1123  FreePlaybackService(playback_service);
1124  playback_service = NULL;
1125 
1126  /* Return to viewing the previous service */
1127  if (tuned_service_ptr != NULL)
1128  {
1129  ACTL_TuneToService(INVALID_RES_ID, NULL, tuned_service_ptr, FALSE, TRUE);
1130  tuned_service_ptr = NULL;
1131  }
1132  }
1133  }
1134  }
1135 
1136  FUNCTION_FINISH(APVR_PlayRecording);
1137 
1138  return(playback_started);
1139 }
1140 
1146 {
1147  FUNCTION_START(APVR_GetPlaybackHandle);
1148  FUNCTION_FINISH(APVR_GetPlaybackHandle);
1149  return(playback_handle);
1150 }
1151 
1156 BOOLEAN APVR_IsDecodingFile(void)
1157 {
1158  BOOLEAN is_playing_file;
1159  U8BIT path;
1160  U32BIT recording_handle;
1161 
1162  FUNCTION_START(APVR_IsDecodingFile);
1163 
1164  is_playing_file = FALSE;
1165 
1166  if (playback_path != INVALID_RES_ID)
1167  {
1168  path = playback_path;
1169  }
1170  else
1171  {
1172  path = STB_DPGetLivePath();
1173  }
1174 
1175  if (path != INVALID_RES_ID)
1176  {
1177  if (STB_PVRIsPlaying(path, &recording_handle) == TRUE)
1178  {
1179  is_playing_file = TRUE;
1180  APP_PRINT_PVR_PLAY_STATUS(("APVR_IsDecodingFile: STB_PVRIsPlaying(%u,...) returned TRUE", path));
1181  }
1182  else
1183  {
1184  APP_PRINT_PVR_PLAY_STATUS(("APVR_IsDecodingFile: STB_PVRIsPlaying(%u,...) returned FALSE", path));
1185  }
1186  }
1187 
1188  FUNCTION_FINISH(APVR_IsDecodingFile);
1189 
1190  return(is_playing_file);
1191 }
1192 
1197 BOOLEAN APVR_IsPlaying(void)
1198 {
1199  BOOLEAN is_playing;
1200 
1201  FUNCTION_START(APVR_IsPlaying);
1202 
1203  is_playing = FALSE;
1204 
1205  if (playback_path != INVALID_RES_ID)
1206  {
1207  if (STB_PVRIsPlayAudio(playback_path))
1208  {
1209  is_playing = TRUE;
1210  }
1211  }
1212 
1213  FUNCTION_FINISH(APVR_IsPlaying);
1214 
1215  return(is_playing);
1216 }
1217 
1227 BOOLEAN APVR_GetPlaybackElapsedTime(U32BIT handle, U8BIT *hours, U8BIT *mins, U8BIT *secs, U8BIT *progress)
1228 {
1229  BOOLEAN retval;
1230  U8BIT path;
1231  U8BIT audio_decoder, video_decoder;
1232  U32BIT space_used;
1233  U8BIT length_hour;
1234  U8BIT length_min;
1235  U8BIT length_sec;
1236 
1237  FUNCTION_START(APVR_GetPlaybackElapsedTime);
1238 
1239  retval = FALSE;
1240 
1241  path = APVR_GetPlaybackPath();
1242  if (path != INVALID_RES_ID)
1243  {
1244  audio_decoder = STB_DPGetPathAudioDecoder(path);
1245  video_decoder = STB_DPGetPathVideoDecoder(path);
1246 
1247  if ((audio_decoder == INVALID_RES_ID) ||
1248  !STB_PVRGetElapsedTime(audio_decoder, video_decoder, hours, mins, secs))
1249  {
1250  *hours = 0;
1251  *mins = 0;
1252  *secs = 0;
1253  }
1254  else
1255  {
1256  if (STB_PVRRecordingGetLength(handle, &length_hour, &length_min, &length_sec, &space_used))
1257  {
1258  if ((length_hour > 0) || (length_min > 0) || (length_sec > 0))
1259  {
1260  /* Calculate the progress as a percentage */
1261  *progress = ((*hours * 3600 + *mins * 60 + *secs) * 100) /
1262  (length_hour * 3600 + length_min * 60 + length_sec);
1263  }
1264  else
1265  {
1266  *progress = 0;
1267  }
1268 
1269  retval = TRUE;
1270  }
1271  }
1272  }
1273 
1274  FUNCTION_FINISH(APVR_GetPlaybackElapsedTime);
1275 
1276  return(retval);
1277 }
1278 
1284 {
1285  FUNCTION_START(APVR_NormalPlay);
1286 
1287  if (playback_path != INVALID_RES_ID)
1288  {
1290 
1291  // set to increment speed for FF
1292  inc_speed = TRUE;
1293  STB_PVRPlayNormal(playback_path);
1294  APP_PRINT_PVR_PLAY_STATUS(("Normal Play"));
1295  }
1296 
1297  FUNCTION_FINISH(APVR_NormalPlay);
1298 }
1299 
1304 void APVR_StopPlay(BOOLEAN return_to_live)
1305 {
1306  U32BIT recording_handle;
1307  U8BIT path;
1308 
1309  FUNCTION_START(APVR_StopPlay);
1310 
1312 
1313  APP_PRINT_PVR_PLAY_TUNE(("Stop Play: recording 0x%x", recording_handle));
1314 
1315  /* Stop playback and release the decoder being used */
1316  if (playback_path != INVALID_RES_ID)
1317  {
1318  /* Stop the SI whether the pvr is playing or not, as this function is called also after EOF,
1319  if the user goes back to live */
1320  STB_DPStopSI(playback_path);
1321 
1322  STB_PVRSavePlayPosition(playback_path);
1323 
1324  /* If playback is in progress then stop it */
1325  ACTL_DecodeOff(playback_path);
1326  if (STB_PVRIsPlaying(playback_path, &recording_handle) == TRUE)
1327  {
1328  STB_PVRStopPlaying(playback_path);
1329  }
1330 
1331  STB_DPReleasePath(playback_path, RES_OWNER_NONE);
1332  playback_path = INVALID_RES_ID;
1333 
1334  FreePlaybackService(playback_service);
1335  playback_service = NULL;
1336  }
1337 
1338  if (monitor_si_path != INVALID_RES_ID)
1339  {
1340  ACTL_TuneOff(monitor_si_path);
1341  STB_DPReleasePath(monitor_si_path, RES_OWNER_NONE);
1342  monitor_si_path = INVALID_RES_ID;
1343  }
1344 
1345  STB_AVBlankVideo(0, TRUE);
1346 
1347  if (return_to_live)
1348  {
1349  if (tuned_service_ptr != NULL)
1350  {
1351  if (!ACTL_CanServiceBeViewed(tuned_service_ptr))
1352  {
1353  /* All tuners are being used and the service being watched when playback was started
1354  * can no longer be tuned to, so need to tune to one that can */
1355  tuned_service_ptr = NULL;
1356  for (path = 0; (path < STB_DPGetNumPaths()) && (tuned_service_ptr == NULL); path++)
1357  {
1358  tuned_service_ptr = ADB_GetTunedService(path);
1359  }
1360  }
1361 
1362  APP_PRINT_PVR_PLAY_TUNE(("APVR_StopPlay: returning to service = Ox%x", tuned_service_ptr));
1363  if (tuned_service_ptr != NULL)
1364  {
1365  ACTL_TuneToService(INVALID_RES_ID, NULL, tuned_service_ptr, FALSE, TRUE);
1366  tuned_service_ptr = NULL;
1367  }
1368  }
1369  }
1370 
1371  FUNCTION_FINISH(APVR_StopPlay);
1372 }
1373 
1377 void APVR_PausePlay(void)
1378 {
1379  U8BIT path;
1380 
1381  FUNCTION_START(APVR_PausePlay);
1382 
1383  if (playback_path != INVALID_RES_ID)
1384  {
1385  path = playback_path;
1386  }
1387  else
1388  {
1389  path = STB_DPGetLivePath();
1390  }
1391 
1392  if (path != INVALID_RES_ID)
1393  {
1394  if (STB_PVRIsPlayPause(path) == TRUE)
1395  {
1396  APP_PRINT_PVR_PLAY_STATUS(("Pause Play(%d): already paused so FrameInc", path));
1397  STB_PVRPlayFrameInc(path);
1398  }
1399  else
1400  {
1401  APP_PRINT_PVR_PLAY_STATUS(("Pause Play(%d): ", path));
1402  STB_PVRPlayPause(path);
1403  }
1404  }
1405 
1406  FUNCTION_FINISH(APVR_PausePlay);
1407 }
1408 
1415 void APVR_FFPlay(void)
1416 {
1417  S16BIT play_speed;
1418  U8BIT path;
1419 
1420  FUNCTION_START(APVR_FFPlay);
1421 
1422  if (playback_path != INVALID_RES_ID)
1423  {
1424  path = playback_path;
1425  }
1426  else
1427  {
1428  path = STB_DPGetLivePath();
1429  }
1430 
1431  if (path != INVALID_RES_ID)
1432  {
1434 
1435  if (STB_PVRIsPlayPause(path) == TRUE)
1436  {
1437  APP_PRINT_PVR_PLAY_STATUS(("Fast Forward(%d): Paused so go into slow motion play", path));
1438  STB_PVRPlayFaster(path, TRUE);
1439  }
1440  else
1441  {
1443 
1444  if ((play_speed >= PVR_NORMAL_PLAY_SPEED) ||
1445  (play_speed <= -PVR_NORMAL_PLAY_SPEED))
1446  {
1447  APP_PRINT_PVR_PLAY_STATUS(("Fast Forward(%d): Not slow motion, play faster", path));
1448  STB_PVRPlayFaster(path, FALSE);
1449  }
1450  else
1451  {
1452  /* Playback in slow motion so allow slow motion speeds */
1453  APP_PRINT_PVR_PLAY_STATUS(("Fast Forward(%d): Slow motion, play faster", path));
1454  STB_PVRPlayFaster(path, TRUE);
1455  }
1456  }
1457  }
1458 
1459  FUNCTION_FINISH(APVR_FFPlay);
1460 }
1461 
1468 void APVR_FRPlay(void)
1469 {
1470  S16BIT play_speed;
1471  U8BIT path;
1472 
1473  FUNCTION_START(APVR_FRPlay);
1474 
1475  if (playback_path != INVALID_RES_ID)
1476  {
1477  path = playback_path;
1478  }
1479  else
1480  {
1481  path = STB_DPGetLivePath();
1482  }
1483 
1484  if (path != INVALID_RES_ID)
1485  {
1487 
1488  if (STB_PVRIsPlayPause(path) == TRUE)
1489  {
1490  APP_PRINT_PVR_PLAY_STATUS(("Fast Rewind(%d): Paused so go into slow motion play", path));
1491  STB_PVRPlaySlower(path, TRUE);
1492  }
1493  else
1494  {
1496  APP_PRINT_PVR_PLAY_STATUS(("Fast Rewind(%d): speed=%d", play_speed));
1497 
1498  if ((play_speed >= PVR_NORMAL_PLAY_SPEED) ||
1499  (play_speed <= -PVR_NORMAL_PLAY_SPEED))
1500  {
1501  APP_PRINT_PVR_PLAY_STATUS(("Fast Rewind(%d): Not slow motion, play slower", path));
1502  STB_PVRPlaySlower(path, FALSE);
1503  }
1504  else
1505  {
1506  /* Playback in slow motion so allow slow motion speeds */
1507  APP_PRINT_PVR_PLAY_STATUS(("Fast Rewind(%d): Slow motion, play slower", path));
1508  STB_PVRPlaySlower(path, TRUE);
1509  }
1510  }
1511  }
1512 
1513  FUNCTION_FINISH(APVR_FRPlay);
1514 }
1515 
1520 {
1521  U8BIT path;
1522 
1523  FUNCTION_START(APVR_SlowMoPlay);
1524 
1525  if (playback_path != INVALID_RES_ID)
1526  {
1527  path = playback_path;
1528  }
1529  else
1530  {
1531  path = STB_DPGetLivePath();
1532  }
1533 
1534  if (path != INVALID_RES_ID)
1535  {
1537 
1538  if (inc_speed == TRUE)
1539  {
1540  APP_PRINT_PVR_PLAY_STATUS(("Slow Motion(%d): play medium and inc_speed = FALSE", path));
1541  STB_PVRPlayMedium(path);
1542  inc_speed = FALSE;
1543  }
1544 
1545  if (STB_PVRIsPlayForward(path))
1546  {
1547  APP_PRINT_PVR_PLAY_STATUS(("Slow Motion(%d): APVR_FFPlay()", path));
1548  APVR_FFPlay();
1549  }
1550  else
1551  {
1552  APP_PRINT_PVR_PLAY_STATUS(("Slow Motion(%d): APVR_FRPlay()", path));
1553  APVR_FRPlay();
1554  }
1555  }
1556 
1557  FUNCTION_FINISH(APVR_SlowMoPlay);
1558 }
1559 
1571 void APVR_QRPlay(void)
1572 {
1573  FUNCTION_START(APVR_QRPlay);
1574 
1575  // TBD this function requires further work on STB layer
1576  APP_PRINT_PVR_PLAY_STATUS(("Quick Replay: TBD - so do nothing"));
1577 
1578  FUNCTION_FINISH(APVR_QRPlay);
1579 }
1580 
1592 void APVR_JTLPlay(void)
1593 {
1594  FUNCTION_START(APVR_JTLPlay);
1595 
1596  // TBD this function requires further work on STB layer
1597  APP_PRINT_PVR_PLAY_STATUS(("Jump To Live: TBD so do nothing"));
1598 
1599  FUNCTION_FINISH(APVR_JTLPlay);
1600 }
1601 
1606 E_PVR_PLAY_STATUS APVR_GetPlayMode(void)
1607 {
1608  U8BIT audio_decoder, video_decoder;
1609  E_PVR_PLAY_STATUS play_mode;
1610  S16BIT play_speed;
1611  U8BIT path;
1612 
1613  FUNCTION_START(APVR_GetPlayMode);
1614 
1615  play_mode = PVR_PLAY_STATUS_NULL;
1616 
1617  if (playback_path != INVALID_RES_ID)
1618  {
1619  path = playback_path;
1620  }
1621  else
1622  {
1623  path = STB_DPGetLivePath();
1624  }
1625 
1626  if (path != INVALID_RES_ID)
1627  {
1628  audio_decoder = STB_DPGetPathAudioDecoder(path);
1629  video_decoder = STB_DPGetPathVideoDecoder(path);
1630 
1631  if (STB_PVRIsPlayStarted(audio_decoder, video_decoder))
1632  {
1634 
1635  if (play_speed == 100)
1636  {
1637  play_mode = PVR_PLAY_STATUS_NORMAL;
1638  }
1639  else if (play_speed > PVR_NORMAL_PLAY_SPEED)
1640  {
1641  play_mode = PVR_PLAY_STATUS_FF;
1642  }
1643  else if (play_speed < -PVR_NORMAL_PLAY_SPEED)
1644  {
1645  play_mode = PVR_PLAY_STATUS_FR;
1646  }
1647  else if ((play_speed > 0) && (play_speed < PVR_NORMAL_PLAY_SPEED))
1648  {
1649  play_mode = PVR_PLAY_STATUS_SF;
1650  }
1651  else if ((play_speed < 0) && (play_speed > -PVR_NORMAL_PLAY_SPEED))
1652  {
1653  play_mode = PVR_PLAY_STATUS_SR;
1654  }
1655  else if (play_speed == 0)
1656  {
1657  play_mode = PVR_PLAY_STATUS_PAUSE;
1658  }
1659  }
1660  else
1661  {
1662  play_mode = PVR_PLAY_STATUS_STOP;
1663  }
1664  }
1665 
1666  FUNCTION_FINISH(APVR_GetPlayMode);
1667 
1668  return(play_mode);
1669 }
1670 
1676 S16BIT APVR_GetPlaySpeed(void)
1677 {
1678  S16BIT play_speed;
1679  U8BIT path;
1680 
1681  FUNCTION_START(APVR_GetPlaySpeed);
1682 
1683  play_speed = 0;
1684 
1685  if (playback_path != INVALID_RES_ID)
1686  {
1687  path = playback_path;
1688  }
1689  else
1690  {
1691  path = STB_DPGetLivePath();
1692  }
1693 
1694  if (path != INVALID_RES_ID)
1695  {
1697  }
1698 
1699  FUNCTION_FINISH(APVR_GetPlaySpeed);
1700 
1701  return(play_speed);
1702 }
1703 
1710 BOOLEAN APVR_SetPlaySpeed(S16BIT speed)
1711 {
1712  BOOLEAN result;
1713 
1714  FUNCTION_START(APVR_SetPlaySpeed);
1715 
1716  if (playback_path != INVALID_RES_ID)
1717  {
1718  result = STB_PVRSetPlaySpeed(STB_DPGetPathAudioDecoder(playback_path),
1719  STB_DPGetPathVideoDecoder(playback_path), speed);
1720 #ifdef INTEGRATE_HBBTV
1721  if (result)
1722  {
1724  }
1725 #endif
1726  }
1727  else
1728  {
1729  result = FALSE;
1730  }
1731 
1732  FUNCTION_FINISH(APVR_SetPlaySpeed);
1733  return result;
1734 }
1735 
1740 {
1741  U8BIT audio_decoder;
1742 
1743  FUNCTION_START(APVR_TrickModeMuteOn);
1744 
1745  if (!is_trick_mode_mute_on && (playback_path != INVALID_RES_ID))
1746  {
1747  audio_decoder = STB_DPGetPathAudioDecoder(playback_path);
1748  if (audio_decoder != INVALID_RES_ID)
1749  {
1750  is_trick_mode_mute_on = TRUE;
1751  trick_mode_copy_volume_value = STB_AVGetAudioVolume(audio_decoder);
1752  STB_AVSetAudioVolume(audio_decoder, ((trick_mode_copy_volume_value * 3) / 4));
1753  }
1754  }
1755 
1756  FUNCTION_FINISH(APVR_TrickModeMuteOn);
1757 }
1758 
1763 {
1764  U8BIT audio_decoder;
1765 
1766  FUNCTION_START(APVR_TrickModeMuteOff);
1767 
1768  if (is_trick_mode_mute_on && (playback_path != INVALID_RES_ID))
1769  {
1770  audio_decoder = STB_DPGetPathAudioDecoder(playback_path);
1771  if (audio_decoder != INVALID_RES_ID)
1772  {
1773  is_trick_mode_mute_on = FALSE;
1774  STB_AVSetAudioVolume(audio_decoder, trick_mode_copy_volume_value);
1775  trick_mode_copy_volume_value = 0;
1776  }
1777  }
1778 
1779  FUNCTION_FINISH(APVR_TrickModeMuteOff);
1780 }
1781 
1782 // ---- recording ----
1783 
1793 U8BIT APVR_PrepareNewRecording(U16BIT onet_id, U16BIT trans_id, U16BIT service_id, BOOLEAN *new_tuned_service)
1794 {
1795  U8BIT path;
1796  void *s_ptr;
1797  S_ACTL_OWNER_INFO owner_info;
1798 
1799  FUNCTION_START(APVR_PrepareNewRecording);
1800 
1801  path = INVALID_RES_ID;
1802  *new_tuned_service = FALSE;
1803 
1804  s_ptr = ADB_FindServiceByIds(onet_id, trans_id, service_id);
1805 
1806  APP_PRINT_PVR_REC(("APVR_PrepareNewRecording(onet=0x%04x, tid=0x%04x, sid=0x%04x): preparing recording on service %p",
1807  onet_id, trans_id, service_id, s_ptr));
1808 
1809  if (s_ptr != NULL)
1810  {
1811  owner_info.owner = RES_OWNER_DVB;
1812  owner_info.data = NULL;
1813  owner_info.data_size = 0;
1814 
1815  if ((path = ACTL_TuneToService(INVALID_RES_ID, &owner_info, s_ptr, FALSE, FALSE)) != INVALID_RES_ID)
1816  {
1817  *new_tuned_service = !ACTL_IsTuned(path);
1818  }
1819  }
1820 
1821  FUNCTION_FINISH(APVR_PrepareNewRecording);
1822 
1823  return(path);
1824 }
1825 
1837 BOOLEAN APVR_StartNewRecording(U16BIT disk_id, U8BIT path, U8BIT *recording_name, U16BIT event_id,
1838  U8BIT *prog_crid, U8BIT *other_crid, U32BIT *rec_handle)
1839 {
1840  BOOLEAN recording_started_ok;
1841  void *service;
1842  void *event_ptr;
1843  U8BIT *guidance;
1844  U8BIT guidance_type;
1845  U8BIT guidance_mode;
1846  U8BIT *name;
1847 #ifdef COMMON_INTERFACE
1848  U8BIT slot_id;
1849  U16BIT service_id;
1850  U8BIT *pmt_data;
1851  U16BIT data_len;
1852  U8BIT uri[CIP_URI_LEN];
1853  S32BIT cam_pin;
1854  U8BIT pin_str[CIP_MAX_PIN_LENGTH + 1];
1855 #endif
1856 #if 0
1857  U8BIT *pvr_err_msg;
1858  U16BIT rec_date;
1859  U8BIT rec_hour, rec_min, rec_secs;
1860  BOOLEAN reverse;
1861 #endif
1862 
1863  FUNCTION_START(APVR_StartNewRecording);
1864 
1865  recording_started_ok = FALSE;
1866 
1867  // start a recording:
1868  if (recording_name == NULL)
1869  {
1870  APP_PRINT_PVR_REC(("APVR_StartNewRecording(%d): Start Record (name!)", path));
1871  }
1872  else
1873  {
1874  APP_PRINT_PVR_REC(("APVR_StartNewRecording(%d): Start Record (%s)", path, recording_name));
1875  }
1876 
1877  /* Can the disk be used for the recording? */
1878  if (!STB_PVRCanDiskBeUsed(disk_id))
1879  {
1880  /* Disk is no longer valid so use the default disk */
1881  disk_id = STB_PVRGetDefaultDisk();
1882  }
1883 
1884  if (STB_PVRCanDiskBeUsed(disk_id))
1885  {
1886  // create and start recording
1887  if (STB_PVRCreateRecording(disk_id, recording_name, rec_handle) == TRUE)
1888  {
1889  APP_PRINT_PVR_REC(("APVR_StartNewRecording: Create Recording"));
1890 
1891  /* Check whether the recording should be encrypted */
1892  service = ADB_GetTunedService(path);
1893  event_ptr = NULL;
1894 
1895  if ((event_id == 0) || ((event_ptr = ADB_GetEvent(service, event_id)) == NULL))
1896  {
1897  /* No event specified, so check the now event */
1898  ADB_GetNowNextEvents(service, &event_ptr, NULL);
1899  }
1900 
1901  if (!encrypt_recordings && (STB_DPGetPathCISlot(path) == INVALID_RES_ID))
1902  {
1903  /* Recording without a CI slot, so check the event or service to see
1904  * whether the recording should be encrypted */
1905  if (event_ptr != NULL)
1906  {
1907  if (!ADB_GetEventDoNotScramble(event_ptr))
1908  {
1909  DBG_PVR((">> This recording(event) needs to be encrypted\n"));
1910  /* Recording must be encrypted */
1911  STB_PVREncryptRecording(path, TRUE);
1912  }
1913  else
1914  {
1915  STB_PVREncryptRecording(path, FALSE);
1916  }
1917  }
1918  else
1919  {
1920  /* Check whether the service is protected */
1921  if (!ADB_GetServiceDoNotScramble(service))
1922  {
1923  DBG_PVR((">> This recording(service) needs to be encrypted\n"));
1924  /* Recording must be encrypted */
1925  STB_PVREncryptRecording(path, TRUE);
1926  }
1927  else
1928  {
1929  STB_PVREncryptRecording(path, FALSE);
1930  }
1931  }
1932  }
1933  else
1934  {
1935  /* Recording needs to be encrypted, which could be because a CI slot was acquired
1936  * for the recording */
1937  STB_PVREncryptRecording(path, TRUE);
1938  }
1939 
1940  /* Setup the PIDs, etc, that are to be recorded */
1941  if (service)
1942  {
1943  SetupForRecording(path, service, FALSE);
1944  }
1945 
1946  if (STB_DPStartRecording(path, *rec_handle))
1947  {
1948 #ifdef PVR_LOG
1949  LogDateTime();
1950  fprintf(pvr_log, "Start recording \"%s\", event id %u, path %u",
1951  recording_name, event_id, path);
1952 
1953  if (service != NULL)
1954  {
1955  name = ADB_GetServiceFullName(service, TRUE);
1956  fprintf(pvr_log, ", on %s", name);
1958  }
1959  if ((prog_crid != NULL) && (strlen((char *)prog_crid) > 0))
1960  {
1961  fprintf(pvr_log, ", crid=%s", (char *)prog_crid);
1962  }
1963  fprintf(pvr_log, ", handle=0x%08lx\n", *rec_handle);
1964  fflush(pvr_log);
1965 #endif
1966  APP_PRINT_PVR_REC(("APVR_StartNewRecording: recording 0x%x, \"%s\" started on path %d",
1967  *rec_handle, recording_name, path));
1968 
1969  recording_started_ok = TRUE;
1970 
1971  if (service != NULL)
1972  {
1973  /* Store the short service name with the recording */
1974  name = ADB_GetServiceFullName(service, FALSE);
1975  STB_PVRRecordingSetServiceName(*rec_handle, name);
1977 
1978  /* Set parental lock on the recording if the service is locked */
1980 
1981  if ((prog_crid != NULL) && (strlen((char *)prog_crid) > 0))
1982  {
1983  STB_PVRRecordingSetCrid(*rec_handle, prog_crid);
1984  }
1985 
1986  if ((other_crid != NULL) && (strlen((char *)other_crid) > 0))
1987  {
1988  STB_PVRRecordingSetOtherCrid(*rec_handle, other_crid);
1989  }
1990 
1991  if (event_ptr != NULL)
1992  {
1993  /* Set recording name to the name of the event if the recording name isn't given */
1994  if ((recording_name != NULL) && !STB_IsStringEmpty(recording_name))
1995  {
1996  STB_PVRRecordingSetName(*rec_handle, recording_name);
1997  }
1998  else
1999  {
2000  STB_PVRRecordingSetName(*rec_handle, ADB_GetEventName(event_ptr));
2001  }
2002 
2003  /* Find the event description and save it with the recording */
2005 
2007  ADB_GetEventExtendedDescription(event_ptr));
2008 
2009  /* Only save guidance if there is some for the event */
2010  guidance = ADB_GetEventGuidance(event_ptr, service, &guidance_type, &guidance_mode);
2011  if (guidance != NULL)
2012  {
2013  STB_PVRRecordingSetGuidance(*rec_handle, guidance);
2014  }
2015  }
2016 
2017 #ifdef COMMON_INTERFACE
2018  slot_id = STB_DPGetPathCISlot(path);
2019  if (slot_id != INVALID_RES_ID)
2020  {
2021  /* Need to ask CAM if the recording can proceed, so pause the recording
2022  * and resume it when a reply is received */
2023  if (STB_PVRPauseRecording(path))
2024  {
2025  service_id = ADB_GetServiceId(service);
2026 
2027  if (STB_CiCcAuthenticated(slot_id))
2028  {
2029  pmt_data = ADB_GetServicePMTData(service, &data_len);
2030  if (STB_CiCaSystemSupported(slot_id, pmt_data))
2031  {
2032  /* Service is scrambled, CAS supported and CAM is CI+, so
2033  * need to get the initial URI and store it with the recording */
2034  STB_CiCcGetUsageRulesInfo(slot_id, service_id, uri);
2035  STB_PVRRecordingAddURI(*rec_handle, uri);
2036  }
2037  }
2038 
2039  /* Get the pin for the slot */
2040  cam_pin = ACI_ReadPinForSlot(slot_id);
2041  if (cam_pin < 0)
2042  {
2043  /* There's no pin for the slot */
2044  pin_str[0] = '\0';
2045  }
2046  else
2047  {
2048  sprintf((char *)pin_str, "%lu", (unsigned long)cam_pin);
2049  }
2050 
2051  /* Start a timer that will stop the recording if the CAM doesn't respond */
2052  cam_record_start_timer[path] = NewCountdownTimer(10);
2053 
2054  if (!STB_CiCcSendRecordStart(slot_id, service_id, pin_str))
2055  {
2056  /* Failed to notify the CAM, so recording can't continue */
2057  ATMR_DeleteTimer(cam_record_start_timer[path]);
2058  cam_record_start_timer[path] = INVALID_TIMER_HANDLE;
2059 
2060  STB_PVRStopRecording(path);
2061  recording_started_ok = FALSE;
2062  }
2063  }
2064  else
2065  {
2066  /* Failed to pause recording so recording must not continue */
2067  STB_PVRStopRecording(path);
2068  recording_started_ok = FALSE;
2069  APP_PRINT_PVR_REC(("APVR_StartNewRecording: Failed to pause recording"));
2070  }
2071  }
2072 #endif
2073  }
2074 
2075  /* The SI is needed on the recording path too (it can be running already if we're starting a live recording */
2076  APP_PRINT_PVR_REC(("APVR_StartNewRecording: Setting APP_SI_MODE_UPDATE on record path %u", path));
2077  ASI_SetAppSiMode(path, APP_SI_MODE_UPDATE);
2078  STB_DPSetSearchMode(path, FALSE);
2079  STB_DPStartSI(path);
2080  }
2081  else
2082  {
2083 #ifdef PVR_LOG
2084  LogDateTime();
2085  fprintf(pvr_log, "Failed to start recording \"%s\", event id %u, path %u",
2086  recording_name, event_id, path);
2087  if (service != NULL)
2088  {
2089  name = ADB_GetServiceFullName(service, TRUE);
2090  fprintf(pvr_log, ", on %s", name);
2092  }
2093  fprintf(pvr_log, "\n");
2094  fflush(pvr_log);
2095 #endif
2096  APP_PRINT_PVR_REC(("APVR_StartNewRecording: failed to start recording 0x%x, \"%s\", path %d",
2097  *rec_handle, recording_name, path));
2098 
2099  STB_PVRDestroyRecording(*rec_handle);
2100  }
2101 
2102  if (event_ptr != NULL)
2103  {
2104  ADB_ReleaseEventData(event_ptr);
2105  }
2106 
2107  if (recording_started_ok)
2108  {
2109  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_PVR_RECORDING_STARTED,
2110  &path, sizeof(path));
2111  }
2112  }
2113  else
2114  {
2115  APP_PRINT_PVR_REC(("APVR_StartNewRecording: Failed to create recording"));
2116  }
2117  }
2118  else
2119  {
2120 #ifdef PVR_LOG
2121  LogDateTime();
2122  fprintf(pvr_log, "Failed to start recording \"%s\", event id %u, path %u, no disk",
2123  recording_name, event_id, path);
2124  fprintf(pvr_log, "\n");
2125  fflush(pvr_log);
2126 #endif
2127  APP_PRINT_PVR_REC(("APVR_StartNewRecording: No disk available to record onto"));
2128 
2129 #if 0
2130  STB_GCGetGMTDateTime(&rec_date, &rec_hour, &rec_min, &rec_secs);
2131 
2132  pvr_err_msg = STB_FormatUnicodeString(FALSE, &reverse,
2133  UI_GetString(STR_PVR_REC_FAIL_NO_DISK), recording_name,
2134  UI_GetString(days_of_week_str_ids[STB_GCGetDateWeekDay((U16BIT)rec_date)]),
2135  STB_GCGetDateString((U16BIT)rec_date, (U8BIT)rec_hour, (U8BIT)rec_min, DATE_DMY),
2136  STB_GCGetTimeString((U16BIT)rec_date, (U8BIT)rec_hour, (U8BIT)rec_min, TIME_24H));
2137 
2138  if (pvr_err_msg != NULL)
2139  {
2140  STB_PVRAddMessage(pvr_err_msg);
2141  STB_ReleaseUnicodeString(pvr_err_msg);
2142  }
2143 #endif
2144  }
2145 
2146  FUNCTION_FINISH(APVR_StartNewRecording);
2147 
2148  return(recording_started_ok);
2149 }
2150 
2156 BOOLEAN APVR_StopRecording(U32BIT recording_handle)
2157 {
2158  U8BIT path;
2159  BOOLEAN recording_stopped;
2160  U32BIT handle;
2161 #ifdef COMMON_INTERFACE
2162  U8BIT slot_id;
2163 #endif
2164 
2165  FUNCTION_START(APVR_StopRecording);
2166 
2167  recording_stopped = FALSE;
2168 
2169  /* Check whether the recording_handle is associated with any of the tuners */
2170  for (path = 0; path < STB_DPGetNumPaths(); path++)
2171  {
2172  if (STB_DPIsRecording(path, &handle) && (handle == recording_handle))
2173  {
2174 #ifdef COMMON_INTERFACE
2175  if ((slot_id = STB_DPGetPathCISlot(path)) != INVALID_RES_ID)
2176  {
2177  STB_CiCcSendRecordStop(slot_id);
2178  }
2179 #endif
2180 
2181  APP_PRINT_PVR_REC(("APVR_StopRecording: recording 0x%x is using path %d", recording_handle, path));
2182 
2183  if (!STB_DPIsLivePath(path))
2184  {
2185  STB_DPStopSI(path);
2186  }
2187 
2188  STB_DPStopRecording(path);
2189  ATMR_DeleteRecordingTimer(recording_handle);
2190 
2191  recording_stopped = TRUE;
2192 
2193  STB_DPReleasePath(path, RES_OWNER_DVB);
2194 
2195  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_PVR_RECORDING_STOPPED,
2196  &handle, sizeof(handle));
2197  break;
2198  }
2199  }
2200 
2201  FUNCTION_FINISH(APVR_StopRecording);
2202 
2203  return(recording_stopped);
2204 }
2205 
2213 U8BIT APVR_GetActiveRecordingList(U32BIT **handle_list)
2214 {
2215  U8BIT list_size = 0;
2216  U8BIT num_paths;
2217  U8BIT path;
2218  BOOLEAN is_recording;
2219  U32BIT recording_handle;
2220  U8BIT index;
2221 
2222  FUNCTION_START(APVR_GetActiveRecordingList);
2223 
2224  /* Calculate list_size */
2225  num_paths = STB_DPGetNumPaths();
2226  for (path = 0; path < num_paths; path++)
2227  {
2228  is_recording = STB_DPIsRecording(path, &recording_handle);
2229 
2230  if (is_recording == TRUE)
2231  {
2232  list_size++;
2233  }
2234  }
2235 
2236  if (list_size > 0)
2237  {
2238  *handle_list = (U32BIT *)STB_AppGetMemory(list_size * sizeof(U32BIT));
2239 
2240  if (*handle_list != NULL)
2241  {
2242  index = 0;
2243  for (path = 0; path < num_paths; path++)
2244  {
2245  is_recording = STB_DPIsRecording(path, &recording_handle);
2246 
2247  if (is_recording == TRUE)
2248  {
2249  if (index < list_size)
2250  {
2251  *handle_list[index] = recording_handle;
2252  }
2253  }
2254  }
2255  }
2256  else
2257  {
2258  list_size = 0;
2259  }
2260  }
2261  else
2262  {
2263  *handle_list = NULL;
2264  }
2265 
2266  FUNCTION_FINISH(APVR_GetActiveRecordingList);
2267 
2268  return(list_size);
2269 }
2270 
2275 void APVR_ReleaseActiveRecordingList(U32BIT *handle_list)
2276 {
2277  FUNCTION_START(PVR_ReleaseActiveRecordingList);
2278 
2279  if (handle_list != NULL)
2280  {
2281  STB_AppFreeMemory(handle_list);
2282  }
2283 
2284  FUNCTION_FINISH(APVR_ReleaseActiveRecordingList);
2285 }
2286 
2295 BOOLEAN APVR_GetPathRecordingName(U8BIT path, U8BIT **name_ptr)
2296 {
2297  BOOLEAN recording_list_ok;
2298 
2299  FUNCTION_START(APVR_GetPathRecordingName);
2300 
2301  recording_list_ok = GetRecording(path, name_ptr);
2302 
2303  if (recording_list_ok)
2304  {
2305  APP_PRINT_PVR_REC(("APVR_GetTunerRecordingName(%d): recording \"%s\" is playing", path, *name_ptr));
2306  }
2307 
2308  FUNCTION_FINISH(APVR_GetPathRecordingName);
2309 
2310  return(recording_list_ok);
2311 }
2312 
2320 BOOLEAN APVR_DeleteRecording(U32BIT handle)
2321 {
2322  BOOLEAN recording_deleted_ok;
2323 
2324  FUNCTION_START(APVR_DeleteRecording);
2325 
2326  if (!STB_PVRRecordingGetLocked(handle))
2327  {
2328  recording_deleted_ok = DestroyRecording(handle);
2329  }
2330  else
2331  {
2332  recording_deleted_ok = FALSE;
2333  }
2334 
2335  FUNCTION_FINISH(APVR_DeleteRecording);
2336 
2337  return(recording_deleted_ok);
2338 }
2339 
2348 BOOLEAN APVR_DeleteAllSelectedRecordings(U32BIT *handles, U16BIT num_handles)
2349 {
2350  BOOLEAN recording_deleted;
2351  U16BIT i;
2352 
2353  FUNCTION_START(APVR_DeleteAllSelectedRecordings);
2354 
2355  recording_deleted = FALSE;
2356 
2357  if ((handles != NULL) && (num_handles > 0))
2358  {
2359  for (i = 0; i < num_handles; i++)
2360  {
2361  if (STB_PVRRecordingGetSelected(handles[i]) && !STB_PVRRecordingGetLocked(handles[i]))
2362  {
2363  DestroyRecording(handles[i]);
2364  recording_deleted = TRUE;
2365  }
2366  }
2367  }
2368 
2369  FUNCTION_FINISH(APVR_DeleteAllSelectedRecordings);
2370 
2371  return(recording_deleted);
2372 }
2373 
2377 void APVR_UnselectAllRecordings(U32BIT *handles, U16BIT num_handles)
2378 {
2379  U16BIT i;
2380 
2381  FUNCTION_START(APVR_UnselectAllRecordings);
2382 
2383  if ((handles != NULL) && (num_handles > 0))
2384  {
2385  for (i = 0; i < num_handles; i++)
2386  {
2387  STB_PVRRecordingSetSelected(handles[i], FALSE);
2388  }
2389  }
2390 
2391  FUNCTION_FINISH(APVR_UnselectAllRecordings);
2392 }
2393 
2400 BOOLEAN APVR_AreSelectedRecordings(U32BIT *handles, U16BIT num_handles)
2401 {
2402  BOOLEAN recording_selected;
2403  U16BIT i;
2404 
2405  FUNCTION_START(APVR_AreSelectedRecordings);
2406 
2407  recording_selected = FALSE;
2408 
2409  if ((handles != NULL) && (num_handles > 0))
2410  {
2411  for (i = 0; (i < num_handles) && !recording_selected; i++)
2412  {
2413  recording_selected = STB_PVRRecordingGetSelected(handles[i]);
2414  }
2415  }
2416 
2417  FUNCTION_FINISH(APVR_AreSelectedRecordings);
2418 
2419  return(recording_selected);
2420 }
2421 
2422 // ----pause recording----
2423 
2431 void APVR_SetTimeshiftBufferSize(U16BIT time_in_mins)
2432 {
2433  FUNCTION_START(APVR_SetTimeshiftBufferSize);
2434  timeshift_buffer_size = time_in_mins;
2435  APP_NvmSave(TIMESHIFT_BUFFER_SIZE_NVM, time_in_mins, TRUE);
2436  FUNCTION_FINISH(APVR_SetTimeshiftBufferSize);
2437 }
2438 
2444 {
2445  FUNCTION_START(APVR_GetTimeshiftBufferSize);
2446  FUNCTION_FINISH(APVR_GetTimeshiftBufferSize);
2447  return((U16BIT)APP_NvmRead(TIMESHIFT_BUFFER_SIZE_NVM));
2448 }
2449 
2455 {
2456  BOOLEAN retval;
2457 
2458  FUNCTION_START(APVR_IsTimeshiftStarted);
2459 
2460  if ((pause_path != INVALID_RES_ID) && (playback_path != INVALID_RES_ID))
2461  {
2462  retval = TRUE;
2463  }
2464  else
2465  {
2466  retval = FALSE;
2467  }
2468 
2469  FUNCTION_FINISH(APVR_IsTimeshiftStarted);
2470 
2471  return(retval);
2472 }
2473 
2480 {
2481  BOOLEAN retval;
2482 
2483  FUNCTION_START(APVR_IsTimeshiftRecordingPath);
2484 
2485  if ((path != INVALID_RES_ID) && (pause_path == path))
2486  {
2487  retval = TRUE;
2488  }
2489  else
2490  {
2491  retval = FALSE;
2492  }
2493 
2494  FUNCTION_FINISH(APVR_IsTimeshiftRecordingPath);
2495 
2496  return(retval);
2497 }
2498 
2504 BOOLEAN APVR_IsTimeshiftRecording(U32BIT handle)
2505 {
2506  BOOLEAN retval;
2507 
2508  FUNCTION_START(APVR_IsTimeshiftRecording);
2509 
2510  if ((handle != STB_PVR_INVALID_HANDLE) && (paused_recording == handle))
2511  {
2512  retval = TRUE;
2513  }
2514  else
2515  {
2516  retval = FALSE;
2517  }
2518 
2519  FUNCTION_FINISH(APVR_IsTimeshiftRecording);
2520 
2521  return(retval);
2522 }
2523 
2532 {
2533  U8BIT live_path;
2534  void *serv_ptr;
2535  void *transport;
2536  U16BIT onet_id;
2537  U16BIT trans_id;
2538  U16BIT service_id;
2539  U16BIT disk_id;
2540  BOOLEAN new_tuned_service;
2541  BOOLEAN record_started;
2542 #ifdef COMMON_INTERFACE
2543  U8BIT slot_id;
2544 #endif
2545 
2546  FUNCTION_START(APVR_StartPauseRecord);
2547 
2548  pause_path = INVALID_RES_ID;
2549 
2550  /* Pausing live TV records to the default disk */
2551  disk_id = STB_PVRGetDefaultDisk();
2552 
2553  live_path = STB_DPGetLivePath();
2554  if (live_path != INVALID_RES_ID)
2555  {
2556  serv_ptr = ADB_GetTunedService(live_path);
2557  if ((serv_ptr != NULL) && (disk_id != INVALID_DISK_ID))
2558  {
2559  /* Create and start recording */
2560  service_id = ADB_GetServiceId(serv_ptr);
2561  if ((transport = ADB_GetServiceTransportPtr(serv_ptr)) != NULL)
2562  {
2563  trans_id = ADB_GetTransportTid(transport);
2564  onet_id = ADB_GetTransportOriginalNetworkId(transport);
2565  }
2566  else
2567  {
2568  trans_id = ADB_INVALID_DVB_ID;
2569  onet_id = ADB_INVALID_DVB_ID;
2570  }
2571 
2572  /* Save the tuned service to be returned to when pause is stopped */
2573  tuned_service_ptr = serv_ptr;
2574 
2575  record_started = FALSE;
2576 
2577 #ifdef INTEGRATE_HBBTV
2578  HBBTV_NotifyRecordingEvent(0, HBBTV_RECORDING_TS_STARTING);
2579 #endif
2580 
2581  /* Acquire a decode path for recording.
2582  * If CI+ is enabled and the CAM has taken ownership of the live path/tuner then it may
2583  * not be possible to get a recording path, but going through the process of asking CI+
2584  * to release the path/tuner is just too much work, so in this case we'll just fail to
2585  * start pause live TV......for now. */
2586  pause_path = APVR_PrepareNewRecording(onet_id, trans_id, service_id, &new_tuned_service);
2587  if (pause_path != INVALID_RES_ID)
2588  {
2589  /* Set the flag for timeshift recording and max size of the timeshift buffer in seconds */
2590  STB_PVRStartRecordPaused(pause_path, timeshift_buffer_size * 60);
2591 
2592 #ifdef COMMON_INTERFACE
2593  if ((slot_id = STB_DPGetPathCISlot(pause_path)) != INVALID_RES_ID)
2594  {
2595  /* Switch to timeshift mode */
2596  STB_CiCcSetRecordOperatingMode(slot_id, STB_CI_MODE_TIMESHIFT, service_id);
2597  }
2598 #endif
2599  if (APVR_StartNewRecording(disk_id, pause_path, (U8BIT *)"PauseLiveTV", 0, 0, 0, &paused_recording) == TRUE)
2600  {
2601  paused_disk_id = disk_id;
2602  APP_PRINT_PVR_PAUSE(("APVR_StartPauseRecord: Recording live, handle=0x%04x", paused_recording));
2603  record_started = TRUE;
2604  }
2605 #ifdef APP_PRINT_PVR_PAUSE
2606  else
2607  {
2608  APP_PRINT_PVR_PAUSE(("APVR_StartPauseRecord: Failed to start recording"));
2609  }
2610 #endif
2611 
2612  if (!record_started)
2613  {
2614  /* Release the record path */
2615  ACTL_TuneToService(pause_path, NULL, NULL, FALSE, TRUE);
2616  STB_DPReleasePath(pause_path, RES_OWNER_DVB);
2617  pause_path = INVALID_RES_ID;
2618  }
2619  }
2620 #if defined(APP_PRINT_PVR_PAUSE) || defined(INTEGRATE_HBBTV)
2621  else
2622  {
2623  APP_PRINT_PVR_PAUSE(("APVR_StartPauseRecord: Failed to get a path for recording"));
2624 #ifdef INTEGRATE_HBBTV
2625  HBBTV_NotifyRecordingEvent(0, HBBTV_RECORDING_TS_STOPPED);
2626 #endif
2627  }
2628 #endif
2629  }
2630  }
2631 
2632  FUNCTION_FINISH(APVR_StartPauseRecord);
2633 
2634  return(pause_path);
2635 }
2636 
2645 {
2646  U8BIT live_path;
2647  U16BIT serv_id, ts_id, orig_net_id;
2648 
2649  FUNCTION_START(APVR_StartPausePlay);
2650 
2651  playback_path = INVALID_RES_ID;
2652 
2653  if (paused_recording != 0)
2654  {
2655  live_path = STB_DPGetLivePath();
2656  if (live_path != INVALID_RES_ID)
2657  {
2658  /* Stop the live path so playback can be started */
2659  ACTL_TuneOff(live_path);
2660  STB_DPReleasePath(live_path, RES_OWNER_NONE);
2661  }
2662 
2663  STB_PVRRecordingGetTriplet(paused_recording, &serv_id, &ts_id, &orig_net_id);
2664  playback_service = CreatePlaybackService(serv_id);
2665 
2666  playback_path = STB_DPAcquirePlaybackPath((void *)playback_service);
2667  if (playback_path != INVALID_RES_ID)
2668  {
2669  /* Set flag for playback */
2670  STB_PVRStartPlayPaused(playback_path);
2671 
2672  /* Start playback */
2673  if (STB_PVRStartPlaying(playback_path, paused_recording, FALSE))
2674  {
2675  ACTL_StartDecoding(playback_path, playback_service);
2676  STB_AVBlankVideo(0, FALSE);
2677 
2678  APP_PRINT_PVR_PAUSE(("%s: Setting APP_SI_MODE_UPDATE on playback path for live pause %u",
2679  __FUNCTION__, playback_path));
2680 
2681  ASI_SetAppSiMode(playback_path, APP_SI_MODE_UPDATE);
2682  STB_DPSetSearchMode(playback_path, FALSE);
2683  STB_DPStartSI(playback_path);
2684 
2685  playback_handle = paused_recording;
2686 
2687  /* Acquire a new path to monitor live SI data. It should always be possible to get a path
2688  * for this service because this is the one being recorded for timeshift playback */
2689  monitor_si_path = ACTL_AcquirePathForService(tuned_service_ptr, FALSE, FALSE, NULL);
2690  APP_PRINT_PVR_PAUSE(("APVR_StartPausePlay: Path for monitoring SI data=%u", monitor_si_path));
2691  if (monitor_si_path != INVALID_RES_ID)
2692  {
2693  ACTL_TuneToService(monitor_si_path, NULL, tuned_service_ptr, TRUE, FALSE);
2694  }
2695 
2696 #ifdef INTEGRATE_HBBTV
2697  /* Now playback has started for timeshift, notify HbbTV */
2698  HBBTV_NotifyRecordingEvent(0, HBBTV_RECORDING_TS_STARTED);
2699 #endif
2700  }
2701  else
2702  {
2703  APP_PRINT_PVR_PAUSE(("APVR_StartPausePlay: Failed to start paused playback"));
2704 
2705  STB_DPReleasePath(playback_path, RES_OWNER_NONE);
2706  playback_path = INVALID_RES_ID;
2707 
2708  FreePlaybackService(playback_service);
2709  playback_service = NULL;
2710  }
2711  }
2712 #ifdef APP_PRINT_PVR_PAUSE
2713  else
2714  {
2715  APP_PRINT_PVR_PAUSE(("APVR_StartPausePlay: Failed to get a playback path"));
2716  }
2717 #endif
2718  }
2719 
2720  FUNCTION_FINISH(APVR_StartPausePlay);
2721 
2722  return(playback_path);
2723 }
2724 
2730 void APVR_StopPauseRecord(BOOLEAN return_to_live)
2731 {
2732  U32BIT handle;
2733 
2734  FUNCTION_START(APVR_StopPauseRecord);
2735 
2736  /* Stop playback and release the decoder being used */
2737  if (playback_path != INVALID_RES_ID)
2738  {
2739  STB_DPStopSI(playback_path);
2740 
2741  FreePlaybackService(playback_service);
2742  playback_service = NULL;
2743 
2744  /* If playback is in progress then stop it */
2745  ACTL_DecodeOff(playback_path);
2746  if (STB_PVRIsPlaying(playback_path, &handle) == TRUE)
2747  {
2748  STB_PVRStopPlaying(playback_path);
2749  }
2750 
2751  STB_DPReleasePath(playback_path, RES_OWNER_NONE);
2752  playback_path = INVALID_RES_ID;
2753  }
2754 
2755  if (pause_path != INVALID_RES_ID)
2756  {
2757  /* Stop the recording and release the path */
2758  STB_DPStopRecording(pause_path);
2759  ACTL_TuneToService(pause_path, NULL, NULL, FALSE, TRUE);
2760  STB_DPReleasePath(pause_path, RES_OWNER_DVB);
2761  pause_path = INVALID_RES_ID;
2762  }
2763 
2764  if (paused_recording != 0)
2765  {
2766  /* Delete any files associated with the pause live recording */
2767  APP_PRINT_PVR_PAUSE(("APVR_StopPauseRecord: stop and destroy recording 0x%x", paused_recording));
2768  DestroyRecording(paused_recording);
2769  paused_recording = 0;
2770  }
2771 
2772  if (monitor_si_path != INVALID_RES_ID)
2773  {
2774  APP_PRINT_PVR_PAUSE(("APVR_StopPauseRecord: Stop monitoring SI on path %u", monitor_si_path));
2775 
2776  ACTL_TuneOff(monitor_si_path);
2777  STB_DPReleasePath(monitor_si_path, RES_OWNER_NONE);
2778  monitor_si_path = INVALID_RES_ID;
2779  }
2780 
2781  if (return_to_live)
2782  {
2783  APP_PRINT_PVR_PAUSE(("APVR_StopPauseRecord: Return to live service %p", tuned_service_ptr));
2784  ACTL_TuneToService(INVALID_RES_ID, NULL, tuned_service_ptr, FALSE, TRUE);
2785  }
2786 
2787 #ifdef INTEGRATE_HBBTV
2788  HBBTV_NotifyRecordingEvent(0, HBBTV_RECORDING_TS_STOPPED);
2789 #endif
2790 
2791  FUNCTION_FINISH(APVR_StopPauseRecord);
2792 }
2793 
2799 {
2800  U8BIT path, num_paths;
2801  U32BIT recording_handle;
2802  BOOLEAN is_recording, recordings;
2803 
2804  FUNCTION_START(APVR_IsRecordingInProgress);
2805 
2806  recordings = FALSE;
2807 
2808  num_paths = STB_DPGetNumPaths();
2809 
2810  for (path = 0; path < num_paths; path++)
2811  {
2812  is_recording = STB_DPIsRecording(path, &recording_handle);
2813 
2814  if ((is_recording) && (recording_handle == paused_recording))
2815  {
2816  /* This tuner is being used for pause so don't mark it as recording */
2817  is_recording = FALSE;
2818  }
2819 
2820  if (is_recording == TRUE)
2821  {
2822  recordings = TRUE;
2823  }
2824  }
2825 
2826  FUNCTION_FINISH(APVR_IsRecordingInProgress);
2827 
2828  return(recordings);
2829 }
2830 
2838 BOOLEAN APVR_IsRecordingHandle(U8BIT path, U32BIT recording_handle)
2839 {
2840  BOOLEAN is_recording;
2841  U32BIT recording_handle_found;
2842 
2843  FUNCTION_START(APVR_IsRecordingHandle);
2844 
2845  is_recording = FALSE;
2846 
2847  if (path != INVALID_RES_ID)
2848  {
2849  if (APVR_GetRecordingHandle(path, &recording_handle_found))
2850  {
2851  if (recording_handle == recording_handle_found)
2852  {
2853  is_recording = TRUE;
2854  }
2855  }
2856  }
2857 
2858  FUNCTION_FINISH(APVR_IsRecordingHandle);
2859 
2860  return(is_recording);
2861 }
2862 
2870 BOOLEAN APVR_GetRecordingHandle(U8BIT path, U32BIT *recording_handle_ptr)
2871 {
2872  BOOLEAN is_recording;
2873 
2874  FUNCTION_START(APVR_GetRecordingHandle);
2875 
2876  is_recording = FALSE;
2877 
2878  // if tuner recording
2879  if (STB_DPIsRecording(path, recording_handle_ptr))
2880  {
2881  APP_PRINT_PVR_REC(("APVR_GetRecordingHandle(%d): found 0x%x", path, recording_handle_ptr));
2882  is_recording = TRUE;
2883  }
2884 
2885  FUNCTION_FINISH(APVR_GetRecordingHandle);
2886 
2887  return(is_recording);
2888 }
2889 
2890 // ---- disk ----
2891 
2898 BOOLEAN APVR_CheckSpaceForEvent(U16BIT disk_id, void *event_ptr)
2899 {
2900  BOOLEAN free_space;
2901 
2902  FUNCTION_START(APVR_CheckSpaceForEvent);
2903 
2904  free_space = APVR_CheckSpaceDuration(disk_id, ADB_GetEventDuration(event_ptr));
2905 
2906  FUNCTION_FINISH(APVR_CheckSpaceForEvent);
2907  return(free_space);
2908 }
2909 
2917 BOOLEAN APVR_CheckSpaceForDuration(U16BIT disk_id, U8BIT hours, U8BIT mins)
2918 {
2919  U8BIT used_hour;
2920  U8BIT used_min;
2921  U8BIT free_hour;
2922  U8BIT free_min;
2923  U8BIT size_hour;
2924  U8BIT size_min;
2925  U16BIT total_time_needed;
2926  U16BIT total_space_left;
2927  BOOLEAN free_space;
2928 
2929  FUNCTION_START(APVR_CheckSpaceForDuration);
2930 
2931  APVR_GetDiskTime(disk_id, &used_hour, &used_min, &free_hour, &free_min, &size_hour, &size_min);
2932 
2933  /* Total up the event and the free space on disk durations */
2934  total_time_needed = (hours * 60) + mins;
2935  total_space_left = (free_hour * 60) + free_min;
2936 
2937  /* Check total time needed is less than whats left and also check for if anythings actually been used */
2938  if (total_time_needed < total_space_left)
2939  {
2940  free_space = TRUE;
2941  }
2942  else
2943  {
2944  free_space = FALSE;
2945  }
2946 
2947  FUNCTION_FINISH(APVR_CheckSpaceForDuration);
2948 
2949  return(free_space);
2950 }
2951 
2958 BOOLEAN APVR_CheckSpaceDuration(U16BIT disk_id, U32BIT duration)
2959 {
2960  BOOLEAN free_space;
2961  FUNCTION_START(APVR_CheckSpaceDuration);
2962  free_space = APVR_CheckSpaceForDuration( disk_id,
2963  (U8BIT)(DHMS_DAYS(duration) * 24) + DHMS_HOUR(duration), DHMS_MINS(duration));
2964  FUNCTION_FINISH(APVR_CheckSpaceDuration);
2965  return(free_space);
2966 }
2967 
2972 U8BIT APVR_GetTotalSpacePercentUsed(U16BIT disk_id)
2973 {
2974  U32BIT size;
2975  U32BIT used;
2976  U8BIT total_space_used;
2977 
2978  FUNCTION_START(APVR_GetTotalSpacePercentUsed);
2979 
2980  if (!APVR_IsInitialised())
2981  {
2982  total_space_used = 100;
2983  }
2984  else
2985  {
2986  /* Calc % files used. All sizes are converted to MB to prevent overflow */
2987  size = STB_DSKGetSize(disk_id) / 1024;
2988  if (size > 0)
2989  {
2990  used = STB_DSKGetUsed(disk_id) / 1024;
2991  total_space_used = (U8BIT)((used * 100) / size);
2992  }
2993  else
2994  {
2995  total_space_used = 100;
2996  }
2997  }
2998 
2999  FUNCTION_FINISH(APVR_GetTotalSpacePercentUsed);
3000 
3001  return(total_space_used);
3002 }
3003 
3014 void APVR_GetDiskTime(U16BIT disk_id,
3015  U8BIT *used_hour_ptr, U8BIT *used_min_ptr,
3016  U8BIT *free_hour_ptr, U8BIT *free_min_ptr,
3017  U8BIT *size_hour_ptr, U8BIT *size_min_ptr)
3018 {
3019  U16BIT total_min;
3020 
3021  FUNCTION_START(APVR_GetDiskTime);
3022 
3023  if (APVR_IsInitialised() == FALSE)
3024  {
3025  *used_hour_ptr = 0;
3026  *used_min_ptr = 0;
3027 
3028  *free_hour_ptr = 0;
3029  *free_min_ptr = 0;
3030 
3031  *size_hour_ptr = 0;
3032  *size_min_ptr = 0;
3033  }
3034  else
3035  {
3036  // hour and min:
3037  STB_PVRDiskUsed(disk_id, used_hour_ptr, used_min_ptr);
3038  STB_PVRDiskFree(disk_id, free_hour_ptr, free_min_ptr);
3039  total_min = (U16BIT)(*used_min_ptr) + (U16BIT)(*free_min_ptr);
3040  *size_min_ptr = (U8BIT)(total_min % 60);
3041  *size_hour_ptr = (*used_hour_ptr) + (*free_hour_ptr) + (U8BIT)(total_min / 60);
3042  }
3043 
3044  FUNCTION_FINISH(APVR_GetDiskTime);
3045 }
3046 
3054 void APVR_GetDiskMbyte(U16BIT disk_id, U32BIT *used_mbyte_ptr, U32BIT *free_mbyte_ptr, U32BIT *size_mbyte_ptr)
3055 {
3056  U8BIT used_percent;
3057 
3058  FUNCTION_START(APVR_GetDiskMbyte);
3059 
3060  if (APVR_IsInitialised() == FALSE)
3061  {
3062  *used_mbyte_ptr = 0;
3063  *free_mbyte_ptr = 0;
3064  *size_mbyte_ptr = 0;
3065  }
3066  else
3067  {
3068  used_percent = APVR_GetTotalSpacePercentUsed(disk_id);
3069  *size_mbyte_ptr = STB_PVRDiskSize(disk_id);
3070  *used_mbyte_ptr = (used_percent * (*size_mbyte_ptr)) / PVR_100_PERCENT;
3071  *free_mbyte_ptr = ((PVR_100_PERCENT - used_percent) * (*size_mbyte_ptr)) / PVR_100_PERCENT;
3072  }
3073 
3074  FUNCTION_FINISH(APVR_GetDiskMbyte);
3075 }
3076 
3077 // ---- pause ----
3078 
3084 {
3085  U8BIT audio_decoder;
3086  U8BIT video_decoder;
3087  U8BIT length_hour, length_min, length_sec;
3088  U8BIT elapsed_hour, elapsed_min, elapsed_sec;
3089  U32BIT length, elapsed;
3090  U32BIT space_used;
3091  U32BIT pause_time;
3092 
3093  FUNCTION_START(APVR_GetPauseProgress);
3094 
3095  pause_time = 0;
3096 
3097  if (paused_recording != 0)
3098  {
3099  if (STB_PVRRecordingGetLength(paused_recording, &length_hour, &length_min, &length_sec, &space_used))
3100  {
3101  if (playback_path != INVALID_RES_ID)
3102  {
3103  audio_decoder = STB_DPGetPathAudioDecoder(playback_path);
3104  video_decoder = STB_DPGetPathVideoDecoder(playback_path);
3105 
3106  if (STB_PVRGetElapsedTime(audio_decoder, video_decoder, &elapsed_hour,
3107  &elapsed_min, &elapsed_sec))
3108  {
3109  /* Calculate the number of seconds behind live TV */
3110  length = length_hour * 3600 + length_min * 60 + length_sec;
3111  elapsed = elapsed_hour * 3600 + elapsed_min * 60 + elapsed_sec;
3112 
3113  pause_time = length - elapsed;
3114  }
3115  }
3116  }
3117  }
3118 
3119  FUNCTION_FINISH(APVR_GetPauseProgress);
3120 
3121  return(pause_time);
3122 }
3123 
3129 {
3130  U8BIT audio_decoder;
3131  U8BIT video_decoder;
3132  U8BIT elapsed_hour, elapsed_min, elapsed_sec;
3133  U32BIT elapsed;
3134 
3135  FUNCTION_START(APVR_GetPlaybackTime);
3136 
3137  elapsed = 0;
3138 
3139  if (playback_path != INVALID_RES_ID)
3140  {
3141  audio_decoder = STB_DPGetPathAudioDecoder(playback_path);
3142  video_decoder = STB_DPGetPathVideoDecoder(playback_path);
3143 
3144  if (STB_PVRGetElapsedTime(audio_decoder, video_decoder, &elapsed_hour,
3145  &elapsed_min, &elapsed_sec))
3146  {
3147  /* Calculate the number of seconds */
3148  elapsed = elapsed_hour * 3600 + elapsed_min * 60 + elapsed_sec;
3149  }
3150  }
3151 
3152  FUNCTION_FINISH(APVR_GetPlaybackTime);
3153 
3154  return(elapsed);
3155 }
3156 
3162 BOOLEAN APVR_SetPlaybackTime(U32BIT position_in_secs)
3163 {
3164  U8BIT audio_decoder;
3165  U8BIT video_decoder;
3166  BOOLEAN result;
3167 
3168  FUNCTION_START(APVR_SetPlaybackTime);
3169 
3170  if (playback_path != INVALID_RES_ID)
3171  {
3172  audio_decoder = STB_DPGetPathAudioDecoder(playback_path);
3173  video_decoder = STB_DPGetPathVideoDecoder(playback_path);
3174  result = STB_PVRPlaySetPosition(audio_decoder, video_decoder, position_in_secs);
3175  }
3176  else
3177  {
3178  result = FALSE;
3179  }
3180 
3181  FUNCTION_FINISH(APVR_SetPlaybackTime);
3182  return result;
3183 }
3184 
3190 {
3191  FUNCTION_START(APVR_GetPlaybackPath);
3192  FUNCTION_FINISH(APVR_GetPlaybackPath);
3193  return(playback_path);
3194 }
3195 
3196 #ifdef FREESAT_BUILD
3197 /*!**************************************************************************
3198  * @brief Works out whether a recording should be protected by a pin for playback
3199  * based on the Freesat rules.
3200  * @param handle - recording to be played
3201  * @return TRUE if a pin should be requested, FALSE otherwise
3202  ****************************************************************************/
3203 BOOLEAN APVR_IsRecordingPinLocked(U32BIT handle)
3204 {
3205  BOOLEAN locked;
3206  U8BIT country_id;
3207  U16BIT date, local_date;
3208  U8BIT hours, mins, secs;
3209  U8BIT local_hours, local_mins, local_secs;
3210 
3211  FUNCTION_START(APVR_IsRecordingPinLocked);
3212 
3213  locked = FALSE;
3214  country_id = (U8BIT)APP_NvmRead(COUNTRY_ID_NVM);
3215 
3216  /* Check whether the recording requires a PIN to be entered before playback can start */
3219  (STB_PVRRecordingHasGuidance(handle) &&
3220  STB_PVRRecordingGetDateTime(handle, &date, &hours, &mins, &secs) &&
3221  !ACFG_IsOutsideWatershedHours(country_id, hours, mins)))
3222  {
3223  /* The programme is subject to guidance so check
3224  * whether the current time is before the watershed */
3225  STB_GCGetGMTDateTime(&date, &hours, &mins, &secs);
3226  STB_GCConvertDateTime(date, hours, mins, secs, &local_date, &local_hours,
3227  &local_mins, &local_secs, CONV_LOCAL);
3228 
3229  if (!ACFG_IsOutsideWatershedHours(country_id, local_hours, local_mins))
3230  {
3231  locked = TRUE;
3232  }
3233  }
3234 
3235  FUNCTION_FINISH(APVR_IsRecordingPinLocked);
3236 
3237  return(locked);
3238 }
3239 
3240 #endif
3241 
3247 BOOLEAN APVR_IsEventInRecordList(U8BIT *prog_crid)
3248 {
3249  U32BIT handle;
3250  BOOLEAN recording_found;
3251 
3252  FUNCTION_START(APVR_IsEventInRecordList);
3253 
3254  recording_found = STB_PVRFindRecordingFromCrid(prog_crid, &handle);
3255 
3256  FUNCTION_FINISH(APVR_IsEventInRecordList);
3257 
3258  return(recording_found);
3259 }
3260 
3267 void APVR_RecordSeries(void *crid_ptr)
3268 {
3269  void **slist;
3270  void **elist;
3271  void *event_ptr;
3272  void *alt_event_ptr;
3273  U16BIT num_services;
3274  U16BIT num_events;
3275  U8BIT *series_crid_str;
3276  U8BIT *event_series_crid;
3277  U8BIT *prog_crid;
3278  U8BIT *series_crid;
3279  U16BIT si, ei;
3280  U8BIT ci, num_series_crids;
3281  U16BIT onet_id, tran_id, serv_id;
3282  U16BIT event_id;
3283  U32DHMS now_time;
3284  BOOLEAN proceed_with_recording;
3285  U32BIT timer;
3286 
3287  FUNCTION_START(APVR_RecordSeries);
3288 
3289  ADB_GetServiceList(ADB_SERVICE_LIST_ALL, &slist, &num_services);
3290 
3291  if ((num_services > 0) && (slist != NULL))
3292  {
3293  series_crid_str = ADB_GetCridString(crid_ptr);
3294 
3295  for (si = 0; si != num_services; si++)
3296  {
3297  /* Events on a service may be associated with different default CRID authorities
3298  * so it isn't possible to check that the service authorities for the series and
3299  * service match before going on to check each event, each event has to be checked
3300  * on all services */
3301  ADB_GetEventSchedule(FALSE, slist[si], &elist, &num_events);
3302 
3303  if ((num_events > 0) && (elist != NULL))
3304  {
3305  /* Get the current date/time to check for old events */
3306  now_time = STB_GCNowDHMSGmt();
3307 
3308  for (ei = 0; ei != num_events; ei++)
3309  {
3310  event_ptr = elist[ei];
3311 
3312  /* Check that the event isn't already in the past */
3313  if (ADB_GetEventStartDateTime(event_ptr) >= now_time)
3314  {
3315  num_series_crids = ADB_GetEventNumSeriesCrids(event_ptr);
3316 
3317  for (ci = 0; ci < num_series_crids; ci++)
3318  {
3319  event_series_crid = ADB_GetEventSeriesCrid(ci, slist[si], event_ptr);
3320  if (event_series_crid != NULL)
3321  {
3322  if (STB_CompareStringsIgnoreCase(event_series_crid, series_crid_str) == 0)
3323  {
3324  /* This event is in the same series, check that it hasn't already
3325  * been recorded and isn't set to be recorded */
3326  proceed_with_recording = TRUE;
3327 
3328  ADB_GetServiceIds(slist[si], &onet_id, &tran_id, &serv_id);
3329 
3330  event_id = ADB_GetEventId(event_ptr);
3331  prog_crid = ADB_GetEventProgrammeCrid(slist[si], event_ptr);
3332 
3333  if ((prog_crid != NULL) && (strlen((char *)prog_crid) > 0))
3334  {
3335  if (APVR_IsEventInRecordList(prog_crid))
3336  {
3337  /* This programme has already been recorded so don't re-record it */
3338  proceed_with_recording = FALSE;
3339  }
3340  else if (((timer = ATMR_FindTimerFromCrid(prog_crid)) != INVALID_TIMER_HANDLE) ||
3341  ((timer = ATMR_FindTimerFromEvent(onet_id, tran_id, serv_id, event_id)) != INVALID_TIMER_HANDLE))
3342  {
3343  /* The event is already set to be recorded; check that it's being
3344  * recorded as part of the series */
3345  series_crid = ATMR_GetOtherCrid(timer);
3346 
3347  if ((series_crid != NULL) &&
3348  (STB_CompareStringsIgnoreCase(series_crid, series_crid_str) == 0))
3349  {
3350  /* The recording is part of the series so don't record it */
3351  proceed_with_recording = FALSE;
3352  }
3353  else if (ATMR_GetRecordingHandle(timer) != STB_PVR_INVALID_HANDLE)
3354  {
3355  /* The recording is already in progress so let it continue */
3356  proceed_with_recording = FALSE;
3357  }
3358  else
3359  {
3360  /* This programme is an individual recording or was being
3361  * recorded as a recommendation, but should now be
3362  * recorded as part of this series; delete the timer so
3363  * another one is created that includes the series CRID */
3364  ATMR_DeleteTimer(timer);
3365  }
3366  }
3367 #ifdef APP_PRINT_PVR_FP
3368  if (proceed_with_recording)
3369  {
3370  APP_PRINT_PVR_FP((" recording series event with prog crid=\"%s\"", prog_crid));
3371  }
3372 #endif
3373  }
3374  else
3375  {
3376  /* As the event doesn't have a programme CRID the only check that
3377  * can be made is to see if a timer exists with the same event and
3378  * service IDs */
3379  if (ATMR_FindTimerFromEvent(onet_id, tran_id, serv_id, event_id) != INVALID_TIMER_HANDLE)
3380  {
3381  proceed_with_recording = FALSE;
3382  }
3383 #ifdef APP_PRINT_PVR_FP
3384  else
3385  {
3386  APP_PRINT_PVR_FP((" recording series event from service 0x%x with event ID %d",
3387  serv_id, event_id));
3388  }
3389 #endif
3390  }
3391 
3392  if (proceed_with_recording)
3393  {
3394  alt_event_ptr = ATMR_RecordEvent(slist[si], event_ptr, prog_crid,
3395  series_crid_str, FALSE, TRUE, ADB_GetCridDoNotDelete(crid_ptr));
3396  if ((alt_event_ptr != NULL) && (alt_event_ptr != event_ptr))
3397  {
3398  ADB_ReleaseEventData(alt_event_ptr);
3399  }
3400  }
3401 
3402  if (prog_crid != NULL)
3403  {
3404  STB_AppFreeMemory(prog_crid);
3405  }
3406 
3407  /* Update the date this series was seen in the EIT */
3408  ADB_UpdateCridEitDate(crid_ptr);
3409  }
3410 
3411  STB_AppFreeMemory(event_series_crid);
3412  }
3413  }
3414  }
3415  }
3416 
3417  ADB_ReleaseEventList(elist, num_events);
3418  }
3419  }
3420 
3421  ADB_ReleaseServiceList(slist, num_services);
3422  }
3423 
3424  FUNCTION_FINISH(APVR_RecordSeries);
3425 }
3426 
3433 void APVR_RecordRecommendations(void *crid_ptr)
3434 {
3435  void **slist;
3436  void **elist;
3437  void *alt_event_ptr;
3438  U16BIT num_services;
3439  U16BIT num_events;
3440  U8BIT *rec_crid_str;
3441  U8BIT *event_series_crid;
3442  U8BIT *prog_crid;
3443  U16BIT si, ei;
3444  U8BIT ci, num_series_crids;
3445  U16BIT onet_id, tran_id, serv_id;
3446  U16BIT event_id;
3447  BOOLEAN proceed_with_recording;
3448 
3449  FUNCTION_START(APVR_RecordRecommendations);
3450 
3451  ADB_GetServiceList(ADB_SERVICE_LIST_ALL, &slist, &num_services);
3452 
3453  if ((num_services > 0) && (slist != NULL))
3454  {
3455  rec_crid_str = ADB_GetCridString(crid_ptr);
3456 
3457  for (si = 0; si < num_services; si++)
3458  {
3459  /* Events on a service may be associated with different default CRID authorities
3460  * so it isn't possible to check that the service authorities for the recommendation
3461  * and service match before going on to check each event, each event has to be checked
3462  * on all services */
3463  ADB_GetEventSchedule(FALSE, slist[si], &elist, &num_events);
3464 
3465  if ((num_events > 0) && (elist != NULL))
3466  {
3467  for (ei = 0; ei < num_events; ei++)
3468  {
3469  proceed_with_recording = TRUE;
3470 
3471  /* A recommendation may either be a link to an individual event
3472  * or to a series, so both need to be checked as there's no way
3473  * to differentiate between them */
3474  prog_crid = ADB_GetEventProgrammeCrid(slist[si], elist[ei]);
3475  if (prog_crid != NULL)
3476  {
3477  if (STB_CompareStringsIgnoreCase(prog_crid, rec_crid_str) == 0)
3478  {
3479  /* The recommendation is for this event, check that it hasn't already been
3480  * recorded and isn't set to be recorded */
3481  if (APVR_IsEventInRecordList(prog_crid) ||
3482  (ATMR_FindTimerFromCrid(prog_crid) != INVALID_TIMER_HANDLE))
3483  {
3484  alt_event_ptr = ATMR_RecordEvent(slist[si], elist[ei], prog_crid, NULL,
3485  TRUE, TRUE, ADB_GetCridDoNotDelete(crid_ptr));
3486  if ((alt_event_ptr != NULL) && (alt_event_ptr != elist[ei]))
3487  {
3488  ADB_ReleaseEventData(alt_event_ptr);
3489  }
3490  }
3491 
3492  /* The recommendation CRID has been matched against this programme CRID
3493  * so it can't match a series */
3494  proceed_with_recording = FALSE;
3495  }
3496 
3497  STB_AppFreeMemory(prog_crid);
3498  }
3499 
3500  if (proceed_with_recording)
3501  {
3502  /* Check the recommendation CRID against all the series CRIDs of this event */
3503  num_series_crids = ADB_GetEventNumSeriesCrids(elist[ei]);
3504 
3505  for (ci = 0; ci < num_series_crids; ci++)
3506  {
3507  event_series_crid = ADB_GetEventSeriesCrid(ci, slist[si], elist[ei]);
3508  if (event_series_crid != NULL)
3509  {
3510  //DBG_PVR((" %d: series crid=\"%s\"\n", ei, event_series_crid));
3511  if (STB_CompareStringsIgnoreCase(event_series_crid, rec_crid_str) == 0)
3512  {
3513  /* This event is in the same series */
3514  ADB_GetServiceIds(slist[si], &onet_id, &tran_id, &serv_id);
3515 
3516  event_id = ADB_GetEventId(elist[ei]);
3517  prog_crid = ADB_GetEventProgrammeCrid(slist[si], elist[ei]);
3518 
3519  if (prog_crid != NULL)
3520  {
3521  /* Check that it hasn't already been recorded and isn't set to be recorded */
3522  if (APVR_IsEventInRecordList(prog_crid) ||
3523  (ATMR_FindTimerFromCrid(prog_crid) != INVALID_TIMER_HANDLE) ||
3524  (ATMR_FindTimerFromEvent(onet_id, tran_id, serv_id, event_id) != INVALID_TIMER_HANDLE))
3525  {
3526  proceed_with_recording = FALSE;
3527  }
3528  }
3529  else
3530  {
3531  /* As the event doesn't have a programme CRID the only check that
3532  * can be made is to see if a timer exists with the same event and
3533  * service IDs */
3534  if (ATMR_FindTimerFromEvent(onet_id, tran_id, serv_id, event_id) != INVALID_TIMER_HANDLE)
3535  {
3536  proceed_with_recording = FALSE;
3537  }
3538  }
3539 
3540  if (proceed_with_recording)
3541  {
3542  alt_event_ptr = ATMR_RecordEvent(slist[si], elist[ei], prog_crid,
3543  event_series_crid, TRUE, TRUE, ADB_GetCridDoNotDelete(crid_ptr));
3544 
3545  if ((alt_event_ptr != NULL) && (alt_event_ptr != elist[ei]))
3546  {
3547  ADB_ReleaseEventData(alt_event_ptr);
3548  }
3549  }
3550 
3551  if (prog_crid != NULL)
3552  {
3553  STB_AppFreeMemory(prog_crid);
3554  }
3555 
3556  /* Update the date this recommendation was seen in the EIT */
3557  ADB_UpdateCridEitDate(crid_ptr);
3558  }
3559 
3560  STB_AppFreeMemory(event_series_crid);
3561  }
3562  }
3563  }
3564  }
3565 
3566  ADB_ReleaseEventList(elist, num_events);
3567  }
3568  }
3569 
3570  ADB_ReleaseServiceList(slist, num_services);
3571  }
3572 
3573  FUNCTION_FINISH(APVR_RecordRecommendations);
3574 }
3575 
3583 BOOLEAN APVR_FindNextSplitEvent(U32BIT curr_handle, U32BIT *next_handle)
3584 {
3585  BOOLEAN found_next_recording;
3586 
3587  FUNCTION_START(APVR_FindNextSplitEvent);
3588 
3589  found_next_recording = FALSE;
3590 
3591  if (playback_path != INVALID_RES_ID)
3592  {
3593  found_next_recording = STB_PVRFindNextSplitRecording(curr_handle, next_handle);
3594  }
3595 
3596  FUNCTION_FINISH(APVR_FindNextSplitEvent);
3597 
3598  return(found_next_recording);
3599 }
3600 
3608 {
3609  FUNCTION_START(APVR_GetPlaybackService);
3610  FUNCTION_FINISH(APVR_GetPlaybackService);
3611  return((void *)playback_service);
3612 }
3613 
3619 BOOLEAN APVR_HandlePrivateTimer(U32BIT timer_handle)
3620 {
3621  BOOLEAN retval;
3622 #ifdef COMMON_INTERFACE
3623  U8BIT path;
3624  U32BIT recording_handle;
3625 #endif
3626 
3627  FUNCTION_START(APVR_HandlePrivateTimer);
3628 
3629  retval = FALSE;
3630 
3631 #ifdef COMMON_INTERFACE
3632  for (path = 0; path < STB_DPGetNumPaths(); path++)
3633  {
3634  if (timer_handle == cam_record_start_timer[path])
3635  {
3636  retval = TRUE;
3637 
3638  /* No reply has been received from the CAM, so the recording can't proceed */
3639  if (STB_DPIsRecording(path, &recording_handle))
3640  {
3641  APVR_StopRecording(recording_handle);
3642  APVR_DeleteRecording(recording_handle);
3643  }
3644 
3645  STB_DPReleasePath(path, RES_OWNER_DVB);
3646 
3647  /* Delete the private timer */
3648  ATMR_DeleteTimer(timer_handle);
3649  cam_record_start_timer[path] = INVALID_TIMER_HANDLE;
3650 
3651  /* Send event to UI to inform it that a recording has failed */
3652  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_PVR_RECORDING_FAILED, NULL, 0);
3653  }
3654  }
3655 #else
3656  USE_UNWANTED_PARAM(timer_handle);
3657 #endif
3658 
3659  FUNCTION_FINISH(APVR_HandlePrivateTimer);
3660 
3661  return(retval);
3662 }
3663 
3664 #ifdef COMMON_INTERFACE
3665 
3672 void APVR_CIRecordReplyReceived(BOOLEAN start_succeeded, U8BIT slot_id)
3673 {
3674  U8BIT path;
3675  U32BIT recording_handle;
3676  S_ACTL_OWNER_INFO owner_info;
3677  BOOLEAN stop_recording;
3678 
3679  FUNCTION_START(APVR_CIRecordReplyReceived);
3680 
3681  /* A slot can be shared with more than one path,
3682  * so handle this event for all paths using this slot */
3683  path = INVALID_RES_ID;
3684  while ((path = STB_DPIsCISlotInUse(path, slot_id, path)) != INVALID_RES_ID)
3685  {
3686  stop_recording = FALSE;
3687 
3688  if (STB_DPIsRecording(path, &recording_handle))
3689  {
3690  /* A reply has been received, so the timer created to handle the case of
3691  * no reply being received can be deleted */
3692  ATMR_DeleteTimer(cam_record_start_timer[path]);
3693  cam_record_start_timer[path] = INVALID_TIMER_HANDLE;
3694 
3695  if (start_succeeded)
3696  {
3697  /* Recording can be resumed */
3698  if (!STB_PVRResumeRecording(path))
3699  {
3700  /* Failed to resume recording, so have to stop it */
3701  stop_recording = TRUE;
3702  }
3703  }
3704  else
3705  {
3706  /* Recording can't be started */
3707  stop_recording = TRUE;
3708  }
3709 
3710  if (stop_recording)
3711  {
3712  /* Stop and delete the recording */
3713  APVR_StopRecording(recording_handle);
3714  APVR_DeleteRecording(recording_handle);
3715 
3716  /* Tune to a NULL service on the recording path */
3717  owner_info.owner = RES_OWNER_DVB;
3718  owner_info.data = NULL;
3719  owner_info.data_size = 0;
3720 
3721  ACTL_TuneToService(path, &owner_info, NULL, FALSE, TRUE);
3722 
3723  STB_DPReleasePath(path, RES_OWNER_DVB);
3724 
3725  /* Send event to UI to inform it that a recording has failed */
3726  STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_PVR_RECORDING_FAILED, NULL, 0);
3727  }
3728  }
3729  }
3730 
3731  FUNCTION_FINISH(APVR_CIRecordReplyReceived);
3732 }
3733 
3734 #endif
3735 
3736 static ADB_SERVICE_REC* CreatePlaybackService(U16BIT service_id)
3737 {
3738  ADB_SERVICE_REC *service;
3739 
3740  FUNCTION_START(CreatePlaybackService);
3741 
3742  service = (ADB_SERVICE_REC *)STB_AppGetMemory(sizeof(ADB_SERVICE_REC));
3743  if (service != NULL)
3744  {
3745  memset(service, 0, sizeof(ADB_SERVICE_REC));
3746  service->serv_id = service_id;
3747  }
3748 
3749  FUNCTION_FINISH(CreatePlaybackService);
3750 
3751  return(service);
3752 }
3753 
3754 static void FreePlaybackService(ADB_SERVICE_REC *s_ptr)
3755 {
3756  FUNCTION_START(FreePlaybackService);
3757 
3758  if (s_ptr != NULL)
3759  {
3760  ADB_DeleteServiceRec(s_ptr);
3761  }
3762 
3763  FUNCTION_FINISH(FreePlaybackService);
3764 }
3765 
3771 {
3772  U8BIT q_msg = 0;
3773 
3774  FUNCTION_START(APVR_EitUpdated);
3775 
3776  if (eit_update_queue != NULL)
3777  {
3778  STB_OSWriteQueue(eit_update_queue, (void *)&q_msg, sizeof(q_msg), TIMEOUT_NOW);
3779  }
3780 
3781  FUNCTION_FINISH(APVR_EitUpdated);
3782 }
3783 
3791 void APVR_PidsUpdated(U8BIT path)
3792 {
3793  U32BIT handle;
3794  void *service;
3795 
3796  FUNCTION_START(APVR_PidsUpdated);
3797 
3798  if (STB_PVRIsRecording(path, &handle) == TRUE)
3799  {
3800  service = ADB_GetTunedService(path);
3801  if (service != NULL)
3802  {
3803  SetupForRecording(path, service, TRUE);
3804  }
3805  }
3806 
3807  FUNCTION_FINISH(APVR_PidsUpdated);
3808 }
3809 
3818 void APVR_EncryptRecordings(BOOLEAN state)
3819 {
3820  FUNCTION_START(APVR_EncryptRecordings);
3821  encrypt_recordings = state;
3822  FUNCTION_FINISH(APVR_EncryptRecordings);
3823 }
3824 
3825 /*!**************************************************************************
3826  * @brief Task entry point that performs all EIT update processing
3827  * @return None
3828  ****************************************************************************/
3829 static void EitUpdatedTask(void *queue)
3830 {
3831  U8BIT q_msg;
3832  BOOLEAN read_queue;
3833  U16BIT num_q_reads;
3834  U32BIT last_update_time = STB_OSGetClockMilliseconds();
3835 
3836  FUNCTION_START(EitUpdatedTask);
3837 
3838  /* As EIT updates tend to arrive several at a time, no processing is performed
3839  * until there's a timeout reading the queue and processing only then occurs if
3840  * there has been at least one EIT update. */
3841  num_q_reads = 0;
3842  q_msg = 0;
3843 
3844  while (q_msg != 0xFF)
3845  {
3846  read_queue = STB_OSReadQueue(queue, &q_msg, sizeof(q_msg), 60000);
3847  if (read_queue)
3848  {
3849  /* A message has been read from the queue so increment the count */
3850  num_q_reads++;
3851  }
3852 
3853  if ((STB_OSGetClockDiff(last_update_time) >= 60000) && (num_q_reads != 0) && q_msg != 0xFF)
3854  {
3855  /* Reset the number of times the queue has been read and process the CRID records */
3856  num_q_reads = 0;
3857 
3858  /* Check whether the EIT update requires changes to any of the already scheduled recordings */
3859  ATMR_EitUpdated();
3860 
3861  /* Check whether the EIT update requires new recordings to be scheduled */
3862  ProcessCridRecords();
3863 
3864  last_update_time = STB_OSGetClockMilliseconds();
3865  }
3866  }
3867  eit_update_queue = NULL;
3868  STB_OSTaskDelay(1);
3869  STB_OSDestroyQueue( queue );
3870  FUNCTION_FINISH(EitUpdatedTask);
3871 }
3872 
3873 /*!**************************************************************************
3874  * @brief Processes all CRID records to see whether there are any new events
3875  * that need to be set for recording. This function is called as part
3876  * of the EIT update background task.
3877  * @return None
3878  ****************************************************************************/
3879 static void ProcessCridRecords(void)
3880 {
3881  void **crid_rec_list;
3882  U16BIT num_crid_recs;
3883  U16BIT i;
3884  U8BIT *crid_str;
3885  U32DHMS start_time, end_time, now_time;
3886  U16BIT eit_date, gmt_date;
3887  U16BIT serv_id;
3888  void *serv_ptr;
3889  void *event_ptr;
3890 
3891  FUNCTION_START(ProcessCridRecords);
3892 
3893  ADB_GetCridRecordList(&crid_rec_list, &num_crid_recs, TRUE, TRUE, TRUE);
3894 #ifdef APP_PRINT_PVR_FP
3895  if (num_crid_recs > 0)
3896  {
3897  APP_PRINT_PVR_FP(("### Processing %d CRID records", num_crid_recs));
3898  }
3899 #endif
3900 
3901  gmt_date = STB_GCGetGMTDate();
3902 
3903  for (i = 0; i < num_crid_recs; i++)
3904  {
3905  crid_str = ADB_GetCridString(crid_rec_list[i]);
3906 
3907  if (ADB_IsProgrammeCrid(crid_rec_list[i]) && ADB_IsSplitProgrammeCrid(crid_str))
3908  {
3909  /* This record represents a split event. Get the info to see whether
3910  * any additional parts of the split event are now available */
3911  start_time = ADB_GetCridDateTime(crid_rec_list[i]);
3912  serv_id = ADB_GetCridService(crid_rec_list[i]);
3913 
3914  APP_PRINT_PVR_FP((" %d: Programme, CRID=\"%s\", time=%d.%d, service=0x%x", i, crid_str,
3915  DHMS_HOUR(start_time), DHMS_MINS(start_time), serv_id));
3916 
3917  serv_ptr = ADB_FindServiceByIds(ADB_INVALID_DVB_ID, ADB_INVALID_DVB_ID, serv_id);
3918 
3919  /* Calculate the time this crid will no longer be valid */
3920  end_time = STB_GCCalculateDHMS(start_time, DHMS_CREATE(0, 3, 0, 0), CALC_ADD);
3921  now_time = STB_GCNowDHMSGmt();
3922  /* Only search for the crid if everything is valid and the time is less than 3 hours old */
3923  if ((crid_str != NULL) && (serv_ptr != NULL) && (end_time >= now_time))
3924  {
3925  /* Search backwards and forwards from the saved date/time */
3926  ATMR_RecordSplitEvent(serv_ptr, crid_str, start_time,
3927  ADB_GetCridDoNotDelete(crid_rec_list[i]), FALSE);
3928  ATMR_RecordSplitEvent(serv_ptr, crid_str, start_time,
3929  ADB_GetCridDoNotDelete(crid_rec_list[i]), TRUE);
3930  }
3931  else
3932  {
3933  /* Delete the record as it's no longer valid */
3934  ADB_DeleteCridRecord(crid_rec_list[i]);
3935  }
3936  }
3937  else
3938  {
3939  /* Check whether this CRID record should now be deleted from the record list */
3940  eit_date = ADB_GetCridEitDate(crid_rec_list[i]);
3941 
3942  if (gmt_date - eit_date >= CRID_DATE_TIMEOUT)
3943  {
3944  APP_PRINT_PVR_FP((" %d: CRID record for \"%s\" has expired, GMT=%d, last seen=%d", i,
3945  ADB_GetCridProgrammeName(crid_rec_list[i]), gmt_date, eit_date));
3946  ADB_DeleteCridRecord(crid_rec_list[i]);
3947  }
3948  else
3949  {
3950  if (ADB_IsProgrammeCrid(crid_rec_list[i]))
3951  {
3952  /* Check whether the event for this CRID is now in the EIT */
3953  event_ptr = ADB_FindEventFromCrid(crid_str, NULL, &serv_ptr);
3954  if (event_ptr != NULL)
3955  {
3956  /* Set the event to be recorded */
3957  ATMR_RecordEvent(serv_ptr, event_ptr, crid_str, NULL, FALSE, TRUE,
3958  ADB_GetCridDoNotDelete(crid_rec_list[i]));
3959 
3960  /* The CRID record can now be deleted */
3961  ADB_DeleteCridRecord(crid_rec_list[i]);
3962  }
3963  }
3964  else if (ADB_IsSeriesCrid(crid_rec_list[i]))
3965  {
3966  APP_PRINT_PVR_FP((" %d: Series, CRID=\"%s\" for \"%s\"", i,
3967  ADB_GetCridString(crid_rec_list[i]), ADB_GetCridProgrammeName(crid_rec_list[i])));
3968  APVR_RecordSeries(crid_rec_list[i]);
3969  }
3970  else if (ADB_IsRecommendationCrid(crid_rec_list[i]))
3971  {
3972  APP_PRINT_PVR_FP((" %d: Recommendation, CRID=\"%s\" for \"%s\"", i,
3973  ADB_GetCridString(crid_rec_list[i]), ADB_GetCridProgrammeName(crid_rec_list[i])));
3974  APVR_RecordRecommendations(crid_rec_list[i]);
3975  }
3976  else
3977  {
3978  APP_PRINT_PVR_FP((" %d: Unrecognised type of CRID record! CRID=\"%s\" for \"%s\"", i,
3979  ADB_GetCridString(crid_rec_list[i]), ADB_GetCridProgrammeName(crid_rec_list[i])));
3980  }
3981  }
3982  }
3983  }
3984 
3985  if (crid_rec_list != NULL)
3986  {
3987  STB_AppFreeMemory(crid_rec_list);
3988  }
3989 
3990 #ifdef APP_PRINT_PVR_FP
3991  if (num_crid_recs > 0)
3992  {
3993  APP_PRINT_PVR_FP((" Finished processing %d CRID records", num_crid_recs));
3994  }
3995 #endif
3996 
3997  FUNCTION_FINISH(ProcessCridRecords);
3998 }
3999 
4000 #ifdef COMMON_INTERFACE
4001 /*!**************************************************************************
4002  * @brief Creates a new private timer that will expire the given number of seconds
4003  * after the timer is created
4004  * @param seconds - number of seconds until the timer expires
4005  * @return timer handle
4006  ****************************************************************************/
4007 static U32BIT NewCountdownTimer(U32BIT seconds)
4008 {
4009  S_TIMER_INFO timer_info;
4010  U32BIT handle;
4011  U16BIT days;
4012  U8BIT hrs, mins, secs;
4013 
4014  FUNCTION_START(NewCountdownTimer);
4015 
4016  days = seconds / (3600 * 24);
4017  hrs = (seconds / 3600) % 24;
4018  mins = (seconds / 60) % 60;
4019  secs = seconds % 60;
4020 
4021  ATMR_InitialiseTimer(&timer_info, TIMER_TYPE_PRIVATE, NULL, NULL);
4022 
4023  timer_info.start_time = STB_GCCalculateDHMS( STB_GCNowDHMSGmt(), DHMS_CREATE(days,hrs,mins,secs), CALC_ADD);
4024 
4025  handle = ATMR_AddTimer(&timer_info);
4026 
4027  FUNCTION_FINISH(NewCountdownTimer);
4028 
4029  return(handle);
4030 }
4031 #endif
4032 
4033 
4034 //**************************************************************************************************
4035 // End of File
4036 //**************************************************************************************************
4037 
U8BIT APVR_GetPlaybackPath(void)
Returns the path currently acquired fro playback.
Definition: ap_pvr.c:3189
void APVR_SlowMoPlay(void)
Play in slow mothing mode.
Definition: ap_pvr.c:1519
void APVR_RecordSeries(void *crid_ptr)
Seaches the schedule for events that are part of the given series and that haven&#39;t already been recor...
Definition: ap_pvr.c:3267
BOOLEAN APVR_DeleteAllSelectedRecordings(U32BIT *handles, U16BIT num_handles)
Delete all the recordings marked as selected but not locked in the given list, including all files as...
Definition: ap_pvr.c:2348
BOOLEAN STB_PVRCreateRecording(U16BIT disk_id, U8BIT *name, U32BIT *handle)
Create a new recording and return the handle.
Definition: stbpvr.c:846
Application level CI control functions.
U32DHMS ADB_GetEventDuration(void *event_ptr)
Returns a value representing the duration of the given event.
Definition: ap_dbacc.c:8513
U32DHMS STB_GCCalculateDHMS(U32DHMS dhms, U32DHMS period, E_STB_GC_CALCTYPE calc)
Calculates the date/time when the period is added/subtracted to/from dhms.
Definition: stbgc.c:2136
void STB_PVRPlayMedium(U8BIT decoder)
Sets play speed to medium (1x) - has no effect when decoding from demux.
Definition: stbpvr.c:5570
BOOLEAN STB_PVRRecordingGetParentalLock(U32BIT handle)
Returns the parental lock state of the given recording.
Definition: stbpvr.c:2760
U8BIT * ADB_GetEventSeriesCrid(U8BIT index, void *serv_ptr, void *event_ptr)
Returns the full series CRID of the given event The returned string should be freed using STB_AppFree...
Definition: ap_dbacc.c:9355
BOOLEAN STB_PVRCanDiskBeUsed(U16BIT disk_id)
Checks whether the given disk can be used for PVR functions.
Definition: stbpvr.c:551
BOOLEAN STB_DPIsRecording(U8BIT path, U32BIT *handle)
Returns status of recording on specified path.
Definition: stbdpc.c:2189
U32BIT STB_DSKGetUsed(U16BIT disk_id)
Returns the amount of space used on the disk.
void STB_PVRRecordingSetServiceName(U32BIT handle, U8BIT *service_name)
Sets the service name for a recording and saves the database file.
Definition: stbpvr.c:1987
U8BIT STB_DPAcquirePlaybackPath(void *service)
Acquires a decode path and all the required resources (demux, audio and video decoders) for playing b...
Definition: stbdpc.c:679
void STB_PVRRecordingSetOtherCrid(U32BIT handle, U8BIT *crid)
Sets the series/recommendation CRID for a recording and saves the database file.
Definition: stbpvr.c:1626
macros and function prototypes for public use
BOOLEAN APVR_IsInitialised(void)
Use to query whether the PVR function is available and ready to be used.
Definition: ap_pvr.c:741
void APVR_GetDiskMbyte(U16BIT disk_id, U32BIT *used_mbyte_ptr, U32BIT *free_mbyte_ptr, U32BIT *size_mbyte_ptr)
Ges disk space in Mbytes: used, free and size.
Definition: ap_pvr.c:3054
U8BIT STB_DPGetPathCISlot(U8BIT path)
Returns the CI slot id associated with the given path.
Definition: stbdpc.c:1082
void STB_PVRStartRecordPaused(U8BIT path, U32BIT timeshift_seconds)
Set to start recording in paused mode for timeshift recording.
Definition: stbpvr.c:5004
void * ADB_GetServiceTransportPtr(void *s_ptr)
Returns a pointer to the service&#39;s parent transport record.
Definition: ap_dbacc.c:5999
BOOLEAN STB_CiCcAuthenticated(U8BIT slot_id)
Tell whether authenticated CI+ module is in the slot.
Definition: stbcicc.c:374
BOOLEAN APVR_IsTimeshiftRecording(U32BIT handle)
Checks whether the given recording handle is the timeshift recording handle.
Definition: ap_pvr.c:2504
BOOLEAN ATMR_RecordSplitEvent(void *serv_ptr, U8BIT *prog_crid, U32DHMS start_date_time, BOOLEAN do_not_delete, BOOLEAN search_forward)
Searches for events within 3 hours of the given start date/time for an event with the given programme...
Definition: ap_tmr.c:2653
void * ADB_GetEvent(void *serv_ptr, U16BIT event_id)
Returns a copy of the event with the given event ID on the given service.
Definition: ap_dbacc.c:8026
BOOLEAN STB_DPIsLivePath(U8BIT path)
Is the given decode path being used for live viewing.
Definition: stbdpc.c:1297
U8BIT * STB_GCGetDateString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_DATETYPE format)
Supplies specifed date as local date string, in format requested.
Definition: stbgc.c:1809
void APVR_EitUpdated(void)
Ensures that any EIT updates are processed to handle scenarios such as checking for new series record...
Definition: ap_pvr.c:3770
BOOLEAN APVR_DeleteRecording(U32BIT handle)
Delete the given recording, including all files associated with it and remove it from the database of...
Definition: ap_pvr.c:2320
BOOLEAN ADB_GetServiceLockedFlag(void *s_ptr)
Returns the status of the &#39;locked&#39; flag of the given service, which is used by the parental control...
Definition: ap_dbacc.c:5805
U8BIT APVR_GetTotalSpacePercentUsed(U16BIT disk_id)
get total percentage of recording space used
Definition: ap_pvr.c:2972
Application configuration.
void APVR_ReleaseActiveRecordingList(U32BIT *handle_list)
Frees the arrays allocated by APVR_GetActiveRecordingList.
Definition: ap_pvr.c:2275
Application database control.
U32DHMS STB_GCNowDHMSGmt(void)
Reads the current GMT date code and time.
Definition: stbgc.c:2264
U32BIT STB_OSGetClockDiff(U32BIT timestamp)
Get Difference between Given Time and Current Time.
Header file - macros and function prototypes for public use.
void ACTL_TuneOff(U8BIT path)
Stops tuning on the given path.
Definition: ap_cntrl.c:2079
U32DHMS ADB_GetCridDateTime(void *c_ptr)
Returns a value representing the date & time held in the given CRID record.
Definition: ap_dbacc.c:10418
Header file for NVM data handling functions.
BOOLEAN APVR_CheckSpaceForDuration(U16BIT disk_id, U8BIT hours, U8BIT mins)
Check if there is enough space for the recording of the given duration to take place.
Definition: ap_pvr.c:2917
S16BIT STB_PVRGetPlaySpeed(U8BIT audio_decoder, U8BIT video_decoder)
Returns the current playback speed.
BOOLEAN ADB_GetServiceDoNotScramble(void *s_ptr)
Returns the do_not_scramble flag for the service which is based on the presence of an FTA descriptor...
Definition: ap_dbacc.c:5727
void ADB_ReleaseStreamList(void **streamlist_ptr, U16BIT num_entries)
Frees the memory allocated for a stream list using ADB_GetStreamList.
Definition: ap_dbacc.c:7052
U8BIT STB_DPIsCISlotInUse(U8BIT start_path, U8BIT slot_id, U8BIT ignore_path)
Checks whether a given CI slot is in use.
Definition: stbdpc.c:1109
BOOLEAN STB_PVRRecordingSetGuidance(U32BIT handle, U8BIT *text)
Sets the guidance text of a recording.
Definition: stbpvr.c:2796
U32DHMS ADB_GetEventStartDateTime(void *event_ptr)
Returns a value representing the date and time of the start of the given event.
Definition: ap_dbacc.c:8441
void * STB_AppGetMemory(U32BIT bytes)
Attempts to allocate memory from the application heap.
Definition: stbheap.c:651
void STB_CiCcGetUsageRulesInfo(U8BIT slot_id, U16BIT service_id, U8BIT uri[CIP_URI_LEN])
Return the current URI for the given service.
Definition: stbcicc.c:449
BOOLEAN APVR_HandlePrivateTimer(U32BIT timer_handle)
Deals with any private timers started by the PVR module.
Definition: ap_pvr.c:3619
void STB_DPStartSI(U8BIT path)
Requests start of SI engine, mode is determined by flags in general control.
Definition: stbdpc.c:2934
U32BIT ATMR_GetRecordingHandle(U32BIT handle)
Returns the recording handle associated with a PVR recording timer.
Definition: ap_tmr.c:1643
void ATMR_DeleteRecordingTimer(U32BIT recording_handle)
Delete the PVR record timer with the given recording handle.
Definition: ap_tmr.c:2382
U8BIT * ADB_GetEventProgrammeCrid(void *serv_ptr, void *event_ptr)
Returns the programme CRID of the given event (excluding IMI) The returned string should be freed usi...
Definition: ap_dbacc.c:9268
void STB_DPStopRecording(U8BIT path)
Requests stop of recording on specified path.
Definition: stbdpc.c:2164
void STB_PVRPlayFaster(U8BIT decoder, BOOLEAN include_slow_speeds)
Increase play speed - has no effect when decoding from demux.
Definition: stbpvr.c:5677
Definition: ap_tmr.h:97
void APVR_ReleasePlayList(U32BIT *handle_list, U8BIT **name_list, U32BIT *rec_status_list, U32BIT *locked_list, U32BIT *selected_list, U32BIT *split_list)
Frees the arrays allocated by APVR_GetPlayList.
Definition: ap_pvr.c:978
void APVR_JTLPlay(void)
quick replay current playing recording
Definition: ap_pvr.c:1592
U8BIT * ADB_GetEventDescription(void *event_ptr)
Returns the short event description text of the event as a UTF-8 string. The returned string should b...
Definition: ap_dbacc.c:8773
BOOLEAN STB_PVRFindNextSplitRecording(U32BIT curr_handle, U32BIT *next_handle)
Returns the handle of a split event recording that follows on from curr_handle.
Definition: stbpvr.c:1142
BOOLEAN STB_CiCcSendRecordStop(U8BIT slot_id)
Called by the app when a recording is stopped or completes.
Definition: stbcicc.c:1529
U8BIT STB_DPGetPathVideoDecoder(U8BIT path)
Returns the video decoder ID acquired by the given decode path.
Definition: stbdpc.c:1757
BOOLEAN APVR_CheckSpaceDuration(U16BIT disk_id, U32BIT duration)
Check if there is enough space for the recording of the given duration to take place.
Definition: ap_pvr.c:2958
BOOLEAN APVR_PlayRecording(U32BIT recording_handle, BOOLEAN resume_playback, void *monitor_service)
Starts playback of the given recording.
Definition: ap_pvr.c:1031
BOOLEAN STB_PVRRecordingGetLocked(U32BIT handle)
Returns whether the given recording is locked.
Definition: stbpvr.c:2577
BOOLEAN ADB_IsRecommendationCrid(void *c_ptr)
Returns TRUE if the CRID record given represents a recommendation.
Definition: ap_dbacc.c:10309
void STB_DPSetSearchMode(U8BIT path, BOOLEAN state)
Writes SI search mode flag into decode path store.
Definition: stbdpc.c:3981
void STB_PVRStartPlayRunning(U8BIT decoder)
Set to start playback in running mode.
Definition: stbpvr.c:4008
PVR messages database access functions header file.
void APVR_TrickModeMuteOn(void)
Mute for trick mode.
Definition: ap_pvr.c:1739
Header file - Function prototypes for A/V control.
BOOLEAN APVR_GetRecordingHandle(U8BIT path, U32BIT *recording_handle_ptr)
Returns the handle of the recording taking place on the given decode path.
Definition: ap_pvr.c:2870
void APVR_SetStartPadding(S32BIT padding)
Sets the default time that will be added to the start of all recording timers created after this valu...
Definition: ap_pvr.c:788
BOOLEAN ACTL_CanServiceBeViewed(void *s_ptr)
Checks whether there&#39;s a tuner available to view the given service. This takes into account whether t...
Definition: ap_cntrl.c:5044
U16BIT ADB_GetStreamPID(void *stream_ptr)
Returns the PID for the given stream.
Definition: ap_dbacc.c:7157
S32BIT APVR_GetEndPadding(void)
Returns the current setting for the end padding time added to all recording timers.
Definition: ap_pvr.c:827
void STB_GCConvertDateTime(U16BIT code, U8BIT hour, U8BIT min, U8BIT secs, U16BIT *rcode, U8BIT *rhour, U8BIT *rmin, U8BIT *rsecs, E_STB_GC_CONVTYPE conv)
Converts specified date / time to another.
Definition: stbgc.c:1591
U32BIT APP_NvmRead(E_NVM_ITEMS nvm_item)
Returns the current value for the given DVB setting.
Definition: app_nvm.c:562
void APVR_EncryptRecordings(BOOLEAN state)
Used to set whether all recordings should be encrypted or not. The default is that recordings aren&#39;t ...
Definition: ap_pvr.c:3818
BOOLEAN APVR_CheckSpaceForEvent(U16BIT disk_id, void *event_ptr)
Checks if there is enough space for the recording of the given event to take place.
Definition: ap_pvr.c:2898
BOOLEAN STB_PVRRecordingSetParentalLock(U32BIT handle, BOOLEAN state)
Sets the parental lock state of a recording.
Definition: stbpvr.c:2714
U8BIT STB_AVGetAudioVolume(U8BIT path)
Returns the current volume of the main audio output.
BOOLEAN STB_CiCaSystemSupported(U8BIT slot_id, U8BIT *pmt_data)
Tell whether CA descriptors were found in PMT and that CA system is supported.
Definition: stbcica.c:247
BOOLEAN STB_PVRSetRecordingPids(U8BIT path, U16BIT num_pids, S_PVR_PID_INFO *pid_array)
Saves (takes a copy of) the array of pids to be recorded.
Definition: stbpvr.c:4140
BOOLEAN STB_PVRDestroyRecording(U32BIT handle)
Completely destroys a recording by deleting all files and removing it from the list of recordings...
Definition: stbpvr.c:948
void * ADB_FindServiceByIds(U16BIT onet_id, U16BIT tid, U16BIT sid)
Returns a pointer to the service matching the given IDs.
Definition: ap_dbacc.c:4071
BOOLEAN STB_OSDestroyQueue(void *queue)
Destroy Queue.
void STB_OSDestroyTask(void *task)
Delete Task must be called upon termination of each task as it frees all OS specific resources alloca...
U8BIT * ADB_GetServicePMTData(void *s_ptr, U16BIT *data_len)
Returns the current PMT data for the given service.
Definition: ap_dbacc.c:11293
BOOLEAN APVR_IsTimeshiftStarted(void)
Checks whether timeshift has been started, which includes both recording and playback.
Definition: ap_pvr.c:2454
Application timer functions and defines.
CI Conditional Access.
void APP_NvmSave(E_NVM_ITEMS nvm_item, U32BIT new_value, BOOLEAN write_to_flash_now)
Sets the current value for the given DVB setting.
Definition: app_nvm.c:634
void ADB_GetNowNextEvents(void *serv_ptr, void **now_event, void **next_event)
Makes copies of the now and/or next events (EITp/f) for the given service. The returned events should...
Definition: ap_dbacc.c:7587
BOOLEAN STB_PVRIsInitialised(void)
Returns Initialised status.
Definition: stbpvr.c:480
BOOLEAN STB_PVRIsValidHandle(U32BIT handle)
Determines whether the given handle is in the recording database.
Definition: stbpvr.c:814
BOOLEAN STB_DPReleasePath(U8BIT path, E_STB_DP_RES_OWNER owner)
Releases the decode path and all resources no longer needed. The path won&#39;t be released if the path i...
Definition: stbdpc.c:785
BOOLEAN APVR_SetPlaybackTime(U32BIT position_in_secs)
Sets returns the number of seconds in playback buffer.
Definition: ap_pvr.c:3162
Header file - macros and function prototypes for public use.
BOOLEAN STB_PVRRecordingSetSelected(U32BIT handle, BOOLEAN state)
Sets the selected state of a recording.
Definition: stbpvr.c:2613
BOOLEAN STB_IsStringEmpty(U8BIT *string_ptr)
Checks for a string of only spaces.
Definition: stbuni.c:2113
S16BIT APVR_GetPlaySpeed(void)
Returns the current play speed as a signed percentage value representing the speed, where 100% is normal playback speed.
Definition: ap_pvr.c:1676
void APVR_SetNotifyTime(U16BIT notify_time)
Sets the time, in seconds, when an event will be sent as a notification that a recording is about to ...
Definition: ap_pvr.c:762
void STB_ERSendEvent(BOOLEAN latched, BOOLEAN repeat, U16BIT path_class, U16BIT type, void *data, U32BIT data_size)
Sends an event to event reporting control module.
Definition: stberc.c:571
BOOLEAN STB_PVRRecordingGetTriplet(U32BIT handle, U16BIT *serv_id, U16BIT *ts_id, U16BIT *orig_net_id)
Read the DVB triplet (service id, transport id, orig net id) for a recording.
Definition: stbpvr.c:3975
CI Content Control.
void STB_PVRDiskUsed(U16BIT disk_id, U8BIT *hours, U8BIT *mins)
Returns disk space used in hours and minutes.
Definition: stbpvr.c:5802
BOOLEAN STB_PVRSetRecoringTriplet(U8BIT path, U16BIT serv_id, U16BIT ts_id, U16BIT orig_net_id)
Saves the DVB triplet of the service to be recorded.
Definition: stbpvr.c:4222
void STB_PVRRecordingSetCrid(U32BIT handle, U8BIT *crid)
Sets the programme CRID for a recording and saves the database file.
Definition: stbpvr.c:2269
void ATMR_EitUpdated(void)
Checks each recording timer that&#39;s linked to an event to see whether the event is still in the schedu...
Definition: ap_tmr.c:2102
BOOLEAN ACTL_ParentalControlEnabled(void)
Returns whether parental control is enabled. This will also return TRUE if parental control has been ...
Definition: ap_cntrl.c:3115
void ADB_GetStreamList(void *serv_ptr, ADB_STREAM_LIST_TYPE stream_list_type, void ***streamlist_ptr, U16BIT *num_entries_ptr)
Allocates and returns an array of the streams of the given type and for the given service...
Definition: ap_dbacc.c:6882
BOOLEAN APVR_FindNextSplitEvent(U32BIT curr_handle, U32BIT *next_handle)
If the current playback recording is a split event then the next chronological part of the event is f...
Definition: ap_pvr.c:3583
U32BIT STB_PVRDiskSize(U16BIT disk_id)
Returns disk size in MBytes.
Definition: stbpvr.c:5872
U8BIT STB_DPGetNumPaths(void)
Returns the maximum number of decode paths.
Definition: stbdpc.c:532
BOOLEAN STB_PVRRecordingGetLength(U32BIT handle, U8BIT *length_hours, U8BIT *length_mins, U8BIT *length_secs, U32BIT *rec_size_kb)
Returns the length in time and size in KB of the recording with the given handle. ...
Definition: stbpvr.c:1535
void STB_PVRPlayFrameInc(U8BIT decoder)
Increments play by one frame - has no effect when decoding from demux.
Definition: stbpvr.c:5514
void STB_PVRStopRecording(U8BIT path)
Stop the PVR recording.
Definition: stbpvr.c:4858
void ADB_ReleaseServiceList(void **slist, U16BIT num_servs)
Frees a list of services returned from one of the functions that returns a service list...
Definition: ap_dbacc.c:3556
void APVR_NormalPlay(void)
If playback has been paused or is subject to some trick mode, calling this function will result in pl...
Definition: ap_pvr.c:1283
U8BIT STB_DPGetLivePath(void)
Returns the ID of the decode path being used for live viewing.
Definition: stbdpc.c:1271
BOOLEAN APVR_IsRecordingInProgress(void)
Returns TRUE if there are any recordings currently in progress.
Definition: ap_pvr.c:2798
void APVR_Terminate(void)
Destroy all PVR resources: filters, recordings etc.
Definition: ap_pvr.c:706
void APVR_FFPlay(void)
If paused, playback will go into the first available slow motion speed in a forwards direction...
Definition: ap_pvr.c:1415
BOOLEAN APVR_StopRecording(U32BIT recording_handle)
Stops the given recording.
Definition: ap_pvr.c:2156
void * ATMR_RecordEvent(void *serv_ptr, void *event_ptr, U8BIT *prog_crid, U8BIT *series_crid, BOOLEAN is_series, BOOLEAN check_alternatives, BOOLEAN do_not_delete)
Adds a timer to perform a recording based on the given event and service. Conflicts are checked and a...
Definition: ap_tmr.c:2466
Header file - EBU Teletext driver.
void STB_PVRStartPlayPaused(U8BIT decoder)
Set to start playback in paused mode.
Definition: stbpvr.c:4030
void APVR_UnselectAllRecordings(U32BIT *handles, U16BIT num_handles)
Un-select all recordings.
Definition: ap_pvr.c:2377
void STB_ReleaseUnicodeString(U8BIT *string)
Releases the specified unicode string, freeing associated heap resources.
Definition: stbuni.c:1955
U8BIT * ADB_GetCridProgrammeName(void *c_ptr)
Returns the programme name field of the given CRID record. The returned string should be freed using ...
Definition: ap_dbacc.c:10197
U8BIT APVR_StartPauseRecord(void)
Starts recording the live service ready for timeshift playback. The recording may not have started wh...
Definition: ap_pvr.c:2531
U16BIT ADB_GetTransportTid(void *t_ptr)
Returns the transport id of the given transport.
Definition: ap_dbacc.c:2325
BOOLEAN APVR_IsEventInRecordList(U8BIT *prog_crid)
Determines whether the given programme CRID is already in the list of recorded events.
Definition: ap_pvr.c:3247
BOOLEAN APVR_StartNewRecording(U16BIT disk_id, U8BIT path, U8BIT *recording_name, U16BIT event_id, U8BIT *prog_crid, U8BIT *other_crid, U32BIT *rec_handle)
Starts a recording after any tuning has completed and sets the info to be stored with it...
Definition: ap_pvr.c:1837
U16BIT ADB_GetServiceLcn(void *s_ptr)
Returns the logical channel number assigned to the given service.
Definition: ap_dbacc.c:4940
U16BIT APVR_GetTimeshiftBufferSize(void)
Returns the maximum size of the timeshift buffer in minutes.
Definition: ap_pvr.c:2443
BOOLEAN STB_PVRIsPlayAudio(U8BIT decoder)
Returns TRUE if play contains audio data.
Definition: stbpvr.c:4115
U8BIT * ADB_GetEventGuidance(void *event_ptr, void *serv_ptr, U8BIT *type, U8BIT *mode)
Returns the guidance text for an event, either from the event itself or the event&#39;s service...
Definition: ap_dbacc.c:8936
Debug functions header file.
Header file - Function prototypes for linked lists.
U32BIT ATMR_FindTimerFromCrid(U8BIT *prog_crid)
Searches the timers for a recording timer with the given programme CRID.
Definition: ap_tmr.c:3000
Header file - macros and function prototypes for public use.
void STB_AVSetAudioVolume(U8BIT path, U8BIT vol)
Sets the volume of the main audio output.
BOOLEAN APVR_SetPlaySpeed(S16BIT speed)
Set current play speed as a signed percentage value representing the speed, where 100% is normal play...
Definition: ap_pvr.c:1710
Header file - macros and function prototypes for public use.
U16BIT ADB_GetCridService(void *c_ptr)
Returns the service ID held in the given CRID record.
Definition: ap_dbacc.c:10448
BOOLEAN APVR_IsDecodingFile(void)
Returns the PVR play status.
Definition: ap_pvr.c:1156
void * ADB_GetTunedService(U8BIT path)
Returns the tuned service for the given decode path.
Definition: ap_dbacc.c:6068
BOOLEAN STB_PVRResumeRecording(U8BIT path)
Resumes a recording after it&#39;s been paused.
Definition: stbpvr.c:4821
void STB_GCGetGMTDateTime(U16BIT *code, U8BIT *hour, U8BIT *min, U8BIT *secs)
Reads the current GMT date code and time.
Definition: stbgc.c:1372
BOOLEAN ADB_IsSeriesCrid(void *c_ptr)
Returns TRUE if the CRID record given represents a series.
Definition: ap_dbacc.c:10279
BOOLEAN STB_PVRUpdateRecordingPids(U8BIT path, U16BIT num_pids, S_PVR_PID_INFO *pid_array)
Saves (takes a copy of) the array of pids to be recorded and pass them to the platform.
Definition: stbpvr.c:4182
U16BIT ADB_GetNumStreams(void *serv_ptr, ADB_STREAM_LIST_TYPE stream_list_type)
Returns the number of streams of the given type for the given service.
Definition: ap_dbacc.c:6845
BOOLEAN STB_PVRIsPlayPause(U8BIT decoder)
Returns TRUE if play is paused trick mode.
Definition: stbpvr.c:5312
void STB_PVREncryptRecording(U8BIT path, BOOLEAN state)
Sets whether a recording should be encrypted. Must be set before the recording is started...
Definition: stbpvr.c:5086
void APVR_SetEndPadding(S32BIT padding)
Sets the default time that will be added to the end of all recording timers created after this value ...
Definition: ap_pvr.c:803
S32BIT APVR_GetStartPadding(void)
Returns the current setting for the start padding time added to all recording timers.
Definition: ap_pvr.c:816
void ASI_SetAppSiMode(U8BIT path, E_APP_SI_MODE si_mode)
Sets application SI mode - used before STB_DPStartSI() is called.
Definition: ap_si.c:9534
U16BIT ADB_GetTransportOriginalNetworkId(void *t_ptr)
Returns the original network id of the given transport.
Definition: ap_dbacc.c:2385
void APVR_PidsUpdated(U8BIT path)
This function should be called when there&#39;s an update to the PIDs for a service that&#39;s being recorded...
Definition: ap_pvr.c:3791
Header file - Function prototypes for Event Reporting.
void APVR_SetTimeshiftBufferSize(U16BIT time_in_mins)
Sets the size of the timeshift buffer so that it&#39;s able to store a recording of the given length befo...
Definition: ap_pvr.c:2431
Header for STB unicode string handling routines.
BOOLEAN STB_PVRFindRecordingFromCrid(U8BIT *prog_crid, U32BIT *handle)
Returns the handle of the recording with the given programme CRID.
Definition: stbpvr.c:1105
void APVR_PausePlay(void)
Pause playback.
Definition: ap_pvr.c:1377
U8BIT * STB_PVRRecordingGetName(U32BIT handle)
Gets the name for a recording.
Definition: stbpvr.c:1457
BOOLEAN STB_PVRPauseRecording(U8BIT path)
Pauses recording after it&#39;s been started.
Definition: stbpvr.c:4790
void * ADB_FindEventFromCrid(U8BIT *prog_crid, void *original_event_ptr, void **serv_ptr)
Finds an alternative event for the given programme CRID and returns a pointer to a copy of the event ...
Definition: ap_dbacc.c:9535
U8BIT STB_DPGetPathAudioDecoder(U8BIT path)
Returns the audio decoder ID acquired by the given decode path.
Definition: stbdpc.c:1734
U8BIT ACTL_TuneToService(U8BIT path, S_ACTL_OWNER_INFO *owner_info, void *s_ptr, BOOLEAN override_lock, BOOLEAN for_live)
Starts the process of tuning to the specified service. If the service is to be tuned on the live path...
Definition: ap_cntrl.c:1651
Glue layer between DVB and conditional access systems.
void APVR_StopPlay(BOOLEAN return_to_live)
Stops playback and optionally returns to live TV.
Definition: ap_pvr.c:1304
U32BIT STB_DSKGetSize(U16BIT disk_id)
Returns the size (capacity) of the disk.
void ADB_GetServiceList(U32BIT list_type, void ***slist_ptr, U16BIT *num_entries_ptr)
Allocates and returns a list of all services in the database for the given list type.
Definition: ap_dbacc.c:3249
BOOLEAN APVR_IsTimeshiftRecordingPath(U8BIT path)
Checks whether the given path is the one that&#39;s being used for timeshift recording.
Definition: ap_pvr.c:2479
void STB_CAReleaseRecordingPids(U16BIT *pid_array, U16BIT num_pids)
Called to free the array of PIDs allocated by STB_CAGetRecordingPids.
Definition: ca_glue.c:382
U8BIT APVR_StartPausePlay(void)
Starts playback of a live timeshift recording started with APVR_StartPauseRecord. This function shoul...
Definition: ap_pvr.c:2644
U16BIT ADB_GetServiceId(void *s_ptr)
Returns the signalled service id of the given service.
Definition: ap_dbacc.c:4960
BOOLEAN STB_PVRPlaySetPosition(U8BIT audio_decoder, U8BIT video_decoder, U32BIT position_in_seconds)
Sets the playback position after playback has started (i.e. jump to bookmark)
void STB_PVRRecordingSetName(U32BIT handle, U8BIT *name)
Sets the name for a recording.
Definition: stbpvr.c:1416
void STB_PVRRecordingSetExtendedDescription(U32BIT handle, U8BIT *description)
Sets the extended description for a recorded programme.
Definition: stbpvr.c:2164
BOOLEAN ACTL_IsTuned(U8BIT path)
Returns whether the given path is currently tuned.
Definition: ap_cntrl.c:1974
application level SI task
void APVR_Initialise(void)
Initialise all PVR resources: filters, recordings etc.
Definition: ap_pvr.c:653
U32BIT APVR_GetPlaybackHandle(void)
Returns the handle of the recording currently being played back.
Definition: ap_pvr.c:1145
Application stb layer control.
U8BIT APVR_PrepareNewRecording(U16BIT onet_id, U16BIT trans_id, U16BIT service_id, BOOLEAN *new_tuned_service)
Acquires a decode path for recording the given service and tunes to it.
Definition: ap_pvr.c:1793
void ADB_GetCridRecordList(void ***clist_ptr, U16BIT *num_entries_ptr, BOOLEAN inc_series_crids, BOOLEAN inc_rec_crids, BOOLEAN inc_prog_crids)
Creates an array of CRID record pointers to pass back to the caller with the number of entries in the...
Definition: ap_dbacc.c:10531
BOOLEAN STB_OSWriteQueue(void *queue, void *msg, U16BIT msg_size, U16BIT timeout)
Write a message to the queue.
Header file - Function prototypes for operating system.
System Wide Global Technical Data Type Definitions.
BOOLEAN APVR_IsRecordingHandle(U8BIT path, U32BIT recording_handle)
Returns TRUE if given recording handle is still in progress on the given decode path.
Definition: ap_pvr.c:2838
void STB_DPStopSI(U8BIT path)
Requests stop of SI engine.
Definition: stbdpc.c:3076
U16BIT APVR_GetNotifyTime(void)
Returns the current recording notification time in seconds.
Definition: ap_pvr.c:775
S32BIT ACI_ReadPinForSlot(U8BIT slot_id)
Checks if a pin has been saved for the CAM in the given slot and returns it.
Definition: ap_ci.c:1714
void STB_PVRDiskFree(U16BIT disk_id, U8BIT *hours, U8BIT *mins)
Returns disk space free in hours and minutes.
Definition: stbpvr.c:5828
void STB_AppFreeMemory(void *addr)
Releases previously allocated application heap memory.
Definition: stbheap.c:781
Application level HBBTV callback functions.
U16BIT ADB_GetCridEitDate(void *c_ptr)
Returns the EIT update date contained in the given CRID record.
Definition: ap_dbacc.c:10478
void APVR_QRPlay(void)
quick replay current playing recording
Definition: ap_pvr.c:1571
Header file - macros and function prototypes for public use.
void STB_PVRSavePlayPosition(U8BIT path)
Saves the bookmark holding the playback position. This bookmark is used to resume a playback when STB...
Definition: stbpvr.c:3813
BOOLEAN STB_PVRRecordingHasGuidance(U32BIT handle)
Returns whether the given recording has guidance.
Definition: stbpvr.c:2841
U8BIT * ADB_GetCridString(void *c_ptr)
Returns the CRID string from the given CRID record. The returned value should not be freed...
Definition: ap_dbacc.c:10388
BOOLEAN STB_PVRIsRecording(U8BIT path, U32BIT *handle)
Reads the PVR record status.
Definition: stbpvr.c:4938
U32BIT ATMR_AddTimer(S_TIMER_INFO *info)
Creates a new timer based on the information supplied.
Definition: ap_tmr.c:189
BOOLEAN ATMR_InitialiseTimer(S_TIMER_INFO *timer_info, E_TIMER_TYPE timer_type, void *serv_ptr, void *event_ptr)
Sets up the given timer info structure with default values for the given timer type using the service...
Definition: ap_tmr.c:724
BOOLEAN STB_PVRRecordingGetSelected(U32BIT handle)
Returns whether the given recording is selected.
Definition: stbpvr.c:2646
void STB_PVRReleaseRecordingHandles(U32BIT *handle_array)
Frees the given array of handles allocated by the preceding function.
Definition: stbpvr.c:1087
BOOLEAN STB_PVRIsPlayForward(U8BIT decoder)
Returns TRUE if play is forwards trick mode.
Definition: stbpvr.c:5395
U16BIT STB_PVRGetRecordingHandles(U32BIT **handle_array)
Allocates and returns an array of all the recording handles.
Definition: stbpvr.c:1039
void APVR_GetDiskTime(U16BIT disk_id, U8BIT *used_hour_ptr, U8BIT *used_min_ptr, U8BIT *free_hour_ptr, U8BIT *free_min_ptr, U8BIT *size_hour_ptr, U8BIT *size_min_ptr)
Gets an estimate of disk space in time (hour / min): used, free and size.
Definition: ap_pvr.c:3014
BOOLEAN STB_PVRAddMessage(U8BIT *message)
Adds a message to the end of the list of existing messages.
Definition: stbpvrmsg.c:111
BOOLEAN STB_PVRIsPlayStarted(U8BIT audio_decoder, U8BIT video_decoder)
Returns status of playback with the given decoders.
U16BIT APVR_GetPlayList(U32BIT **handle_list, U8BIT ***name_list, U32BIT **rec_status_list, U32BIT **locked_list, U32BIT **selected_list, U32BIT **split_list)
Returns a list of all the existing recordings that can be played. All the arrays returned will be all...
Definition: ap_pvr.c:853
U32BIT ATMR_FindTimerFromEvent(U16BIT onet_id, U16BIT trans_id, U16BIT serv_id, U16BIT event_id)
Searches the timers for a recording timer with the given event and service IDs.
Definition: ap_tmr.c:2964
void HBBTV_NotifyPlaySpeedChanged(S16BIT speed)
Notify the video broadcast object that the timeshift play speed has changed.
void * STB_OSCreateTask(void(*function)(void *), void *param, U32BIT stack, U8BIT priority, U8BIT *name)
Create a New Task to the calling process. Upon success, the created task runs on its own stack...
void * STB_OSCreateQueue(U16BIT msg_size, U16BIT msg_max)
Create Queue of given number of messages and size of message.
U16BIT ADB_GetServicePCRPid(void *s_ptr)
Returns the PCR PID for the given service.
Definition: ap_dbacc.c:5164
S8BIT STB_CompareStringsIgnoreCase(U8BIT *string1_ptr, U8BIT *string2_ptr)
Compares the contents of the two given ASCII strings and returns the status (as per strcmp) but ignor...
Definition: stbuni.c:2183
BOOLEAN APVR_GetPlaybackElapsedTime(U32BIT handle, U8BIT *hours, U8BIT *mins, U8BIT *secs, U8BIT *progress)
Returns the playback progress in time and as a percentage.
Definition: ap_pvr.c:1227
Header file - Function prototypes for DVB subtitles api.
Header file - Function prototypes for heap memory.
void ADB_GetServiceIds(void *s_ptr, U16BIT *onet_id, U16BIT *trans_id, U16BIT *serv_id)
Returns the original network id, transport id and service id for the given service.
Definition: ap_dbacc.c:4982
void * APVR_GetPlaybackService(void)
A service instance is associated to the playback, this function returns its pointer. The handle can be used, for example, to call ADB_ServiceHasSubtitles as it&#39;s done for live channels.
Definition: ap_pvr.c:3607
void ACTL_StartDecoding(U8BIT path, void *s_ptr)
Sets up and starts decoding for the given service. This is used for PVR playback, but could also be u...
Definition: ap_cntrl.c:2058
BOOLEAN ATMR_DeleteTimer(U32BIT handle)
Deletes the timer with the given handle.
Definition: ap_tmr.c:436
U8BIT * ADB_GetEventExtendedDescription(void *event_ptr)
Returns the extended event description text of the event as a UTF-8 string. The returned string shoul...
Definition: ap_dbacc.c:8841
BOOLEAN STB_PVRStartPlaying(U8BIT path, U32BIT handle, BOOLEAN resume)
Start the PVR playing.
Definition: stbpvr.c:3638
Application header file.
BOOLEAN STB_PVRIsPlaying(U8BIT path, U32BIT *handle)
Reads the PVR play status.
Definition: stbpvr.c:3792
BOOLEAN STB_DPStartRecording(U8BIT path, U32BIT param)
Requests start of recording on specified path.
Definition: stbdpc.c:2112
BOOLEAN STB_OSReadQueue(void *queue, void *msg, U16BIT msg_size, U16BIT timeout)
Read a message from a queue.
Function prototypes for disk functions.
void APVR_TrickModeMuteOff(void)
Unmute for trick mode.
Definition: ap_pvr.c:1762
void HBBTV_NotifyRecordingEvent(U32BIT id, E_HBBTV_RECORDING_EVENT event)
Notifies the HbbTV engine of a recording event.
BOOLEAN ADB_GetEventDoNotScramble(void *event_ptr)
Returns the do_not_scramble flag for the event, which will have been found by looking backwards in th...
Definition: ap_dbacc.c:9057
void ADB_UpdateCridEitDate(void *c_ptr)
Updates the time the CRID was last seen in the EIT.
Definition: ap_dbacc.c:10226
void STB_OSTaskDelay(U16BIT timeout)
Delay Task for Specifed Time Period.
U16BIT STB_GCGetGMTDate(void)
Reads the current GMT date code.
Definition: stbgc.c:1207
void ADB_GetEventSchedule(BOOLEAN include_old_events, void *serv_ptr, void ***elist_ptr, U16BIT *num_entries_ptr)
Allocates and returns an array containing copies of events for the given service from the service&#39;s E...
Definition: ap_dbacc.c:7634
E_PVR_PLAY_STATUS APVR_GetPlayMode(void)
Returns the current play mode according to the current play speed.
Definition: ap_pvr.c:1606
void ACTL_DecodeOff(U8BIT path)
Stops decoding on the given path.
Definition: ap_cntrl.c:2105
U16BIT ADB_GetEventId(void *event_ptr)
Returns the event id for the given event.
Definition: ap_dbacc.c:8970
void STB_CiCcSetRecordOperatingMode(U8BIT slot_id, U32BIT mode, U16BIT service_id)
Sets the record operating mode for the given slot id.
Definition: stbcicc.c:1065
void APVR_StopPauseRecord(BOOLEAN return_to_live)
Stops timeshifted playback and recording and optionally restarts decoding of the live signal...
Definition: ap_pvr.c:2730
void STB_PVRRecordingSetDescription(U32BIT handle, U8BIT *description)
Sets the short description for a recorded programme.
Definition: stbpvr.c:2059
BOOLEAN ADB_IsProgrammeCrid(void *c_ptr)
Returns TRUE if the CRID record given represents a programme (split event)
Definition: ap_dbacc.c:10245
BOOLEAN STB_PVRRecordingGetDateTime(U32BIT handle, U16BIT *date, U8BIT *hours, U8BIT *mins, U8BIT *secs)
Gets the date and time for a recording.
Definition: stbpvr.c:1494
BOOLEAN APVR_IsPlaying(void)
Returns whether playback is in progress.
Definition: ap_pvr.c:1197
void STB_PVRPlaySlower(U8BIT decoder, BOOLEAN include_slow_speeds)
Decrease play speed - has no effect when decoding from demux.
Definition: stbpvr.c:5612
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
U32BIT APVR_GetPauseProgress(void)
Calculates and returns the number of seconds behind live TV.
Definition: ap_pvr.c:3083
void STB_AVBlankVideo(U8BIT path, BOOLEAN blank)
Blanks or unblanks the video display.
void STB_PVRPlayPause(U8BIT decoder)
Pauses play - has no effect when decoding from demux.
Definition: stbpvr.c:5280
BOOLEAN APVR_AreSelectedRecordings(U32BIT *handles, U16BIT num_handles)
Checks if any recording in a list is selected.
Definition: ap_pvr.c:2400
U32BIT APVR_GetPlaybackTime(void)
Calculates and returns the number of seconds in playback buffer.
Definition: ap_pvr.c:3128
U16BIT ADB_GetServicePmtPid(void *s_ptr)
Returns the current PMT PID for the given service.
Definition: ap_dbacc.c:11325
U8BIT * ADB_GetEventName(void *event_ptr)
Returns the name of the event as a UTF-8 string. The returned string should be freed using STB_Releas...
Definition: ap_dbacc.c:8740
void ADB_ReleaseEventList(void **elist, U16BIT num_entries)
Frees all teh events in the given list and all associated memory for those events.
Definition: ap_dbacc.c:7924
U8BIT APVR_GetActiveRecordingList(U32BIT **handle_list)
Returns an array of recordings currently in progress. Use APVR_ReleaseActiveRecordingList to free the...
Definition: ap_pvr.c:2213
U8BIT ACTL_AcquirePathForService(void *s_ptr, BOOLEAN with_decoders, BOOLEAN for_recording, S_ACTL_OWNER_INFO *owner)
Acquires a decode path suitable for tuning to the given service.
Definition: ap_cntrl.c:4897
void STB_PVRUpdateRecordings(BOOLEAN force_load)
Called when a disk is added or removed and updates the disk database and the recordings that are now ...
Definition: stbpvr.c:715
void ADB_DeleteCridRecord(void *c_ptr)
Deletes the given CRID record from the database.
Definition: ap_dbacc.c:10507
BOOLEAN STB_PVRSetPlaySpeed(U8BIT audio_decoder, U8BIT video_decoder, S16BIT speed)
Set the play speed for the specified decoder.
U8BIT * ATMR_GetOtherCrid(U32BIT handle)
Returns a pointer to the other CRID string from a recording timer. This will either be a series or re...
Definition: ap_tmr.c:1553
U16BIT STB_PVRGetDefaultDisk(void)
Returns the set default disk, or finds the first mounted (usable) disk if a default hasn&#39;t been set...
Definition: stbpvr.c:512
void STB_PVRStopPlaying(U8BIT path)
Stop the PVR play back.
Definition: stbpvr.c:3931
BOOLEAN APVR_GetPathRecordingName(U8BIT path, U8BIT **name_ptr)
Get the name of the recording currently taking place on the given decode path.
Definition: ap_pvr.c:2295
U8BIT ADB_GetEventNumSeriesCrids(void *event_ptr)
Returns the number of series CRIDs for the given event.
Definition: ap_dbacc.c:9380
U8BIT * ADB_GetServiceFullName(void *s_ptr, BOOLEAN use_pref_name)
Returns the full name of the given service as a UTF-8 string. The returned string should be freed usi...
Definition: ap_dbacc.c:4833
void ADB_DeleteServiceRec(void *s_ptr)
Deletes the given service from the database.
Definition: ap_dbacc.c:6686
U8BIT * STB_GCGetTimeString(U16BIT code, U8BIT hour, U8BIT min, E_STB_GC_TIMETYPE format)
Supplies specified time as local time string, in format requested.
Definition: stbgc.c:1743
void APVR_FRPlay(void)
If paused, playback will go into the first available slow motion speed in a reverse direction...
Definition: ap_pvr.c:1468
U8BIT * STB_FormatUnicodeString(BOOLEAN strip_DVB_cntrl_char, BOOLEAN *reverse_dir, const U8BIT *const format_ptr,...)
Unicode version of sprintf.
Definition: stbuni.c:2292
Application database access functions.
U16BIT STB_CAGetRecordingPids(U8BIT *pmt_data, U16BIT **pid_array)
This function is called to get an array of PIDs that need to be recorded for the CA system required f...
Definition: ca_glue.c:359
BOOLEAN STB_PVRGetElapsedTime(U8BIT audio_decoder, U8BIT video_decoder, U8BIT *elapsed_hours, U8BIT *elapsed_mins, U8BIT *elapsed_secs)
Returns the elapsed playback time in hours, mins & secs.
BOOLEAN STB_PVRIsBeingRecorded(U32BIT handle)
Returns whether the recording with the given handle is currently being recorded.
Definition: stbpvr.c:2364
ADB_STREAM_TYPE ADB_GetStreamType(void *stream_ptr)
Returns the type of the given stream.
Definition: ap_dbacc.c:7083
void STB_PVRPlayNormal(U8BIT decoder)
Restarts playback (no trick mode) - has no effect when decoding from demux.
Definition: stbpvr.c:5198
BOOLEAN ADB_GetCridDoNotDelete(void *c_ptr)
Returns the value of the do not delete flag for the given CRID record.
Definition: ap_dbacc.c:10358
Header file - macros and function prototypes for public use.
E_STB_GC_WEEKDAY STB_GCGetDateWeekDay(U16BIT code)
Returns the weekday number of the specified date code.
Definition: stbgc.c:1448
BOOLEAN STB_CiCcSendRecordStart(U8BIT slot_id, U16BIT program_number, U8BIT *pin_string)
Called by the app when a recording is to be started on a CA protected service.
Definition: stbcicc.c:1110
BOOLEAN ADB_IsSplitProgrammeCrid(U8BIT *crid)
Returns TRUE if the given CRID represents a split event (i.e. it contains an Instance Metadata Identi...
Definition: ap_dbacc.c:9219
BOOLEAN STB_PVRRecordingGetCrid(U32BIT handle, U8BIT *crid, U16BIT name_len)
Gets the programme CRID for a given recording.
Definition: stbpvr.c:2320
void ADB_ReleaseEventData(void *event_ptr)
Frees any memory allocated for the given event and the event itself.
Definition: ap_dbacc.c:7907
void APVR_RecordRecommendations(void *crid_ptr)
Searches the schedule for events that are part of the given recommendation and that haven&#39;t already b...
Definition: ap_pvr.c:3433