/*************************************************************************** * Copyright (c) 2009, Broadcom Corporation * All Rights Reserved * Confidential Property of Broadcom Corporation * * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. * * $brcm_Workfile: $ * $brcm_Revision: $ * $brcm_Date: $ * * Module Description: * * Revision History: * * $brcm_Log: $ * ***************************************************************************/ #ifndef SCTE_27_H__ #define SCTE_27_H__ #include "bstd.h" #include "bos.h" #include "genericlist.h" #define SCTE_27_STK_SIZE 1024 /* words */ #define SUBTITLE_STREAM_TYPE 0x82 /* OpenCable Subtitle */ #define SUBTITLE_SECTION_ID 0xc6 /* table ID */ typedef struct subtitle_message { uint8_t table_ID; // 8 bits uint16_t section_length; // 12 bits uint8_t segmentation_overlay_included; // 1 bit // for segmentation overlay included uint16_t table_extension; // 16 bits, table ID for segmented packet uint16_t last_segment_number; // 12 bits uint16_t segment_number; // 12 bits /* Body */ uint32_t ISO_639_language_code; // 3 bits uint8_t pre_clear_display; // 1 uint8_t immediate; // 1 uint8_t display_standard; // 5 bits /* Out-Cure Time */ uint32_t display_in_PTS; // 32 /* Subtitle Format */ uint8_t subtitle_type; // 4 /* Display Duration */ uint16_t display_duration; // 11, 1 - 2000 /* BLock Length */ uint16_t block_length; // 16 /* for simple bitmap which is supported only */ uint8_t background_style; // 1 uint8_t outline_style; // 2 /* Subtitle Color */ uint8_t Y_component; uint8_t opaque_enable; uint8_t Cr_component; uint8_t Cb_component; uint16_t bitmap_top_H_coordinate; uint16_t bitmap_top_V_coordinate; uint16_t bitmap_bottom_H_coordinate; uint16_t bitmap_bottom_V_coordinate; /* for framed background style */ uint16_t frame_top_H_coordinate; uint16_t frame_top_V_coordinate; uint16_t frame_bottom_H_coordinate; uint16_t frame_bottom_V_coordinate; uint8_t frame_Y_component; uint8_t frame_opaque_enable; uint8_t frame_Cr_component; uint8_t frame_Cb_component; /* for outline outline style */ uint8_t outline_thickness; uint8_t outline_Y_component; uint8_t outline_opaque_enable; uint8_t outline_Cr_component; uint8_t outline_Cb_component; /* for drop shadow outline style */ uint8_t shadow_right; uint8_t shadow_bottom; uint8_t shadow_Y_component; uint8_t shadow_opaque_enable; uint8_t shadow_Cr_component; uint8_t shadow_Cb_component; uint16_t bitmap_length; /* Uncompressed Bitmap */ uint32_t bitmap_size; /* if not zero, means there uncompressed data */ uint8_t *bitmap_data; /* if not NULL, data buffer allowed */ /* variables for clearing subttle */ uint16_t top_H; uint16_t top_V; uint16_t bottom_H; uint16_t bottom_V; uint32_t display_out_PTS; /* time to clear (out-cue) time */ } subtitle_message, *psubtitle_message; /* Subtitle Message State */ typedef enum { SMS_NONE, SMS_RENDER, /* to render */ SMS_ERASE, /* to rease due to out-cue time */ } subtitle_message_state; /* Outline Style */ typedef enum { OS_NONE, OS_OUTLINE, OS_DROP_SHADOW, OS_RESERVED } OS; /* Subtitle Command */ typedef enum SC { SC_NONE, /* no event */ SC_RENDER, /* render subtile event */ SC_CLEAR, /* clear subtitle event */ SC_IDLE, /* idle. Used for dynamic format change if we don't want to exit from the task */ SC_MAX /* idle. Used for dynamic format change if we don't want to exit from the task */ } SC; #define SUBTITLE_TYPE_SIMPLE_BITMAP 1 /* bitmap type we supported */ #define MAX_SUBTITLE_MESSAGE 4 /* currently 4 (found out of buffer in 3) */ #define MAX_SUBTITLE_EVENTS 8 /* max subtitle events */ #define PCRS_PER_SEC 45000 /* 45KHz clock ticks */ #define PCRS_PER_MSEC 45 /* clock ticks per ms */ typedef struct { LINKS_T links; psubtitle_message msg; /* pointer to subtitle message structure */ } scte_27_data, *pscte_27_data; typedef struct { b_mutex_t mutex; /* mutex for list handling */ void *v_app; /* pointer to application data structure */ uint8_t *bitmap; /* pointer to uncompress bitmap to rendering */ uint16_t bitmap_size; /* uncompress bitmap size */ bool enabled; /* subtitle rendering enabled or not */ b_task_t task; unsigned int stack[SCTE_27_STK_SIZE]; b_queue_t queue; b_event_t event[MAX_SUBTITLE_EVENTS]; b_event_t cmd_array[SC_MAX]; /* global variable to track segmented subtitle message */ uint16_t table_extension; uint16_t last_segment_number; uint16_t segment_number; bool segmented; /* segmented subtilte packet */ uint8_t *segment_data; /* pointer to a buffer holding segmented data */ uint16_t segment_data_size; /* size of one segmented data */ LIST_T free_list; /* free list */ LIST_T render_list; /* list for the subtitle to be rendered */ LIST_T clear_list; /* list for the subtutle to be cleared */ pscte_27_data pdata; /* pointer to a scte 27 data for holding segmented subtitle data */ } scte_27_handle, *pscte_27_handle; /* List TYPE */ typedef enum { LT_FREE, LT_RENDER, LT_CLEAR, LT_MAX } LT; /* Definitions for identifying language standardized by ISO 639 specification */ #define ISO639English 0x00656E67 // eng #define ISO639Spanish 0x00737061 // spa #define ISO639Spanish2 0x0065736C // esl #define ISO639Portuguese 0x00706F72 // por #define ISO639French 0x00667265 // fre #define ISO639French2 0x00667261 // fra /* function prototype */ pscte_27_handle scte_27_init(void *v_app); void scte_27_deinit(pscte_27_handle pscte_27); bool scte_27_reset(pscte_27_handle pscte_27); void scte_27_enable(pscte_27_handle pscte_27, int enable); /* function prototype related to subtitle handling*/ bool scte_27_parse_subtitle(pscte_27_handle pscte_27, unsigned char *data, int length, scte_27_data *pdata); #endif /* SCTE_27_H__ */