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.
This commit is contained in:
Edward Hervey 2005-10-04 17:44:43 +00:00
parent 05799a1509
commit 3ec9e676e7
3 changed files with 57 additions and 11 deletions

View file

@ -1,3 +1,11 @@
2005-10-04 Edward Hervey <edward@fluendo.com>
* 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 <thomas at apestaart dot org>
* configure.ac:

View file

@ -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

View file

@ -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;
}