mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
tests: port amrnbenc test to 0.11
This commit is contained in:
parent
0f2f834285
commit
c5838071d5
1 changed files with 15 additions and 23 deletions
|
@ -22,8 +22,10 @@
|
|||
*/
|
||||
|
||||
#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)
|
||||
|
|
Loading…
Reference in a new issue