• 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_CONSUMER_SURFACE_POOL_H
17 #define GST_CONSUMER_SURFACE_POOL_H
18 
19 #include <gst/gst.h>
20 #include <gst/video/gstvideopool.h>
21 #include "surface.h"
22 
23 G_BEGIN_DECLS
24 
25 #define GST_TYPE_CONSUMER_SURFACE_POOL (gst_consumer_surface_pool_get_type())
26 #define GST_CONSUMER_SURFACE_POOL(obj) \
27     (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_CONSUMER_SURFACE_POOL, GstConsumerSurfacePool))
28 #define GST_CONSUMER_SURFACE_POOL_CLASS(klass) \
29     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_CONSUMER_SURFACE_POOL, GstConsumerSurfacePoolClass))
30 #define GST_CONSUMER_SURFACE_POOL_GET_CLASS(obj) \
31     (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_CONSUMER_SURFACE_POOL, GstConsumerSurfacePoolClass))
32 #define GST_IS_CONSUMER_SURFACE_POOL(obj) \
33     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_CONSUMER_SURFACE_POOL))
34 #define GST_IS_CONSUMER_SURFACE_POOL_CLASS(klass) \
35     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_CONSUMER_SURFACE_POOL))
36 #define GST_CONSUMER_SURFACE_POOL_CAST(obj) ((GstConsumerSurfacePool*)(obj))
37 
38 typedef struct _GstConsumerSurfacePool GstConsumerSurfacePool;
39 typedef struct _GstConsumerSurfacePoolClass GstConsumerSurfacePoolClass;
40 typedef struct _GstConsumerSurfacePoolPrivate GstConsumerSurfacePoolPrivate;
41 
42 /* 1. The acquire and release functions are overloaded and the queue is no longer used.
43  * 2. GstConsumerSurfacePool is mainly used to maintain the surface buffer.
44  */
45 struct _GstConsumerSurfacePool {
46     GstVideoBufferPool basepool;
47 
48     /* < private > */
49     GstConsumerSurfacePoolPrivate *priv;
50 
51     GstFlowReturn (*buffer_available) (GstConsumerSurfacePool *pool, bool *releasebuffer);
52     GstFlowReturn (*find_buffer) (GstBufferPool *pool, GstBuffer **buffer, bool *found);
53     GstFlowReturn (*get_surface_buffer) (GstConsumerSurfacePool *pool,
54         OHOS::sptr<OHOS::SurfaceBuffer> &surface_buffer, gint32 &fencefd);
55     void (*release_surface_buffer) (GstConsumerSurfacePool *pool,
56         OHOS::sptr<OHOS::SurfaceBuffer> &surface_buffer, gint32 &fencefd);
57 };
58 
59 struct _GstConsumerSurfacePoolClass {
60     GstVideoBufferPoolClass parent_class;
61 };
62 
63 GType gst_consumer_surface_pool_get_type(void);
64 
65 GstBufferPool *gst_consumer_surface_pool_new();
66 
67 GstCaps *gst_consumer_surface_pool_get_caps(GstConsumerSurfacePool *pool);
68 
69 void gst_consumer_surface_pool_set_surface(GstBufferPool *pool,
70     OHOS::sptr<OHOS::Surface> &consumer_surface);
71 G_END_DECLS
72 
73 #endif
74