GST_PAD_ALWAYS,
GST_STATIC_CAPS ("ANY"));
-GST_BOILERPLATE (GstId3v2Mux, gst_id3v2_mux, GstTagMux, GST_TYPE_TAG_MUX);
+G_DEFINE_TYPE (GstId3v2Mux, gst_id3v2_mux, GST_TYPE_TAG_MUX);
static GstBuffer *gst_id3v2_mux_render_tag (GstTagMux * mux,
const GstTagList * taglist);
const GstTagList * taglist);
static void
-gst_id3v2_mux_base_init (gpointer g_class)
+gst_id3v2_mux_class_init (GstId3v2MuxClass * klass)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+ GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+
+ 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_static_pad_template (element_class, &sink_template);
- gst_element_class_add_static_pad_template (element_class, &src_template);
+ 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));
gst_element_class_set_details_simple (element_class,
"TagLib-based ID3v2 Muxer", "Formatter/Metadata",
}
static void
-gst_id3v2_mux_class_init (GstId3v2MuxClass * klass)
-{
- 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);
-}
-
-static void
-gst_id3v2_mux_init (GstId3v2Mux * id3v2mux, GstId3v2MuxClass * id3v2mux_class)
+gst_id3v2_mux_init (GstId3v2Mux * id3v2mux)
{
/* nothing to do */
}
ID3v2::Frame * frame;
const GValue *val;
GstBuffer *buf;
+ GstSample *sample;
val = gst_tag_list_get_value_index (list, tag, i);
- buf = (GstBuffer *) gst_value_get_mini_object (val);
+ sample = (GstSample *) g_value_get_boxed (val);
- if (buf && GST_BUFFER_CAPS (buf)) {
+ if (sample && (buf = gst_sample_get_buffer (sample)) &&
+ gst_sample_get_caps (sample)) {
GstStructure *s;
gint version = 0;
- s = gst_caps_get_structure (GST_BUFFER_CAPS (buf), 0);
+ s = gst_caps_get_structure (gst_sample_get_caps (sample), 0);
if (s && gst_structure_get_int (s, "version", &version) && version > 0) {
- ByteVector bytes ((char *) GST_BUFFER_DATA (buf),
- GST_BUFFER_SIZE (buf));
+ GstMapInfo map;
+ gst_buffer_map (buf, &map, GST_MAP_READ);
GST_DEBUG ("Injecting ID3v2.%u frame %u/%u of length %u and type %"
- GST_PTR_FORMAT, version, i, num_tags, GST_BUFFER_SIZE (buf), s);
+ GST_PTR_FORMAT, version, i, num_tags, map.size, s);
- frame = factory->createFrame (bytes, (TagLib::uint) version);
+ frame = factory->createFrame (ByteVector ((const char *) map.data,
+ map.size), (TagLib::uint) version);
if (frame)
id3v2tag->addFrame (frame);
+
+ gst_buffer_unmap (buf, &map);
}
}
}
for (n = 0; n < num_tags; ++n) {
const GValue *val;
+ GstSample *sample;
GstBuffer *image;
GST_DEBUG ("image %u/%u", n + 1, num_tags);
val = gst_tag_list_get_value_index (list, tag, n);
- image = (GstBuffer *) gst_value_get_mini_object (val);
+ sample = (GstSample *) g_value_get_boxed (val);
- if (GST_IS_BUFFER (image) && GST_BUFFER_SIZE (image) > 0 &&
- GST_BUFFER_CAPS (image) != NULL &&
- !gst_caps_is_empty (GST_BUFFER_CAPS (image))) {
+ if (GST_IS_SAMPLE (image) && (image = gst_sample_get_buffer (sample)) &&
+ GST_IS_BUFFER (image) && gst_buffer_get_size (image) > 0 &&
+ gst_sample_get_caps (sample) != NULL &&
+ !gst_caps_is_empty (gst_sample_get_caps (sample))) {
const gchar *mime_type;
GstStructure *s;
- s = gst_caps_get_structure (GST_BUFFER_CAPS (image), 0);
+ s = gst_caps_get_structure (gst_sample_get_caps (sample), 0);
mime_type = gst_structure_get_name (s);
if (mime_type != NULL) {
ID3v2::AttachedPictureFrame * frame;
const gchar *desc;
+ GstMapInfo map;
if (strcmp (mime_type, "text/uri-list") == 0)
mime_type = "-->";
frame = new ID3v2::AttachedPictureFrame ();
+ gst_buffer_map (image, &map, GST_MAP_READ);
+
GST_DEBUG ("Attaching picture of %u bytes and mime type %s",
- GST_BUFFER_SIZE (image), mime_type);
+ map.size, mime_type);
id3v2tag->addFrame (frame);
- frame->setPicture (ByteVector ((const char *) GST_BUFFER_DATA (image),
- GST_BUFFER_SIZE (image)));
+ frame->setPicture (ByteVector ((const char *) map.data, map.size));
frame->setTextEncoding (String::UTF8);
frame->setMimeType (mime_type);
+ gst_buffer_unmap (image, &map);
+
desc = gst_structure_get_string (s, "image-description");
frame->setDescription ((desc) ? desc : "");
}
}
} else {
- GST_WARNING ("NULL image or no caps on image buffer (%p, caps=%"
- GST_PTR_FORMAT ")", image, (image) ? GST_BUFFER_CAPS (image) : NULL);
+ GST_WARNING ("NULL image or no caps on image sample (%p, caps=%"
+ GST_PTR_FORMAT ")", sample,
+ (sample) ? gst_sample_get_caps (sample) : NULL);
}
}
}
ID3v2::Tag id3v2tag;
ByteVector rendered_tag;
GstBuffer *buf;
- GstCaps *caps;
guint tag_size;
/* write all strings as UTF-8 by default */
/* Create buffer with tag */
buf = gst_buffer_new_and_alloc (tag_size);
- memcpy (GST_BUFFER_DATA (buf), rendered_tag.data (), tag_size);
-
- caps = gst_static_pad_template_get_caps (&src_template);
- gst_buffer_set_caps (buf, caps);
- gst_caps_unref (caps);
+ gst_buffer_fill (buf, 0, rendered_tag.data (), tag_size);
return buf;
}