• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 typedef struct _GstBufferHandleConfig GstBufferHandleConfig;
32 
33 typedef enum {
34     FLAGS_READ_WRITE = 0x1,
35     FLAGS_READ_ONLY = 0x2,
36 } AVShmemFlags;
37 
38 typedef enum {
39     BUFFER_FLAG_NONE = 0,
40     BUFFER_FLAG_EOS = 1 << 0,
41     BUFFER_FLAG_SYNC_FRAME = 1 << 1,
42     BUFFER_FLAG_PARTIAL_FRAME = 1 << 2,
43     BUFFER_FLAG_CODEC_DATA = 1 << 3,
44 } BufferFlags;
45 
46 typedef enum {
47     BUFFER_TYPE_VIR,
48     BUFFER_TYPE_AVSHMEM,
49     BUFFER_TYPE_HANDLE,
50 } GstBufferType;
51 
52 struct _GstBufferTypeMeta {
53     GstMeta meta;
54     uint32_t id;
55     GstBufferType type;
56     intptr_t buf;
57     uint32_t bufLen;
58     uint32_t offset;
59     uint32_t length;
60     uint32_t totalSize;
61     int32_t fenceFd;
62     uint32_t memFlag;
63     uint32_t bufferFlag;
64     int32_t pixelFormat;
65     uint32_t width;
66     uint32_t height;
67     gboolean invalidpts;
68 };
69 
70 struct _GstBufferFdConfig {
71     uint32_t bufLen;
72     uint32_t offset;
73     uint32_t length;
74     uint32_t totalSize;
75     uint32_t memFlag;
76     uint32_t bufferFlag;
77 };
78 
79 struct _GstBufferHandleConfig {
80     uint32_t bufLen;
81     int32_t fenceFd;
82     uint32_t bufferFlag;
83     uint32_t length;
84     int32_t pixelFormat;
85     uint32_t width;
86     uint32_t height;
87 };
88 
89 GST_API_EXPORT GType gst_buffer_type_meta_api_get_type(void);
90 
91 GST_API_EXPORT const GstMetaInfo *gst_buffer_type_meta_get_info(void);
92 
93 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_get_buffer_type_meta(GstBuffer *buffer);
94 
95 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_vir_meta(GstBuffer *buffer,
96     intptr_t buf, uint32_t bufferFlag);
97 
98 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_handle_meta(GstBuffer *buffer, intptr_t buf,
99     GstBufferHandleConfig config);
100 
101 GST_API_EXPORT GstBufferTypeMeta *gst_buffer_add_buffer_fd_meta(GstBuffer *buffer, intptr_t buf,
102     GstBufferFdConfig config);
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 #endif
108