Commit 6ef95281 authored by David Schleef's avatar David Schleef

Convert to new caps

Original commit message from CVS:
Convert to new caps
parent a678b180
......@@ -28,6 +28,7 @@
#include <string.h>
#include <gstauparse.h>
#include <gst/audio/audio.h>
/* elementfactory information */
static GstElementDetails gst_auparse_details = GST_ELEMENT_DETAILS (
......@@ -37,47 +38,26 @@ static GstElementDetails gst_auparse_details = GST_ELEMENT_DETAILS (
"Erik Walthinsen <omega@cse.ogi.edu>"
);
GST_PAD_TEMPLATE_FACTORY (sink_factory_templ,
static GstStaticPadTemplate gst_auparse_sink_template =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"auparse_sink",
"audio/x-au",
NULL
)
)
GST_STATIC_CAPS ( "audio/x-au" )
);
GST_PAD_TEMPLATE_FACTORY (src_factory_templ,
static GstStaticPadTemplate gst_auparse_src_template =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"auparse_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"signed", GST_PROPS_LIST(
GST_PROPS_BOOLEAN (FALSE),
GST_PROPS_BOOLEAN (TRUE)
),
"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,48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"auparse_src_alaw",
"audio/x-alaw",
"rate", GST_PROPS_INT_RANGE (8000,48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS (
GST_AUDIO_INT_PAD_TEMPLATE_CAPS ", "
"audio/x-alaw, "
"rate = (int) [ 8000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
)
);
/* AuParse signals and args */
enum {
......@@ -127,9 +107,9 @@ gst_auparse_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (sink_factory_templ));
gst_static_pad_template_get (&gst_auparse_sink_template));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory_templ));
gst_static_pad_template_get (&gst_auparse_src_template));
gst_element_class_set_details (element_class, &gst_auparse_details);
}
......@@ -148,12 +128,12 @@ static void
gst_auparse_init (GstAuParse *auparse)
{
auparse->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (sink_factory_templ), "sink");
gst_static_pad_template_get (&gst_auparse_sink_template), "sink");
gst_element_add_pad (GST_ELEMENT (auparse), auparse->sinkpad);
gst_pad_set_chain_function (auparse->sinkpad, gst_auparse_chain);
auparse->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (src_factory_templ), "src");
gst_static_pad_template_get (&gst_auparse_src_template), "src");
gst_element_add_pad (GST_ELEMENT (auparse), auparse->srcpad);
auparse->offset = 0;
......@@ -170,7 +150,7 @@ gst_auparse_chain (GstPad *pad, GstData *_data)
GstAuParse *auparse;
gchar *data;
glong size;
GstCaps* tempcaps;
GstCaps2 *tempcaps;
gint law, depth;
gboolean sign;
......@@ -258,19 +238,17 @@ gst_auparse_chain (GstPad *pad, GstData *_data)
}
if (law) {
tempcaps = GST_CAPS_NEW ("auparse_src",
"audio/x-alaw",
"rate", GST_PROPS_INT (auparse->frequency),
"channels", GST_PROPS_INT (auparse->channels));
tempcaps = gst_caps2_new_simple ("audio/x-alaw",
"rate", G_TYPE_INT, auparse->frequency,
"channels", G_TYPE_INT, auparse->channels, NULL);
} else {
tempcaps = GST_CAPS_NEW ("auparse_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BIG_ENDIAN),
"rate", GST_PROPS_INT (auparse->frequency),
"channels", GST_PROPS_INT (auparse->channels),
"depth", GST_PROPS_INT (depth),
"width", GST_PROPS_INT (depth),
"signed", GST_PROPS_BOOLEAN (sign));
tempcaps = gst_caps2_new_simple ("audio/x-raw-int",
"endianness", G_TYPE_INT, G_BIG_ENDIAN,
"rate", G_TYPE_INT, auparse->frequency,
"channels", G_TYPE_INT, auparse->channels,
"depth", G_TYPE_INT, depth,
"width", G_TYPE_INT, depth,
"signed", G_TYPE_BOOLEAN, sign, NULL);
}
if (gst_pad_try_set_caps (auparse->srcpad, tempcaps) <= 0) {
......
This diff is collapsed.
......@@ -26,9 +26,7 @@
#include <gst/bytestream/bytestream.h>
#include <gst/riff/riff.h>
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
G_BEGIN_DECLS
#define GST_TYPE_AVI_DEMUX \
(gst_avi_demux_get_type())
......@@ -115,7 +113,8 @@ struct _GstAviDemux {
gint64 seek_offset;
guint64 last_seek;
GstCaps *metadata, *streaminfo;
GstStructure *metadata;
GstCaps2 *streaminfo;
};
struct _GstAviDemuxClass {
......@@ -124,9 +123,6 @@ struct _GstAviDemuxClass {
GType gst_avi_demux_get_type (void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
G_END_DECLS
#endif /* __GST_AVI_DEMUX_H__ */
......@@ -54,139 +54,85 @@ enum {
ARG_BIGFILE,
};
GST_PAD_TEMPLATE_FACTORY (src_factory,
static GstStaticPadTemplate src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"avimux_src_video",
"video/x-msvideo",
NULL
)
)
GST_STATIC_CAPS ("video/x-msvideo")
);
GST_PAD_TEMPLATE_FACTORY (video_sink_factory,
static GstStaticPadTemplate video_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"video_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_NEW (
"avimux_sink_video_yuv",
"video/x-raw-yuv",
"format", GST_PROPS_LIST (
GST_PROPS_FOURCC (GST_MAKE_FOURCC('Y','U','Y','2')),
GST_PROPS_FOURCC (GST_MAKE_FOURCC('I','4','2','0'))
),
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"avimux_sink_video_jpeg",
"video/x-jpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"avimux_sink_video_divx",
"video/x-divx",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"divxversion", GST_PROPS_INT_RANGE (3, 5)
),
GST_CAPS_NEW (
"avimux_sink_video_xvid",
"video/x-xvid",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"avimux_sink_video_3ivx",
"video/x-3ivx",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"avimux_sink_video_msmpeg",
"video/x-msmpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"msmpegversion", GST_PROPS_INT_RANGE (41, 43)
),
GST_CAPS_NEW (
"avimux_sink_video_mpeg",
"video/mpeg",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096),
"mpegversion", GST_PROPS_INT (1),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
),
GST_CAPS_NEW (
"avimux_sink_video_h263",
"video/x-h263",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
),
GST_CAPS_NEW (
"avimux_sink_video_dv",
"video/x-dv",
"width", GST_PROPS_INT (720),
"height", GST_PROPS_LIST (
GST_PROPS_INT (576),
GST_PROPS_INT (480)
),
"systemstream", GST_PROPS_BOOLEAN (FALSE)
),
GST_CAPS_NEW (
"avimux_sink_video_hfyu",
"video/x-huffyuv",
"width", GST_PROPS_INT_RANGE (16, 4096),
"height", GST_PROPS_INT_RANGE (16, 4096)
GST_STATIC_CAPS (
"video/x-raw-yuv, "
"format = (fourcc) { YUY2, I420 }, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]; "
"video/x-jpeg, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]; "
"video/x-divx, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"divxversion = (int) [ 3, 5 ]; "
"video/x-xvid, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]; "
"video/x-3ivx, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]; "
"video/x-msmpeg, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"msmpegversion = (int) [ 41, 43 ]; "
"video/mpeg, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ], "
"mpegversion = (int) 1, "
"systemstream = (boolean) FALSE; "
"video/x-h263, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]; "
"video/x-dv, "
"width = (int) 720, "
"height = (int) { 576, 480 }, "
"systemstream = (boolean) FALSE; "
"video/x-huffyuv, "
"width = (int) [ 16, 4096 ], "
"height = (int) [ 16, 4096 ]"
)
)
);
GST_PAD_TEMPLATE_FACTORY (audio_sink_factory,
static GstStaticPadTemplate audio_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"audio_%d",
GST_PAD_SINK,
GST_PAD_REQUEST,
GST_CAPS_NEW (
"avimux_sink_audio_raw",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_LITTLE_ENDIAN),
"signed", GST_PROPS_LIST (
GST_PROPS_BOOLEAN (TRUE),
GST_PROPS_BOOLEAN (FALSE)
),
"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 (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"avimux_sink_audio_mpeg",
"audio/mpeg",
"mpegversion", GST_PROPS_INT (1),
"layer", GST_PROPS_INT_RANGE (1, 3),
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"avimux_sink_audio_vorbis",
"audio/x-vorbis",
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 2)
),
GST_CAPS_NEW (
"avimux_sink_audio_ac3",
"audio/x-ac3",
"rate", GST_PROPS_INT_RANGE (1000, 96000),
"channels", GST_PROPS_INT_RANGE (1, 6)
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) LITTLE_ENDIAN, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/mpeg, "
"mpegversion = (int) 1, "
"layer = (int) [ 1, 3 ], "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/x-vorbis, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/x-ac3, "
"rate = (int) [ 1000, 96000 ], "
"channels = (int) [ 1, 2 ]"
)
)
);
static void gst_avimux_base_init (gpointer g_class);
......@@ -246,11 +192,11 @@ gst_avimux_base_init (gpointer g_class)
);
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (src_factory));
gst_static_pad_template_get (&src_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (audio_sink_factory));
gst_static_pad_template_get (&audio_sink_factory));
gst_element_class_add_pad_template (element_class,
GST_PAD_TEMPLATE_GET (video_sink_factory));
gst_static_pad_template_get (&video_sink_factory));
gst_element_class_set_details (element_class, &gst_avimux_details);
}
......@@ -334,113 +280,101 @@ gst_avimux_init (GstAviMux *avimux)
}
static GstPadLinkReturn
gst_avimux_vidsinkconnect (GstPad *pad, GstCaps *vscaps)
gst_avimux_vidsinkconnect (GstPad *pad, const GstCaps2 *vscaps)
{
GstAviMux *avimux;
GstCaps *caps;
GstStructure *structure;
const gchar* mimetype;
gdouble fps = 0.;
gboolean ret;
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (vscaps))
return GST_PAD_LINK_DELAYED;
GST_DEBUG ("avimux: video sinkconnect triggered on %s",
gst_pad_get_name (pad));
for (caps = vscaps; caps != NULL; caps = vscaps = vscaps->next)
{
const gchar* mimetype = gst_caps_get_mime(caps);
gfloat fps = 0.;
/* global */
avimux->vids.size = sizeof(gst_riff_strf_vids);
avimux->vids.planes = 1;
gst_caps_get (caps, "width", &avimux->vids.width,
"height", &avimux->vids.height,
"framerate", &fps,
NULL);
if (fps != 0.)
avimux->vids_hdr.scale = avimux->vids_hdr.rate / fps;
if (!strcmp (mimetype, "video/x-raw-yuv"))
{
guint32 format;
gst_caps_get_fourcc_int (caps, "format", &format);
avimux->vids.compression = format;
switch (format)
{
case GST_MAKE_FOURCC('Y','U','Y','2'):
avimux->vids.bit_cnt = 16;
break;
case GST_MAKE_FOURCC('I','4','2','0'):
avimux->vids.bit_cnt = 12;
break;
}
structure = gst_caps2_get_nth_cap (vscaps, 0);
mimetype = gst_structure_get_name (structure);
goto done;
}
else
/* global */
avimux->vids.size = sizeof(gst_riff_strf_vids);
avimux->vids.planes = 1;
ret = gst_structure_get_int (structure, "width", &avimux->vids.width);
ret &= gst_structure_get_int (structure, "height", &avimux->vids.height);
ret &= gst_structure_get_double (structure, "framerate", &fps);
if (!ret) return GST_PAD_LINK_REFUSED;
if (fps != 0.)
avimux->vids_hdr.scale = avimux->vids_hdr.rate / fps;
if (!strcmp (mimetype, "video/x-raw-yuv")) {
guint32 format;
gst_structure_get_fourcc (structure, "format", &format);
avimux->vids.compression = format;
switch (format)
{
avimux->vids.bit_cnt = 24;
avimux->vids.compression = 0;
/* find format */
if (!strcmp (mimetype, "video/x-huffyuv")) {
avimux->vids.compression = GST_MAKE_FOURCC('H','F','Y','U');
} else if (!strcmp (mimetype, "video/x-jpeg")) {
avimux->vids.compression = GST_MAKE_FOURCC('M','J','P','G');
} else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion;
gst_caps_get_int (caps, "divxversion", &divxversion);
switch (divxversion) {
case 3:
avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','3');
break;
case 4:
avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','X');
break;
case 5:
avimux->vids.compression = GST_MAKE_FOURCC('D','X','5','0');
break;
}
} else if (!strcmp (mimetype, "video/x-xvid")) {
avimux->vids.compression = GST_MAKE_FOURCC('X','V','I','D');
} else if (!strcmp (mimetype, "video/x-3ivx")) {
avimux->vids.compression = GST_MAKE_FOURCC('3','I','V','2');
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
gint msmpegversion;
gst_caps_get_int (caps, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','G','4');
break;
case 42:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','2');
break;
case 43:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','3');
case GST_MAKE_FOURCC('Y','U','Y','2'):
avimux->vids.bit_cnt = 16;
break;
case GST_MAKE_FOURCC('I','4','2','0'):
avimux->vids.bit_cnt = 12;
break;
}
} else {
avimux->vids.bit_cnt = 24;
avimux->vids.compression = 0;
/* find format */
if (!strcmp (mimetype, "video/x-huffyuv")) {
avimux->vids.compression = GST_MAKE_FOURCC('H','F','Y','U');
} else if (!strcmp (mimetype, "video/x-jpeg")) {
avimux->vids.compression = GST_MAKE_FOURCC('M','J','P','G');
} else if (!strcmp (mimetype, "video/x-divx")) {
gint divxversion;
gst_structure_get_int (structure, "divxversion", &divxversion);
switch (divxversion) {
case 3:
avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','3');
break;
case 4:
avimux->vids.compression = GST_MAKE_FOURCC('D','I','V','X');
break;
case 5:
avimux->vids.compression = GST_MAKE_FOURCC('D','X','5','0');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
avimux->vids.compression = GST_MAKE_FOURCC('D','V','S','D');
} else if (!strcmp (mimetype, "video/x-h263")) {
avimux->vids.compression = GST_MAKE_FOURCC('H','2','6','3');
} else if (!strcmp (mimetype, "video/mpeg")) {
avimux->vids.compression = GST_MAKE_FOURCC('M','P','E','G');
}
if (!avimux->vids.compression) {
continue;
} else if (!strcmp (mimetype, "video/x-xvid")) {
avimux->vids.compression = GST_MAKE_FOURCC('X','V','I','D');
} else if (!strcmp (mimetype, "video/x-3ivx")) {
avimux->vids.compression = GST_MAKE_FOURCC('3','I','V','2');
} else if (!strcmp (mimetype, "video/x-msmpeg")) {
gint msmpegversion;
gst_structure_get_int (structure, "msmpegversion", &msmpegversion);
switch (msmpegversion) {
case 41:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','G','4');
break;
case 42:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','2');
break;
case 43:
avimux->vids.compression = GST_MAKE_FOURCC('M','P','4','3');
break;
}
} else if (!strcmp (mimetype, "video/x-dv")) {
avimux->vids.compression = GST_MAKE_FOURCC('D','V','S','D');
} else if (!strcmp (mimetype, "video/x-h263")) {
avimux->vids.compression = GST_MAKE_FOURCC('H','2','6','3');
} else if (!strcmp (mimetype, "video/mpeg")) {
avimux->vids.compression = GST_MAKE_FOURCC('M','P','E','G');
}
goto done;
if (!avimux->vids.compression) {
return GST_PAD_LINK_DELAYED;
}
}
return GST_PAD_LINK_REFUSED;
done:
avimux->vids_hdr.fcc_handler = avimux->vids.compression;
avimux->vids.image_size = avimux->vids.height * avimux->vids.width;
avimux->avi_hdr.width = avimux->vids.width;
......@@ -450,80 +384,70 @@ done:
}
static GstPadLinkReturn
gst_avimux_audsinkconnect (GstPad *pad, GstCaps *vscaps)
gst_avimux_audsinkconnect (GstPad *pad, const GstCaps2 *vscaps)
{
GstAviMux *avimux;
GstCaps *caps;
GstStructure *structure;
const gchar* mimetype;
int i;
avimux = GST_AVIMUX (gst_pad_get_parent (pad));
/* we are not going to act on variable caps */
if (!GST_CAPS_IS_FIXED (vscaps))
return GST_PAD_LINK_DELAYED;
GST_DEBUG ("avimux: audio sinkconnect triggered on %s",
gst_pad_get_name (pad));
for (caps = vscaps; caps != NULL; caps = vscaps = vscaps->next)
{
const gchar* mimetype = gst_caps_get_mime(caps);
structure = gst_caps2_get_nth_cap (vscaps, 0);
mimetype = gst_structure_get_name (structure);
/* we want these for all */
gst_caps_get (caps, "channels", &avimux->auds.channels,
"rate", &avimux->auds.rate,
NULL);
/* we want these for all */
gst_structure_get_int (structure, "channels", &i);
avimux->auds.channels = i;
gst_structure_get_int (structure, "rate", &i);
avimux->auds.rate = i;
if (!strcmp (mimetype, "audio/x-raw-int"))
{
avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
if (!strcmp (mimetype, "audio/x-raw-int")) {
avimux->auds.format = GST_RIFF_WAVE_FORMAT_PCM;
gst_caps_get (caps, "width", &avimux->auds.blockalign,
"depth", &avimux->auds.size,