summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim-Philipp Müller <tim@centricular.com>2015-08-08 15:45:59 +0100
committerTim-Philipp Müller <tim@centricular.com>2015-08-08 16:19:09 +0100
commit424426f48646d40ee4930582bc986ade99bfd645 (patch)
tree4a481cf58ebdd2c3272b718366e60c239ff4eadf
parent4fd7b2408eca30d1e60c743e2c8a37b94fab46cd (diff)
downloadgstreamer-plugins-bad-424426f48646d40ee4930582bc986ade99bfd645.tar.gz
asfmux: output TIME segment if we output a stream and won't seek back later
Check if downstream is seekable via a SEEKING query and output a BYTE segment if we want to seek back to fix up the headers later, but if we're streaming send a TIME segment instead (which goes down better with e.g. asfmux ! rtpasfpay). https://bugzilla.gnome.org/show_bug.cgi?id=719553
-rw-r--r--gst/asfmux/gstasfmux.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/gst/asfmux/gstasfmux.c b/gst/asfmux/gstasfmux.c
index 7614de571..c77f8b63f 100644
--- a/gst/asfmux/gstasfmux.c
+++ b/gst/asfmux/gstasfmux.c
@@ -1265,6 +1265,31 @@ gst_asf_mux_start_file (GstAsfMux * asfmux)
if (padding < ASF_PADDING_OBJECT_SIZE)
padding = 0;
+ /* if not streaming, check if downstream is seekable */
+ if (!asfmux->prop_streamable) {
+ gboolean seekable;
+ GstQuery *query;
+
+ query = gst_query_new_seeking (GST_FORMAT_BYTES);
+ if (gst_pad_peer_query (asfmux->srcpad, query)) {
+ gst_query_parse_seeking (query, NULL, &seekable, NULL, NULL);
+ GST_INFO_OBJECT (asfmux, "downstream is %sseekable",
+ seekable ? "" : "not ");
+ } else {
+ /* assume seeking is not supported if query not handled downstream */
+ GST_WARNING_OBJECT (asfmux, "downstream did not handle seeking query");
+ seekable = FALSE;
+ }
+ if (!seekable) {
+ asfmux->prop_streamable = TRUE;
+ g_object_notify (G_OBJECT (asfmux), "streamable");
+ GST_WARNING_OBJECT (asfmux, "downstream is not seekable, but "
+ "streamable=false. Will ignore that and create streamable output "
+ "instead");
+ }
+ gst_query_unref (query);
+ }
+
/* from this point we started writing the headers */
GST_INFO_OBJECT (asfmux, "Writing headers");
asfmux->state = GST_ASF_MUX_STATE_HEADERS;
@@ -1277,8 +1302,12 @@ gst_asf_mux_start_file (GstAsfMux * asfmux)
gst_pad_set_caps (asfmux->srcpad, caps);
gst_caps_unref (caps);
- /* let downstream know we think in BYTES and expect to do seeking later */
- gst_segment_init (&segment, GST_FORMAT_BYTES);
+ /* send a BYTE format segment if we're going to seek to fix up the headers
+ * later, otherwise send a TIME segment */
+ if (asfmux->prop_streamable)
+ gst_segment_init (&segment, GST_FORMAT_TIME);
+ else
+ gst_segment_init (&segment, GST_FORMAT_BYTES);
gst_pad_push_event (asfmux->srcpad, gst_event_new_segment (&segment));
gst_asf_generate_file_id (&asfmux->file_id);