|
1 /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
|
2 /* vim: set ts=2 et sw=2 tw=80: */ |
|
3 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
4 * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
|
5 * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #ifndef mozilla_dom_bluetooth_bluetootha2dpmanager_h__ |
|
8 #define mozilla_dom_bluetooth_bluetootha2dpmanager_h__ |
|
9 |
|
10 #include "BluetoothCommon.h" |
|
11 #include "BluetoothProfileController.h" |
|
12 #include "BluetoothProfileManagerBase.h" |
|
13 |
|
14 BEGIN_BLUETOOTH_NAMESPACE |
|
15 |
|
16 class BluetoothA2dpManager : public BluetoothProfileManagerBase |
|
17 { |
|
18 public: |
|
19 BT_DECL_PROFILE_MGR_BASE |
|
20 virtual void GetName(nsACString& aName) |
|
21 { |
|
22 aName.AssignLiteral("A2DP"); |
|
23 } |
|
24 |
|
25 enum SinkState { |
|
26 SINK_UNKNOWN, |
|
27 SINK_DISCONNECTED, |
|
28 SINK_CONNECTING, |
|
29 SINK_CONNECTED, |
|
30 SINK_PLAYING, |
|
31 }; |
|
32 |
|
33 static BluetoothA2dpManager* Get(); |
|
34 virtual ~BluetoothA2dpManager(); |
|
35 |
|
36 // A2DP-specific functions |
|
37 void HandleSinkPropertyChanged(const BluetoothSignal& aSignal); |
|
38 |
|
39 // AVRCP-specific functions |
|
40 void SetAvrcpConnected(bool aConnected); |
|
41 bool IsAvrcpConnected(); |
|
42 void UpdateMetaData(const nsAString& aTitle, |
|
43 const nsAString& aArtist, |
|
44 const nsAString& aAlbum, |
|
45 uint64_t aMediaNumber, |
|
46 uint64_t aTotalMediaCount, |
|
47 uint32_t aDuration); |
|
48 void UpdatePlayStatus(uint32_t aDuration, |
|
49 uint32_t aPosition, |
|
50 ControlPlayStatus aPlayStatus); |
|
51 void GetAlbum(nsAString& aAlbum); |
|
52 uint32_t GetDuration(); |
|
53 ControlPlayStatus GetPlayStatus(); |
|
54 uint32_t GetPosition(); |
|
55 uint64_t GetMediaNumber(); |
|
56 void GetTitle(nsAString& aTitle); |
|
57 |
|
58 private: |
|
59 BluetoothA2dpManager(); |
|
60 bool Init(); |
|
61 void ResetA2dp(); |
|
62 void ResetAvrcp(); |
|
63 |
|
64 void HandleShutdown(); |
|
65 void NotifyConnectionStatusChanged(); |
|
66 |
|
67 nsString mDeviceAddress; |
|
68 nsRefPtr<BluetoothProfileController> mController; |
|
69 |
|
70 // A2DP data member |
|
71 bool mA2dpConnected; |
|
72 SinkState mSinkState; |
|
73 |
|
74 // AVRCP data member |
|
75 bool mAvrcpConnected; |
|
76 nsString mAlbum; |
|
77 nsString mArtist; |
|
78 nsString mTitle; |
|
79 uint32_t mDuration; |
|
80 uint64_t mMediaNumber; |
|
81 uint64_t mTotalMediaCount; |
|
82 uint32_t mPosition; |
|
83 ControlPlayStatus mPlayStatus; |
|
84 }; |
|
85 |
|
86 END_BLUETOOTH_NAMESPACE |
|
87 |
|
88 #endif |