diff options
author | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 11:16:09 +0200 |
---|---|---|
committer | Carl-Anton Ingmarsson <ca.ingmarsson@gmail.com> | 2010-07-30 11:33:13 +0200 |
commit | c0e1fba08943e6b4873d0c3e0e2ae23c768de84f (patch) | |
tree | 2112073458cdb6367d4b35104ac701ce20986341 | |
parent | 2d9132c590ca2ee54a03b44733a4d0544cb7ec6c (diff) |
vdpau: use GstVdpVideoBufferPool in GstVdpVideoSrcPad
We also don't pad_alloc our GstVdpVideoBuffers anymore since we don't support
downstream negotation anyway.
-rw-r--r-- | sys/vdpau/gstvdp/gstvdpvideosrcpad.c | 92 |
1 files changed, 34 insertions, 58 deletions
diff --git a/sys/vdpau/gstvdp/gstvdpvideosrcpad.c b/sys/vdpau/gstvdp/gstvdpvideosrcpad.c index 7c8444b8d..6c8a88368 100644 --- a/sys/vdpau/gstvdp/gstvdpvideosrcpad.c +++ b/sys/vdpau/gstvdp/gstvdpvideosrcpad.c @@ -21,2 +21,3 @@ #include "gstvdpvideobuffer.h" +#include "gstvdpvideobufferpool.h" @@ -37,2 +38,3 @@ struct _GstVdpVideoSrcPad + GstVdpBufferPool *bpool; GstCaps *caps; @@ -135,34 +137,2 @@ gst_vdp_video_src_pad_push (GstVdpVideoSrcPad * vdp_pad, -static GstFlowReturn -gst_vdp_video_src_pad_alloc_with_caps (GstVdpVideoSrcPad * vdp_pad, - GstCaps * caps, GstVdpVideoBuffer ** video_buf, GError ** error) -{ - GstFlowReturn ret; - - ret = gst_pad_alloc_buffer ((GstPad *) vdp_pad, 0, 0, caps, - (GstBuffer **) video_buf); - if (ret != GST_FLOW_OK) - return ret; - - if (!gst_caps_is_equal_fixed (caps, GST_BUFFER_CAPS (*video_buf))) - goto wrong_caps; - - if (!GST_IS_VDP_VIDEO_BUFFER (*video_buf)) - goto invalid_buf; - - return GST_FLOW_OK; - -wrong_caps: - gst_buffer_unref (GST_BUFFER (*video_buf)); - g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, - "Sink element returned buffer with wrong caps"); - return GST_FLOW_ERROR; - -invalid_buf: - gst_buffer_unref (GST_BUFFER (*video_buf)); - g_set_error (error, GST_STREAM_ERROR, GST_STREAM_ERROR_FAILED, - "Sink element returned buffer of wrong type"); - return GST_FLOW_ERROR; -} - GstFlowReturn @@ -172,3 +142,2 @@ gst_vdp_video_src_pad_alloc_buffer (GstVdpVideoSrcPad * vdp_pad, GstCaps *caps; - GstFlowReturn ret; @@ -180,23 +149,9 @@ gst_vdp_video_src_pad_alloc_buffer (GstVdpVideoSrcPad * vdp_pad, - if (vdp_pad->yuv_output) { - GstVdpDevice *device = vdp_pad->device; - - *video_buf = gst_vdp_video_buffer_new (device, VDP_CHROMA_TYPE_420, - vdp_pad->width, vdp_pad->height, NULL); - if (!*video_buf) - goto video_buf_error; - - } else { - ret = gst_vdp_video_src_pad_alloc_with_caps (vdp_pad, caps, video_buf, - error); - if (ret != GST_FLOW_OK) - return ret; - } + *video_buf = + (GstVdpVideoBuffer *) gst_vdp_buffer_pool_get_buffer (vdp_pad->bpool, + error); + if (!*video_buf) + return GST_FLOW_ERROR; return GST_FLOW_OK; - -video_buf_error: - g_set_error (error, GST_RESOURCE_ERROR, GST_RESOURCE_ERROR_READ, - "Couldn't create a GstVdpVideoBuffer"); - return GST_FLOW_ERROR; } @@ -209,2 +164,5 @@ gst_vdp_video_src_pad_setcaps (GstPad * pad, GstCaps * caps) + VdpChromaType chroma_type; + GstCaps *video_caps; + structure = gst_caps_get_structure (caps, 0); @@ -218,2 +176,4 @@ gst_vdp_video_src_pad_setcaps (GstPad * pad, GstCaps * caps) + chroma_type = VDP_CHROMA_TYPE_420; + vdp_pad->yuv_output = TRUE; @@ -224,2 +184,5 @@ gst_vdp_video_src_pad_setcaps (GstPad * pad, GstCaps * caps) return FALSE; + if (!gst_structure_get_int (structure, "chroma-type", + (gint *) & chroma_type)) + return FALSE; @@ -229,2 +192,8 @@ gst_vdp_video_src_pad_setcaps (GstPad * pad, GstCaps * caps) + video_caps = gst_caps_new_simple ("video/x-vdpau-video", + "chroma-type", G_TYPE_INT, (gint) chroma_type, + "width", G_TYPE_INT, vdp_pad->width, + "height", G_TYPE_INT, vdp_pad->height, NULL); + gst_vdp_buffer_pool_set_caps (vdp_pad->bpool, video_caps); + return TRUE; @@ -267,3 +236,4 @@ gst_vdp_video_src_pad_activate_push (GstPad * pad, gboolean active) static void -gst_vdp_video_src_pad_update_caps (GstVdpVideoSrcPad * vdp_pad) +gst_vdp_video_src_pad_set_device (GstVdpVideoSrcPad * vdp_pad, + GstVdpDevice * device) { @@ -272,2 +242,11 @@ gst_vdp_video_src_pad_update_caps (GstVdpVideoSrcPad * vdp_pad) + if (vdp_pad->bpool) + g_object_unref (vdp_pad->bpool); + if (vdp_pad->device) + g_object_unref (vdp_pad->device); + + vdp_pad->device = device; + vdp_pad->bpool = gst_vdp_video_buffer_pool_new (device); + + /* update caps */ if (vdp_pad->caps) @@ -275,3 +254,3 @@ gst_vdp_video_src_pad_update_caps (GstVdpVideoSrcPad * vdp_pad) - caps = gst_vdp_video_buffer_get_allowed_caps (vdp_pad->device); + caps = gst_vdp_video_buffer_get_allowed_caps (device); @@ -309,6 +288,3 @@ gst_vdp_video_src_pad_set_property (GObject * object, guint prop_id, case PROP_DEVICE: - if (vdp_pad->device) - g_object_unref (vdp_pad->device); - vdp_pad->device = g_value_dup_object (value); - gst_vdp_video_src_pad_update_caps (vdp_pad); + gst_vdp_video_src_pad_set_device (vdp_pad, g_value_dup_object (value)); break; |