tests: fix after baseparse api change

This commit is contained in:
Wim Taymans 2012-02-14 10:50:45 +01:00
parent e16d8e3b19
commit d1beba8b6d

View File

@ -218,10 +218,8 @@ static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
static GType test_mpeg_audio_parse_get_type (void); static GType test_mpeg_audio_parse_get_type (void);
static gboolean test_mpeg_audio_parse_start (GstBaseParse * parse); static gboolean test_mpeg_audio_parse_start (GstBaseParse * parse);
static gboolean test_mpeg_audio_parse_stop (GstBaseParse * parse); static gboolean test_mpeg_audio_parse_stop (GstBaseParse * parse);
static gboolean test_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse, static GstFlowReturn test_mpeg_audio_parse_handle_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * size, gint * skipsize); GstBaseParseFrame * frame, gint * skipsize);
static GstFlowReturn test_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame);
G_DEFINE_TYPE (TestMpegAudioParse, test_mpeg_audio_parse, GST_TYPE_BASE_PARSE); G_DEFINE_TYPE (TestMpegAudioParse, test_mpeg_audio_parse, GST_TYPE_BASE_PARSE);
@ -242,8 +240,7 @@ test_mpeg_audio_parse_class_init (TestMpegAudioParseClass * klass)
parse_class->start = test_mpeg_audio_parse_start; parse_class->start = test_mpeg_audio_parse_start;
parse_class->stop = test_mpeg_audio_parse_stop; parse_class->stop = test_mpeg_audio_parse_stop;
parse_class->check_valid_frame = test_mpeg_audio_parse_check_valid_frame; parse_class->handle_frame = test_mpeg_audio_parse_handle_frame;
parse_class->parse_frame = test_mpeg_audio_parse_parse_frame;
} }
static gint num_parse_instances = 0; static gint num_parse_instances = 0;
@ -268,40 +265,33 @@ test_mpeg_audio_parse_stop (GstBaseParse * parse)
return TRUE; return TRUE;
} }
static gboolean static GstFlowReturn
test_mpeg_audio_parse_check_valid_frame (GstBaseParse * parse, test_mpeg_audio_parse_handle_frame (GstBaseParse * parse,
GstBaseParseFrame * frame, guint * framesize, gint * skipsize) GstBaseParseFrame * frame, gint * skipsize)
{ {
guint8 data[2]; guint8 data[2];
gst_buffer_extract (frame->buffer, 0, data, 2); gst_buffer_extract (frame->buffer, 0, data, 2);
if ((GST_READ_UINT16_BE (data) & 0xffe0) == 0xffe0) { if ((GST_READ_UINT16_BE (data) & 0xffe0) == 0xffe0) {
if (GST_BUFFER_OFFSET (frame->buffer) == 0) {
GstCaps *caps;
caps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1,
"mpegaudioversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3,
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 2, NULL);
gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
gst_caps_unref (caps);
}
/* this framesize is hard-coded for ../test.mp3 */ /* this framesize is hard-coded for ../test.mp3 */
*framesize = 1045; return gst_base_parse_finish_frame (parse, frame, 1045);
return TRUE;
} else { } else {
*skipsize = 1; *skipsize = 1;
return FALSE; return GST_FLOW_OK;
} }
} }
static GstFlowReturn
test_mpeg_audio_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame)
{
if (GST_BUFFER_OFFSET (frame->buffer) == 0) {
GstCaps *caps;
caps = gst_caps_new_simple ("audio/mpeg", "mpegversion", G_TYPE_INT, 1,
"mpegaudioversion", G_TYPE_INT, 1, "layer", G_TYPE_INT, 3,
"rate", G_TYPE_INT, 44100, "channels", G_TYPE_INT, 2, NULL);
gst_pad_set_caps (GST_BASE_PARSE_SRC_PAD (parse), caps);
gst_caps_unref (caps);
}
return GST_FLOW_OK;
}
static gboolean static gboolean
plugin_init (GstPlugin * plugin) plugin_init (GstPlugin * plugin)
{ {