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 17 #ifndef GST_AUDIO_SERVER_SINK_H 18 #define GST_AUDIO_SERVER_SINK_H 19 20 #include <mutex> 21 #include <memory> 22 #include <gst/base/gstbasesink.h> 23 #include "audio_sink.h" 24 #include "common_utils.h" 25 26 G_BEGIN_DECLS 27 28 #define GST_TYPE_AUDIO_SERVER_SINK \ 29 (gst_audio_server_sink_get_type()) 30 #define GST_AUDIO_SERVER_SINK(obj) \ 31 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_AUDIO_SERVER_SINK, GstAudioServerSink)) 32 #define GST_AUDIO_SERVER_SINK_CLASS(klass) \ 33 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_AUDIO_SERVER_SINK, GstAudioServerSinkClass)) 34 #define GST_IS_AUDIO_SERVER_SINK(obj) \ 35 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_AUDIO_SERVER_SINK)) 36 #define GST_IS_AUDIO_SERVER_SINK_CLASS(klass) \ 37 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_AUDIO_SERVER_SINK)) 38 #define GST_AUDIO_SERVER_SINK_CAST(obj) ((GstAudioServerSink *)(obj)) 39 40 struct _GstAudioServerSink { 41 GstBaseSink parent; 42 43 /* private */ 44 std::unique_ptr<OHOS::Media::AudioSink> audio_sink; 45 guint bits_per_sample; 46 guint channels; 47 guint sample_rate; 48 gfloat volume; 49 gfloat max_volume; 50 gfloat min_volume; 51 guint min_buffer_size; 52 guint min_frame_count; 53 GstBuffer *cache_buffer; 54 guint cache_size; 55 gboolean enable_cache; 56 gboolean frame_after_segment; 57 GMutex render_lock; 58 std::mutex mutex_; 59 GstBuffer *pause_cache_buffer; 60 }; 61 62 struct _GstAudioServerSinkClass { 63 GstBaseSinkClass parent_class; 64 }; 65 66 using GstAudioServerSink = struct _GstAudioServerSink; 67 using GstAudioServerSinkClass = struct _GstAudioServerSinkClass; 68 69 G_GNUC_INTERNAL GType gst_audio_server_sink_get_type (void); 70 71 G_END_DECLS 72 73 #endif // GST_AUDIO_SERVER_SINK_H 74