• 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 
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     gint appuid;
49     gint apppid;
50     gfloat volume;
51     gfloat max_volume;
52     gfloat min_volume;
53     guint min_buffer_size;
54     guint min_frame_count;
55     gboolean frame_after_segment;
56     GMutex render_lock;
57     std::mutex mutex_;
58     GstBuffer *pause_cache_buffer;
59     guint renderer_desc;
60     gint renderer_flag;
61     GstClockTime last_render_pts;
62     gboolean enable_opt_render_delay;
63     GstClockTimeDiff last_running_time_diff;
64 };
65 
66 struct _GstAudioServerSinkClass {
67     GstBaseSinkClass parent_class;
68 };
69 
70 using GstAudioServerSink = struct _GstAudioServerSink;
71 using GstAudioServerSinkClass = struct _GstAudioServerSinkClass;
72 
73 G_GNUC_INTERNAL GType gst_audio_server_sink_get_type(void);
74 
75 G_END_DECLS
76 
77 #endif // GST_AUDIO_SERVER_SINK_H
78