* get_peer, and then remove references in every test function */
static GstPad *mysrcpad, *mysinkpad;
+#if G_BYTE_ORDER == G_LITTLE_ENDIAN
+#define FORMATS_F "{ F32LE, F64LE }"
+#define FORMATS_I "{ S16LE, S32LE }"
+#else
+#define FORMATS_F "{ F32BE, F64BE }"
+#define FORMATS_I "{ S16BE, S32BE }"
+#endif
+
#define RESAMPLE_CAPS_FLOAT \
- "audio/x-raw-float, " \
+ "audio/x-raw, " \
+ "formats = (string) "FORMATS_F", " \
"channels = (int) [ 1, MAX ], " \
- "rate = (int) [ 1, MAX ], " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) { 32, 64 }"
+ "rate = (int) [ 1, MAX ]"
#define RESAMPLE_CAPS_INT \
- "audio/x-raw-int, " \
+ "audio/x-raw, " \
+ "formats = (string) "FORMATS_I", " \
"channels = (int) [ 1, MAX ], " \
- "rate = (int) [ 1, MAX ], " \
- "endianness = (int) BYTE_ORDER, " \
- "width = (int) { 16, 32 }, " \
- "depth = (int) { 16, 32 }, " \
- "signed = (bool) TRUE"
+ "rate = (int) [ 1, MAX ]"
#define RESAMPLE_CAPS_TEMPLATE_STRING \
RESAMPLE_CAPS_FLOAT " ; " \
GstBuffer *inbuffer, *outbuffer;
GstCaps *caps;
guint64 offset = 0;
-
int i, j;
- gint16 *p;
+ gint16 *p, *data;
audioresample = setup_audioresample (2, inrate, outrate, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
gst_buffer_set_caps (inbuffer, caps);
- p = (gint16 *) GST_BUFFER_DATA (inbuffer);
+ p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
++p;
}
+ gst_buffer_unmap (inbuffer, data, samples * 4);
/* pushing gives away my reference ... */
fail_unless (gst_pad_push (mysrcpad, inbuffer) == GST_FLOW_OK);
GstClockTime ints;
int i, j;
- gint16 *p;
+ gint16 *p, *data;
GST_DEBUG ("inrate:%d outrate:%d samples:%d numbuffers:%d",
inrate, outrate, samples, numbuffers);
gst_buffer_set_caps (inbuffer, caps);
- p = (gint16 *) GST_BUFFER_DATA (inbuffer);
-
+ p = data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
/* create a 16 bit signed ramp */
for (i = 0; i < samples; ++i) {
*p = -32767 + i * (65535 / samples);
*p = -32767 + i * (65535 / samples);
++p;
}
+ gst_buffer_unmap (inbuffer, data, samples * 4);
GST_DEBUG ("Sending Buffer time:%" G_GUINT64_FORMAT " duration:%"
G_GINT64_FORMAT " discont:%d offset:%" G_GUINT64_FORMAT " offset_end:%"
GstEvent *newseg;
GstBuffer *inbuffer;
GstCaps *caps;
+ guint8 *data;
audioresample = setup_audioresample (1, 9343, 48000, 16, FALSE);
caps = gst_pad_get_negotiated_caps (mysrcpad);
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
- memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+ data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ memset (data, 0, 9343 * 4);
+ gst_buffer_unmap (inbuffer, data, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
fail_unless (gst_pad_push_event (mysrcpad, newseg) != FALSE);
inbuffer = gst_buffer_new_and_alloc (9343 * 4);
- memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+ data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ memset (data, 0, 9343 * 4);
+ gst_buffer_unmap (inbuffer, data, 9343 * 4);
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
g_object_set (cf2, "name", "capsfilter2", NULL);
sink = gst_check_setup_element ("fakesink");
- caps =
- gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 11025, NULL);
+ caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 11025, NULL);
g_object_set (cf1, "caps", caps, NULL);
gst_caps_unref (caps);
- caps =
- gst_caps_new_simple ("audio/x-raw-int", "rate", G_TYPE_INT, 48000, NULL);
+ caps = gst_caps_new_simple ("audio/x-raw", "rate", G_TYPE_INT, 48000, NULL);
g_object_set (cf2, "caps", caps, NULL);
gst_caps_unref (caps);
GST_END_TEST;
+#if 0
static GstFlowReturn
live_switch_alloc_only_48000 (GstPad * pad, guint64 offset,
guint size, GstCaps * caps, GstBuffer ** buf)
return GST_FLOW_OK;
}
+#endif
static GstCaps *
live_switch_get_sink_caps (GstPad * pad)
GstBuffer *inbuffer;
GstCaps *desired;
GList *l;
+ guint8 *data;
desired = gst_caps_copy (caps);
gst_caps_set_simple (desired, "rate", G_TYPE_INT, rate, NULL);
gst_pad_set_caps (mysrcpad, desired);
+#if 0
fail_unless (gst_pad_alloc_buffer_and_set_caps (mysrcpad,
GST_BUFFER_OFFSET_NONE, rate * 4, desired, &inbuffer) == GST_FLOW_OK);
+#endif
+ inbuffer = gst_buffer_new_and_alloc (rate * 4);
+ gst_buffer_set_caps (inbuffer, desired);
/* When the basetransform hits the non-configured case it always
* returns a buffer with exactly the same caps as we requested so the actual
desired, GST_BUFFER_CAPS (inbuffer));
fail_unless (gst_caps_is_equal (desired, GST_BUFFER_CAPS (inbuffer)));
- memset (GST_BUFFER_DATA (inbuffer), 0, GST_BUFFER_SIZE (inbuffer));
+ data = gst_buffer_map (inbuffer, NULL, NULL, GST_MAP_WRITE);
+ memset (data, 0, rate * 4);
+ gst_buffer_unmap (inbuffer, data, rate * 4);
+
GST_BUFFER_DURATION (inbuffer) = GST_SECOND;
GST_BUFFER_TIMESTAMP (inbuffer) = 0;
GST_BUFFER_OFFSET (inbuffer) = 0;
* rate 48000- and can only allocate buffers for that rate, but if someone
* tries to get a buffer with a rate higher then 48000 tries to renegotiate
* */
- gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
+ //gst_pad_set_bufferalloc_function (mysinkpad, live_switch_alloc_only_48000);
gst_pad_set_getcaps_function (mysinkpad, live_switch_get_sink_caps);
gst_pad_use_fixed_caps (mysrcpad);
}
static void
-test_pipeline (gint width, gboolean fp, gint inrate, gint outrate, gint quality)
+test_pipeline (const gchar * format, gint inrate, gint outrate, gint quality)
{
GstElement *pipeline;
GstBus *bus;
pipe_str =
g_strdup_printf
- ("audiotestsrc num-buffers=10 ! audioconvert ! audio/x-raw-%s,rate=%d,width=%d,channels=2 ! audioresample quality=%d ! audio/x-raw-%s,rate=%d,width=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
- (fp) ? "float" : "int", inrate, width, quality, (fp) ? "float" : "int",
- outrate, width);
+ ("audiotestsrc num-buffers=10 ! audioconvert ! audio/x-raw,format=%s,rate=%d,channels=2 ! audioresample quality=%d ! audio/x-raw,format=%s,rate=%d ! identity check-imperfect-timestamp=TRUE ! fakesink",
+ format, inrate, quality, format, outrate);
pipeline = gst_parse_launch (pipe_str, &error);
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
gint rate = 0;
pipeline = gst_parse_launch ("audiotestsrc num-buffers=1 name=src ! "
- "audioresample ! audio/x-raw-int,channels=1,width=16,depth=16,"
- "endianness=BYTE_ORDER,signed=true,rate=8000 ! "
- "fakesink can-activate-pull=false", &error);
+ "audioresample ! audio/x-raw,format=" GST_AUDIO_NE (S16) ",channels=1,"
+ "rate=8000 ! fakesink can-activate-pull=false", &error);
fail_unless (pipeline != NULL, "Error parsing pipeline: %s",
error ? error->message : "(invalid error)");
ctx->out_buffer_count++;
if (ctx->latency == GST_CLOCK_TIME_NONE) {
- ctx->latency = 1000 - GST_BUFFER_SIZE (buffer) / 8;
+ ctx->latency = 1000 - gst_buffer_get_size (buffer) / 8;
}
/* Check if we have a perfectly timestamped stream */
/* Check if we have a perfectly offsetted stream */
fail_unless (GST_BUFFER_OFFSET_END (buffer) ==
- GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
+ GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
"expected offset end %" G_GUINT64_FORMAT " got offset end %"
G_GUINT64_FORMAT,
- GST_BUFFER_OFFSET (buffer) + GST_BUFFER_SIZE (buffer) / 8,
+ GST_BUFFER_OFFSET (buffer) + gst_buffer_get_size (buffer) / 8,
GST_BUFFER_OFFSET_END (buffer));
if (ctx->next_out_off != GST_BUFFER_OFFSET_NONE) {
fail_unless (GST_BUFFER_OFFSET (buffer) == ctx->next_out_off,
fail_unless (capsfilter1 != NULL);
caps =
gst_caps_from_string
- ("audio/x-raw-float, channels=1, width=64, rate=16384");
+ ("audio/x-raw, format=F64LE, channels=1, rate=16384");
g_object_set (G_OBJECT (capsfilter1), "caps", caps, NULL);
gst_caps_unref (caps);
capsfilter2 = gst_element_factory_make ("capsfilter", "capsfilter2");
fail_unless (capsfilter2 != NULL);
caps =
- gst_caps_from_string
- ("audio/x-raw-float, channels=1, width=64, rate=4096");
+ gst_caps_from_string ("audio/x-raw, format=F64LE, channels=1, rate=4096");
g_object_set (G_OBJECT (capsfilter2), "caps", caps, NULL);
gst_caps_unref (caps);