ext/taglib/gsttaglib.cc: We do not want to proxy the caps on the sink pad; our source pad should have application/x-i...

Original commit message from CVS:
* ext/taglib/gsttaglib.cc:
We do not want to proxy the caps on the sink pad; our
source pad should have application/x-id3 caps; also,
don't use already-freed strings in debug messages;
finally, adjust buffer offsets on buffers sent out.
This commit is contained in:
Tim-Philipp Müller 2006-03-25 21:57:24 +00:00
parent 72b5f716fe
commit 022687f7ab
2 changed files with 28 additions and 10 deletions

View file

@ -1,3 +1,11 @@
2006-03-25 Tim-Philipp Müller <tim at centricular dot net>
* ext/taglib/gsttaglib.cc:
We do not want to proxy the caps on the sink pad; our
source pad should have application/x-id3 caps; also,
don't use already-freed strings in debug messages;
finally, adjust buffer offsets on buffers sent out.
2006-03-25 Tim-Philipp Müller <tim at centricular dot net> 2006-03-25 Tim-Philipp Müller <tim at centricular dot net>
* sys/v4l2/gstv4l2src.c: * sys/v4l2/gstv4l2src.c:

View file

@ -149,14 +149,11 @@ static void
gst_tag_lib_mux_init (GstTagLibMux * taglib, gst_tag_lib_mux_init (GstTagLibMux * taglib,
GstTagLibMuxClass * taglibmux_class) GstTagLibMuxClass * taglibmux_class)
{ {
GstElementClass *klass = GST_ELEMENT_CLASS (taglibmux_class); GstCaps *srccaps;
/* pad through which data comes in to the element */ /* pad through which data comes in to the element */
taglib->sinkpad = taglib->sinkpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass, gst_pad_new_from_static_template (&gst_tag_lib_mux_sink_template, "sink");
"sink"), "sink");
gst_pad_set_setcaps_function (taglib->sinkpad,
GST_DEBUG_FUNCPTR (gst_pad_proxy_setcaps));
gst_pad_set_chain_function (taglib->sinkpad, gst_pad_set_chain_function (taglib->sinkpad,
GST_DEBUG_FUNCPTR (gst_tag_lib_mux_chain)); GST_DEBUG_FUNCPTR (gst_tag_lib_mux_chain));
gst_pad_set_event_function (taglib->sinkpad, gst_pad_set_event_function (taglib->sinkpad,
@ -165,8 +162,10 @@ gst_tag_lib_mux_init (GstTagLibMux * taglib,
/* pad through which data goes out of the element */ /* pad through which data goes out of the element */
taglib->srcpad = taglib->srcpad =
gst_pad_new_from_template (gst_element_class_get_pad_template (klass, gst_pad_new_from_static_template (&gst_tag_lib_mux_src_template, "src");
"src"), "src"); srccaps = gst_static_pad_template_get_caps (&gst_tag_lib_mux_src_template);
gst_pad_use_fixed_caps (taglib->srcpad);
gst_pad_set_caps (taglib->srcpad, srccaps);
gst_element_add_pad (GST_ELEMENT (taglib), taglib->srcpad); gst_element_add_pad (GST_ELEMENT (taglib), taglib->srcpad);
taglib->render_tag = TRUE; taglib->render_tag = TRUE;
@ -309,10 +308,11 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
tag_str = g_strdup_printf ("%d", volume_number); tag_str = g_strdup_printf ("%d", volume_number);
} }
GST_DEBUG ("Setting album number to %s", tag_str);
id3v2tag->addFrame (frame); id3v2tag->addFrame (frame);
frame->setText (tag_str); frame->setText (tag_str);
g_free (tag_str); g_free (tag_str);
GST_DEBUG ("Setting album number to %s", tag_str);
} }
} else if (strcmp (tag, GST_TAG_COPYRIGHT) == 0) { } else if (strcmp (tag, GST_TAG_COPYRIGHT) == 0) {
gchar *copyright; gchar *copyright;
@ -322,12 +322,13 @@ add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
if (result != FALSE) { if (result != FALSE) {
ID3v2::TextIdentificationFrame * frame; ID3v2::TextIdentificationFrame * frame;
GST_DEBUG ("Setting copyright to %s", copyright);
frame = new ID3v2::TextIdentificationFrame ("TCOP", String::UTF8); frame = new ID3v2::TextIdentificationFrame ("TCOP", String::UTF8);
id3v2tag->addFrame (frame); id3v2tag->addFrame (frame);
frame->setText (copyright); frame->setText (copyright);
g_free (copyright); g_free (copyright);
GST_DEBUG ("Setting copyright to %s", copyright);
} }
} else if (strcmp (tag, GST_TAG_MUSICBRAINZ_ARTISTID) == 0) { } else if (strcmp (tag, GST_TAG_MUSICBRAINZ_ARTISTID) == 0) {
gchar *id_str; gchar *id_str;
@ -417,6 +418,8 @@ gst_tag_lib_mux_render_tag (GstTagLibMux * taglib)
event = gst_event_new_tag (taglist); event = gst_event_new_tag (taglist);
gst_pad_push_event (taglib->srcpad, event); gst_pad_push_event (taglib->srcpad, event);
GST_BUFFER_OFFSET (buffer) = 0;
return buffer; return buffer;
} }
@ -429,7 +432,7 @@ gst_tag_lib_mux_chain (GstPad * pad, GstBuffer * buffer)
if (taglib->render_tag) { if (taglib->render_tag) {
GstFlowReturn ret; GstFlowReturn ret;
GST_INFO ("Adding tags to stream"); GST_INFO_OBJECT (taglib, "Adding tags to stream");
ret = gst_pad_push (taglib->srcpad, gst_tag_lib_mux_render_tag (taglib)); ret = gst_pad_push (taglib->srcpad, gst_tag_lib_mux_render_tag (taglib));
if (ret != GST_FLOW_OK) { if (ret != GST_FLOW_OK) {
gst_buffer_unref (buffer); gst_buffer_unref (buffer);
@ -438,6 +441,13 @@ gst_tag_lib_mux_chain (GstPad * pad, GstBuffer * buffer)
taglib->render_tag = FALSE; taglib->render_tag = FALSE;
} }
if (GST_BUFFER_OFFSET (buffer) != GST_BUFFER_OFFSET_NONE) {
GST_LOG_OBJECT (taglib, "Adjusting buffer offset from %" G_GINT64_FORMAT
" to %" G_GINT64_FORMAT, GST_BUFFER_OFFSET (buffer),
GST_BUFFER_OFFSET (buffer) + taglib->tag_size);
GST_BUFFER_OFFSET (buffer) += taglib->tag_size;
}
gst_buffer_set_caps (buffer, GST_PAD_CAPS (taglib->srcpad)); gst_buffer_set_caps (buffer, GST_PAD_CAPS (taglib->srcpad));
return gst_pad_push (taglib->srcpad, buffer); return gst_pad_push (taglib->srcpad, buffer);
} }