• 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 
16 #ifndef __GST_MEM_POOL_SRC_H__
17 #define __GST_MEM_POOL_SRC_H__
18 
19 #include <gst/base/gstbasesrc.h>
20 
21 G_BEGIN_DECLS
22 
23 #ifndef GST_API_EXPORT
24 #define GST_API_EXPORT __attribute__((visibility("default")))
25 #endif
26 
27 #define GST_TYPE_MEM_POOL_SRC (gst_mem_pool_src_get_type())
28 #define GST_MEM_POOL_SRC(obj) \
29     (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_MEM_POOL_SRC, GstMemPoolSrc))
30 #define GST_MEM_POOL_SRC_CLASS(klass) \
31     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_MEM_POOL_SRC, GstMemPoolSrcClass))
32 #define GST_MEM_POOL_SRC_GET_CLASS(obj) \
33     (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_MEM_POOL_SRC, GstMemPoolSrcClass))
34 #define GST_IS_MEM_POOL_SRC(obj) \
35     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_MEM_POOL_SRC))
36 #define GST_IS_MEM_POOL_SRC_CLASS(klass) \
37     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_MEM_POOL_SRC))
38 #define GST_MEM_POOL_SRC_CAST(obj) ((GstMemPoolSrc*)(obj))
39 
40 typedef struct _GstMemPoolSrc GstMemPoolSrc;
41 typedef struct _GstMemPoolSrcClass GstMemPoolSrcClass;
42 typedef struct _GstMemPoolSrcPrivate GstMemPoolSrcPrivate;
43 typedef GstFlowReturn (*BufferAvailable) (GstMemPoolSrc *memsrc, gpointer user_data);
44 
45 struct _GstMemPoolSrc {
46     GstBaseSrc basesrc;
47     GstCaps *caps;
48     guint buffer_size;
49     guint buffer_num;
50 
51     /* < private > */
52     GstMemPoolSrcPrivate *priv;
53 };
54 
55 struct _GstMemPoolSrcClass {
56     GstBaseSrcClass parent;
57 
58     // for API and action calling, subclass need accomplish it
59     GstBuffer *(*pull_buffer) (GstMemPoolSrc *memsrc);
60     GstFlowReturn (*push_buffer) (GstMemPoolSrc *memsrc, GstBuffer *buffer);
61 };
62 
63 // for subclass to use
64 GstFlowReturn gst_mem_pool_src_buffer_available(GstMemPoolSrc *memsrc);
65 // for app to use
66 GST_API_EXPORT GstBuffer *gst_mem_pool_src_pull_buffer(GstMemPoolSrc *memsrc);
67 
68 GST_API_EXPORT GstFlowReturn gst_mem_pool_src_push_buffer(GstMemPoolSrc *memsrc, GstBuffer *buffer);
69 
70 GST_API_EXPORT void gst_mem_pool_src_set_callback(GstMemPoolSrc *memsrc, BufferAvailable callback,
71     gpointer user_data, GDestroyNotify notify);
72 
73 GST_API_EXPORT GType gst_mem_pool_src_get_type(void);
74 
75 G_END_DECLS
76 #endif