1 /*
2  * Copyright (c) 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 AUDIO_HAPTIC_MANAGER_H
17 #define AUDIO_HAPTIC_MANAGER_H
18 
19 #include <mutex>
20 #include <string>
21 
22 #include "audio_info.h"
23 
24 #include "audio_haptic_player.h"
25 
26 namespace OHOS {
27 namespace Media {
28 class AudioHapticManager {
29 public:
30     virtual ~AudioHapticManager() = default;
31 
32     virtual int32_t RegisterSource(const std::string &audioUri, const std::string &hapticUri) = 0;
33 
34     virtual int32_t RegisterSourceWithEffectId(const std::string &audioUri, const std::string &effectId) = 0;
35 
36     virtual int32_t UnregisterSource(const int32_t &sourceID) = 0;
37 
38     virtual int32_t SetAudioLatencyMode(const int32_t &sourceID, const AudioLatencyMode &latencyMode) = 0;
39 
40     virtual int32_t SetStreamUsage(const int32_t &sourceID, const AudioStandard::StreamUsage &streamUsage) = 0;
41 
42     virtual std::shared_ptr<AudioHapticPlayer> CreatePlayer(const int32_t &sourceID,
43         const AudioHapticPlayerOptions &audioHapticPlayerOptions) = 0;
44 };
45 
46 class __attribute__((visibility("default"))) AudioHapticManagerFactory {
47 public:
48     static std::shared_ptr<AudioHapticManager> CreateAudioHapticManager();
49 
50 private:
51     static std::shared_ptr<AudioHapticManager> audioHapticManager_;
52     static std::mutex audioHapticManagerMutex_;
53     AudioHapticManagerFactory() = default;
54     ~AudioHapticManagerFactory() = default;
55 };
56 } // Media
57 } // OHOS
58 #endif // AUDIO_HAPTIC_MANAGER_H
59