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.
This commit is contained in:
Zaheer Abbas Merali 2010-06-08 14:09:00 +02:00
parent 2f71143135
commit 44c911d255
2 changed files with 20 additions and 21 deletions

View file

@ -26,7 +26,7 @@
* <refsect2> * <refsect2>
* <title>Example launch line</title> * <title>Example launch line</title>
* |[ * |[
* 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. * ]| This pipeline muxes an audio and video file into a single FLV file.
* </refsect2> * </refsect2>
*/ */
@ -46,10 +46,10 @@ GST_DEBUG_CATEGORY_STATIC (flvmux_debug);
enum enum
{ {
PROP_0, PROP_0,
PROP_IS_LIVE PROP_INDEXED
}; };
#define DEFAULT_IS_LIVE FALSE #define DEFAULT_INDEXED TRUE
#define MAX_INDEX_ENTRIES 128 #define MAX_INDEX_ENTRIES 128
static GstStaticPadTemplate src_templ = GST_STATIC_PAD_TEMPLATE ("src", 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->set_property = gst_flv_mux_set_property;
gobject_class->finalize = gst_flv_mux_finalize; gobject_class->finalize = gst_flv_mux_finalize;
/* FIXME: disabled for release, needs a better/less wrong name; ideally the /* FIXME: ideally the right mode of operation should be detected
* right mode of operation should be detected automatically using queries */ * automatically using queries when parameter not specified. */
#if 0 g_object_class_install_property (gobject_class, PROP_INDEXED,
g_object_class_install_property (gobject_class, PROP_IS_LIVE, g_param_spec_boolean ("indexed", "indexed",
g_param_spec_boolean ("is-live", "Is Live", "If set to false, the output should be as if it is to be streamed "
"The stream is live and does not need an index", DEFAULT_IS_LIVE, "and hence no indexes written or duration written.", DEFAULT_INDEXED,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
#endif
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_flv_mux_change_state); gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_flv_mux_change_state);
gstelement_class->request_new_pad = 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); gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
/* property */ /* property */
mux->is_live = DEFAULT_IS_LIVE; mux->indexed = DEFAULT_INDEXED;
mux->collect = gst_collect_pads_new (); mux->collect = gst_collect_pads_new ();
gst_collect_pads_set_function (mux->collect, 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 /* Sometimes the information about the total file size is useful for the
player. It will be filled later, after getting EOS */ 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); tmp = gst_flv_mux_create_number_script_value ("filesize", 0);
script_tag = gst_buffer_join (script_tag, tmp); script_tag = gst_buffer_join (script_tag, tmp);
tags_written++; tags_written++;
} }
if (!mux->is_live) { if (mux->indexed) {
tmp = gst_flv_mux_preallocate_index (mux); tmp = gst_flv_mux_preallocate_index (mux);
script_tag = gst_buffer_join (script_tag, tmp); script_tag = gst_buffer_join (script_tag, tmp);
} else { } else {
@ -1184,7 +1183,7 @@ gst_flv_mux_write_buffer (GstFlvMux * mux, GstFlvPad * cpad)
gst_collect_pads_pop (mux->collect, (GstCollectData *) cpad); gst_collect_pads_pop (mux->collect, (GstCollectData *) cpad);
GstFlowReturn ret; GstFlowReturn ret;
if (!mux->is_live) if (mux->indexed)
gst_flv_mux_update_index (mux, buffer, cpad); gst_flv_mux_update_index (mux, buffer, cpad);
tag = gst_flv_mux_buffer_to_tag (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 index_len, allocate_size;
guint32 i, index_skip; guint32 i, index_skip;
if (mux->is_live) if (!mux->indexed)
return GST_FLOW_OK; return GST_FLOW_OK;
/* seek back to the preallocated index space */ /* 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 /* 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 bigger timestamp is seen, for live the timestamp will get wrapped in
gst_flv_mux_buffer_to_tag */ 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) { && best_time / GST_MSECOND > G_MAXINT32) {
GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS"); GST_WARNING_OBJECT (mux, "Timestamp larger than FLV supports - EOS");
eos = TRUE; eos = TRUE;
@ -1450,8 +1449,8 @@ gst_flv_mux_get_property (GObject * object,
GstFlvMux *mux = GST_FLV_MUX (object); GstFlvMux *mux = GST_FLV_MUX (object);
switch (prop_id) { switch (prop_id) {
case PROP_IS_LIVE: case PROP_INDEXED:
g_value_set_boolean (value, mux->is_live); g_value_set_boolean (value, mux->indexed);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 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); GstFlvMux *mux = GST_FLV_MUX (object);
switch (prop_id) { switch (prop_id) {
case PROP_IS_LIVE: case PROP_INDEXED:
mux->is_live = g_value_get_boolean (value); mux->indexed = g_value_get_boolean (value);
break; break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);

View file

@ -73,7 +73,7 @@ typedef struct _GstFlvMux {
GstFlvMuxState state; GstFlvMuxState state;
gboolean have_audio; gboolean have_audio;
gboolean have_video; gboolean have_video;
gboolean is_live; gboolean indexed;
GstTagList *tags; GstTagList *tags;
GList *index; GList *index;