Permalink
Browse files

flvmux: only write full metadata at start

... rather than having (potentially) unnecessary duplicates written all over,
or even contradictory varying filesize info, or duration info that will not
be rewritten upon header rewrite.
  • Loading branch information...
1 parent 8c32195 commit fa5c02b211c0a9b746fb42260a41c05cde6e8675 Mark Nauwelaerts committed Dec 19, 2011
Showing with 20 additions and 4 deletions.
  1. +20 −4 gst/flv/gstflvmux.c
View
@@ -644,7 +644,7 @@ gst_flv_mux_create_number_script_value (const gchar * name, gdouble value)
}
static GstBuffer *
-gst_flv_mux_create_metadata (GstFlvMux * mux)
+gst_flv_mux_create_metadata (GstFlvMux * mux, gboolean full)
{
const GstTagList *tags;
GstBuffer *script_tag, *tmp;
@@ -687,6 +687,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
GST_WRITE_UINT32_BE (data + 1, n_tags);
script_tag = gst_buffer_join (script_tag, tmp);
+ if (!full)
+ goto tags;
+
/* Some players expect the 'duration' to be always set. Fill it out later,
after querying the pads or after getting EOS */
if (!mux->streamable) {
@@ -707,6 +710,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
GST_DEBUG_OBJECT (mux, "not preallocating index, streamable mode");
}
+tags:
for (i = 0; tags && i < n_tags; i++) {
const gchar *tag_name =
gst_structure_nth_field_name ((const GstStructure *) tags, i);
@@ -745,6 +749,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
}
}
+ if (!full)
+ goto end;
+
if (mux->duration == GST_CLOCK_TIME_NONE) {
GSList *l;
@@ -926,6 +933,13 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
tags_written++;
}
+end:
+
+ if (!tags_written) {
+ gst_buffer_unref (script_tag);
+ goto exit;
+ }
+
tmp = gst_buffer_new_and_alloc (2 + 0 + 1);
data = GST_BUFFER_DATA (tmp);
data[0] = 0; /* 0 byte size */
@@ -946,6 +960,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
GST_WRITE_UINT32_BE (data + 11 + 13 + 1, tags_written);
+exit:
return script_tag;
}
@@ -1089,7 +1104,7 @@ gst_flv_mux_write_header (GstFlvMux * mux)
GstFlowReturn ret;
header = gst_flv_mux_create_header (mux);
- metadata = gst_flv_mux_create_metadata (mux);
+ metadata = gst_flv_mux_create_metadata (mux, TRUE);
video_codec_data = NULL;
audio_codec_data = NULL;
@@ -1407,8 +1422,9 @@ gst_flv_mux_handle_buffer (GstCollectPads2 * pads, GstCollectData2 * cdata,
}
if (mux->new_tags) {
- GstBuffer *buf = gst_flv_mux_create_metadata (mux);
- gst_flv_mux_push (mux, buf);
+ GstBuffer *buf = gst_flv_mux_create_metadata (mux, FALSE);
+ if (buf)
+ gst_flv_mux_push (mux, buf);
mux->new_tags = FALSE;
}

0 comments on commit fa5c02b

Please sign in to comment.