1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef GST_SHMEM_POOL_H 17 #define GST_SHMEM_POOL_H 18 19 #include <gst/gst.h> 20 #include <gst/video/video-info.h> 21 #include "gst_shmem_allocator.h" 22 23 G_BEGIN_DECLS 24 25 #ifndef GST_API_EXPORT 26 #define GST_API_EXPORT __attribute__((visibility("default"))) 27 #endif 28 29 #define GST_TYPE_SHMEM_POOL (gst_shmem_pool_get_type()) 30 #define GST_SHMEM_POOL(obj) \ 31 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SHMEM_POOL, GstShMemPool)) 32 #define GST_SHMEM_POOL_CLASS(klass) \ 33 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SHMEM_POOL, GstShMemPoolClass)) 34 #define GST_IS_SHMEM_POOL(obj) \ 35 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SHMEM_POOL)) 36 #define GST_IS_SHMEM_POOL_CLASS(klass) \ 37 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SHMEM_POOL)) 38 #define GST_SHMEM_POOL_CAST(obj) ((GstShMemPool*)(obj)) 39 40 typedef struct _GstShMemPool GstShMemPool; 41 typedef struct _GstShMemPoolClass GstShMemPoolClass; 42 43 struct _GstShMemPool { 44 GstBufferPool basepool; 45 gboolean started; 46 GstShMemAllocator *allocator; 47 GstAllocationParams params; 48 guint size; 49 guint minBuffers; 50 guint maxBuffers; 51 GMutex lock; 52 GCond cond; 53 gint curBuffers; 54 GstVideoInfo info; 55 gboolean addVideoMeta; 56 gboolean end; 57 gchar *debugName; 58 std::shared_ptr<OHOS::Media::AVSharedMemoryPool> avshmempool; 59 }; 60 61 struct _GstShMemPoolClass { 62 GstBufferPoolClass basepool_class; 63 }; 64 65 GST_API_EXPORT GType gst_shmem_pool_get_type(void); 66 67 GST_API_EXPORT GstShMemPool *gst_shmem_pool_new(); 68 69 GST_API_EXPORT gboolean gst_shmem_pool_set_avshmempool(GstShMemPool *pool, 70 const std::shared_ptr<OHOS::Media::AVSharedMemoryPool> &avshmempool); 71 72 G_END_DECLS 73 74 #endif