diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2009-11-22 22:24:12 +0100 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2009-11-22 22:38:09 +0100 |
commit | a71cf4dfb2074044a7e8db8a3fced3bf70de8210 (patch) | |
tree | e1e26bf2843f394a6a603aee1ea89618afad1335 /sys | |
parent | 65bc7c87b2a2a2d1776b1592be4b7eb7c8367df3 (diff) |
gstvdpvideosrcpad: add "template-caps" property
The property limits the available output caps
Diffstat (limited to 'sys')
-rw-r--r-- | sys/vdpau/gstvdpmpegdec.c | 12 | ||||
-rw-r--r-- | sys/vdpau/gstvdpvideosrcpad.c | 66 | ||||
-rw-r--r-- | sys/vdpau/gstvdpvideosrcpad.h | 3 |
3 files changed, 57 insertions, 24 deletions
diff --git a/sys/vdpau/gstvdpmpegdec.c b/sys/vdpau/gstvdpmpegdec.c index 8fef8ca92..ec1db3292 100644 --- a/sys/vdpau/gstvdpmpegdec.c +++ b/sys/vdpau/gstvdpmpegdec.c @@ -1085,7 +1085,7 @@ gst_vdp_mpeg_dec_base_init (gpointer gclass) gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&sink_template)); - src_caps = gst_vdp_video_src_pad_get_template_caps (); + src_caps = gst_vdp_video_buffer_get_caps (TRUE, VDP_CHROMA_TYPE_420); src_template = gst_pad_template_new ("src", GST_PAD_SRC, GST_PAD_ALWAYS, src_caps); @@ -1133,7 +1133,15 @@ gst_vdp_mpeg_dec_init_info (VdpPictureInfoMPEG1Or2 * vdp_info) static void gst_vdp_mpeg_dec_init (GstVdpMpegDec * mpeg_dec, GstVdpMpegDecClass * gclass) { - mpeg_dec->src = GST_PAD (gst_vdp_video_src_pad_new ()); + GstPadTemplate *src_template; + + /* SRC PAD */ + src_template = + gst_element_class_get_pad_template (GST_ELEMENT_CLASS (gclass), "src"); + mpeg_dec->src = + GST_PAD (gst_vdp_video_src_pad_new (gst_pad_template_get_caps + (src_template))); + gst_pad_set_event_function (mpeg_dec->src, GST_DEBUG_FUNCPTR (gst_vdp_mpeg_dec_src_event)); gst_pad_set_query_function (mpeg_dec->src, diff --git a/sys/vdpau/gstvdpvideosrcpad.c b/sys/vdpau/gstvdpvideosrcpad.c index 453634cf2..93ced9b3f 100644 --- a/sys/vdpau/gstvdpvideosrcpad.c +++ b/sys/vdpau/gstvdpvideosrcpad.c @@ -28,7 +28,8 @@ GST_DEBUG_CATEGORY_STATIC (gst_vdp_video_src_pad_debug); enum { PROP_0, - PROP_DISPLAY + PROP_DISPLAY, + PROP_TEMPL_CAPS }; #define DEBUG_INIT(bla) \ @@ -73,8 +74,10 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad, } if (!gst_caps_is_equal_fixed (caps, GST_BUFFER_CAPS (out_buf))) { - GST_ERROR_OBJECT (vdp_pad, "Couldn't calculate buffer size for caps"); + GST_ERROR_OBJECT (vdp_pad, + "Sink element allocated buffer with different caps"); gst_buffer_unref (GST_BUFFER_CAST (video_buf)); + gst_buffer_unref (out_buf); return GST_FLOW_ERROR; } @@ -83,7 +86,8 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad, GST_ERROR_OBJECT (vdp_pad, "Couldn't convert from GstVdpVideoBuffer to the requested format"); gst_buffer_unref (GST_BUFFER_CAST (video_buf)); - gst_buffer_unref (GST_BUFFER_CAST (out_buf)); + gst_buffer_unref (out_buf); + return GST_FLOW_ERROR; } gst_buffer_copy_metadata (out_buf, (const GstBuffer *) video_buf, @@ -100,17 +104,21 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad, static void gst_vdp_video_src_pad_update_caps (GstVdpVideoSrcPad * vdp_pad) { - GstCaps *yuv_caps, *video_caps, *caps; + GstCaps *yuv_caps, *video_caps; video_caps = gst_vdp_video_buffer_get_allowed_video_caps (vdp_pad->device); yuv_caps = gst_vdp_video_buffer_get_allowed_yuv_caps (vdp_pad->device); gst_caps_append (video_caps, yuv_caps); - caps = gst_caps_intersect (video_caps, vdp_pad->caps); - gst_caps_unref (video_caps); - gst_caps_unref (vdp_pad->caps); - vdp_pad->caps = caps; + if (vdp_pad->caps) + gst_caps_unref (vdp_pad->caps); + + if (vdp_pad->templ_caps) { + vdp_pad->caps = gst_caps_intersect (video_caps, vdp_pad->templ_caps); + gst_caps_unref (video_caps); + } else + vdp_pad->caps = video_caps; } GstFlowReturn @@ -219,18 +227,17 @@ gst_vdp_video_src_pad_get_device (GstVdpVideoSrcPad * vdp_pad) return vdp_pad->device; } -GstCaps * -gst_vdp_video_src_pad_get_template_caps () -{ - return gst_vdp_video_buffer_get_caps (TRUE, VDP_CHROMA_TYPE_420); -} - static GstCaps * gst_vdp_video_src_pad_getcaps (GstPad * pad) { GstVdpVideoSrcPad *vdp_pad = (GstVdpVideoSrcPad *) pad; - return gst_caps_ref (vdp_pad->caps); + if (vdp_pad->caps) + return gst_caps_ref (vdp_pad->caps); + else if (vdp_pad->templ_caps) + return gst_caps_ref (vdp_pad->templ_caps); + + return NULL; } static gboolean @@ -243,18 +250,19 @@ gst_vdp_video_src_pad_activate_push (GstPad * pad, gboolean active) g_object_unref (vdp_pad->device); vdp_pad->device = NULL; - gst_caps_unref (vdp_pad->caps); - vdp_pad->caps = gst_vdp_video_buffer_get_caps (TRUE, VDP_CHROMA_TYPE_420); + if (vdp_pad->caps) + gst_caps_unref (vdp_pad->caps); + vdp_pad->caps = NULL; } return TRUE; } GstVdpVideoSrcPad * -gst_vdp_video_src_pad_new () +gst_vdp_video_src_pad_new (GstCaps * templ_caps) { return g_object_new (GST_TYPE_VDP_VIDEO_SRC_PAD, "direction", GST_PAD_SRC, - NULL); + "template-caps", templ_caps, NULL); } static void @@ -267,6 +275,9 @@ gst_vdp_video_src_pad_get_property (GObject * object, guint prop_id, case PROP_DISPLAY: g_value_set_string (value, vdp_pad->display); break; + case PROP_TEMPL_CAPS: + gst_value_set_caps (value, vdp_pad->templ_caps); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -283,6 +294,11 @@ gst_vdp_video_src_pad_set_property (GObject * object, guint prop_id, case PROP_DISPLAY: vdp_pad->display = g_value_dup_string (value); break; + case PROP_TEMPL_CAPS: + if (vdp_pad->templ_caps) + gst_caps_unref (vdp_pad->templ_caps); + vdp_pad->templ_caps = gst_caps_copy (gst_value_get_caps (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -295,6 +311,8 @@ gst_vdp_video_src_pad_finalize (GObject * object) GstVdpVideoSrcPad *vdp_pad = (GstVdpVideoSrcPad *) object; g_free (vdp_pad->display); + if (vdp_pad->templ_caps) + gst_caps_unref (vdp_pad->templ_caps); G_OBJECT_CLASS (gst_vdp_video_src_pad_parent_class)->finalize (object); } @@ -305,9 +323,10 @@ gst_vdp_video_src_pad_init (GstVdpVideoSrcPad * vdp_pad) GstPad *pad = GST_PAD (vdp_pad); vdp_pad->device = NULL; - vdp_pad->display = NULL; + vdp_pad->caps = NULL; - vdp_pad->caps = gst_vdp_video_buffer_get_caps (TRUE, VDP_CHROMA_TYPE_420); + vdp_pad->display = NULL; + vdp_pad->templ_caps = NULL; gst_pad_set_getcaps_function (pad, GST_DEBUG_FUNCPTR (gst_vdp_video_src_pad_getcaps)); @@ -328,4 +347,9 @@ gst_vdp_video_src_pad_class_init (GstVdpVideoSrcPadClass * klass) g_param_spec_string ("display", "Display", "X Display name", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + g_object_class_install_property (object_class, PROP_TEMPL_CAPS, + g_param_spec_boxed ("template-caps", "Template caps", + "Template caps", GST_TYPE_CAPS, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT)); + } diff --git a/sys/vdpau/gstvdpvideosrcpad.h b/sys/vdpau/gstvdpvideosrcpad.h index 0aab29871..05393ff34 100644 --- a/sys/vdpau/gstvdpvideosrcpad.h +++ b/sys/vdpau/gstvdpvideosrcpad.h @@ -51,6 +51,7 @@ struct _GstVdpVideoSrcPad /* properties */ gchar *display; + GstCaps *templ_caps; }; struct _GstVdpVideoSrcPadClass @@ -67,7 +68,7 @@ gboolean gst_vdp_video_src_pad_set_caps (GstVdpVideoSrcPad *vdp_pad, GstCaps *ca GstCaps *gst_vdp_video_src_pad_get_template_caps (); -GstVdpVideoSrcPad *gst_vdp_video_src_pad_new (); +GstVdpVideoSrcPad *gst_vdp_video_src_pad_new (GstCaps *templ_caps); GType gst_vdp_video_src_pad_get_type (void) G_GNUC_CONST; G_END_DECLS |