summaryrefslogtreecommitdiffstats
path: root/ext/dv
diff options
context:
space:
mode:
authorEdward Hervey <bilboed@bilboed.com>2005-10-04 17:44:43 +0000
committerEdward Hervey <bilboed@bilboed.com>2005-10-04 17:44:43 +0000
commit3ec9e676e764b773aedd1d50b01cbebe60c31c91 (patch)
treebedd11a7a29d431ca4055f867b6aaa867132662f /ext/dv
parent05799a15093c4ada8475676b9d53d7c9d19fef28 (diff)
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.
Diffstat (limited to 'ext/dv')
-rw-r--r--ext/dv/Makefile.am4
-rw-r--r--ext/dv/gstdvdemux.c56
2 files changed, 49 insertions, 11 deletions
diff --git a/ext/dv/Makefile.am b/ext/dv/Makefile.am
index 6352ca58..5afc7f06 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 ec509790..f72be8d8 100644
--- a/ext/dv/gstdvdemux.c
+++ b/ext/dv/gstdvdemux.c
@@ -24,6 +24,7 @@
#include <string.h>
#include <math.h>
+#include <gst/audio/audio.h>
#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;
}