ext/speex/gstspeexenc.c: Add position and duration query, fix query type function.

Original commit message from CVS:
* ext/speex/gstspeexenc.c: (gst_speexenc_get_query_types),
(gst_speexenc_src_query):
Add position and duration query, fix query type function.
* gst/matroska/matroska-demux.c: (gst_matroska_demux_add_stream),
(gst_matroska_demux_video_caps), (gst_matroska_demux_audio_caps):
Let's not set non-fixed caps on source pads.
This commit is contained in:
Tim-Philipp Müller 2005-10-21 17:00:58 +00:00
parent bee54790e7
commit 512eb8ab25
3 changed files with 67 additions and 65 deletions

View file

@ -1,3 +1,13 @@
2005-10-21 Tim-Philipp Müller <tim at centricular dot net>
* ext/speex/gstspeexenc.c: (gst_speexenc_get_query_types),
(gst_speexenc_src_query):
Add position and duration query, fix query type function.
* gst/matroska/matroska-demux.c: (gst_matroska_demux_add_stream),
(gst_matroska_demux_video_caps), (gst_matroska_demux_audio_caps):
Let's not set non-fixed caps on source pads.
2005-10-21 Wim Taymans <wim@fluendo.com> 2005-10-21 Wim Taymans <wim@fluendo.com>
* ext/dv/gstdvdemux.c: (gst_dvdemux_demux_frame): * ext/dv/gstdvdemux.c: (gst_dvdemux_demux_frame):

View file

