1 /*
2  * Copyright (c) 2022-2023 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 RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_AUDIO_OBSERVER_H
17 #define RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_AUDIO_OBSERVER_H
18 #ifdef RESSCHED_AUDIO_FRAMEWORK_ENABLE
19 #include <string>
20 
21 #include "nlohmann/json.hpp"
22 #include "audio_stream_manager.h"
23 #include "audio_system_manager.h"
24 #include "audio_routing_manager.h"
25 
26 namespace OHOS {
27 namespace ResourceSchedule {
28 class AudioObserver :
29     public AudioStandard::AudioRendererStateChangeCallback,
30     public AudioStandard::AudioRingerModeCallback,
31     public AudioStandard::VolumeKeyEventCallback,
32     public AudioStandard::AudioPreferredOutputDeviceChangeCallback {
33 public:
34     void OnRendererStateChange(
35         const std::vector<std::unique_ptr<AudioStandard::AudioRendererChangeInfo>> &audioRendererChangeInfos) override;
36     void OnRingerModeUpdated(const AudioStandard::AudioRingerMode &ringerMode) override;
37     void OnVolumeKeyEvent(AudioStandard::VolumeEvent volumeEvent) override;
38     void OnPreferredOutputDeviceUpdated(const std::vector<sptr<AudioStandard::AudioDeviceDescriptor>> &descs)  override;
39 private:
40     int32_t mode_ = -1;
41     void MarshallingAudioRendererChangeInfo(
42         const std::unique_ptr<AudioStandard::AudioRendererChangeInfo> &audioRendererChangeInfo,
43         nlohmann::json &payload);
44 };
45 } // namespace ResourceSchedule
46 } // namespace OHOS
47 #endif
48 #endif // RESSCHED_SCHED_CONTROLLER_OBSERVER_INCLUDE_AUDIO_OBSERVER_H
49