tests: port amrnbenc test to 0.11
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 30 Oct 2011 15:05:56 +0000 (15:05 +0000)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Sun, 30 Oct 2011 15:05:56 +0000 (15:05 +0000)
tests/check/elements/amrnbenc.c

index 82b938a..72dc766 100644 (file)
  */
 
 #include <gst/check/gstcheck.h>
+#include <gst/audio/audio.h>
 
-#define SRC_CAPS "audio/x-raw-int,width=16,depth=16,channels=1,rate=8000,signed=true,endianness=BYTE_ORDER"
+#define SRC_CAPS "audio/x-raw, format = (string)" GST_AUDIO_NE (S16) ", " \
+    "channels = (int) 1, rate = (int) 8000"
 #define SINK_CAPS "audio/AMR"
 
 GList *buffers;
@@ -43,32 +45,17 @@ static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
     GST_STATIC_CAPS (SRC_CAPS)
     );
 
-/* takes a copy of the passed buffer data */
-GstBuffer *
-buffer_new (const gchar * buffer_data, guint size)
-{
-  GstBuffer *buffer;
-  GstCaps *caps;
-
-  buffer = gst_buffer_new_and_alloc (size);
-  memcpy (GST_BUFFER_DATA (buffer), buffer_data, size);
-  caps = gst_caps_from_string (SRC_CAPS);
-  gst_buffer_set_caps (buffer, caps);
-  gst_caps_unref (caps);
-
-  return buffer;
-}
-
 static void
 buffer_unref (void *buffer, void *user_data)
 {
   gst_buffer_unref (GST_BUFFER (buffer));
 }
 
-GstElement *
-setup_amrnbenc ()
+static GstElement *
+setup_amrnbenc (void)
 {
   GstElement *amrnbenc;
+  GstCaps *caps;
   GstBus *bus;
   guint64 granulerate_n, granulerate_d;
 
@@ -87,6 +74,10 @@ setup_amrnbenc ()
           GST_STATE_PLAYING) != GST_STATE_CHANGE_FAILURE,
       "could not set to playing");
 
+  caps = gst_caps_from_string (SRC_CAPS);
+  fail_unless (gst_pad_push_event (srcpad, gst_event_new_caps (caps)));
+  gst_caps_unref (caps);
+
   buffers = NULL;
   return amrnbenc;
 }
@@ -119,13 +110,14 @@ push_data (gint size, GstFlowReturn expected_return)
 {
   GstBuffer *buffer;
   GstFlowReturn res;
-  gchar *data = g_malloc0 (size);
 
-  buffer = buffer_new (data, size);
-  g_free (data);
+  buffer = gst_buffer_new_and_alloc (size);
+
   res = gst_pad_push (srcpad, buffer);
   fail_unless (res == expected_return,
-      "pushing audio returned %d not %d", res, expected_return);
+      "pushing audio returned %d (%s) not %d (%s)", res,
+      gst_flow_get_name (res), expected_return,
+      gst_flow_get_name (expected_return));
 }
 
 GST_START_TEST (test_enc)