From 44c911d255a7a3596c2cdbf0d779cce34684d68a Mon Sep 17 00:00:00 2001 From: Zaheer Abbas Merali Date: Tue, 8 Jun 2010 14:09:00 +0200 Subject: [PATCH] flvmux: Add indexed property to replace disabled is-live. Add indexed property to be the negation of what the disabled is-live property was. Fixes bug #613066. --- gst/flv/gstflvmux.c | 39 +++++++++++++++++++-------------------- gst/flv/gstflvmux.h | 2 +- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/gst/flv/gstflvmux.c b/gst/flv/gstflvmux.c index 883ebb7563..eb0d561317 100644 --- a/gst/flv/gstflvmux.c +++ b/gst/flv/gstflvmux.c @@ -26,7 +26,7 @@ * * Example launch line * |[ - * gst-launch -v filesrc location=/path/to/audio ! decodebin2 ! queue ! flvmux name=m ! filesink location=file.flv filesrc location=/path/to/video ! decodebin2 ! queue ! m. + * gst-launch -v filesrc location=/path/to/audio ! decodebin2 ! queue ! flvmux name=m ! filesink location=file.flv filesrc location=/path/to/video ! decodebin2 ! queue ! m. * ]| This pipeline muxes an audio and video file into a single FLV file. * */ @@ -46,10 +46,10 @@ GST_DEBUG_CATEGORY_STATIC (flvmux_debug); enum { PROP_0, - PROP_IS_LIVE + PROP_INDEXED }; -#define DEFAULT_IS_LIVE FALSE +#define DEFAULT_INDEXED TRUE #define MAX_INDEX_ENTRIES 128 static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", @@ -160,14 +160,13 @@ gst_flv_mux_class_init (GstFlvMuxClass * klass) gobject_class->set_property = gst_flv_mux_set_property; gobject_class->finalize = gst_flv_mux_finalize; - /* FIXME: disabled for release, needs a better/less wrong name; ideally the - * right mode of operation should be detected automatically using queries */ -#if 0 - g_object_class_install_property (gobject_class, PROP_IS_LIVE, - g_param_spec_boolean ("is-live", "Is Live", - "The stream is live and does not need an index", DEFAULT_IS_LIVE, + /* FIXME: ideally the right mode of operation should be detected + * automatically using queries when parameter not specified. */ + g_object_class_install_property (gobject_class, PROP_INDEXED, + g_param_spec_boolean ("indexed", "indexed", + "If set to false, the output should be as if it is to be streamed " + "and hence no indexes written or duration written.", DEFAULT_INDEXED, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); -#endif gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_flv_mux_change_state); gstelement_class->request_new_pad = @@ -183,7 +182,7 @@ gst_flv_mux_init (GstFlvMux * mux, GstFlvMuxClass * g_class) gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad); /* property */ - mux->is_live = DEFAULT_IS_LIVE; + mux->indexed = DEFAULT_INDEXED; mux->collect = gst_collect_pads_new (); gst_collect_pads_set_function (mux->collect, @@ -678,13 +677,13 @@ gst_flv_mux_create_metadata (GstFlvMux * mux) /* Sometimes the information about the total file size is useful for the player. It will be filled later, after getting EOS */ - if (!mux->is_live) { + if (mux->indexed) { tmp = gst_flv_mux_create_number_script_value ("filesize", 0); script_tag = gst_buffer_join (script_tag, tmp); tags_written++; } - if (!mux->is_live) { + if (mux->indexed) { tmp = gst_flv_mux_preallocate_index (mux); script_tag = gst_buffer_join (script_tag, tmp); } else { @@ -1184,7 +1183,7 @@ gst_flv_mux_write_buffer (GstFlvMux * mux, GstFlvPad * cpad) gst_collect_pads_pop (mux->collect, (GstCollectData *) cpad); GstFlowReturn ret; - if (!mux->is_live) + if (mux->indexed) gst_flv_mux_update_index (mux, buffer, cpad); tag = gst_flv_mux_buffer_to_tag (mux, buffer, cpad); @@ -1239,7 +1238,7 @@ gst_flv_mux_rewrite_header (GstFlvMux * mux) guint32 index_len, allocate_size; guint32 i, index_skip; - if (mux->is_live) + if (!mux->indexed) return GST_FLOW_OK; /* seek back to the preallocated index space */ @@ -1426,7 +1425,7 @@ gst_flv_mux_collected (GstCollectPads * pads, gpointer user_data) /* The FLV timestamp is an int32 field. For non-live streams error out if a bigger timestamp is seen, for live the timestamp will get wrapped in gst_flv_mux_buffer_to_tag */ - if (!mux->is_live && GST_CLOCK_TIME_IS_VALID (best_time) + if (mux->indexed && GST_CLOCK_TIME_IS_VALID (best_time) && best_time / GST_MSECOND > G_MAXINT32) { GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS"); eos = TRUE; @@ -1450,8 +1449,8 @@ gst_flv_mux_get_property (GObject * object, GstFlvMux *mux = GST_FLV_MUX (object); switch (prop_id) { - case PROP_IS_LIVE: - g_value_set_boolean (value, mux->is_live); + case PROP_INDEXED: + g_value_set_boolean (value, mux->indexed); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -1466,8 +1465,8 @@ gst_flv_mux_set_property (GObject * object, GstFlvMux *mux = GST_FLV_MUX (object); switch (prop_id) { - case PROP_IS_LIVE: - mux->is_live = g_value_get_boolean (value); + case PROP_INDEXED: + mux->indexed = g_value_get_boolean (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); diff --git a/gst/flv/gstflvmux.h b/gst/flv/gstflvmux.h index 74d932baae..66e5fb84f1 100644 --- a/gst/flv/gstflvmux.h +++ b/gst/flv/gstflvmux.h @@ -73,7 +73,7 @@ typedef struct _GstFlvMux { GstFlvMuxState state; gboolean have_audio; gboolean have_video; - gboolean is_live; + gboolean indexed; GstTagList *tags; GList *index;