mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
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.
This commit is contained in:
parent
8c32195d51
commit
fa5c02b211
1 changed files with 20 additions and 4 deletions
|
@ -644,7 +644,7 @@ gst_flv_mux_create_number_script_value (const gchar * name, gdouble value)
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
gst_flv_mux_create_metadata (GstFlvMux * mux)
|
gst_flv_mux_create_metadata (GstFlvMux * mux, gboolean full)
|
||||||
{
|
{
|
||||||
const GstTagList *tags;
|
const GstTagList *tags;
|
||||||
GstBuffer *script_tag, *tmp;
|
GstBuffer *script_tag, *tmp;
|
||||||
|
@ -687,6 +687,9 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
|
||||||
GST_WRITE_UINT32_BE (data + 1, n_tags);
|
GST_WRITE_UINT32_BE (data + 1, n_tags);
|
||||||
script_tag = gst_buffer_join (script_tag, tmp);
|
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,
|
/* Some players expect the 'duration' to be always set. Fill it out later,
|
||||||
after querying the pads or after getting EOS */
|
after querying the pads or after getting EOS */
|
||||||
if (!mux->streamable) {
|
if (!mux->streamable) {
|
||||||
|
@ -707,6 +710,7 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
|
||||||
GST_DEBUG_OBJECT (mux, "not preallocating index, streamable mode");
|
GST_DEBUG_OBJECT (mux, "not preallocating index, streamable mode");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tags:
|
||||||
for (i = 0; tags && i < n_tags; i++) {
|
for (i = 0; tags && i < n_tags; i++) {
|
||||||
const gchar *tag_name =
|
const gchar *tag_name =
|
||||||
gst_structure_nth_field_name ((const GstStructure *) tags, i);
|
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) {
|
if (mux->duration == GST_CLOCK_TIME_NONE) {
|
||||||
GSList *l;
|
GSList *l;
|
||||||
|
|
||||||
|
@ -926,6 +933,13 @@ gst_flv_mux_create_metadata (GstFlvMux * mux)
|
||||||
tags_written++;
|
tags_written++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
end:
|
||||||
|
|
||||||
|
if (!tags_written) {
|
||||||
|
gst_buffer_unref (script_tag);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
tmp = gst_buffer_new_and_alloc (2 + 0 + 1);
|
tmp = gst_buffer_new_and_alloc (2 + 0 + 1);
|
||||||
data = GST_BUFFER_DATA (tmp);
|
data = GST_BUFFER_DATA (tmp);
|
||||||
data[0] = 0; /* 0 byte size */
|
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);
|
GST_WRITE_UINT32_BE (data + 11 + 13 + 1, tags_written);
|
||||||
|
|
||||||
|
exit:
|
||||||
return script_tag;
|
return script_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1089,7 +1104,7 @@ gst_flv_mux_write_header (GstFlvMux * mux)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
header = gst_flv_mux_create_header (mux);
|
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;
|
video_codec_data = NULL;
|
||||||
audio_codec_data = NULL;
|
audio_codec_data = NULL;
|
||||||
|
|
||||||
|
@ -1407,7 +1422,8 @@ gst_flv_mux_handle_buffer (GstCollectPads2 * pads, GstCollectData2 * cdata,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->new_tags) {
|
if (mux->new_tags) {
|
||||||
GstBuffer *buf = gst_flv_mux_create_metadata (mux);
|
GstBuffer *buf = gst_flv_mux_create_metadata (mux, FALSE);
|
||||||
|
if (buf)
|
||||||
gst_flv_mux_push (mux, buf);
|
gst_flv_mux_push (mux, buf);
|
||||||
mux->new_tags = FALSE;
|
mux->new_tags = FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue