• 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_PRODUCER_SURFACE_POOL_H
17 #define GST_PRODUCER_SURFACE_POOL_H
18 
19 #include <gst/gst.h>
20 #include <gst/video/video-info.h>
21 #include "surface.h"
22 #include "gst_surface_allocator.h"
23 #include "display_type.h"
24 
25 G_BEGIN_DECLS
26 
27 #define GST_TYPE_PRODUCER_SURFACE_POOL (gst_producer_surface_pool_get_type())
28 #define GST_PRODUCER_SURFACE_POOL(obj) \
29     (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_PRODUCER_SURFACE_POOL, GstProducerSurfacePool))
30 #define GST_PRODUCER_SURFACE_POOL_CLASS(klass) \
31     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_PRODUCER_SURFACE_POOL, GstProducerSurfacePoolClass))
32 #define GST_IS_SURFACE_POOL(obj) \
33     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_PRODUCER_SURFACE_POOL))
34 #define GST_IS_SURFACE_POOL_CLASS(klass) \
35     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_PRODUCER_SURFACE_POOL))
36 #define GST_PRODUCER_SURFACE_POOL_CAST(obj) ((GstProducerSurfacePool*)(obj))
37 
38 typedef struct _GstProducerSurfacePool GstProducerSurfacePool;
39 typedef struct _GstProducerSurfacePoolClass GstProducerSurfacePoolClass;
40 
41 struct _GstProducerSurfacePool {
42     GstBufferPool basepool;
43     OHOS::sptr<OHOS::Surface> surface;
44     gboolean started;
45     GstSurfaceAllocator *allocator;
46     GstAllocationParams params;
47     PixelFormat format;
48     GstVideoInfo info;
49     guint minBuffers;
50     guint maxBuffers;
51     GMutex lock;
52     GCond cond;
53     GList *preAllocated;
54     guint freeBufCnt;
55     guint64 usage;
56     GstTask *task;
57     GRecMutex taskLock;
58     timeval beginTime;
59     timeval endTime;
60     int32_t callCnt;
61     gboolean isDynamicCached;
62     guint cachedBuffers;
63     guint scale_type;
64 };
65 
66 struct _GstProducerSurfacePoolClass {
67     GstBufferPoolClass basepool_class;
68 };
69 
70 GType gst_producer_surface_pool_get_type(void);
71 
72 GstProducerSurfacePool *gst_producer_surface_pool_new(void);
73 
74 GST_API gboolean gst_producer_surface_pool_set_surface(GstProducerSurfacePool *pool,
75     OHOS::sptr<OHOS::Surface> surface);
76 
77 G_END_DECLS
78 
79 #endif