Merge the tizen patch and fix build err based on 1.12.2
[platform/upstream/gst-plugins-good.git] / ext / taglib / gstapev2mux.cc
index d1c689e..9659daf 100644 (file)
@@ -15,8 +15,8 @@
  *
  * 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.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 
 /**
  * <refsect2>
  * <title>Example pipelines</title>
  * |[
- * gst-launch -v filesrc location=foo.ogg ! decodebin ! audioconvert ! lame ! apev2mux ! filesink location=foo.mp3
+ * gst-launch-1.0 -v filesrc location=foo.ogg ! decodebin ! audioconvert ! lame ! apev2mux ! filesink location=foo.mp3
  * ]| A pipeline that transcodes a file from Ogg/Vorbis to mp3 format with an
  * APEv2 that contains the same as the the Ogg/Vorbis file. Make sure the
  * Ogg/Vorbis file actually has comments to preserve.
  * |[
- * gst-launch -m filesrc location=foo.mp3 ! apedemux ! fakesink silent=TRUE 2&gt; /dev/null | grep taglist
+ * gst-launch-1.0 -m filesrc location=foo.mp3 ! apedemux ! fakesink silent=TRUE 2&gt; /dev/null | grep taglist
  * ]| Verify that tags have been written.
  * </refsect2>
  */
@@ -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,14 +82,12 @@ 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);
 
-  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_add_static_pad_template (element_class, &sink_template);
+  gst_element_class_add_static_pad_template (element_class, &src_template);
 
   gst_element_class_set_static_metadata (element_class,
       "TagLib-based APEv2 Muxer", "Formatter/Metadata",
@@ -106,6 +104,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)
 {
@@ -369,7 +390,19 @@ gst_apev2_mux_render_tag (GstTagMux * mux, const GstTagList * taglist)
 }
 
 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;
 }