| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2008, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: ts_scte_18.h $ |
|---|
| 11 | * $brcm_Revision: $ |
|---|
| 12 | * $brcm_Date: $ |
|---|
| 13 | * |
|---|
| 14 | * [File Description:] |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | ***************************************************************************/ |
|---|
| 19 | #ifndef TS_SCTE_18_H__ |
|---|
| 20 | #define TS_SCTE_18_H__ |
|---|
| 21 | |
|---|
| 22 | #include "bstd.h" |
|---|
| 23 | #include "ts_priv.h" |
|---|
| 24 | |
|---|
| 25 | #ifdef __cplusplus |
|---|
| 26 | extern "C" { |
|---|
| 27 | #endif |
|---|
| 28 | |
|---|
| 29 | #define TS_SCTE_18_MAX_TABLE_SIZE 4096 |
|---|
| 30 | #define TS_SCTE_18_EAS_TABLE_ID 0xD8 |
|---|
| 31 | |
|---|
| 32 | #define TS_SCTE_18_PROTOCOL_VERSION 8 |
|---|
| 33 | #define TS_SCTE_18_EAS_EVENT_ID 9 |
|---|
| 34 | #define TS_SCTE_18_EAS_ORIGINATOR_CODE 10 /* should be 11, but need 4 byte alignment */ |
|---|
| 35 | #define TS_SCTE_18_EAS_EVENT_CODE_LENGTH 14 |
|---|
| 36 | |
|---|
| 37 | typedef const uint8_t * TS_SCTE_18_descriptor; |
|---|
| 38 | |
|---|
| 39 | typedef struct |
|---|
| 40 | { |
|---|
| 41 | uint8_t state_code; /* 0 - 99 */ |
|---|
| 42 | uint8_t county_subdivision; /* 0 - 99 */ |
|---|
| 43 | uint16_t county_code; /* 10 bits, 0 - 999 */ |
|---|
| 44 | } TS_SCTE_18_location_code; |
|---|
| 45 | |
|---|
| 46 | #define TS_SCTE_18_LOCATION_CODE_BYTES 3 /* 8 + 4 + 2 + 10 = 24 bits */ |
|---|
| 47 | |
|---|
| 48 | typedef struct |
|---|
| 49 | { |
|---|
| 50 | uint8_t in_band_reference; /* 1 */ |
|---|
| 51 | uint16_t major_channel_number; /* if in_band_reference == 1 */ |
|---|
| 52 | uint16_t minor_channel_number; |
|---|
| 53 | uint16_t OOB_source_ID; /* if in_band_reference == 0 */ |
|---|
| 54 | } TS_SCTE_18_exception; |
|---|
| 55 | |
|---|
| 56 | #define TS_SCTE_18_EXCEPTION_BYTES 5 /* 1 + 7 + 16 + 16 */ |
|---|
| 57 | |
|---|
| 58 | typedef struct |
|---|
| 59 | { |
|---|
| 60 | uint8_t exception_RF_channel; /* 8 */ |
|---|
| 61 | uint16_t exception_program_number; /* 16 */ |
|---|
| 62 | } TS_SCTE_18_in_band_channel_descriptor; |
|---|
| 63 | |
|---|
| 64 | #define TS_SCTE_18_IN_BAND_EXCEPTION_CHANNEL_DESCRIPTOR_BYTES 3 |
|---|
| 65 | |
|---|
| 66 | #define IN_BAND_DETAILS_CHANNEL_DESCRIPTOR_TAG 0x00 |
|---|
| 67 | #define IN_BAND_EXCEPTION_CHANNEL_DESCRIPTOR_TAG 0x01 |
|---|
| 68 | #define IN_BAND_AUDIO_FILE_DESCRIPTOR_TAG 0x02 |
|---|
| 69 | |
|---|
| 70 | typedef struct |
|---|
| 71 | { |
|---|
| 72 | uint8_t table_id; /* 0xD8 */ |
|---|
| 73 | //bool section_syntax_indicator; /* 1 */ |
|---|
| 74 | uint16_t section_length; |
|---|
| 75 | //uint16_t table_id_extension; /* 0x0000 */ |
|---|
| 76 | uint8_t sequence_number; /* 5 bits, ( % 32) */ |
|---|
| 77 | //bool current_next_indicator; |
|---|
| 78 | //uint8_t section_number; /* 0x00 */ |
|---|
| 79 | //uint8_t last_section_number; /* 0x00 */ |
|---|
| 80 | //uint8_t protocol_version; /* 0x00 currently */ |
|---|
| 81 | |
|---|
| 82 | uint16_t EAS_event_ID; |
|---|
| 83 | uint32_t EAS_originator_code; /* 24 bits */ |
|---|
| 84 | uint8_t EAS_event_code_length; |
|---|
| 85 | uint8_t EAS_event_code; /* var */ |
|---|
| 86 | |
|---|
| 87 | uint8_t nature_of_activation_text_length; /* following nature of activation text, var */ |
|---|
| 88 | |
|---|
| 89 | uint8_t alert_message_time_remaining; /* range 1 - 120 */ |
|---|
| 90 | uint32_t event_start_time; |
|---|
| 91 | uint16_t event_duration; /* minutes range 15 - 6000 */ |
|---|
| 92 | uint8_t alert_priority; |
|---|
| 93 | |
|---|
| 94 | uint16_t details_OOB_source_ID; |
|---|
| 95 | uint16_t details_major_channel_number; /* 10 bits */ |
|---|
| 96 | uint16_t details_minor_channel_number; /* 10 bits */ |
|---|
| 97 | uint16_t audio_OOB_source_ID; |
|---|
| 98 | uint16_t alert_text_length; |
|---|
| 99 | |
|---|
| 100 | uint8_t location_code_count; /* for TS_SCTE_18_location_code structure */ |
|---|
| 101 | |
|---|
| 102 | uint8_t exception_count; /* for TS_SCTE_18_exception */ |
|---|
| 103 | |
|---|
| 104 | uint16_t descriptors_length; /* for descriptor, please refer to psip_descriptor.c */ |
|---|
| 105 | |
|---|
| 106 | } TS_SCTE_18_header; |
|---|
| 107 | |
|---|
| 108 | int TS_SCTE_18_getSectionHeader( const uint8_t *pkt, size_t size, TS_SCTE_18_header *p_header ); |
|---|
| 109 | uint8_t *TS_SCTE_18_getEASEventCodeOffset(const uint8_t *pkt, size_t *size); |
|---|
| 110 | uint8_t *TS_SCTE_18_getActivationTextOffset(const uint8_t *pkt, size_t *size); |
|---|
| 111 | uint8_t *TS_SCTE_18_getAlrtTextOffset(const uint8_t *pkt, size_t *size); |
|---|
| 112 | uint8_t *TS_SCTE_18_getLocationOffset(const uint8_t *pkt, size_t *size); |
|---|
| 113 | uint8_t *TS_SCTE_18_getExpectionOffset(const uint8_t *pkt, size_t *size); |
|---|
| 114 | uint8_t *TS_SCTE_18_getDescriptorOffset(const uint8_t *pkt, size_t *size); |
|---|
| 115 | |
|---|
| 116 | bool TS_SCTE_18_getLocationCode( const uint8_t *buf, int index, TS_SCTE_18_location_code *p_location ); |
|---|
| 117 | bool TS_SCTE_18_getException( const uint8_t *buf, int index, TS_SCTE_18_exception *p_exception ); |
|---|
| 118 | bool TS_SCTE_18_getInBandExceptionDescriptorCount(const uint8_t *buf, int *count); |
|---|
| 119 | bool TS_SCTE_18_getInBandChannelDescriptor(const uint8_t *buf, TS_SCTE_18_in_band_channel_descriptor *p_descriptor,size_t size); |
|---|
| 120 | |
|---|
| 121 | void TS_SCTE_18_DumpHeader(TS_SCTE_18_header *pHdr); |
|---|
| 122 | void TS_SCTE_18_DumpPacket(uint8_t *pkt, TS_SCTE_18_header *pHdr); |
|---|
| 123 | |
|---|
| 124 | #ifdef __cplusplus |
|---|
| 125 | } |
|---|
| 126 | #endif |
|---|
| 127 | |
|---|
| 128 | #endif /* TS_SCTE_18_H__ */ |
|---|
| 129 | /* End of File */ |
|---|