|
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 class BluetoothA2dpManager : public BluetoothProfileManagerBase |
|
16 { |
|
17 public: |
|
18 BT_DECL_PROFILE_MGR_BASE |
|
19 virtual void GetName(nsACString& aName) |
|
20 { |
|
21 aName.AssignLiteral("A2DP"); |
|
22 } |
|
23 |
|
24 enum SinkState { |
|
25 SINK_UNKNOWN, |
|
26 SINK_DISCONNECTED, |
|
27 SINK_CONNECTING, |
|
28 SINK_CONNECTED, |
|
29 SINK_PLAYING, |
|
30 }; |
|
31 |
|
32 static BluetoothA2dpManager* Get(); |
|
33 virtual ~BluetoothA2dpManager(); |
|
34 |
|
35 // A2DP-specific functions |
|
36 void HandleSinkPropertyChanged(const BluetoothSignal& aSignal); |
|
37 |
|
38 // AVRCP-specific functions |
|
39 void SetAvrcpConnected(bool aConnected); |
|
40 bool IsAvrcpConnected(); |
|
41 void UpdateMetaData(const nsAString& aTitle, |
|
42 const nsAString& aArtist, |
|
43 const nsAString& aAlbum, |
|
44 uint64_t aMediaNumber, |
|
45 uint64_t aTotalMediaCount, |
|
46 uint32_t aDuration); |
|
47 void UpdatePlayStatus(uint32_t aDuration, |
|
48 uint32_t aPosition, |
|
49 ControlPlayStatus aPlayStatus); |
|
50 void UpdateRegisterNotification(int aEventId, int aParam); |
|
51 void GetAlbum(nsAString& aAlbum); |
|
52 uint32_t GetDuration(); |
|
53 ControlPlayStatus GetPlayStatus(); |
|
54 uint32_t GetPosition(); |
|
55 uint64_t GetMediaNumber(); |
|
56 uint64_t GetTotalMediaNumber(); |
|
57 void GetTitle(nsAString& aTitle); |
|
58 void GetArtist(nsAString& aArtist); |
|
59 |
|
60 private: |
|
61 class SinkPropertyChangedHandler; |
|
62 BluetoothA2dpManager(); |
|
63 bool Init(); |
|
64 void ResetA2dp(); |
|
65 void ResetAvrcp(); |
|
66 |
|
67 void HandleShutdown(); |
|
68 void NotifyConnectionStatusChanged(); |
|
69 |
|
70 nsString mDeviceAddress; |
|
71 nsRefPtr<BluetoothProfileController> mController; |
|
72 |
|
73 // A2DP data member |
|
74 bool mA2dpConnected; |
|
75 SinkState mSinkState; |
|
76 |
|
77 // AVRCP data member |
|
78 bool mAvrcpConnected; |
|
79 nsString mAlbum; |
|
80 nsString mArtist; |
|
81 nsString mTitle; |
|
82 uint32_t mDuration; |
|
83 uint64_t mMediaNumber; |
|
84 uint64_t mTotalMediaCount; |
|
85 uint32_t mPosition; |
|
86 /* |
|
87 * mPlaybackInterval specifies the time interval (in seconds) at which |
|
88 * the change in playback position will be notified. If the song is being |
|
89 * forwarded / rewound, a notification will be received whenever the playback |
|
90 * position will change by this value. |
|
91 */ |
|
92 uint32_t mPlaybackInterval; |
|
93 ControlPlayStatus mPlayStatus; |
|
94 /* |
|
95 * Notification types: 1. INTERIM 2. CHANGED |
|
96 * 1. The initial response to this Notify command shall be an INTERIM |
|
97 * response with current status. |
|
98 * 2. The following response shall be a CHANGED response with the updated |
|
99 * status. |
|
100 * mPlayStatusChangedNotifType, mTrackChangedNotifType, |
|
101 * mPlayPosChangedNotifType represents current RegisterNotification |
|
102 * notification type. |
|
103 */ |
|
104 int mPlayStatusChangedNotifyType; |
|
105 int mTrackChangedNotifyType; |
|
106 int mPlayPosChangedNotifyType; |
|
107 }; |
|
108 |
|
109 END_BLUETOOTH_NAMESPACE |
|
110 |
|
111 #endif |