#include <unistd.h>
+#include <gst/audio/audio.h>
#include <gst/base/gstbasetransform.h>
#include <gst/check/gstcheck.h>
#define DYNAMIC_CAPS_STRING \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
"channels = (int) 1, " \
"rate = (int) 44100, " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) 16, " \
- "depth = (int) 16, " \
- "signed = (bool) TRUE"
+ "format = (string) " GST_AUDIO_NE(S16)
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string)" GST_AUDIO_NE(S16)));
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
- GST_STATIC_CAPS ("audio/x-raw-int, "
+ GST_STATIC_CAPS ("audio/x-raw, "
"channels = (int) 1, "
"rate = (int) [ 1, MAX ], "
- "endianness = (int) BYTE_ORDER, "
- "width = (int) 16, " "depth = (int) 16, " "signed = (bool) TRUE")
- );
+ "format = (string) " GST_AUDIO_NE(S16)));
static GstElement *
setup_dynamic (void)
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[6] = { 24576, -16384, 256, -128, 0, -24576 };
- gint16 *res;
+ gint16 res[6];
dynamic = setup_dynamic ();
fail_unless (gst_element_set_state (dynamic,
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (12);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 12);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 12) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 12);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 12) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 12) == 12);
GST_INFO
("expected %+5d %+5d %+5d %+5d %+5d %+5d real %+5d %+5d %+5d %+5d %+5d %+5d",
in[0], in[1], in[2], in[3], in[4], in[5], res[0], res[1], res[2], res[3],
res[4], res[5]);
- fail_unless (memcmp (GST_BUFFER_DATA (outbuffer), in, 12) == 0);
+ fail_unless (gst_buffer_memcmp (outbuffer, 0, in, 12) == 0);
/* cleanup */
cleanup_dynamic (dynamic);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] > in[0]);
fail_unless (res[1] < in[1]);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] > in[0]);
fail_unless (res[1] < in[1]);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16384, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 0, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
gint16 in[8] = { -30000, 24576, -16383, 256, -128, 0, -24576, 30000 };
- gint16 *res;
+ gint16 res[8];
dynamic = setup_dynamic ();
g_object_set (G_OBJECT (dynamic), "mode", 1, NULL);
GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS,
"could not set to playing");
- inbuffer = gst_buffer_new_and_alloc (16);
- memcpy (GST_BUFFER_DATA (inbuffer), in, 16);
- fail_unless (memcmp (GST_BUFFER_DATA (inbuffer), in, 16) == 0);
+ inbuffer = gst_buffer_new_wrapped_full (in, NULL, 0, 16);
+ fail_unless (gst_buffer_memcmp (inbuffer, 0, in, 16) == 0);
caps = gst_caps_from_string (DYNAMIC_CAPS_STRING);
- gst_buffer_set_caps (inbuffer, caps);
+ fail_unless (gst_pad_set_caps (mysrcpad, caps));
gst_caps_unref (caps);
ASSERT_BUFFER_REFCOUNT (inbuffer, "inbuffer", 1);
fail_unless_equals_int (g_list_length (buffers), 1);
fail_if ((outbuffer = (GstBuffer *) buffers->data) == NULL);
- res = (gint16 *) GST_BUFFER_DATA (outbuffer);
+ fail_unless (gst_buffer_extract (outbuffer, 0, res, 16) == 16);
fail_unless (res[0] == in[0]);
fail_unless (res[1] == in[1]);