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_AUDIO_CAPTURE_SRC_H 17 #define GST_AUDIO_CAPTURE_SRC_H 18 19 #include <memory> 20 #include <gst/base/gstpushsrc.h> 21 #include "audio_capture.h" 22 #include "common_utils.h" 23 24 G_BEGIN_DECLS 25 26 #define GST_TYPE_AUDIO_CAPTURE_SRC \ 27 (gst_audio_capture_src_get_type()) 28 #define GST_AUDIO_CAPTURE_SRC(obj) \ 29 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUDIO_CAPTURE_SRC, GstAudioCaptureSrc)) 30 #define GST_FD_SRC_CLASS(klass) \ 31 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUDIO_CAPTURE_SRC, GstAudioCaptureSrcClass)) 32 #define GST_IS_AUDIO_CAPTURE_SRC(obj) \ 33 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUDIO_CAPTURE_SRC)) 34 #define GST_IS_AUDIO_CAPTURE_SRC_CLASS(klass) \ 35 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUDIO_CAPTURE_SRC)) 36 37 /** 38 * GstAudioCaptureSrc: 39 * 40 * Opaque #GstAudioCaptureSrc data structure. 41 */ 42 struct _GstAudioCaptureSrc { 43 GstPushSrc element; 44 45 /* private */ 46 AudioStreamType stream_type; 47 AudioSourceType source_type; 48 std::unique_ptr<OHOS::Media::AudioCapture> audio_capture; 49 GstCaps *src_caps; 50 guint32 bitrate; 51 guint32 channels; 52 guint32 sample_rate; 53 gboolean is_start; 54 gboolean need_caps_info; 55 }; 56 57 struct _GstAudioCaptureSrcClass { 58 GstPushSrcClass parent_class; 59 }; 60 61 using GstAudioCaptureSrc = struct _GstAudioCaptureSrc; 62 using GstAudioCaptureSrcClass = struct _GstAudioCaptureSrcClass; 63 64 G_GNUC_INTERNAL GType gst_audio_capture_src_get_type(void); 65 66 G_END_DECLS 67 68 #endif /* GST_AUDIO_CAPTURE_SRC_H */ 69