From: Edward Hervey Date: Tue, 4 Oct 2005 17:44:43 +0000 (+0000) Subject: ext/dv/: Added DEFAULT <==> BYTES, TIME conversions on srcpad, X-Git-Tag: RELEASE-0_9_4~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=3ec9e676e764b773aedd1d50b01cbebe60c31c91;p=platform%2Fupstream%2Fgst-plugins-good.git ext/dv/: Added DEFAULT <==> BYTES, TIME conversions on srcpad, Original commit message from CVS: * ext/dv/Makefile.am: * ext/dv/gstdvdemux.c: (gst_dvdemux_src_query), (gst_dvdemux_src_conver): Added DEFAULT <==> BYTES, TIME conversions on srcpad, Corrected the query function for position so it doesn't forget what format was asked, and calls the conversion functions on the correct pad. --- diff --git a/ChangeLog b/ChangeLog index 2e98fa0..65b8319 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2005-10-04 Edward Hervey + + * ext/dv/Makefile.am: + * ext/dv/gstdvdemux.c: (gst_dvdemux_src_query), (gst_dvdemux_src_conver): + Added DEFAULT <==> BYTES, TIME conversions on srcpad, + Corrected the query function for position so it doesn't forget what + format was asked, and calls the conversion functions on the correct pad. + 2005-10-03 Thomas Vander Stichele * configure.ac: diff --git a/ext/dv/Makefile.am b/ext/dv/Makefile.am index 6352ca5..5afc7f0 100644 --- a/ext/dv/Makefile.am +++ b/ext/dv/Makefile.am @@ -1,8 +1,8 @@ plugin_LTLIBRARIES = libgstdv.la libgstdv_la_SOURCES = gstdv.c gstdvdec.c gstdvdemux.c -libgstdv_la_CFLAGS = $(GST_CFLAGS) $(LIBDV_CFLAGS) -libgstdv_la_LIBADD = $(GST_BASE_LIBS) $(LIBDV_LIBS) +libgstdv_la_CFLAGS = $(GST_CFLAGS) $(LIBDV_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) +libgstdv_la_LIBADD = $(GST_BASE_LIBS) $(LIBDV_LIBS) $(GST_PLUGINS_BASE_LIBS) -lgstaudio-@GST_MAJORMINOR@ libgstdv_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) noinst_HEADERS = gstdvdemux.h gstdvdec.h diff --git a/ext/dv/gstdvdemux.c b/ext/dv/gstdvdemux.c index ec50979..f72be8d 100644 --- a/ext/dv/gstdvdemux.c +++ b/ext/dv/gstdvdemux.c @@ -24,6 +24,7 @@ #include #include +#include #include "gstdvdemux.h" /* DV output has two modes, normal and wide. The resolution is the same in both @@ -245,13 +246,18 @@ gst_dvdemux_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value, goto done; } + GST_INFO ("src_value:%lld, src_format:%d, dest_format:%d", src_value, + src_format, *dest_format); + switch (src_format) { case GST_FORMAT_BYTES: switch (*dest_format) { - case GST_FORMAT_BYTES: - *dest_value = src_value; - break; case GST_FORMAT_DEFAULT: + if (pad == dvdemux->videosrcpad) + *dest_value = src_value / dvdemux->frame_len; + else if (pad == dvdemux->audiosrcpad) + *dest_value = src_value / gst_audio_frame_byte_size (pad); + break; case GST_FORMAT_TIME: *dest_format = GST_FORMAT_TIME; if (pad == dvdemux->videosrcpad) @@ -275,10 +281,41 @@ gst_dvdemux_src_convert (GstPad * pad, GstFormat src_format, gint64 src_value, *dest_value = 2 * src_value * dvdemux->frequency * dvdemux->channels / GST_SECOND; break; - case GST_FORMAT_TIME: case GST_FORMAT_DEFAULT: - *dest_format = GST_FORMAT_TIME; - *dest_value = src_value; + if (pad == dvdemux->videosrcpad) { + if (src_value) + *dest_value = src_value / (dvdemux->framerate * GST_SECOND); + else + *dest_value = 0; + } else if (pad == dvdemux->audiosrcpad) + *dest_value = 2 * src_value * dvdemux->frequency * + dvdemux->channels / (GST_SECOND * + gst_audio_frame_byte_size (pad)); + break; + default: + res = FALSE; + } + break; + case GST_FORMAT_DEFAULT: + switch (*dest_format) { + case GST_FORMAT_TIME: + if (pad == dvdemux->videosrcpad) { + *dest_value = src_value * GST_SECOND * dvdemux->framerate; + } else if (pad == dvdemux->audiosrcpad) { + if (src_value) + *dest_value = + src_value * GST_SECOND * gst_audio_frame_byte_size (pad) + / (2 * dvdemux->frequency * dvdemux->channels); + else + *dest_value = 0; + } + break; + case GST_FORMAT_BYTES: + if (pad == dvdemux->videosrcpad) { + *dest_value = src_value * dvdemux->frame_len; + } else if (pad == dvdemux->audiosrcpad) { + *dest_value = src_value * gst_audio_frame_byte_size (pad); + } break; default: res = FALSE; @@ -394,6 +431,7 @@ gst_dvdemux_src_query (GstPad * pad, GstQuery * query) case GST_QUERY_POSITION: { GstFormat format; + GstFormat format2; gint64 cur, end; GstPad *peer; @@ -415,8 +453,9 @@ gst_dvdemux_src_query (GstPad * pad, GstQuery * query) /* convert end to requested format */ if (end != -1) { - if (!(res = gst_pad_query_convert (dvdemux->sinkpad, - GST_FORMAT_BYTES, end, &format, &end))) { + format2 = format; + if (!(res = gst_pad_query_convert (pad, + GST_FORMAT_BYTES, end, &format2, &end))) { gst_object_unref (peer); goto error; } @@ -429,7 +468,6 @@ gst_dvdemux_src_query (GstPad * pad, GstQuery * query) if (!(res = gst_pad_query_convert (pad, GST_FORMAT_TIME, dvdemux->timestamp, &format, &cur))) goto error; - gst_query_set_position (query, format, cur, end); break; }