summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Otte <otte@gnome.org>2003-12-17 05:22:33 +0000
committerBenjamin Otte <otte@gnome.org>2003-12-17 05:22:33 +0000
commit05bbc25623d656580928e45415611aaa59882864 (patch)
tree452484fcfb9e85fa02d958139ffeeae962fbc31e
parentd0b4ac409e900f02ad7ebcfb98a5183680140ca0 (diff)
downloadgst-libav-05bbc25623d656580928e45415611aaa59882864.tar.gz
port to new caps branch. Includes complete rework of colorspace caps nego. (untested unfortunately)
Original commit message from CVS: port to new caps branch. Includes complete rework of colorspace caps nego. (untested unfortunately)
m---------common0
-rw-r--r--ext/ffmpeg/gstffmpegcodecmap.c1136
-rw-r--r--ext/ffmpeg/gstffmpegcodecmap.h10
-rw-r--r--ext/ffmpeg/gstffmpegcolorspace.c444
-rw-r--r--ext/ffmpeg/gstffmpegdec.c18
-rw-r--r--ext/ffmpeg/gstffmpegdemux.c42
-rw-r--r--ext/ffmpeg/gstffmpegenc.c66
-rw-r--r--ext/ffmpeg/gstffmpegmux.c35
8 files changed, 716 insertions, 1035 deletions
diff --git a/common b/common
-Subproject 2c2bce01ed5ed1d1684bd76a334477398009ef4
+Subproject cd5507ae3df8dc48c07df9e37878846b6b79faa
diff --git a/ext/ffmpeg/gstffmpegcodecmap.c b/ext/ffmpeg/gstffmpegcodecmap.c
index e4ae451..912e583 100644
--- a/ext/ffmpeg/gstffmpegcodecmap.c
+++ b/ext/ffmpeg/gstffmpegcodecmap.c
@@ -36,39 +36,33 @@
* See below for why we use this.
*/
-#define GST_FF_VID_CAPS_NEW(name, mimetype, props...) \
- (context != NULL) ? \
- GST_CAPS_NEW (name, \
- mimetype, \
- "width", GST_PROPS_INT (context->width), \
- "height", GST_PROPS_INT (context->height),\
- "framerate", GST_PROPS_FLOAT ( \
- 1.*context->frame_rate/ \
- context->frame_rate_base) , \
- ##props) \
- : \
- GST_CAPS_NEW (name, \
- mimetype, \
- "width", GST_PROPS_INT_RANGE (16, 4096), \
- "height", GST_PROPS_INT_RANGE (16, 4096), \
- "framerate", GST_PROPS_FLOAT_RANGE (0, \
- G_MAXFLOAT) , \
- ##props)
+#define GST_FF_VID_CAPS_NEW(mimetype, props...) \
+ (context != NULL) ? \
+ gst_caps2_new_simple (mimetype, \
+ "width", G_TYPE_INT, context->width, \
+ "height", G_TYPE_INT, context->height, \
+ "framerate", G_TYPE_FLOAT, 1. * context->frame_rate / \
+ context->frame_rate_base, \
+ ##props, NULL) \
+ : \
+ gst_caps2_new_simple (mimetype, \
+ "width", GST_TYPE_INT_RANGE, 16, 4096, \
+ "height", GST_TYPE_INT_RANGE, 16, 4096, \
+ "framerate", GST_TYPE_DOUBLE_RANGE, 0, G_MAXFLOAT, \
+ ##props, NULL)
/* same for audio - now with channels/sample rate
*/
-#define GST_FF_AUD_CAPS_NEW(name, mimetype, props...) \
- (context != NULL) ? \
- GST_CAPS_NEW (name, \
- mimetype, \
- "rate", GST_PROPS_INT (context->sample_rate), \
- "channels", GST_PROPS_INT (context->channels) , \
- ##props) \
- : \
- GST_CAPS_NEW (name, \
- mimetype, \
- ##props)
+#define GST_FF_AUD_CAPS_NEW(mimetype, props...) \
+ (context != NULL) ? \
+ gst_caps2_new_simple (mimetype, \
+ "rate", G_TYPE_INT, context->sample_rate, \
+ "channels", G_TYPE_INT, context->channels, \
+ ##props, NULL) \
+ : \
+ gst_caps2_new_simple (mimetype, \
+ ##props, NULL)
/* Convert a FFMPEG codec ID and optional AVCodecContext
* to a GstCaps. If the context is ommitted, no fixed values
@@ -77,97 +71,75 @@
* CodecID is primarily meant for compressed data GstCaps!
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
AVCodecContext *context)
{
- GstCaps *caps = NULL;
+ GstCaps2 *caps = NULL;
switch (codec_id) {
case CODEC_ID_MPEG1VIDEO:
/* this caps doesn't need width/height/framerate */
- caps = GST_CAPS_NEW ("ffmpeg_mpeg1video",
- "video/mpeg",
- "mpegversion", GST_PROPS_INT (1),
- "systemstream", GST_PROPS_BOOLEAN (FALSE)
- );
+ caps = gst_caps2_new_simple ("video/mpeg",
+ "mpegversion", G_TYPE_INT, 1,
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ NULL);
break;
-
+
case CODEC_ID_H263P:
case CODEC_ID_H263I:
case CODEC_ID_H263:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_h263",
- "video/x-h263"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-h263");
break;
case CODEC_ID_RV10:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rv10",
- "video/x-pn-realvideo",
- "systemstream", GST_PROPS_BOOLEAN (FALSE)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-pn-realvideo",
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ NULL);
break;
case CODEC_ID_MP2:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mp2",
- "audio/mpeg",
- "layer", GST_PROPS_INT (2)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
+ "layer", G_TYPE_INT, 2,
+ NULL);
break;
case CODEC_ID_MP3LAME:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mp3",
- "audio/mpeg",
- "layer", GST_PROPS_INT (3)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
+ "layer", G_TYPE_INT, 3,
+ NULL);
break;
- case CODEC_ID_VORBIS: /* FIXME? vorbis or ogg? */
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_vorbis",
- "application/ogg",
- NULL
- );
+ /* FIXME: This could become problematic when we fully switched to seperation
+ of ogg and vorbis, because ffmpeg does ass ume ogg == ogg/vorbis
+ Maybe we want to disable this? */
+ case CODEC_ID_VORBIS:
+ caps = GST_FF_AUD_CAPS_NEW ("application/ogg");
break;
case CODEC_ID_AC3:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_ac3",
- "audio/x-ac3",
- NULL
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-ac3");
break;
case CODEC_ID_MJPEG:
case CODEC_ID_MJPEGB:
/*case CODEC_ID_LJPEG:*/
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_mjpeg",
- "video/x-jpeg"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-jpeg");
break;
case CODEC_ID_MPEG4:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_mpeg4",
- "video/mpeg",
- "mpegversion", GST_PROPS_INT (4),
- "systemstream", GST_PROPS_BOOLEAN (FALSE)
- );
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_divx",
- "video/x-divx",
- "divxversion", GST_PROPS_INT (5)
- ));
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_divx",
- "video/x-divx",
- "divxversion", GST_PROPS_INT (4)
- ));
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_xvid",
- "video/x-xvid"
- ));
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_3ivx",
- "video/x-3ivx"
- ));
+ caps = GST_FF_VID_CAPS_NEW ("video/mpeg",
+ "mpegversion", G_TYPE_INT, 4,
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ NULL);
+ gst_caps2_append(caps,
+ GST_FF_VID_CAPS_NEW ("video/x-divx",
+ "divxversion", GST_TYPE_INT_RANGE, 4, 5,
+ NULL));
+ gst_caps2_append(caps,
+ GST_FF_VID_CAPS_NEW ("video/x-xvid"));
+ gst_caps2_append(caps,
+ GST_FF_VID_CAPS_NEW ("video/x-3ivx"));
break;
/* weird quasi-codecs for the demuxers only */
@@ -176,112 +148,93 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
return gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, context);
case CODEC_ID_MSMPEG4V1:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v1",
- "video/x-msmpeg",
- "msmpegversion", GST_PROPS_INT (41)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
+ "msmpegversion", G_TYPE_INT, 41,
+ NULL);
break;
case CODEC_ID_MSMPEG4V2:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v2",
- "video/x-msmpeg",
- "msmpegversion", GST_PROPS_INT (42)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
+ "msmpegversion", G_TYPE_INT, 42,
+ NULL);
break;
case CODEC_ID_MSMPEG4V3:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v3",
- "video/x-msmpeg",
- "msmpegversion", GST_PROPS_INT (43)
- );
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_msmpeg4v3_divx3",
- "video/x-divx",
- "divxversion", GST_PROPS_INT (3)
- ));
+ caps = GST_FF_VID_CAPS_NEW ("video/x-msmpeg",
+ "msmpegversion", G_TYPE_INT, 43,
+ NULL);
+ gst_caps2_append(caps,
+ GST_FF_VID_CAPS_NEW ("video/x-divx",
+ "divxversion", G_TYPE_INT, 3,
+ NULL));
break;
case CODEC_ID_WMV1:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_wmv1",
- "video/x-wmv",
- "wmvversion", GST_PROPS_INT (1)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-wmv",
+ "wmvversion", G_TYPE_INT, 1,
+ NULL);
break;
case CODEC_ID_WMV2:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_wmv2",
- "video/x-wmv",
- "wmvversion", GST_PROPS_INT (2)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-wmv",
+ "wmvversion", G_TYPE_INT, 2,
+ NULL);
break;
case CODEC_ID_SVQ1:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_svq1",
- "video/x-svq",
- "svqversion", GST_PROPS_INT (1)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
+ "svqversion", G_TYPE_INT, 1,
+ NULL);
break;
case CODEC_ID_SVQ3:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_svq3",
- "video/x-svq",
- "svqversion", GST_PROPS_INT (3)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-svq",
+ "svqversion", G_TYPE_INT, 1,
+ NULL);
break;
case CODEC_ID_DVAUDIO:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_dvaudio",
- "audio/x-dv",
- NULL
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-dv");
break;
case CODEC_ID_DVVIDEO:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_dvvideo",
- "video/dv"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/dv");
break;
case CODEC_ID_WMAV1:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_wma1",
- "audio/x-wma",
- "wmaversion", GST_PROPS_INT (1),
- "flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
- "flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
- "block_align", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-wma",
+ "wmaversion", G_TYPE_INT, 1,
+ "flags1", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
+ "flags2", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
+ "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ NULL);
break;
case CODEC_ID_WMAV2:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_wma2",
- "audio/x-wma",
- "wmaversion", GST_PROPS_INT (2),
- "flags1", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
- "flags2", GST_PROPS_INT_RANGE (G_MININT, G_MAXINT),
- "block_align", GST_PROPS_INT_RANGE (0, G_MAXINT),
- "bitrate", GST_PROPS_INT_RANGE (0, G_MAXINT)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-wma",
+ "wmaversion", G_TYPE_INT, 2,
+ "flags1", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
+ "flags2", GST_TYPE_INT_RANGE, G_MININT, G_MAXINT,
+ "block_align", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ "bitrate", GST_TYPE_INT_RANGE, 0, G_MAXINT,
+ NULL);
break;
case CODEC_ID_MACE3:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mace3",
- "audio/x-mace",
- "maceversion", GST_PROPS_INT (3)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-mace",
+ "maceversion", G_TYPE_INT, 3,
+ NULL);
break;
case CODEC_ID_MACE6:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mace6",
- "audio/x-mace",
- "maceversion", GST_PROPS_INT (6)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-mace",
+ "maceversion", G_TYPE_INT, 6,
+ NULL);
break;
case CODEC_ID_HUFFYUV:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_huffyuv",
- "video/x-huffyuv"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-huffyuv");
break;
case CODEC_ID_CYUV:
@@ -289,42 +242,33 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_H264:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_h264",
- "video/x-h264"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-h264");
break;
case CODEC_ID_INDEO3:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_indeo3",
- "video/x-indeo",
- "indeoversion", GST_PROPS_INT (3)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-indeo",
+ "indeoversion", G_TYPE_INT, 3,
+ NULL);
break;
case CODEC_ID_VP3:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_vp3",
- "video/x-vp3"
- );
- caps = gst_caps_append(caps,
- GST_FF_VID_CAPS_NEW ("ffmpeg_theora",
- "video/x-theora"
- ));
+ caps = GST_FF_VID_CAPS_NEW ("video/x-vp3");
+ gst_caps2_append(caps,
+ GST_FF_VID_CAPS_NEW ("video/x-theora"));
break;
case CODEC_ID_AAC:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mpeg2aac",
- "audio/mpeg",
- "systemstream", GST_PROPS_BOOLEAN (FALSE),
- "mpegversion", GST_PROPS_INT (2)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ "mpegversion", G_TYPE_INT, 2,
+ NULL);
break;
case CODEC_ID_MPEG4AAC:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mpeg4aac",
- "audio/mpeg",
- "systemstream", GST_PROPS_BOOLEAN (FALSE),
- "mpegversion", GST_PROPS_INT (4)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/mpeg",
+ "systemstream", G_TYPE_BOOLEAN, FALSE,
+ "mpegversion", G_TYPE_INT, 4,
+ NULL);
break;
case CODEC_ID_ASV1:
@@ -332,16 +276,13 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_FFV1:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_ffv1",
- "video/x-ffv",
- "ffvversion", GST_PROPS_INT (1)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-ffv",
+ "ffvversion", G_TYPE_INT, 1,
+ NULL);
break;
case CODEC_ID_4XM:
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_4xmvideo",
- "video/x-4xm"
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-4xm");
break;
/* weird quasi-codecs for the demuxers only */
@@ -391,55 +332,45 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
}
- caps = GST_FF_AUD_CAPS_NEW (
- "ffmpeg_pcmaudio",
- "audio/x-raw-int",
- "width", GST_PROPS_INT (width),
- "depth", GST_PROPS_INT (depth),
- "endianness", GST_PROPS_INT (endianness),
- "signed", GST_PROPS_BOOLEAN (signedness)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
+ "width", G_TYPE_INT, width,
+ "depth", G_TYPE_INT, depth,
+ "endianness", G_TYPE_INT, endianness,
+ "signed", G_TYPE_BOOLEAN, signedness,
+ NULL);
} while (0);
break;
case CODEC_ID_PCM_MULAW:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_mulawaudio",
- "audio/x-mulaw",
- NULL);
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-mulaw");
break;
case CODEC_ID_PCM_ALAW:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_alawaudio",
- "audio/x-alaw",
- NULL);
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-alaw");
break;
case CODEC_ID_ADPCM_IMA_QT:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ima_qt",
- "audio/x-adpcm",
- "layout", GST_PROPS_STRING ("quicktime")
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "quicktime",
+ NULL);
break;
case CODEC_ID_ADPCM_IMA_WAV:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ima_wav",
- "audio/x-adpcm",
- "layout", GST_PROPS_STRING ("wav")
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "wav",
+ NULL);
break;
case CODEC_ID_ADPCM_MS:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_ms",
- "audio/x-adpcm",
- "layout", GST_PROPS_STRING ("microsoft")
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "microsoft",
+ NULL);
break;
case CODEC_ID_ADPCM_4XM:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_adpcm_4xm",
- "audio/x-adpcm",
- "layout", GST_PROPS_STRING ("4xm")
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-adpcm",
+ "layout", G_TYPE_STRING, "4xm",
+ NULL);
break;
case CODEC_ID_AMR_NB:
@@ -447,17 +378,15 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
break;
case CODEC_ID_RA_144:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_realaudio_144",
- "audio/x-pn-realaudio",
- "bitrate", GST_PROPS_INT (14400)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-pn-realaudio",
+ "bitrate", G_TYPE_INT, 14400,
+ NULL);
break;
case CODEC_ID_RA_288:
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_realaudio_288",
- "audio/x-pn-realaudio",
- "bitrate", GST_PROPS_INT (28800)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-pn-realaudio",
+ "bitrate", G_TYPE_INT, 28800,
+ NULL);
break;
default:
@@ -466,15 +395,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
}
if (caps != NULL) {
- char *str = g_strdup_printf("The caps that belongs to codec_id=%d",
- codec_id);
- gst_caps_debug(caps, str);
+ char *str = gst_caps2_to_string (caps);
+ GST_DEBUG ("caps for codec_id=%d: %s", codec_id, str);
g_free(str);
} else {
- char *str = g_strdup_printf("No caps found for codec_id=%d",
- codec_id);
- gst_caps_debug(caps, str);
- g_free(str);
+ GST_WARNING ("No caps found for codec_id=%d", codec_id);
}
return caps;
@@ -487,11 +412,11 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
* See below for usefullness
*/
-static GstCaps *
+static GstCaps2 *
gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
AVCodecContext *context)
{
- GstCaps *caps = NULL;
+ GstCaps2 *caps = NULL;
int bpp = 0, depth = 0, endianness = 0;
gulong g_mask = 0, r_mask = 0, b_mask = 0;
@@ -551,32 +476,26 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
}
if (bpp != 0) {
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rawvideo",
- "video/x-raw-rgb",
- "bpp", GST_PROPS_INT (bpp),
- "depth", GST_PROPS_INT (depth),
- "red_mask", GST_PROPS_INT (r_mask),
- "green_mask", GST_PROPS_INT (g_mask),
- "blue_mask", GST_PROPS_INT (b_mask),
- "endianness", GST_PROPS_INT (endianness)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-raw-rgb",
+ "bpp", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, depth,
+ "red_mask", G_TYPE_INT, r_mask,
+ "green_mask", G_TYPE_INT, g_mask,
+ "blue_mask", G_TYPE_INT, b_mask,
+ "endianness", G_TYPE_INT, endianness,
+ NULL);
} else if (fmt) {
- caps = GST_FF_VID_CAPS_NEW ("ffmpeg_rawvideo",
- "video/x-raw-yuv",
- "format", GST_PROPS_FOURCC (fmt)
- );
+ caps = GST_FF_VID_CAPS_NEW ("video/x-raw-yuv",
+ "format", GST_TYPE_FOURCC, fmt,
+ NULL);
}
if (caps != NULL) {
- char *str = g_strdup_printf("The caps that belongs to pix_fmt=%d",
- pix_fmt);
- gst_caps_debug(caps, str);
+ char *str = gst_caps2_to_string (caps);
+ GST_DEBUG ("caps for pix_fmt=%d: %s", pix_fmt, str);
g_free(str);
} else {
- char *str = g_strdup_printf("No caps found for pix_fmt=%d",
- pix_fmt);
- gst_caps_debug(caps, str);
- g_free(str);
+ GST_WARNING ("No caps found for pix_fmt=%d", pix_fmt);
}
return caps;
@@ -589,11 +508,11 @@ gst_ffmpeg_pixfmt_to_caps (enum PixelFormat pix_fmt,
* See below for usefullness
*/
-static GstCaps *
+static GstCaps2 *
gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
AVCodecContext *context)
{
- GstCaps *caps = NULL;
+ GstCaps2 *caps = NULL;
int bpp = 0;
gboolean signedness = FALSE;
@@ -610,25 +529,20 @@ gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
}
if (bpp) {
- caps = GST_FF_AUD_CAPS_NEW ("ffmpeg_rawaudio",
- "audio/x-raw-int",
- "signed", GST_PROPS_BOOLEAN (signedness),
- "endianness", GST_PROPS_INT (G_BYTE_ORDER),
- "width", GST_PROPS_INT (bpp),
- "depth", GST_PROPS_INT (bpp)
- );
+ caps = GST_FF_AUD_CAPS_NEW ("audio/x-raw-int",
+ "signed", G_TYPE_BOOLEAN, signedness,
+ "endianness", G_TYPE_INT, G_BYTE_ORDER,
+ "width", G_TYPE_INT, bpp,
+ "depth", G_TYPE_INT, bpp,
+ NULL);
}
if (caps != NULL) {
- char *str = g_strdup_printf("The caps that belongs to sample_fmt=%d",
- sample_fmt);
- gst_caps_debug(caps, str);
+ char *str = gst_caps2_to_string (caps);
+ GST_DEBUG ("caps for sample_fmt=%d: %s", sample_fmt, str);
g_free(str);
} else {
- char *str = g_strdup_printf("No caps found for sample_fmt=%d",
- sample_fmt);
- gst_caps_debug(caps, str);
- g_free(str);
+ GST_WARNING ("No caps found for sample_fmt=%d", sample_fmt);
}
return caps;
@@ -641,24 +555,24 @@ gst_ffmpeg_smpfmt_to_caps (enum SampleFormat sample_fmt,
* CodecType is primarily meant for uncompressed data GstCaps!
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
AVCodecContext *context)
{
- GstCaps *caps = NULL;
+ GstCaps2 *caps = NULL;
switch (codec_type) {
case CODEC_TYPE_VIDEO:
if (context) {
caps = gst_ffmpeg_pixfmt_to_caps (context->pix_fmt, context);
} else {
- GstCaps *temp;
+ GstCaps2 *temp;
enum PixelFormat i;
for (i = 0; i < PIX_FMT_NB; i++) {
temp = gst_ffmpeg_pixfmt_to_caps (i, NULL);
if (temp != NULL) {
- caps = gst_caps_append (caps, temp);
+ gst_caps2_append (caps, temp);
}
}
}
@@ -668,13 +582,13 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
if (context) {
caps = gst_ffmpeg_smpfmt_to_caps (context->sample_fmt, context);
} else {
- GstCaps *temp;
+ GstCaps2 *temp;
enum SampleFormat i;
for (i = 0; i <= SAMPLE_FMT_S16; i++) {
temp = gst_ffmpeg_smpfmt_to_caps (i, NULL);
if (temp != NULL) {
- caps = gst_caps_append (caps, temp);
+ gst_caps2_append (caps, temp);
}
}
}
@@ -693,59 +607,54 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
* when needed.
*/
static void
-gst_ffmpeg_caps_to_extradata (GstCaps *caps,
+gst_ffmpeg_caps_to_extradata (const GstCaps2 *caps,
AVCodecContext *context)
{
+ GstStructure *structure;
const gchar *mimetype;
- mimetype = gst_caps_get_mime(caps);
+ g_return_if_fail (gst_caps2_get_n_structures (caps) == 1);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+
+ mimetype = gst_structure_get_name (structure);
if (!strcmp(mimetype, "audio/x-wma")) {
+ gint flags1, flags2, wmaversion = 0;
- if (!gst_caps_has_property (caps, "flags1")) {
- g_warning ("Caps without flags1 property for %s", mimetype);
- return;
- }
-
- if (!gst_caps_has_property (caps, "flags2")) {
- g_warning ("Caps without flags2 property for %s", mimetype);
+ if (!gst_structure_get_int (structure, "flags1", &flags1) &&
+ !gst_structure_get_int (structure, "flags2", &flags2) &&
+ !gst_structure_get_int (structure, "wmaversion", &wmaversion)) {
+ g_warning ("invalid caps for audio/x-wma");
return;
}
- if (gst_caps_has_property (caps, "wmaversion")) {
- gint wmaversion = 0;
- gint value;
-
- /*
- * Rebuild context data from flags1 & flags2
- * see wmadec in ffmpeg/libavcodec/wmadec.c
- */
- gst_caps_get_int (caps, "wmaversion", &wmaversion);
- switch (wmaversion) {
- case 1:
- context->extradata = (guint8 *) g_malloc0 (4);
- gst_caps_get_int (caps, "flags1", &value);
- ((guint8 *)context->extradata)[0] = value;
- gst_caps_get_int (caps, "flags2", &value);
- ((guint8 *)context->extradata)[2] = value;
- context->extradata_size = 4;
- break;
- case 2:
- context->extradata = (guint8 *) g_malloc0 (6);
- gst_caps_get_int (caps, "flags1", &value);
- ((guint8 *) context->extradata)[0] = value;
- ((guint8 *) context->extradata)[1] = value >> 8;
- ((guint8 *) context->extradata)[2] = value >> 16;
- ((guint8 *) context->extradata)[3] = value >> 24;
- gst_caps_get_int (caps, "flags2", &value);
- ((guint8 *) context->extradata)[4] = value;
- ((guint8 *) context->extradata)[5] = value >> 8;
- context->extradata_size = 6;
- break;
- default:
- g_warning ("Unknown wma version %d\n", wmaversion);
- break;
- }
+ /*
+ * Rebuild context data from flags1 & flags2
+ * see wmadec in ffmpeg/libavcodec/wmadec.c
+ */
+ gst_structure_get_int (structure, "wmaversion", &wmaversion);
+ switch (wmaversion) {
+ case 1:
+ /* FIXME: is this freed with g_free? If not, don't use g_malloc */
+ context->extradata = (guint8 *) g_malloc0 (4);
+ ((guint8 *)context->extradata)[0] = flags1;
+ ((guint8 *)context->extradata)[2] = flags2;
+ context->extradata_size = 4;
+ break;
+ case 2:
+ /* FIXME: is this freed with g_free? If not, don't use g_malloc */
+ context->extradata = (guint8 *) g_malloc0 (6);
+ ((guint8 *) context->extradata)[0] = flags1;
+ ((guint8 *) context->extradata)[1] = flags1 >> 8;
+ ((guint8 *) context->extradata)[2] = flags1 >> 16;
+ ((guint8 *) context->extradata)[3] = flags1 >> 24;
+ ((guint8 *) context->extradata)[4] = flags2;
+ ((guint8 *) context->extradata)[5] = flags2 >> 8;
+ context->extradata_size = 6;
+ break;
+ default:
+ g_warning ("Unknown wma version %d\n", wmaversion);
+ break;
}
}
}
@@ -758,50 +667,30 @@ gst_ffmpeg_caps_to_extradata (GstCaps *caps,
*/
static void
-gst_ffmpeg_caps_to_smpfmt (GstCaps *caps,
+gst_ffmpeg_caps_to_smpfmt (const GstCaps2 *caps,
AVCodecContext *context)
{
- if (gst_caps_has_property_typed (caps, "width",
- GST_PROPS_INT_TYPE) &&
- gst_caps_has_property_typed (caps, "depth",
- GST_PROPS_INT_TYPE) &&
- gst_caps_has_property_typed (caps, "signed",
- GST_PROPS_BOOLEAN_TYPE) &&
- gst_caps_has_property_typed (caps, "endianness",
- GST_PROPS_INT_TYPE)) {
- gint depth = 0, width = 0, endianness = 0;
- gboolean signedness = FALSE;
- gst_caps_get (caps,
- "width", &width,
- "depth", &depth,
- "endianness", &endianness,
- "signed", &signedness,
- NULL);
+ GstStructure *structure;
+ gint depth = 0, width = 0, endianness = 0;
+ gboolean signedness = FALSE;
+
+ g_return_if_fail (gst_caps2_get_n_structures (caps) == 1);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+
+ if (gst_structure_get_int (structure, "width", &width) &&
+ gst_structure_get_int (structure, "depth", &depth) &&
+ gst_structure_get_int (structure, "signed", &signedness) &&
+ gst_structure_get_int (structure, "endianness", &endianness)) {
if (width == 16 && depth == 16 &&
endianness == G_BYTE_ORDER && signedness == TRUE) {
context->sample_fmt = SAMPLE_FMT_S16;
}
}
- if (gst_caps_has_property_typed (caps, "channels",
- GST_PROPS_INT_TYPE)) {
- gst_caps_get_int (caps, "channels", &context->channels);
- }
-
- if (gst_caps_has_property_typed (caps, "rate",
- GST_PROPS_INT_TYPE)) {
- gst_caps_get_int (caps, "rate", &context->sample_rate);
- }
-
- if (gst_caps_has_property_typed (caps, "block_align",
- GST_PROPS_INT_TYPE)) {
- gst_caps_get_int (caps, "block_align", &context->block_align);
- }
-
- if (gst_caps_has_property_typed (caps, "bitrate",
- GST_PROPS_INT_TYPE)) {
- gst_caps_get_int (caps, "bitrate", &context->bit_rate);
- }
+ gst_structure_get_int (structure, "channels", &context->channels);
+ gst_structure_get_int (structure, "rate", &context->sample_rate);
+ gst_structure_get_int (structure, "block_align", &context->block_align);
+ gst_structure_get_int (structure, "bitrate", &context->bit_rate);
gst_ffmpeg_caps_to_extradata (caps, context);
}
@@ -814,33 +703,27 @@ gst_ffmpeg_caps_to_smpfmt (GstCaps *caps,
*/
static void
-gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
+gst_ffmpeg_caps_to_pixfmt (const GstCaps2 *caps,
AVCodecContext *context)
{
- if (gst_caps_has_property_typed (caps, "width",
- GST_PROPS_INT_TYPE) &&
- gst_caps_has_property_typed (caps, "height",
- GST_PROPS_INT_TYPE)) {
- gst_caps_get (caps,
- "width", &context->width,
- "height", &context->height,
- NULL);
- }
+ GstStructure *structure;
+ gdouble fps;
+
+ g_return_if_fail (gst_caps2_get_n_structures (caps) == 1);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+
+ gst_structure_get_int (structure, "width", &context->width);
+ gst_structure_get_int (structure, "height", &context->height);
- if (gst_caps_has_property_typed (caps, "framerate",
- GST_PROPS_FLOAT_TYPE)) {
- gfloat fps;
- gst_caps_get_float (caps, "framerate", &fps);
+ if (gst_structure_get_double (structure, "framerate", &fps)) {
context->frame_rate = fps * DEFAULT_FRAME_RATE_BASE;
context->frame_rate_base = DEFAULT_FRAME_RATE_BASE;
}
- if (strcmp (gst_caps_get_mime (caps), "video/x-raw-yuv") == 0) {
- if (gst_caps_has_property_typed (caps, "format",
- GST_PROPS_FOURCC_TYPE)) {
- guint32 fourcc;
- gst_caps_get_fourcc_int (caps, "format", &fourcc);
-
+ if (strcmp (gst_structure_get_name (structure), "video/x-raw-yuv") == 0) {
+ guint32 fourcc;
+
+ if (gst_structure_get_fourcc (structure, "format", &fourcc)) {
switch (fourcc) {
case GST_MAKE_FOURCC ('Y','U','Y','2'):
context->pix_fmt = PIX_FMT_YUV422;
@@ -864,15 +747,12 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
#endif
}
}
- } else if (strcmp (gst_caps_get_mime (caps), "video/x-raw-rgb") == 0) {
- if (gst_caps_has_property_typed (caps, "bpp", GST_PROPS_INT_TYPE) &&
- gst_caps_has_property_typed (caps, "red_mask", GST_PROPS_INT_TYPE)) {
- gint bpp = 0, rmask = 0, endianness = 0;
-
- gst_caps_get (caps, "bpp", &bpp,
- "red_mask", &rmask,
- "endianness", &endianness, NULL);
-
+ } else if (strcmp (gst_structure_get_name (structure), "video/x-raw-rgb") == 0) {
+ gint bpp = 0, rmask = 0, endianness = 0;
+
+ if (gst_structure_get_int (structure, "bpp", &bpp) &&
+ gst_structure_get_int (structure, "endianness", &endianness) &&
+ gst_structure_get_int (structure, "red_mask", &rmask)) {
switch (bpp) {
case 32:
#if (G_BYTE_ORDER == G_BIG_ENDIAN)
@@ -913,7 +793,7 @@ gst_ffmpeg_caps_to_pixfmt (GstCaps *caps,
void
gst_ffmpeg_caps_to_codectype (enum CodecType type,
- GstCaps *caps,
+ const GstCaps2 *caps,
AVCodecContext *context)
{
if (context == NULL)
@@ -944,66 +824,48 @@ gst_ffmpeg_caps_to_codectype (enum CodecType type,
* media type anyway
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_formatid_to_caps (const gchar *format_name)
{
- GstCaps *caps = NULL;
+ GstCaps2 *caps = NULL;
if (!strcmp (format_name, "mpeg")) {
- caps = GST_CAPS_NEW ("ffmpeg_mpeg",
- "video/mpeg",
- "systemstream", GST_PROPS_BOOLEAN (TRUE)
- );
+ caps = gst_caps2_new_simple ("video/mpeg",
+ "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
} else if (!strcmp (format_name, "mpegts")) {
- caps = GST_CAPS_NEW ("ffmpeg_mpegts",
- "video/mpegts",
- "systemstream", GST_PROPS_BOOLEAN (TRUE)
- );
+ caps = gst_caps2_new_simple ("video/mpegts",
+ "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
} else if (!strcmp (format_name, "rm")) {
- caps = GST_CAPS_NEW ("ffmpeg_rm",
- "audio/x-pn-realvideo",
- "systemstream", GST_PROPS_BOOLEAN (TRUE)
- );
+ caps = gst_caps2_new_simple ("ffmpeg_rm", "audio/x-pn-realvideo",
+ "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
} else if (!strcmp (format_name, "asf")) {
- caps = GST_CAPS_NEW ("ffmpeg_asf",
- "video/x-ms-asf",
- NULL
- );
+ caps = gst_caps2_new_simple ("video/x-ms-asf",
+ NULL);
} else if (!strcmp (format_name, "avi")) {
- caps = GST_CAPS_NEW ("ffmpeg_avi",
- "video/x-msvideo",
- NULL
- );
+ caps = gst_caps2_new_simple ("video/x-msvideo",
+ NULL);
} else if (!strcmp (format_name, "wav")) {
- caps = GST_CAPS_NEW ("ffmpeg_wav",
- "video/x-wav",
- NULL
- );
+ caps = gst_caps2_new_simple ("video/x-wav",
+ NULL);
} else if (!strcmp (format_name, "swf")) {
- caps = GST_CAPS_NEW ("ffmpeg_swf",
- "application/x-shockwave-flash",
- NULL
- );
+ caps = gst_caps2_new_simple ("application/x-shockwave-flash",
+ NULL);
} else if (!strcmp (format_name, "au")) {
- caps = GST_CAPS_NEW ("ffmpeg_au",
- "audio/x-au",
- NULL
- );
+ caps = gst_caps2_new_simple ("audio/x-au",
+ NULL);
} else if (!strcmp (format_name, "mov")) {
- caps = GST_CAPS_NEW ("ffmpeg_quicktime",
- "video/quicktime",
- NULL
- );
+ caps = gst_caps2_new_simple ("video/quicktime",
+ NULL);
} else if (!strcmp (format_name, "dv")) {
- caps = GST_CAPS_NEW ("ffmpeg_dv",
- "video/x-dv",
- "systemstream", GST_PROPS_BOOLEAN (TRUE)
- );
+ caps = gst_caps2_new_simple ("video/x-dv",
+ "systemstream", G_TYPE_BOOLEAN, TRUE,
+ NULL);
} else if (!strcmp (format_name, "4xm")) {
- caps = GST_CAPS_NEW ("ffmpeg_4xm",
- "video/x-4xm",
- NULL
- );
+ caps = gst_caps2_new_simple ("video/x-4xm",
+ NULL);
} else {
/* unknown! */
}
@@ -1019,16 +881,19 @@ gst_ffmpeg_formatid_to_caps (const gchar *format_name)
*/
enum CodecID
-gst_ffmpeg_caps_to_codecid (GstCaps *caps,
+gst_ffmpeg_caps_to_codecid (const GstCaps2 *caps,
AVCodecContext *context)
{
enum CodecID id = CODEC_ID_NONE;
const gchar *mimetype;
+ const GstStructure *structure;
gboolean video = FALSE, audio = FALSE; /* we want to be sure! */
g_return_val_if_fail (caps != NULL, CODEC_ID_NONE);
-
- mimetype = gst_caps_get_mime(caps);
+ g_return_val_if_fail (gst_caps2_get_n_structures (caps) == 1, CODEC_ID_NONE);
+ structure = gst_caps2_get_nth_cap (caps, 0);
+
+ mimetype = gst_structure_get_name (structure);
if (!strcmp (mimetype, "video/x-raw-rgb")) {
@@ -1038,9 +903,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gint bpp = 0, endianness = 0, rmask = 0;
enum PixelFormat pix_fmt = -1;
- gst_caps_get (caps, "bpp", &bpp,
- "endianness", &endianness,
- "rmask", &rmask, NULL);
+ gst_structure_get_int (structure, "bpp", &bpp);
+ gst_structure_get_int (structure, "endianness", &endianness);
+ gst_structure_get_int (structure, "rmask", &rmask);
switch (bpp) {
case 15:
@@ -1091,7 +956,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
guint32 fmt_fcc = 0;
enum PixelFormat pix_fmt = -1;
- gst_caps_get_fourcc_int (caps, "format", &fmt_fcc);
+ gst_structure_get_fourcc (structure, "format", &fmt_fcc);
switch (fmt_fcc) {
case GST_MAKE_FOURCC ('Y','U','Y','2'):
@@ -1128,51 +993,49 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gint depth = 0, width = 0, endianness = 0;
gboolean signedness = FALSE; /* bla default value */
- if (gst_caps_has_property(caps, "signed")) {
- gst_caps_get_int(caps, "endianness", &endianness);
- gst_caps_get_boolean(caps, "signed", &signedness);
- gst_caps_get_int(caps, "width", &width);
- gst_caps_get_int(caps, "depth", &depth);
+ gst_structure_get_int (structure, "endianness", &endianness);
+ gst_structure_get_boolean (structure, "signed", &signedness);
+ gst_structure_get_int (structure, "width", &width);
+ gst_structure_get_int (structure, "depth", &depth);
- if (context) {
- context->sample_rate = 0;
- context->channels = 0;
- gst_caps_get_int(caps, "channels", &context->channels);
- gst_caps_get_int(caps, "rate", &context->sample_rate);
- }
+ if (context) {
+ context->sample_rate = 0;
+ context->channels = 0;
+ gst_structure_get_int (structure, "channels", &context->channels);
+ gst_structure_get_int (structure, "rate", &context->sample_rate);
+ }
- if (depth == width) {
- switch (depth) {
- case 8:
- if (signedness) {
- id = CODEC_ID_PCM_S8;
- } else {
- id = CODEC_ID_PCM_U8;
- }
- break;
- case 16:
- switch (endianness) {
- case G_BIG_ENDIAN:
- if (signedness) {
- id = CODEC_ID_PCM_S16BE;
- } else {
- id = CODEC_ID_PCM_U16BE;
- }
- break;
- case G_LITTLE_ENDIAN:
- if (signedness) {
- id = CODEC_ID_PCM_S16LE;
- } else {
- id = CODEC_ID_PCM_U16LE;
- }
- break;
- }
- break;
- }
+ if (depth == width) {
+ switch (depth) {
+ case 8:
+ if (signedness) {
+ id = CODEC_ID_PCM_S8;
+ } else {
+ id = CODEC_ID_PCM_U8;
+ }
+ break;
+ case 16:
+ switch (endianness) {
+ case G_BIG_ENDIAN:
+ if (signedness) {
+ id = CODEC_ID_PCM_S16BE;
+ } else {
+ id = CODEC_ID_PCM_U16BE;
+ }
+ break;
+ case G_LITTLE_ENDIAN:
+ if (signedness) {
+ id = CODEC_ID_PCM_S16LE;
+ } else {
+ id = CODEC_ID_PCM_U16LE;
+ }
+ break;
+ }
+ break;
+ }
- if (id != CODEC_ID_NONE) {
- audio = TRUE;
- }
+ if (id != CODEC_ID_NONE) {
+ audio = TRUE;
}
}
@@ -1205,11 +1068,9 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
gboolean sys_strm = TRUE;
gint mpegversion = 0;
- if (gst_caps_has_property(caps, "systemstream")) {
- gst_caps_get_boolean(caps, "systemstream", &sys_strm);
- }
- if (!sys_strm && gst_caps_has_property(caps, "mpegversion")) {
- gst_caps_get_int(caps, "mpegversion", &mpegversion);
+ gst_structure_get_boolean (structure, "systemstream", &sys_strm);
+ gst_structure_get_int (structure, "mpegversion", &mpegversion);
+ if (!sys_strm) {
switch (mpegversion) {
case 1:
id = CODEC_ID_MPEG1VIDEO;
@@ -1233,26 +1094,24 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE;
} else if (!strcmp(mimetype, "video/x-wmv")) {
+ gint wmvversion = 0;
+
+ gst_structure_get_int (structure, "wmvversion", &wmvversion);
+
+ switch (wmvversion) {
+ case 1:
+ id = CODEC_ID_WMV1;
+ break;
+ case 2:
+ id = CODEC_ID_WMV2;
+ break;
+ default:
+ /* ... */
+ break;
+ }
- if (gst_caps_has_property (caps, "wmvversion")) {
- gint wmvversion = 0;
-
- gst_caps_get_int (caps, "wmvversion", &wmvversion);
- switch (wmvversion) {
- case 1:
- id = CODEC_ID_WMV1;
- break;
- case 2:
- id = CODEC_ID_WMV2;
- break;
- default:
- /* ... */
- break;
- }
-
- if (id != CODEC_ID_NONE) {
- video = TRUE;
- }
+ if (id != CODEC_ID_NONE) {
+ video = TRUE;
}
} else if (!strcmp(mimetype, "application/ogg")) {
@@ -1260,30 +1119,26 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
id = CODEC_ID_VORBIS;
} else if (!strcmp(mimetype, "audio/mpeg")) {
+ gint layer = 0;
+ gint mpegversion = 0;
- if (gst_caps_has_property (caps, "layer")) {
- gint layer = 0;
-
- gst_caps_get_int (caps, "layer", &layer);
- switch (layer) {
- case 1:
- case 2:
- id = CODEC_ID_MP2;
- break;
- case 3:
- id = CODEC_ID_MP3LAME;
- break;
- default:
- /* ... */
- break;
- }
- } else if (gst_caps_has_property (caps, "mpegversion")) {
- gint mpegversion = 0;
+ gst_structure_get_int (structure, "layer", &layer);
+ switch (layer) {
+ case 1:
+ case 2:
+ id = CODEC_ID_MP2;
+ break;
+ case 3:
+ id = CODEC_ID_MP3LAME;
+ break;
+ default:
+ /* ... */
+ break;
+ }
- gst_caps_get_int (caps, "mpegversion", &mpegversion);
- if (mpegversion == 4) {
- id = CODEC_ID_MPEG4AAC;
- }
+ gst_structure_get_int (structure, "mpegversion", &mpegversion);
+ if (mpegversion == 4) {
+ id = CODEC_ID_MPEG4AAC;
}
if (id != CODEC_ID_NONE) {
@@ -1291,22 +1146,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
}
} else if (!strcmp(mimetype, "audio/x-wma")) {
-
- if (gst_caps_has_property (caps, "wmaversion")) {
- gint wmaversion = 0;
-
- gst_caps_get_int (caps, "wmaversion", &wmaversion);
- switch (wmaversion) {
- case 1:
- id = CODEC_ID_WMAV1;
- break;
- case 2:
- id = CODEC_ID_WMAV2;
- break;
- default:
- /* ... */
- break;
- }
+ gint wmaversion = 0;
+
+ gst_structure_get_int (structure, "wmaversion", &wmaversion);
+
+ switch (wmaversion) {
+ case 1:
+ id = CODEC_ID_WMAV1;
+ break;
+ case 2:
+ id = CODEC_ID_WMAV2;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1318,25 +1171,23 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
id = CODEC_ID_AC3;
} else if (!strcmp(mimetype, "video/x-msmpeg")) {
-
- if (gst_caps_has_property (caps, "msmpegversion")) {
- gint msmpegversion = 0;
-
- gst_caps_get_int (caps, "msmpegversion", &msmpegversion);
- switch (msmpegversion) {
- case 41:
- id = CODEC_ID_MSMPEG4V1;
- break;
- case 42:
- id = CODEC_ID_MSMPEG4V2;
- break;
- case 43:
- id = CODEC_ID_MSMPEG4V3;
- break;
- default:
- /* ... */
- break;
- }
+ gint msmpegversion = 0;
+
+ gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
+
+ switch (msmpegversion) {
+ case 41:
+ id = CODEC_ID_MSMPEG4V1;
+ break;
+ case 42:
+ id = CODEC_ID_MSMPEG4V2;
+ break;
+ case 43:
+ id = CODEC_ID_MSMPEG4V3;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1344,22 +1195,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
}
} else if (!strcmp(mimetype, "video/x-svq")) {
-
- if (gst_caps_has_property (caps, "svqversion")) {
- gint svqversion = 0;
-
- gst_caps_get_int (caps, "svqversion", &svqversion);
- switch (svqversion) {
- case 1:
- id = CODEC_ID_SVQ1;
- break;
- case 3:
- id = CODEC_ID_SVQ3;
- break;
- default:
- /* ... */
- break;
- }
+ gint svqversion = 0;
+
+ gst_structure_get_int (structure, "svqversion", &svqversion);
+
+ switch (svqversion) {
+ case 1:
+ id = CODEC_ID_SVQ1;
+ break;
+ case 3:
+ id = CODEC_ID_SVQ3;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1372,22 +1221,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE;
} else if (!strcmp (mimetype, "audio/x-mace")) {
-
- if (gst_caps_has_property (caps, "maceversion")) {
- gint maceversion;
-
- gst_caps_get_int (caps, "maceversion", &maceversion);
- switch (maceversion) {
- case 3:
- id = CODEC_ID_MACE3;
- break;
- case 6:
- id = CODEC_ID_MACE6;
- break;
- default:
- /* ... */
- break;
- }
+ gint maceversion = 0;
+
+ gst_structure_get_int (structure, "maceversion", &maceversion);
+ switch (maceversion) {
+ case 3:
+ id = CODEC_ID_MACE3;
+ break;
+ case 6:
+ id = CODEC_ID_MACE6;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1401,19 +1247,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE;
} else if (!strcmp (mimetype, "video/x-indeo")) {
-
- if (gst_caps_has_property (caps, "indeoversion")) {
- gint indeoversion = 0;
-
- gst_caps_get_int (caps, "indeoversion", &indeoversion);
- switch (indeoversion) {
- case 3:
- id = CODEC_ID_INDEO3;
- break;
- default:
- /* ... */
- break;
- }
+ gint indeoversion = 0;
+
+ gst_structure_get_int (structure, "indeoversion", &indeoversion);
+ switch (indeoversion) {
+ case 3:
+ id = CODEC_ID_INDEO3;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1421,23 +1264,20 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
}
} else if (!strcmp (mimetype, "video/x-divx")) {
-
- if (gst_caps_has_property (caps, "divxversion")) {
- gint divxversion = 0;
-
- gst_caps_get_int (caps, "divxversion", &divxversion);
- switch (divxversion) {
- case 3:
- id = CODEC_ID_MSMPEG4V3;
- break;
- case 4:
- case 5:
- id = CODEC_ID_MPEG4;
- break;
- default:
- /* ... */
- break;
- }
+ gint divxversion = 0;
+
+ gst_structure_get_int (structure, "divxversion", &divxversion);
+ switch (divxversion) {
+ case 3:
+ id = CODEC_ID_MSMPEG4V3;
+ break;
+ case 4:
+ case 5:
+ id = CODEC_ID_MPEG4;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1451,19 +1291,16 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
video = TRUE;
} else if (!strcmp (mimetype, "video/x-ffv")) {
-
- if (gst_caps_has_property (caps, "ffvversion")) {
- gint ffvversion = 0;
-
- gst_caps_get_int (caps, "ffvversion", &ffvversion);
- switch (ffvversion) {
- case 1:
- id = CODEC_ID_FFV1;
- break;
- default:
- /* ... */
- break;
- }
+ gint ffvversion = 0;
+
+ gst_structure_get_int (structure, "ffvversion", &ffvversion);
+ switch (ffvversion) {
+ case 1:
+ id = CODEC_ID_FFV1;
+ break;
+ default:
+ /* ... */
+ break;
}
if (id != CODEC_ID_NONE) {
@@ -1471,20 +1308,19 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
}
} else if (!strcmp (mimetype, "x-adpcm")) {
-
- if (gst_caps_has_property (caps, "layout")) {
- const gchar *layout = "";
-
- gst_caps_get_string (caps, "layout", &layout);
- if (!strcmp (layout, "quicktime")) {
- id = CODEC_ID_ADPCM_IMA_QT;
- } else if (!strcmp (layout, "microsoft")) {
- id = CODEC_ID_ADPCM_MS;
- } else if (!strcmp (layout, "wav")) {
- id = CODEC_ID_ADPCM_IMA_WAV;
- } else if (!strcmp (layout, "4xm")) {
- id = CODEC_ID_ADPCM_4XM;
- }
+ const gchar *layout;
+
+ layout = gst_structure_get_string (structure, "layout");
+ if (layout == NULL) {
+ /* break */
+ } else if (!strcmp (layout, "quicktime")) {
+ id = CODEC_ID_ADPCM_IMA_QT;
+ } else if (!strcmp (layout, "microsoft")) {
+ id = CODEC_ID_ADPCM_MS;
+ } else if (!strcmp (layout, "wav")) {
+ id = CODEC_ID_ADPCM_IMA_WAV;
+ } else if (!strcmp (layout, "4xm")) {
+ id = CODEC_ID_ADPCM_4XM;
}
if (id != CODEC_ID_NONE) {
@@ -1513,8 +1349,8 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
}
if (id != CODEC_ID_NONE) {
- char *str = g_strdup_printf("The id=%d belongs to this caps", id);
- gst_caps_debug(caps, str);
+ char *str = gst_caps2_to_string (caps);
+ GST_DEBUG ("The id=%d belongs to the caps %s", id, str);
g_free(str);
}
diff --git a/ext/ffmpeg/gstffmpegcodecmap.h b/ext/ffmpeg/gstffmpegcodecmap.h
index e08b3b0..5f587d4 100644
--- a/ext/ffmpeg/gstffmpegcodecmap.h
+++ b/ext/ffmpeg/gstffmpegcodecmap.h
@@ -31,7 +31,7 @@
* a certain CodecID for a pad with compressed data.
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
AVCodecContext *context);
@@ -39,7 +39,7 @@ gst_ffmpeg_codecid_to_caps (enum CodecID codec_id,
* a certain CodecType for a pad with uncompressed data.
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
AVCodecContext *context);
@@ -49,7 +49,7 @@ gst_ffmpeg_codectype_to_caps (enum CodecType codec_type,
*/
enum CodecID
-gst_ffmpeg_caps_to_codecid (GstCaps *caps,
+gst_ffmpeg_caps_to_codecid (const GstCaps2 *caps,
AVCodecContext *context);
/* caps_to_codectype () transforms a GstCaps that belongs to
@@ -58,7 +58,7 @@ gst_ffmpeg_caps_to_codecid (GstCaps *caps,
void
gst_ffmpeg_caps_to_codectype (enum CodecType type,
- GstCaps *caps,
+ const GstCaps2 *caps,
AVCodecContext *context);
/* _formatid_to_caps () is meant for muxers/demuxers, it
@@ -67,7 +67,7 @@ gst_ffmpeg_caps_to_codectype (enum CodecType type,
* caps belonging to that mux-format
*/
-GstCaps *
+GstCaps2 *
gst_ffmpeg_formatid_to_caps (const gchar *format_name);
#endif /* __GST_FFMPEG_CODECMAP_H__ */
diff --git a/ext/ffmpeg/gstffmpegcolorspace.c b/ext/ffmpeg/gstffmpegcolorspace.c
index 0dfce88..229e26a 100644
--- a/ext/ffmpeg/gstffmpegcolorspace.c
+++ b/ext/ffmpeg/gstffmpegcolorspace.c
@@ -32,35 +32,38 @@
#include "gstffmpegcodecmap.h"
-#define GST_TYPE_FFMPEGCSP \
+GST_DEBUG_CATEGORY_STATIC (debug_ffmpeg_csp);
+#define GST_CAT_DEFAULT debug_ffmpeg_csp
+
+#define GST_TYPE_FFMPEG_CSP \
(gst_ffmpegcsp_get_type())
-#define GST_FFMPEGCSP(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEGCSP,GstFFMpegCsp))
-#define GST_FFMPEGCSP_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEGCSP,GstFFMpegCsp))
-#define GST_IS_FFMPEGCSP(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEGCSP))
-#define GST_IS_FFMPEGCSP_CLASS(obj) \
- (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEGCSP))
+#define GST_FFMPEG_CSP(obj) \
+ (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FFMPEG_CSP,GstFFMpegCsp))
+#define GST_FFMPEG_CSP_CLASS(klass) \
+ (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FFMPEG_CSP,GstFFMpegCsp))
+#define GST_IS_FFMPEG_CSP(obj) \
+ (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FFMPEG_CSP))
+#define GST_IS_FFMPEG_CSP_CLASS(obj) \
+ (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FFMPEG_CSP))
typedef struct _GstFFMpegCsp GstFFMpegCsp;
typedef struct _GstFFMpegCspClass GstFFMpegCspClass;
struct _GstFFMpegCsp {
- GstElement element;
-
- GstPad *sinkpad, *srcpad;
+ GstElement element;
- gint width, height;
- gfloat fps;
- enum PixelFormat
- from_pixfmt,
- to_pixfmt;
- AVFrame *from_frame,
- *to_frame;
- GstCaps *sinkcaps;
+ GstPad * sinkpad;
+ GstPad * srcpad;
+ gboolean need_caps_nego;
- GstBufferPool *pool;
+ gint width;
+ gint height;
+ gdouble fps;
+
+ enum PixelFormat from_pixfmt;
+ enum PixelFormat to_pixfmt;
+ AVFrame * from_frame;
+ AVFrame * to_frame;
};
struct _GstFFMpegCspClass {
@@ -88,176 +91,91 @@ enum {
static GType gst_ffmpegcsp_get_type (void);
-static void gst_ffmpegcsp_base_init (GstFFMpegCspClass *klass);
-static void gst_ffmpegcsp_class_init (GstFFMpegCspClass *klass);
-static void gst_ffmpegcsp_init (GstFFMpegCsp *space);
+static void gst_ffmpegcsp_base_init (gpointer g_class);
+static void gst_ffmpegcsp_class_init (gpointer g_class, gpointer class_data);
+static void gst_ffmpegcsp_init (GTypeInstance *instance, gpointer g_class);
-static void gst_ffmpegcsp_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec);
-static void gst_ffmpegcsp_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec);
-
-static GstPadLinkReturn
- gst_ffmpegcsp_sinkconnect (GstPad *pad,
- GstCaps *caps);
static GstPadLinkReturn
- gst_ffmpegcsp_srcconnect (GstPad *pad,
- GstCaps *caps);
+ gst_ffmpegcsp_connect (GstPad *pad,
+ const GstCaps2 *caps);
static GstPadLinkReturn
- gst_ffmpegcsp_srcconnect_func (GstPad *pad,
- GstCaps *caps,
- gboolean newcaps);
+ gst_ffmpegcsp_try_connect (GstPad *pad,
+ AVCodecContext *ctx,
+ double fps);
-static void gst_ffmpegcsp_chain (GstPad *pad,
- GstData *data);
+static void gst_ffmpegcsp_chain (GstPad *pad,
+ GstData *data);
static GstElementStateReturn
- gst_ffmpegcsp_change_state (GstElement *element);
+ gst_ffmpegcsp_change_state (GstElement *element);
-static GstPadTemplate *srctempl, *sinktempl;
static GstElementClass *parent_class = NULL;
/*static guint gst_ffmpegcsp_signals[LAST_SIGNAL] = { 0 }; */
-static GstBufferPool *
-ffmpegcsp_get_bufferpool (GstPad *pad)
-{
- GstFFMpegCsp *space;
-
- space = GST_FFMPEGCSP (gst_pad_get_parent (pad));
-
- if (space->from_pixfmt == space->to_pixfmt &&
- space->from_pixfmt != PIX_FMT_NB) {
- return gst_pad_get_bufferpool (space->srcpad);
- }
-
- return NULL;
-}
-
-static GstCaps *
-gst_ffmpegcsp_getcaps (GstPad *pad,
- GstCaps *caps)
-{
- GstFFMpegCsp *space;
- GstCaps *result;
- GstCaps *peercaps;
- GstCaps *ourcaps;
-
- space = GST_FFMPEGCSP (gst_pad_get_parent (pad));
-
- /* we can do everything our peer can... */
- peercaps = gst_caps_copy (gst_pad_get_allowed_caps (space->srcpad));
-
- /* and our own template of course */
- ourcaps = gst_caps_copy (gst_pad_get_pad_template_caps (pad));
-
- /* merge them together, we prefer the peercaps first */
- result = gst_caps_prepend (ourcaps, peercaps);
-
- return result;
-}
-
+/* does caps nego on a pad */
static GstPadLinkReturn
-gst_ffmpegcsp_srcconnect_func (GstPad *pad,
- GstCaps *caps,
- gboolean newcaps)
+gst_ffmpegcsp_try_connect (GstPad *pad, AVCodecContext *ctx, double fps)
{
- AVCodecContext *ctx;
+ gint i, ret;
GstFFMpegCsp *space;
- GstCaps *peercaps;
- GstCaps *ourcaps;
+ GstCaps2 *caps;
+ gboolean try_all = (ctx->pix_fmt != PIX_FMT_NB);
- space = GST_FFMPEGCSP (gst_pad_get_parent (pad));
-
- /* we cannot operate if we didn't get src caps */
- if (!(ourcaps = space->sinkcaps)) {
- if (newcaps) {
- gst_pad_recalc_allowed_caps (space->sinkpad);
- }
+ space = GST_FFMPEG_CSP (gst_pad_get_parent (pad));
- return GST_PAD_LINK_DELAYED;
- }
+ /* loop over all possibilities and select the first one we can convert and
+ * is accepted by the peer */
+ caps = gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, ctx);
+ for (i = 0; i < gst_caps2_get_n_structures (caps); i++) {
+ GstStructure *structure = gst_caps2_get_nth_cap (caps, i);
+ GstCaps2 *setcaps;
+
+ if (fps > 0)
+ gst_structure_set (structure, "framerate", G_TYPE_DOUBLE, fps, NULL);
+
+ setcaps = gst_caps2_new_full (gst_structure_copy (structure), NULL);
+
+ ret = gst_pad_try_set_caps (pad, setcaps);
+ gst_caps2_free (setcaps);
+ if (ret >= 0) {
+ if (ctx->pix_fmt == PIX_FMT_NB)
+ gst_ffmpeg_caps_to_codectype (CODEC_TYPE_VIDEO, caps, ctx);
+ gst_caps2_free (caps);
- /* first see if we can do the format natively by filtering the peer caps
- * with our incomming caps */
- if ((peercaps = gst_caps_intersect (caps, ourcaps)) != NULL) {
- /* see if the peer likes it too, it should as the caps say so.. */
- if (gst_pad_try_set_caps (space->srcpad, peercaps) > 0) {
- space->from_pixfmt = space->to_pixfmt = -1;
- return GST_PAD_LINK_DONE;
+ return ret;
}
}
- /* then see what the peer has that matches the size */
- peercaps = gst_caps_intersect (caps,
- gst_caps_append (
- GST_CAPS_NEW (
- "ffmpegcsp_filter",
- "video/x-raw-yuv",
- "width", GST_PROPS_INT (space->width),
- "height", GST_PROPS_INT (space->height),
- "framerate", GST_PROPS_FLOAT (space->fps)
- ), GST_CAPS_NEW (
- "ffmpegcsp_filter",
- "video/x-raw-rgb",
- "width", GST_PROPS_INT (space->width),
- "height", GST_PROPS_INT (space->height),
- "framerate", GST_PROPS_FLOAT (space->fps)
- )));
-
- /* we are looping over the caps, so we have to get rid of the lists */
- peercaps = gst_caps_normalize (peercaps);
-
- /* loop over all possibilities and select the first one we can convert and
- * is accepted by the peer */
- ctx = avcodec_alloc_context ();
- while (peercaps) {
- ctx->width = space->width;
- ctx->height = space->height;
+ if (try_all) {
ctx->pix_fmt = PIX_FMT_NB;
- gst_ffmpeg_caps_to_codectype (CODEC_TYPE_VIDEO, peercaps, ctx);
- if (ctx->pix_fmt != PIX_FMT_NB) {
- GstCaps *one = gst_caps_copy_1 (peercaps);
- if (gst_pad_try_set_caps (space->srcpad, one) > 0) {
- space->to_pixfmt = ctx->pix_fmt;
- gst_caps_unref (one);
- av_free (ctx);
- if (space->from_frame)
- av_free (space->from_frame);
- if (space->to_frame)
- av_free (space->to_frame);
- space->from_frame = avcodec_alloc_frame ();
- space->to_frame = avcodec_alloc_frame ();
- return GST_PAD_LINK_DONE;
- }
- gst_caps_unref (one);
- }
- peercaps = peercaps->next;
+ return gst_ffmpegcsp_try_connect (pad, ctx, fps);
+ } else {
+ return GST_PAD_LINK_REFUSED;
}
- av_free (ctx);
-
- /* we disable ourself here */
- space->from_pixfmt = space->to_pixfmt = PIX_FMT_NB;
-
- return GST_PAD_LINK_REFUSED;
}
static GstPadLinkReturn
-gst_ffmpegcsp_sinkconnect (GstPad *pad,
- GstCaps *caps)
+gst_ffmpegcsp_connect (GstPad *pad, const GstCaps2 *caps)
{
AVCodecContext *ctx;
GstFFMpegCsp *space;
- GstPad *peer;
-
- space = GST_FFMPEGCSP (gst_pad_get_parent (pad));
-
- if (!GST_CAPS_IS_FIXED (caps)) {
- return GST_PAD_LINK_DELAYED;
+ gdouble fps;
+ enum PixelFormat pixfmt;
+ GstPad *other;
+ enum PixelFormat *format, *other_format;
+
+ space = GST_FFMPEG_CSP (gst_pad_get_parent (pad));
+
+ if (space->sinkpad == pad) {
+ other = space->srcpad;
+ format = &space->from_pixfmt;
+ other_format = &space->to_pixfmt;
+ } else if (space->srcpad == pad) {
+ other = space->sinkpad;
+ format = &space->to_pixfmt;
+ other_format = &space->from_pixfmt;
+ } else {
+ g_assert_not_reached ();
}
-
ctx = avcodec_alloc_context ();
ctx->width = 0;
ctx->height = 0;
@@ -265,42 +183,40 @@ gst_ffmpegcsp_sinkconnect (GstPad *pad,
gst_ffmpeg_caps_to_codectype (CODEC_TYPE_VIDEO, caps, ctx);
if (!ctx->width || !ctx->height || ctx->pix_fmt == PIX_FMT_NB) {
+ av_free (ctx);
return GST_PAD_LINK_REFUSED;
}
- gst_caps_get_float (caps, "framerate", &space->fps);
+ if (!gst_structure_get_double (gst_caps2_get_nth_cap (caps, 0),
+ "framerate", &fps))
+ fps = 0;
+
+ pixfmt = ctx->pix_fmt;
+ if (*other_format == PIX_FMT_NB ||
+ space->width != ctx->width ||
+ space->height != ctx->height ||
+ space->fps != fps) {
+ GST_DEBUG_OBJECT (space, "Need caps nego on pad %s for size %dx%d",
+ GST_PAD_NAME (other), ctx->width, ctx->height);
+ /* ctx->pix_fmt is set to preferred format */
+ if (gst_ffmpegcsp_try_connect (space->sinkpad, ctx, fps) <= 0) {
+ av_free (ctx);
+ return GST_PAD_LINK_REFUSED;
+ }
+ *other_format = ctx->pix_fmt;
+ }
space->width = ctx->width;
space->height = ctx->height;
- space->from_pixfmt = ctx->pix_fmt;
+ space->fps = fps;
+ *format = pixfmt;
av_free (ctx);
- GST_INFO ( "size: %dx%d", space->width, space->height);
-
- space->sinkcaps = caps;
-
- if ((peer = gst_pad_get_peer (pad)) != NULL) {
- GstPadLinkReturn ret;
- ret = gst_ffmpegcsp_srcconnect_func (pad,
- gst_pad_get_allowed_caps (space->srcpad),
- FALSE);
- if (ret <= 0) {
- space->sinkcaps = NULL;
- return ret;
- }
-
- return GST_PAD_LINK_DONE;
- }
+ GST_INFO_OBJECT (space, "new size: %dx%d (fps: %g)",
+ space->width, space->height, space->fps);
return GST_PAD_LINK_OK;
}
-static GstPadLinkReturn
-gst_ffmpegcsp_srcconnect (GstPad *pad,
- GstCaps *caps)
-{
- return gst_ffmpegcsp_srcconnect_func (pad, caps, TRUE);
-}
-
static GType
gst_ffmpegcsp_get_type (void)
{
@@ -309,66 +225,79 @@ gst_ffmpegcsp_get_type (void)
if (!ffmpegcsp_type) {
static const GTypeInfo ffmpegcsp_info = {
sizeof (GstFFMpegCspClass),
- (GBaseInitFunc) gst_ffmpegcsp_base_init,
+ gst_ffmpegcsp_base_init,
NULL,
- (GClassInitFunc) gst_ffmpegcsp_class_init,
+ gst_ffmpegcsp_class_init,
NULL,
NULL,
sizeof (GstFFMpegCsp),
0,
- (GInstanceInitFunc) gst_ffmpegcsp_init,
+ gst_ffmpegcsp_init,
};
ffmpegcsp_type = g_type_register_static (GST_TYPE_ELEMENT,
"GstFFMpegColorspace",
&ffmpegcsp_info, 0);
+
+ GST_DEBUG_CATEGORY_INIT (debug_ffmpeg_csp, "ffcolorspace", 0, "FFMpeg colorspace converter");
}
return ffmpegcsp_type;
}
static void
-gst_ffmpegcsp_base_init (GstFFMpegCspClass *klass)
+gst_ffmpegcsp_base_init (gpointer g_class)
{
- GstElementClass *element_class = GST_ELEMENT_CLASS (klass);
+ GstCaps2 *caps, *capscopy;
+ GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
+
+ /* template caps */
+ caps = gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, NULL);
+ capscopy = gst_caps2_copy (caps);
+
+ /* build templates */
+ gst_element_class_add_pad_template (element_class,
+ gst_pad_template_new ("src",
+ GST_PAD_SRC,
+ GST_PAD_ALWAYS,
+ caps));
+ gst_element_class_add_pad_template (element_class,
+ gst_pad_template_new ("sink",
+ GST_PAD_SINK,
+ GST_PAD_ALWAYS,
+ capscopy));
- gst_element_class_add_pad_template (element_class, srctempl);
- gst_element_class_add_pad_template (element_class, sinktempl);
gst_element_class_set_details (element_class, &ffmpegcsp_details);
}
static void
-gst_ffmpegcsp_class_init (GstFFMpegCspClass *klass)
+gst_ffmpegcsp_class_init (gpointer g_class, gpointer class_data)
{
- GObjectClass *gobject_class;
- GstElementClass *gstelement_class;
+ GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class);
- gobject_class = (GObjectClass*) klass;
- gstelement_class = (GstElementClass*) klass;
-
- parent_class = g_type_class_ref (GST_TYPE_ELEMENT);
-
- gobject_class->set_property = gst_ffmpegcsp_set_property;
- gobject_class->get_property = gst_ffmpegcsp_get_property;
+ parent_class = g_type_class_peek_parent (g_class);
gstelement_class->change_state = gst_ffmpegcsp_change_state;
}
static void
-gst_ffmpegcsp_init (GstFFMpegCsp *space)
+gst_ffmpegcsp_init (GTypeInstance *instance, gpointer g_class)
{
- space->sinkpad = gst_pad_new_from_template (sinktempl, "sink");
- gst_pad_set_link_function (space->sinkpad, gst_ffmpegcsp_sinkconnect);
- gst_pad_set_getcaps_function (space->sinkpad, gst_ffmpegcsp_getcaps);
- gst_pad_set_bufferpool_function (space->sinkpad, ffmpegcsp_get_bufferpool);
+ GstFFMpegCsp *space = GST_FFMPEG_CSP (instance);
+
+ space->sinkpad = gst_pad_new_from_template (
+ gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (space), "sink"),
+ "sink");
+ gst_pad_set_link_function (space->sinkpad, gst_ffmpegcsp_connect);
gst_pad_set_chain_function (space->sinkpad,gst_ffmpegcsp_chain);
gst_element_add_pad (GST_ELEMENT(space), space->sinkpad);
- space->srcpad = gst_pad_new_from_template (srctempl, "src");
+ space->srcpad = gst_pad_new_from_template (
+ gst_element_class_get_pad_template (GST_ELEMENT_GET_CLASS (space), "src"),
+ "src");
gst_element_add_pad (GST_ELEMENT (space), space->srcpad);
- gst_pad_set_link_function (space->srcpad, gst_ffmpegcsp_srcconnect);
+ gst_pad_set_link_function (space->srcpad, gst_ffmpegcsp_connect);
- space->pool = NULL;
space->from_pixfmt = space->to_pixfmt = PIX_FMT_NB;
space->from_frame = space->to_frame = NULL;
}
@@ -377,18 +306,18 @@ static void
gst_ffmpegcsp_chain (GstPad *pad,
GstData *data)
{
- GstBuffer *inbuf = GST_BUFFER (data);
GstFFMpegCsp *space;
+ GstBuffer *inbuf = GST_BUFFER (data);
GstBuffer *outbuf = NULL;
g_return_if_fail (pad != NULL);
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (inbuf != NULL);
- space = GST_FFMPEGCSP (gst_pad_get_parent (pad));
+ space = GST_FFMPEG_CSP (gst_pad_get_parent (pad));
g_return_if_fail (space != NULL);
- g_return_if_fail (GST_IS_FFMPEGCSP (space));
+ g_return_if_fail (GST_IS_FFMPEG_CSP (space));
if (space->from_pixfmt == PIX_FMT_NB ||
space->to_pixfmt == PIX_FMT_NB) {
@@ -399,16 +328,11 @@ gst_ffmpegcsp_chain (GstPad *pad,
if (space->from_pixfmt == space->to_pixfmt) {
outbuf = inbuf;
} else {
- if (space->pool) {
- outbuf = gst_buffer_new_from_pool (space->pool, 0, 0);
- }
-
- if (!outbuf) {
- guint size = avpicture_get_size (space->to_pixfmt,
- space->width,
- space->height);
- outbuf = gst_buffer_new_and_alloc (size);
- }
+ guint size = avpicture_get_size (space->to_pixfmt,
+ space->width,
+ space->height);
+ /* use bufferpools here */
+ outbuf = gst_buffer_new_and_alloc (size);
/* convert */
avpicture_fill ((AVPicture *) space->from_frame, GST_BUFFER_DATA (inbuf),
@@ -419,8 +343,7 @@ gst_ffmpegcsp_chain (GstPad *pad,
(AVPicture *) space->from_frame, space->from_pixfmt,
space->width, space->height);
- GST_BUFFER_TIMESTAMP (outbuf) = GST_BUFFER_TIMESTAMP (inbuf);
- GST_BUFFER_DURATION (outbuf) = GST_BUFFER_DURATION (inbuf);
+ gst_buffer_stamp (outbuf, inbuf);
gst_buffer_unref (inbuf);
}
@@ -433,14 +356,12 @@ gst_ffmpegcsp_change_state (GstElement *element)
{
GstFFMpegCsp *space;
- space = GST_FFMPEGCSP (element);
+ space = GST_FFMPEG_CSP (element);
switch (GST_STATE_TRANSITION (element)) {
- case GST_STATE_PAUSED_TO_PLAYING:
- space->pool = gst_pad_get_bufferpool (space->srcpad);
+ case GST_STATE_READY_TO_PAUSED:
+ space->need_caps_nego = TRUE;
break;
- case GST_STATE_PLAYING_TO_PAUSED:
- space->pool = NULL;
case GST_STATE_PAUSED_TO_READY:
if (space->from_frame)
av_free (space->from_frame);
@@ -457,62 +378,9 @@ gst_ffmpegcsp_change_state (GstElement *element)
return GST_STATE_SUCCESS;
}
-static void
-gst_ffmpegcsp_set_property (GObject *object,
- guint prop_id,
- const GValue *value,
- GParamSpec *pspec)
-{
- GstFFMpegCsp *space;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail (GST_IS_FFMPEGCSP (object));
- space = GST_FFMPEGCSP (object);
-
- switch (prop_id) {
- default:
- break;
- }
-}
-
-static void
-gst_ffmpegcsp_get_property (GObject *object,
- guint prop_id,
- GValue *value,
- GParamSpec *pspec)
-{
- GstFFMpegCsp *space;
-
- /* it's not null if we got it, but it might not be ours */
- g_return_if_fail (GST_IS_FFMPEGCSP (object));
- space = GST_FFMPEGCSP (object);
-
- switch (prop_id) {
- default:
- G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
- break;
- }
-}
-
gboolean
gst_ffmpegcsp_register (GstPlugin *plugin)
{
- GstCaps *caps;
-
- /* template caps */
- caps = gst_ffmpeg_codectype_to_caps (CODEC_TYPE_VIDEO, NULL);
-
- /* build templates */
- srctempl = gst_pad_template_new ("src",
- GST_PAD_SRC,
- GST_PAD_ALWAYS,
- caps, NULL);
- gst_caps_ref (caps); /* FIXME: pad_template_new refs the caps, doesn't it? */
- sinktempl = gst_pad_template_new ("sink",
- GST_PAD_SINK,
- GST_PAD_ALWAYS,
- caps, NULL);
-
return gst_element_register (plugin, "ffcolorspace",
- GST_RANK_NONE, GST_TYPE_FFMPEGCSP);
+ GST_RANK_NONE, GST_TYPE_FFMPEG_CSP);
}
diff --git a/ext/ffmpeg/gstffmpegdec.c b/ext/ffmpeg/gstffmpegdec.c
index 0c4cd07..ffa718d 100644
--- a/ext/ffmpeg/gstffmpegdec.c
+++ b/ext/ffmpeg/gstffmpegdec.c
@@ -59,7 +59,7 @@ typedef struct _GstFFMpegDecClassParams GstFFMpegDecClassParams;
struct _GstFFMpegDecClassParams {
AVCodec *in_plugin;
- GstCaps *srccaps, *sinkcaps;
+ GstCaps2 *srccaps, *sinkcaps;
};
#define GST_TYPE_FFMPEGDEC \
@@ -92,7 +92,7 @@ static void gst_ffmpegdec_init (GstFFMpegDec *ffmpegdec);
static void gst_ffmpegdec_dispose (GObject *object);
static GstPadLinkReturn gst_ffmpegdec_connect (GstPad *pad,
- GstCaps *caps);
+ const GstCaps2 *caps);
static void gst_ffmpegdec_chain (GstPad *pad,
GstData *data);
@@ -141,9 +141,9 @@ gst_ffmpegdec_base_init (GstFFMpegDecClass *klass)
/* pad templates */
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS, params->sinkcaps, NULL);
+ GST_PAD_ALWAYS, params->sinkcaps);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS, params->srccaps, NULL);
+ GST_PAD_ALWAYS, params->srccaps);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
@@ -206,15 +206,11 @@ gst_ffmpegdec_dispose (GObject *object)
static GstPadLinkReturn
gst_ffmpegdec_connect (GstPad *pad,
- GstCaps *caps)
+ const GstCaps2 *caps)
{
GstFFMpegDec *ffmpegdec = (GstFFMpegDec *)(gst_pad_get_parent (pad));
GstFFMpegDecClass *oclass = (GstFFMpegDecClass*)(G_OBJECT_GET_CLASS (ffmpegdec));
- /* we want fixed caps */
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
/* close old session */
if (ffmpegdec->opened) {
avcodec_close (ffmpegdec->context);
@@ -407,7 +403,7 @@ gst_ffmpegdec_chain (GstPad *pad,
if (have_data) {
if (!GST_PAD_CAPS (ffmpegdec->srcpad)) {
- GstCaps *caps;
+ GstCaps2 *caps;
caps = gst_ffmpeg_codectype_to_caps (oclass->in_plugin->type,
ffmpegdec->context);
if (caps == NULL ||
@@ -475,7 +471,7 @@ gst_ffmpegdec_register (GstPlugin *plugin)
while (in_plugin) {
GstFFMpegDecClassParams *params;
- GstCaps *srccaps, *sinkcaps;
+ GstCaps2 *srccaps, *sinkcaps;
gchar *type_name;
/* no quasi-codecs, please */
diff --git a/ext/ffmpeg/gstffmpegdemux.c b/ext/ffmpeg/gstffmpegdemux.c
index 6c0392e..d26aa0d 100644
--- a/ext/ffmpeg/gstffmpegdemux.c
+++ b/ext/ffmpeg/gstffmpegdemux.c
@@ -51,7 +51,7 @@ struct _GstFFMpegDemux {
typedef struct _GstFFMpegDemuxClassParams {
AVInputFormat *in_plugin;
- GstCaps *sinkcaps, *videosrccaps, *audiosrccaps;
+ GstCaps2 *sinkcaps, *videosrccaps, *audiosrccaps;
} GstFFMpegDemuxClassParams;
typedef struct _GstFFMpegDemuxClass GstFFMpegDemuxClass;
@@ -133,15 +133,15 @@ gst_ffmpegdemux_base_init (GstFFMpegDemuxClass *klass)
sinktempl = gst_pad_template_new ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
- params->sinkcaps, NULL);
+ params->sinkcaps);
videosrctempl = gst_pad_template_new ("video_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
- params->videosrccaps, NULL);
+ params->videosrccaps);
audiosrctempl = gst_pad_template_new ("audio_%02d",
GST_PAD_SRC,
GST_PAD_SOMETIMES,
- params->audiosrccaps, NULL);
+ params->audiosrccaps);
gst_element_class_add_pad_template (element_class, videosrctempl);
gst_element_class_add_pad_template (element_class, audiosrctempl);
@@ -217,12 +217,8 @@ gst_ffmpegdemux_type_find (GstTypeFind *tf, gpointer priv)
res = in_plugin->read_probe (&probe_data);
res = res * GST_TYPE_FIND_MAXIMUM / AVPROBE_SCORE_MAX;
- if (res > 0) {
- GstCaps *caps = params->sinkcaps;
- /* make sure we still hold a refcount to this caps */
- gst_caps_ref (caps);
- gst_type_find_suggest (tf, res, caps);
- }
+ if (res > 0)
+ gst_type_find_suggest (tf, res, params->sinkcaps);
}
}
@@ -291,7 +287,7 @@ gst_ffmpegdemux_loop (GstElement *element)
/* create the pad/stream if we didn't do so already */
if (st->codec_info_state == 0) {
GstPadTemplate *templ = NULL;
- GstCaps *caps;
+ GstCaps2 *caps;
gchar *padname;
gint num;
@@ -386,6 +382,11 @@ gst_ffmpegdemux_change_state (GstElement *element)
gboolean
gst_ffmpegdemux_register (GstPlugin *plugin)
{
+ GType type;
+ AVInputFormat *in_plugin;
+ GstFFMpegDemuxClassParams *params;
+ AVCodec *in_codec;
+ gchar **extensions;
GTypeInfo typeinfo = {
sizeof(GstFFMpegDemuxClass),
(GBaseInitFunc)gst_ffmpegdemux_base_init,
@@ -397,11 +398,7 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
0,
(GInstanceInitFunc)gst_ffmpegdemux_init,
};
- GType type;
- AVInputFormat *in_plugin;
- GstFFMpegDemuxClassParams *params;
- AVCodec *in_codec;
- gchar **extensions;
+ GstCaps2 *any_caps = gst_caps2_new_any ();
in_plugin = first_iformat;
@@ -410,7 +407,7 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
while (in_plugin) {
gchar *type_name, *typefind_name;
gchar *p;
- GstCaps *sinkcaps, *audiosrccaps, *videosrccaps;
+ GstCaps2 *sinkcaps, *audiosrccaps, *videosrccaps;
/* Try to find the caps that belongs here */
sinkcaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
@@ -424,19 +421,19 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
videosrccaps = NULL;
for (in_codec = first_avcodec; in_codec != NULL;
in_codec = in_codec->next) {
- GstCaps *temp = gst_ffmpeg_codecid_to_caps (in_codec->id, NULL);
+ GstCaps2 *temp = gst_ffmpeg_codecid_to_caps (in_codec->id, NULL);
if (!temp) {
continue;
}
switch (in_codec->type) {
case CODEC_TYPE_VIDEO:
- videosrccaps = gst_caps_append (videosrccaps, temp);
+ gst_caps2_append (videosrccaps, temp);
break;
case CODEC_TYPE_AUDIO:
- audiosrccaps = gst_caps_append (audiosrccaps, temp);
+ gst_caps2_append (audiosrccaps, temp);
break;
default:
- gst_caps_unref (temp);
+ gst_caps2_free (temp);
break;
}
}
@@ -480,13 +477,14 @@ gst_ffmpegdemux_register (GstPlugin *plugin)
if (!gst_element_register (plugin, type_name, GST_RANK_MARGINAL, type) ||
!gst_type_find_register (plugin, typefind_name, GST_RANK_MARGINAL,
gst_ffmpegdemux_type_find,
- extensions, GST_CAPS_ANY, params))
+ extensions, any_caps, params))
return FALSE;
g_strfreev (extensions);
next:
in_plugin = in_plugin->next;
}
+ gst_caps2_free (any_caps);
g_hash_table_remove (global_plugins, GINT_TO_POINTER (0));
return TRUE;
diff --git a/ext/ffmpeg/gstffmpegenc.c b/ext/ffmpeg/gstffmpegenc.c
index 03f80f2..d4549a9 100644
--- a/ext/ffmpeg/gstffmpegenc.c
+++ b/ext/ffmpeg/gstffmpegenc.c
@@ -64,7 +64,7 @@ struct _GstFFMpegEncClass {
typedef struct {
AVCodec *in_plugin;
- GstCaps *srccaps, *sinkcaps;
+ GstCaps2 *srccaps, *sinkcaps;
} GstFFMpegEncClassParams;
#define GST_TYPE_FFMPEGENC \
@@ -123,7 +123,7 @@ static void gst_ffmpegenc_init (GstFFMpegEnc *ffmpegenc);
static void gst_ffmpegenc_dispose (GObject *object);
static GstPadLinkReturn
- gst_ffmpegenc_connect (GstPad *pad, GstCaps *caps);
+ gst_ffmpegenc_connect (GstPad *pad, const GstCaps2 *caps);
static void gst_ffmpegenc_chain_video (GstPad *pad, GstData *_data);
static void gst_ffmpegenc_chain_audio (GstPad *pad, GstData *_data);
@@ -175,9 +175,9 @@ gst_ffmpegenc_base_init (GstFFMpegEncClass *klass)
/* pad templates */
sinktempl = gst_pad_template_new ("sink", GST_PAD_SINK,
- GST_PAD_ALWAYS, params->sinkcaps, NULL);
+ GST_PAD_ALWAYS, params->sinkcaps);
srctempl = gst_pad_template_new ("src", GST_PAD_SRC,
- GST_PAD_ALWAYS, params->srccaps, NULL);
+ GST_PAD_ALWAYS, params->srccaps);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, sinktempl);
@@ -282,15 +282,13 @@ gst_ffmpegenc_dispose (GObject *object)
static GstPadLinkReturn
gst_ffmpegenc_connect (GstPad *pad,
- GstCaps *caps)
+ const GstCaps2 *caps)
{
- GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) gst_pad_get_parent (pad);
- GstFFMpegEncClass *oclass = (GstFFMpegEncClass*)(G_OBJECT_GET_CLASS(ffmpegenc));
- GstCaps *ret_caps;
+ GstCaps2 *other_caps;
GstPadLinkReturn ret;
-
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
+ enum PixelFormat pix_fmt;
+ GstFFMpegEnc *ffmpegenc = (GstFFMpegEnc *) gst_pad_get_parent (pad);
+ GstFFMpegEncClass *oclass = (GstFFMpegEncClass *) G_OBJECT_GET_CLASS(ffmpegenc);
/* close old session */
if (ffmpegenc->opened) {
@@ -315,47 +313,37 @@ gst_ffmpegenc_connect (GstPad *pad,
/* no edges */
ffmpegenc->context->flags |= CODEC_FLAG_EMU_EDGE;
- for (ret_caps = caps; ret_caps != NULL; ret_caps = ret_caps->next) {
- enum PixelFormat pix_fmt;
-
- /* fetch pix_fmt and so on */
- gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
- caps, ffmpegenc->context);
+ /* fetch pix_fmt and so on */
+ gst_ffmpeg_caps_to_codectype (oclass->in_plugin->type,
+ caps, ffmpegenc->context);
- pix_fmt = ffmpegenc->context->pix_fmt;
+ pix_fmt = ffmpegenc->context->pix_fmt;
- /* open codec */
- if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
- GST_DEBUG ("ffenc_%s: Failed to open FFMPEG codec",
- oclass->in_plugin->name);
- continue;
- }
-
- /* is the colourspace correct? */
- if (pix_fmt != ffmpegenc->context->pix_fmt) {
- avcodec_close (ffmpegenc->context);
- GST_DEBUG ("ffenc_%s: AV wants different colourspace (%d given, %d wanted)",
- oclass->in_plugin->name, pix_fmt, ffmpegenc->context->pix_fmt);
- continue;
- }
-
- break;
+ /* open codec */
+ if (avcodec_open (ffmpegenc->context, oclass->in_plugin) < 0) {
+ GST_DEBUG ("ffenc_%s: Failed to open FFMPEG codec",
+ oclass->in_plugin->name);
+ return GST_PAD_LINK_REFUSED;
}
- if (ret_caps == NULL) {
+ /* is the colourspace correct? */
+ if (pix_fmt != ffmpegenc->context->pix_fmt) {
+ avcodec_close (ffmpegenc->context);
+ GST_DEBUG ("ffenc_%s: AV wants different colourspace (%d given, %d wanted)",
+ oclass->in_plugin->name, pix_fmt, ffmpegenc->context->pix_fmt);
return GST_PAD_LINK_REFUSED;
}
/* try to set this caps on the other side */
- ret_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
+ other_caps = gst_ffmpeg_codecid_to_caps (oclass->in_plugin->id,
ffmpegenc->context);
- if (!ret_caps) {
+ if (!other_caps) {
avcodec_close (ffmpegenc->context);
GST_DEBUG ("Unsupported codec - no caps found");
return GST_PAD_LINK_REFUSED;
}
- if ((ret = gst_pad_try_set_caps (ffmpegenc->srcpad, ret_caps)) <= 0) {
+ if ((ret = gst_pad_try_set_caps (ffmpegenc->srcpad, other_caps)) <= 0) {
avcodec_close (ffmpegenc->context);
GST_DEBUG ("Failed to set caps on next element for ffmpeg encoder (%s)",
oclass->in_plugin->name);
@@ -606,7 +594,7 @@ gst_ffmpegenc_register (GstPlugin *plugin)
while (in_plugin) {
gchar *type_name;
- GstCaps *srccaps, *sinkcaps;
+ GstCaps2 *srccaps, *sinkcaps;
GstFFMpegEncClassParams *params;
/* no quasi codecs, please */
diff --git a/ext/ffmpeg/gstffmpegmux.c b/ext/ffmpeg/gstffmpegmux.c
index c4bd645..864b960 100644
--- a/ext/ffmpeg/gstffmpegmux.c
+++ b/ext/ffmpeg/gstffmpegmux.c
@@ -51,7 +51,7 @@ struct _GstFFMpegMux {
typedef struct _GstFFMpegMuxClassParams {
AVOutputFormat *in_plugin;
- GstCaps *srccaps, *videosinkcaps, *audiosinkcaps;
+ GstCaps2 *srccaps, *videosinkcaps, *audiosinkcaps;
} GstFFMpegMuxClassParams;
typedef struct _GstFFMpegMuxClass GstFFMpegMuxClass;
@@ -96,7 +96,7 @@ static void gst_ffmpegmux_dispose (GObject *object);
static GstPadLinkReturn
gst_ffmpegmux_connect (GstPad *pad,
- GstCaps *caps);
+ const GstCaps2 *caps);
static GstPad * gst_ffmpegmux_request_new_pad (GstElement *element,
GstPadTemplate *templ,
const gchar *name);
@@ -138,15 +138,15 @@ gst_ffmpegmux_base_init (GstFFMpegMuxClass *klass)
/* pad templates */
srctempl = gst_pad_template_new ("sink", GST_PAD_SRC,
GST_PAD_ALWAYS,
- params->srccaps, NULL);
+ params->srccaps);
audiosinktempl = gst_pad_template_new ("audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
- params->audiosinkcaps, NULL);
+ params->audiosinkcaps);
videosinktempl = gst_pad_template_new ("video_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
- params->videosinkcaps, NULL);
+ params->videosinkcaps);
gst_element_class_add_pad_template (element_class, srctempl);
gst_element_class_add_pad_template (element_class, videosinktempl);
@@ -272,7 +272,7 @@ gst_ffmpegmux_request_new_pad (GstElement *element,
static GstPadLinkReturn
gst_ffmpegmux_connect (GstPad *pad,
- GstCaps *caps)
+ const GstCaps2 *caps)
{
GstFFMpegMux *ffmpegmux = (GstFFMpegMux *)(gst_pad_get_parent (pad));
gint i;
@@ -281,9 +281,6 @@ gst_ffmpegmux_connect (GstPad *pad,
g_return_val_if_fail (ffmpegmux->opened == FALSE,
GST_PAD_LINK_REFUSED);
- if (!GST_CAPS_IS_FIXED (caps))
- return GST_PAD_LINK_DELAYED;
-
for (i = 0; i < ffmpegmux->context->nb_streams; i++) {
if (pad == ffmpegmux->sinkpads[i]) {
break;
@@ -297,12 +294,10 @@ gst_ffmpegmux_connect (GstPad *pad,
/* for the format-specific guesses, we'll go to
* our famous codec mapper */
- for ( ; caps != NULL; caps = caps->next) {
- if (gst_ffmpeg_caps_to_codecid (caps,
- &st->codec) != CODEC_ID_NONE) {
- ffmpegmux->eos[i] = FALSE;
- return GST_PAD_LINK_OK;
- }
+ if (gst_ffmpeg_caps_to_codecid (caps,
+ &st->codec) != CODEC_ID_NONE) {
+ ffmpegmux->eos[i] = FALSE;
+ return GST_PAD_LINK_OK;
}
return GST_PAD_LINK_REFUSED;
@@ -463,7 +458,7 @@ gst_ffmpegmux_register (GstPlugin *plugin)
while (in_plugin) {
gchar *type_name;
gchar *p;
- GstCaps *srccaps, *audiosinkcaps, *videosinkcaps;
+ GstCaps2 *srccaps, *audiosinkcaps, *videosinkcaps;
/* Try to find the caps that belongs here */
srccaps = gst_ffmpeg_formatid_to_caps (in_plugin->name);
@@ -477,19 +472,19 @@ gst_ffmpegmux_register (GstPlugin *plugin)
videosinkcaps = NULL;
for (in_codec = first_avcodec; in_codec != NULL;
in_codec = in_codec->next) {
- GstCaps *temp = gst_ffmpeg_codecid_to_caps (in_codec->id, NULL);
+ GstCaps2 *temp = gst_ffmpeg_codecid_to_caps (in_codec->id, NULL);
if (!temp) {
continue;
}
switch (in_codec->type) {
case CODEC_TYPE_VIDEO:
- videosinkcaps = gst_caps_append (videosinkcaps, temp);
+ gst_caps2_append (videosinkcaps, temp);
break;
case CODEC_TYPE_AUDIO:
- audiosinkcaps = gst_caps_append (audiosinkcaps, temp);
+ gst_caps2_append (audiosinkcaps, temp);
break;
default:
- gst_caps_unref (temp);
+ gst_caps2_free (temp);
break;
}
}