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 OHOS_DAUDIO_IO_DEV_H
17 #define OHOS_DAUDIO_IO_DEV_H
18 
19 #include <queue>
20 #include <set>
21 #include <thread>
22 
23 #include "audio_param.h"
24 #include "audio_status.h"
25 #include "av_receiver_engine_transport.h"
26 #include "ashmem.h"
27 #include "daudio_hdi_handler.h"
28 #include "iaudio_data_transport.h"
29 #include "iaudio_datatrans_callback.h"
30 #include "iaudio_event_callback.h"
31 #include "idaudio_hdi_callback.h"
32 
33 namespace OHOS {
34 namespace DistributedHardware {
35 class DAudioIoDev : public IDAudioHdiCallback {
36 public:
DAudioIoDev(const std::string & devId)37     explicit DAudioIoDev(const std::string &devId)
38         : devId_(devId) {};
39     ~DAudioIoDev() override = default;
40     virtual int32_t InitReceiverEngine(IAVEngineProvider *providerPtr) = 0;
41     virtual int32_t InitSenderEngine(IAVEngineProvider *providerPtr) = 0;
42 
43     virtual int32_t EnableDevice(const int32_t dhId, const std::string &capability) = 0;
44     virtual int32_t DisableDevice(const int32_t dhId) = 0;
45 
46     virtual int32_t MmapStart() = 0;
47     virtual int32_t MmapStop() = 0;
48 
49     virtual int32_t SetUp() = 0;
50     virtual int32_t Start() = 0;
51     virtual int32_t Pause() = 0;
52     virtual int32_t Restart() = 0;
53     virtual int32_t Stop() = 0;
54     virtual int32_t Release() = 0;
55     virtual bool IsOpened() = 0;
56     virtual int32_t SendMessage(uint32_t type, std::string content, std::string dstDevId) = 0;
57 
58     virtual AudioParam GetAudioParam() const = 0;
59     virtual int32_t NotifyHdfAudioEvent(const AudioEvent &event, const int32_t portId) = 0;
60 
61 protected:
62     const std::string devId_;
63 };
64 } // DistributedHardware
65 } // OHOS
66 #endif // OHOS_DAUDIO_IO_DEV_H