@ -368,6 +368,8 @@ gst_speexenc_get_query_types (GstPad * pad)
{ {
static const GstQueryType gst_speexenc_src_query_types[] = { static const GstQueryType gst_speexenc_src_query_types[] = {
GST_QUERY_POSITION, GST_QUERY_POSITION,
GST_QUERY_DURATION,
GST_QUERY_CONVERT,
0 0
}; };
@ -379,48 +381,50 @@ gst_speexenc_src_query (GstPad * pad, GstQuery * query)
{ {
gboolean res = TRUE; gboolean res = TRUE;
GstSpeexEnc *speexenc; GstSpeexEnc *speexenc;
GstPad *peerpad;
speexenc = GST_SPEEXENC (GST_PAD_PARENT (pad)); speexenc = GST_SPEEXENC (gst_pad_get_parent (pad));
peerpad = gst_pad_get_peer (GST_PAD (speexenc->sinkpad));
switch (GST_QUERY_TYPE (query)) { switch (GST_QUERY_TYPE (query)) {
case GST_QUERY_POSITION: case GST_QUERY_POSITION:
{ {
#if 0 GstFormat fmt, req_fmt;
switch (*format) { gint64 pos, val;
case GST_FORMAT_BYTES:
case GST_FORMAT_TIME:
{
gint64 peer_value;
const GstFormat *peer_formats;
res = FALSE; gst_query_parse_position (query, &req_fmt, NULL);
if ((res = gst_pad_query_position (peerpad, &req_fmt, &val))) {
peer_formats = gst_pad_get_formats (GST_PAD_PEER (speexenc->sinkpad)); gst_query_set_position (query, req_fmt, val);
break;
while (peer_formats && *peer_formats && !res) { }
GstFormat peer_format = *peer_formats; fmt = GST_FORMAT_TIME;
if (!(res = gst_pad_query_position (peerpad, &fmt, &pos)))
/* do the probe */ break;
if (gst_pad_query (GST_PAD_PEER (speexenc->sinkpad),
GST_QUERY_TOTAL, &peer_format, &peer_value)) { if ((res = gst_pad_query_convert (peerpad, fmt, pos, &req_fmt, &val)))
GstFormat conv_format; gst_query_set_position (query, req_fmt, val);
/* convert to TIME */ break;
conv_format = GST_FORMAT_TIME; }
res = gst_pad_convert (speexenc->sinkpad, case GST_QUERY_DURATION:
peer_format, peer_value, &conv_format, value); {
/* and to final format */ GstFormat fmt, req_fmt;
res &= gst_pad_convert (pad, gint64 dur, val;
GST_FORMAT_TIME, *value, format, value);
} gst_query_parse_duration (query, &req_fmt, NULL);
peer_formats++; if ((res = gst_pad_query_duration (peerpad, &req_fmt, &val))) {
} gst_query_set_duration (query, req_fmt, val);
break; break;
} }
fmt = GST_FORMAT_TIME;
if (!(res = gst_pad_query_duration (peerpad, &fmt, &dur)))
break;
if ((res = gst_pad_query_convert (peerpad, fmt, dur, &req_fmt, &val))) {
gst_query_set_duration (query, req_fmt, val);
} }
#endif
res = FALSE;
break; break;
} }
case GST_QUERY_CONVERT: case GST_QUERY_CONVERT:
@ -441,6 +445,8 @@ gst_speexenc_src_query (GstPad * pad, GstQuery * query)
} }
error: error:
gst_object_unref (peerpad);
gst_object_unref (speexenc);
return res; return res;
} }

View file

@ -265,28 +265,6 @@ gst_matroska_demux_stream_from_num (GstMatroskaDemux * demux, guint track_num)
return -1; return -1;
} }
static GstCaps *
gst_matroska_demux_getcaps (GstPad * pad)
{
GstMatroskaDemux *demux;
GstCaps *caps = NULL;
guint i;
demux = GST_MATROSKA_DEMUX (gst_pad_get_parent (pad));
for (i = 0; caps == NULL && i < demux->num_streams; ++i) {
if (demux->src[i]->pad == pad)
caps = gst_caps_copy (demux->src[i]->caps);
}
gst_object_unref (demux);
g_return_val_if_fail (caps != NULL, NULL);
return caps;
}
static gboolean static gboolean
gst_matroska_demux_add_stream (GstMatroskaDemux * demux) gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
{ {
@ -922,16 +900,13 @@ gst_matroska_demux_add_stream (GstMatroskaDemux * demux)
if (caps) { if (caps) {
GST_LOG ("Adding pad '%s' with caps %" GST_PTR_FORMAT, padname, caps); GST_LOG ("Adding pad '%s' with caps %" GST_PTR_FORMAT, padname, caps);
if (gst_caps_is_fixed (caps)) { if (gst_caps_is_fixed (caps)) {
GST_LOG ("fixed caps");
gst_pad_use_fixed_caps (context->pad); gst_pad_use_fixed_caps (context->pad);
gst_pad_set_caps (context->pad, context->caps); gst_pad_set_caps (context->pad, context->caps);
gst_pad_set_active (context->pad, TRUE);
gst_element_add_pad (GST_ELEMENT (demux), context->pad);
} else { } else {
GST_LOG ("non-fixed caps"); g_warning ("FIXME: non-fixed caps: %s", gst_caps_to_string (caps));
gst_pad_set_getcaps_function (context->pad,
GST_DEBUG_FUNCPTR (gst_matroska_demux_getcaps));
} }
gst_pad_set_active (context->pad, TRUE);
gst_element_add_pad (GST_ELEMENT (demux), context->pad);
} else { } else {
/* FIXME: are we leaking the pad here? can this even happen? */ /* FIXME: are we leaking the pad here? can this even happen? */
GST_LOG ("Not adding pad '%s' with empty caps", padname); GST_LOG ("Not adding pad '%s' with empty caps", padname);
@ -2967,12 +2942,17 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
*codec_name = g_strdup ("MPEG-4 simple profile"); *codec_name = g_strdup ("MPEG-4 simple profile");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP) || } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP) ||
!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AP)) { !strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_AP)) {
#if 0
caps = gst_caps_new_full (gst_structure_new ("video/x-divx", caps = gst_caps_new_full (gst_structure_new ("video/x-divx",
"divxversion", G_TYPE_INT, 5, NULL), "divxversion", G_TYPE_INT, 5, NULL),
gst_structure_new ("video/x-xvid", NULL), gst_structure_new ("video/x-xvid", NULL),
gst_structure_new ("video/mpeg", gst_structure_new ("video/mpeg",
"mpegversion", G_TYPE_INT, 4, "mpegversion", G_TYPE_INT, 4,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL), NULL); "systemstream", G_TYPE_BOOLEAN, FALSE, NULL), NULL);
#endif
caps = gst_caps_new_simple ("video/mpeg",
"mpegversion", G_TYPE_INT, 4,
"systemstream", G_TYPE_BOOLEAN, FALSE, NULL);
if (codec_name) { if (codec_name) {
if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP)) if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG4_ASP))
*codec_name = g_strdup ("MPEG-4 advanced simple profile"); *codec_name = g_strdup ("MPEG-4 advanced simple profile");
@ -2980,10 +2960,14 @@ gst_matroska_demux_video_caps (GstMatroskaTrackVideoContext *
*codec_name = g_strdup ("MPEG-4 advanced profile"); *codec_name = g_strdup ("MPEG-4 advanced profile");
} }
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3)) { } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MSMPEG4V3)) {
#if 0
caps = gst_caps_new_full (gst_structure_new ("video/x-divx", caps = gst_caps_new_full (gst_structure_new ("video/x-divx",
"divxversion", G_TYPE_INT, 3, NULL), "divxversion", G_TYPE_INT, 3, NULL),
gst_structure_new ("video/x-msmpeg", gst_structure_new ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 43, NULL), NULL); "msmpegversion", G_TYPE_INT, 43, NULL), NULL);
#endif
caps = gst_caps_new_simple ("video/x-msmpeg",
"msmpegversion", G_TYPE_INT, 43, NULL);
if (codec_name) if (codec_name)
*codec_name = g_strdup ("Microsoft MPEG-4 v.3"); *codec_name = g_strdup ("Microsoft MPEG-4 v.3");
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG1) || } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_VIDEO_MPEG1) ||
@ -3190,8 +3174,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
audiocontext->bitdepth); audiocontext->bitdepth);
} else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT)) { } else if (!strcmp (codec_id, GST_MATROSKA_CODEC_ID_AUDIO_PCM_FLOAT)) {
caps = gst_caps_new_simple ("audio/x-raw-float", caps = gst_caps_new_simple ("audio/x-raw-float",
"endianness", G_TYPE_INT, G_BYTE_ORDER, "endianness", G_TYPE_INT, G_BYTE_ORDER, NULL);
"buffer-frames", GST_TYPE_INT_RANGE, 1, G_MAXINT, NULL);
if (audiocontext != NULL) { if (audiocontext != NULL) {
gst_caps_set_simple (caps, gst_caps_set_simple (caps,
"width", G_TYPE_INT, audiocontext->bitdepth, NULL); "width", G_TYPE_INT, audiocontext->bitdepth, NULL);
@ -3286,6 +3269,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
caps = gst_caps_new_simple ("audio/x-tta", caps = gst_caps_new_simple ("audio/x-tta",
"width", G_TYPE_INT, audiocontext->bitdepth, NULL); "width", G_TYPE_INT, audiocontext->bitdepth, NULL);
} else { } else {
/* FIXME: we can't have non-fixed caps, what to do here? */
caps = gst_caps_from_string ("audio/x-tta, " caps = gst_caps_from_string ("audio/x-tta, "
"width = (int) { 8, 16, 24 }"); "width = (int) { 8, 16, 24 }");
} }
@ -3297,6 +3281,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
"width", G_TYPE_INT, audiocontext->bitdepth, "width", G_TYPE_INT, audiocontext->bitdepth,
"framed", G_TYPE_BOOLEAN, TRUE, NULL); "framed", G_TYPE_BOOLEAN, TRUE, NULL);
} else { } else {
/* FIXME: we can't have non-fixed caps, what to do here? */
caps = gst_caps_from_string ("audio/x-wavpack, " caps = gst_caps_from_string ("audio/x-wavpack, "
"width = (int) { 8, 16, 24 }, " "framed = (boolean) true"); "width = (int) { 8, 16, 24 }, " "framed = (boolean) true");
} }
@ -3320,6 +3305,7 @@ gst_matroska_demux_audio_caps (GstMatroskaTrackAudioContext *
"rate", G_TYPE_INT, audiocontext->samplerate, NULL); "rate", G_TYPE_INT, audiocontext->samplerate, NULL);
} }
} else { } else {
/* FIXME: we can't have non-fixed caps, what to do here? */
gst_structure_set (structure, gst_structure_set (structure,
"channels", GST_TYPE_INT_RANGE, 1, 6, "channels", GST_TYPE_INT_RANGE, 1, 6,
"rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL); "rate", GST_TYPE_INT_RANGE, 4000, 96000, NULL);