From d0ab18f823217969b0058f7f88f4f44ab03e57f4 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 27 Jul 2004 10:33:59 +0000 Subject: [PATCH] gst/videomixer/videomixer.c: Be a nicer negotiation citizen and provide a getcaps function on the srcpad. This also f... Original commit message from CVS: * gst/videomixer/videomixer.c: (gst_videomixer_pad_get_type), (gst_videomixer_pad_class_init), (gst_videomixer_pad_get_property), (gst_videomixer_pad_set_property), (gst_videomixer_pad_sinkconnect), (gst_videomixer_pad_init), (gst_video_mixer_background_get_type), (gst_videomixer_get_type), (gst_videomixer_class_init), (gst_videomixer_init), (gst_videomixer_getcaps), (gst_videomixer_request_new_pad), (gst_videomixer_blend_ayuv_i420), (pad_zorder_compare), (gst_videomixer_sort_pads), (gst_videomixer_fill_checker), (gst_videomixer_fill_color), (gst_videomixer_fill_queues), (gst_videomixer_blend_buffers), (gst_videomixer_update_queues), (gst_videomixer_loop), (plugin_init): Be a nicer negotiation citizen and provide a getcaps function on the srcpad. This also fixes a crash when resizing. --- ChangeLog | 17 +++++++++++++++++ gst/videomixer/videomixer.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/ChangeLog b/ChangeLog index 6c29c1c827..1b220dfdd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2004-07-27 Wim Taymans + + * gst/videomixer/videomixer.c: (gst_videomixer_pad_get_type), + (gst_videomixer_pad_class_init), (gst_videomixer_pad_get_property), + (gst_videomixer_pad_set_property), + (gst_videomixer_pad_sinkconnect), (gst_videomixer_pad_init), + (gst_video_mixer_background_get_type), (gst_videomixer_get_type), + (gst_videomixer_class_init), (gst_videomixer_init), + (gst_videomixer_getcaps), (gst_videomixer_request_new_pad), + (gst_videomixer_blend_ayuv_i420), (pad_zorder_compare), + (gst_videomixer_sort_pads), (gst_videomixer_fill_checker), + (gst_videomixer_fill_color), (gst_videomixer_fill_queues), + (gst_videomixer_blend_buffers), (gst_videomixer_update_queues), + (gst_videomixer_loop), (plugin_init): + Be a nicer negotiation citizen and provide a getcaps function on + the srcpad. This also fixes a crash when resizing. + 2004-07-27 Julien MOUTTE * sys/xvimage/xvimagesink.c: (gst_xvimagesink_check_xshm_calls), diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c index adcb6bcc41..685cd25e5e 100644 --- a/gst/videomixer/videomixer.c +++ b/gst/videomixer/videomixer.c @@ -400,6 +400,8 @@ static void gst_videomixer_base_init (gpointer g_class); static void gst_videomixer_class_init (GstVideoMixerClass * klass); static void gst_videomixer_init (GstVideoMixer * videomixer); +static GstCaps *gst_videomixer_getcaps (GstPad * pad); + static void gst_videomixer_loop (GstElement * element); static gboolean gst_videomixer_handle_src_event (GstPad * pad, GstEvent * event); @@ -485,6 +487,7 @@ gst_videomixer_init (GstVideoMixer * mix) mix->srcpad = gst_pad_new_from_template (gst_element_class_get_pad_template (klass, "src"), "src"); + gst_pad_set_getcaps_function (GST_PAD (mix->srcpad), gst_videomixer_getcaps); gst_pad_set_event_function (mix->srcpad, gst_videomixer_handle_src_event); gst_element_add_pad (GST_ELEMENT (mix), mix->srcpad); @@ -500,6 +503,35 @@ gst_videomixer_init (GstVideoMixer * mix) gst_element_set_loop_function (GST_ELEMENT (mix), gst_videomixer_loop); } +static GstCaps * +gst_videomixer_getcaps (GstPad * pad) +{ + GstVideoMixer *mix; + GstCaps *caps; + GstPadTemplate *src_pad_template; + GstStructure *structure; + + + mix = GST_VIDEO_MIXER (gst_pad_get_parent (pad)); + src_pad_template = gst_static_pad_template_get (&src_factory); + caps = gst_caps_copy (gst_pad_template_get_caps (src_pad_template)); + + structure = gst_caps_get_structure (caps, 0); + + if (mix->out_width != 0) { + gst_structure_set (structure, "width", G_TYPE_INT, mix->out_width, NULL); + } + if (mix->out_height != 0) { + gst_structure_set (structure, "height", G_TYPE_INT, mix->out_height, NULL); + } + if (mix->in_framerate != 0) { + gst_structure_set (structure, + "framerate", G_TYPE_DOUBLE, mix->in_framerate, NULL); + } + + return caps; +} + static GstPad * gst_videomixer_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * req_name)