tsparse: Extract and fill m2ts header for each packet

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7625>
This commit is contained in:
Aniket Hande 2024-10-16 15:56:40 +09:00 committed by GStreamer Marge Bot
parent 5b521c210b
commit 37087f129f
3 changed files with 23 additions and 4 deletions

View file

@ -871,6 +871,15 @@ mpegts_packetizer_next_packet (MpegTSPacketizer2 * packetizer,
if (!mpegts_packetizer_map (packetizer, packet_size))
return PACKET_NEED_MORE;
/* Get M2TS header start */
if (packet_size == MPEGTS_M2TS_PACKETSIZE) {
guint8 *m2ts_header_start = &packetizer->map_data[packetizer->map_offset];
packet->m2ts_header_start = m2ts_header_start;
GST_MEMDUMP ("M2TS header start", packet->m2ts_header_start, 4);
} else
packet->m2ts_header_start = NULL;
/* Get TS packet data start */
packet_data = &packetizer->map_data[packetizer->map_offset + sync_offset];
/* Check sync byte */

View file

@ -309,6 +309,7 @@ typedef struct
guint8 scram_afc_cc;
guint8 *payload;
guint8 *m2ts_header_start;
guint8 *data_start;
guint8 *data_end;
guint8 *data;

View file

@ -610,10 +610,19 @@ mpegts_parse_request_new_pad (GstElement * element, GstPadTemplate * template,
static GstBuffer *
mpegts_packet_to_buffer (MpegTSPacketizerPacket * packet)
{
GstBuffer *buf =
gst_buffer_new_and_alloc (packet->data_end - packet->data_start);
gst_buffer_fill (buf, 0, packet->data_start,
packet->data_end - packet->data_start);
GstBuffer *buf;
if (packet->m2ts_header_start != NULL) {
/* Fill the buffer with all 192 bytes */
buf =
gst_buffer_new_and_alloc (packet->data_end - packet->m2ts_header_start);
gst_buffer_fill (buf, 0, packet->m2ts_header_start,
packet->data_end - packet->m2ts_header_start);
} else {
buf = gst_buffer_new_and_alloc (packet->data_end - packet->data_start);
gst_buffer_fill (buf, 0, packet->data_start,
packet->data_end - packet->data_start);
}
return buf;
}