• 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_HANDLER_H
17 #define OHOS_DAUDIO_HANDLER_H
18 
19 #include <set>
20 
21 #include "ihardware_handler.h"
22 #include "single_instance.h"
23 #include "audio_param.h"
24 #include "audio_capturer.h"
25 #include "audio_info.h"
26 
27 namespace OHOS {
28 namespace DistributedHardware {
29 typedef struct {
30     std::vector<int32_t> sampleRates;
31     std::vector<int32_t> channels;
32     std::vector<int32_t> formats;
33     int32_t channelMaxVal;
34     int32_t channelMinVal;
35 } CoderInfo;
36 
37 typedef struct {
38     std::vector<AudioStandard::AudioSamplingRate> sampleRates;
39     std::vector<AudioStandard::AudioChannel> channels;
40     std::vector<AudioStandard::AudioSampleFormat> formats;
41 } AudioInfo;
42 
43 class DAudioHandler : public IHardwareHandler {
44 DECLARE_SINGLE_INSTANCE_BASE(DAudioHandler);
45 
46 public:
47     int32_t Initialize() override;
48     std::vector<DHItem> Query() override;
49     std::map<std::string, std::string> QueryExtraInfo() override;
50     bool IsSupportPlugin() override;
51     void RegisterPluginListener(std::shared_ptr<PluginListener> listener) override;
52     void UnRegisterPluginListener() override;
53     std::vector<DHItem> ablityForDump();
54     std::vector<DHItem> ablityForDumpVec_;
55 private:
56     DAudioHandler();
57     ~DAudioHandler();
58     int32_t QueryCodecInfo();
59     int32_t QueryAudioInfo();
60     void GetSupportAudioInfo(AudioInfo &audioInfos, CoderInfo &encoderInfos, CoderInfo &decoderInfos);
61 
62 private:
63     CoderInfo encoderInfos_;
64     CoderInfo decoderInfos_;
65     AudioInfo audioInfos_;
66     CoderInfo spkInfos_;
67     CoderInfo micInfos_;
68     std::shared_ptr<PluginListener> listener_ = nullptr;
69 };
70 
71 #ifdef __cplusplus
72 extern "C" {
73 #endif
74 __attribute__((visibility("default"))) IHardwareHandler *GetHardwareHandler();
75 #ifdef __cplusplus
76 }
77 #endif
78 } // DistributedHardware
79 } // OHOS
80 #endif // OHOS_DAUDIO_HANDLER_H
81