58 #ifdef COMMON_INTERFACE 62 #ifdef INTEGRATE_HBBTV 67 #define MAX_EVENTS 500 69 #define TASK_STACK_SIZE 4096 70 #define TASK_PRIORITY 11 73 #define DBG(x) STB_SPDebugWrite x 82 static void *event_queue;
84 static void *original_alternative_service;
85 static BOOLEAN classify_repeats = FALSE;
94 void* event_handlers_mutex = NULL;
98 static BOOLEAN STBEventHandler(BOOLEAN latched, BOOLEAN repeat, U16BIT path_class, U16BIT type,
99 void *data, U32BIT data_size);
100 static void EventTask(
void *param);
101 static BOOLEAN CheckForAlternativeService(U8BIT alt_serv_type);
102 static BOOLEAN ReturnFromAlternativeService(
void);
114 FUNCTION_START(AEV_Initialise);
130 if ((event_handlers_mutex == NULL) ||
132 (
STB_OSCreateTask(EventTask, NULL, TASK_STACK_SIZE, TASK_PRIORITY, (U8BIT *)
"EventTask") == NULL))
137 original_alternative_service = NULL;
139 FUNCTION_FINISH(AEV_Initialise);
144 void AEV_Terminate(
void)
155 if (event_handlers_mutex)
158 event_handlers_mutex = NULL;
165 BOOLEAN registered = FALSE;
167 if (event_handler && event_handlers_mutex)
172 handler->handler = event_handler;
186 BOOLEAN unregistered = FALSE;
188 if (event_handler && event_handlers_mutex)
195 if (handler->handler == event_handler)
215 classify_repeats = enable;
220 static void NotifyAll(U32BIT event,
void *event_data, U32BIT data_size)
225 if (event_handlers_mutex)
232 handler->handler(event, event_data, data_size);
243 static BOOLEAN STBEventHandler(BOOLEAN latched, BOOLEAN repeat, U16BIT
class, U16BIT type,
244 void *data, U32BIT data_size)
249 FUNCTION_START(STBEventHandler);
251 USE_UNWANTED_PARAM(latched);
255 if (repeat && (
class & EV_CLASS_CAN_REPEAT_FLAG) && classify_repeats)
257 class |= EV_CLASS_IS_REPEAT;
261 event_info.event_code = (U32BIT)(
class << 16) | type;
263 if ((data != NULL) && (data_size > 0))
268 memcpy(event_info.data, data, data_size);
269 event_info.data_size = data_size;
278 event_info.data = NULL;
279 event_info.data_size = 0;
288 FUNCTION_FINISH(STBEventHandler);
296 static void EventTask(
void *param)
309 FUNCTION_START(EventTask);
311 USE_UNWANTED_PARAM(param);
313 DBG((
"EventTask: started"));
319 DBG((
"EventTask: event 0x%08lx, data %p, %lu bytes", event_info.event_code,
320 event_info.data, event_info.data_size));
322 switch (event_info.event_code)
324 case STB_EVENT_TUNE_LOCKED:
325 case STB_EVENT_TUNE_NOTLOCKED:
326 case STB_EVENT_TUNE_SIGNAL_DATA_BAD:
327 case STB_EVENT_TUNE_SIGNAL_DATA_OK:
328 case STB_EVENT_SEARCH_SUCCESS:
329 case STB_EVENT_SEARCH_FAIL:
335 case STB_EVENT_AUDIO_DECODE_STARTED:
336 case STB_EVENT_VIDEO_DECODE_STARTED:
337 case STB_EVENT_AUDIO_DECODE_STOPPED:
338 case STB_EVENT_VIDEO_DECODE_STOPPED:
339 case STB_EVENT_AUDIO_DECODE_UNDERFLOW:
340 case STB_EVENT_VIDEO_DECODE_UNDERFLOW:
341 case STB_EVENT_SAMPLE_DECODE_STOPPED:
342 case STB_EVENT_DECODE_LOCKED:
348 case STB_EVENT_HDMI_CONNECTED:
354 case STB_EVENT_HDMI_DISCONNECTED:
360 case STB_EVENT_OTA_SW_UPGRADE_FOUND:
361 case STB_EVENT_OTA_SW_UPGRADE_NOTFOUND:
362 case STB_EVENT_OTA_SW_UPGRADE_ERROR:
368 case STB_EVENT_DISK_FULL:
371 disk_id = *(U16BIT *)event_info.data;
384 case APP_EVENT_SERVICE_NOT_RUNNING:
389 if (!CheckForAlternativeService(LINK_TYPE_SERVICE_REPLACEMENT))
397 case APP_EVENT_SERVICE_AUDIO_PID_UPDATE:
398 case APP_EVENT_SERVICE_VIDEO_PID_UPDATE:
399 case APP_EVENT_SERVICE_RUNNING:
401 event_serv = *(
void **)event_info.data;
406 if ((original_alternative_service != NULL) &&
407 (event_serv == original_alternative_service))
412 ReturnFromAlternativeService();
429 case APP_EVENT_SERVICE_STREAMS_CHANGED:
431 event_serv = *(
void **)event_info.data;
445 case APP_EVENT_SERVICE_SCRAMBLE_CHANGE:
447 event_serv = *(
void **)event_info.data;
453 if ((path != INVALID_RES_ID) && (event_serv == serv_ptr))
459 if (!CheckForAlternativeService(LINK_TYPE_CA_REPLACEMENT_SERVICE))
471 else if ((original_alternative_service != NULL) &&
472 (event_serv == original_alternative_service))
478 ReturnFromAlternativeService();
484 case APP_EVENT_SERVICE_SUBTITLE_UPDATE:
485 case APP_EVENT_SERVICE_VIDEO_CODEC_CHANGED:
486 case APP_EVENT_SERVICE_AUDIO_CODEC_CHANGED:
488 event_serv = *(
void **)event_info.data;
496 case STB_EVENT_TIMER_EXPIRE:
499 #ifdef COMMON_INTERFACE 514 case STB_EVENT_TIMER_NOTIFY:
516 #ifdef INTEGRATE_HBBTV 517 if ((event_info.data != NULL) && (event_info.data_size ==
sizeof(U32BIT)))
519 U32BIT timer_handle = *(U32BIT *)event_info.data;
520 if (timer_handle != INVALID_TIMER_HANDLE)
529 case APP_EVENT_SERVICE_EIT_NOW_UPDATE:
531 #ifdef NOW_EVENTS_LATCHED 536 STB_ERNotifyEvent(EVENT_CLASS(event_info.event_code), EVENT_TYPE(event_info.event_code));
548 event_serv = *(
void **)event_info.data;
570 case APP_EVENT_PVR_RECORDING_FAILED:
571 case STB_EVENT_PVR_REC_STOP:
581 case APP_EVENT_SERVICE_EIT_SCHED_UPDATE:
584 STB_ERNotifyEvent(EVENT_CLASS(event_info.event_code), EVENT_TYPE(event_info.event_code));
589 case STB_EVENT_FORCED_SERVICE_CHANGE:
591 path = *(U8BIT *)event_info.data;
597 STB_ERSendEvent(FALSE, FALSE, EV_CLASS_APPLICATION, EV_SERVICE_CHANGED,
598 &serv_ptr,
sizeof(
void *));
603 #ifdef COMMON_INTERFACE 604 case STB_EVENT_CI_APP_INFO:
619 NotifyAll(event_info.event_code, event_info.data, event_info.data_size);
622 if (event_info.data != NULL)
629 U32BIT cur_app, max_app, num_app, cur_mem, max_mem, num_mem;
630 STB_GetHeapStats(&cur_app, &max_app, &num_app, &cur_mem, &max_mem, &num_mem);
632 STB_SPDebugWrite(
" App: Current=%luKB, Max=%luKB, Num=%lu\n", cur_app / 1024, max_app / 1024, num_app);
633 STB_SPDebugWrite(
" Sys: Current=%luKB, Max=%luKB, Num=%lu\n", cur_mem / 1024, max_mem / 1024, num_mem);
640 DBG((
"EventTask: finished"));
642 FUNCTION_FINISH(EventTask);
651 static BOOLEAN CheckForAlternativeService(U8BIT alt_serv_type)
658 FUNCTION_START(CheckForAlternativeService);
663 if (path != INVALID_RES_ID)
668 if (new_serv != NULL)
671 original_alternative_service = serv_ptr;
673 NotifyAll(APP_EVENT_SWITCH_ALTERNATIVE_SERVICE,&new_serv,
sizeof(
void *));
679 FUNCTION_FINISH(CheckForAlternativeService);
689 static BOOLEAN ReturnFromAlternativeService(
void)
693 FUNCTION_START(ReturnFromAlternativeService);
695 if (original_alternative_service != NULL)
697 NotifyAll(APP_EVENT_SWITCH_ALTERNATIVE_SERVICE,&original_alternative_service,
sizeof(
void *));
700 original_alternative_service = NULL;
707 FUNCTION_FINISH(ReturnFromAlternativeService);
U8BIT STB_DPGetPathForService(void *service)
Checks whether any of the paths are tuned to the given service.
void STB_LLAddBlockToEnd(LINK_LIST_HEADER *hdr, LINK_LIST_PTR_BLK *new_blk)
Adds the block identified by the new_blk pointer to the end of the linked list identified by the list...
BOOLEAN STB_DPIsRecording(U8BIT path, U32BIT *handle)
Returns status of recording on specified path.
BOOLEAN ATMR_CheckRecordStatus(BOOLEAN recordings_can_start, void *service)
Checks all timers to see whether any recordings should be started or stopped as a result of the now e...
BOOLEAN ACTL_HandlePrivateTimerEvent(U32BIT timer_handle)
Handles all the private timer events.
void * ADB_GetAlternativeService(void *s_ptr, U8BIT alt_serv_type)
Searches for a replacement service of the given type for the given service.
macros and function prototypes for public use
void ACTL_ApplyParentalControl(U8BIT path, void *s_ptr)
Checks the parental control for the current event on the given service to determine whether decoding ...
void * STB_DPGetTunedService(U8BIT path)
Returns the service saved with the given decode path.
void ACTL_ActionEvent(U32BIT event, void *event_data)
Actions external events.
BOOLEAN STB_DPIsLivePath(U8BIT path)
Is the given decode path being used for live viewing.
U32BIT STB_OSGetClockDiff(U32BIT timestamp)
Get Difference between Given Time and Current Time.
Header file - macros and function prototypes for public use.
void APVR_PidsUpdated(U8BIT path)
This function should be called when there's an update to the PIDs for a service that's being recorded...
BOOLEAN APP_UnregisterDVBEventHandler(DVB_EVENT_HANDLER event_handler)
Unregister a previously registered event handler.
void * STB_AppGetMemory(U32BIT bytes)
Attempts to allocate memory from the application heap.
void STB_ERRegisterHandler(BOOLEAN(*func)(BOOLEAN latched, BOOLEAN repeat, U16BIT class, U16BIT type, void *data, U32BIT data_size))
Called by app to register callback function for events.
BOOLEAN ACI_HandlePrivateTimer(U32BIT timer_handle)
Checks whether the given timer is associated with any of the CI+ profiles and starts the operator sea...
Header file - Function prototypes for A/V control.
void(* DVB_EVENT_HANDLER)(U32BIT event, void *event_data, U32BIT data_size)
The event notification callback function.
U16BIT STB_PVRRecordingGetDiskId(U32BIT handle)
Gets the disk id for a recording.
void ASTE_StartRecording(void)
Application timer functions and defines.
void ATMR_HandleTimerEvent(U32BIT timer_handle)
Used by the DVB stack to handle an event for the given timer. If the timer requires the app to deal w...
void STB_OSMutexUnlock(void *mutex)
Unlock a mutex (a.k.a. 'leave', 'signal' or 'release')
Header file - macros and function prototypes for public use.
void ACTL_EnterStandby(void)
Puts DVB into standby mode. It will continue to monitor SI for recordings, SSU updates, etc., unless it goes into low power standby.
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.
U8BIT STB_DPGetNumPaths(void)
Returns the maximum number of decode paths.
BOOLEAN APP_RegisterDVBEventHandler(DVB_EVENT_HANDLER event_handler)
Register for DVB event notifications.
U8BIT STB_DPGetLivePath(void)
Returns the ID of the decode path being used for live viewing.
void ACTL_ApplyHDCP(void *s_ptr)
Checks content protection requirements for the current event on the given service to determine whethe...
BOOLEAN STB_DPIsDecodingPath(U8BIT path)
Is the given decode path being used for decoding.
void STB_ERNotifyEvent(U8BIT event_class, U16BIT event_type)
Called by app to notify consumption of latched event.
void STB_SPDebugWrite(const char *format,...)
Write debug string to serial/debug port. <CR><LF> characters will be automatically added to the end o...
Debug functions header file.
void STB_LLRemoveBlock(LINK_LIST_PTR_BLK *blk)
Removes the block identified by the blk pointer from its linked list.
Header file - Function prototypes for linked lists.
Header file - macros and function prototypes for public use.
void STB_OSMutexLock(void *mutex)
Lock a mutex (a.k.a. 'enter', 'wait' or 'get').
BOOLEAN ADB_GetServiceScrambledFlag(void *s_ptr)
Returns the status of the 'scrambled' flag of the given service. This flag is set depending on the sc...
void * ADB_GetTunedService(U8BIT path)
Returns the tuned service for the given decode path.
LINK_LIST_PTR_BLK * STB_LLGetNextBlock(LINK_LIST_PTR_BLK *blk)
Returns a pointer to the next block in the linked list, or NULL if at the end of the list...
Application level CI - internal functions.
void APP_SetClassifyRepeatEvents(BOOLEAN enable)
Enable classifying of repeat events by EV_CLASS_IS_REPEAT flag.
Header file - Function prototypes for Event Reporting.
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...
LINK_LIST_PTR_BLK * STB_LLGetFirstBlock(LINK_LIST_HEADER *hdr)
Returns a pointer to the first block in the linked list, identified by hdr.
application level SI task
Application stb layer control.
BOOLEAN APVR_IsRecordingInProgress(void)
Returns TRUE if there are any recordings currently in progress.
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_StopRecording(U32BIT recording_handle)
Stops the given recording.
void STB_AppFreeMemory(void *addr)
Releases previously allocated application heap memory.
Application level HBBTV callback functions.
void ACTL_HDMIDisconnected(void)
Sets flag to indicate HDMI is now disconnected. This function is called by the event task when the HD...
void ACTL_StopSubtitles(void)
Stops subtitles from being displayed and processed.
BOOLEAN STB_DPIsRecordingPath(U8BIT path)
Is the given decode path being used for recording.
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.
BOOLEAN APVR_HandlePrivateTimer(U32BIT timer_handle)
Deals with any private timers started by the PVR module.
void ACTL_HDMIConnected(void)
Checks that the selected HDMI resolution mode is supported and, if not, chooses the best one availabl...
BOOLEAN ASTE_InStandby(void)
Header file - Function prototypes for heap memory.
void * STB_OSCreateMutex(void)
Create a mutex.
U8BIT ACTL_GetActivePath(void)
Returns the active path (live, playback, etc...), i.e. the one using the decoders.
BOOLEAN STB_OSReadQueue(void *queue, void *msg, U16BIT msg_size, U16BIT timeout)
Read a message from a queue.
void HBBTV_NotifyRecordingEvent(U32BIT id, E_HBBTV_RECORDING_EVENT event)
Notifies the HbbTV engine of a recording event.
void STB_OSDeleteMutex(void *mutex)
Delete a mutex.
void APVR_EitUpdated(void)
Ensures that any EIT updates are processed to handle scenarios such as checking for new series record...
U32BIT STB_OSGetClockMilliseconds(void)
Get Current Computer Clock Time.
void STB_LLInitialiseHeader(LINK_LIST_HEADER *hdr)
Initialise the header variables of the linked list.
Application database access functions.
Header file - macros and function prototypes for public use.