Commit efac0e00 authored by David Schleef's avatar David Schleef

Convert to new caps

Original commit message from CVS:
Convert to new caps
parent ea40cc5d
......@@ -58,51 +58,28 @@ enum {
};
static GstPadTemplate*
mikmod_src_factory (void)
{
static GstPadTemplate *template = NULL;
if (!template) {
template = gst_pad_template_new (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
gst_caps_new (
"mikmod_src",
"audio/x-raw-int",
GST_AUDIO_INT_PAD_TEMPLATE_PROPS
), NULL);
}
return template;
}
static GstPadTemplate*
mikmod_sink_factory (void)
{
static GstPadTemplate *template = NULL;
if (!template) {
template = gst_pad_template_new (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
gst_caps_new (
"mikmod_sink",
"audio/x-mod",
NULL),NULL
);
}
return template;
}
static GstStaticPadTemplate mikmod_src_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS (GST_AUDIO_INT_PAD_TEMPLATE_CAPS)
);
static GstStaticPadTemplate mikmod_sink_factory =
GST_STATIC_PAD_TEMPLATE (
"sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("audio/x-mod")
);
static void gst_mikmod_base_init (gpointer g_class);
static void gst_mikmod_class_init (GstMikModClass *klass);
static void gst_mikmod_init (GstMikMod *filter);
static void gst_mikmod_set_property (GObject *object, guint id, const GValue *value, GParamSpec *pspec );
static void gst_mikmod_get_property (GObject *object, guint id, GValue *value, GParamSpec *pspec );
static GstPadLinkReturn gst_mikmod_srclink (GstPad *pad, GstCaps *caps);
static GstPadLinkReturn gst_mikmod_srclink (GstPad *pad, const GstCaps2 *caps);
static void gst_mikmod_loop (GstElement *element);
static gboolean gst_mikmod_setup (GstMikMod *mikmod);
static GstElementStateReturn gst_mikmod_change_state (GstElement *element);
......@@ -137,8 +114,10 @@ gst_mikmod_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class, mikmod_src_factory ());
gst_element_class_add_pad_template (element_class, mikmod_sink_factory ());
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&mikmod_src_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&mikmod_sink_factory));
gst_element_class_set_details (element_class, &mikmod_details);
}
......@@ -205,8 +184,10 @@ gst_mikmod_class_init (GstMikModClass *klass)
static void
gst_mikmod_init (GstMikMod *filter)
{
filter->sinkpad = gst_pad_new_from_template(mikmod_sink_factory (),"sink");
filter->srcpad = gst_pad_new_from_template(mikmod_src_factory (),"src");
filter->sinkpad = gst_pad_new_from_template(
gst_static_pad_template_get (&mikmod_sink_factory),"sink");
filter->srcpad = gst_pad_new_from_template(
gst_static_pad_template_get (&mikmod_src_factory),"src");
gst_element_add_pad(GST_ELEMENT(filter),filter->sinkpad);
gst_element_add_pad(GST_ELEMENT(filter),filter->srcpad);
......@@ -245,39 +226,35 @@ gst_mikmod_negotiate (GstMikMod *mikmod)
sign = FALSE;
}
return gst_pad_try_set_caps (mikmod->srcpad,
GST_CAPS_NEW (
"mikmod_src",
"audio/x-raw-int",
"endianness", GST_PROPS_INT (G_BYTE_ORDER),
"signed", GST_PROPS_BOOLEAN (sign),
"width", GST_PROPS_INT (width),
"depth", GST_PROPS_INT (width),
"rate", GST_PROPS_INT (mikmod->mixfreq),
"channels", GST_PROPS_INT (mikmod->stereo ? 2 : 1)));
return gst_pad_try_set_caps (mikmod->srcpad,
gst_caps2_new_simple ( "audio/x-raw-int",
"endianness", G_TYPE_INT, G_BYTE_ORDER,
"signed", G_TYPE_BOOLEAN, sign,
"width", G_TYPE_INT, width,
"depth", G_TYPE_INT, width,
"rate", G_TYPE_INT, mikmod->mixfreq,
"channels", G_TYPE_INT, mikmod->stereo ? 2 : 1,
NULL));
}
static GstPadLinkReturn
gst_mikmod_srclink (GstPad *pad, GstCaps *caps)
gst_mikmod_srclink (GstPad *pad, const GstCaps2 *caps)
{
GstMikMod *filter;
GstStructure *structure;
gint depth;
gint channels;
filter = GST_MIKMOD (gst_pad_get_parent (pad));
if (gst_caps_has_property_typed (caps, "depth", GST_PROPS_INT_TYPE)) {
gint depth;
gst_caps_get_int (caps, "depth", &depth);
filter->_16bit = (depth == 16);
}
if (gst_caps_has_property_typed (caps, "channels", GST_PROPS_INT_TYPE)) {
gint channels;
gst_caps_get_int (caps, "channels", &channels);
filter->stereo = (channels == 2);
}
if (gst_caps_has_property_typed (caps, "rate", GST_PROPS_INT_TYPE)) {
gst_caps_get_int (caps, "rate", &filter->mixfreq);
}
structure = gst_caps2_get_nth_cap (caps, 0);
gst_structure_get_int (structure, "depth", &depth);
filter->_16bit = (depth == 16);
gst_structure_get_int (structure, "channels", &channels);
filter->stereo = (channels == 2);
gst_structure_get_int (structure, "rate", &filter->mixfreq);
return gst_mikmod_negotiate(filter);
}
......
......@@ -28,46 +28,35 @@ enum {
};
GST_PAD_TEMPLATE_FACTORY(textoverlay_src_template_factory,
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_CAPS_NEW(
"textoverlay_src",
"video/x-raw-yuv",
"format", GST_PROPS_LIST(
GST_PROPS_FOURCC(GST_STR_FOURCC("I420"))
),
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
"height", GST_PROPS_INT_RANGE(0, G_MAXINT)
)
)
GST_PAD_TEMPLATE_FACTORY(video_sink_template_factory,
"video_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW(
"video_sink",
"video/x-raw-yuv",
"format", GST_PROPS_LIST(
GST_PROPS_FOURCC(GST_STR_FOURCC("I420"))
),
"width", GST_PROPS_INT_RANGE(0, G_MAXINT),
"height", GST_PROPS_INT_RANGE(0, G_MAXINT)
)
)
GST_PAD_TEMPLATE_FACTORY(text_sink_template_factory,
"text_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_CAPS_NEW(
"text_sink",
"text/x-pango-markup",
NULL
)
)
static GstStaticPadTemplate textoverlay_src_template_factory =
GST_STATIC_PAD_TEMPLATE (
"src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) I420, "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate video_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"video_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv, "
"format = (fourcc) I420, "
"width = (int) [ 1, MAX ], "
"height = (int) [ 1, MAX ]")
);
static GstStaticPadTemplate text_sink_template_factory =
GST_STATIC_PAD_TEMPLATE (
"text_sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("text/x-pango-markup; text/plain")
);
static void gst_textoverlay_base_init (gpointer g_class);
static void gst_textoverlay_class_init(GstTextOverlayClass *klass);
......@@ -116,9 +105,12 @@ gst_textoverlay_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 (textoverlay_src_template_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (video_sink_template_factory));
gst_element_class_add_pad_template (element_class, GST_PAD_TEMPLATE_GET (text_sink_template_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&textoverlay_src_template_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&video_sink_template_factory));
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&text_sink_template_factory));
gst_element_class_set_details (element_class, &textoverlay_details);
}
......@@ -221,25 +213,24 @@ render_text(GstTextOverlay *overlay)
}
/* static GstPadLinkReturn */
/* gst_textoverlay_text_sinkconnect (GstPad *pad, GstCaps *caps) */
/* gst_textoverlay_text_sinkconnect (GstPad *pad, GstCaps2 *caps) */
/* { */
/* return GST_PAD_LINK_DONE; */
/* } */
static GstPadLinkReturn
gst_textoverlay_video_sinkconnect(GstPad *pad, GstCaps *caps)
gst_textoverlay_video_sinkconnect(GstPad *pad, const GstCaps2 *caps)
{
GstTextOverlay *overlay;
GstStructure *structure;
overlay = GST_TEXTOVERLAY(gst_pad_get_parent(pad));
if (!GST_CAPS_IS_FIXED(caps))
return GST_PAD_LINK_DELAYED;
structure = gst_caps2_get_nth_cap (caps, 0);
overlay->width = overlay->height = 0;
gst_caps_get_int(caps, "width", &overlay->width);
gst_caps_get_int(caps, "height", &overlay->height);
gst_structure_get_int (structure, "width", &overlay->width);
gst_structure_get_int (structure, "height", &overlay->height);
return gst_pad_try_set_caps(overlay->srcpad, caps);
}
......@@ -514,20 +505,20 @@ gst_textoverlay_init(GstTextOverlay *overlay)
{
/* video sink */
overlay->video_sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(video_sink_template_factory), "video_sink");
gst_static_pad_template_get (&video_sink_template_factory), "video_sink");
/* gst_pad_set_chain_function(overlay->video_sinkpad, gst_textoverlay_video_chain); */
gst_pad_set_link_function(overlay->video_sinkpad, gst_textoverlay_video_sinkconnect);
gst_element_add_pad(GST_ELEMENT(overlay), overlay->video_sinkpad);
/* text sink */
overlay->text_sinkpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(text_sink_template_factory), "text_sink");
gst_static_pad_template_get (&text_sink_template_factory), "text_sink");
/* gst_pad_set_link_function(overlay->text_sinkpad, gst_textoverlay_text_sinkconnect); */
gst_element_add_pad(GST_ELEMENT(overlay), overlay->text_sinkpad);
/* (video) source */
overlay->srcpad = gst_pad_new_from_template(
GST_PAD_TEMPLATE_GET(textoverlay_src_template_factory), "src");
gst_static_pad_template_get (&textoverlay_src_template_factory), "src");
gst_element_add_pad(GST_ELEMENT(overlay), overlay->srcpad);
overlay->layout = pango_layout_new(GST_TEXTOVERLAY_GET_CLASS(overlay)->pango_context);
......
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