law: fix negotiation
[platform/upstream/gst-plugins-good.git] / gst / law / alaw-encode.c
index a115534..208e533 100644 (file)
@@ -26,6 +26,7 @@
 #include "config.h"
 #endif
 
+#include <gst/audio/audio.h>
 #include "alaw-encode.h"
 
 GST_DEBUG_CATEGORY_STATIC (alaw_enc_debug);
@@ -316,11 +317,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
     name = "audio/x-alaw";
     otherpad = alawenc->sinkpad;
   } else {
-    name = "audio/x-raw-int";
+    name = "audio/x-raw";
     otherpad = alawenc->srcpad;
   }
   /* get caps from the peer, this can return NULL when there is no peer */
-  othercaps = gst_pad_peer_query_caps (otherpad, filter);
+  othercaps = gst_pad_peer_query_caps (otherpad, NULL);
 
   /* get the template caps to make sure we return something acceptable */
   templ = gst_pad_get_pad_template_caps (pad);
@@ -340,14 +341,11 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
 
       if (pad == alawenc->srcpad) {
         /* remove the fields we don't want */
-        gst_structure_remove_fields (structure, "width", "depth", "endianness",
-            "signed", NULL);
+        gst_structure_remove_fields (structure, "format", NULL);
       } else {
         /* add fixed fields */
-        gst_structure_set (structure, "width", G_TYPE_INT, 16,
-            "depth", G_TYPE_INT, 16,
-            "endianness", G_TYPE_INT, G_BYTE_ORDER,
-            "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+        gst_structure_set (structure, "format", G_TYPE_STRING,
+            GST_AUDIO_NE (S16), NULL);
       }
     }
     /* filter against the allowed caps of the pad to return our result */
@@ -357,6 +355,13 @@ gst_alaw_enc_getcaps (GstPad * pad, GstCaps * filter)
     /* there was no peer, return the template caps */
     result = gst_caps_copy (templ);
   }
+  if (filter && result) {
+    GstCaps *temp;
+
+    temp = gst_caps_intersect (result, filter);
+    gst_caps_unref (result);
+    result = temp;
+  }
 
   return result;
 }