1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) Carl-Anton Ingmarsson 2010 <ca.ingmarsson@gmail.com>
6 * gst-plugins-bad is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * gst-plugins-bad is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "gstvdpdevice.h"
21 #include "gstvdpvideobuffer.h"
23 #include "gstvdpvideobufferpool.h"
26 struct _GstVdpVideoBufferPool
28 GstVdpBufferPool buffer_pool;
30 VdpChromaType chroma_type;
34 G_DEFINE_TYPE (GstVdpVideoBufferPool, gst_vdp_video_buffer_pool,
35 GST_TYPE_VDP_BUFFER_POOL);
38 gst_vdp_video_buffer_pool_new (GstVdpDevice * device)
40 g_return_val_if_fail (GST_IS_VDP_DEVICE (device), NULL);
42 return g_object_new (GST_TYPE_VDP_VIDEO_BUFFER_POOL, "device", device, NULL);
46 parse_caps (const GstCaps * caps, VdpChromaType * chroma_type, gint * width,
49 GstStructure *structure;
51 structure = gst_caps_get_structure (caps, 0);
53 if (!gst_structure_get_int (structure, "chroma-type", (gint *) chroma_type))
55 if (!gst_structure_get_int (structure, "width", width))
57 if (!gst_structure_get_int (structure, "height", height))
64 gst_vdp_video_buffer_pool_check_caps (GstVdpBufferPool * bpool,
67 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
69 VdpChromaType chroma_type;
72 if (!parse_caps (caps, &chroma_type, &width, &height))
75 if (chroma_type != vpool->chroma_type || width != vpool->width ||
76 height != vpool->height)
83 gst_vdp_video_buffer_pool_set_caps (GstVdpBufferPool * bpool,
84 const GstCaps * caps, gboolean * clear_bufs)
86 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
88 VdpChromaType chroma_type;
91 if (!parse_caps (caps, &chroma_type, &width, &height))
94 if (chroma_type != vpool->chroma_type || width != vpool->width ||
95 height != vpool->height)
100 vpool->chroma_type = chroma_type;
101 vpool->width = width;
102 vpool->height = height;
107 static GstVdpBuffer *
108 gst_vdp_video_buffer_pool_alloc_buffer (GstVdpBufferPool * bpool,
111 GstVdpVideoBufferPool *vpool = GST_VDP_VIDEO_BUFFER_POOL (bpool);
112 GstVdpDevice *device;
114 device = gst_vdp_buffer_pool_get_device (bpool);
115 return GST_VDP_BUFFER_CAST (gst_vdp_video_buffer_new (device,
116 vpool->chroma_type, vpool->width, vpool->height, error));
120 gst_vdp_video_buffer_pool_finalize (GObject * object)
122 /* TODO: Add deinitalization code here */
124 G_OBJECT_CLASS (gst_vdp_video_buffer_pool_parent_class)->finalize (object);
128 gst_vdp_video_buffer_pool_init (GstVdpVideoBufferPool * vpool)
130 vpool->chroma_type = -1;
136 gst_vdp_video_buffer_pool_class_init (GstVdpVideoBufferPoolClass * klass)
138 GObjectClass *object_class = G_OBJECT_CLASS (klass);
139 GstVdpBufferPoolClass *buffer_pool_class = GST_VDP_BUFFER_POOL_CLASS (klass);
141 buffer_pool_class->alloc_buffer = gst_vdp_video_buffer_pool_alloc_buffer;
142 buffer_pool_class->set_caps = gst_vdp_video_buffer_pool_set_caps;
143 buffer_pool_class->check_caps = gst_vdp_video_buffer_pool_check_caps;
145 object_class->finalize = gst_vdp_video_buffer_pool_finalize;