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_ALLOCATOR_H 17 #define GST_SHMEM_ALLOCATOR_H 18 19 #include <gst/gst.h> 20 #include "gst_shmem_memory.h" 21 #include "avsharedmemorypool.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_ALLOCATOR (gst_shmem_allocator_get_type()) 30 #define GST_SHMEM_ALLOCATOR(obj) \ 31 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SHMEM_ALLOCATOR, GstShMemAllocator)) 32 #define GST_SHMEM_ALLOCATOR_CLASS(klass) \ 33 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SHMEM_ALLOCATOR, GstShMemAllocatorClass)) 34 #define GST_IS_SHMEM_ALLOCATOR(obj) \ 35 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SHMEM_ALLOCATOR)) 36 #define GST_IS_SHMEM_ALLOCATOR_CLASS(klass) \ 37 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SHMEM_ALLOCATOR)) 38 #define GST_SHMEM_ALLOCATOR_CAST(obj) ((GstShMemAllocator*)(obj)) 39 40 typedef struct _GstShMemAllocator GstShMemAllocator; 41 typedef struct _GstShMemAllocatorClass GstShMemAllocatorClass; 42 43 struct _GstShMemAllocator { 44 GstAllocator parent; 45 std::shared_ptr<OHOS::Media::AVSharedMemoryPool> avShmemPool; 46 }; 47 48 struct _GstShMemAllocatorClass { 49 GstAllocatorClass parent; 50 }; 51 52 GST_API_EXPORT GType gst_shmem_allocator_get_type(void); 53 54 GST_API_EXPORT GstShMemAllocator *gst_shmem_allocator_new(); 55 56 GST_API_EXPORT void gst_shmem_allocator_set_pool(GstShMemAllocator *allocator, 57 std::shared_ptr<OHOS::Media::AVSharedMemoryPool> pool); 58 59 G_END_DECLS 60 61 #endif 62