105 lines
3.6 KiB
C++
105 lines
3.6 KiB
C++
/* GStreamer
|
|
* Copyright (C) 2023 <[email protected]>
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Library General Public
|
|
* License as published by the Free Software Foundation; either
|
|
* version 2 of the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Library General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Library General Public
|
|
* License along with this library; if not, write to the
|
|
* Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
|
* Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
#ifndef TS_PATPMT_PARSE_H
|
|
#define TS_PATPMT_PARSE_H
|
|
|
|
#define MAX_PROGRAM_NUM 7
|
|
#define MAX_STREAM_NUM 7
|
|
|
|
/* video type */
|
|
#define STREAM_TYPE_VIDEO_MPEG1 0x01
|
|
#define STREAM_TYPE_VIDEO_MPEG2 0x02
|
|
#define STREAM_TYPE_VIDEO_MPEG4 0x10
|
|
#define STREAM_TYPE_VIDEO_H264 0x1b
|
|
#define STREAM_TYPE_VIDEO_HEVC 0x24
|
|
#define STREAM_TYPE_VIDEO_CAVS 0x42
|
|
/* audio type */
|
|
#define STREAM_TYPE_AUDIO_MPEG1 0x03
|
|
#define STREAM_TYPE_AUDIO_MPEG2 0x04
|
|
#define STREAM_TYPE_AUDIO_AAC 0x0f
|
|
#define STREAM_TYPE_AUDIO_AC3 0x81
|
|
|
|
#define STREAM_DESCRIPTOR_SIZE 128
|
|
|
|
typedef struct TS_PAT_Program
|
|
{
|
|
unsigned program_number : 16; // program num
|
|
unsigned program_map_PID : 13; // PID
|
|
} TS_PAT_Program;
|
|
|
|
typedef struct TS_PAT
|
|
{
|
|
unsigned table_id : 8; // Fixed:0x00 for PAT
|
|
unsigned section_syntax_indicator : 1; // Fixed:1
|
|
unsigned zero : 1; // 0
|
|
unsigned reserved_1 : 2; // Reserved
|
|
unsigned section_length : 12; // section length
|
|
unsigned transport_stream_id : 16; // Stream id
|
|
unsigned reserved_2 : 2; // Reserved
|
|
unsigned version_number : 5; // PAT version num
|
|
unsigned current_next_indicator : 1; // current PAT valid or next PAT valid
|
|
unsigned section_number : 8; // section num
|
|
unsigned last_section_number : 8; // last section num
|
|
|
|
// std::vector<TS_PAT_Program> program;
|
|
TS_PAT_Program program[MAX_PROGRAM_NUM];
|
|
unsigned program_num;
|
|
unsigned reserved_3 : 3; // Reserved
|
|
unsigned network_PID : 13; // NIT PID
|
|
unsigned CRC_32 : 32; // CRC32
|
|
} TS_PAT;
|
|
|
|
typedef struct TS_PMT_Stream
|
|
{
|
|
unsigned stream_type : 8;
|
|
unsigned elementary_PID : 13;
|
|
unsigned ES_info_length : 12;
|
|
unsigned char descriptor[STREAM_DESCRIPTOR_SIZE];
|
|
} TS_PMT_Stream;
|
|
|
|
typedef struct TS_PMT
|
|
{
|
|
unsigned table_id : 8; // Fixed:0x02 for PMT
|
|
unsigned section_syntax_indicator : 1; // Fixed:0x01
|
|
unsigned zero : 1; // Fixed:0x01
|
|
unsigned reserved_1 : 2; // Fixed:0x03
|
|
unsigned section_length : 12;
|
|
unsigned program_number : 16;
|
|
unsigned reserved_2 : 2; // Fixed:0x03
|
|
unsigned version_number : 5;
|
|
unsigned current_next_indicator : 1;
|
|
unsigned section_number : 8; // Fixed:0x00
|
|
unsigned last_section_number : 8; // Fixed:0x00
|
|
unsigned reserved_3 : 3; // Fixed:0x07
|
|
unsigned PCR_PID : 13;
|
|
unsigned reserved_4 : 4; // Fixed:0x0F
|
|
unsigned program_info_length : 12;
|
|
|
|
TS_PMT_Stream PMT_Stream[MAX_STREAM_NUM];
|
|
unsigned PMT_Stream_num;
|
|
unsigned reserved_5 : 3; // 0x07
|
|
unsigned reserved_6 : 4; // 0x0F
|
|
unsigned CRC_32 : 32;
|
|
} TS_PMT;
|
|
|
|
int adjust_PAT_table(TS_PAT *packet, unsigned char *buffer);
|
|
int adjust_PMT_table(TS_PMT *packet, unsigned char *buffer);
|
|
|
|
#endif |