• 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 OHOS_DAUDIO_HDI_HANDLER_H
17 #define OHOS_DAUDIO_HDI_HANDLER_H
18 
19 #include <map>
20 #include <mutex>
21 #include <set>
22 
23 #include <v1_0/id_audio_callback.h>
24 #include <v1_0/id_audio_manager.h>
25 
26 #include "audio_event.h"
27 #include "daudio_manager_callback.h"
28 #include "idaudio_hdi_callback.h"
29 #include "single_instance.h"
30 
31 namespace OHOS {
32 namespace DistributedHardware {
33 using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioCallback;
34 using OHOS::HDI::DistributedAudio::Audioext::V1_0::IDAudioManager;
35 class DAudioHdiHandler {
36     DECLARE_SINGLE_INSTANCE_BASE(DAudioHdiHandler);
37 
38 public:
39     int32_t InitHdiHandler();
40 
41     int32_t UninitHdiHandler();
42 
43     int32_t RegisterAudioDevice(const std::string &devId, const int32_t dhId, const std::string &capability,
44         const std::shared_ptr<IDAudioHdiCallback> &callbackObjParam);
45 
46     int32_t UnRegisterAudioDevice(const std::string &devId, const int32_t dhId);
47 
48     int32_t NotifyEvent(const std::string &devId, const int32_t dhId, const AudioEvent &audioEvent);
49 
50 private:
51     DAudioHdiHandler();
52     ~DAudioHdiHandler();
53 
54     const std::string HDF_AUDIO_SERVICE_NAME = "daudio_ext_service";
55     std::mutex devMapMtx_;
56     sptr<IDAudioManager> audioSrvHdf_;
57     std::map<std::string, sptr<DAudioManagerCallback>> mapAudioMgrCallback_;
58     std::map<std::string, std::set<int32_t>> mapAudioMgrDhIds_;
59 };
60 } // DistributedHardware
61 } // OHOS
62 #endif // OHOS_DAUDIO_HDI_HANDLER_H
63