mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
tagmux: fix up private base class header so it can be made public
Move private bits into a private struct, add some padding. https://bugzilla.gnome.org/show_bug.cgi?id=555437
This commit is contained in:
parent
33428b79f9
commit
1c3229307e
3 changed files with 132 additions and 102 deletions
|
@ -1,5 +1,4 @@
|
||||||
/* GStreamer tag muxer base class
|
/* GStreamer tag muxer base class
|
||||||
*
|
|
||||||
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
||||||
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
||||||
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
@ -31,6 +30,23 @@
|
||||||
|
|
||||||
#include "gsttagmux.h"
|
#include "gsttagmux.h"
|
||||||
|
|
||||||
|
struct _GstTagMuxPrivate
|
||||||
|
{
|
||||||
|
GstPad *srcpad;
|
||||||
|
GstPad *sinkpad;
|
||||||
|
GstTagList *event_tags; /* tags received from upstream elements */
|
||||||
|
GstTagList *final_tags; /* Final set of tags used for muxing */
|
||||||
|
gsize start_tag_size;
|
||||||
|
gsize end_tag_size;
|
||||||
|
gboolean render_start_tag;
|
||||||
|
gboolean render_end_tag;
|
||||||
|
|
||||||
|
gint64 current_offset;
|
||||||
|
gint64 max_offset;
|
||||||
|
|
||||||
|
GstEvent *newsegment_ev; /* cached newsegment event from upstream */
|
||||||
|
};
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_STATIC (gst_tag_mux_debug);
|
GST_DEBUG_CATEGORY_STATIC (gst_tag_mux_debug);
|
||||||
#define GST_CAT_DEFAULT gst_tag_mux_debug
|
#define GST_CAT_DEFAULT gst_tag_mux_debug
|
||||||
|
|
||||||
|
@ -74,19 +90,19 @@ gst_tag_mux_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
GstTagMux *mux = GST_TAG_MUX (obj);
|
GstTagMux *mux = GST_TAG_MUX (obj);
|
||||||
|
|
||||||
if (mux->newsegment_ev) {
|
if (mux->priv->newsegment_ev) {
|
||||||
gst_event_unref (mux->newsegment_ev);
|
gst_event_unref (mux->priv->newsegment_ev);
|
||||||
mux->newsegment_ev = NULL;
|
mux->priv->newsegment_ev = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->event_tags) {
|
if (mux->priv->event_tags) {
|
||||||
gst_tag_list_free (mux->event_tags);
|
gst_tag_list_free (mux->priv->event_tags);
|
||||||
mux->event_tags = NULL;
|
mux->priv->event_tags = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->final_tags) {
|
if (mux->priv->final_tags) {
|
||||||
gst_tag_list_free (mux->final_tags);
|
gst_tag_list_free (mux->priv->final_tags);
|
||||||
mux->final_tags = NULL;
|
mux->priv->final_tags = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||||
|
@ -115,6 +131,8 @@ gst_tag_mux_class_init (GstTagMuxClass * klass)
|
||||||
|
|
||||||
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_tag_mux_finalize);
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_tag_mux_finalize);
|
||||||
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_tag_mux_change_state);
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_tag_mux_change_state);
|
||||||
|
|
||||||
|
g_type_class_add_private (klass, sizeof (GstTagMuxPrivate));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -123,26 +141,30 @@ gst_tag_mux_init (GstTagMux * mux, GstTagMuxClass * mux_class)
|
||||||
GstElementClass *element_klass = GST_ELEMENT_CLASS (mux_class);
|
GstElementClass *element_klass = GST_ELEMENT_CLASS (mux_class);
|
||||||
GstPadTemplate *tmpl;
|
GstPadTemplate *tmpl;
|
||||||
|
|
||||||
|
mux->priv =
|
||||||
|
G_TYPE_INSTANCE_GET_PRIVATE (mux, GST_TYPE_TAG_MUX, GstTagMuxPrivate);
|
||||||
|
|
||||||
/* pad through which data comes in to the element */
|
/* pad through which data comes in to the element */
|
||||||
mux->sinkpad =
|
mux->priv->sinkpad =
|
||||||
gst_pad_new_from_static_template (&gst_tag_mux_sink_template, "sink");
|
gst_pad_new_from_static_template (&gst_tag_mux_sink_template, "sink");
|
||||||
gst_pad_set_chain_function (mux->sinkpad,
|
gst_pad_set_chain_function (mux->priv->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_tag_mux_chain));
|
GST_DEBUG_FUNCPTR (gst_tag_mux_chain));
|
||||||
gst_pad_set_event_function (mux->sinkpad,
|
gst_pad_set_event_function (mux->priv->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_tag_mux_sink_event));
|
GST_DEBUG_FUNCPTR (gst_tag_mux_sink_event));
|
||||||
gst_element_add_pad (GST_ELEMENT (mux), mux->sinkpad);
|
gst_element_add_pad (GST_ELEMENT (mux), mux->priv->sinkpad);
|
||||||
|
|
||||||
/* pad through which data goes out of the element */
|
/* pad through which data goes out of the element */
|
||||||
tmpl = gst_element_class_get_pad_template (element_klass, "src");
|
tmpl = gst_element_class_get_pad_template (element_klass, "src");
|
||||||
if (tmpl) {
|
if (tmpl) {
|
||||||
mux->srcpad = gst_pad_new_from_template (tmpl, "src");
|
mux->priv->srcpad = gst_pad_new_from_template (tmpl, "src");
|
||||||
gst_pad_use_fixed_caps (mux->srcpad);
|
gst_pad_use_fixed_caps (mux->priv->srcpad);
|
||||||
gst_pad_set_caps (mux->srcpad, gst_pad_template_get_caps (tmpl));
|
/* FIXME: we assume the template caps are fixed.. */
|
||||||
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
gst_pad_set_caps (mux->priv->srcpad, gst_pad_template_get_caps (tmpl));
|
||||||
|
gst_element_add_pad (GST_ELEMENT (mux), mux->priv->srcpad);
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->render_start_tag = TRUE;
|
mux->priv->render_start_tag = TRUE;
|
||||||
mux->render_end_tag = TRUE;
|
mux->priv->render_end_tag = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstTagList *
|
static GstTagList *
|
||||||
|
@ -152,22 +174,22 @@ gst_tag_mux_get_tags (GstTagMux * mux)
|
||||||
const GstTagList *tagsetter_tags;
|
const GstTagList *tagsetter_tags;
|
||||||
GstTagMergeMode merge_mode;
|
GstTagMergeMode merge_mode;
|
||||||
|
|
||||||
if (mux->final_tags)
|
if (mux->priv->final_tags)
|
||||||
return mux->final_tags;
|
return mux->priv->final_tags;
|
||||||
|
|
||||||
tagsetter_tags = gst_tag_setter_get_tag_list (tagsetter);
|
tagsetter_tags = gst_tag_setter_get_tag_list (tagsetter);
|
||||||
merge_mode = gst_tag_setter_get_tag_merge_mode (tagsetter);
|
merge_mode = gst_tag_setter_get_tag_merge_mode (tagsetter);
|
||||||
|
|
||||||
GST_LOG_OBJECT (mux, "merging tags, merge mode = %d", merge_mode);
|
GST_LOG_OBJECT (mux, "merging tags, merge mode = %d", merge_mode);
|
||||||
GST_LOG_OBJECT (mux, "event tags: %" GST_PTR_FORMAT, mux->event_tags);
|
GST_LOG_OBJECT (mux, "event tags: %" GST_PTR_FORMAT, mux->priv->event_tags);
|
||||||
GST_LOG_OBJECT (mux, "set tags: %" GST_PTR_FORMAT, tagsetter_tags);
|
GST_LOG_OBJECT (mux, "set tags: %" GST_PTR_FORMAT, tagsetter_tags);
|
||||||
|
|
||||||
mux->final_tags =
|
mux->priv->final_tags =
|
||||||
gst_tag_list_merge (tagsetter_tags, mux->event_tags, merge_mode);
|
gst_tag_list_merge (tagsetter_tags, mux->priv->event_tags, merge_mode);
|
||||||
|
|
||||||
GST_LOG_OBJECT (mux, "final tags: %" GST_PTR_FORMAT, mux->final_tags);
|
GST_LOG_OBJECT (mux, "final tags: %" GST_PTR_FORMAT, mux->priv->final_tags);
|
||||||
|
|
||||||
return mux->final_tags;
|
return mux->priv->final_tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
@ -191,29 +213,35 @@ gst_tag_mux_render_start_tag (GstTagMux * mux)
|
||||||
/* Null buffer is ok, just means we're not outputting anything */
|
/* Null buffer is ok, just means we're not outputting anything */
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
GST_INFO_OBJECT (mux, "No start tag generated");
|
GST_INFO_OBJECT (mux, "No start tag generated");
|
||||||
mux->start_tag_size = 0;
|
mux->priv->start_tag_size = 0;
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->start_tag_size = GST_BUFFER_SIZE (buffer);
|
if (GST_BUFFER_CAPS (buffer) == NULL) {
|
||||||
|
buffer = gst_buffer_make_metadata_writable (buffer);
|
||||||
|
gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->priv->srcpad));
|
||||||
|
}
|
||||||
|
|
||||||
|
mux->priv->start_tag_size = GST_BUFFER_SIZE (buffer);
|
||||||
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes",
|
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes",
|
||||||
mux->start_tag_size);
|
mux->priv->start_tag_size);
|
||||||
|
|
||||||
/* Send newsegment event from byte position 0, so the tag really gets
|
/* Send newsegment event from byte position 0, so the tag really gets
|
||||||
* written to the start of the file, independent of the upstream segment */
|
* written to the start of the file, independent of the upstream segment */
|
||||||
gst_pad_push_event (mux->srcpad,
|
gst_pad_push_event (mux->priv->srcpad,
|
||||||
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
|
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
|
||||||
|
|
||||||
/* Send an event about the new tags to downstream elements */
|
/* Send an event about the new tags to downstream elements */
|
||||||
/* gst_event_new_tag takes ownership of the list, so use a copy */
|
/* gst_event_new_tag takes ownership of the list, so use a copy */
|
||||||
event = gst_event_new_tag (gst_tag_list_copy (taglist));
|
event = gst_event_new_tag (gst_tag_list_copy (taglist));
|
||||||
gst_pad_push_event (mux->srcpad, event);
|
gst_pad_push_event (mux->priv->srcpad, event);
|
||||||
|
|
||||||
GST_BUFFER_OFFSET (buffer) = 0;
|
GST_BUFFER_OFFSET (buffer) = 0;
|
||||||
ret = gst_pad_push (mux->srcpad, buffer);
|
ret = gst_pad_push (mux->priv->srcpad, buffer);
|
||||||
|
|
||||||
mux->current_offset = mux->start_tag_size;
|
mux->priv->current_offset = mux->priv->start_tag_size;
|
||||||
mux->max_offset = MAX (mux->max_offset, mux->current_offset);
|
mux->priv->max_offset =
|
||||||
|
MAX (mux->priv->max_offset, mux->priv->current_offset);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -244,22 +272,27 @@ gst_tag_mux_render_end_tag (GstTagMux * mux)
|
||||||
|
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
GST_INFO_OBJECT (mux, "No end tag generated");
|
GST_INFO_OBJECT (mux, "No end tag generated");
|
||||||
mux->end_tag_size = 0;
|
mux->priv->end_tag_size = 0;
|
||||||
return GST_FLOW_OK;
|
return GST_FLOW_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->end_tag_size = GST_BUFFER_SIZE (buffer);
|
if (GST_BUFFER_CAPS (buffer) == NULL) {
|
||||||
|
buffer = gst_buffer_make_metadata_writable (buffer);
|
||||||
|
gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->priv->srcpad));
|
||||||
|
}
|
||||||
|
|
||||||
|
mux->priv->end_tag_size = GST_BUFFER_SIZE (buffer);
|
||||||
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes",
|
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes",
|
||||||
mux->end_tag_size);
|
mux->priv->end_tag_size);
|
||||||
|
|
||||||
/* Send newsegment event from the end of the file, so it gets written there,
|
/* Send newsegment event from the end of the file, so it gets written there,
|
||||||
independent of whatever new segment events upstream has sent us */
|
independent of whatever new segment events upstream has sent us */
|
||||||
gst_pad_push_event (mux->srcpad,
|
gst_pad_push_event (mux->priv->srcpad,
|
||||||
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, mux->max_offset,
|
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES,
|
||||||
-1, 0));
|
mux->priv->max_offset, -1, 0));
|
||||||
|
|
||||||
GST_BUFFER_OFFSET (buffer) = mux->max_offset;
|
GST_BUFFER_OFFSET (buffer) = mux->priv->max_offset;
|
||||||
ret = gst_pad_push (mux->srcpad, buffer);
|
ret = gst_pad_push (mux->priv->srcpad, buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
@ -284,15 +317,16 @@ gst_tag_mux_adjust_event_offsets (GstTagMux * mux,
|
||||||
g_assert (format == GST_FORMAT_BYTES);
|
g_assert (format == GST_FORMAT_BYTES);
|
||||||
|
|
||||||
if (start != -1)
|
if (start != -1)
|
||||||
start += mux->start_tag_size;
|
start += mux->priv->start_tag_size;
|
||||||
if (stop != -1)
|
if (stop != -1)
|
||||||
stop += mux->start_tag_size;
|
stop += mux->priv->start_tag_size;
|
||||||
if (cur != -1)
|
if (cur != -1)
|
||||||
cur += mux->start_tag_size;
|
cur += mux->priv->start_tag_size;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mux, "adjusting newsegment event offsets to start=%"
|
GST_DEBUG_OBJECT (mux, "adjusting newsegment event offsets to start=%"
|
||||||
G_GINT64_FORMAT ", stop=%" G_GINT64_FORMAT ", cur=%" G_GINT64_FORMAT
|
G_GINT64_FORMAT ", stop=%" G_GINT64_FORMAT ", cur=%" G_GINT64_FORMAT
|
||||||
" (delta = +%" G_GSIZE_FORMAT ")", start, stop, cur, mux->start_tag_size);
|
" (delta = +%" G_GSIZE_FORMAT ")", start, stop, cur,
|
||||||
|
mux->priv->start_tag_size);
|
||||||
|
|
||||||
return gst_event_new_new_segment (TRUE, 1.0, format, start, stop, cur);
|
return gst_event_new_new_segment (TRUE, 1.0, format, start, stop, cur);
|
||||||
}
|
}
|
||||||
|
@ -304,7 +338,7 @@ gst_tag_mux_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if (mux->render_start_tag) {
|
if (mux->priv->render_start_tag) {
|
||||||
|
|
||||||
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
||||||
ret = gst_tag_mux_render_start_tag (mux);
|
ret = gst_tag_mux_render_start_tag (mux);
|
||||||
|
@ -315,26 +349,27 @@ gst_tag_mux_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now send the cached newsegment event that we got from upstream */
|
/* Now send the cached newsegment event that we got from upstream */
|
||||||
if (mux->newsegment_ev) {
|
if (mux->priv->newsegment_ev) {
|
||||||
gint64 start;
|
gint64 start;
|
||||||
GstEvent *newseg;
|
GstEvent *newseg;
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mux, "sending cached newsegment event");
|
GST_DEBUG_OBJECT (mux, "sending cached newsegment event");
|
||||||
newseg = gst_tag_mux_adjust_event_offsets (mux, mux->newsegment_ev);
|
newseg = gst_tag_mux_adjust_event_offsets (mux, mux->priv->newsegment_ev);
|
||||||
gst_event_unref (mux->newsegment_ev);
|
gst_event_unref (mux->priv->newsegment_ev);
|
||||||
mux->newsegment_ev = NULL;
|
mux->priv->newsegment_ev = NULL;
|
||||||
|
|
||||||
gst_event_parse_new_segment (newseg, NULL, NULL, NULL, &start, NULL,
|
gst_event_parse_new_segment (newseg, NULL, NULL, NULL, &start, NULL,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
gst_pad_push_event (mux->srcpad, newseg);
|
gst_pad_push_event (mux->priv->srcpad, newseg);
|
||||||
mux->current_offset = start;
|
mux->priv->current_offset = start;
|
||||||
mux->max_offset = MAX (mux->max_offset, mux->current_offset);
|
mux->priv->max_offset =
|
||||||
|
MAX (mux->priv->max_offset, mux->priv->current_offset);
|
||||||
} else {
|
} else {
|
||||||
/* upstream sent no newsegment event or only one in a non-BYTE format */
|
/* upstream sent no newsegment event or only one in a non-BYTE format */
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->render_start_tag = FALSE;
|
mux->priv->render_start_tag = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer = gst_buffer_make_metadata_writable (buffer);
|
buffer = gst_buffer_make_metadata_writable (buffer);
|
||||||
|
@ -342,17 +377,18 @@ gst_tag_mux_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
if (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) {
|
if (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) {
|
||||||
GST_LOG_OBJECT (mux, "Adjusting buffer offset from %" G_GINT64_FORMAT
|
GST_LOG_OBJECT (mux, "Adjusting buffer offset from %" G_GINT64_FORMAT
|
||||||
" to %" G_GINT64_FORMAT, GST_BUFFER_OFFSET (buffer),
|
" to %" G_GINT64_FORMAT, GST_BUFFER_OFFSET (buffer),
|
||||||
GST_BUFFER_OFFSET (buffer) + mux->start_tag_size);
|
GST_BUFFER_OFFSET (buffer) + mux->priv->start_tag_size);
|
||||||
GST_BUFFER_OFFSET (buffer) += mux->start_tag_size;
|
GST_BUFFER_OFFSET (buffer) += mux->priv->start_tag_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
length = GST_BUFFER_SIZE (buffer);
|
length = GST_BUFFER_SIZE (buffer);
|
||||||
|
|
||||||
gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->srcpad));
|
gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->priv->srcpad));
|
||||||
ret = gst_pad_push (mux->srcpad, buffer);
|
ret = gst_pad_push (mux->priv->srcpad, buffer);
|
||||||
|
|
||||||
mux->current_offset += length;
|
mux->priv->current_offset += length;
|
||||||
mux->max_offset = MAX (mux->max_offset, mux->current_offset);
|
mux->priv->max_offset =
|
||||||
|
MAX (mux->priv->max_offset, mux->priv->current_offset);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -374,14 +410,15 @@ gst_tag_mux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
|
|
||||||
GST_INFO_OBJECT (mux, "Got tag event: %" GST_PTR_FORMAT, tags);
|
GST_INFO_OBJECT (mux, "Got tag event: %" GST_PTR_FORMAT, tags);
|
||||||
|
|
||||||
if (mux->event_tags != NULL) {
|
if (mux->priv->event_tags != NULL) {
|
||||||
gst_tag_list_insert (mux->event_tags, tags, GST_TAG_MERGE_REPLACE);
|
gst_tag_list_insert (mux->priv->event_tags, tags,
|
||||||
|
GST_TAG_MERGE_REPLACE);
|
||||||
} else {
|
} else {
|
||||||
mux->event_tags = gst_tag_list_copy (tags);
|
mux->priv->event_tags = gst_tag_list_copy (tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_INFO_OBJECT (mux, "Event tags are now: %" GST_PTR_FORMAT,
|
GST_INFO_OBJECT (mux, "Event tags are now: %" GST_PTR_FORMAT,
|
||||||
mux->event_tags);
|
mux->priv->event_tags);
|
||||||
|
|
||||||
/* just drop the event, we'll push a new tag event in render_start_tag */
|
/* just drop the event, we'll push a new tag event in render_start_tag */
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
@ -401,34 +438,35 @@ gst_tag_mux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mux->render_start_tag) {
|
if (mux->priv->render_start_tag) {
|
||||||
/* we have not rendered the tag yet, which means that we don't know
|
/* we have not rendered the tag yet, which means that we don't know
|
||||||
* how large it is going to be yet, so we can't adjust the offsets
|
* how large it is going to be yet, so we can't adjust the offsets
|
||||||
* here at this point and need to cache the newsegment event for now
|
* here at this point and need to cache the newsegment event for now
|
||||||
* (also, there could be tag events coming after this newsegment event
|
* (also, there could be tag events coming after this newsegment event
|
||||||
* and before the first buffer). */
|
* and before the first buffer). */
|
||||||
if (mux->newsegment_ev) {
|
if (mux->priv->newsegment_ev) {
|
||||||
GST_WARNING_OBJECT (mux, "discarding old cached newsegment event");
|
GST_WARNING_OBJECT (mux, "discarding old cached newsegment event");
|
||||||
gst_event_unref (mux->newsegment_ev);
|
gst_event_unref (mux->priv->newsegment_ev);
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_LOG_OBJECT (mux, "caching newsegment event for later");
|
GST_LOG_OBJECT (mux, "caching newsegment event for later");
|
||||||
mux->newsegment_ev = event;
|
mux->priv->newsegment_ev = event;
|
||||||
} else {
|
} else {
|
||||||
GST_DEBUG_OBJECT (mux, "got newsegment event, adjusting offsets");
|
GST_DEBUG_OBJECT (mux, "got newsegment event, adjusting offsets");
|
||||||
gst_pad_push_event (mux->srcpad,
|
gst_pad_push_event (mux->priv->srcpad,
|
||||||
gst_tag_mux_adjust_event_offsets (mux, event));
|
gst_tag_mux_adjust_event_offsets (mux, event));
|
||||||
gst_event_unref (event);
|
gst_event_unref (event);
|
||||||
|
|
||||||
mux->current_offset = start;
|
mux->priv->current_offset = start;
|
||||||
mux->max_offset = MAX (mux->max_offset, mux->current_offset);
|
mux->priv->max_offset =
|
||||||
|
MAX (mux->priv->max_offset, mux->priv->current_offset);
|
||||||
}
|
}
|
||||||
event = NULL;
|
event = NULL;
|
||||||
result = TRUE;
|
result = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case GST_EVENT_EOS:{
|
case GST_EVENT_EOS:{
|
||||||
if (mux->render_end_tag) {
|
if (mux->priv->render_end_tag) {
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
|
||||||
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
||||||
|
@ -438,7 +476,7 @@ gst_tag_mux_sink_event (GstPad * pad, GstEvent * event)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
mux->render_end_tag = FALSE;
|
mux->priv->render_end_tag = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now forward EOS */
|
/* Now forward EOS */
|
||||||
|
@ -471,20 +509,20 @@ gst_tag_mux_change_state (GstElement * element, GstStateChange transition)
|
||||||
|
|
||||||
switch (transition) {
|
switch (transition) {
|
||||||
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
||||||
if (mux->newsegment_ev) {
|
if (mux->priv->newsegment_ev) {
|
||||||
gst_event_unref (mux->newsegment_ev);
|
gst_event_unref (mux->priv->newsegment_ev);
|
||||||
mux->newsegment_ev = NULL;
|
mux->priv->newsegment_ev = NULL;
|
||||||
}
|
}
|
||||||
if (mux->event_tags) {
|
if (mux->priv->event_tags) {
|
||||||
gst_tag_list_free (mux->event_tags);
|
gst_tag_list_free (mux->priv->event_tags);
|
||||||
mux->event_tags = NULL;
|
mux->priv->event_tags = NULL;
|
||||||
}
|
}
|
||||||
mux->start_tag_size = 0;
|
mux->priv->start_tag_size = 0;
|
||||||
mux->end_tag_size = 0;
|
mux->priv->end_tag_size = 0;
|
||||||
mux->render_start_tag = TRUE;
|
mux->priv->render_start_tag = TRUE;
|
||||||
mux->render_end_tag = TRUE;
|
mux->priv->render_end_tag = TRUE;
|
||||||
mux->current_offset = 0;
|
mux->priv->current_offset = 0;
|
||||||
mux->max_offset = 0;
|
mux->priv->max_offset = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -29,24 +29,16 @@ G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstTagMux GstTagMux;
|
typedef struct _GstTagMux GstTagMux;
|
||||||
typedef struct _GstTagMuxClass GstTagMuxClass;
|
typedef struct _GstTagMuxClass GstTagMuxClass;
|
||||||
|
typedef struct _GstTagMuxPrivate GstTagMuxPrivate;
|
||||||
|
|
||||||
/* Definition of structure storing data for this element. */
|
/* Definition of structure storing data for this element. */
|
||||||
struct _GstTagMux {
|
struct _GstTagMux {
|
||||||
GstElement element;
|
GstElement element;
|
||||||
|
|
||||||
GstPad *srcpad;
|
/*< private >*/
|
||||||
GstPad *sinkpad;
|
GstTagMuxPrivate *priv;
|
||||||
GstTagList *event_tags; /* tags received from upstream elements */
|
|
||||||
GstTagList *final_tags; /* Final set of tags used for muxing */
|
|
||||||
gsize start_tag_size;
|
|
||||||
gsize end_tag_size;
|
|
||||||
gboolean render_start_tag;
|
|
||||||
gboolean render_end_tag;
|
|
||||||
|
|
||||||
gint64 current_offset;
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
gint64 max_offset;
|
|
||||||
|
|
||||||
GstEvent *newsegment_ev; /* cached newsegment event from upstream */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Standard definition defining a class for this element. */
|
/* Standard definition defining a class for this element. */
|
||||||
|
@ -56,6 +48,9 @@ struct _GstTagMuxClass {
|
||||||
/* vfuncs */
|
/* vfuncs */
|
||||||
GstBuffer * (*render_start_tag) (GstTagMux * mux, GstTagList * tag_list);
|
GstBuffer * (*render_start_tag) (GstTagMux * mux, GstTagList * tag_list);
|
||||||
GstBuffer * (*render_end_tag) (GstTagMux * mux, GstTagList * tag_list);
|
GstBuffer * (*render_end_tag) (GstTagMux * mux, GstTagList * tag_list);
|
||||||
|
|
||||||
|
/*< private >*/
|
||||||
|
gpointer _gst_reserved[GST_PADDING];
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Standard macros for defining types for this element. */
|
/* Standard macros for defining types for this element. */
|
||||||
|
@ -76,4 +71,3 @@ GType gst_tag_mux_get_type (void);
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -1159,7 +1159,6 @@ id3_mux_render_v2_tag (GstTagMux * mux, GstTagList * taglist, int version)
|
||||||
|
|
||||||
/* Create buffer with tag */
|
/* Create buffer with tag */
|
||||||
buf = id3v2_tag_to_buffer (&tag);
|
buf = id3v2_tag_to_buffer (&tag);
|
||||||
gst_buffer_set_caps (buf, GST_PAD_CAPS (mux->srcpad));
|
|
||||||
GST_LOG_OBJECT (mux, "tag size = %d bytes", GST_BUFFER_SIZE (buf));
|
GST_LOG_OBJECT (mux, "tag size = %d bytes", GST_BUFFER_SIZE (buf));
|
||||||
|
|
||||||
id3v2_tag_unset (&tag);
|
id3v2_tag_unset (&tag);
|
||||||
|
@ -1312,6 +1311,5 @@ id3_mux_render_v1_tag (GstTagMux * mux, GstTagList * taglist)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
gst_buffer_set_caps (buf, GST_PAD_CAPS (mux->srcpad));
|
|
||||||
return buf;
|
return buf;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue