diff options
author | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
---|---|---|
committer | Ronald S. Bultje <rbultje@ronald.bitfreak.net> | 2003-07-06 20:49:52 +0000 |
commit | 95011fd7e8eb3a2ec3a87ff9dad523d18005db42 (patch) | |
tree | 6e75f9139c6520126f9344e15e1dea2a49f70f9c /ext | |
parent | 85a8dd7ecb04d043be8192e27e3c89ef8ccebe55 (diff) | |
download | gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.tar.gz gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.tar.bz2 gst-plugins-bad-95011fd7e8eb3a2ec3a87ff9dad523d18005db42.zip |
New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as descri...
Original commit message from CVS:
New mimetypes gone into effect today - this commit changes all old mimetypes over to the new mimetypes spec as described in the previous commit's document. Note: some plugins will break, some pipelines will break, expect HEAD to be broken or at least not 100% working for a few days, but don't forget to report bugs
Diffstat (limited to 'ext')
34 files changed, 649 insertions, 695 deletions
diff --git a/ext/arts/gst_arts.c b/ext/arts/gst_arts.c index 482c91b4..fd2d1be3 100644 --- a/ext/arts/gst_arts.c +++ b/ext/arts/gst_arts.c @@ -47,9 +47,7 @@ GST_PAD_TEMPLATE_FACTORY ( sink_temp, GST_PAD_ALWAYS, GST_CAPS_NEW ( "arts_sample", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "depth", GST_PROPS_INT (16), "width", GST_PROPS_INT (16), "signed", GST_PROPS_BOOLEAN (TRUE), @@ -64,9 +62,7 @@ GST_PAD_TEMPLATE_FACTORY ( src_temp, GST_PAD_ALWAYS, GST_CAPS_NEW ( "arts_sample", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "depth", GST_PROPS_INT (16), "width", GST_PROPS_INT (16), "signed", GST_PROPS_BOOLEAN (TRUE), diff --git a/ext/artsd/gstartsdsink.c b/ext/artsd/gstartsdsink.c index 2847d8af..894b3cd5 100644 --- a/ext/artsd/gstartsdsink.c +++ b/ext/artsd/gstartsdsink.c @@ -45,9 +45,6 @@ enum { enum { ARG_0, ARG_MUTE, - ARG_DEPTH, - ARG_CHANNELS, - ARG_RATE, ARG_NAME, }; @@ -57,27 +54,24 @@ GST_PAD_TEMPLATE_FACTORY (sink_factory, GST_PAD_ALWAYS, /* ALWAYS/SOMETIMES */ GST_CAPS_NEW ( "artsdsink_sink", /* the name of the caps */ - "audio/raw", /* the mime type of the caps */ + "audio/x-raw-int", /* the mime type of the caps */ "format", GST_PROPS_STRING ("int"), "law", GST_PROPS_INT (0), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (FALSE), - "width", GST_PROPS_INT (8), - "depth", GST_PROPS_INT (8), + "width", GST_PROPS_LIST ( + GST_PROPS_INT (8), + GST_PROPS_INT (16) + ), + "depth", GST_PROPS_LIST ( + GST_PROPS_INT (8), + GST_PROPS_INT (16) + ), "rate", GST_PROPS_INT_RANGE (8000, 96000), - "channels", GST_PROPS_LIST (GST_PROPS_INT (1), GST_PROPS_INT (2)) - ), - GST_CAPS_NEW ( - "artsdsink_sink", /* the name of the caps */ - "audio/raw", /* the mime type of the caps */ - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT_RANGE (8000, 96000), - "channels", GST_PROPS_LIST (GST_PROPS_INT (1), GST_PROPS_INT (2)) + "channels", GST_PROPS_LIST ( + GST_PROPS_INT (1), + GST_PROPS_INT (2) + ) ) ); @@ -88,7 +82,7 @@ static gboolean gst_artsdsink_open_audio (GstArtsdsink *sink); static void gst_artsdsink_close_audio (GstArtsdsink *sink); static GstElementStateReturn gst_artsdsink_change_state (GstElement *element); static gboolean gst_artsdsink_sync_parms (GstArtsdsink *artsdsink); - +static GstPadLinkReturn gst_artsdsink_link (GstPad *pad, GstCaps *caps); static void gst_artsdsink_chain (GstPad *pad, GstBuffer *buf); static void gst_artsdsink_set_property (GObject *object, guint prop_id, @@ -96,39 +90,6 @@ static void gst_artsdsink_set_property (GObject *object, guint prop_id, static void gst_artsdsink_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); -#define GST_TYPE_ARTSDSINK_DEPTHS (gst_artsdsink_depths_get_type()) -static GType -gst_artsdsink_depths_get_type (void) -{ - static GType artsdsink_depths_type = 0; - static GEnumValue artsdsink_depths[] = { - {8, "8", "8 Bits"}, - {16, "16", "16 Bits"}, - {0, NULL, NULL}, - }; - if (!artsdsink_depths_type) { - artsdsink_depths_type = g_enum_register_static("GstArtsdsinkDepths", artsdsink_depths); - } - return artsdsink_depths_type; -} - -#define GST_TYPE_ARTSDSINK_CHANNELS (gst_artsdsink_channels_get_type()) -static GType -gst_artsdsink_channels_get_type (void) -{ - static GType artsdsink_channels_type = 0; - static GEnumValue artsdsink_channels[] = { - {1, "1", "Mono"}, - {2, "2", "Stereo"}, - {0, NULL, NULL}, - }; - if (!artsdsink_channels_type) { - artsdsink_channels_type = g_enum_register_static("GstArtsdsinkChannels", artsdsink_channels); - } - return artsdsink_channels_type; -} - - static GstElementClass *parent_class = NULL; /*static guint gst_artsdsink_signals[LAST_SIGNAL] = { 0 }; */ @@ -167,15 +128,7 @@ gst_artsdsink_class_init (GstArtsdsinkClass *klass) g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_MUTE, g_param_spec_boolean("mute","mute","mute", TRUE,G_PARAM_READWRITE)); /* CHECKME */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_DEPTH, - g_param_spec_enum("depth","depth","depth", - GST_TYPE_ARTSDSINK_DEPTHS,16,G_PARAM_READWRITE)); /* CHECKME! */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_CHANNELS, - g_param_spec_enum("channels","channels","channels", - GST_TYPE_ARTSDSINK_CHANNELS,2,G_PARAM_READWRITE)); /* CHECKME! */ - g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_RATE, - g_param_spec_int("frequency","frequency","frequency", - G_MININT,G_MAXINT,0,G_PARAM_READWRITE)); /* CHECKME */ + g_object_class_install_property(G_OBJECT_CLASS(klass), ARG_NAME, g_param_spec_string("name","name","name", NULL, G_PARAM_READWRITE)); /* CHECKME */ @@ -193,15 +146,10 @@ gst_artsdsink_init(GstArtsdsink *artsdsink) GST_PAD_TEMPLATE_GET (sink_factory), "sink"); gst_element_add_pad(GST_ELEMENT(artsdsink), artsdsink->sinkpad); gst_pad_set_chain_function(artsdsink->sinkpad, gst_artsdsink_chain); + gst_pad_set_link_function(artsdsink->sinkpad, gst_artsdsink_link); artsdsink->connected = FALSE; artsdsink->mute = FALSE; - - /* FIXME: get default from somewhere better than just putting them inline. */ - artsdsink->signd = TRUE; - artsdsink->depth = 16; - artsdsink->channels = 2; - artsdsink->frequency = 44100; artsdsink->connect_name = NULL; } @@ -218,6 +166,26 @@ gst_artsdsink_sync_parms (GstArtsdsink *artsdsink) return gst_artsdsink_open_audio (artsdsink); } +static GstPadLinkReturn +gst_artsdsink_link (GstPad *pad, GstCaps *caps) +{ + GstArtsdsink *artsdsink = GST_ARTSDSINK (gst_pad_get_parent (pad)); + + if (!GST_CAPS_FIXED (caps)) + return GST_PAD_LINK_DELAYED; + + gst_caps_get (caps, + "rate", &artsdsink->frequency, + "depth", &artsdsink->depth, + "signed", &artsdsink->signd, + "channels", &artsdsink->channels, + NULL); + + if (gst_artsdsink_sync_parms (artsdsink)) + return GST_PAD_LINK_OK; + + return GST_PAD_LINK_REFUSED; +} static void gst_artsdsink_chain (GstPad *pad, GstBuffer *buf) @@ -267,18 +235,6 @@ gst_artsdsink_set_property (GObject *object, guint prop_id, const GValue *value, case ARG_MUTE: artsdsink->mute = g_value_get_boolean (value); break; - case ARG_DEPTH: - artsdsink->depth = g_value_get_enum (value); - gst_artsdsink_sync_parms (artsdsink); - break; - case ARG_CHANNELS: - artsdsink->channels = g_value_get_enum (value); - gst_artsdsink_sync_parms (artsdsink); - break; - case ARG_RATE: - artsdsink->frequency = g_value_get_int (value); - gst_artsdsink_sync_parms (artsdsink); - break; case ARG_NAME: if (artsdsink->connect_name != NULL) g_free(artsdsink->connect_name); if (g_value_get_string (value) == NULL) @@ -304,15 +260,6 @@ gst_artsdsink_get_property (GObject *object, guint prop_id, GValue *value, GPara case ARG_MUTE: g_value_set_boolean (value, artsdsink->mute); break; - case ARG_DEPTH: - g_value_set_enum (value, artsdsink->depth); - break; - case ARG_CHANNELS: - g_value_set_enum (value, artsdsink->channels); - break; - case ARG_RATE: - g_value_set_int (value, artsdsink->frequency); - break; case ARG_NAME: g_value_set_string (value, artsdsink->connect_name); break; diff --git a/ext/audiofile/gstafparse.c b/ext/audiofile/gstafparse.c index 2ceb4ee7..255247e8 100644 --- a/ext/audiofile/gstafparse.c +++ b/ext/audiofile/gstafparse.c @@ -59,9 +59,7 @@ GST_PAD_TEMPLATE_FACTORY (afparse_src_factory, GST_PAD_ALWAYS, GST_CAPS_NEW ( "audiofile_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_LIST (GST_PROPS_BOOLEAN (TRUE), GST_PROPS_BOOLEAN (FALSE)), "width", GST_PROPS_INT_RANGE (8, 16), @@ -87,7 +85,7 @@ GST_PAD_TEMPLATE_FACTORY (afparse_sink_factory, ), GST_CAPS_NEW ( "afparse_sink_snd", - "audio/basic", + "audio/x-au", NULL ) ) @@ -215,7 +213,7 @@ gst_afparse_loop(GstElement *element) } if (bypass_afread){ - g_print("will bypass afReadFrames\n"); + GST_DEBUG("will bypass afReadFrames\n"); } frames_to_bytes = afparse->channels * afparse->width / 8; @@ -352,7 +350,7 @@ gst_afparse_open_file (GstAFParse *afparse) /* open the file */ - g_print("opening vfile %p\n", afparse->vfile); + GST_DEBUG("opening vfile %p\n", afparse->vfile); afparse->file = afOpenVirtualFile (afparse->vfile, "r", AF_NULL_FILESETUP); if (afparse->file == AF_NULL_FILEHANDLE) { @@ -361,7 +359,7 @@ gst_afparse_open_file (GstAFParse *afparse) return FALSE; } - g_print("vfile opened\n"); + GST_DEBUG("vfile opened\n"); /* get the audiofile audio parameters */ { int sampleFormat, sampleWidth; @@ -393,9 +391,7 @@ gst_afparse_open_file (GstAFParse *afparse) gst_pad_try_set_caps (afparse->srcpad, GST_CAPS_NEW ( "af_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), /*FIXME */ + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */ "signed", GST_PROPS_BOOLEAN (afparse->is_signed), "width", GST_PROPS_INT (afparse->width), @@ -444,22 +440,19 @@ gst_afparse_vf_read (AFvirtualfile *vfile, void *data, size_t nbytes) /*g_print("no event found with %u bytes\n", got_bytes);*/ return 0; } - if (event){ - g_print("got event\n"); - if (GST_EVENT_TYPE(event) == GST_EVENT_EOS){ + switch (GST_EVENT_TYPE(event)) { + case GST_EVENT_EOS: return 0; - } - else if (GST_EVENT_TYPE(event) == GST_EVENT_FLUSH){ - g_print("flush\n"); - } - else if (GST_EVENT_TYPE(event) == GST_EVENT_DISCONTINUOUS){ - g_print("seek done\n"); + case GST_EVENT_FLUSH: + GST_DEBUG("flush"); + break; + case GST_EVENT_DISCONTINUOUS: + GST_DEBUG("seek done"); got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes); - } - else { - g_print("unknown event %d", GST_EVENT_TYPE(event)); + break; + default: + g_warning("unknown event %d", GST_EVENT_TYPE(event)); got_bytes = gst_bytestream_peek_bytes(bs, &bytes, nbytes); - } } } @@ -493,7 +486,7 @@ gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative) } if (gst_bytestream_seek(bs, (gint64)offset, method)){ - g_print("doing seek to %d\n", (gint)offset); + GST_DEBUG("doing seek to %d", (gint)offset); return offset; } return 0; @@ -502,11 +495,12 @@ gst_afparse_vf_seek (AFvirtualfile *vfile, long offset, int is_relative) static long gst_afparse_vf_length (AFvirtualfile *vfile) { - /*GstByteStream *bs = (GstByteStream*)vfile->closure;*/ - /* FIXME there is currently no practical way to do this. - * wait for the events rewrite to drop */ - g_warning("cannot get length at the moment"); - return G_MAXLONG; + GstByteStream *bs = (GstByteStream*)vfile->closure; + guint64 length; + + length = gst_bytestream_length(bs); + GST_DEBUG("doing length: %" G_GUINT64_FORMAT, length); + return length; } static ssize_t @@ -522,7 +516,7 @@ gst_afparse_vf_destroy(AFvirtualfile *vfile) { /* GstByteStream *bs = (GstByteStream*)vfile->closure;*/ - g_print("doing destroy\n"); + GST_DEBUG("doing destroy"); } static long @@ -532,7 +526,7 @@ gst_afparse_vf_tell (AFvirtualfile *vfile) guint64 offset; offset = gst_bytestream_tell(bs); - g_print("doing tell: %" G_GUINT64_FORMAT "\n", offset); + GST_DEBUG("doing tell: %" G_GUINT64_FORMAT, offset); return offset; } diff --git a/ext/audiofile/gstafsink.c b/ext/audiofile/gstafsink.c index e9783ac2..3392717c 100644 --- a/ext/audiofile/gstafsink.c +++ b/ext/audiofile/gstafsink.c @@ -61,9 +61,7 @@ GST_PAD_TEMPLATE_FACTORY (afsink_sink_factory, GST_PAD_ALWAYS, GST_CAPS_NEW ( "audiofile_sink", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_LIST ( GST_PROPS_BOOLEAN (TRUE), diff --git a/ext/audiofile/gstafsrc.c b/ext/audiofile/gstafsrc.c index cf2ebb56..2b817310 100644 --- a/ext/audiofile/gstafsrc.c +++ b/ext/audiofile/gstafsrc.c @@ -60,9 +60,7 @@ GST_PAD_TEMPLATE_FACTORY (afsrc_src_factory, GST_PAD_ALWAYS, GST_CAPS_NEW ( "audiofile_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_LIST ( GST_PROPS_BOOLEAN (TRUE), @@ -345,9 +343,7 @@ gst_afsrc_open_file (GstAFSrc *src) gst_pad_try_set_caps (src->srcpad, GST_CAPS_NEW ( "af_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), /*FIXME */ + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), /*FIXME */ "signed", GST_PROPS_BOOLEAN (src->is_signed), "width", GST_PROPS_INT (src->width), diff --git a/ext/divx/gstdivxdec.c b/ext/divx/gstdivxdec.c index 0ee308b8..011836f9 100644 --- a/ext/divx/gstdivxdec.c +++ b/ext/divx/gstdivxdec.c @@ -43,28 +43,42 @@ GST_PAD_TEMPLATE_FACTORY(sink_template, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW("divxdec_sink", - "video/divx", - NULL) + GST_CAPS_NEW( + "divxdec_sink", + "video/x-divx", + "divxversion", GST_PROPS_INT_RANGE(3, 5), + "width", GST_PROPS_INT_RANGE(0, G_MAXINT), + "height", GST_PROPS_INT_RANGE(0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT) + ) ) GST_PAD_TEMPLATE_FACTORY(src_template, "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW("divxdec_src", - "video/raw", - "format", GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','Y','U','V')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT), - NULL) + gst_caps_new( + "divxdec_src", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( + GST_PROPS_LIST( + GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) + ) + ) + ), + gst_caps_new( + "divxdec_src_rgb1", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 + ), + gst_caps_new( + "divxdec_src_rgb2", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + ) ) @@ -87,6 +101,7 @@ static void gst_divxdec_chain (GstPad *pad, GstBuffer *buf); static GstPadLinkReturn gst_divxdec_connect (GstPad *pad, GstCaps *vscapslist); +static GstPadLinkReturn gst_divxdec_negotiate (GstDivxDec *divxdec); static GstElementClass *parent_class = NULL; /* static guint gst_divxdec_signals[LAST_SIGNAL] = { 0 }; */ @@ -261,10 +276,12 @@ gst_divxdec_chain (GstPad *pad, divxdec = GST_DIVXDEC(GST_OBJECT_PARENT(pad)); if (!divxdec->handle) { - gst_element_error(GST_ELEMENT(divxdec), - "No format set - aborting"); - gst_buffer_unref(buf); - return; + if (gst_divxdec_negotiate(divxdec) <= 0) { + gst_element_error(GST_ELEMENT(divxdec), + "No format set - aborting"); + gst_buffer_unref(buf); + return; + } } outbuf = gst_buffer_new_and_alloc(divxdec->width * @@ -297,10 +314,9 @@ gst_divxdec_chain (GstPad *pad, static GstPadLinkReturn -gst_divxdec_connect (GstPad *pad, - GstCaps *vscaps) +gst_divxdec_negotiate (GstDivxDec *divxdec) { - GstDivxDec *divxdec; + GstPadLinkReturn ret; GstCaps *caps; struct { guint32 fourcc; @@ -314,8 +330,6 @@ gst_divxdec_connect (GstPad *pad, GST_MAKE_FOURCC('U','Y','V','Y'), 0 }, { GST_MAKE_FOURCC('I','4','2','0'), 12, 12, GST_MAKE_FOURCC('I','4','2','0'), 0 }, - { GST_MAKE_FOURCC('I','Y','U','V'), 12, 12, - GST_MAKE_FOURCC('I','4','2','0'), 0 }, { GST_MAKE_FOURCC('Y','V','1','2'), 12, 12, GST_MAKE_FOURCC('Y','V','1','2'), 0 }, { GST_MAKE_FOURCC('R','G','B',' '), 32, 32, @@ -338,69 +352,59 @@ gst_divxdec_connect (GstPad *pad, }; gint i; - divxdec = GST_DIVXDEC(gst_pad_get_parent (pad)); - - /* if there's something old around, remove it */ - if (divxdec->handle) { - gst_divxdec_unset(divxdec); - } - - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED(vscaps)) - return GST_PAD_LINK_DELAYED; - - /* if we get here, we know the input is divx. we - * only need to bother with the output colorspace */ - gst_caps_get_int(vscaps, "width", &divxdec->width); - gst_caps_get_int(vscaps, "height", &divxdec->height); - for (i = 0; fmt_list[i].fourcc != 0; i++) { divxdec->csp = fmt_list[i].csp; /* try making a caps to set on the other side */ if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) { guint32 r_mask = 0, b_mask = 0, g_mask = 0; + gint endianness = 0; switch (fmt_list[i].depth) { case 15: + endianness = G_BYTE_ORDER; r_mask = 0xf800; g_mask = 0x07c0; b_mask = 0x003e; break; case 16: + endianness = G_BYTE_ORDER; r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f; break; case 24: - r_mask = 0xff0000; g_mask = 0x00ff00; b_mask = 0x0000ff; + endianness = G_BIG_ENDIAN; + r_mask = R_MASK_24; g_mask = G_MASK_24; b_mask = B_MASK_24; break; case 32: - r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00; + endianness = G_BIG_ENDIAN; + r_mask = R_MASK_32; g_mask = G_MASK_32; b_mask = B_MASK_32; break; } caps = GST_CAPS_NEW("divxdec_src_pad_rgb", - "video/raw", + "video/x-raw-rgb", "width", GST_PROPS_INT(divxdec->width), "height", GST_PROPS_INT(divxdec->height), - "format", GST_PROPS_FOURCC(fmt_list[i].fourcc), + "framerate", GST_PROPS_FLOAT(divxdec->fps), "depth", GST_PROPS_INT(fmt_list[i].depth), "bpp", GST_PROPS_INT(fmt_list[i].bpp), - "endianness", GST_PROPS_INT(G_BYTE_ORDER), + "endianness", GST_PROPS_INT(endianness), "red_mask", GST_PROPS_INT(r_mask), "green_mask", GST_PROPS_INT(g_mask), - "blue_mask", GST_PROPS_INT(b_mask), - NULL); + "blue_mask", GST_PROPS_INT(b_mask)); } else { caps = GST_CAPS_NEW("divxdec_src_pad_yuv", - "video/raw", + "video/x-raw-yuv", "width", GST_PROPS_INT(divxdec->width), "height", GST_PROPS_INT(divxdec->height), - "format", GST_PROPS_FOURCC(fmt_list[i].fourcc), - NULL); + "framerate", GST_PROPS_FLOAT(divxdec->fps), + "format", GST_PROPS_FOURCC(fmt_list[i].fourcc)); } - if (gst_pad_try_set_caps(divxdec->srcpad, caps) > 0) { + if ((ret = gst_pad_try_set_caps(divxdec->srcpad, caps)) > 0) { divxdec->csp = fmt_list[i].csp; divxdec->bpp = fmt_list[i].bpp; divxdec->bitcnt = fmt_list[i].bitcnt; if (gst_divxdec_setup(divxdec)) return GST_PAD_LINK_OK; + } else if (ret == GST_PAD_LINK_DELAYED) { + return ret; /* trying more is useless */ } } @@ -409,6 +413,33 @@ gst_divxdec_connect (GstPad *pad, } +static GstPadLinkReturn +gst_divxdec_connect (GstPad *pad, + GstCaps *vscaps) +{ + GstDivxDec *divxdec; + + divxdec = GST_DIVXDEC(gst_pad_get_parent (pad)); + + /* if there's something old around, remove it */ + if (divxdec->handle) { + gst_divxdec_unset(divxdec); + } + + /* we are not going to act on variable caps */ + if (!GST_CAPS_IS_FIXED(vscaps)) + return GST_PAD_LINK_DELAYED; + + /* if we get here, we know the input is divx. we + * only need to bother with the output colorspace */ + gst_caps_get_int(vscaps, "width", &divxdec->width); + gst_caps_get_int(vscaps, "height", &divxdec->height); + gst_caps_get_float(vscaps, "framerate", &divxdec->fps); + + return gst_divxdec_negotiate(divxdec); +} + + static gboolean plugin_init (GModule *module, GstPlugin *plugin) diff --git a/ext/divx/gstdivxdec.h b/ext/divx/gstdivxdec.h index 35876bdb..9f1da3ff 100644 --- a/ext/divx/gstdivxdec.h +++ b/ext/divx/gstdivxdec.h @@ -55,6 +55,7 @@ struct _GstDivxDec { guint32 csp; int bitcnt, bpp; int width, height; + float fps; }; struct _GstDivxDecClass { diff --git a/ext/divx/gstdivxenc.c b/ext/divx/gstdivxenc.c index 24a26684..bd7547a1 100644 --- a/ext/divx/gstdivxenc.c +++ b/ext/divx/gstdivxenc.c @@ -44,28 +44,43 @@ GST_PAD_TEMPLATE_FACTORY(sink_template, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW("divxenc_sink", - "video/raw", - "format", GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','Y','U','V')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT), - NULL) + gst_caps_new( + "divxdec_src", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS( + GST_PROPS_LIST( + GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) + ) + ) + ), + gst_caps_new( + "divxdec_src_rgb1", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 + ), + gst_caps_new( + "divxdec_src_rgb2", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + ) ) GST_PAD_TEMPLATE_FACTORY(src_template, "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW("divxenc_src", - "video/divx", - NULL) + GST_CAPS_NEW( + "divxenc_sink", + "video/x-divx", + "divxversion", GST_PROPS_INT(5), + "width", GST_PROPS_INT_RANGE(0, G_MAXINT), + "height", GST_PROPS_INT_RANGE(0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE(0, G_MAXFLOAT) + ) ) @@ -246,11 +261,8 @@ gst_divxenc_setup (GstDivxEnc *divxenc) void *handle = NULL; SETTINGS output; DivXBitmapInfoHeader input; - gdouble fps; int ret; - fps = gst_video_frame_rate(GST_PAD_PEER(divxenc->sinkpad)); - /* set it up */ memset(&input, 0, sizeof(DivXBitmapInfoHeader)); input.biSize = sizeof(DivXBitmapInfoHeader); @@ -266,9 +278,9 @@ gst_divxenc_setup (GstDivxEnc *divxenc) output.use_bidirect = 0; output.input_clock = 0; output.input_frame_period = 1000000; - output.internal_timescale = fps * 1000000; + output.internal_timescale = divxenc->fps * 1000000; output.max_key_interval = (divxenc->max_key_interval == -1) ? - (2 * fps) : + (2 * divxenc->fps) : divxenc->max_key_interval; output.key_frame_threshold = 0; output.vbv_bitrate = 0; @@ -340,13 +352,6 @@ gst_divxenc_chain (GstPad *pad, divxenc = GST_DIVXENC(GST_OBJECT_PARENT(pad)); - if (!divxenc->handle) { - if (!gst_divxenc_setup(divxenc)) { - gst_buffer_unref(buf); - return; - } - } - outbuf = gst_buffer_new_and_alloc(divxenc->buffer_size); GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); @@ -397,21 +402,21 @@ gst_divxenc_connect (GstPad *pad, return GST_PAD_LINK_DELAYED; for (caps = vscaps; caps != NULL; caps = caps->next) { - int w,h,d; + gint w,h,d; + gfloat fps; guint32 fourcc; guint32 divx_cs; gint bitcnt = 0; gst_caps_get_int(caps, "width", &w); gst_caps_get_int(caps, "height", &h); + gst_caps_get_float(caps, "framerate", &fps); gst_caps_get_fourcc_int(caps, "format", &fourcc); switch (fourcc) { case GST_MAKE_FOURCC('I','4','2','0'): - case GST_MAKE_FOURCC('I','Y','U','V'): divx_cs = GST_MAKE_FOURCC('I','4','2','0'); break; case GST_MAKE_FOURCC('Y','U','Y','2'): - case GST_MAKE_FOURCC('Y','U','Y','V'): divx_cs = GST_MAKE_FOURCC('Y','U','Y','2'); break; case GST_MAKE_FOURCC('Y','V','1','2'): @@ -442,18 +447,32 @@ gst_divxenc_connect (GstPad *pad, goto trynext; } - /* grmbl, we only know the peer pad *after* - * linking, so we accept here, get the fps on - * the first cycle and set it all up then */ divxenc->csp = divx_cs; divxenc->bitcnt = bitcnt; divxenc->width = w; divxenc->height = h; - return gst_pad_try_set_caps(divxenc->srcpad, - GST_CAPS_NEW("divxenc_src_caps", - "video/divx", - "width", GST_PROPS_INT(w), - "height", GST_PROPS_INT(h))); + divxenc->fps = fps; + + /* try it */ + if (gst_divxenc_setup(divxenc)) { + GstPadLinkReturn ret; + GstCaps *new_caps; + + new_caps = GST_CAPS_NEW("divxenc_src_caps", + "video/x-divx", + "divxversion", GST_PROPS_INT(5), + "width", GST_PROPS_INT(w), + "height", GST_PROPS_INT(h), + "framerate", GST_PROPS_FLOAT(fps)); + + ret = gst_pad_try_set_caps(divxenc->srcpad, new_caps); + + if (ret <= 0) { + gst_divxenc_unset(divxenc); + } + + return ret; + } trynext: continue; diff --git a/ext/divx/gstdivxenc.h b/ext/divx/gstdivxenc.h index be1ddae5..206659d3 100644 --- a/ext/divx/gstdivxenc.h +++ b/ext/divx/gstdivxenc.h @@ -64,6 +64,7 @@ struct _GstDivxEnc { guint32 csp; gint bitcnt; gint width, height; + gfloat fps; }; struct _GstDivxEncClass { diff --git a/ext/gsm/gstgsm.c b/ext/gsm/gstgsm.c index 32225ff7..e50dec2b 100644 --- a/ext/gsm/gstgsm.c +++ b/ext/gsm/gstgsm.c @@ -32,16 +32,15 @@ GST_CAPS_FACTORY (gsm_caps_factory, GST_CAPS_NEW ( "gsm_gsm", "audio/x-gsm", - "rate", GST_PROPS_INT_RANGE (1000, 48000) + "rate", GST_PROPS_INT_RANGE (1000, 48000), + "channels", GST_PROPS_INT (1) ) ) GST_CAPS_FACTORY (raw_caps_factory, GST_CAPS_NEW ( "gsm_raw", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), diff --git a/ext/gsm/gstgsmdec.c b/ext/gsm/gstgsmdec.c index 957b832d..e857feff 100644 --- a/ext/gsm/gstgsmdec.c +++ b/ext/gsm/gstgsmdec.c @@ -122,9 +122,7 @@ gst_gsmdec_sinkconnect (GstPad *pad, GstCaps *caps) if (gst_pad_try_set_caps (gsmdec->srcpad, GST_CAPS_NEW ( "gsm_raw", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), + "audio/x-raw-int", "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), diff --git a/ext/gsm/gstgsmenc.c b/ext/gsm/gstgsmenc.c index 2b25042f..9a41430b 100644 --- a/ext/gsm/gstgsmenc.c +++ b/ext/gsm/gstgsmenc.c @@ -131,7 +131,8 @@ gst_gsmenc_sinkconnect (GstPad *pad, GstCaps *caps) if (gst_pad_try_set_caps (gsmenc->srcpad, GST_CAPS_NEW ( "gsm_gsm", "audio/x-gsm", - "rate", GST_PROPS_INT (gsmenc->rate) + "rate", GST_PROPS_INT (gsmenc->rate), + "channels", GST_PROPS_INT (1) )) > 0) { return GST_PAD_LINK_OK; @@ -158,7 +159,8 @@ gst_gsmenc_chain (GstPad *pad, GstBuffer *buf) GST_CAPS_NEW ( "gsm_enc", "audio/x-gsm", - "rate", GST_PROPS_INT (gsmenc->rate) + "rate", GST_PROPS_INT (gsmenc->rate), + "channels", GST_PROPS_INT (1) )); } diff --git a/ext/hermes/gstcolorspace.c b/ext/hermes/gstcolorspace.c index 7e99a749..86b3fc6b 100644 --- a/ext/hermes/gstcolorspace.c +++ b/ext/hermes/gstcolorspace.c @@ -21,6 +21,7 @@ #include "config.h" #endif #include <gst/gst.h> +#include <gst/video/video.h> #include "gstcolorspace.h" #include "yuv2rgb.h" @@ -50,42 +51,6 @@ enum { ARG_DEST, }; -GST_PAD_TEMPLATE_FACTORY (colorspace_src_template_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_src", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - -GST_PAD_TEMPLATE_FACTORY (colorspace_sink_template_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_sink", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - static void gst_colorspace_class_init (GstColorspaceClass *klass); static void gst_colorspace_init (GstColorspace *space); @@ -110,6 +75,7 @@ extern void gst_colorspace_rgb32_to_i420 (unsigned char *src, unsigned char *de extern void gst_colorspace_rgb32_to_yv12 (unsigned char *src, unsigned char *dest, guint width, guint height); +static GstPadTemplate *srctempl, *sinktempl; static GstElementClass *parent_class = NULL; /*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */ @@ -134,10 +100,20 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t g_return_val_if_fail (to_caps != NULL, FALSE); g_return_val_if_fail (from_caps != NULL, FALSE); - gst_caps_get_fourcc_int (from_caps, "format", &from_space); - gst_caps_get_fourcc_int (to_caps, "format", &to_space); + if (gst_caps_has_property (from_caps, "format")) + gst_caps_get_fourcc_int (from_caps, "format", &from_space); + else + from_space = GST_MAKE_FOURCC ('R','G','B',' '); + + if (gst_caps_has_property (to_caps, "format")) + gst_caps_get_fourcc_int (to_caps, "format", &to_space); + else + to_space = GST_MAKE_FOURCC ('R','G','B',' '); - GST_INFO ( "set up converter for %08x to %08x", from_space, to_space); + GST_INFO ("set up converter for " GST_FOURCC_FORMAT + " (%08x) to " GST_FOURCC_FORMAT " (%08x)", + GST_FOURCC_ARGS (from_space), from_space, + GST_FOURCC_ARGS (to_space), to_space); switch (from_space) { case GST_MAKE_FOURCC ('R','G','B',' '): @@ -308,6 +284,7 @@ gst_colorspace_sinkconnect (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &space->width); gst_caps_get_int (caps, "height", &space->height); + gst_caps_get_float (caps, "framerate", &space->fps); GST_INFO ( "size: %dx%d", space->width, space->height); @@ -367,12 +344,20 @@ gst_colorspace_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps) gst_caps_unref (peercaps); } - to_intersect = GST_CAPS_NEW ( + to_intersect = gst_caps_append ( + GST_CAPS_NEW ( "colorspace_filter", - "video/raw", - "width", GST_PROPS_INT (space->width), - "height", GST_PROPS_INT (space->height) - ); + "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 ( + "colorspace_filter", + "video/x-raw-rgb", + "width", GST_PROPS_INT (space->width), + "height", GST_PROPS_INT (space->height), + "framerate", GST_PROPS_FLOAT (space->fps) + )); /* then see what the peer has that matches the size */ peercaps = gst_caps_intersect (caps, to_intersect); @@ -456,16 +441,14 @@ gst_colorspace_class_init (GstColorspaceClass *klass) static void gst_colorspace_init (GstColorspace *space) { - space->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory), "sink"); + space->sinkpad = gst_pad_new_from_template (sinktempl, "sink"); gst_pad_set_link_function (space->sinkpad, gst_colorspace_sinkconnect); gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps); gst_pad_set_bufferpool_function (space->sinkpad, colorspace_get_bufferpool); gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain); gst_element_add_pad(GST_ELEMENT(space),space->sinkpad); - space->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory), "src"); + space->srcpad = gst_pad_new_from_template (srctempl, "src"); gst_element_add_pad(GST_ELEMENT(space),space->srcpad); gst_pad_set_link_function (space->srcpad, gst_colorspace_srcconnect); @@ -623,6 +606,7 @@ static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; + GstCaps *caps; #ifdef HAVE_HERMES gint hermes_res; @@ -634,11 +618,37 @@ plugin_init (GModule *module, GstPlugin *plugin) &colorspace_details); g_return_val_if_fail (factory != NULL, FALSE); gst_element_factory_set_rank (factory, GST_ELEMENT_RANK_PRIMARY); - - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory)); - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory)); + + /* create caps for templates */ + caps = gst_caps_new ("csp_templ_yuv", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))))); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb24_32", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32)); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb15_16", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16)); + + /* build templates */ + srctempl = gst_pad_template_new ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + caps, NULL); + gst_caps_ref (caps); + sinktempl = gst_pad_template_new ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + caps, NULL); + + gst_element_factory_add_pad_template (factory, srctempl); + gst_element_factory_add_pad_template (factory, sinktempl); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); diff --git a/ext/hermes/gstcolorspace.h b/ext/hermes/gstcolorspace.h index 37a80c5c..45371c72 100644 --- a/ext/hermes/gstcolorspace.h +++ b/ext/hermes/gstcolorspace.h @@ -76,6 +76,7 @@ struct _GstColorspace { GstColorSpaceConverterType type; gint width, height; + gfloat fps; gint srcbpp, destbpp; gboolean disabled; diff --git a/ext/ivorbis/vorbis.c b/ext/ivorbis/vorbis.c index b543f88f..4a95c14e 100644 --- a/ext/ivorbis/vorbis.c +++ b/ext/ivorbis/vorbis.c @@ -37,7 +37,7 @@ vorbis_caps_factory (void) return gst_caps_new ( "tremor_tremor", - "application/x-ogg", + "application/ogg", NULL); } @@ -47,10 +47,8 @@ raw_caps_factory (void) return gst_caps_new ( "tremor_raw", - "audio/raw", + "audio/x-raw-int", gst_props_new ( - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), "endianness", GST_PROPS_INT (G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN (TRUE), "width", GST_PROPS_INT (16), @@ -66,18 +64,18 @@ raw_caps2_factory (void) return gst_caps_new ( "tremor_raw_float", - "audio/raw", + "audio/x-raw-float", gst_props_new ( - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("IEEE"), + "depth", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), "rate", GST_PROPS_INT_RANGE (11025, 48000), - "channels", GST_PROPS_INT (2), + "channels", GST_PROPS_INT (2), /* ?? */ NULL)); } static GstTypeDefinition vorbisdefinition = { "tremor_audio/x-ogg", - "application/x-ogg", + "application/ogg", ".ogg", vorbis_type_find, }; @@ -90,7 +88,7 @@ vorbis_type_find (GstBuffer *buf, gpointer private) if (head != 0x4F676753) return NULL; - return gst_caps_new ("vorbis_type_find", "application/x-ogg", NULL); + return gst_caps_new ("vorbis_type_find", "application/ogg", NULL); } diff --git a/ext/ivorbis/vorbisfile.c b/ext/ivorbis/vorbisfile.c index 76763f22..3e869e1d 100644 --- a/ext/ivorbis/vorbisfile.c +++ b/ext/ivorbis/vorbisfile.c @@ -82,7 +82,7 @@ GstElementDetails ivorbisfile_details = "GPL", "Decodes OGG Vorbis audio using the Tremor vorbisfile API", VERSION, - "Monty <monty@xiph.org>, " + "Monty <monty@xiph.org>\n" "Wim Taymans <wim.taymans@chello.be>", "(C) 2000", }; @@ -448,26 +448,24 @@ static gboolean gst_ivorbisfile_new_link (Ivorbisfile *ivorbisfile, gint link) { vorbis_info *vi = ov_info (&ivorbisfile->vf, link); + GstCaps *newcaps; /* new logical bitstream */ ivorbisfile->current_link = link; gst_ivorbisfile_update_metadata (ivorbisfile, link); gst_ivorbisfile_update_streaminfo (ivorbisfile, link); - - if (gst_pad_try_set_caps (ivorbisfile->srcpad, - GST_CAPS_NEW ("vorbisdec_src", - "audio/raw", - "format", GST_PROPS_STRING ("int"), - "law", GST_PROPS_INT (0), - "endianness", GST_PROPS_INT (G_BYTE_ORDER), - "signed", GST_PROPS_BOOLEAN (TRUE), - "width", GST_PROPS_INT (16), - "depth", GST_PROPS_INT (16), - "rate", GST_PROPS_INT (vi->rate), - "channels", GST_PROPS_INT (vi->channels) - )) <= 0) - { + + newcaps = GST_CAPS_NEW ("vorbisdec_src", + "audio/x-raw-int", + "endianness", GST_PROPS_INT (G_BYTE_ORDER), + "signed", GST_PROPS_BOOLEAN (TRUE), + "width", GST_PROPS_INT (16), + "depth", GST_PROPS_INT (16), + "rate", GST_PROPS_INT (vi->rate), + "channels", GST_PROPS_INT (vi->channels) + ); + if (gst_pad_try_set_caps (ivorbisfile->srcpad, newcaps) <= 0) { return FALSE; } diff --git a/ext/jack/gstjack.c b/ext/jack/gstjack.c index 8db6c56b..700cf0ae 100644 --- a/ext/jack/gstjack.c +++ b/ext/jack/gstjack.c @@ -167,11 +167,14 @@ gst_jack_src_request_pad_factory(void) { static GstPadTemplate *template = NULL; - if (!template) - template = gst_pad_template_new("%s", GST_PAD_SRC, GST_PAD_REQUEST, - gst_caps_new("src", "audio/raw", - GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS), - NULL); + if (!template) { + GstCaps *caps; + caps = gst_caps_new("src", + "audio/x-raw-float", + GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS); + template = gst_pad_template_new("%s", GST_PAD_SRC, + GST_PAD_REQUEST, caps, NULL); + } return template; } @@ -181,11 +184,14 @@ gst_jack_sink_request_pad_factory(void) { static GstPadTemplate *template = NULL; - if (!template) - template = gst_pad_template_new("%s", GST_PAD_SINK, GST_PAD_REQUEST, - gst_caps_new("sink", "audio/raw", - GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS), - NULL); + if (!template) { + GstCaps *caps; + caps = gst_caps_new ("sink", + "audio/x-raw-float", + GST_AUDIO_FLOAT_MONO_PAD_TEMPLATE_PROPS); + template = gst_pad_template_new("%s", GST_PAD_SINK, + GST_PAD_REQUEST, caps, NULL); + } return template; } diff --git a/ext/ladspa/gstladspa.c b/ext/ladspa/gstladspa.c index 55c0186d..ddaa7970 100644 --- a/ext/ladspa/gstladspa.c +++ b/ext/ladspa/gstladspa.c @@ -33,10 +33,10 @@ GST_PAD_TEMPLATE_FACTORY (ladspa_sink_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "ladspa_sink", - "audio/raw", + "audio/x-raw-float", + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), "rate", GST_PROPS_INT_RANGE (4000, 96000), - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("gfloat"), "intercept", GST_PROPS_FLOAT(0.0), "slope", GST_PROPS_FLOAT(1.0), "channels", GST_PROPS_INT (1) @@ -49,10 +49,10 @@ GST_PAD_TEMPLATE_FACTORY (ladspa_src_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "ladspa_src", - "audio/raw", + "audio/x-raw-float", + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), "rate", GST_PROPS_INT_RANGE (4000, 96000), - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("gfloat"), "intercept", GST_PROPS_FLOAT (0.0), "slope", GST_PROPS_FLOAT (1.0), "channels", GST_PROPS_INT (1) @@ -542,10 +542,10 @@ gst_ladspa_force_src_caps(GstLADSPA *ladspa, GstPad *pad) GST_DEBUG ("forcing caps with rate %d", ladspa->samplerate); gst_pad_try_set_caps (pad, gst_caps_new ( "ladspa_src_caps", - "audio/raw", + "audio/x-raw-float", gst_props_new ( - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("gfloat"), + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER), "intercept", GST_PROPS_FLOAT(0.0), "slope", GST_PROPS_FLOAT(1.0), "rate", GST_PROPS_INT (ladspa->samplerate), diff --git a/ext/lcs/gstcolorspace.c b/ext/lcs/gstcolorspace.c index c457f9a7..0ed3b278 100644 --- a/ext/lcs/gstcolorspace.c +++ b/ext/lcs/gstcolorspace.c @@ -21,6 +21,7 @@ #include "config.h" #endif #include <gst/gst.h> +#include <gst/video/video.h> #include <lcs/lcs.h> #define GST_TYPE_COLORSPACE \ @@ -51,6 +52,7 @@ struct _GstColorspace { GstColorSpaceConverterType type; gint width, height; + gfloat fps; gboolean disabled; GstCaps *sinkcaps; @@ -86,42 +88,6 @@ enum { ARG_DEST, }; -GST_PAD_TEMPLATE_FACTORY (colorspace_src_template_factory, - "src", - GST_PAD_SRC, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_src", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - -GST_PAD_TEMPLATE_FACTORY (colorspace_sink_template_factory, - "sink", - GST_PAD_SINK, - GST_PAD_ALWAYS, - GST_CAPS_NEW ( - "colorspace_sink", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")) - ), - "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) - ) -) - static GType gst_colorspace_get_type (void); static void gst_colorspace_class_init (GstColorspaceClass *klass); @@ -142,6 +108,7 @@ static void gst_colorspace_chain (GstPad *pad, GstBuffer *buf); static GstElementStateReturn gst_colorspace_change_state (GstElement *element); +static GstPadTemplate *srctempl, *sinktempl; static GstElementClass *parent_class = NULL; /*static guint gst_colorspace_signals[LAST_SIGNAL] = { 0 }; */ @@ -207,8 +174,15 @@ colorspace_setup_converter (GstColorspace *space, GstCaps *from_caps, GstCaps *t g_return_val_if_fail (to_caps != NULL, FALSE); g_return_val_if_fail (from_caps != NULL, FALSE); - gst_caps_get_fourcc_int (from_caps, "format", &from_space); - gst_caps_get_fourcc_int (to_caps, "format", &to_space); + if (gst_caps_has_property (from_caps, "format")) + gst_caps_get_fourcc_int (from_caps, "format", &from_space); + else + from_space = GST_MAKE_FOURCC ('R','G','B',' '); + + if (gst_caps_has_property (to_caps, "format")) + gst_caps_get_fourcc_int (to_caps, "format", &to_space); + else + to_space = GST_MAKE_FOURCC ('R','G','B',' '); from_format = colorspace_find_lcs_format (from_caps); to_format = colorspace_find_lcs_format (to_caps); @@ -260,6 +234,7 @@ gst_colorspace_sinkconnect (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &space->width); gst_caps_get_int (caps, "height", &space->height); + gst_caps_get_float (caps, "framerate", &space->fps); GST_INFO ( "size: %dx%d", space->width, space->height); @@ -313,12 +288,20 @@ gst_colorspace_srcconnect_func (GstPad *pad, GstCaps *caps, gboolean newcaps) } /* then see what the peer has that matches the size */ peercaps = gst_caps_intersect (caps, + gst_caps_append ( GST_CAPS_NEW ( "colorspace_filter", - "video/raw", - "width", GST_PROPS_INT (space->width), - "height", GST_PROPS_INT (space->height) - )); + "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 ( + "colorspace_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); @@ -384,16 +367,14 @@ gst_colorspace_class_init (GstColorspaceClass *klass) static void gst_colorspace_init (GstColorspace *space) { - space->sinkpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory), "sink"); + space->sinkpad = gst_pad_new_from_template (sinktempl, "sink"); gst_pad_set_link_function (space->sinkpad, gst_colorspace_sinkconnect); gst_pad_set_getcaps_function (space->sinkpad, gst_colorspace_getcaps); gst_pad_set_bufferpool_function (space->sinkpad, colorspace_get_bufferpool); gst_pad_set_chain_function(space->sinkpad,gst_colorspace_chain); gst_element_add_pad(GST_ELEMENT(space),space->sinkpad); - space->srcpad = gst_pad_new_from_template ( - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory), "src"); + space->srcpad = gst_pad_new_from_template (srctempl, "src"); gst_element_add_pad(GST_ELEMENT(space),space->srcpad); gst_pad_set_link_function (space->srcpad, gst_colorspace_srcconnect); @@ -511,17 +492,44 @@ static gboolean plugin_init (GModule *module, GstPlugin *plugin) { GstElementFactory *factory; + GstCaps *caps; lcs_init (NULL, NULL); factory = gst_element_factory_new ("colorspacelcs", GST_TYPE_COLORSPACE, &colorspace_details); g_return_val_if_fail (factory != NULL, FALSE); - - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_src_template_factory)); - gst_element_factory_add_pad_template (factory, - GST_PAD_TEMPLATE_GET (colorspace_sink_template_factory)); + + /* create caps for templates */ + caps = gst_caps_new ("csp_templ_yuv", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YV12")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2"))))); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb24_32", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32)); + caps = gst_caps_append (caps, + gst_caps_new ("csp_templ_rgb15_16", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16)); + + /* build templates */ + srctempl = gst_pad_template_new ("src", + GST_PAD_SRC, + GST_PAD_ALWAYS, + caps, NULL); + gst_caps_ref (caps); + sinktempl = gst_pad_template_new ("sink", + GST_PAD_SINK, + GST_PAD_ALWAYS, + caps, NULL); + + gst_element_factory_add_pad_template (factory, srctempl); + gst_element_factory_add_pad_template (factory, sinktempl); gst_plugin_add_feature (plugin, GST_PLUGIN_FEATURE (factory)); @@ -534,11 +542,3 @@ GstPluginDesc plugin_desc = { "colorspacelcs", plugin_init }; - - - - - - - - diff --git a/ext/libfame/gstfamedec.c b/ext/libfame/gstfamedec.c index 03805f84..3cfa2869 100644 --- a/ext/libfame/gstfamedec.c +++ b/ext/libfame/gstfamedec.c @@ -24,6 +24,7 @@ #include <string.h> #include "gstlibfame.h" +#include <gst/video/video.h> #define FAMEENC_BUFFER_SIZE (300 * 1024) @@ -51,7 +52,6 @@ enum { enum { ARG_0, ARG_VERSION, - ARG_FRAMERATE, ARG_BITRATE, ARG_QUALITY, ARG_PATTERN, @@ -67,12 +67,11 @@ GST_PAD_TEMPLATE_FACTORY (sink_template_factory, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "famedec_sink_caps", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096) + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0'))) ) ) @@ -83,72 +82,15 @@ GST_PAD_TEMPLATE_FACTORY (src_template_factory, GST_CAPS_NEW ( "famedec_src_caps", "video/mpeg", - "mpegversion", GST_PROPS_LIST ( - GST_PROPS_INT (1), GST_PROPS_INT (4)), + /* we don't need width/height/framerate */ + "mpegversion", GST_PROPS_LIST ( + GST_PROPS_INT (1), + GST_PROPS_INT (4) + ), "systemstream", GST_PROPS_BOOLEAN (FALSE) ) ); -#define MAX_FRAME_RATES 16 -typedef struct -{ - gint num; - gint den; -} frame_rate_entry; - -static const frame_rate_entry frame_rates[] = -{ - { 0, 0 }, - { 24000, 1001 }, - { 24, 1 }, - { 25, 1 }, - { 30000, 1001 }, - { 30, 1 }, - { 50, 1 }, - { 60000, 1001 }, - { 60, 1 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, -}; - -static gint -framerate_to_index (num, den) -{ - gint i; - - for (i = 0; i < MAX_FRAME_RATES; i++) { - if (frame_rates[i].num == num && frame_rates[i].den == den) - return i; - } - return 0; -} - -#define GST_TYPE_FAMEENC_FRAMERATE (gst_famedec_framerate_get_type()) -static GType -gst_famedec_framerate_get_type(void) { - static GType famedec_framerate_type = 0; - static GEnumValue famedec_framerate[] = { - {1, "1", "24000/1001 (23.97)"}, - {2, "2", "24"}, - {3, "3", "25"}, - {4, "4", "30000/1001 (29.97)"}, - {5, "5", "30"}, - {6, "6", "50"}, - {7, "7", "60000/1001 (59.94)"}, - {8, "8", "60"}, - {0, NULL, NULL}, - }; - if (!famedec_framerate_type) { - famedec_framerate_type = g_enum_register_static("GstFameEncFrameRate", famedec_framerate); - } - return famedec_framerate_type; -} - static void gst_famedec_class_init (GstFameEncClass *klass); static void gst_famedec_init (GstFameEnc *famedec); static void gst_famedec_dispose (GObject *object); @@ -276,9 +218,6 @@ gst_famedec_class_init (GstFameEncClass *klass) } } - g_object_class_install_property (gobject_class, ARG_FRAMERATE, - g_param_spec_enum ("framerate", "Frame Rate", "Number of frames per second", - GST_TYPE_FAMEENC_FRAMERATE, 3, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_BITRATE, g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)", 0, 5000000, 0, G_PARAM_READWRITE)); @@ -471,14 +410,6 @@ gst_famedec_set_property (GObject *object, guint prop_id, } switch (prop_id) { - case ARG_FRAMERATE: - { - gint index = g_value_get_enum (value); - - famedec->fp.frame_rate_num = frame_rates[index].num; - famedec->fp.frame_rate_den = frame_rates[index].den; - break; - } case ARG_BITRATE: famedec->fp.bitrate = g_value_get_int (value); break; @@ -525,13 +456,6 @@ gst_famedec_get_property (GObject *object, guint prop_id, famedec = GST_FAMEENC (object); switch (prop_id) { - case ARG_FRAMERATE: - { - gint index = framerate_to_index (famedec->fp.frame_rate_num, - famedec->fp.frame_rate_den); - g_value_set_enum (value, index); - break; - } case ARG_BITRATE: g_value_set_int (value, famedec->fp.bitrate); break; diff --git a/ext/libfame/gstlibfame.c b/ext/libfame/gstlibfame.c index 45ffee4e..5d7be473 100644 --- a/ext/libfame/gstlibfame.c +++ b/ext/libfame/gstlibfame.c @@ -22,8 +22,10 @@ #endif #include <fame.h> #include <string.h> +#include <math.h> #include "gstlibfame.h" +#include <gst/video/video.h> #define FAMEENC_BUFFER_SIZE (300 * 1024) @@ -50,7 +52,6 @@ enum { enum { ARG_0, ARG_VERSION, - ARG_FRAMERATE, ARG_BITRATE, ARG_QUALITY, ARG_PATTERN, @@ -66,12 +67,11 @@ GST_PAD_TEMPLATE_FACTORY (sink_template_factory, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "fameenc_sink_caps", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0')), - "width", GST_PROPS_INT_RANGE (16, 4096), - "height", GST_PROPS_INT_RANGE (16, 4096) + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_FOURCC (GST_MAKE_FOURCC ('I','4','2','0'))) ) ) @@ -82,13 +82,27 @@ GST_PAD_TEMPLATE_FACTORY (src_template_factory, GST_CAPS_NEW ( "fameenc_src_caps", "video/mpeg", - "mpegversion", GST_PROPS_LIST ( - GST_PROPS_INT (1), GST_PROPS_INT (4)), - "systemstream", GST_PROPS_BOOLEAN (FALSE) + "mpegversion", GST_PROPS_LIST ( + GST_PROPS_INT (1), + GST_PROPS_INT (4) + ), + "systemstream", GST_PROPS_BOOLEAN (FALSE), + "width", GST_PROPS_INT_RANGE (16, 4096), + "height", GST_PROPS_INT_RANGE (16, 4096), + "framerate", GST_PROPS_LIST ( + GST_PROPS_FLOAT (24/1.001), + GST_PROPS_FLOAT (24.), + GST_PROPS_FLOAT (25.), + GST_PROPS_FLOAT (30/1.001), + GST_PROPS_FLOAT (30.), + GST_PROPS_FLOAT (50.), + GST_PROPS_FLOAT (60/1.001), + GST_PROPS_FLOAT (60.) + ) ) ); -#define MAX_FRAME_RATES 16 +#define MAX_FRAME_RATES 9 typedef struct { gint num; @@ -106,46 +120,30 @@ static const frame_rate_entry frame_rates[] = { 50, 1 }, { 60000, 1001 }, { 60, 1 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, - { 0, 0 }, }; static gint -framerate_to_index (num, den) +framerate_to_index (gfloat fps) { gint i; + gint idx = -1; - for (i = 0; i < MAX_FRAME_RATES; i++) { - if (frame_rates[i].num == num && frame_rates[i].den == den) - return i; + for (i = 1; i < MAX_FRAME_RATES; i++) { + if (idx == -1) { + idx = i; + } else { + gfloat old_diff = fabs((1. * frame_rates[idx].num / + frame_rates[idx].den) - fps), + new_diff = fabs((1. * frame_rates[i].num / + frame_rates[i].den) - fps); + + if (new_diff < old_diff) { + idx = i; + } + } } - return 0; -} -#define GST_TYPE_FAMEENC_FRAMERATE (gst_fameenc_framerate_get_type()) -static GType -gst_fameenc_framerate_get_type(void) { - static GType fameenc_framerate_type = 0; - static GEnumValue fameenc_framerate[] = { - {1, "1", "24000/1001 (23.97)"}, - {2, "2", "24"}, - {3, "3", "25"}, - {4, "4", "30000/1001 (29.97)"}, - {5, "5", "30"}, - {6, "6", "50"}, - {7, "7", "60000/1001 (59.94)"}, - {8, "8", "60"}, - {0, NULL, NULL}, - }; - if (!fameenc_framerate_type) { - fameenc_framerate_type = g_enum_register_static("GstFameEncFrameRate", fameenc_framerate); - } - return fameenc_framerate_type; + return idx; } static void gst_fameenc_class_init (GstFameEncClass *klass); @@ -275,9 +273,6 @@ gst_fameenc_class_init (GstFameEncClass *klass) } } - g_object_class_install_property (gobject_class, ARG_FRAMERATE, - g_param_spec_enum ("framerate", "Frame Rate", "Number of frames per second", - GST_TYPE_FAMEENC_FRAMERATE, 3, G_PARAM_READWRITE)); g_object_class_install_property (gobject_class, ARG_BITRATE, g_param_spec_int ("bitrate", "Bitrate", "Target bitrate (0 = VBR)", 0, 5000000, 0, G_PARAM_READWRITE)); @@ -302,7 +297,8 @@ gst_fameenc_class_init (GstFameEncClass *klass) static GstPadLinkReturn gst_fameenc_sinkconnect (GstPad *pad, GstCaps *caps) { - gint width, height; + gint width, height, fps_idx; + gfloat fps; GstFameEnc *fameenc; fameenc = GST_FAMEENC (gst_pad_get_parent (pad)); @@ -317,11 +313,17 @@ gst_fameenc_sinkconnect (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &width); gst_caps_get_int (caps, "height", &height); + gst_caps_get_float (caps, "framerate", &fps); /* fameenc requires width and height to be multiples of 16 */ if (width % 16 != 0 || height % 16 != 0) return GST_PAD_LINK_REFUSED; + fps_idx = framerate_to_index (fps); + fameenc->fp.frame_rate_num = frame_rates[fps_idx].num; + fameenc->fp.frame_rate_den = frame_rates[fps_idx].den; + fameenc->time_interval = 0; + fameenc->fp.width = width; fameenc->fp.height = height; fameenc->fp.coding = (const char *) fameenc->pattern; @@ -445,7 +447,7 @@ gst_fameenc_chain (GstPad *pad, GstBuffer *buf) g_warning ("FAMEENC_BUFFER_SIZE is defined too low, encoded slice has size %d !\n", length); if (!fameenc->time_interval) { - fameenc->time_interval = GST_SECOND / fameenc->fp.frame_rate_num; + fameenc->time_interval = GST_SECOND * fameenc->fp.frame_rate_den / fameenc->fp.frame_rate_num; } fameenc->next_time += fameenc->time_interval; @@ -482,15 +484,6 @@ gst_fameenc_set_property (GObject *object, guint prop_id, } switch (prop_id) { - case ARG_FRAMERATE: - { - gint index = g_value_get_enum (value); - - fameenc->fp.frame_rate_num = frame_rates[index].num; - fameenc->fp.frame_rate_den = frame_rates[index].den; - fameenc->time_interval = 0; - break; - } case ARG_BITRATE: fameenc->fp.bitrate = g_value_get_int (value); break; @@ -537,13 +530,6 @@ gst_fameenc_get_property (GObject *object, guint prop_id, fameenc = GST_FAMEENC (object); switch (prop_id) { - case ARG_FRAMERATE: - { - gint index = framerate_to_index (fameenc->fp.frame_rate_num, - fameenc->fp.frame_rate_den); - g_value_set_enum (value, index); - break; - } case ARG_BITRATE: g_value_set_int (value, fameenc->fp.bitrate); break; diff --git a/ext/mplex/gstmplex.cc b/ext/mplex/gstmplex.cc index eec81998..1142dd78 100644 --- a/ext/mplex/gstmplex.cc +++ b/ext/mplex/gstmplex.cc @@ -86,8 +86,8 @@ GST_PAD_TEMPLATE_FACTORY (audio_sink_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "sink_audio", - "audio/mp3", - NULL + "audio/mpeg", + "layer", GST_PROPS_RANGE (1, 3) ) ) @@ -97,7 +97,7 @@ GST_PAD_TEMPLATE_FACTORY (private_1_sink_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "sink_private1", - "audio/ac3", + "audio/x-ac3", NULL ) ) diff --git a/ext/sdl/sdlvideosink.c b/ext/sdl/sdlvideosink.c index eb5c2cc4..4a47bef3 100644 --- a/ext/sdl/sdlvideosink.c +++ b/ext/sdl/sdlvideosink.c @@ -207,7 +207,6 @@ gst_sdlvideosink_get_sdl_from_fourcc (GstSDLVideoSink *sdlvideosink, switch (code) { case GST_MAKE_FOURCC('I','4','2','0'): - case GST_MAKE_FOURCC('I','Y','U','V'): return SDL_IYUV_OVERLAY; case GST_MAKE_FOURCC('Y','V','1','2'): return SDL_YV12_OVERLAY; @@ -377,7 +376,6 @@ gst_sdlvideosink_sinkconnect (GstPad *pad, switch (format) { case GST_MAKE_FOURCC('I','4','2','0'): - case GST_MAKE_FOURCC('I','Y','U','V'): case GST_MAKE_FOURCC('Y','V','1','2'): case GST_MAKE_FOURCC('Y','U','Y','2'): case GST_MAKE_FOURCC('Y','V','Y','U'): @@ -458,8 +456,7 @@ gst_sdlvideosink_chain (GstPad *pad, GstBuffer *buf) /* buf->yuv */ if (sdlvideosink->format == GST_MAKE_FOURCC('I','4','2','0') || - sdlvideosink->format == GST_MAKE_FOURCC('Y','V','1','2') || - sdlvideosink->format == GST_MAKE_FOURCC('I','Y','U','V')) + sdlvideosink->format == GST_MAKE_FOURCC('Y','V','1','2')) { sdlvideosink->yuv[0] = GST_BUFFER_DATA(buf); sdlvideosink->yuv[1] = sdlvideosink->yuv[0] + sdlvideosink->image_width*sdlvideosink->image_height; @@ -598,7 +595,6 @@ plugin_init (GModule *module, GstPlugin *plugin) GstCaps *caps; gint i; gulong format[6] = { GST_MAKE_FOURCC('I','4','2','0'), - GST_MAKE_FOURCC('I','Y','U','V'), GST_MAKE_FOURCC('Y','V','1','2'), GST_MAKE_FOURCC('Y','U','Y','2'), GST_MAKE_FOURCC('Y','V','Y','U'), @@ -611,14 +607,15 @@ plugin_init (GModule *module, GstPlugin *plugin) g_return_val_if_fail(factory != NULL, FALSE); /* make a list of all available caps */ - for (i=0;i<6;i++) + for (i=0;i<5;i++) { caps = gst_caps_new ("sdlvideosink_caps", - "video/raw", + "video/x-raw-yuv", gst_props_new ( "format", GST_PROPS_FOURCC(format[i]), "width", GST_PROPS_INT_RANGE (0, G_MAXINT), "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT), NULL ) ); capslist = gst_caps_append(capslist, caps); diff --git a/ext/shout/gstshout.c b/ext/shout/gstshout.c index a17c0c8c..46908ee3 100644 --- a/ext/shout/gstshout.c +++ b/ext/shout/gstshout.c @@ -78,8 +78,11 @@ sink_template_factory (void) GST_PAD_ALWAYS, gst_caps_new ( "icecastsend_sink", - "audio/x-mp3", - NULL), + "audio/mpeg", + gst_props_new ( + "layer", GST_PROPS_INT_RANGE (1, 3), + NULL + )), NULL); } diff --git a/ext/snapshot/gstsnapshot.c b/ext/snapshot/gstsnapshot.c index 6af87f2c..859d5600 100644 --- a/ext/snapshot/gstsnapshot.c +++ b/ext/snapshot/gstsnapshot.c @@ -24,6 +24,7 @@ #include <inttypes.h> #include "gstsnapshot.h" +#include <gst/video/video.h> #define MAX_HEIGHT 2048 @@ -42,15 +43,14 @@ GST_PAD_TEMPLATE_FACTORY (snapshot_src_factory, "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "snapshot_src", - "video/raw", - "format", GST_PROPS_LIST ( + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST ( GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT) + )) ) ) @@ -58,15 +58,14 @@ GST_PAD_TEMPLATE_FACTORY (snapshot_sink_factory, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW ( + gst_caps_new ( "snapshot_src", - "video/raw", - "format", GST_PROPS_LIST ( - GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT) + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST ( + GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), + GST_PROPS_FOURCC (GST_STR_FOURCC ("YUY2")) + )) ) ) @@ -172,6 +171,7 @@ gst_snapshot_sinkconnect (GstPad *pad, GstCaps *caps) { GstSnapshot *filter; GstCaps *from_caps, *to_caps; + gfloat fps; filter = GST_SNAPSHOT (gst_pad_get_parent (pad)); @@ -180,20 +180,21 @@ gst_snapshot_sinkconnect (GstPad *pad, GstCaps *caps) gst_caps_get_int (caps, "width", &filter->width); gst_caps_get_int (caps, "height", &filter->height); + gst_caps_get_float (caps, "framerate", &fps); gst_caps_get_fourcc_int (caps, "format", &filter->format); filter->to_bpp = 24; to_caps = GST_CAPS_NEW ( "snapshot_conversion", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), - "width", GST_PROPS_INT( filter->width ), - "height", GST_PROPS_INT( filter->height ), + "video/x-raw-rgb", + "width", GST_PROPS_INT( filter->width ), + "height", GST_PROPS_INT( filter->height ), "red_mask", GST_PROPS_INT (0x0000FF), "green_mask", GST_PROPS_INT (0x00FF00), "blue_mask", GST_PROPS_INT (0xFF0000), - "bpp", GST_PROPS_INT( 24 ) + "bpp", GST_PROPS_INT( 24 ), + "framerate", GST_PROPS_FLOAT (fps) ); switch ( filter->format ) @@ -202,10 +203,11 @@ gst_snapshot_sinkconnect (GstPad *pad, GstCaps *caps) case GST_MAKE_FOURCC('I','4','2','0'): from_caps = GST_CAPS_NEW ( "snapshot_from", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), - "width", GST_PROPS_INT( filter->width ), - "height", GST_PROPS_INT( filter->height ) + "video/x-raw-yuv", + "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("I420")), + "width", GST_PROPS_INT( filter->width ), + "height", GST_PROPS_INT( filter->height ), + "framerate", GST_PROPS_FLOAT (fps) ); filter->converter = gst_colorspace_yuv2rgb_get_converter ( from_caps, to_caps ); diff --git a/ext/sndfile/gstsf.c b/ext/sndfile/gstsf.c index 2c5245b4..998bf9e7 100644 --- a/ext/sndfile/gstsf.c +++ b/ext/sndfile/gstsf.c @@ -67,13 +67,13 @@ GST_PAD_TEMPLATE_FACTORY (sf_src_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "sf_src", - "audio/raw", + "audio/x-raw-float", "rate", GST_PROPS_INT_RANGE (1, G_MAXINT), - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("gfloat"), "intercept", GST_PROPS_FLOAT(0.0), "slope", GST_PROPS_FLOAT(1.0), - "channels", GST_PROPS_INT (1) + "channels", GST_PROPS_INT (1), + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER) ) ); @@ -83,13 +83,13 @@ GST_PAD_TEMPLATE_FACTORY (sf_sink_factory, GST_PAD_REQUEST, GST_CAPS_NEW ( "sf_sink", - "audio/raw", + "audio/x-raw-float", "rate", GST_PROPS_INT_RANGE (1, G_MAXINT), - "format", GST_PROPS_STRING ("float"), - "layout", GST_PROPS_STRING ("gfloat"), "intercept", GST_PROPS_FLOAT(0.0), "slope", GST_PROPS_FLOAT(1.0), - "channels", GST_PROPS_INT (1) + "channels", GST_PROPS_INT (1), + "width", GST_PROPS_INT (32), + "endianness", GST_PROPS_INT (G_BYTE_ORDER) ) ); diff --git a/ext/swfdec/gstswfdec.c b/ext/swfdec/gstswfdec.c index 13920197..e56b9da1 100644 --- a/ext/swfdec/gstswfdec.c +++ b/ext/swfdec/gstswfdec.c @@ -43,7 +43,6 @@ enum { enum { ARG_0, - ARG_FRAME_RATE, /* FILL ME */ }; @@ -53,8 +52,7 @@ GST_PAD_TEMPLATE_FACTORY (video_template_factory, GST_PAD_ALWAYS, GST_CAPS_NEW ( "swfdec_videosrc", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('R','G','B',' ')), + "video/x-raw-rgb", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096), "bpp", GST_PROPS_INT (24), @@ -62,7 +60,8 @@ GST_PAD_TEMPLATE_FACTORY (video_template_factory, "endianness", GST_PROPS_INT (G_BIG_ENDIAN), "red_mask", GST_PROPS_INT (0xff0000), "green_mask", GST_PROPS_INT (0x00ff00), - "blue_mask", GST_PROPS_INT (0x0000ff) + "blue_mask", GST_PROPS_INT (0x0000ff), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) ) ); @@ -72,9 +71,7 @@ GST_PAD_TEMPLATE_FACTORY (audio_template_factory, GST_PAD_ALWAYS, GST_CAPS_NEW ( "swfdec_audiosrc", - "audio/raw", - "format", GST_PROPS_STRING("int"), - "law", GST_PROPS_INT(0), + "audio/x-raw-int", "endianness", GST_PROPS_INT(G_BYTE_ORDER), "signed", GST_PROPS_BOOLEAN(TRUE), "width", GST_PROPS_INT(16), @@ -156,10 +153,6 @@ gst_swfdec_class_init(GstSwfdecClass *klass) parent_class = g_type_class_ref(GST_TYPE_ELEMENT); - g_object_class_install_property (G_OBJECT_CLASS (klass), ARG_FRAME_RATE, - g_param_spec_float ("frame_rate","frame_rate","frame_rate", - 0.0, 1000.0, 0.0, G_PARAM_READABLE)); - gobject_class->set_property = gst_swfdec_set_property; gobject_class->get_property = gst_swfdec_get_property; gobject_class->dispose = gst_swfdec_dispose; @@ -176,8 +169,7 @@ static GstCaps *gst_swfdec_videosrc_getcaps(GstPad *pad, GstCaps *caps) c = GST_CAPS_NEW ( "swfdec_videosrc", - "video/raw", - "format", GST_PROPS_FOURCC (GST_MAKE_FOURCC ('R','G','B',' ')), + "video/x-raw-rgb", "width", GST_PROPS_INT_RANGE (16, 4096), "height", GST_PROPS_INT_RANGE (16, 4096), "bpp", GST_PROPS_INT (24), @@ -185,7 +177,8 @@ static GstCaps *gst_swfdec_videosrc_getcaps(GstPad *pad, GstCaps *caps) "endianness", GST_PROPS_INT (G_BIG_ENDIAN), "red_mask", GST_PROPS_INT (0xff0000), "green_mask", GST_PROPS_INT (0x00ff00), - "blue_mask", GST_PROPS_INT (0x0000ff) + "blue_mask", GST_PROPS_INT (0x0000ff), + "framerate", GST_PROPS_FLOAT (swfdec->frame_rate) ); if(swfdec->height){ @@ -318,6 +311,8 @@ gst_swfdec_init (GstSwfdec *swfdec) swfdec_decoder_set_colorspace(swfdec->state, SWF_COLORSPACE_RGB888); GST_FLAG_SET (GST_ELEMENT (swfdec), GST_ELEMENT_EVENT_AWARE); + + swfdec->frame_rate = 0.; } static void @@ -626,9 +621,6 @@ gst_swfdec_get_property (GObject *object, guint prop_id, GValue *value, GParamSp swfdec = GST_SWFDEC (object); switch (prop_id) { - case ARG_FRAME_RATE: - g_value_set_float (value, swfdec->frame_rate); - break; default: break; } diff --git a/ext/swfdec/gstswfdec.h b/ext/swfdec/gstswfdec.h index 38f58e88..d3e6355e 100644 --- a/ext/swfdec/gstswfdec.h +++ b/ext/swfdec/gstswfdec.h @@ -63,7 +63,7 @@ struct _GstSwfdec { double rate; gint64 timestamp; gint64 interval; - gdouble frame_rate; + gfloat frame_rate; /* video state */ gint format; diff --git a/ext/tarkin/gsttarkin.c b/ext/tarkin/gsttarkin.c index fdee893a..69fee01a 100644 --- a/ext/tarkin/gsttarkin.c +++ b/ext/tarkin/gsttarkin.c @@ -35,8 +35,8 @@ tarkin_caps_factory (void) return gst_caps_new ( "tarkin_tarkin", - "video/x-ogg", - NULL); + "application/ogg", + NULL); } static GstCaps* @@ -45,8 +45,7 @@ raw_caps_factory (void) return GST_CAPS_NEW ( "tarkin_raw", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), + "video/x-raw-rgb", "bpp", GST_PROPS_INT (24), "depth", GST_PROPS_INT (24), "endianness", GST_PROPS_INT (G_BYTE_ORDER), @@ -54,14 +53,15 @@ raw_caps_factory (void) "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT_RANGE (0, G_MAXINT), - "height", GST_PROPS_INT_RANGE (0, G_MAXINT) + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT) ); } static GstTypeDefinition tarkindefinition = { "tarkin_video/x-ogg", - "video/x-ogg", + "application/ogg", ".ogg", tarkin_type_find, }; @@ -77,7 +77,7 @@ tarkin_type_find (GstBuffer *buf, gpointer private) if (head != 0x4F676753) return NULL; - return gst_caps_new ("tarkin_type_find", "video/x-ogg", NULL); + return gst_caps_new ("tarkin_type_find", "application/ogg", NULL); } @@ -88,7 +88,7 @@ plugin_init (GModule *module, GstPlugin *plugin) GstTypeFactory *type; GstCaps *raw_caps, *tarkin_caps; - gst_plugin_set_longname (plugin, "The OGG Vorbis Codec"); + gst_plugin_set_longname (plugin, "The OGG Tarkin Codec"); /* create an elementfactory for the tarkinenc element */ enc = gst_element_factory_new ("tarkinenc", GST_TYPE_TARKINENC, diff --git a/ext/tarkin/gsttarkindec.c b/ext/tarkin/gsttarkindec.c index 7d2c42c0..f77e5c8f 100644 --- a/ext/tarkin/gsttarkindec.c +++ b/ext/tarkin/gsttarkindec.c @@ -213,8 +213,7 @@ gst_tarkindec_chain (GstPad *pad, GstBuffer *buf) if (gst_pad_try_set_caps (tarkindec->srcpad, GST_CAPS_NEW ( "tarkin_raw", - "video/raw", - "format", GST_PROPS_FOURCC (GST_STR_FOURCC ("RGB ")), + "video/x-raw-rgb", "bpp", GST_PROPS_INT (24), "depth", GST_PROPS_INT (24), "endianness", GST_PROPS_INT (G_BYTE_ORDER), @@ -222,7 +221,8 @@ gst_tarkindec_chain (GstPad *pad, GstBuffer *buf) "green_mask", GST_PROPS_INT (0xff00), "blue_mask", GST_PROPS_INT (0xff), "width", GST_PROPS_INT (layer->width), - "height", GST_PROPS_INT (layer->height) + "height", GST_PROPS_INT (layer->height), + "framerate", GST_PROPS_FLOAT (0.) /* FIXME!!! */ )) <= 0) { gst_element_error (GST_ELEMENT (tarkindec), "could not output format"); diff --git a/ext/xvid/gstxviddec.c b/ext/xvid/gstxviddec.c index cd4ce3f5..fcde219b 100644 --- a/ext/xvid/gstxviddec.c +++ b/ext/xvid/gstxviddec.c @@ -44,28 +44,39 @@ GST_PAD_TEMPLATE_FACTORY(sink_template, GST_PAD_SINK, GST_PAD_ALWAYS, GST_CAPS_NEW("xviddec_sink", - "video/xvid", - NULL) + "video/x-xvid", + "width", GST_PROPS_INT_RANGE (0, G_MAXINT), + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)) ) GST_PAD_TEMPLATE_FACTORY(src_template, "src", GST_PAD_SRC, GST_PAD_ALWAYS, - GST_CAPS_NEW("xviddec_src", - "video/raw", - "format", GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','Y','U','V')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT), - NULL) + gst_caps_new( + "xviddec_sink", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST( + GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) + ) + ) + ), + gst_caps_new( + "xviddec_sink_rgb24_32", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 + ), + gst_caps_new( + "xviddec_sink_rgb15_16", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + ) ) @@ -88,6 +99,7 @@ static void gst_xviddec_chain (GstPad *pad, GstBuffer *buf); static GstPadLinkReturn gst_xviddec_connect (GstPad *pad, GstCaps *vscapslist); +static GstPadLinkReturn gst_xviddec_negotiate (GstXvidDec *xviddec); static GstElementClass *parent_class = NULL; /* static guint gst_xviddec_signals[LAST_SIGNAL] = { 0 }; */ @@ -216,10 +228,12 @@ gst_xviddec_chain (GstPad *pad, xviddec = GST_XVIDDEC(GST_OBJECT_PARENT(pad)); if (!xviddec->handle) { - gst_element_error(GST_ELEMENT(xviddec), - "No format set - aborting"); - gst_buffer_unref(buf); - return; + if (!gst_xviddec_negotiate(xviddec)) { + gst_element_error(GST_ELEMENT(xviddec), + "No format set - aborting"); + gst_buffer_unref(buf); + return; + } } outbuf = gst_buffer_new_and_alloc(xviddec->width * @@ -252,10 +266,9 @@ gst_xviddec_chain (GstPad *pad, static GstPadLinkReturn -gst_xviddec_connect (GstPad *pad, - GstCaps *vscaps) +gst_xviddec_negotiate (GstXvidDec *xviddec) { - GstXvidDec *xviddec; + GstPadLinkReturn ret; GstCaps *caps; struct { guint32 fourcc; @@ -266,7 +279,6 @@ gst_xviddec_connect (GstPad *pad, { GST_MAKE_FOURCC('U','Y','V','Y'), 16, 16, XVID_CSP_UYVY }, { GST_MAKE_FOURCC('Y','V','Y','U'), 16, 16, XVID_CSP_YVYU }, { GST_MAKE_FOURCC('I','4','2','0'), 12, 12, XVID_CSP_I420 }, - { GST_MAKE_FOURCC('I','Y','U','V'), 12, 12, XVID_CSP_I420 }, { GST_MAKE_FOURCC('Y','V','1','2'), 12, 12, XVID_CSP_YV12 }, { GST_MAKE_FOURCC('R','G','B',' '), 32, 32, XVID_CSP_RGB32 }, { GST_MAKE_FOURCC('R','G','B',' '), 24, 24, XVID_CSP_RGB24 }, @@ -276,68 +288,60 @@ gst_xviddec_connect (GstPad *pad, }; gint i; - xviddec = GST_XVIDDEC(gst_pad_get_parent (pad)); - - /* if there's something old around, remove it */ - if (xviddec->handle) { - gst_xviddec_unset(xviddec); - } - - /* we are not going to act on variable caps */ - if (!GST_CAPS_IS_FIXED(vscaps)) - return GST_PAD_LINK_DELAYED; - - /* if we get here, we know the input is xvid. we - * only need to bother with the output colorspace */ - gst_caps_get_int(vscaps, "width", &xviddec->width); - gst_caps_get_int(vscaps, "height", &xviddec->height); - for (i = 0; fmt_list[i].fourcc != 0; i++) { xviddec->csp = fmt_list[i].csp; /* try making a caps to set on the other side */ if (fmt_list[i].fourcc == GST_MAKE_FOURCC('R','G','B',' ')) { guint32 r_mask = 0, b_mask = 0, g_mask = 0; + gint endianness = 0; switch (fmt_list[i].depth) { case 15: + endianness = G_BYTE_ORDER; r_mask = 0xf800; g_mask = 0x07c0; b_mask = 0x003e; break; case 16: + endianness = G_BYTE_ORDER; r_mask = 0xf800; g_mask = 0x07e0; b_mask = 0x001f; break; case 24: - r_mask = 0xff0000; g_mask = 0x00ff00; b_mask = 0x0000ff; + endianness = G_BIG_ENDIAN; + r_mask = R_MASK_24; g_mask = G_MASK_24; b_mask = B_MASK_24; break; case 32: - r_mask = 0xff000000; g_mask = 0x00ff0000; b_mask = 0x0000ff00; + endianness = G_BIG_ENDIAN; + r_mask = R_MASK_32; g_mask = G_MASK_32; b_mask = B_MASK_32; break; } caps = GST_CAPS_NEW("xviddec_src_pad_rgb", - "video/raw", + "video/x-raw-rgb", "width", GST_PROPS_INT(xviddec->width), "height", GST_PROPS_INT(xviddec->height), - "format", GST_PROPS_FOURCC(fmt_list[i].fourcc), "depth", GST_PROPS_INT(fmt_list[i].depth), "bpp", GST_PROPS_INT(fmt_list[i].bpp), - "endianness", GST_PROPS_INT(G_BYTE_ORDER), + "endianness", GST_PROPS_INT(endianness), "red_mask", GST_PROPS_INT(r_mask), "green_mask", GST_PROPS_INT(g_mask), "blue_mask", GST_PROPS_INT(b_mask), + "framerate", GST_PROPS_FLOAT(xviddec->fps), NULL); } else { caps = GST_CAPS_NEW("xviddec_src_pad_yuv", - "video/raw", + "video/x-raw-yuv", "width", GST_PROPS_INT(xviddec->width), "height", GST_PROPS_INT(xviddec->height), "format", GST_PROPS_FOURCC(fmt_list[i].fourcc), + "framerate", GST_PROPS_FLOAT(xviddec->fps), NULL); } - if (gst_pad_try_set_caps(xviddec->srcpad, caps) > 0) { + if ((ret = gst_pad_try_set_caps(xviddec->srcpad, caps)) > 0) { xviddec->csp = fmt_list[i].csp; xviddec->bpp = fmt_list[i].bpp; if (gst_xviddec_setup(xviddec)) return GST_PAD_LINK_OK; + } else if (ret == GST_PAD_LINK_DELAYED) { + return ret; /* don't try further (yet) */ } } @@ -346,6 +350,33 @@ gst_xviddec_connect (GstPad *pad, } +static GstPadLinkReturn +gst_xviddec_connect (GstPad *pad, + GstCaps *vscaps) +{ + GstXvidDec *xviddec; + + xviddec = GST_XVIDDEC(gst_pad_get_parent (pad)); + + /* if there's something old around, remove it */ + if (xviddec->handle) { + gst_xviddec_unset(xviddec); + } + + /* we are not going to act on variable caps */ + if (!GST_CAPS_IS_FIXED(vscaps)) + return GST_PAD_LINK_DELAYED; + + /* if we get here, we know the input is xvid. we + * only need to bother with the output colorspace */ + gst_caps_get_int(vscaps, "width", &xviddec->width); + gst_caps_get_int(vscaps, "height", &xviddec->height); + gst_caps_get_float(vscaps, "framerate", &xviddec->fps); + + return gst_xviddec_negotiate(xviddec); +} + + gboolean gst_xviddec_plugin_init (GModule *module, GstPlugin *plugin) diff --git a/ext/xvid/gstxviddec.h b/ext/xvid/gstxviddec.h index cdee5540..6a08b2be 100644 --- a/ext/xvid/gstxviddec.h +++ b/ext/xvid/gstxviddec.h @@ -54,6 +54,7 @@ struct _GstXvidDec { /* video (output) settings */ int csp, bpp; int width, height; + float fps; }; struct _GstXvidDecClass { diff --git a/ext/xvid/gstxvidenc.c b/ext/xvid/gstxvidenc.c index 7b3d62dd..5a4156ce 100644 --- a/ext/xvid/gstxvidenc.c +++ b/ext/xvid/gstxvidenc.c @@ -44,20 +44,29 @@ GST_PAD_TEMPLATE_FACTORY(sink_template, "sink", GST_PAD_SINK, GST_PAD_ALWAYS, - GST_CAPS_NEW("xvidenc_sink", - "video/raw", - "format", GST_PROPS_LIST( - GST_PROPS_FOURCC(GST_MAKE_FOURCC('R','G','B',' ')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','Y','U','V')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), - GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) - ), - "width", GST_PROPS_INT_RANGE(0, G_MAXINT), - "height", GST_PROPS_INT_RANGE(0, G_MAXINT), - NULL) + gst_caps_new( + "xvidenc_sink", + "video/x-raw-yuv", + GST_VIDEO_YUV_PAD_TEMPLATE_PROPS ( + GST_PROPS_LIST( + GST_PROPS_FOURCC(GST_MAKE_FOURCC('I','4','2','0')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','U','Y','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','1','2')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('Y','V','Y','U')), + GST_PROPS_FOURCC(GST_MAKE_FOURCC('U','Y','V','Y')) + ) + ) + ), + gst_caps_new( + "xvidenc_sink_rgb24_32", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_24_32 + ), + gst_caps_new( + "xvidenc_sink_rgb15_16", + "video/x-raw-rgb", + GST_VIDEO_RGB_PAD_TEMPLATE_PROPS_15_16 + ) ) GST_PAD_TEMPLATE_FACTORY(src_template, @@ -65,8 +74,10 @@ GST_PAD_TEMPLATE_FACTORY(src_template, GST_PAD_SRC, GST_PAD_ALWAYS, GST_CAPS_NEW("xvidenc_src", - "video/xvid", - NULL) + "video/x-xvid", + "width", GST_PROPS_INT_RANGE (0, G_MAXINT), + "height", GST_PROPS_INT_RANGE (0, G_MAXINT), + "framerate", GST_PROPS_FLOAT_RANGE (0, G_MAXFLOAT)) ) @@ -202,17 +213,14 @@ static gboolean gst_xvidenc_setup (GstXvidEnc *xvidenc) { XVID_ENC_PARAM xenc; - gdouble fps; int ret; - fps = gst_video_frame_rate(GST_PAD_PEER(xvidenc->sinkpad)); - /* set up xvid codec parameters - grab docs from * xvid.org for more info */ memset(&xenc, 0, sizeof(XVID_ENC_PARAM)); xenc.width = xvidenc->width; xenc.height = xvidenc->height; - xenc.fincr = (int)(fps * 1000); + xenc.fincr = (int)(xvidenc->fps * 1000); xenc.fbase = 1000; xenc.rc_bitrate = xvidenc->bitrate; xenc.rc_reaction_delay_factor = -1; @@ -254,13 +262,6 @@ gst_xvidenc_chain (GstPad *pad, xvidenc = GST_XVIDENC(GST_OBJECT_PARENT(pad)); - if (!xvidenc->handle) { - if (!gst_xvidenc_setup(xvidenc)) { - gst_buffer_unref(buf); - return; - } - } - outbuf = gst_buffer_new_and_alloc(xvidenc->buffer_size); GST_BUFFER_TIMESTAMP(outbuf) = GST_BUFFER_TIMESTAMP(buf); @@ -326,11 +327,17 @@ gst_xvidenc_connect (GstPad *pad, for (caps = vscaps; caps != NULL; caps = caps->next) { int w,h,d; + float fps; guint32 fourcc; gint xvid_cs; + gst_caps_get_int(caps, "width", &w); gst_caps_get_int(caps, "height", &h); - gst_caps_get_fourcc_int(caps, "format", &fourcc); + gst_caps_get_float(caps, "framerate", &fps); + if (gst_caps_has_property(caps, "format")) + gst_caps_get_fourcc_int(caps, "format", &fourcc); + else + fourcc = GST_MAKE_FOURCC('R','G','B',' '); switch (fourcc) { @@ -373,17 +380,32 @@ gst_xvidenc_connect (GstPad *pad, goto trynext; } - /* grmbl, we only know the peer pad *after* - * linking, so we accept here, get the fps on - * the first cycle and set it all up then */ xvidenc->csp = xvid_cs; xvidenc->width = w; xvidenc->height = h; - return gst_pad_try_set_caps(xvidenc->srcpad, - GST_CAPS_NEW("xvidenc_src_caps", - "video/xvid", - "width", GST_PROPS_INT(w), - "height", GST_PROPS_INT(h))); + xvidenc->fps = fps; + + if (gst_xvidenc_setup(xvidenc)) { + GstPadLinkReturn ret; + GstCaps *new_caps; + + new_caps = GST_CAPS_NEW("xvidenc_src_caps", + "video/x-xvid", + "width", GST_PROPS_INT(w), + "height", GST_PROPS_INT(h), + "framerate", GST_PROPS_FLOAT (fps)); + + ret = gst_pad_try_set_caps(xvidenc->srcpad, new_caps); + + if (ret <= 0) { + if (xvidenc->handle) { + xvid_encore(xvidenc->handle, XVID_ENC_DESTROY, NULL, NULL); + xvidenc->handle = NULL; + } + } + + return ret; + } trynext: continue; diff --git a/ext/xvid/gstxvidenc.h b/ext/xvid/gstxvidenc.h index e14b4133..224487dc 100644 --- a/ext/xvid/gstxvidenc.h +++ b/ext/xvid/gstxvidenc.h @@ -60,6 +60,7 @@ struct _GstXvidEnc { void *handle; int csp; int width, height; + float fps; }; struct _GstXvidEncClass { |