PageRenderTime 21ms CodeModel.GetById 16ms app.highlight 3ms RepoModel.GetById 1ms app.codeStats 0ms

/ts/pat.h

https://bitbucket.org/a84/gs_public/
C++ Header | 85 lines | 54 code | 11 blank | 20 comment | 6 complexity | f5f7407474a53795151201cc59842d76 MD5 | raw file
 1/*
 2 *
 3 */
 4
 5#ifndef _TS_PAT_H_
 6#define _TS_PAT_H_ 1
 7
 8#ifdef	__cplusplus
 9extern "C" {
10#endif
11
12#include "ts.h"
13
14typedef struct {
15    uint8_t     table_id        :8;
16#if __BYTE_ORDER == __BIG_ENDIAN
17    uint8_t     slen_hi         :4;
18    uint8_t                     :2; // reserved
19    uint8_t                     :1; // 0
20    uint8_t     syntax          :1;
21#else
22    uint8_t     syntax          :1;
23    uint8_t                     :1; // 0
24    uint8_t                     :2; // reserved
25    uint8_t     slen_hi         :4;
26#endif
27    uint8_t     slen_lo         :8;
28    uint8_t     stream_id_hi    :8;
29    uint8_t     stream_id_lo    :8;
30#if __BYTE_ORDER == __BIG_ENDIAN
31    uint8_t     current_next    :1;
32    uint8_t     version         :5;
33    uint8_t                     :2; // reserved
34#else
35    uint8_t                     :2; // reserved
36    uint8_t     version         :5;
37    uint8_t     current_next    :1;
38#endif
39    uint8_t     cs_number       :8;
40    uint8_t     ls_number       :8;
41} mpeg2_pat_header_t;
42
43typedef struct {
44    uint8_t     pnr_hi          :8;
45    uint8_t     pnr_lo          :8;
46#if __BYTE_ORDER == __BIG_ENDIAN
47    uint8_t     pid_hi          :5;
48    uint8_t                     :3; // reserved
49#else
50    uint8_t                     :3; // reserved
51    uint8_t     pid_hi          :5;
52#endif
53    uint8_t     pid_lo          :8;
54} mpeg2_pat_pmt_t;
55
56#define is_pat_ok(pat) ((pat->payload[0] == 0x00) && (pat->payload[1] & 0x80) && (!psi_check_crc32(pat)))
57
58/*
59buffer: pointer to PSI buffer, if is NULL, then allocate new buffer
60stream_id: identify transport stream
61version: version number of PAT
62return: pointer to allocated PSI buffer
63write base info to PSI
64*/
65mpeg2_psi_t *mpeg2_pat_alloc(mpeg2_psi_t *buffer, uint16_t stream_id, uint8_t version);
66
67/*
68pat_p: pointer to buffer
69clean buffer allocated by pat_alloc
70*/
71void mpeg2_pat_free(mpeg2_psi_t *pat_p);
72
73/*
74es - elementary stream
75pmt_p: pointer to buffer
76pnr: number of program
77pid: pid of pmt
78*/
79void mpeg2_pat_add_pmt(mpeg2_psi_t *pat_p, uint16_t pnr, uint16_t pid);
80
81#ifdef	__cplusplus
82}
83#endif
84
85#endif // _TS_PAT_H_