1 /* 2 * Copyright (C) 2022 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_VIDEO_CAPTURE_SRC_H 17 #define GST_VIDEO_CAPTURE_SRC_H 18 19 #include <memory> 20 #include "gst_surface_src.h" 21 #include "common_utils.h" 22 23 G_BEGIN_DECLS 24 25 #define GST_TYPE_VIDEO_CAPTURE_SRC \ 26 (gst_video_capture_src_get_type()) 27 #define GST_VIDEO_CAPTURE_SRC(obj) \ 28 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_VIDEO_CAPTURE_SRC, GstVideoCaptureSrc)) 29 #define GST_VIDEO_CAPTURE_SRC_CLASS(klass) \ 30 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_VIDEO_CAPTURE_SRC, GstVideoCaptureSrcClass)) 31 #define GST_IS_VIDEO_CAPTURE_SRC(obj) \ 32 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VIDEO_CAPTURE_SRC)) 33 #define GST_IS_VIDEO_CAPTURE_SRC_CLASS(klass) \ 34 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VIDEO_CAPTURE_SRC)) 35 #define GST_VIDEO_CAPTURE_SRC_CAST(obj) ((GstVideoCaptureSrc *)(obj)) 36 37 typedef enum { 38 RECORDER_INITIALIZED = 0, 39 RECORDER_RUNNING, 40 RECORDER_PAUSED, 41 RECORDER_RESUME, 42 RECORDER_STOP, 43 } VideoRecorderState; 44 45 struct _GstVideoCaptureSrc { 46 GstSurfaceSrc element; 47 48 /* private */ 49 VideoStreamType stream_type; 50 GstCaps *src_caps; 51 guint video_width; 52 guint video_height; 53 guint min_buffer_size; 54 guint video_frame_rate; 55 gboolean is_first_buffer; 56 VideoRecorderState cur_state; 57 gint64 min_interval; 58 59 // about pause/resume 60 gint64 last_timestamp; 61 gint64 paused_time; // the timestamp when video pause called 62 gint64 resume_time; // the timestamp when video resume called 63 guint paused_count; // the paused count times 64 gint64 persist_time; 65 gint64 total_pause_time; 66 }; 67 68 struct _GstVideoCaptureSrcClass { 69 GstSurfaceSrcClass parent_class; 70 }; 71 72 using GstVideoCaptureSrc = struct _GstVideoCaptureSrc; 73 using GstVideoCaptureSrcClass = struct _GstVideoCaptureSrcClass; 74 75 GType gst_video_capture_src_get_type(void); 76 77 G_END_DECLS 78 #endif /* GST_VIDEO_CAPTURE_SRC_H */ 79