Merge branch 'move_subdir_editing-services' into tizen_gst_1.19.2_mono
[platform/upstream/gstreamer.git] / subprojects / gstreamer-vaapi / gst / vaapi / gstvaapivideobuffer.c
1 /*
2  *  gstvaapivideobuffer.c - Gstreamer/VA video buffer
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6  *  Copyright (C) 2011-2013 Intel Corporation
7  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
8  *
9  *  This library is free software; you can redistribute it and/or
10  *  modify it under the terms of the GNU Lesser General Public License
11  *  as published by the Free Software Foundation; either version 2.1
12  *  of the License, or (at your option) any later version.
13  *
14  *  This library is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  *  Lesser General Public License for more details.
18  *
19  *  You should have received a copy of the GNU Lesser General Public
20  *  License along with this library; if not, write to the Free
21  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22  *  Boston, MA 02110-1301 USA
23  */
24
25 /**
26  * SECTION:gstvaapivideobuffer
27  * @short_description: VA video buffer for GStreamer
28  *
29  * This functions creates and decorates a #GstBuffer that is going to
30  * be used by VA base gstreamer elements.
31  */
32
33 #include "gstcompat.h"
34 #include "gstvaapivideobuffer.h"
35
36 static GstBuffer *
37 new_vbuffer (GstVaapiVideoMeta * meta)
38 {
39   GstBuffer *buffer;
40
41   g_return_val_if_fail (meta != NULL, NULL);
42
43   buffer = gst_buffer_new ();
44   if (buffer)
45     gst_buffer_set_vaapi_video_meta (buffer, meta);
46   gst_vaapi_video_meta_unref (meta);
47   return buffer;
48 }
49
50 GstBuffer *
51 gst_vaapi_video_buffer_new (GstVaapiVideoMeta * meta)
52 {
53   g_return_val_if_fail (meta != NULL, NULL);
54
55   return new_vbuffer (gst_vaapi_video_meta_ref (meta));
56 }
57
58 GstBuffer *
59 gst_vaapi_video_buffer_new_empty (void)
60 {
61   return gst_buffer_new ();
62 }
63
64 GstBuffer *
65 gst_vaapi_video_buffer_new_from_pool (GstVaapiVideoPool * pool)
66 {
67   return new_vbuffer (gst_vaapi_video_meta_new_from_pool (pool));
68 }
69
70 GstBuffer *
71 gst_vaapi_video_buffer_new_from_buffer (GstBuffer * buffer)
72 {
73   GstVaapiVideoMeta *const meta = gst_buffer_get_vaapi_video_meta (buffer);
74
75   return meta ? new_vbuffer (gst_vaapi_video_meta_ref (meta)) : NULL;
76 }
77
78 GstBuffer *
79 gst_vaapi_video_buffer_new_with_image (GstVaapiImage * image)
80 {
81   return new_vbuffer (gst_vaapi_video_meta_new_with_image (image));
82 }
83
84 GstBuffer *
85 gst_vaapi_video_buffer_new_with_surface_proxy (GstVaapiSurfaceProxy * proxy)
86 {
87   return new_vbuffer (gst_vaapi_video_meta_new_with_surface_proxy (proxy));
88 }