|
libclosedcaption 1.0.3
ISDB-Tb/SBTVD (Brazilian DTV) closed caption extraction from MPEG-TS
|
MPEG-TS demuxer: PAT/PMT tables, per PID stats and reassembly of the PES packets of one PID. More...


Go to the source code of this file.
Data Structures | |
| struct | TsPidInfo_t |
Macros | |
| #define | TS_PID_PAT 0x0000 |
| #define | TS_PID_NULL 0x1fff |
| #define | TS_PID_MAX 0x2000 |
| #define | TS_PID_NONE 0xffff |
Typedefs | |
| typedef void(* | TsDemuxPesCallback_t) (const uint8_t *pes, size_t len, void *userdata) |
| typedef struct TsDemux_s | TsDemux_t |
Functions | |
| TsDemux_t * | ts_demux_new (void) |
| void | ts_demux_free (TsDemux_t *demux) |
| void | ts_demux_set_pes_callback (TsDemux_t *demux, uint16_t pid, TsDemuxPesCallback_t callback, void *userdata) |
| void | ts_demux_push (TsDemux_t *demux, const uint8_t *packet) |
| void | ts_demux_flush (TsDemux_t *demux) |
| const TsPidInfo_t * | ts_demux_get_pid_info (const TsDemux_t *demux, uint16_t pid) |
| uint16_t | ts_demux_get_caption_pid (const TsDemux_t *demux) |
| const char * | ts_demux_describe_pid (const TsDemux_t *demux, uint16_t pid, char *buf, size_t len) |
| const char * | ts_stream_type_name (uint8_t stream_type) |
| const char * | ts_component_tag_name (int16_t component_tag) |
| const char * | ts_system_pid_name (uint16_t pid) |
MPEG-TS demuxer: PAT/PMT tables, per PID stats and reassembly of the PES packets of one PID.
The demuxer takes the 188 byte TS packets (see ts-reader.h) and:
component_tag;Example:
Definition in file ts-demux.h.
| #define TS_PID_PAT 0x0000 |
PAT PID (Program Association Table).
Definition at line 42 of file ts-demux.h.
| #define TS_PID_NULL 0x1fff |
PID of the null packets (stuffing).
Definition at line 45 of file ts-demux.h.
| #define TS_PID_MAX 0x2000 |
Number of possible PIDs (13 bits).
Definition at line 48 of file ts-demux.h.
| #define TS_PID_NONE 0xffff |
Value used to say "no PID".
Definition at line 51 of file ts-demux.h.
| typedef void(* TsDemuxPesCallback_t) (const uint8_t *pes, size_t len, void *userdata) |
Callback called for each whole PES of the PID chosen in ts_demux_set_pes_callback().
| pes | Whole PES packet, starting at the packet_start_code_prefix (00 00 01). Only valid during the call. |
| len | Size of pes in bytes. |
| userdata | Pointer given to ts_demux_set_pes_callback(). |
Definition at line 75 of file ts-demux.h.
| typedef struct TsDemux_s TsDemux_t |
MPEG-TS demuxer. Opaque struct, created by ts_demux_new().
Definition at line 82 of file ts-demux.h.
| TsDemux_t * ts_demux_new | ( | void | ) |
Creates a demuxer.
| void ts_demux_free | ( | TsDemux_t * | demux | ) |
Frees the demuxer. Does not call ts_demux_flush().
| demux | Demuxer created by ts_demux_new(). NULL is fine. |
| void ts_demux_set_pes_callback | ( | TsDemux_t * | demux, |
| uint16_t | pid, | ||
| TsDemuxPesCallback_t | callback, | ||
| void * | userdata | ||
| ) |
Chooses the PID whose PES packets will be reassembled and handed to the callback.
Only one PID is reassembled at a time. A new call replaces the previous one and drops the PES that was incomplete.
| demux | Demuxer created by ts_demux_new(). |
| pid | PID to be reassembled, or TS_PID_NONE to turn it off. |
| callback | Function called for each whole PES. |
| userdata | Passed on to the callback. |
| void ts_demux_push | ( | TsDemux_t * | demux, |
| const uint8_t * | packet | ||
| ) |
Processes a TS packet.
Packets with the transport_error_indicator set are ignored. Lost packets (continuity_counter failure) drop the incomplete PES.
| demux | Demuxer created by ts_demux_new(). |
| packet | Packet of TS_PACKET_SIZE bytes, starting with TS_SYNC_BYTE. |
| void ts_demux_flush | ( | TsDemux_t * | demux | ) |
Delivers the last PES, if it is still pending.
A PES is only considered complete when the next one starts or when it reaches the PES_packet_length; so call this function at the end of the file.
| demux | Demuxer created by ts_demux_new(). |
| const TsPidInfo_t * ts_demux_get_pid_info | ( | const TsDemux_t * | demux, |
| uint16_t | pid | ||
| ) |
Returns the info collected about a PID.
| demux | Demuxer created by ts_demux_new(). |
| pid | PID between 0 and TS_PID_MAX - 1. |
pid is invalid. | uint16_t ts_demux_get_caption_pid | ( | const TsDemux_t * | demux | ) |
Returns the caption PID suggested by the PMT.
It picks the private stream (stream_type 0x06) with a caption component_tag: 0x30 to 0x37 (full-seg) or 0x87 (one-seg), preferring the lowest component_tag, that is, the main full-seg caption.
| demux | Demuxer created by ts_demux_new(). |
| const char * ts_demux_describe_pid | ( | const TsDemux_t * | demux, |
| uint16_t | pid, | ||
| char * | buf, | ||
| size_t | len | ||
| ) |
Builds a readable description of the PID, for example "0x06 PES privado (component_tag 0x30, legenda)".
| demux | Demuxer created by ts_demux_new(). |
| pid | PID between 0 and TS_PID_MAX - 1. |
| buf | Buffer that receives the description. |
| len | Size of buf (128 bytes is enough). |
buf itself. | const char * ts_stream_type_name | ( | uint8_t | stream_type | ) |
Name of the PMT stream_type (ISO/IEC 13818-1, Table 2-34).
| stream_type | stream_type value. |
"H.264 video", or "desconhecido" (unknown). | const char * ts_component_tag_name | ( | int16_t | component_tag | ) |
Name of the component_tag in ISDB-T (ARIB TR-B14 / ABNT NBR 15608).
| component_tag | component_tag value. |
"legenda", "legenda one-seg", "superimpose", or NULL for the other values. | const char * ts_system_pid_name | ( | uint16_t | pid | ) |
Name of the PIDs reserved for system tables (PAT, NIT, SDT, EIT, etc.).
| pid | PID to look up. |