1 /*
2  * Copyright (C) 2021-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_BLUETOOTH_STANDARD_A2DP_SOURCE_SERVER_H
17 #define OHOS_BLUETOOTH_STANDARD_A2DP_SOURCE_SERVER_H
18 
19 #include "bluetooth_a2dp_src_stub.h"
20 #include "raw_address.h"
21 #include "bluetooth_types.h"
22 #include "i_bluetooth_a2dp_src.h"
23 #include "if_system_ability_manager.h"
24 #include "iservice_registry.h"
25 #include "system_ability.h"
26 
27 namespace OHOS {
28 namespace Bluetooth {
29 class BluetoothA2dpSourceServer : public BluetoothA2dpSrcStub {
30 public:
31     BluetoothA2dpSourceServer();
32     ~BluetoothA2dpSourceServer() override;
33 
34     // IBluetoothHost overrides:
35     void RegisterObserver(const sptr<IBluetoothA2dpSourceObserver> &observer) override;
36     void DeregisterObserver(const sptr<IBluetoothA2dpSourceObserver> &observer) override;
37     int Connect(const RawAddress &device) override;
38     int Disconnect(const RawAddress &device) override;
39     int GetDeviceState(const RawAddress &device, int &state) override;
40     int GetDevicesByStates(const std::vector<int32_t> &states, std::vector<RawAddress> &rawAddrs) override;
41     int GetPlayingState(const RawAddress &device, int &state) override;
42     int SetConnectStrategy(const RawAddress &device, int strategy) override;
43     int GetConnectStrategy(const RawAddress &device, int &strategy) override;
44     int SetActiveSinkDevice(const RawAddress &device) override;
45     RawAddress GetActiveSinkDevice() override;
46     BluetoothA2dpCodecStatus GetCodecStatus(const RawAddress &device) override;
47     int GetCodecPreference(const RawAddress &device, BluetoothA2dpCodecInfo &info) override;
48     int SetCodecPreference(const RawAddress &device, const BluetoothA2dpCodecInfo &info) override;
49     void SwitchOptionalCodecs(const RawAddress &device, bool isEnable) override;
50     int GetOptionalCodecsSupportState(const RawAddress &device ) override;
51     int StartPlaying(const RawAddress &device) override;
52     int SuspendPlaying(const RawAddress &device) override;
53     int StopPlaying(const RawAddress &device) override;
54     int WriteFrame(const uint8_t *data, uint32_t size) override;
55     int GetRenderPosition(const RawAddress &device, uint32_t &delayValue, uint64_t &sendDataSize,
56                           uint32_t &timeStamp) override;
57     int OffloadStartPlaying(const RawAddress &device, const std::vector<int32_t> &sessionsId) override;
58     int OffloadStopPlaying(const RawAddress &device, const std::vector<int32_t> &sessionsId) override;
59     int A2dpOffloadSessionPathRequest(const RawAddress &device,
60         const std::vector<BluetoothA2dpStreamInfo> &info) override;
61     BluetoothA2dpOffloadCodecStatus GetOffloadCodecStatus(const RawAddress &device) override;
62     int EnableAutoPlay(const RawAddress &device) override;
63     int DisableAutoPlay(const RawAddress &device, const int duration) override;
64     int GetAutoPlayDisabledDuration(const RawAddress &device, int &duration) override;
65     void GetVirtualDeviceList(std::vector<std::string> &devices) override;
66     void UpdateVirtualDevice(int32_t action, const std::string &address) override;
67 
68 private:
69     BLUETOOTH_DECLARE_IMPL();
70     BLUETOOTH_DISALLOW_COPY_AND_ASSIGN(BluetoothA2dpSourceServer);
71 };
72 }  // namespace Bluetooth
73 }  // namespace OHOS
74 #endif  // OHOS_BLUETOOTH_STANDARD_A2DP_SOURCE_SERVER_H