2006-04-29 18:18:24 +00:00
|
|
|
/* GStreamer taglib-based muxer base class
|
|
|
|
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
|
|
|
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
2007-09-13 15:04:15 +00:00
|
|
|
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
2006-04-29 18:18:24 +00:00
|
|
|
|
2006-03-09 17:44:17 +00:00
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include <config.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
#include <gst/gsttagsetter.h>
|
2006-03-12 15:02:02 +00:00
|
|
|
#include <gst/tag/tag.h>
|
2006-05-01 11:46:33 +00:00
|
|
|
|
|
|
|
#include "gsttaglibmux.h"
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_tag_lib_mux_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_tag_lib_mux_debug
|
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
static GstStaticPadTemplate gst_tag_lib_mux_sink_template =
|
|
|
|
GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
2006-04-29 18:18:24 +00:00
|
|
|
GST_STATIC_CAPS ("ANY"));
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-03-09 17:44:17 +00:00
|
|
|
static void
|
|
|
|
gst_tag_lib_mux_iface_init (GType taglib_type)
|
|
|
|
{
|
|
|
|
static const GInterfaceInfo tag_setter_info = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
g_type_add_interface_static (taglib_type, GST_TYPE_TAG_SETTER,
|
|
|
|
&tag_setter_info);
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_BOILERPLATE_FULL (GstTagLibMux, gst_tag_lib_mux,
|
|
|
|
GstElement, GST_TYPE_ELEMENT, gst_tag_lib_mux_iface_init);
|
|
|
|
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_tag_lib_mux_change_state (GstElement * element, GstStateChange transition);
|
|
|
|
static GstFlowReturn gst_tag_lib_mux_chain (GstPad * pad, GstBuffer * buffer);
|
|
|
|
static gboolean gst_tag_lib_mux_sink_event (GstPad * pad, GstEvent * event);
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_tag_lib_mux_finalize (GObject * obj)
|
|
|
|
{
|
2006-04-28 15:33:09 +00:00
|
|
|
GstTagLibMux *mux = GST_TAG_LIB_MUX (obj);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->newsegment_ev) {
|
|
|
|
gst_event_unref (mux->newsegment_ev);
|
|
|
|
mux->newsegment_ev = NULL;
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->event_tags) {
|
|
|
|
gst_tag_list_free (mux->event_tags);
|
|
|
|
mux->event_tags = NULL;
|
2006-03-26 19:56:37 +00:00
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gst_tag_lib_mux_base_init (gpointer g_class)
|
|
|
|
{
|
|
|
|
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
|
|
|
|
|
|
|
|
gst_element_class_add_pad_template (element_class,
|
|
|
|
gst_static_pad_template_get (&gst_tag_lib_mux_sink_template));
|
2006-04-29 18:18:24 +00:00
|
|
|
|
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_tag_lib_mux_debug, "taglibmux", 0,
|
|
|
|
"taglib-based muxer");
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_tag_lib_mux_class_init (GstTagLibMuxClass * klass)
|
|
|
|
{
|
|
|
|
GObjectClass *gobject_class;
|
|
|
|
GstElementClass *gstelement_class;
|
|
|
|
|
|
|
|
gobject_class = (GObjectClass *) klass;
|
|
|
|
gstelement_class = (GstElementClass *) klass;
|
|
|
|
|
2010-06-06 16:00:22 +00:00
|
|
|
gobject_class->finalize = gst_tag_lib_mux_finalize;
|
2006-03-09 17:44:17 +00:00
|
|
|
gstelement_class->change_state =
|
|
|
|
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_change_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-04-29 18:18:24 +00:00
|
|
|
gst_tag_lib_mux_init (GstTagLibMux * mux, GstTagLibMuxClass * mux_class)
|
2006-03-09 17:44:17 +00:00
|
|
|
{
|
2006-04-29 18:18:24 +00:00
|
|
|
GstElementClass *element_klass = GST_ELEMENT_CLASS (mux_class);
|
|
|
|
GstPadTemplate *tmpl;
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
/* pad through which data comes in to the element */
|
2006-04-28 15:33:09 +00:00
|
|
|
mux->sinkpad =
|
2006-03-25 21:57:24 +00:00
|
|
|
gst_pad_new_from_static_template (&gst_tag_lib_mux_sink_template, "sink");
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_pad_set_chain_function (mux->sinkpad,
|
2006-03-09 17:44:17 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_chain));
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_pad_set_event_function (mux->sinkpad,
|
2006-03-09 17:44:17 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_sink_event));
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (mux), mux->sinkpad);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
/* pad through which data goes out of the element */
|
2006-04-29 18:18:24 +00:00
|
|
|
tmpl = gst_element_class_get_pad_template (element_klass, "src");
|
|
|
|
if (tmpl) {
|
|
|
|
mux->srcpad = gst_pad_new_from_template (tmpl, "src");
|
|
|
|
gst_pad_use_fixed_caps (mux->srcpad);
|
|
|
|
gst_pad_set_caps (mux->srcpad, gst_pad_template_get_caps (tmpl));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
2006-03-12 15:02:02 +00:00
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-29 18:18:24 +00:00
|
|
|
mux->render_tag = TRUE;
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstBuffer *
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_tag_lib_mux_render_tag (GstTagLibMux * mux)
|
2006-03-09 17:44:17 +00:00
|
|
|
{
|
2006-04-29 18:18:24 +00:00
|
|
|
GstTagLibMuxClass *klass;
|
2006-05-18 12:46:08 +00:00
|
|
|
GstTagMergeMode merge_mode;
|
|
|
|
GstTagSetter *tagsetter;
|
2006-03-09 17:44:17 +00:00
|
|
|
GstBuffer *buffer;
|
2006-03-26 19:56:37 +00:00
|
|
|
const GstTagList *tagsetter_tags;
|
2006-03-09 17:44:17 +00:00
|
|
|
GstTagList *taglist;
|
|
|
|
GstEvent *event;
|
|
|
|
|
2006-05-18 12:46:08 +00:00
|
|
|
tagsetter = GST_TAG_SETTER (mux);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
tagsetter_tags = gst_tag_setter_get_tag_list (tagsetter);
|
2006-05-18 12:46:08 +00:00
|
|
|
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, "event tags: %" GST_PTR_FORMAT, mux->event_tags);
|
|
|
|
GST_LOG_OBJECT (mux, "set tags: %" GST_PTR_FORMAT, tagsetter_tags);
|
|
|
|
|
|
|
|
taglist = gst_tag_list_merge (tagsetter_tags, mux->event_tags, merge_mode);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_LOG_OBJECT (mux, "final tags: %" GST_PTR_FORMAT, taglist);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-29 18:18:24 +00:00
|
|
|
klass = GST_TAG_LIB_MUX_CLASS (G_OBJECT_GET_CLASS (mux));
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-29 18:18:24 +00:00
|
|
|
if (klass->render_tag == NULL)
|
|
|
|
goto no_vfunc;
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-29 18:18:24 +00:00
|
|
|
buffer = klass->render_tag (mux, taglist);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-29 18:18:24 +00:00
|
|
|
if (buffer == NULL)
|
|
|
|
goto render_error;
|
|
|
|
|
|
|
|
mux->tag_size = GST_BUFFER_SIZE (buffer);
|
2007-11-20 11:41:13 +00:00
|
|
|
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes", mux->tag_size);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
|
|
|
/* Send newsegment event from byte position 0, so the tag really gets
|
|
|
|
* written to the start of the file, independent of the upstream segment */
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_pad_push_event (mux->srcpad,
|
2006-03-26 19:56:37 +00:00
|
|
|
gst_event_new_new_segment (FALSE, 1.0, GST_FORMAT_BYTES, 0, -1, 0));
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
/* Send an event about the new tags to downstream elements */
|
|
|
|
/* gst_event_new_tag takes ownership of the list, so no need to unref it */
|
|
|
|
event = gst_event_new_tag (taglist);
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_pad_push_event (mux->srcpad, event);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-03-25 21:57:24 +00:00
|
|
|
GST_BUFFER_OFFSET (buffer) = 0;
|
|
|
|
|
2006-03-09 17:44:17 +00:00
|
|
|
return buffer;
|
2006-04-29 18:18:24 +00:00
|
|
|
|
|
|
|
no_vfunc:
|
|
|
|
{
|
2006-04-29 18:46:36 +00:00
|
|
|
GST_ERROR_OBJECT (mux, "Subclass does not implement render_tag vfunc!");
|
2006-05-18 12:46:08 +00:00
|
|
|
gst_tag_list_free (taglist);
|
2006-04-29 18:46:36 +00:00
|
|
|
return NULL;
|
2006-04-29 18:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render_error:
|
|
|
|
{
|
2006-04-29 18:46:36 +00:00
|
|
|
GST_ERROR_OBJECT (mux, "Failed to render tag");
|
2006-05-18 12:46:08 +00:00
|
|
|
gst_tag_list_free (taglist);
|
2006-04-29 18:46:36 +00:00
|
|
|
return NULL;
|
2006-04-29 18:18:24 +00:00
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
static GstEvent *
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_tag_lib_mux_adjust_event_offsets (GstTagLibMux * mux,
|
2006-03-26 19:56:37 +00:00
|
|
|
const GstEvent * newsegment_event)
|
|
|
|
{
|
|
|
|
GstFormat format;
|
|
|
|
gint64 start, stop, cur;
|
|
|
|
|
|
|
|
gst_event_parse_new_segment ((GstEvent *) newsegment_event, NULL, NULL,
|
|
|
|
&format, &start, &stop, &cur);
|
|
|
|
|
|
|
|
g_assert (format == GST_FORMAT_BYTES);
|
|
|
|
|
|
|
|
if (start != -1)
|
2006-04-28 15:33:09 +00:00
|
|
|
start += mux->tag_size;
|
2006-03-26 19:56:37 +00:00
|
|
|
if (stop != -1)
|
2006-04-28 15:33:09 +00:00
|
|
|
stop += mux->tag_size;
|
2006-03-26 19:56:37 +00:00
|
|
|
if (cur != -1)
|
2006-04-28 15:33:09 +00:00
|
|
|
cur += mux->tag_size;
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "adjusting newsegment event offsets to start=%"
|
2006-03-26 19:56:37 +00:00
|
|
|
G_GINT64_FORMAT ", stop=%" G_GINT64_FORMAT ", cur=%" G_GINT64_FORMAT
|
2007-11-20 11:41:13 +00:00
|
|
|
" (delta = +%" G_GSIZE_FORMAT ")", start, stop, cur, mux->tag_size);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
|
|
|
return gst_event_new_new_segment (TRUE, 1.0, format, start, stop, cur);
|
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_tag_lib_mux_chain (GstPad * pad, GstBuffer * buffer)
|
|
|
|
{
|
2006-04-28 15:33:09 +00:00
|
|
|
GstTagLibMux *mux = GST_TAG_LIB_MUX (GST_OBJECT_PARENT (pad));
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->render_tag) {
|
2006-03-09 17:44:17 +00:00
|
|
|
GstFlowReturn ret;
|
2006-04-29 18:46:36 +00:00
|
|
|
GstBuffer *tag_buffer;
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
2006-04-29 18:46:36 +00:00
|
|
|
tag_buffer = gst_tag_lib_mux_render_tag (mux);
|
|
|
|
if (tag_buffer == NULL)
|
|
|
|
goto no_tag_buffer;
|
|
|
|
ret = gst_pad_push (mux->srcpad, tag_buffer);
|
2006-03-09 17:44:17 +00:00
|
|
|
if (ret != GST_FLOW_OK) {
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "flow: %s", gst_flow_get_name (ret));
|
2006-03-09 17:44:17 +00:00
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
return ret;
|
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
|
|
|
|
/* Now send the cached newsegment event that we got from upstream */
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->newsegment_ev) {
|
|
|
|
GST_DEBUG_OBJECT (mux, "sending cached newsegment event");
|
|
|
|
gst_pad_push_event (mux->srcpad,
|
|
|
|
gst_tag_lib_mux_adjust_event_offsets (mux, mux->newsegment_ev));
|
|
|
|
gst_event_unref (mux->newsegment_ev);
|
|
|
|
mux->newsegment_ev = NULL;
|
2006-03-26 19:56:37 +00:00
|
|
|
} else {
|
|
|
|
/* upstream sent no newsegment event or only one in a non-BYTE format */
|
|
|
|
}
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
mux->render_tag = FALSE;
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
buffer = gst_buffer_make_metadata_writable (buffer);
|
|
|
|
|
2006-03-25 21:57:24 +00:00
|
|
|
if (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) {
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_LOG_OBJECT (mux, "Adjusting buffer offset from %" G_GINT64_FORMAT
|
2006-03-25 21:57:24 +00:00
|
|
|
" to %" G_GINT64_FORMAT, GST_BUFFER_OFFSET (buffer),
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_BUFFER_OFFSET (buffer) + mux->tag_size);
|
|
|
|
GST_BUFFER_OFFSET (buffer) += mux->tag_size;
|
2006-03-25 21:57:24 +00:00
|
|
|
}
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_buffer_set_caps (buffer, GST_PAD_CAPS (mux->srcpad));
|
|
|
|
return gst_pad_push (mux->srcpad, buffer);
|
2006-04-29 18:46:36 +00:00
|
|
|
|
|
|
|
/* ERRORS */
|
|
|
|
no_tag_buffer:
|
|
|
|
{
|
|
|
|
GST_ELEMENT_ERROR (mux, LIBRARY, ENCODE, (NULL), (NULL));
|
|
|
|
return GST_FLOW_ERROR;
|
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_tag_lib_mux_sink_event (GstPad * pad, GstEvent * event)
|
|
|
|
{
|
2006-04-28 15:33:09 +00:00
|
|
|
GstTagLibMux *mux;
|
2006-03-09 17:44:17 +00:00
|
|
|
gboolean result;
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
mux = GST_TAG_LIB_MUX (gst_pad_get_parent (pad));
|
2006-03-09 17:44:17 +00:00
|
|
|
result = FALSE;
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2006-03-26 19:56:37 +00:00
|
|
|
case GST_EVENT_TAG:{
|
2006-03-09 17:44:17 +00:00
|
|
|
GstTagList *tags;
|
|
|
|
|
|
|
|
gst_event_parse_tag (event, &tags);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_INFO_OBJECT (mux, "Got tag event: %" GST_PTR_FORMAT, tags);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->event_tags != NULL) {
|
|
|
|
gst_tag_list_insert (mux->event_tags, tags, GST_TAG_MERGE_REPLACE);
|
2006-03-09 17:44:17 +00:00
|
|
|
} else {
|
2006-04-28 15:33:09 +00:00
|
|
|
mux->event_tags = gst_tag_list_copy (tags);
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_INFO_OBJECT (mux, "Event tags are now: %" GST_PTR_FORMAT,
|
|
|
|
mux->event_tags);
|
2006-03-26 19:56:37 +00:00
|
|
|
|
|
|
|
/* just drop the event, we'll push a new tag event in render_tag */
|
2006-03-09 17:44:17 +00:00
|
|
|
gst_event_unref (event);
|
|
|
|
result = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
case GST_EVENT_NEWSEGMENT:{
|
|
|
|
GstFormat fmt;
|
|
|
|
|
|
|
|
gst_event_parse_new_segment (event, NULL, NULL, &fmt, NULL, NULL, NULL);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
2006-03-26 19:56:37 +00:00
|
|
|
if (fmt != GST_FORMAT_BYTES) {
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_WARNING_OBJECT (mux, "dropping newsegment event in %s format",
|
2006-03-26 19:56:37 +00:00
|
|
|
gst_format_get_name (fmt));
|
2006-03-09 17:44:17 +00:00
|
|
|
gst_event_unref (event);
|
2006-03-26 19:56:37 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->render_tag) {
|
2006-03-26 19:56:37 +00:00
|
|
|
/* 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
|
|
|
|
* here at this point and need to cache the newsegment event for now
|
|
|
|
* (also, there could be tag events coming after this newsegment event
|
|
|
|
* and before the first buffer). */
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->newsegment_ev) {
|
|
|
|
GST_WARNING_OBJECT (mux, "discarding old cached newsegment event");
|
|
|
|
gst_event_unref (mux->newsegment_ev);
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_LOG_OBJECT (mux, "caching newsegment event for later");
|
|
|
|
mux->newsegment_ev = event;
|
2006-03-26 19:56:37 +00:00
|
|
|
} else {
|
2006-04-28 15:33:09 +00:00
|
|
|
GST_DEBUG_OBJECT (mux, "got newsegment event, adjusting offsets");
|
|
|
|
gst_pad_push_event (mux->srcpad,
|
|
|
|
gst_tag_lib_mux_adjust_event_offsets (mux, event));
|
2006-03-26 19:56:37 +00:00
|
|
|
gst_event_unref (event);
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
event = NULL;
|
|
|
|
result = TRUE;
|
2006-03-09 17:44:17 +00:00
|
|
|
break;
|
2006-03-26 19:56:37 +00:00
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
default:
|
|
|
|
result = gst_pad_event_default (pad, event);
|
|
|
|
break;
|
|
|
|
}
|
2006-03-26 19:56:37 +00:00
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
gst_object_unref (mux);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_tag_lib_mux_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
2006-04-28 15:33:09 +00:00
|
|
|
GstTagLibMux *mux;
|
2006-03-09 17:44:17 +00:00
|
|
|
GstStateChangeReturn result;
|
|
|
|
|
2006-04-28 15:33:09 +00:00
|
|
|
mux = GST_TAG_LIB_MUX (element);
|
2006-03-09 17:44:17 +00:00
|
|
|
|
|
|
|
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
if (result != GST_STATE_CHANGE_SUCCESS) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (transition) {
|
2006-03-26 19:56:37 +00:00
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->newsegment_ev) {
|
|
|
|
gst_event_unref (mux->newsegment_ev);
|
|
|
|
mux->newsegment_ev = NULL;
|
2006-03-26 19:56:37 +00:00
|
|
|
}
|
2006-04-28 15:33:09 +00:00
|
|
|
if (mux->event_tags) {
|
|
|
|
gst_tag_list_free (mux->event_tags);
|
|
|
|
mux->event_tags = NULL;
|
2006-03-09 17:44:17 +00:00
|
|
|
}
|
2006-04-28 15:33:09 +00:00
|
|
|
mux->tag_size = 0;
|
|
|
|
mux->render_tag = TRUE;
|
2006-03-09 17:44:17 +00:00
|
|
|
break;
|
2006-03-26 19:56:37 +00:00
|
|
|
}
|
2006-03-09 17:44:17 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
2006-05-30 14:35:18 +00:00
|
|
|
|
|
|
|
static gboolean
|
|
|
|
plugin_init (GstPlugin * plugin)
|
|
|
|
{
|
|
|
|
return (gst_id3v2_mux_plugin_init (plugin)
|
|
|
|
&& gst_apev2_mux_plugin_init (plugin));
|
|
|
|
}
|
|
|
|
|
|
|
|
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
|
|
|
|
GST_VERSION_MINOR,
|
|
|
|
"taglib",
|
|
|
|
"Tag writing plug-in based on taglib",
|
|
|
|
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
|