Commit fe38f535 authored by Michael Smith's avatar Michael Smith

id3tag: Add new id3 tagging plugin, supports v1, v2.3, and v2.4.

By default, does v1 and v2.3, but there are properties to select.
Will hopefully replace id3mux, id3v2mux, in the not-too-distant future.
parent b9ac2671
......@@ -265,6 +265,7 @@ AG_GST_CHECK_PLUGIN(dvdspu)
AG_GST_CHECK_PLUGIN(festival)
AG_GST_CHECK_PLUGIN(freeze)
AG_GST_CHECK_PLUGIN(h264parse)
AG_GST_CHECK_PLUGIN(id3tag)
AG_GST_CHECK_PLUGIN(librfb)
AG_GST_CHECK_PLUGIN(liveadder)
AG_GST_CHECK_PLUGIN(mpegdemux)
......@@ -1574,6 +1575,7 @@ gst/dvdspu/Makefile
gst/festival/Makefile
gst/freeze/Makefile
gst/h264parse/Makefile
gst/id3tag/Makefile
gst/librfb/Makefile
gst/mpegdemux/Makefile
gst/mpegtsmux/Makefile
......
plugin_LTLIBRARIES = libgstid3tag.la
libgstid3tag_la_SOURCES = \
gsttagmux.c \
id3tag.c \
gstid3tag.c
libgstid3tag_la_CFLAGS = \
$(GST_PLUGINS_BASE_CFLAGS) \
$(GST_CFLAGS)
libgstid3tag_la_LIBADD = \
$(GST_PLUGINS_BASE_LIBS) -lgsttag-$(GST_MAJORMINOR) \
$(GST_LIBS)
libgstid3tag_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
libgstid3tag_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstid3tag.h id3tag.h gsttagmux.h
/* GStreamer ID3 v1 and v2 muxer
*
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2009 Pioneers of the Inevitable <songbird@songbirdnest.com>
*
* 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.
*/
/**
* SECTION:element-id3tag
* @see_also: #GstID3Demux, #GstTagSetter
*
* This element adds ID3v2 tags to the beginning of a stream, and ID3v1 tags
* to the end.
*
* It defaults to writing ID3 version 2.3.0 tags (since those are the most
* widely supported), but can optionally write version 2.4.0 tags.
*
* Applications can set the tags to write using the #GstTagSetter interface.
* Tags sent by upstream elements will be picked up automatically (and merged
* according to the merge mode set via the tag setter interface).
*
* <refsect2>
* <title>Example pipelines</title>
* |[
* gst-launch -v filesrc location=foo.ogg ! decodebin ! audioconvert ! lame ! id3tag ! filesink location=foo.mp3
* ]| A pipeline that transcodes a file from Ogg/Vorbis to mp3 format with
* ID3 tags that contain the same metadata as the the Ogg/Vorbis file.
* Make sure the Ogg/Vorbis file actually has comments to preserve.
* |[
* gst-launch -m filesrc location=foo.mp3 ! id3demux ! fakesink silent=TRUE 2&gt; /dev/null | grep taglist
* ]| Verify that tags have been written.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "gstid3tag.h"
#include <gst/tag/tag.h>
#include <string.h>
GST_DEBUG_CATEGORY (gst_id3tag_debug);
#define GST_CAT_DEFAULT gst_id3tag_debug
enum
{
ARG_0,
ARG_WRITE_V1,
ARG_WRITE_V2,
ARG_V2_MAJOR_VERSION
};
#define DEFAULT_WRITE_V1 TRUE
#define DEFAULT_WRITE_V2 TRUE
#define DEFAULT_V2_MAJOR_VERSION 3
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("application/x-id3"));
GST_BOILERPLATE (GstID3Tag, gst_id3tag, GstTagMux, GST_TYPE_TAG_MUX);
static GstBuffer *gst_id3tag_render_v2_tag (GstTagMux * mux,
GstTagList * taglist);
static GstBuffer *gst_id3tag_render_v1_tag (GstTagMux * mux,
GstTagList * taglist);
static void gst_id3tag_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec);
static void gst_id3tag_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec);
static void
gst_id3tag_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 (&src_template));
gst_element_class_set_details_simple (element_class,
"ID3 v1 and v2 Muxer", "Formatter/Metadata",
"Adds an ID3v2 header and ID3v1 footer to a file",
"Michael Smith <msmith@songbirdnest.com>, "
"Tim-Philipp Müller <tim centricular net>");
GST_DEBUG_CATEGORY_INIT (gst_id3tag_debug, "id3tag", 0,
"ID3 v1 and v2 tag muxer");
}
static void
gst_id3tag_class_init (GstID3TagClass * klass)
{
GObjectClass *gobject_class = (GObjectClass *) klass;
gobject_class->set_property = gst_id3tag_set_property;
gobject_class->get_property = gst_id3tag_get_property;
g_object_class_install_property (gobject_class, ARG_WRITE_V1,
g_param_spec_boolean ("write-v1", "Write id3v1 tag",
"Write an id3v1 tag at the end of the file", DEFAULT_WRITE_V1,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class, ARG_WRITE_V2,
g_param_spec_boolean ("write-v2", "Write id3v2 tag",
"Write an id3v2 tag at the start of the file", DEFAULT_WRITE_V2,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
g_object_class_install_property (gobject_class, ARG_V2_MAJOR_VERSION,
g_param_spec_int ("v2-version", "Version (3 or 4) of id3v2 tag",
"Set version (3 for id3v2.3, 4 for id3v2.4) of id3v2 tags",
3, 4, DEFAULT_V2_MAJOR_VERSION,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
GST_TAG_MUX_CLASS (klass)->render_start_tag =
GST_DEBUG_FUNCPTR (gst_id3tag_render_v2_tag);
GST_TAG_MUX_CLASS (klass)->render_end_tag = gst_id3tag_render_v1_tag;
}
static void
gst_id3tag_init (GstID3Tag * id3mux, GstID3TagClass * id3mux_class)
{
id3mux->write_v1 = DEFAULT_WRITE_V1;
id3mux->write_v2 = DEFAULT_WRITE_V2;
id3mux->v2_major_version = DEFAULT_V2_MAJOR_VERSION;
}
static void
gst_id3tag_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstID3Tag *mux = GST_ID3TAG (object);
switch (prop_id) {
case ARG_WRITE_V1:
mux->write_v1 = g_value_get_boolean (value);
break;
case ARG_WRITE_V2:
mux->write_v2 = g_value_get_boolean (value);
break;
case ARG_V2_MAJOR_VERSION:
mux->v2_major_version = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_id3tag_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstID3Tag *mux = GST_ID3TAG (object);
switch (prop_id) {
case ARG_WRITE_V1:
g_value_set_boolean (value, mux->write_v1);
break;
case ARG_WRITE_V2:
g_value_set_boolean (value, mux->write_v2);
break;
case ARG_V2_MAJOR_VERSION:
g_value_set_int (value, mux->v2_major_version);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static GstBuffer *
gst_id3tag_render_v2_tag (GstTagMux * mux, GstTagList * taglist)
{
GstID3Tag *id3mux = GST_ID3TAG (mux);
if (id3mux->write_v2)
return gst_id3mux_render_v2_tag (mux, taglist, id3mux->v2_major_version);
else
return NULL;
}
static GstBuffer *
gst_id3tag_render_v1_tag (GstTagMux * mux, GstTagList * taglist)
{
GstID3Tag *id3mux = GST_ID3TAG (mux);
if (id3mux->write_v1)
return gst_id3mux_render_v1_tag (mux, taglist);
else
return NULL;
}
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "id3tag", GST_RANK_NONE, GST_TYPE_ID3TAG))
return FALSE;
gst_tag_register_musicbrainz_tags ();
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"id3tag",
"ID3 v1 and v2 muxing plugin",
plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
/* GStreamer ID3 v1 and v2 muxer
*
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2009 Pioneers of the Inevitable <songbird@songbirdnest.com>
*
* 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_ID3TAG_H
#define GST_ID3TAG_H
#include "gsttagmux.h"
#include "id3tag.h"
G_BEGIN_DECLS
typedef struct _GstID3Tag GstID3Tag;
typedef struct _GstID3TagClass GstID3TagClass;
struct _GstID3Tag {
GstTagMux tagmux;
gboolean write_v1;
gboolean write_v2;
gint v2_major_version;
};
struct _GstID3TagClass {
GstTagMuxClass tagmux_class;
};
#define GST_TYPE_ID3TAG \
(gst_id3tag_get_type())
#define GST_ID3TAG(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ID3TAG,GstID3Tag))
#define GST_ID3TAG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ID3TAG,GstID3TagClass))
#define GST_IS_ID3TAG(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ID3TAG))
#define GST_IS_ID3TAG_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ID3TAG))
GType gst_id3tag_get_type (void);
G_END_DECLS
#endif /* GST_ID3TAG_H */
This diff is collapsed.
/* GStreamer tag muxer base class
*
* Copyright (C) 2006 Christophe Fergeau <teuf@gnome.org>
* Copyright (C) 2006 Tim-Philipp Müller <tim centricular net>
* Copyright (C) 2009 Pioneers of the Inevitable <songbird@songbirdnest.com>
*
* 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_MUX_H
#define GST_TAG_MUX_H
#include <gst/gst.h>
G_BEGIN_DECLS
typedef struct _GstTagMux GstTagMux;
typedef struct _GstTagMuxClass GstTagMuxClass;
/* Definition of structure storing data for this element. */
struct _GstTagMux {
GstElement element;
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 */
};
/* Standard definition defining a class for this element. */
struct _GstTagMuxClass {
GstElementClass parent_class;
/* vfuncs */
GstBuffer * (*render_start_tag) (GstTagMux * mux, GstTagList * tag_list);
GstBuffer * (*render_end_tag) (GstTagMux * mux, GstTagList * tag_list);
};
/* Standard macros for defining types for this element. */
#define GST_TYPE_TAG_MUX \
(gst_tag_mux_get_type())
#define GST_TAG_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_TAG_MUX,GstTagMux))
#define GST_TAG_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_TAG_MUX,GstTagMuxClass))
#define GST_IS_TAG_MUX(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_TAG_MUX))
#define GST_IS_TAG_MUX_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_TAG_MUX))
/* Standard function returning type information. */
GType gst_tag_mux_get_type (void);
G_END_DECLS
#endif
This diff is collapsed.
/* GStreamer ID3v2 tag writer
* Copyright (C) 2009 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.
*/
#include "gsttagmux.h"
G_BEGIN_DECLS
#define ID3_VERSION_2_3 3
#define ID3_VERSION_2_4 4
GstBuffer * gst_id3mux_render_v2_tag (GstTagMux * mux, GstTagList * taglist,
int version);
GstBuffer * gst_id3mux_render_v1_tag (GstTagMux * mux, GstTagList * taglist);
G_END_DECLS
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment