mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-20 04:56:24 +00:00
mpegtsparse: Factor common code into mpegts_packet_to_buffer
The same code was used twice for turning an MpegTSPacketizerPacket into a GstBuffer.
This commit is contained in:
parent
68f69d419b
commit
e44cbfb1da
1 changed files with 12 additions and 8 deletions
|
@ -516,6 +516,16 @@ mpegts_parse_request_new_pad (GstElement * element, GstPadTemplate * template,
|
||||||
return pad;
|
return pad;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mpegts_parse_release_pad (GstElement * element, GstPad * pad)
|
mpegts_parse_release_pad (GstElement * element, GstPad * pad)
|
||||||
{
|
{
|
||||||
|
@ -556,10 +566,7 @@ mpegts_parse_tspad_push_section (MpegTSParse2 * parse, MpegTSParsePad * tspad,
|
||||||
tspad->program_number, section->table_id);
|
tspad->program_number, section->table_id);
|
||||||
|
|
||||||
if (to_push) {
|
if (to_push) {
|
||||||
GstBuffer *buf =
|
GstBuffer *buf = mpegts_packet_to_buffer (packet);
|
||||||
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);
|
|
||||||
ret = gst_pad_push (tspad->pad, buf);
|
ret = gst_pad_push (tspad->pad, buf);
|
||||||
ret = gst_flow_combiner_update_flow (parse->flowcombiner, ret);
|
ret = gst_flow_combiner_update_flow (parse->flowcombiner, ret);
|
||||||
}
|
}
|
||||||
|
@ -586,10 +593,7 @@ mpegts_parse_tspad_push (MpegTSParse2 * parse, MpegTSParsePad * tspad,
|
||||||
if (bp) {
|
if (bp) {
|
||||||
if (packet->pid == bp->pmt_pid || bp->streams == NULL
|
if (packet->pid == bp->pmt_pid || bp->streams == NULL
|
||||||
|| bp->streams[packet->pid]) {
|
|| bp->streams[packet->pid]) {
|
||||||
GstBuffer *buf =
|
GstBuffer *buf = mpegts_packet_to_buffer (packet);
|
||||||
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);
|
|
||||||
/* push if there's no filter or if the pid is in the filter */
|
/* push if there's no filter or if the pid is in the filter */
|
||||||
ret = gst_pad_push (tspad->pad, buf);
|
ret = gst_pad_push (tspad->pad, buf);
|
||||||
ret = gst_flow_combiner_update_flow (parse->flowcombiner, ret);
|
ret = gst_flow_combiner_update_flow (parse->flowcombiner, ret);
|
||||||
|
|
Loading…
Reference in a new issue