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:
Thiago Santos 2014-01-14 13:02:28 -03:00
parent 695ddbd56f
commit 36efe20679

View File

@ -42,6 +42,8 @@ typedef struct _GstAudioDecoderTesterClass GstAudioDecoderTesterClass;
struct _GstAudioDecoderTester struct _GstAudioDecoderTester
{ {
GstAudioDecoder parent; GstAudioDecoder parent;
gboolean setoutputformat_on_decoding;
}; };
struct _GstAudioDecoderTesterClass struct _GstAudioDecoderTesterClass
@ -72,17 +74,19 @@ gst_audio_decoder_tester_flush (GstAudioDecoder * dec, gboolean hard)
static gboolean static gboolean
gst_audio_decoder_tester_set_format (GstAudioDecoder * dec, GstCaps * caps) gst_audio_decoder_tester_set_format (GstAudioDecoder * dec, GstCaps * caps)
{ {
GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec;
GstAudioInfo info; GstAudioInfo info;
gst_caps_unref (caps); gst_caps_unref (caps);
caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S16LE", if (!tester->setoutputformat_on_decoding) {
"channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 44100, caps = gst_caps_new_simple ("audio/x-raw", "format", G_TYPE_STRING, "S16LE",
"layout", G_TYPE_STRING, "interleaved", NULL); "channels", G_TYPE_INT, 2, "rate", G_TYPE_INT, 44100,
gst_audio_info_from_caps (&info, caps); "layout", G_TYPE_STRING, "interleaved", NULL);
gst_caps_unref (caps); gst_audio_info_from_caps (&info, caps);
gst_caps_unref (caps);
gst_audio_decoder_set_output_format (dec, &info);
gst_audio_decoder_set_output_format (dec, &info);
}
return TRUE; return TRUE;
} }
@ -90,6 +94,7 @@ static GstFlowReturn
gst_audio_decoder_tester_handle_frame (GstAudioDecoder * dec, gst_audio_decoder_tester_handle_frame (GstAudioDecoder * dec,
GstBuffer * buffer) GstBuffer * buffer)
{ {
GstAudioDecoderTester *tester = (GstAudioDecoderTester *) dec;
guint8 *data; guint8 *data;
gint size; gint size;
GstMapInfo map; GstMapInfo map;
@ -99,6 +104,19 @@ gst_audio_decoder_tester_handle_frame (GstAudioDecoder * dec,
if (buffer == NULL) if (buffer == NULL)
return GST_FLOW_OK; 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); gst_buffer_map (buffer, &map, GST_MAP_READ);
/* the output is SE16LE stereo 44100 Hz */ /* the output is SE16LE stereo 44100 Hz */
@ -370,6 +388,37 @@ GST_START_TEST (audiodecoder_negotiation_with_gap_event)
GST_END_TEST; 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 * static Suite *
gst_audiodecoder_suite (void) gst_audiodecoder_suite (void)
{ {
@ -380,6 +429,7 @@ gst_audiodecoder_suite (void)
tcase_add_test (tc, audiodecoder_playback); tcase_add_test (tc, audiodecoder_playback);
tcase_add_test (tc, audiodecoder_negotiation_with_buffer); tcase_add_test (tc, audiodecoder_negotiation_with_buffer);
tcase_add_test (tc, audiodecoder_negotiation_with_gap_event); tcase_add_test (tc, audiodecoder_negotiation_with_gap_event);
tcase_add_test (tc, audiodecoder_delayed_negotiation_with_gap_event);
return s; return s;
} }