• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ST_AUDIO_STREAM_MANAGER_H
17 #define ST_AUDIO_STREAM_MANAGER_H
18 
19 #include <iostream>
20 
21 #include "audio_info.h"
22 
23 namespace OHOS {
24 namespace AudioStandard {
25 class AudioRendererStateChangeCallback {
26 public:
27     virtual ~AudioRendererStateChangeCallback() = default;
28     /**
29      * Called when the renderer state changes
30      *
31      * @param rendererChangeInfo Contains the renderer state information.
32      */
33     virtual void OnRendererStateChange(
34         const std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos) = 0;
35 };
36 
37 class AudioCapturerStateChangeCallback {
38 public:
39     virtual ~AudioCapturerStateChangeCallback() = default;
40     /**
41      * Called when the capturer state changes
42      *
43      * @param capturerChangeInfo Contains the renderer state information.
44      */
45     virtual void OnCapturerStateChange(
46         const std::vector<std::unique_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos) = 0;
47 };
48 
49 class AudioClientTracker {
50 public:
51     virtual ~AudioClientTracker() = default;
52     /**
53      * Paused Stream was controlled by system application
54      *
55      * @param streamSetStateEventInternal Contains the set even information.
56      */
57     virtual void PausedStreamImpl(const StreamSetStateEventInternal &streamSetStateEventInternal) = 0;
58      /**
59      * Resumed Stream was controlled by system application
60      *
61      * @param streamSetStateEventInternal Contains the set even information.
62      */
63     virtual void ResumeStreamImpl(const StreamSetStateEventInternal &streamSetStateEventInternal) = 0;
64     virtual void SetLowPowerVolumeImpl(float volume) = 0;
65     virtual void GetLowPowerVolumeImpl(float &volume) = 0;
66     virtual void GetSingleStreamVolumeImpl(float &volume) = 0;
67 };
68 
69 class AudioStreamManager {
70 public:
71     AudioStreamManager() = default;
72     virtual ~AudioStreamManager() = default;
73 
74     static AudioStreamManager *GetInstance();
75     int32_t RegisterAudioRendererEventListener(const int32_t clientUID,
76                                               const std::shared_ptr<AudioRendererStateChangeCallback> &callback);
77     int32_t UnregisterAudioRendererEventListener(const int32_t clientUID);
78     int32_t RegisterAudioCapturerEventListener(const int32_t clientUID,
79                                               const std::shared_ptr<AudioCapturerStateChangeCallback> &callback);
80     int32_t UnregisterAudioCapturerEventListener(const int32_t clientUID);
81     int32_t GetCurrentRendererChangeInfos(
82         std::vector<std::unique_ptr<AudioRendererChangeInfo>> &audioRendererChangeInfos);
83     int32_t GetCurrentCapturerChangeInfos(
84         std::vector<std::unique_ptr<AudioCapturerChangeInfo>> &audioCapturerChangeInfos);
85     bool IsAudioRendererLowLatencySupported(const AudioStreamInfo &audioStreamInfo);
86 };
87 } // namespace AudioStandard
88 } // namespace OHOS
89 #endif // ST_AUDIO_STREAM_MANAGER_H
90