From afa4be4b3b2bfc3f83317de7c38a606caadb803c Mon Sep 17 00:00:00 2001 From: Yeongjin Jeong Date: Fri, 12 Oct 2018 22:33:15 +0900 Subject: [PATCH] tests: flvdemux: Add new test for channel detect using aac codec-data https://bugzilla.gnome.org/show_bug.cgi?id=797275 --- tests/check/elements/flvdemux.c | 129 ++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/tests/check/elements/flvdemux.c b/tests/check/elements/flvdemux.c index b8955bf9d9..dd46c84387 100644 --- a/tests/check/elements/flvdemux.c +++ b/tests/check/elements/flvdemux.c @@ -450,6 +450,134 @@ GST_START_TEST (test_aac) GST_END_TEST; +GST_START_TEST (test_aac_not_support_rate_channels) +{ + guint8 flv_header[] = { + 0x46, 0x4c, 0x56, 0x01, 0x04, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x44, /* script tag */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, + 0x00, 0x0a, 0x6f, 0x6e, 0x4d, 0x65, 0x74, 0x61, + 0x44, 0x61, 0x74, 0x61, 0x08, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x0c, 0x61, 0x75, 0x64, 0x69, 0x6f, + 0x63, 0x6f, 0x64, 0x65, 0x63, 0x69, 0x64, 0x00, + 0x40, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0d, 0x61, 0x75, 0x64, 0x69, 0x6f, 0x64, + 0x61, 0x74, 0x61, 0x72, 0x61, 0x74, 0x65, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x4f, + }; + + guint8 aac_header[] = { + 0x08, 0x00, 0x00, 0x04, /* audio tag */ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xaf, + 0x00, 0x13, 0x88, 0x00, 0x00, 0x00, 0x0f, + }; + + guint8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69, 0x69, 0x69, 0x69, 0x69, 0x69, 0x69, + 0x69, 0x69, 0x69, 0x69, 0x69, 0x78, 0x00, 0x00, + 0x01, 0x62 + }; + + GstHarness *h = gst_harness_new_with_padnames ("flvdemux", "sink", NULL); + gst_harness_set_src_caps_str (h, "video/x-flv"); + + g_signal_connect (h->element, "pad-added", + G_CALLBACK (flvdemux_pad_added), h); + + gst_harness_push (h, create_buffer (flv_header, sizeof (flv_header))); + gst_harness_push (h, create_buffer (aac_header, sizeof (aac_header))); + gst_harness_push (h, create_buffer (aac_buffer, sizeof (aac_buffer))); + + { + GstCaps *caps; + const GstStructure *s; + gint mpegversion; + gboolean framed; + const gchar *stream_format; + gint rate; + gint channels; + const GValue *codec_data; + + caps = gst_pad_get_current_caps (h->sinkpad); + s = gst_caps_get_structure (caps, 0); + + fail_unless (gst_structure_has_name (s, "audio/mpeg")); + + gst_structure_get_int (s, "mpegversion", &mpegversion); + fail_unless_equals_int (4, mpegversion); + + gst_structure_get_boolean (s, "framed", &framed); + fail_unless (framed == TRUE); + + stream_format = gst_structure_get_string (s, "stream-format"); + fail_unless_equals_string ("raw", stream_format); + + gst_structure_get_int (s, "rate", &rate); + fail_unless_equals_int (22050, rate); + + gst_structure_get_int (s, "channels", &channels); + fail_unless_equals_int (1, channels); + + codec_data = gst_structure_get_value (s, "codec_data"); + fail_unless (codec_data != NULL); + fail_unless (G_VALUE_HOLDS (codec_data, GST_TYPE_BUFFER)); + + gst_caps_unref (caps); + } + + /* we should have gotten one encoded buffer */ + fail_unless_equals_int (1, gst_harness_buffers_in_queue (h)); + + gst_harness_teardown (h); +} + +GST_END_TEST; + GST_START_TEST (test_h264) { guint8 flv_header[] = { @@ -537,6 +665,7 @@ flvdemux_suite (void) tcase_add_test (tc_chain, test_speex); tcase_add_test (tc_chain, test_aac); tcase_add_test (tc_chain, test_h264); + tcase_add_test (tc_chain, test_aac_not_support_rate_channels); return s; }