Commit 2f33fbac authored by David Schleef's avatar David Schleef

Convert to new caps

Original commit message from CVS:
Convert to new caps
parent 5704069c
......@@ -486,19 +486,22 @@ gst_ossformat_get (gint law, gint endianness, gboolean sign, gint width, gint de
}
gboolean
gst_osselement_parse_caps (GstOssElement *oss, GstCaps *caps)
gst_osselement_parse_caps (GstOssElement *oss, const GstCaps2 *caps)
{
gint bps, format;
GstStructure *structure;
gst_caps_get_int (caps, "width", &oss->width);
gst_caps_get_int (caps, "depth", &oss->depth);
structure = gst_caps2_get_nth_cap (caps, 0);
gst_structure_get_int (structure, "width", &oss->width);
gst_structure_get_int (structure, "depth", &oss->depth);
if (oss->width != oss->depth)
return FALSE;
gst_caps_get_int (caps, "law", &oss->law);
gst_caps_get_int (caps, "endianness", &oss->endianness);
gst_caps_get_boolean (caps, "signed", &oss->sign);
gst_structure_get_int (structure, "law", &oss->law);
gst_structure_get_int (structure, "endianness", &oss->endianness);
gst_structure_get_boolean (structure, "signed", &oss->sign);
if (!gst_ossformat_get (oss->law, oss->endianness, oss->sign,
oss->width, oss->depth, &format, &bps))
......@@ -507,8 +510,8 @@ gst_osselement_parse_caps (GstOssElement *oss, GstCaps *caps)
return FALSE;
}
gst_caps_get_int (caps, "channels", &oss->channels);
gst_caps_get_int (caps, "rate", &oss->rate);
gst_structure_get_int (structure, "channels", &oss->channels);
gst_structure_get_int (structure, "rate", &oss->rate);
oss->bps = bps * oss->channels * oss->rate;
oss->format = format;
......@@ -519,25 +522,28 @@ gst_osselement_parse_caps (GstOssElement *oss, GstCaps *caps)
#define GET_FIXED_INT(caps, name, dest) \
G_STMT_START { \
if (gst_caps_has_fixed_property (caps, name)) \
gst_caps_get_int (caps, name, dest); \
gst_structure_get_int (structure, name, dest); \
} G_STMT_END
#define GET_FIXED_BOOLEAN(caps, name, dest) \
G_STMT_START { \
if (gst_caps_has_fixed_property (caps, name)) \
gst_caps_get_boolean (caps, name, dest); \
gst_structure_get_boolean (structure, name, dest); \
} G_STMT_END
gboolean
gst_osselement_merge_fixed_caps (GstOssElement *oss, GstCaps *caps)
gst_osselement_merge_fixed_caps (GstOssElement *oss, GstCaps2 *caps)
{
gint bps, format;
GstStructure *structure;
structure = gst_caps2_get_nth_cap (caps, 0);
/* peel off fixed stuff from the caps */
GET_FIXED_INT (caps, "law", &oss->law);
GET_FIXED_INT (caps, "endianness", &oss->endianness);
GET_FIXED_BOOLEAN (caps, "signed", &oss->sign);
GET_FIXED_INT (caps, "width", &oss->width);
GET_FIXED_INT (caps, "depth", &oss->depth);
gst_structure_get_int (structure, "law", &oss->law);
gst_structure_get_int (structure, "endianness", &oss->endianness);
gst_structure_get_boolean (structure, "signed", &oss->sign);
gst_structure_get_int (structure, "width", &oss->width);
gst_structure_get_int (structure, "depth", &oss->depth);
if (!gst_ossformat_get (oss->law, oss->endianness, oss->sign,
oss->width, oss->depth, &format, &bps))
......@@ -545,8 +551,8 @@ gst_osselement_merge_fixed_caps (GstOssElement *oss, GstCaps *caps)
return FALSE;
}
GET_FIXED_INT (caps, "rate", &oss->rate);
GET_FIXED_INT (caps, "channels", &oss->channels);
gst_structure_get_int (structure, "rate", &oss->rate);
gst_structure_get_int (structure, "channels", &oss->channels);
oss->bps = bps * oss->channels * oss->rate;
oss->format = format;
......
......@@ -101,9 +101,9 @@ GType gst_osselement_get_type (void);
/* some useful functions */
gboolean gst_osselement_parse_caps (GstOssElement *oss,
GstCaps *caps);
const GstCaps2 *caps);
gboolean gst_osselement_merge_fixed_caps (GstOssElement *oss,
GstCaps *caps);
GstCaps2 *caps);
gboolean gst_osselement_sync_parms (GstOssElement *oss);
void gst_osselement_reset (GstOssElement *oss);
......
......@@ -67,50 +67,27 @@ enum {
/* FILL ME */
};
static GstPadTemplate*
ossgst_src_factory (void)
{
return
gst_pad_template_new (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
gst_caps_new (
"ossgst_src",
"audio/x-raw-int",
gst_props_new (
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"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),
NULL)),
gst_caps_new (
"ossgst_src",
"audio/x-mulaw",
gst_props_new (
"rate", GST_PROPS_INT_RANGE (8000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2),
NULL)),
gst_caps_new (
"ossgst_src",
"audio/x-alaw",
gst_props_new (
"rate", GST_PROPS_INT_RANGE (8000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2),
NULL)),
NULL);
}
static GstStaticPadTemplate ossgst_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (
"audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/x-mulaw, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) [ 1, 2 ]; "
"audio/x-alaw, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
);
static GstElementClass *parent_class = NULL;
......@@ -147,7 +124,7 @@ gst_ossgst_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_ossgst_details);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (ossgst_src_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&ossgst_src_factory));
}
static void
gst_ossgst_class_init (GstOssGstClass *klass)
......@@ -184,10 +161,10 @@ gst_ossgst_init (GstOssGst *ossgst)
ossgst->command = NULL;
}
static GstCaps*
static GstCaps2*
gst_ossgst_format_to_caps (gint format, gint stereo, gint rate)
{
GstCaps *caps = NULL;
GstCaps2 *caps = NULL;
gint law = 0;
gulong endianness = G_BYTE_ORDER;
gboolean is_signed = TRUE;
......@@ -244,35 +221,26 @@ gst_ossgst_format_to_caps (gint format, gint stereo, gint rate)
if (supported) {
switch (law) {
case 0:
caps = gst_caps_new (
"ossgst_caps",
"audio/x-raw-int",
gst_props_new (
"endianness", GST_PROPS_INT (endianness),
"signed", GST_PROPS_BOOLEAN (is_signed),
"width", GST_PROPS_INT (width),
"depth", GST_PROPS_INT (width),
"rate", GST_PROPS_INT (rate),
"channels", GST_PROPS_INT (stereo?2:1),
NULL));
caps = gst_caps2_new_simple ( "audio/x-raw-int",
"endianness", G_TYPE_INT, endianness,
"signed", G_TYPE_BOOLEAN, is_signed,
"width", G_TYPE_INT, width,
"depth", G_TYPE_INT, width,
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, stereo?2:1,
NULL);
break;
case 1:
caps = gst_caps_new (
"ossgst_caps",
"audio/x-mulaw",
gst_props_new (
"rate", GST_PROPS_INT (rate),
"channels", GST_PROPS_INT (stereo?2:1),
NULL));
caps = gst_caps2_new_simple ("audio/x-mulaw",
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, stereo?2:1,
NULL);
break;
case 2:
caps = gst_caps_new (
"ossgst_caps",
"audio/x-alaw",
gst_props_new (
"rate", GST_PROPS_INT (rate),
"channels", GST_PROPS_INT (stereo?2:1),
NULL));
caps = gst_caps2_new_simple ("audio/x-alaw",
"rate", G_TYPE_INT, rate,
"channels", G_TYPE_INT, stereo?2:1,
NULL);
break;
}
}
......@@ -312,7 +280,7 @@ gst_ossgst_get (GstPad *pad)
break;
case CMD_FORMAT:
{
GstCaps *caps;
GstCaps2 *caps;
caps = gst_ossgst_format_to_caps (cmd.cmd.format.format,
cmd.cmd.format.stereo,
......
......@@ -58,7 +58,7 @@ static gboolean gst_osssink_query (GstElement *element, GstQueryType type,
static gboolean gst_osssink_sink_query (GstPad *pad, GstQueryType type,
GstFormat *format, gint64 *value);
static GstPadLinkReturn gst_osssink_sinkconnect (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_osssink_sinkconnect (GstPad *pad, const GstCaps2 *caps);
static void gst_osssink_set_property (GObject *object, guint prop_id, const GValue *value,
GParamSpec *pspec);
......@@ -83,28 +83,18 @@ enum {
/* FILL ME */
};
GST_PAD_TEMPLATE_FACTORY (osssink_sink_factory,
static GstStaticPadTemplate osssink_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"osssink_sink",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"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 (1000, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
);
......@@ -164,7 +154,7 @@ gst_osssink_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_osssink_details);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (osssink_sink_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&osssink_sink_factory));
}
static void
gst_osssink_class_init (GstOssSinkClass *klass)
......@@ -214,7 +204,7 @@ static void
gst_osssink_init (GstOssSink *osssink)
{
osssink->sinkpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (osssink_sink_factory), "sink");
gst_static_pad_template_get (&osssink_sink_factory), "sink");
gst_element_add_pad (GST_ELEMENT (osssink), osssink->sinkpad);
gst_pad_set_link_function (osssink->sinkpad, gst_osssink_sinkconnect);
gst_pad_set_bufferpool_function (osssink->sinkpad, gst_osssink_get_bufferpool);
......@@ -241,13 +231,10 @@ gst_osssink_init (GstOssSink *osssink)
static GstPadLinkReturn
gst_osssink_sinkconnect (GstPad *pad, GstCaps *caps)
gst_osssink_sinkconnect (GstPad *pad, const GstCaps2 *caps)
{
GstOssSink *osssink = GST_OSSSINK (gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
if (!gst_osselement_parse_caps (GST_OSSELEMENT (osssink), caps))
return GST_PAD_LINK_REFUSED;
......
......@@ -57,37 +57,27 @@ enum {
ARG_FRAGMENT,
};
GST_PAD_TEMPLATE_FACTORY (osssrc_src_factory,
static GstStaticPadTemplate osssrc_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW (
"osssrc_src",
"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_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, 48000),
"channels", GST_PROPS_INT_RANGE (1, 2)
GST_STATIC_CAPS ("audio/x-raw-int, "
"endianness = (int) BYTE_ORDER, "
"signed = (boolean) { TRUE, FALSE }, "
"width = (int) { 8, 16 }, "
"depth = (int) { 8, 16 }, "
"rate = (int) [ 1000, 48000 ], "
"channels = (int) [ 1, 2 ]"
)
)
);
static void gst_osssrc_base_init (gpointer g_class);
static void gst_osssrc_class_init (GstOssSrcClass *klass);
static void gst_osssrc_init (GstOssSrc *osssrc);
static void gst_osssrc_dispose (GObject *object);
static GstPadLinkReturn gst_osssrc_srcconnect (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_osssrc_srcconnect (GstPad *pad, const GstCaps2 *caps);
static const GstFormat* gst_osssrc_get_formats (GstPad *pad);
static gboolean gst_osssrc_convert (GstPad *pad,
GstFormat src_format, gint64 src_value,
......@@ -143,7 +133,7 @@ gst_osssrc_base_init (gpointer g_class)
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_set_details (element_class, &gst_osssrc_details);
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (osssrc_src_factory));
gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&osssrc_src_factory));
}
static void
gst_osssrc_class_init (GstOssSrcClass *klass)
......@@ -179,7 +169,7 @@ static void
gst_osssrc_init (GstOssSrc *osssrc)
{
osssrc->srcpad = gst_pad_new_from_template (
GST_PAD_TEMPLATE_GET (osssrc_src_factory), "src");
gst_static_pad_template_get (&osssrc_src_factory), "src");
gst_pad_set_get_function (osssrc->srcpad, gst_osssrc_get);
gst_pad_set_link_function (osssrc->srcpad, gst_osssrc_srcconnect);
gst_pad_set_convert_function (osssrc->srcpad, gst_osssrc_convert);
......@@ -212,15 +202,12 @@ gst_osssrc_dispose (GObject *object)
}
static GstPadLinkReturn
gst_osssrc_srcconnect (GstPad *pad, GstCaps *caps)
gst_osssrc_srcconnect (GstPad *pad, const GstCaps2 *caps)
{
GstOssSrc *src;
src = GST_OSSSRC(gst_pad_get_parent (pad));
if (!GST_CAPS_IS_FIXED (caps))
return GST_PAD_LINK_DELAYED;
if (!gst_osselement_parse_caps (GST_OSSELEMENT (src), caps))
return GST_PAD_LINK_REFUSED;
......@@ -234,7 +221,7 @@ static gboolean
gst_osssrc_negotiate (GstPad *pad)
{
GstOssSrc *src;
GstCaps *allowed;
GstCaps2 *allowed;
src = GST_OSSSRC(gst_pad_get_parent (pad));
......@@ -248,17 +235,14 @@ gst_osssrc_negotiate (GstPad *pad)
/* set caps on src pad */
if (gst_pad_try_set_caps (src->srcpad,
GST_CAPS_NEW (
"oss_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (GST_OSSELEMENT (src)->endianness),
"signed", GST_PROPS_BOOLEAN (GST_OSSELEMENT (src)->sign),
"width", GST_PROPS_INT (GST_OSSELEMENT (src)->width),
"depth", GST_PROPS_INT (GST_OSSELEMENT (src)->depth),
"rate", GST_PROPS_INT (GST_OSSELEMENT (src)->rate),
"channels", GST_PROPS_INT (GST_OSSELEMENT (src)->channels)
)) <= 0)
{
gst_caps2_new_simple("audio/x-raw-int",
"endianness", G_TYPE_INT, GST_OSSELEMENT (src)->endianness,
"signed", G_TYPE_BOOLEAN, GST_OSSELEMENT (src)->sign,
"width", G_TYPE_INT, GST_OSSELEMENT (src)->width,
"depth", G_TYPE_INT, GST_OSSELEMENT (src)->depth,
"rate", G_TYPE_INT, GST_OSSELEMENT (src)->rate,
"channels", G_TYPE_INT, GST_OSSELEMENT (src)->channels,
NULL)) <= 0) {
return FALSE;
}
return TRUE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment