1 /*
2  * Copyright (c) 2021 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_BLUETOOTH_MANAGER_H
17 #define AUDIO_BLUETOOTH_MANAGER_H
18 
19 #include "bluetooth_a2dp_codec.h"
20 #include "bluetooth_a2dp_a2dpCodecInfo.h"
21 #include "bluetooth_a2dp_a2dpCodecStatus.h"
22 #include "raw_address.h"
23 #include "audio_internal.h"
24 
25 #ifdef LOG_DOMAIN
26 #undef LOG_DOMAIN
27 #endif
28 #define LOG_DOMAIN 0xD000105
29 
30 namespace OHOS {
31 namespace Bluetooth {
32 using namespace OHOS::bluetooth;
33 
34 typedef struct BtA2dpAudioCallback {
35     void (*OnConnectionStateChanged)(const RawAddress &device, int state, int cause);
36     void (*OnPlayingStatusChanged)(const RawAddress &device, int playingState, int error);
37     void (*OnConfigurationChanged)(const RawAddress &device, const BluetoothA2dpCodecInfo &info, int error);
38     void (*OnMediaStackChanged)(const RawAddress &device, int action);
39 }BtA2dpAudioCallback;
40 
41 int GetPlayingState();
42 void GetProxy();
43 void RegisterObserver();
44 void DeRegisterObserver();
45 
46 #ifdef A2DP_HDI_SERVICE
47 bool SetUp();
48 void TearDown();
49 bool FastSetUp();
50 void FastTearDown();
51 int FastStartPlaying(uint32_t sampleRate, uint32_t channelCount, uint32_t format);
52 int FastSuspendPlaying();
53 int FastStopPlaying();
54 int FastReqMmapBuffer(int32_t ashmemLength);
55 void FastReadMmapPosition(int64_t &sec, int64_t &nSec, uint64_t &frames);
56 int FastGetLatency(uint32_t &latency);
57 int SuspendPlayingFromParam();
58 int FastSuspendPlayingFromParam();
59 void UnBlockStart();
60 #endif
61 
62 int WriteFrame(const uint8_t *data, uint32_t size, const HDI::Audio_Bluetooth::AudioSampleAttributes *attrs);
63 int StartPlaying();
64 int SuspendPlaying();
65 int StopPlaying();
66 int GetLatency(uint32_t &latency);
67 }
68 }
69 
70 #endif