Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/GStreamer/gst-plugins-good.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorHavard Graff <havard@pexip.com>2020-04-03 11:29:18 +0300
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-04-03 12:04:32 +0300
commitd9aaa15a30ecaf86e9ca82135300fcd223da5648 (patch)
treed59e7d4e813321bf79284efd041e9711f02a7d3b /tests
parent018218dd73d9f79b8756e059f2e00d2fbd9b952e (diff)
rtpopuspay: make depay ! pay work
There is a use-case for a server to re-payload opus going through it. Problem was that the payloader requires channels in the caps, but this is not something the depayloader can parse out of the stream, meaning caps-negotiation would fail. Removing the requirement of channels in the template-caps fixes this.
Diffstat (limited to 'tests')
-rw-r--r--tests/check/elements/rtpopus.c92
-rw-r--r--tests/check/meson.build1
2 files changed, 93 insertions, 0 deletions
diff --git a/tests/check/elements/rtpopus.c b/tests/check/elements/rtpopus.c
new file mode 100644
index 000000000..35a9af86c
--- /dev/null
+++ b/tests/check/elements/rtpopus.c
@@ -0,0 +1,92 @@
+/* GStreamer
+ *
+ * Copyright (C) 2020 Pexip AS
+ * @author Havard Graff <havard@pexip.com>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+#include <gst/check/check.h>
+#include <gst/check/gstharness.h>
+#include <gst/rtp/gstrtpbuffer.h>
+
+#define buffer_from_array(a) gst_buffer_new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_TEST (test_pay_to_depay)
+{
+ GstHarness *h = gst_harness_new_parse ("rtpopuspay ! rtpopusdepay");
+ GstBuffer *buf = buffer_from_array (opus_data);
+ gst_harness_set_src_caps_str (h, "audio/x-opus,channel-mapping-family=0");
+ fail_unless_equals_int (GST_FLOW_OK, gst_harness_push (h, buf));
+ gst_buffer_unref (gst_harness_pull (h));
+
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST
+GST_START_TEST (test_depay_to_pay)
+{
+ GstHarness *h = gst_harness_new_parse ("rtpopusdepay ! rtpopuspay");
+ guint8 opus_rtp_buf[] = {
+ 0x80, 0x60, 0x54, 0xfd, 0x3b, 0x5a, 0x93, 0xf9, 0x1c, 0x33, 0x2b, 0xbb,
+ };
+ GstBuffer *buf = buffer_from_array (opus_rtp_buf);
+ gst_harness_set_src_caps_str (h,
+ "application/x-rtp,encoding-name=OPUS,media=audio,clock-rate=48000,payload=96");
+ fail_unless_equals_int (GST_FLOW_OK, gst_harness_push (h, buf));
+ gst_buffer_unref (gst_harness_pull (h));
+
+ gst_harness_teardown (h);
+}
+
+GST_END_TEST;
+
+static Suite *
+rtpopus_suite (void)
+{
+ Suite *s = suite_create ("rtpopus");
+ TCase *tc_chain;
+
+ suite_add_tcase (s, (tc_chain = tcase_create ("rtpopus")));
+ tcase_add_test (tc_chain, test_pay_to_depay);
+ tcase_add_test (tc_chain, test_depay_to_pay);
+
+ return s;
+}
+
+GST_CHECK_MAIN (rtpopus);
diff --git a/tests/check/meson.build b/tests/check/meson.build
index fd5a931c7..aa1710623 100644
--- a/tests/check/meson.build
+++ b/tests/check/meson.build
@@ -64,6 +64,7 @@ good_tests = [
[ 'elements/rtph263' ],
[ 'elements/rtph264' ],
[ 'elements/rtph265' ],
+ [ 'elements/rtpopus' ],
[ 'elements/rtpvp9' ],
[ 'elements/rtpbin' ],
[ 'elements/rtpbin_buffer_list' ],