• 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_SURFACE_VIDEO_SRC_H__
17 #define __GST_SURFACE_VIDEO_SRC_H__
18 
19 #include <memory>
20 #include <gst/base/gstpushsrc.h>
21 #include "common_utils.h"
22 #include "video_capture.h"
23 
24 G_BEGIN_DECLS
25 
26 #define GST_TYPE_SURFACE_VIDEO_SRC \
27     (gst_surface_video_src_get_type())
28 #define GST_SURFACE_VIDEO_SRC(obj) \
29     (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_SURFACE_VIDEO_SRC, GstSurfaceVideoSrc))
30 #define GST_SURFACE_VIDEO_SRC_CLASS(klass) \
31     (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_SURFACE_VIDEO_SRC, GstSurfaceVideoSrcClass))
32 #define GST_IS_SURFACE_VIDEO_SRC(obj) \
33     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_SURFACE_VIDEO_SRC))
34 #define GST_IS_SURFACE_VIDEO_SRC_CLASS(klass) \
35     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_SURFACE_VIDEO_SRC))
36 #define GST_SURFACE_VIDEO_SRC_CAST(obj) ((GstSurfaceVideoSrc *)obj)
37 
38 /**
39  * GstSurfaceVideoSrc:
40  *
41  * Opaque #GstSurfaceVideoSrc structure.
42  */
43 struct _GstSurfaceVideoSrc {
44     GstBaseSrc parent_element;
45 
46     /* private */
47     VideoStreamType stream_type;
48     std::unique_ptr<OHOS::Media::VideoCapture> capture;
49     GstCaps *src_caps;
50     guint video_width;
51     guint video_height;
52     guint video_frame_rate;
53     gboolean is_start;
54     gboolean need_codec_data;
55     gboolean is_eos;
56     gboolean is_flushing;
57     gboolean reset_caps;
58 };
59 
60 struct _GstSurfaceVideoSrcClass {
61     GstPushSrcClass parent_class;
62 };
63 
64 using GstSurfaceVideoSrc = struct _GstSurfaceVideoSrc;
65 using GstSurfaceVideoSrcClass = struct _GstSurfaceVideoSrcClass;
66 
67 GType gst_surface_video_src_get_type(void);
68 
69 G_END_DECLS
70 #endif /* __GST_SURFACE_VIDEO_SRC_H__ */
71