Commit 023a1637 authored by Tim-Philipp Müller's avatar Tim-Philipp Müller 🐠

apev2mux: write APE tags at end for wavpack files

http://www.wavpack.com/file_format.txt:
"Both the APEv2 tags and/or ID3v1 tags must come at the end of the
WavPack file, with the ID3v1 coming last if both are present."

WavPack files that contain APEv2 tags at the beginning of the files
are unplayable on players that use FFmpeg (like VLC) and most other
software (except Banshee). Players that use libwavpack directly can
play the files because it skips the tags, but does not recognize the
tag data at that location.

https://bugzilla.gnome.org/show_bug.cgi?id=711437
parent 7b64b3e1
......@@ -71,7 +71,7 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
G_DEFINE_TYPE (GstApev2Mux, gst_apev2_mux, GST_TYPE_TAG_MUX);
static GstBuffer *gst_apev2_mux_render_tag (GstTagMux * mux,
static GstBuffer *gst_apev2_mux_render_start_tag (GstTagMux * mux,
const GstTagList * taglist);
static GstBuffer *gst_apev2_mux_render_end_tag (GstTagMux * mux,
const GstTagList * taglist);
......@@ -82,7 +82,7 @@ gst_apev2_mux_class_init (GstApev2MuxClass * klass)
GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
GST_TAG_MUX_CLASS (klass)->render_start_tag =
GST_DEBUG_FUNCPTR (gst_apev2_mux_render_tag);
GST_DEBUG_FUNCPTR (gst_apev2_mux_render_start_tag);
GST_TAG_MUX_CLASS (klass)->render_end_tag =
GST_DEBUG_FUNCPTR (gst_apev2_mux_render_end_tag);
......@@ -106,6 +106,29 @@ gst_apev2_mux_init (GstApev2Mux * apev2mux)
/* nothing to do */
}
static gboolean
gst_apev2_mux_have_wavpack (GstApev2Mux * apev2mux)
{
const GstStructure *s;
gboolean ret;
GstCaps *caps;
GstPad *sink;
sink = gst_element_get_static_pad (GST_ELEMENT_CAST (apev2mux), "sink");
caps = gst_pad_get_current_caps (sink);
gst_object_unref (sink);
if (caps == NULL)
return FALSE;
s = gst_caps_get_structure (caps, 0);
ret = gst_structure_has_name (s, "audio/x-wavpack");
gst_caps_unref (caps);
GST_LOG_OBJECT (apev2mux, "got wavpack input: %s", ret ? "yes" : "no");
return ret;
}
static void
add_one_tag (const GstTagList * list, const gchar * tag, gpointer user_data)
{
......@@ -368,8 +391,20 @@ gst_apev2_mux_render_tag (GstTagMux * mux, const GstTagList * taglist)
return buf;
}
static GstBuffer *
gst_apev2_mux_render_start_tag (GstTagMux * mux, const GstTagList * taglist)
{
if (gst_apev2_mux_have_wavpack (GST_APEV2_MUX (mux)))
return NULL;
return gst_apev2_mux_render_tag (mux, taglist);
}
static GstBuffer *
gst_apev2_mux_render_end_tag (GstTagMux * mux, const GstTagList * taglist)
{
if (gst_apev2_mux_have_wavpack (GST_APEV2_MUX (mux)))
return gst_apev2_mux_render_tag (mux, taglist);
return NULL;
}
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