• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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 AUDIO_LOOPBACK_H
17 #define AUDIO_LOOPBACK_H
18 
19 #include "audio_stream_change_info.h"
20 
21 namespace OHOS {
22 namespace AudioStandard {
23 
24 
25 class AudioLoopbackCallback {
26 public:
27     virtual ~AudioLoopbackCallback() = default;
28 
29     /**
30      * Called when loopback state is updated.
31      *
32      * @param state Indicates updated state of the loopback.
33      * For details, refer AudioLoopbackStatus enum.
34      */
35     virtual void OnStatusChange(const AudioLoopbackStatus state,
36         const StateChangeCmdType cmdType = CMD_FROM_CLIENT) = 0;
37 };
38 
39 /**
40  * @brief audio loopback
41  * @since 20
42  */
43 class AudioLoopback {
44 public:
45     /**
46      * @brief  create loopback instance.
47      *
48      * @param rendererOptions The audio loopback configuration to be used while creating loopback instance.
49      * @param appInfo Originating application's uid and token id can be passed here
50      * @return Returns shared pointer to the AudioLoopback object
51      * @since 20
52     */
53     static std::shared_ptr<AudioLoopback> CreateAudioLoopback(AudioLoopbackMode mode,
54         const AppInfo &appInfo = AppInfo());
55 
56     virtual bool Enable(bool enable) = 0;
57 
58     virtual AudioLoopbackStatus GetStatus() = 0;
59 
60     virtual int32_t SetVolume(float volume) = 0;
61 
62     virtual int32_t SetAudioLoopbackCallback(const std::shared_ptr<AudioLoopbackCallback> &callback) = 0;
63 
64     virtual int32_t RemoveAudioLoopbackCallback() = 0;
65 
66     virtual bool SetReverbPreset(AudioLoopbackReverbPreset preset) = 0;
67 
68     virtual AudioLoopbackReverbPreset GetReverbPreset() = 0;
69 
70     virtual bool SetEqualizerPreset(AudioLoopbackEqualizerPreset preset) = 0;
71 
72     virtual AudioLoopbackEqualizerPreset GetEqualizerPreset() = 0;
73 
74     virtual ~AudioLoopback();
75 };
76 } // namespace AudioStandard
77 } // namespace OHOS
78 #endif