mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-18 15:51:11 +00:00
Merge remote-tracking branch 'origin/master' into 0.11
Conflicts: ext/taglib/gstapev2mux.cc ext/taglib/gstid3v2mux.cc ext/taglib/gsttaglibmux.c ext/taglib/gsttaglibmux.h
This commit is contained in:
commit
91a58ccda1
8 changed files with 94 additions and 545 deletions
|
@ -1,6 +1,6 @@
|
|||
plugin_LTLIBRARIES = libgsttaglib.la
|
||||
|
||||
libgsttaglib_la_SOURCES = gsttaglibmux.c gstid3v2mux.cc gstapev2mux.cc
|
||||
libgsttaglib_la_SOURCES = gsttaglibplugin.c gstid3v2mux.cc gstapev2mux.cc
|
||||
libgsttaglib_la_CFLAGS = \
|
||||
$(GST_PLUGINS_BASE_CFLAGS) \
|
||||
$(GST_CFLAGS) \
|
||||
|
@ -16,4 +16,4 @@ libgsttaglib_la_LIBADD = \
|
|||
libgsttaglib_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
|
||||
libgsttaglib_la_LIBTOOLFLAGS = --tag=disable-static
|
||||
|
||||
noinst_HEADERS = gsttaglibmux.h gstid3v2mux.h gstapev2mux.h
|
||||
noinst_HEADERS = gstid3v2mux.h gstapev2mux.h
|
||||
|
|
|
@ -64,19 +64,30 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("application/x-apetag"));
|
||||
|
||||
G_DEFINE_TYPE (GstApev2Mux, gst_apev2_mux, GST_TYPE_TAG_LIB_MUX);
|
||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("ANY"));
|
||||
|
||||
static GstBuffer *gst_apev2_mux_render_tag (GstTagLibMux * mux,
|
||||
GstTagList * taglist);
|
||||
G_DEFINE_TYPE (GstApev2Mux, gst_apev2_mux, GST_TYPE_TAG_MUX);
|
||||
|
||||
static GstBuffer *gst_apev2_mux_render_tag (GstTagMux * mux,
|
||||
const GstTagList * taglist);
|
||||
static GstBuffer *gst_apev2_mux_render_end_tag (GstTagMux * mux,
|
||||
const GstTagList * taglist);
|
||||
|
||||
static void
|
||||
gst_apev2_mux_class_init (GstApev2MuxClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
GST_TAG_LIB_MUX_CLASS (klass)->render_tag =
|
||||
GST_TAG_MUX_CLASS (klass)->render_start_tag =
|
||||
GST_DEBUG_FUNCPTR (gst_apev2_mux_render_tag);
|
||||
GST_TAG_MUX_CLASS (klass)->render_end_tag =
|
||||
GST_DEBUG_FUNCPTR (gst_apev2_mux_render_end_tag);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
|
||||
|
@ -335,7 +346,7 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
|
|||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_apev2_mux_render_tag (GstTagLibMux * mux, GstTagList * taglist)
|
||||
gst_apev2_mux_render_tag (GstTagMux * mux, const GstTagList * taglist)
|
||||
{
|
||||
APE::Tag apev2tag;
|
||||
ByteVector rendered_tag;
|
||||
|
@ -357,12 +368,8 @@ gst_apev2_mux_render_tag (GstTagLibMux * mux, GstTagList * taglist)
|
|||
return buf;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_apev2_mux_plugin_init (GstPlugin * plugin)
|
||||
static GstBuffer *
|
||||
gst_apev2_mux_render_end_tag (GstTagMux * mux, const GstTagList * taglist)
|
||||
{
|
||||
if (!gst_element_register (plugin, "apev2mux", GST_RANK_NONE,
|
||||
GST_TYPE_APEV2_MUX))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
#ifndef GST_APEV2_MUX_H
|
||||
#define GST_APEV2_MUX_H
|
||||
|
||||
#include "gsttaglibmux.h"
|
||||
#include <gst/tag/gsttagmux.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -30,11 +30,11 @@ typedef struct _GstApev2Mux GstApev2Mux;
|
|||
typedef struct _GstApev2MuxClass GstApev2MuxClass;
|
||||
|
||||
struct _GstApev2Mux {
|
||||
GstTagLibMux taglibmux;
|
||||
GstTagMux tagmux;
|
||||
};
|
||||
|
||||
struct _GstApev2MuxClass {
|
||||
GstTagLibMuxClass taglibmux_class;
|
||||
GstTagMuxClass tagmux_class;
|
||||
};
|
||||
|
||||
#define GST_TYPE_APEV2_MUX \
|
||||
|
|
|
@ -72,20 +72,30 @@ static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
|||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("application/x-id3"));
|
||||
|
||||
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("ANY"));
|
||||
|
||||
G_DEFINE_TYPE (GstId3v2Mux, gst_id3v2_mux, GST_TYPE_TAG_LIB_MUX);
|
||||
G_DEFINE_TYPE (GstId3v2Mux, gst_id3v2_mux, GST_TYPE_TAG_MUX);
|
||||
|
||||
static GstBuffer *gst_id3v2_mux_render_tag (GstTagLibMux * mux,
|
||||
GstTagList * taglist);
|
||||
static GstBuffer *gst_id3v2_mux_render_tag (GstTagMux * mux,
|
||||
const GstTagList * taglist);
|
||||
static GstBuffer *gst_id3v2_mux_render_end_tag (GstTagMux * mux,
|
||||
const GstTagList * taglist);
|
||||
|
||||
static void
|
||||
gst_id3v2_mux_class_init (GstId3v2MuxClass * klass)
|
||||
{
|
||||
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
|
||||
|
||||
GST_TAG_LIB_MUX_CLASS (klass)->render_tag =
|
||||
GST_TAG_MUX_CLASS (klass)->render_start_tag =
|
||||
GST_DEBUG_FUNCPTR (gst_id3v2_mux_render_tag);
|
||||
GST_TAG_MUX_CLASS (klass)->render_end_tag =
|
||||
GST_DEBUG_FUNCPTR (gst_id3v2_mux_render_end_tag);
|
||||
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&sink_template));
|
||||
gst_element_class_add_pad_template (element_class,
|
||||
gst_static_pad_template_get (&src_template));
|
||||
|
||||
|
@ -731,7 +741,7 @@ foreach_add_tag (const GstTagList * list, const gchar * tag, gpointer userdata)
|
|||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_id3v2_mux_render_tag (GstTagLibMux * mux, GstTagList * taglist)
|
||||
gst_id3v2_mux_render_tag (GstTagMux * mux, const GstTagList * taglist)
|
||||
{
|
||||
ID3v2::Tag id3v2tag;
|
||||
ByteVector rendered_tag;
|
||||
|
@ -769,14 +779,8 @@ gst_id3v2_mux_render_tag (GstTagLibMux * mux, GstTagList * taglist)
|
|||
return buf;
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_id3v2_mux_plugin_init (GstPlugin * plugin)
|
||||
static GstBuffer *
|
||||
gst_id3v2_mux_render_end_tag (GstTagMux * mux, const GstTagList * taglist)
|
||||
{
|
||||
if (!gst_element_register (plugin, "id3v2mux", GST_RANK_NONE,
|
||||
GST_TYPE_ID3V2_MUX))
|
||||
return FALSE;
|
||||
|
||||
gst_tag_register_musicbrainz_tags ();
|
||||
|
||||
return TRUE;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
#ifndef GST_ID3V2_MUX_H
|
||||
#define GST_ID3V2_MUX_H
|
||||
|
||||
#include "gsttaglibmux.h"
|
||||
#include <gst/tag/gsttagmux.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
|
@ -29,11 +29,11 @@ typedef struct _GstId3v2Mux GstId3v2Mux;
|
|||
typedef struct _GstId3v2MuxClass GstId3v2MuxClass;
|
||||
|
||||
struct _GstId3v2Mux {
|
||||
GstTagLibMux taglibmux;
|
||||
GstTagMux tagmux;
|
||||
};
|
||||
|
||||
struct _GstId3v2MuxClass {
|
||||
GstTagLibMuxClass taglibmux_class;
|
||||
GstTagMuxClass tagmux_class;
|
||||
};
|
||||
|
||||
#define GST_TYPE_ID3V2_MUX \
|
||||
|
|
|
@ -1,438 +0,0 @@
|
|||
/* GStreamer taglib-based muxer base class
|
||||
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
||||
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
||||
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* 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>
|
||||
#include <gst/tag/tag.h>
|
||||
|
||||
#include "gsttaglibmux.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (gst_tag_lib_mux_debug);
|
||||
#define GST_CAT_DEFAULT gst_tag_lib_mux_debug
|
||||
|
||||
static GstStaticPadTemplate gst_tag_lib_mux_sink_template =
|
||||
GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
GST_PAD_ALWAYS,
|
||||
GST_STATIC_CAPS ("ANY"));
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
static void gst_tag_lib_mux_class_init (GstTagLibMuxClass * klass);
|
||||
static void gst_tag_lib_mux_init (GstTagLibMux * mux,
|
||||
GstTagLibMuxClass * mux_class);
|
||||
|
||||
GType
|
||||
gst_tag_lib_mux_get_type (void)
|
||||
{
|
||||
static volatile gsize tag_lib_mux_type = 0;
|
||||
|
||||
if (g_once_init_enter (&tag_lib_mux_type)) {
|
||||
GType _type;
|
||||
static const GTypeInfo tag_lib_mux_info = {
|
||||
sizeof (GstTagLibMuxClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gst_tag_lib_mux_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GstTagLibMux),
|
||||
0,
|
||||
(GInstanceInitFunc) gst_tag_lib_mux_init,
|
||||
};
|
||||
|
||||
_type = g_type_register_static (GST_TYPE_ELEMENT,
|
||||
"GstTagLibMux", &tag_lib_mux_info, 0);
|
||||
|
||||
gst_tag_lib_mux_iface_init (_type);
|
||||
|
||||
g_once_init_leave (&tag_lib_mux_type, _type);
|
||||
}
|
||||
return tag_lib_mux_type;
|
||||
}
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_tag_lib_mux_change_state (GstElement * element, GstStateChange transition);
|
||||
static GstFlowReturn gst_tag_lib_mux_chain (GstPad * pad, GstObject * parent,
|
||||
GstBuffer * buffer);
|
||||
static gboolean gst_tag_lib_mux_sink_event (GstPad * pad, GstObject * parent,
|
||||
GstEvent * event);
|
||||
|
||||
static void
|
||||
gst_tag_lib_mux_finalize (GObject * obj)
|
||||
{
|
||||
GstTagLibMux *mux = GST_TAG_LIB_MUX (obj);
|
||||
|
||||
if (mux->newsegment_ev) {
|
||||
gst_event_unref (mux->newsegment_ev);
|
||||
mux->newsegment_ev = NULL;
|
||||
}
|
||||
|
||||
if (mux->event_tags) {
|
||||
gst_tag_list_free (mux->event_tags);
|
||||
mux->event_tags = NULL;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (obj);
|
||||
}
|
||||
|
||||
static void
|
||||
gst_tag_lib_mux_class_init (GstTagLibMuxClass * klass)
|
||||
{
|
||||
GObjectClass *gobject_class;
|
||||
GstElementClass *gstelement_class;
|
||||
|
||||
gobject_class = (GObjectClass *) klass;
|
||||
gstelement_class = (GstElementClass *) klass;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
gobject_class->finalize = gst_tag_lib_mux_finalize;
|
||||
gstelement_class->change_state =
|
||||
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_change_state);
|
||||
|
||||
gst_element_class_add_pad_template (gstelement_class,
|
||||
gst_static_pad_template_get (&gst_tag_lib_mux_sink_template));
|
||||
|
||||
GST_DEBUG_CATEGORY_INIT (gst_tag_lib_mux_debug, "taglibmux", 0,
|
||||
"taglib-based muxer");
|
||||
}
|
||||
|
||||
static void
|
||||
gst_tag_lib_mux_init (GstTagLibMux * mux, GstTagLibMuxClass * mux_class)
|
||||
{
|
||||
GstElementClass *element_klass = GST_ELEMENT_CLASS (mux_class);
|
||||
GstPadTemplate *tmpl;
|
||||
|
||||
/* pad through which data comes in to the element */
|
||||
mux->sinkpad =
|
||||
gst_pad_new_from_static_template (&gst_tag_lib_mux_sink_template, "sink");
|
||||
gst_pad_set_chain_function (mux->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_chain));
|
||||
gst_pad_set_event_function (mux->sinkpad,
|
||||
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_sink_event));
|
||||
gst_element_add_pad (GST_ELEMENT (mux), mux->sinkpad);
|
||||
|
||||
/* pad through which data goes out of the element */
|
||||
tmpl = gst_element_class_get_pad_template (element_klass, "src");
|
||||
if (tmpl) {
|
||||
GstCaps *caps;
|
||||
|
||||
mux->srcpad = gst_pad_new_from_template (tmpl, "src");
|
||||
gst_pad_use_fixed_caps (mux->srcpad);
|
||||
caps = gst_pad_template_get_caps (tmpl);
|
||||
gst_pad_set_caps (mux->srcpad, caps);
|
||||
gst_caps_unref (caps);
|
||||
gst_element_add_pad (GST_ELEMENT (mux), mux->srcpad);
|
||||
}
|
||||
|
||||
mux->render_tag = TRUE;
|
||||
}
|
||||
|
||||
static GstBuffer *
|
||||
gst_tag_lib_mux_render_tag (GstTagLibMux * mux)
|
||||
{
|
||||
GstTagLibMuxClass *klass;
|
||||
GstTagMergeMode merge_mode;
|
||||
GstTagSetter *tagsetter;
|
||||
GstBuffer *buffer;
|
||||
const GstTagList *tagsetter_tags;
|
||||
GstTagList *taglist;
|
||||
GstEvent *event;
|
||||
GstSegment segment;
|
||||
|
||||
tagsetter = GST_TAG_SETTER (mux);
|
||||
|
||||
tagsetter_tags = gst_tag_setter_get_tag_list (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, "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);
|
||||
|
||||
GST_LOG_OBJECT (mux, "final tags: %" GST_PTR_FORMAT, taglist);
|
||||
|
||||
klass = GST_TAG_LIB_MUX_CLASS (G_OBJECT_GET_CLASS (mux));
|
||||
|
||||
if (klass->render_tag == NULL)
|
||||
goto no_vfunc;
|
||||
|
||||
buffer = klass->render_tag (mux, taglist);
|
||||
|
||||
if (buffer == NULL)
|
||||
goto render_error;
|
||||
|
||||
mux->tag_size = gst_buffer_get_size (buffer);
|
||||
GST_LOG_OBJECT (mux, "tag size = %" G_GSIZE_FORMAT " bytes", mux->tag_size);
|
||||
|
||||
/* Send newsegment event from byte position 0, so the tag really gets
|
||||
* written to the start of the file, independent of the upstream segment */
|
||||
gst_segment_init (&segment, GST_FORMAT_BYTES);
|
||||
gst_pad_push_event (mux->srcpad, gst_event_new_segment (&segment));
|
||||
|
||||
/* 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);
|
||||
gst_pad_push_event (mux->srcpad, event);
|
||||
|
||||
GST_BUFFER_OFFSET (buffer) = 0;
|
||||
|
||||
return buffer;
|
||||
|
||||
no_vfunc:
|
||||
{
|
||||
GST_ERROR_OBJECT (mux, "Subclass does not implement render_tag vfunc!");
|
||||
gst_tag_list_free (taglist);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
render_error:
|
||||
{
|
||||
GST_ERROR_OBJECT (mux, "Failed to render tag");
|
||||
gst_tag_list_free (taglist);
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static GstEvent *
|
||||
gst_tag_lib_mux_adjust_event_offsets (GstTagLibMux * mux,
|
||||
const GstEvent * newsegment_event)
|
||||
{
|
||||
GstSegment segment;
|
||||
|
||||
gst_event_copy_segment ((GstEvent *) newsegment_event, &segment);
|
||||
|
||||
g_assert (segment.format == GST_FORMAT_BYTES);
|
||||
|
||||
if (segment.start != -1)
|
||||
segment.start += mux->tag_size;
|
||||
if (segment.stop != -1)
|
||||
segment.stop += mux->tag_size;
|
||||
if (segment.time != -1)
|
||||
segment.time += mux->tag_size;
|
||||
|
||||
GST_DEBUG_OBJECT (mux, "adjusting newsegment event offsets to start=%"
|
||||
G_GUINT64_FORMAT ", stop=%" G_GUINT64_FORMAT ", cur=%" G_GUINT64_FORMAT
|
||||
" (delta = +%" G_GSIZE_FORMAT ")",
|
||||
segment.start, segment.stop, segment.time, mux->tag_size);
|
||||
|
||||
return gst_event_new_segment (&segment);
|
||||
}
|
||||
|
||||
static GstFlowReturn
|
||||
gst_tag_lib_mux_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
||||
{
|
||||
GstTagLibMux *mux = GST_TAG_LIB_MUX (parent);
|
||||
|
||||
if (mux->render_tag) {
|
||||
GstFlowReturn ret;
|
||||
GstBuffer *tag_buffer;
|
||||
GstCaps *tcaps;
|
||||
|
||||
GST_INFO_OBJECT (mux, "Adding tags to stream");
|
||||
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);
|
||||
if (ret != GST_FLOW_OK) {
|
||||
GST_DEBUG_OBJECT (mux, "flow: %s", gst_flow_get_name (ret));
|
||||
gst_buffer_unref (buffer);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Now send the cached newsegment event that we got from upstream */
|
||||
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;
|
||||
} else {
|
||||
/* upstream sent no newsegment event or only one in a non-BYTE format */
|
||||
}
|
||||
|
||||
mux->render_tag = FALSE;
|
||||
|
||||
/* we have data flow, so pad is active and caps can be set */
|
||||
tcaps = gst_pad_get_pad_template_caps (mux->srcpad);
|
||||
gst_pad_set_caps (mux->srcpad, tcaps);
|
||||
gst_caps_unref (tcaps);
|
||||
}
|
||||
|
||||
buffer = gst_buffer_make_writable (buffer);
|
||||
|
||||
if (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) {
|
||||
GST_LOG_OBJECT (mux, "Adjusting buffer offset from %" G_GUINT64_FORMAT
|
||||
" to %" G_GUINT64_FORMAT, GST_BUFFER_OFFSET (buffer),
|
||||
GST_BUFFER_OFFSET (buffer) + mux->tag_size);
|
||||
GST_BUFFER_OFFSET (buffer) += mux->tag_size;
|
||||
}
|
||||
|
||||
return gst_pad_push (mux->srcpad, buffer);
|
||||
|
||||
/* ERRORS */
|
||||
no_tag_buffer:
|
||||
{
|
||||
GST_ELEMENT_ERROR (mux, LIBRARY, ENCODE, (NULL), (NULL));
|
||||
return GST_FLOW_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gst_tag_lib_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
||||
{
|
||||
GstTagLibMux *mux;
|
||||
gboolean result;
|
||||
|
||||
mux = GST_TAG_LIB_MUX (parent);
|
||||
result = FALSE;
|
||||
|
||||
switch (GST_EVENT_TYPE (event)) {
|
||||
case GST_EVENT_TAG:{
|
||||
GstTagList *tags;
|
||||
|
||||
gst_event_parse_tag (event, &tags);
|
||||
|
||||
GST_INFO_OBJECT (mux, "Got tag event: %" GST_PTR_FORMAT, tags);
|
||||
|
||||
if (mux->event_tags != NULL) {
|
||||
gst_tag_list_insert (mux->event_tags, tags, GST_TAG_MERGE_REPLACE);
|
||||
} else {
|
||||
mux->event_tags = gst_tag_list_copy (tags);
|
||||
}
|
||||
|
||||
GST_INFO_OBJECT (mux, "Event tags are now: %" GST_PTR_FORMAT,
|
||||
mux->event_tags);
|
||||
|
||||
/* just drop the event, we'll push a new tag event in render_tag */
|
||||
gst_event_unref (event);
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
case GST_EVENT_SEGMENT:{
|
||||
const GstSegment *segment;
|
||||
|
||||
gst_event_parse_segment (event, &segment);
|
||||
|
||||
if (segment->format != GST_FORMAT_BYTES) {
|
||||
GST_WARNING_OBJECT (mux, "dropping newsegment event in %s format",
|
||||
gst_format_get_name (segment->format));
|
||||
gst_event_unref (event);
|
||||
break;
|
||||
}
|
||||
|
||||
if (mux->render_tag) {
|
||||
/* 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). */
|
||||
if (mux->newsegment_ev) {
|
||||
GST_WARNING_OBJECT (mux, "discarding old cached newsegment event");
|
||||
gst_event_unref (mux->newsegment_ev);
|
||||
}
|
||||
|
||||
GST_LOG_OBJECT (mux, "caching newsegment event for later");
|
||||
mux->newsegment_ev = event;
|
||||
} else {
|
||||
GST_DEBUG_OBJECT (mux, "got newsegment event, adjusting offsets");
|
||||
gst_pad_push_event (mux->srcpad,
|
||||
gst_tag_lib_mux_adjust_event_offsets (mux, event));
|
||||
gst_event_unref (event);
|
||||
}
|
||||
event = NULL;
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
result = gst_pad_event_default (pad, parent, event);
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static GstStateChangeReturn
|
||||
gst_tag_lib_mux_change_state (GstElement * element, GstStateChange transition)
|
||||
{
|
||||
GstTagLibMux *mux;
|
||||
GstStateChangeReturn result;
|
||||
|
||||
mux = GST_TAG_LIB_MUX (element);
|
||||
|
||||
result = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
||||
if (result != GST_STATE_CHANGE_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (transition) {
|
||||
case GST_STATE_CHANGE_PAUSED_TO_READY:{
|
||||
if (mux->newsegment_ev) {
|
||||
gst_event_unref (mux->newsegment_ev);
|
||||
mux->newsegment_ev = NULL;
|
||||
}
|
||||
if (mux->event_tags) {
|
||||
gst_tag_list_free (mux->event_tags);
|
||||
mux->event_tags = NULL;
|
||||
}
|
||||
mux->tag_size = 0;
|
||||
mux->render_tag = TRUE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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);
|
|
@ -1,73 +0,0 @@
|
|||
/* GStreamer taglib-based muxer base class
|
||||
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
||||
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
||||
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef GST_TAG_LIB_MUX_H
|
||||
#define GST_TAG_LIB_MUX_H
|
||||
|
||||
#include <gst/gst.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef struct _GstTagLibMux GstTagLibMux;
|
||||
typedef struct _GstTagLibMuxClass GstTagLibMuxClass;
|
||||
|
||||
/* Definition of structure storing data for this element. */
|
||||
struct _GstTagLibMux {
|
||||
GstElement element;
|
||||
|
||||
GstPad *srcpad;
|
||||
GstPad *sinkpad;
|
||||
GstTagList *event_tags; /* tags received from upstream elements */
|
||||
gsize tag_size;
|
||||
gboolean render_tag;
|
||||
|
||||
GstEvent *newsegment_ev; /* cached newsegment event from upstream */
|
||||
};
|
||||
|
||||
/* Standard definition defining a class for this element. */
|
||||
struct _GstTagLibMuxClass {
|
||||
GstElementClass parent_class;
|
||||
|
||||
/* vfuncs */
|
||||
GstBuffer * (*render_tag) (GstTagLibMux * mux, GstTagList * tag_list);
|
||||
};
|
||||
|
||||
/* Standard macros for defining types for this element. */
|
||||
#define GST_TYPE_TAG_LIB_MUX \
|
||||
(gst_tag_lib_mux_get_type())
|
||||
#define GST_TAG_LIB_MUX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TAG_LIB_MUX,GstTagLibMux))
|
||||
#define GST_TAG_LIB_MUX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TAG_LIB_MUX,GstTagLibMuxClass))
|
||||
#define GST_IS_TAG_LIB_MUX(obj) \
|
||||
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TAG_LIB_MUX))
|
||||
#define GST_IS_TAG_LIB_MUX_CLASS(klass) \
|
||||
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TAG_LIB_MUX))
|
||||
#define GST_TAG_LIB_MUX_GET_CLASS(obj) \
|
||||
(G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TAG_LIB_MUX, GstTagLibMuxClass))
|
||||
|
||||
/* Standard function returning type information. */
|
||||
GType gst_tag_lib_mux_get_type (void);
|
||||
gboolean gst_apev2_mux_plugin_init (GstPlugin * plugin);
|
||||
gboolean gst_id3v2_mux_plugin_init (GstPlugin * plugin);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif
|
49
ext/taglib/gsttaglibplugin.c
Normal file
49
ext/taglib/gsttaglibplugin.c
Normal file
|
@ -0,0 +1,49 @@
|
|||
/* GStreamer taglib-based muxer base class
|
||||
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
|
||||
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
|
||||
* Copyright (C) 2006 Sebastian Dröge <slomo@circular-chaos.org>
|
||||
|
||||
* 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 "gstapev2mux.h"
|
||||
#include "gstid3v2mux.h"
|
||||
|
||||
#include <gst/tag/tag.h>
|
||||
|
||||
static gboolean
|
||||
plugin_init (GstPlugin * plugin)
|
||||
{
|
||||
if (!gst_element_register (plugin, "id3v2mux", GST_RANK_NONE,
|
||||
GST_TYPE_ID3V2_MUX) ||
|
||||
!gst_element_register (plugin, "apev2mux", GST_RANK_NONE,
|
||||
GST_TYPE_APEV2_MUX))
|
||||
return FALSE;
|
||||
|
||||
gst_tag_register_musicbrainz_tags ();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
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);
|
Loading…
Reference in a new issue