diff options
author | Edward Hervey <edward@collabora.com> | 2013-07-07 11:42:50 +0200 |
---|---|---|
committer | Edward Hervey <edward@collabora.com> | 2013-07-09 12:25:11 +0200 |
commit | 2fb7b87140b281b095fcc0714b803ddfbd435395 (patch) | |
tree | cb092fd90dcb1ae2fdc4590048b079fa48ea7b2c /gst | |
parent | 61b30175b38e839c818a2d642d1c254c749e2292 (diff) | |
download | gstreamer-plugins-bad-2fb7b87140b281b095fcc0714b803ddfbd435395.tar.gz |
mpegtsdemux: Avoid vmethod calls
Depending on usage, tsparse and tsdemux might not need to be called
when new section/pes-data is available.
Diffstat (limited to 'gst')
-rw-r--r-- | gst/mpegtsdemux/mpegtsbase.c | 9 | ||||
-rw-r--r-- | gst/mpegtsdemux/mpegtsbase.h | 4 | ||||
-rw-r--r-- | gst/mpegtsdemux/mpegtsparse.c | 19 | ||||
-rw-r--r-- | gst/mpegtsdemux/tsdemux.c | 8 |
4 files changed, 28 insertions, 12 deletions
diff --git a/gst/mpegtsdemux/mpegtsbase.c b/gst/mpegtsdemux/mpegtsbase.c index 03b64ff94..b4fa74d34 100644 --- a/gst/mpegtsdemux/mpegtsbase.c +++ b/gst/mpegtsdemux/mpegtsbase.c @@ -236,6 +236,9 @@ mpegts_base_init (MpegTSBase * base) base->program_size = sizeof (MpegTSBaseProgram); base->stream_size = sizeof (MpegTSBaseStream); + base->push_data = TRUE; + base->push_section = TRUE; + mpegts_base_reset (base); } @@ -1106,7 +1109,8 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) /* If it's a known PES, push it */ if (MPEGTS_BIT_IS_SET (base->is_pes, packet.pid)) { /* push the packet downstream */ - res = klass->push (base, &packet, NULL); + if (base->push_data) + res = klass->push (base, &packet, NULL); } else if (packet.payload && MPEGTS_BIT_IS_SET (base->known_psi, packet.pid)) { /* base PSI data */ @@ -1123,7 +1127,8 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) } /* we need to push section packet downstream */ - res = klass->push (base, &packet, section); + if (base->push_section) + res = klass->push (base, &packet, section); } else if (packet.payload && packet.pid != 0x1fff) GST_LOG ("PID 0x%04x Saw packet on a pid we don't handle", packet.pid); diff --git a/gst/mpegtsdemux/mpegtsbase.h b/gst/mpegtsdemux/mpegtsbase.h index e55cc5718..81099da25 100644 --- a/gst/mpegtsdemux/mpegtsbase.h +++ b/gst/mpegtsdemux/mpegtsbase.h @@ -151,6 +151,10 @@ struct _MpegTSBase { /* Whether to parse private section or not */ gboolean parse_private_sections; + + /* Whether to push data and/or sections to subclasses */ + gboolean push_data; + gboolean push_section; }; struct _MpegTSBaseClass { diff --git a/gst/mpegtsdemux/mpegtsparse.c b/gst/mpegtsdemux/mpegtsparse.c index d83a2b266..dd3b58502 100644 --- a/gst/mpegtsdemux/mpegtsparse.c +++ b/gst/mpegtsdemux/mpegtsparse.c @@ -146,7 +146,12 @@ mpegts_parse_class_init (MpegTSParse2Class * klass) static void mpegts_parse_init (MpegTSParse2 * parse) { - GST_MPEGTS_BASE (parse)->program_size = sizeof (MpegTSParseProgram); + MpegTSBase *base = (MpegTSBase *) parse; + + base->program_size = sizeof (MpegTSParseProgram); + /* We will only need to handle data/section if we have request pads */ + base->push_data = FALSE; + base->push_section = FALSE; parse->srcpad = gst_pad_new_from_static_template (&src_template, "src"); parse->first = TRUE; @@ -269,6 +274,7 @@ static void mpegts_parse_pad_removed (GstElement * element, GstPad * pad) { MpegTSParsePad *tspad; + MpegTSBase *base = (MpegTSBase *) element; MpegTSParse2 *parse = GST_MPEGTS_PARSE (element); if (gst_pad_get_direction (pad) == GST_PAD_SINK) @@ -280,6 +286,10 @@ mpegts_parse_pad_removed (GstElement * element, GstPad * pad) parse->srcpads = g_list_remove_all (parse->srcpads, pad); } + if (parse->srcpads == NULL) { + base->push_data = FALSE; + base->push_section = FALSE; + } if (GST_ELEMENT_CLASS (parent_class)->pad_removed) GST_ELEMENT_CLASS (parent_class)->pad_removed (element, pad); @@ -289,6 +299,7 @@ static GstPad * mpegts_parse_request_new_pad (GstElement * element, GstPadTemplate * template, const gchar * padname, const GstCaps * caps) { + MpegTSBase *base = (MpegTSBase *) element; MpegTSParse2 *parse; MpegTSParsePad *tspad; MpegTSParseProgram *parseprogram; @@ -320,6 +331,8 @@ mpegts_parse_request_new_pad (GstElement * element, GstPadTemplate * template, pad = tspad->pad; parse->srcpads = g_list_append (parse->srcpads, pad); + base->push_data = TRUE; + base->push_section = TRUE; gst_pad_set_active (pad, TRUE); @@ -430,10 +443,6 @@ mpegts_parse_push (MpegTSBase * base, MpegTSPacketizerPacket * packet, GstFlowReturn ret; GList *srcpads; - /* Shortcut: If no request pads exist, just return */ - if (parse->srcpads == NULL) - return GST_FLOW_OK; - GST_OBJECT_LOCK (parse); srcpads = parse->srcpads; diff --git a/gst/mpegtsdemux/tsdemux.c b/gst/mpegtsdemux/tsdemux.c index 9a4e05fc2..c334e57b7 100644 --- a/gst/mpegtsdemux/tsdemux.c +++ b/gst/mpegtsdemux/tsdemux.c @@ -339,6 +339,9 @@ gst_ts_demux_init (GstTSDemux * demux) base->stream_size = sizeof (TSDemuxStream); base->parse_private_sections = TRUE; + /* We are not interested in sections (all handled by mpegtsbase) */ + base->push_section = FALSE; + gst_ts_demux_reset (base); } @@ -1526,11 +1529,6 @@ gst_ts_demux_handle_packet (GstTSDemux * demux, TSDemuxStream * stream, packet->payload_unit_start_indicator, packet->scram_afc_cc & 0x30, FLAGS_CONTINUITY_COUNTER (packet->scram_afc_cc), packet->payload); - if (section) { - GST_LOG ("Got section, returning"); - return res; - } - if (G_UNLIKELY (packet->payload_unit_start_indicator) && FLAGS_HAS_PAYLOAD (packet->scram_afc_cc)) /* Flush previous data */ |