flacparse: Implement conversions between TIME and DEFAULT format

Fixes bug #650785.
This commit is contained in:
Sebastian Dröge 2011-05-23 11:36:36 +02:00
parent e0cadab5c2
commit 8823ae251a

View file

@ -198,6 +198,9 @@ static GstFlowReturn gst_flac_parse_parse_frame (GstBaseParse * parse,
GstBaseParseFrame * frame); GstBaseParseFrame * frame);
static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse, static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse,
GstBaseParseFrame * frame); GstBaseParseFrame * frame);
static gboolean gst_flac_parse_convert (GstBaseParse * parse,
GstFormat src_format, gint64 src_value, GstFormat dest_format,
gint64 * dest_value);
GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse, GST_BOILERPLATE (GstFlacParse, gst_flac_parse, GstBaseParse,
GST_TYPE_BASE_PARSE); GST_TYPE_BASE_PARSE);
@ -244,6 +247,7 @@ gst_flac_parse_class_init (GstFlacParseClass * klass)
baseparse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_parse_frame); baseparse_class->parse_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_parse_frame);
baseparse_class->pre_push_frame = baseparse_class->pre_push_frame =
GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame); GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame);
baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert);
} }
static void static void
@ -1351,3 +1355,34 @@ gst_flac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame)
return GST_FLOW_OK; return GST_FLOW_OK;
} }
static gboolean
gst_flac_parse_convert (GstBaseParse * parse,
GstFormat src_format, gint64 src_value, GstFormat dest_format,
gint64 * dest_value)
{
GstFlacParse *flacparse = GST_FLAC_PARSE (parse);
if (flacparse->samplerate > 0) {
if (src_format == GST_FORMAT_DEFAULT && dest_format == GST_FORMAT_TIME) {
if (src_value != -1)
*dest_value =
gst_util_uint64_scale (src_value, GST_SECOND,
flacparse->samplerate);
else
*dest_value = -1;
return TRUE;
} else if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_TIME) {
if (src_value != -1)
*dest_value =
gst_util_uint64_scale (src_value, flacparse->samplerate,
GST_SECOND);
else
*dest_value = -1;
return TRUE;
}
}
return GST_BASE_PARSE_CLASS (parent_class)->convert (parse, src_format,
src_value, dest_format, dest_value);
}