summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorZaheer Abbas Merali <zaheerabbas@merali.org>2008-02-05 12:19:46 +0000
committerZaheer Abbas Merali <zaheerabbas@merali.org>2008-02-05 12:19:46 +0000
commit9d8a7aa18ffb703ea942b16f4068a7e17548d65c (patch)
treef2db458b7ac5ccb60a7992b1f6c35d64a41ef641 /gst
parented4368e08f58c98864e28e31db1f2ce4cfa44923 (diff)
downloadgst-plugins-bad-9d8a7aa18ffb703ea942b16f4068a7e17548d65c.tar.gz
gst-plugins-bad-9d8a7aa18ffb703ea942b16f4068a7e17548d65c.tar.bz2
gst-plugins-bad-9d8a7aa18ffb703ea942b16f4068a7e17548d65c.zip
gst/mpegtsparse/mpegtsparse.c: Handle latency queries in src pads.
Original commit message from CVS: * gst/mpegtsparse/mpegtsparse.c: Handle latency queries in src pads.
Diffstat (limited to 'gst')
-rw-r--r--gst/mpegtsparse/mpegtsparse.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/gst/mpegtsparse/mpegtsparse.c b/gst/mpegtsparse/mpegtsparse.c
index c780876c..bf05d3cc 100644
--- a/gst/mpegtsparse/mpegtsparse.c
+++ b/gst/mpegtsparse/mpegtsparse.c
@@ -29,6 +29,9 @@
#include "mpegtsparse.h"
+/* latency in mseconds */
+#define TS_LATENCY 700
+
GST_DEBUG_CATEGORY_STATIC (mpegts_parse_debug);
#define GST_CAT_DEFAULT mpegts_parse_debug
@@ -125,6 +128,7 @@ static GstFlowReturn mpegts_parse_chain (GstPad * pad, GstBuffer * buf);
static gboolean mpegts_parse_sink_event (GstPad * pad, GstEvent * event);
static GstStateChangeReturn mpegts_parse_change_state (GstElement * element,
GstStateChange transition);
+static gboolean mpegts_parse_src_pad_query (GstPad * pad, GstQuery * query);
GST_BOILERPLATE (MpegTSParse, mpegts_parse, GstElement, GST_TYPE_ELEMENT);
@@ -553,6 +557,8 @@ mpegts_parse_create_tspad (MpegTSParse * parse, const gchar * pad_name)
MpegTSParsePad *tspad;
pad = gst_pad_new_from_static_template (&program_template, pad_name);
+ gst_pad_set_query_function (pad,
+ GST_DEBUG_FUNCPTR (mpegts_parse_src_pad_query));
/* create our wrapper */
tspad = g_new0 (MpegTSParsePad, 1);
@@ -1157,6 +1163,38 @@ mpegts_parse_change_state (GstElement * element, GstStateChange transition)
}
static gboolean
+mpegts_parse_src_pad_query (GstPad * pad, GstQuery * query)
+{
+ MpegTSParse *parse = GST_MPEGTS_PARSE (gst_pad_get_parent (pad));
+ gboolean res;
+
+ switch (GST_QUERY_TYPE (query)) {
+ case GST_QUERY_LATENCY:
+ {
+ if ((res = gst_pad_peer_query (parse->sinkpad, query))) {
+ gboolean is_live;
+ GstClockTime min_latency, max_latency;
+
+ gst_query_parse_latency (query, &is_live, &min_latency, &max_latency);
+ if (is_live) {
+ min_latency += TS_LATENCY * GST_MSECOND;
+ if (max_latency != GST_CLOCK_TIME_NONE)
+ max_latency += TS_LATENCY * GST_MSECOND;
+ }
+
+ gst_query_set_latency (query, is_live, min_latency, max_latency);
+ }
+
+ break;
+ }
+ default:
+ res = gst_pad_query_default (pad, query);
+ }
+
+ return res;
+}
+
+static gboolean
plugin_init (GstPlugin * plugin)
{
GST_DEBUG_CATEGORY_INIT (mpegts_parse_debug, "mpegtsparse", 0,