mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
interleave: set output caps layout to interleaved
Set output caps layout independently from input caps layout which can be either non-interleaved or interleaved. https://bugzilla.gnome.org/show_bug.cgi?id=733866
This commit is contained in:
parent
550be3e51b
commit
b8b5704445
2 changed files with 45 additions and 13 deletions
|
@ -782,7 +782,8 @@ gst_interleave_sink_setcaps (GstInterleave * self, GstPad * pad,
|
||||||
|
|
||||||
gst_structure_remove_field (s, "channel-mask");
|
gst_structure_remove_field (s, "channel-mask");
|
||||||
|
|
||||||
gst_structure_set (s, "channels", G_TYPE_INT, self->channels, NULL);
|
gst_structure_set (s, "channels", G_TYPE_INT, self->channels, "layout",
|
||||||
|
G_TYPE_STRING, "interleaved", NULL);
|
||||||
gst_interleave_set_channel_positions (self, s);
|
gst_interleave_set_channel_positions (self, s);
|
||||||
|
|
||||||
gst_interleave_send_stream_start (self);
|
gst_interleave_send_stream_start (self);
|
||||||
|
|
|
@ -401,7 +401,7 @@ GST_END_TEST;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
src_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
src_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
||||||
gpointer user_data)
|
gboolean interleaved, gpointer user_data)
|
||||||
{
|
{
|
||||||
gint n = GPOINTER_TO_INT (user_data);
|
gint n = GPOINTER_TO_INT (user_data);
|
||||||
gfloat *data;
|
gfloat *data;
|
||||||
|
@ -430,7 +430,7 @@ src_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
||||||
caps = gst_caps_new_simple ("audio/x-raw",
|
caps = gst_caps_new_simple ("audio/x-raw",
|
||||||
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
"format", G_TYPE_STRING, GST_AUDIO_NE (F32),
|
||||||
"channels", G_TYPE_INT, 1,
|
"channels", G_TYPE_INT, 1,
|
||||||
"layout", G_TYPE_STRING, "interleaved",
|
"layout", G_TYPE_STRING, interleaved ? "interleaved" : "non-interleaved",
|
||||||
"channel-mask", GST_TYPE_BITMASK, mask, "rate", G_TYPE_INT, 48000, NULL);
|
"channel-mask", GST_TYPE_BITMASK, mask, "rate", G_TYPE_INT, 48000, NULL);
|
||||||
|
|
||||||
gst_pad_set_caps (pad, caps);
|
gst_pad_set_caps (pad, caps);
|
||||||
|
@ -450,6 +450,20 @@ src_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
||||||
GST_BUFFER_DURATION (buffer) = GST_SECOND;
|
GST_BUFFER_DURATION (buffer) = GST_SECOND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
src_handoff_float32_interleaved (GstElement * element, GstBuffer * buffer,
|
||||||
|
GstPad * pad, gpointer user_data)
|
||||||
|
{
|
||||||
|
src_handoff_float32 (element, buffer, pad, TRUE, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
src_handoff_float32_non_interleaved (GstElement * element, GstBuffer * buffer,
|
||||||
|
GstPad * pad, gpointer user_data)
|
||||||
|
{
|
||||||
|
src_handoff_float32 (element, buffer, pad, FALSE, user_data);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
||||||
gpointer user_data)
|
gpointer user_data)
|
||||||
|
@ -509,11 +523,15 @@ sink_handoff_float32 (GstElement * element, GstBuffer * buffer, GstPad * pad,
|
||||||
have_data++;
|
have_data++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GST_START_TEST (test_interleave_2ch_pipeline)
|
static void
|
||||||
|
test_interleave_2ch_pipeline (gboolean interleaved)
|
||||||
{
|
{
|
||||||
GstElement *pipeline, *queue, *src1, *src2, *interleave, *sink;
|
GstElement *pipeline, *queue, *src1, *src2, *interleave, *sink;
|
||||||
GstPad *sinkpad0, *sinkpad1, *tmp, *tmp2;
|
GstPad *sinkpad0, *sinkpad1, *tmp, *tmp2;
|
||||||
GstMessage *msg;
|
GstMessage *msg;
|
||||||
|
void *src_handoff_float32 =
|
||||||
|
interleaved ? &src_handoff_float32_interleaved :
|
||||||
|
&src_handoff_float32_non_interleaved;
|
||||||
|
|
||||||
have_data = 0;
|
have_data = 0;
|
||||||
|
|
||||||
|
@ -589,6 +607,18 @@ GST_START_TEST (test_interleave_2ch_pipeline)
|
||||||
gst_object_unref (pipeline);
|
gst_object_unref (pipeline);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GST_START_TEST (test_interleave_2ch_pipeline_interleaved)
|
||||||
|
{
|
||||||
|
test_interleave_2ch_pipeline (TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
GST_END_TEST;
|
||||||
|
|
||||||
|
GST_START_TEST (test_interleave_2ch_pipeline_non_interleaved)
|
||||||
|
{
|
||||||
|
test_interleave_2ch_pipeline (FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
GST_END_TEST;
|
GST_END_TEST;
|
||||||
|
|
||||||
GST_START_TEST (test_interleave_2ch_pipeline_input_chanpos)
|
GST_START_TEST (test_interleave_2ch_pipeline_input_chanpos)
|
||||||
|
@ -606,16 +636,16 @@ GST_START_TEST (test_interleave_2ch_pipeline_input_chanpos)
|
||||||
fail_unless (src1 != NULL);
|
fail_unless (src1 != NULL);
|
||||||
g_object_set (src1, "num-buffers", 4, NULL);
|
g_object_set (src1, "num-buffers", 4, NULL);
|
||||||
g_object_set (src1, "signal-handoffs", TRUE, NULL);
|
g_object_set (src1, "signal-handoffs", TRUE, NULL);
|
||||||
g_signal_connect (src1, "handoff", G_CALLBACK (src_handoff_float32),
|
g_signal_connect (src1, "handoff",
|
||||||
GINT_TO_POINTER (2));
|
G_CALLBACK (src_handoff_float32_interleaved), GINT_TO_POINTER (2));
|
||||||
gst_bin_add (GST_BIN (pipeline), src1);
|
gst_bin_add (GST_BIN (pipeline), src1);
|
||||||
|
|
||||||
src2 = gst_element_factory_make ("fakesrc", "src2");
|
src2 = gst_element_factory_make ("fakesrc", "src2");
|
||||||
fail_unless (src2 != NULL);
|
fail_unless (src2 != NULL);
|
||||||
g_object_set (src2, "num-buffers", 4, NULL);
|
g_object_set (src2, "num-buffers", 4, NULL);
|
||||||
g_object_set (src2, "signal-handoffs", TRUE, NULL);
|
g_object_set (src2, "signal-handoffs", TRUE, NULL);
|
||||||
g_signal_connect (src2, "handoff", G_CALLBACK (src_handoff_float32),
|
g_signal_connect (src2, "handoff",
|
||||||
GINT_TO_POINTER (3));
|
G_CALLBACK (src_handoff_float32_interleaved), GINT_TO_POINTER (3));
|
||||||
gst_bin_add (GST_BIN (pipeline), src2);
|
gst_bin_add (GST_BIN (pipeline), src2);
|
||||||
|
|
||||||
queue = gst_element_factory_make ("queue", "queue");
|
queue = gst_element_factory_make ("queue", "queue");
|
||||||
|
@ -691,16 +721,16 @@ GST_START_TEST (test_interleave_2ch_pipeline_custom_chanpos)
|
||||||
fail_unless (src1 != NULL);
|
fail_unless (src1 != NULL);
|
||||||
g_object_set (src1, "num-buffers", 4, NULL);
|
g_object_set (src1, "num-buffers", 4, NULL);
|
||||||
g_object_set (src1, "signal-handoffs", TRUE, NULL);
|
g_object_set (src1, "signal-handoffs", TRUE, NULL);
|
||||||
g_signal_connect (src1, "handoff", G_CALLBACK (src_handoff_float32),
|
g_signal_connect (src1, "handoff",
|
||||||
GINT_TO_POINTER (0));
|
G_CALLBACK (src_handoff_float32_interleaved), GINT_TO_POINTER (0));
|
||||||
gst_bin_add (GST_BIN (pipeline), src1);
|
gst_bin_add (GST_BIN (pipeline), src1);
|
||||||
|
|
||||||
src2 = gst_element_factory_make ("fakesrc", "src2");
|
src2 = gst_element_factory_make ("fakesrc", "src2");
|
||||||
fail_unless (src2 != NULL);
|
fail_unless (src2 != NULL);
|
||||||
g_object_set (src2, "num-buffers", 4, NULL);
|
g_object_set (src2, "num-buffers", 4, NULL);
|
||||||
g_object_set (src2, "signal-handoffs", TRUE, NULL);
|
g_object_set (src2, "signal-handoffs", TRUE, NULL);
|
||||||
g_signal_connect (src2, "handoff", G_CALLBACK (src_handoff_float32),
|
g_signal_connect (src2, "handoff",
|
||||||
GINT_TO_POINTER (1));
|
G_CALLBACK (src_handoff_float32_interleaved), GINT_TO_POINTER (1));
|
||||||
gst_bin_add (GST_BIN (pipeline), src2);
|
gst_bin_add (GST_BIN (pipeline), src2);
|
||||||
|
|
||||||
queue = gst_element_factory_make ("queue", "queue");
|
queue = gst_element_factory_make ("queue", "queue");
|
||||||
|
@ -783,7 +813,8 @@ interleave_suite (void)
|
||||||
tcase_add_test (tc_chain, test_request_pads);
|
tcase_add_test (tc_chain, test_request_pads);
|
||||||
tcase_add_test (tc_chain, test_interleave_2ch);
|
tcase_add_test (tc_chain, test_interleave_2ch);
|
||||||
tcase_add_test (tc_chain, test_interleave_2ch_1eos);
|
tcase_add_test (tc_chain, test_interleave_2ch_1eos);
|
||||||
tcase_add_test (tc_chain, test_interleave_2ch_pipeline);
|
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_interleaved);
|
||||||
|
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_non_interleaved);
|
||||||
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_input_chanpos);
|
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_input_chanpos);
|
||||||
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_custom_chanpos);
|
tcase_add_test (tc_chain, test_interleave_2ch_pipeline_custom_chanpos);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue