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 #ifndef GST_BUFFER_TYPE_META_H_ 16 #define GST_BUFFER_TYPE_META_H_ 17 18 #include <gst/gst.h> 19 #include <stdint.h> 20 #ifdef __cplusplus 21 extern "C" { 22 #endif 23 24 #ifndef GST_API_EXPORT 25 #define GST_API_EXPORT __attribute__((visibility("default"))) 26 #endif 27 #define GST_BUFFER_TYPE_META_API_TYPE (gst_buffer_type_meta_api_get_type()) 28 #define GST_BUFFER_TYPE_META_INFO (gst_buffer_type_meta_get_info()) 29 typedef struct _GstBufferTypeMeta GstBufferTypeMeta; 30 typedef struct _GstBufferFdConfig GstBufferFdConfig; 31 32 typedef enum { 33 FLAGS_READ_WRITE = 0x1, 34 FLAGS_READ_ONLY = 0x2, 35 } AVShmemFlags; 36 37 typedef enum { 38 BUFFER_FLAG_EOS = 0x1, 39 } BufferFlags; 40 41 typedef enum { 42 BUFFER_TYPE_VIR, 43 BUFFER_TYPE_AVSHMEM, 44 BUFFER_TYPE_HANDLE, 45 } BufferType; 46 47 struct _GstBufferTypeMeta { 48 GstMeta meta; 49 BufferType type; 50 intptr_t buf; 51 uint32_t offset; 52 uint32_t length; 53 uint32_t totalSize; 54 int32_t fenceFd; 55 uint32_t memFlag; 56 uint32_t bufferFlag; 57 }; 58 59 struct _GstBufferFdConfig { 60 uint32_t offset; 61 uint32_t length; 62 uint32_t totalSize; 63 uint32_t memFlag; 64 uint32_t bufferFlag; 65 }; 66 67 GST_API_EXPORT GType gst_buffer_type_meta_api_get_type(void); 68 69 GST_API_EXPORT const GstMetaInfo *gst_buffer_type_meta_get_info(void); 70 71 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_get_buffer_type_meta(GstBuffer *buffer); 72 73 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_vir_meta(GstBuffer *buffer, 74 intptr_t buf, uint32_t bufferFlag); 75 76 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_handle_meta(GstBuffer *buffer, intptr_t buf, 77 int32_t fenceFd, uint32_t bufferFlag); 78 79 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_fd_meta(GstBuffer *buffer, intptr_t buf, 80 GstBufferFdConfig config); 81 82 #ifdef __cplusplus 83 } 84 #endif 85 #endif 86