diff --git a/gst/audioparsers/gstflacparse.c b/gst/audioparsers/gstflacparse.c index 0671187dab..0c766552bf 100644 --- a/gst/audioparsers/gstflacparse.c +++ b/gst/audioparsers/gstflacparse.c @@ -198,6 +198,9 @@ static GstFlowReturn gst_flac_parse_parse_frame (GstBaseParse * parse, GstBaseParseFrame * frame); static GstFlowReturn gst_flac_parse_pre_push_frame (GstBaseParse * parse, 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_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->pre_push_frame = GST_DEBUG_FUNCPTR (gst_flac_parse_pre_push_frame); + baseparse_class->convert = GST_DEBUG_FUNCPTR (gst_flac_parse_convert); } static void @@ -1351,3 +1355,34 @@ gst_flac_parse_pre_push_frame (GstBaseParse * parse, GstBaseParseFrame * frame) 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); +}