mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
tests: audiodecoder: add another test for negotiation with gap event
Check that even if the subclass doesn't call set_output_format, the base class should use upstream provided caps to fill the output caps that is pushed before the gap event is forwarded, otherwise it ends again fixating the rate and channels to 1. https://bugzilla.gnome.org/show_bug.cgi?id=722144
This commit is contained in:
parent
695ddbd56f
commit
36efe20679
1 changed files with 57 additions and 7 deletions
|
@ -42,6 +42,8 @@ typedef struct _GstAudioDecoderTesterClass GstAudioDecoderTesterClass;
|
|||
struct _GstAudioDecoderTester
|
||||
{
|
||||
GstAudioDecoder parent;
|
||||
|
||||
gboolean setoutputformat_on_decoding;
|
||||
};
|
||||
|
||||
struct _GstAudioDecoderTesterClass
|
||||
|
@ -72,9 +74,11 @@ gst_audio_decoder_tester_flush (GstAudioDecoder * dec, gboolean hard)
|
|||
static gboolean
|
||||
gst_audio_decoder_tester_set_format (GstAudioDecoder * dec, GstCaps * caps)
|
||||
{
|
||||
GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec;
|
||||
GstAudioInfo info;
|
||||
gst_caps_unref (caps);
|
||||
|
||||
if (!tester->setoutputformat_on_decoding) {
|
||||
caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S16LE",
|
||||
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 44100,
|
||||
"layout", G_TYPE_STRING, "interleaved", NULL);
|
||||
|
@ -82,7 +86,7 @@ gst_audio_decoder_tester_set_format (GstAudioDecoder * dec, GstCaps * caps)
|
|||
gst_caps_unref (caps);
|
||||
|
||||
gst_audio_decoder_set_output_format (dec, &info);
|
||||
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -90,6 +94,7 @@ static GstFlowReturn
|
|||
gst_audio_decoder_tester_handle_frame (GstAudioDecoder * dec,
|
||||
GstBuffer * buffer)
|
||||
{
|
||||
GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec;
|
||||
guint8 *data;
|
||||
gint size;
|
||||
GstMapInfo map;
|
||||
|
@ -99,6 +104,19 @@ gst_audio_decoder_tester_handle_frame (GstAudioDecoder * dec,
|
|||
if (buffer == NULL)
|
||||
return GST_FLOW_OK;
|
||||
|
||||
if (tester->setoutputformat_on_decoding) {
|
||||
GstCaps *caps;
|
||||
GstAudioInfo info;
|
||||
|
||||
caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S16LE",
|
||||
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 44100,
|
||||
"layout", G_TYPE_STRING, "interleaved", NULL);
|
||||
gst_audio_info_from_caps (&info, caps);
|
||||
gst_caps_unref (caps);
|
||||
|
||||
gst_audio_decoder_set_output_format (dec, &info);
|
||||
}
|
||||
|
||||
gst_buffer_map (buffer, &map, GST_MAP_READ);
|
||||
|
||||
/* the output is SE16LE stereo 44100 Hz */
|
||||
|
@ -370,6 +388,37 @@ GST_START_TEST (audiodecoder_negotiation_with_gap_event)
|
|||
GST_END_TEST;
|
||||
|
||||
|
||||
GST_START_TEST (audiodecoder_delayed_negotiation_with_gap_event)
|
||||
{
|
||||
GstSegment segment;
|
||||
|
||||
setup_audiodecodertester ();
|
||||
|
||||
((GstAudioDecoderTester *) dec)->setoutputformat_on_decoding = TRUE;
|
||||
|
||||
gst_pad_set_active (mysrcpad, TRUE);
|
||||
gst_element_set_state (dec, GST_STATE_PLAYING);
|
||||
gst_pad_set_active (mysinkpad, TRUE);
|
||||
|
||||
send_startup_events ();
|
||||
|
||||
/* push a new segment */
|
||||
gst_segment_init (&segment, GST_FORMAT_TIME);
|
||||
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_segment (&segment)));
|
||||
|
||||
/* push a gap event to force audiodecoder to push a caps event */
|
||||
fail_unless (gst_pad_push_event (mysrcpad, gst_event_new_gap (0,
|
||||
GST_SECOND)));
|
||||
fail_unless (buffers == NULL);
|
||||
|
||||
check_audiodecoder_negotiation ();
|
||||
|
||||
cleanup_audiodecodertest ();
|
||||
}
|
||||
|
||||
GST_END_TEST;
|
||||
|
||||
|
||||
static Suite *
|
||||
gst_audiodecoder_suite (void)
|
||||
{
|
||||
|
@ -380,6 +429,7 @@ gst_audiodecoder_suite (void)
|
|||
tcase_add_test (tc, audiodecoder_playback);
|
||||
tcase_add_test (tc, audiodecoder_negotiation_with_buffer);
|
||||
tcase_add_test (tc, audiodecoder_negotiation_with_gap_event);
|
||||
tcase_add_test (tc, audiodecoder_delayed_negotiation_with_gap_event);
|
||||
|
||||
return s;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue