| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 1998-2009, 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_utils.h $ |
|---|
| 11 | * $brcm_Revision: 4 $ |
|---|
| 12 | * $brcm_Date: 10/28/09 1:30p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /BSEAV/lib/bcmplayer/utils/ts_utils.h $ |
|---|
| 19 | * |
|---|
| 20 | * 4 10/28/09 1:30p erickson |
|---|
| 21 | * SW7405-3287: add functions for getting and setting pes headers |
|---|
| 22 | * |
|---|
| 23 | * 3 4/30/07 1:31p erickson |
|---|
| 24 | * PR30310: move BTP modes to public file |
|---|
| 25 | * |
|---|
| 26 | * 2 4/30/07 1:09p erickson |
|---|
| 27 | * PR30310: added TIMING_MARKER, PICTURE_TAG. changed debug code to |
|---|
| 28 | * function. |
|---|
| 29 | * |
|---|
| 30 | * Irvine_BSEAVSW_Devel/3 6/30/06 9:39a erickson |
|---|
| 31 | * PR21941: fix start code detection algorithm, and eliminate duplication |
|---|
| 32 | * by moving to ts_utils |
|---|
| 33 | * |
|---|
| 34 | * Irvine_BSEAVSW_Devel/2 9/14/05 2:24p erickson |
|---|
| 35 | * PR17148: converted to BCHP_7411_REV |
|---|
| 36 | * |
|---|
| 37 | * Irvine_BSEAVSW_Devel/1 9/1/05 3:37p erickson |
|---|
| 38 | * PR16964: moved common ts functions to shared locations |
|---|
| 39 | * |
|---|
| 40 | ****************************************************************/ |
|---|
| 41 | #ifndef COMMONTS_H__ |
|---|
| 42 | #define COMMONTS_H__ |
|---|
| 43 | |
|---|
| 44 | #include "bstd.h" |
|---|
| 45 | #include "playertypes.h" |
|---|
| 46 | |
|---|
| 47 | #ifdef __cplusplus |
|---|
| 48 | extern "C" { |
|---|
| 49 | #endif |
|---|
| 50 | |
|---|
| 51 | const char *b_btp_mode_str(int mode); |
|---|
| 52 | |
|---|
| 53 | /* Byteswap LE unsigned long to BE */ |
|---|
| 54 | #define be(L) \ |
|---|
| 55 | ((((L) & 0xFF) << 24) | (((L) & 0xFF00) << 8) | (((L) & 0xFF0000) >> 8) | (((L) & 0xFF000000) >> 24)) |
|---|
| 56 | |
|---|
| 57 | unsigned short b_get_pid( |
|---|
| 58 | const unsigned char *pkt /* 188 byte transport packet */ |
|---|
| 59 | ); |
|---|
| 60 | |
|---|
| 61 | bool b_is_btp( |
|---|
| 62 | const unsigned char *pkt /* 188 byte transport packet */ |
|---|
| 63 | ); |
|---|
| 64 | |
|---|
| 65 | int b_get_btp_word( |
|---|
| 66 | const unsigned char *pkt, /* 188 byte transport packet */ |
|---|
| 67 | int command_word /* index 0..9 into BTP command word array */ |
|---|
| 68 | ); |
|---|
| 69 | |
|---|
| 70 | /* advance the sccount, looking for start codes. when |
|---|
| 71 | sccount gets to 3, the next byte is a start code. */ |
|---|
| 72 | int b_check_for_start_code(unsigned char data, int sccount); |
|---|
| 73 | |
|---|
| 74 | bool b_is_pes_stream_id(unsigned char stream_id); |
|---|
| 75 | |
|---|
| 76 | typedef enum b_pes_packet_type { |
|---|
| 77 | b_pes_packet_type_invalid, |
|---|
| 78 | b_pes_packet_type_data, /* program_stream_map, private_stream_2, ECM, EMM, program_stream_directory, |
|---|
| 79 | DSMCC_stream, ITU-T Rec. H.222.1 type E stream */ |
|---|
| 80 | b_pes_packet_type_pes, |
|---|
| 81 | b_pes_packet_type_padding |
|---|
| 82 | } b_pes_packet_type; |
|---|
| 83 | |
|---|
| 84 | b_pes_packet_type b_get_pes_type(unsigned char stream_id); |
|---|
| 85 | |
|---|
| 86 | typedef struct b_pes_header |
|---|
| 87 | { |
|---|
| 88 | b_pes_packet_type pes_type; |
|---|
| 89 | unsigned packet_length; |
|---|
| 90 | unsigned header_data_length; |
|---|
| 91 | unsigned pts_dts_flags; |
|---|
| 92 | uint32_t pts; |
|---|
| 93 | uint32_t dts; |
|---|
| 94 | } b_pes_header; |
|---|
| 95 | |
|---|
| 96 | void b_get_pes_header(unsigned char *buf, b_pes_header *pes_header); |
|---|
| 97 | |
|---|
| 98 | void b_set_pes_header(unsigned char *buf, const b_pes_header *pes_header); |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | #ifdef __cplusplus |
|---|
| 102 | } |
|---|
| 103 | #endif |
|---|
| 104 | |
|---|
| 105 | #endif /* COMMONTS_H__ */ |
|---|