2 * GStreamer tizen memory
3 * Copyright (c) 2018 Samsung Electronics Co., Ltd.
4 * Author: Sejun Park <sejun79.park@samsung.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 #ifndef __GST_TIZEN_MEMORY_H__
22 #define __GST_TIZEN_MEMORY_H__
25 #include <gst/allocators/allocators-prelude.h>
26 #include <gst/video/video.h>
27 #include <gst/video/gstvideometa.h>
28 //#include <gst/gstallocator.h>
29 #include <gst/gstmemory.h>
30 #include <tbm_bufmgr.h>
31 #include <tbm_surface.h>
35 typedef struct _GstTizenAllocator GstTizenAllocator;
36 typedef struct _GstTizenAllocatorClass GstTizenAllocatorClass;
37 typedef struct _GstTizenAllocatorPrivate GstTizenAllocatorPrivate;
39 typedef struct _GstTizenMemory GstTizenMemory;
40 #define GST_TYPE_TIZEN_ALLOCATOR (gst_tizen_allocator_get_type())
43 GType gst_tizen_allocator_get_type(void);
45 #define GST_IS_TIZEN_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_TIZEN_ALLOCATOR))
46 #define GST_IS_TIZEN_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_TIZEN_ALLOCATOR))
47 #define GST_TIZEN_ALLOCATOR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_TIZEN_ALLOCATOR, GstTizenAllocatorClass))
48 #define GST_TIZEN_ALLOCATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_TIZEN_ALLOCATOR, GstTizenAllocator))
49 #define GST_TIZEN_ALLOCATOR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_TIZEN_ALLOCATOR, GstTizenAllocatorClass))
50 #define GST_TIZEN_ALLOCATOR_CAST(obj) ((GstTizenAllocator *)(obj))
52 #define GST_TIZEN_MEMORY_TYPE "TizenVideoMemory"
54 struct _GstTizenMemory
58 tbm_surface_h surface;
59 tbm_surface_info_s surface_info;
64 gboolean video_memory_map[GST_VIDEO_MAX_PLANES];
65 gint video_memory_map_count;
68 GDestroyNotify notify;
73 struct _GstTizenAllocatorPrivate
76 GstAllocator *dmabuf_alloc;
80 * GstTizenMemoryAllocator
82 * Base class for allocators with bo memory
84 struct _GstTizenAllocator
87 GstTizenAllocatorPrivate *priv;
91 struct _GstTizenAllocatorClass
93 GstAllocatorClass parent_class;
97 GstAllocator * gst_tizen_allocator_new (void);
100 GstMemory * gst_tizen_allocator_alloc (GstAllocator * allocator, GstVideoInfo * vinfo);
103 GstMemory * gst_tizen_allocator_alloc_surface (GstAllocator * allocator, GstVideoInfo * vinfo,
104 tbm_surface_h surface, gpointer user_data, GDestroyNotify notify);
107 gboolean gst_is_tizen_memory (GstMemory *mem);
110 gint gst_tizen_memory_get_num_bos (GstMemory *mem);
113 void * gst_tizen_memory_get_bos (GstMemory *mem, gint index);
116 void * gst_tizen_memory_get_surface (GstMemory *mem);
119 GstMemory * gst_tizen_allocator_dmabuf_export (GstAllocator * allocator, GstMemory *tmem, int bo_idx);
122 GstTizenMemory *gst_tizen_allocator_dmabuf_import (GstAllocator * allocator, gint * fds, gint planes, gsize offsets[4], GstVideoInfo * vinfo);
125 gboolean gst_tizen_video_meta_map (GstVideoMeta * meta, guint plane, GstMapInfo * info,
126 gpointer * data, gint * stride, GstMapFlags flags);
129 gboolean gst_tizen_video_meta_unmap (GstVideoMeta * meta, guint plane, GstMapInfo * info);
132 tbm_format gst_video_format_to_tbm_format (GstVideoFormat format);
136 #endif /* _GST_TIZEN_MEMORY_H_ */