• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-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 NAPI_BLUETOOTH_A2DP_SRC_H_
17 #define NAPI_BLUETOOTH_A2DP_SRC_H_
18 
19 #include <vector>
20 #include "bluetooth_a2dp_src.h"
21 #include "napi_bluetooth_a2dp_src_observer.h"
22 
23 namespace OHOS {
24 namespace Bluetooth {
25 enum CodecType {
26     CODEC_TYPE_SBC = 0,
27     CODEC_TYPE_AAC = 1,
28     CODEC_TYPE_L2HC = 2,
29     CODEC_TYPE_INVALID = -1,
30 };
31 
32 enum CodecBitsPerSample {
33     CODEC_BITS_PER_SAMPLE_NONE = 0,
34     CODEC_BITS_PER_SAMPLE_16 = 1,
35     CODEC_BITS_PER_SAMPLE_24 = 2,
36     CODEC_BITS_PER_SAMPLE_32 = 3,
37 };
38 
39 enum CodecChannelMode {
40     CODEC_CHANNEL_MODE_NONE = 0,
41     CODEC_CHANNEL_MODE_MONO = 1,
42     CODEC_CHANNEL_MODE_STEREO = 2,
43 };
44 
45 enum CodecSampleRate {
46     CODEC_SAMPLE_RATE_NONE = 0,
47     CODEC_SAMPLE_RATE_44100 = 1,
48     CODEC_SAMPLE_RATE_48000 = 2,
49     CODEC_SAMPLE_RATE_88200 = 3,
50     CODEC_SAMPLE_RATE_96000 = 4,
51     CODEC_SAMPLE_RATE_176400 = 5,
52     CODEC_SAMPLE_RATE_192000 = 6,
53 };
54 
55 struct CodecInfo {
56     CodecType codecType;
57     CodecBitsPerSample codecBitsPerSample;
58     CodecChannelMode codecChannelMode;
59     CodecSampleRate codecSampleRate;
60 };
61 
62 class NapiA2dpSource {
63 public:
64     static napi_value DefineA2dpSourceJSClass(napi_env env, napi_value exports);
65     static napi_value A2dpSourceConstructor(napi_env env, napi_callback_info info);
66     static napi_value A2dpPropertyValueInit(napi_env env, napi_value exports);
67 
68     static napi_value On(napi_env env, napi_callback_info info);
69     static napi_value Off(napi_env env, napi_callback_info info);
70     static napi_value GetPlayingState(napi_env env, napi_callback_info info);
71     static napi_value Connect(napi_env env, napi_callback_info info);
72     static napi_value Disconnect(napi_env env, napi_callback_info info);
73     static napi_value GetConnectionDevices(napi_env env, napi_callback_info info);
74     static napi_value GetDeviceState(napi_env env, napi_callback_info info);
75 #ifdef BLUETOOTH_API_SINCE_10
76     static napi_value DefineCreateProfile(napi_env env, napi_value exports);
77     static napi_value CreateA2dpSrcProfile(napi_env env, napi_callback_info info);
78     static napi_value SetConnectionStrategy(napi_env env, napi_callback_info info);
79     static napi_value GetConnectionStrategy(napi_env env, napi_callback_info info);
80     static napi_value GetConnectionState(napi_env env, napi_callback_info info);
81     static napi_value GetConnectedDevices(napi_env env, napi_callback_info info);
82     static napi_value IsAbsoluteVolumeSupported(napi_env env, napi_callback_info info);
83     static napi_value IsAbsoluteVolumeEnabled(napi_env env, napi_callback_info info);
84     static napi_value EnableAbsoluteVolume(napi_env env, napi_callback_info info);
85     static napi_value DisableAbsoluteVolume(napi_env env, napi_callback_info info);
86     static napi_value SetCurrentCodecInfo(napi_env env, napi_callback_info info);
87     static napi_value GetCurrentCodecInfo(napi_env env, napi_callback_info info);
88 #endif
89     static std::shared_ptr<NapiA2dpSourceObserver> observer_;
90     static bool isRegistered_;
91 };
92 
93 }  // namespace Bluetooth
94 }  // namespace OHOS
95 #endif /* NAPI_BLUETOOTH_A2DP_SRC_H_ */