libdvbv5: lib/include/libdvbv5/mpeg_pes.h Source File

libdvbv5 1.32.0 Library to work with Digital TV devices on Linux

mpeg_pes.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2013-2014 - Andre Roth <neolynx@gmail.com>
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation version 2.1 of the License.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 * Or, point your browser to http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
17 *
18 */
19
20#ifndef _MPEG_PES_H
21#define _MPEG_PES_H
22
39
40#include <stdint.h>
41#include <unistd.h> /* ssize_t */
42
43
79
80#define DVB_MPEG_PES 0x00001
81
82#define DVB_MPEG_PES_AUDIO 0xc0 ... 0xcf
83#define DVB_MPEG_PES_VIDEO 0xe0 ... 0xef
84
85#define DVB_MPEG_STREAM_MAP 0xBC
86#define DVB_MPEG_STREAM_PADDING 0xBE
87#define DVB_MPEG_STREAM_PRIVATE_2 0x5F
88#define DVB_MPEG_STREAM_ECM 0x70
89#define DVB_MPEG_STREAM_EMM 0x71
90#define DVB_MPEG_STREAM_DIRECTORY 0xFF
91#define DVB_MPEG_STREAM_DSMCC 0x7A
92#define DVB_MPEG_STREAM_H222E 0xF8
93
107
108 struct ts_t {
109 uint8_t one:1;
110 uint8_t bits30:3;
111 uint8_t tag:4;
112
113 union {
114 uint16_t bitfield;
115 struct {
116 uint16_t one1:1;
117 uint16_t bits15:15;
118 } __attribute__((packed));
119 } __attribute__((packed));
120
121 union {
122 uint16_t bitfield2;
123 struct {
124 uint16_t one2:1;
125 uint16_t bits00:15;
126 } __attribute__((packed));
127 } __attribute__((packed));
128} __attribute__((packed));
129
152 struct dvb_mpeg_pes_optional {
153 union {
154 uint16_t bitfield;
155 struct {
156 uint16_t PES_extension:1;
157 uint16_t PES_CRC:1;
158 uint16_t additional_copy_info:1;
159 uint16_t DSM_trick_mode:1;
160 uint16_t ES_rate:1;
161 uint16_t ESCR:1;
162 uint16_t PTS_DTS:2;
163 uint16_t original_or_copy:1;
164 uint16_t copyright:1;
165 uint16_t data_alignment_indicator:1;
166 uint16_t PES_priority:1;
167 uint16_t PES_scrambling_control:2;
168 uint16_t two:2;
169 } __attribute__((packed));
170 } __attribute__((packed));
171 uint8_t length;
172 uint64_t pts;
173 uint64_t dts;
174} __attribute__((packed));
175
186 struct dvb_mpeg_pes {
187 union {
188 uint32_t bitfield;
189 struct {
190 uint32_t stream_id:8;
191 uint32_t sync:24;
192 } __attribute__((packed));
193 } __attribute__((packed));
194 uint16_t length;
195 struct dvb_mpeg_pes_optional optional[];
196} __attribute__((packed));
197
198struct dvb_v5_fe_parms;
199
200#ifdef __cplusplus
201extern "C" {
202#endif
203
219ssize_t dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen,
220 uint8_t *table);
221
231 void dvb_mpeg_pes_free(struct dvb_mpeg_pes *pes);
232
242 void dvb_mpeg_pes_print (struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *pes);
243
244#ifdef __cplusplus
245}
246#endif
247
248#endif
dvb_mpeg_pes_init
ssize_t dvb_mpeg_pes_init(struct dvb_v5_fe_parms *parms, const uint8_t *buf, ssize_t buflen, uint8_t *table)
Initialize a struct dvb_mpeg_pes from buffer.
dvb_mpeg_pes_free
void dvb_mpeg_pes_free(struct dvb_mpeg_pes *pes)
Deallocate memory associated with a struct dvb_mpeg_pes.
dvb_mpeg_pes_print
void dvb_mpeg_pes_print(struct dvb_v5_fe_parms *parms, struct dvb_mpeg_pes *pes)
Print details of struct dvb_mpeg_pes.
dvb_mpeg_pes_optional
MPEG PES optional header.
Definition mpeg_pes.h:152
dvb_mpeg_pes_optional::PTS_DTS
uint16_t PTS_DTS
Definition mpeg_pes.h:162
dvb_mpeg_pes_optional::PES_priority
uint16_t PES_priority
Definition mpeg_pes.h:166
dvb_mpeg_pes_optional::length
uint8_t length
Definition mpeg_pes.h:171
dvb_mpeg_pes_optional::original_or_copy
uint16_t original_or_copy
Definition mpeg_pes.h:163
dvb_mpeg_pes_optional::pts
uint64_t pts
Definition mpeg_pes.h:172
dvb_mpeg_pes_optional::copyright
uint16_t copyright
Definition mpeg_pes.h:164
dvb_mpeg_pes_optional::dts
uint64_t dts
Definition mpeg_pes.h:173
dvb_mpeg_pes_optional::bitfield
uint16_t bitfield
Definition mpeg_pes.h:154
dvb_mpeg_pes_optional::two
uint16_t two
Definition mpeg_pes.h:168
dvb_mpeg_pes_optional::PES_CRC
uint16_t PES_CRC
Definition mpeg_pes.h:157
dvb_mpeg_pes_optional::ES_rate
uint16_t ES_rate
Definition mpeg_pes.h:160
dvb_mpeg_pes_optional::PES_extension
uint16_t PES_extension
Definition mpeg_pes.h:156
dvb_mpeg_pes_optional::data_alignment_indicator
uint16_t data_alignment_indicator
Definition mpeg_pes.h:165
dvb_mpeg_pes_optional::PES_scrambling_control
uint16_t PES_scrambling_control
Definition mpeg_pes.h:167
dvb_mpeg_pes_optional::additional_copy_info
uint16_t additional_copy_info
Definition mpeg_pes.h:158
dvb_mpeg_pes_optional::DSM_trick_mode
uint16_t DSM_trick_mode
Definition mpeg_pes.h:159
dvb_mpeg_pes_optional::ESCR
uint16_t ESCR
Definition mpeg_pes.h:161
dvb_mpeg_pes
MPEG PES data structure.
Definition mpeg_pes.h:186
dvb_mpeg_pes::stream_id
uint32_t stream_id
Definition mpeg_pes.h:190
dvb_mpeg_pes::length
uint16_t length
Definition mpeg_pes.h:194
dvb_mpeg_pes::sync
uint32_t sync
Definition mpeg_pes.h:191
dvb_mpeg_pes::optional
struct dvb_mpeg_pes_optional optional[]
Definition mpeg_pes.h:195
dvb_mpeg_pes::bitfield
uint32_t bitfield
Definition mpeg_pes.h:188
dvb_v5_fe_parms
Keeps data needed to handle the DVB frontend.
Definition dvb-fe.h:117
ts_t
MPEG PES timestamp structure, used for dts and pts.
Definition mpeg_pes.h:108
ts_t::one
uint8_t one
Definition mpeg_pes.h:109
ts_t::bits15
uint16_t bits15
Definition mpeg_pes.h:117
ts_t::one1
uint16_t one1
Definition mpeg_pes.h:116
ts_t::bits30
uint8_t bits30
Definition mpeg_pes.h:110
ts_t::tag
uint8_t tag
Definition mpeg_pes.h:111
ts_t::bitfield2
uint16_t bitfield2
Definition mpeg_pes.h:122
ts_t::bitfield
uint16_t bitfield
Definition mpeg_pes.h:114
ts_t::bits00
uint16_t bits00
Definition mpeg_pes.h:125
ts_t::one2
uint16_t one2
Definition mpeg_pes.h:124