Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_bluetooth_bluetootha2dpmanager_h__ |
michael@0 | 8 | #define mozilla_dom_bluetooth_bluetootha2dpmanager_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "BluetoothCommon.h" |
michael@0 | 11 | #include "BluetoothProfileController.h" |
michael@0 | 12 | #include "BluetoothProfileManagerBase.h" |
michael@0 | 13 | |
michael@0 | 14 | BEGIN_BLUETOOTH_NAMESPACE |
michael@0 | 15 | class BluetoothA2dpManager : public BluetoothProfileManagerBase |
michael@0 | 16 | { |
michael@0 | 17 | public: |
michael@0 | 18 | BT_DECL_PROFILE_MGR_BASE |
michael@0 | 19 | virtual void GetName(nsACString& aName) |
michael@0 | 20 | { |
michael@0 | 21 | aName.AssignLiteral("A2DP"); |
michael@0 | 22 | } |
michael@0 | 23 | |
michael@0 | 24 | enum SinkState { |
michael@0 | 25 | SINK_UNKNOWN, |
michael@0 | 26 | SINK_DISCONNECTED, |
michael@0 | 27 | SINK_CONNECTING, |
michael@0 | 28 | SINK_CONNECTED, |
michael@0 | 29 | SINK_PLAYING, |
michael@0 | 30 | }; |
michael@0 | 31 | |
michael@0 | 32 | static BluetoothA2dpManager* Get(); |
michael@0 | 33 | virtual ~BluetoothA2dpManager(); |
michael@0 | 34 | |
michael@0 | 35 | // A2DP-specific functions |
michael@0 | 36 | void HandleSinkPropertyChanged(const BluetoothSignal& aSignal); |
michael@0 | 37 | |
michael@0 | 38 | // AVRCP-specific functions |
michael@0 | 39 | void SetAvrcpConnected(bool aConnected); |
michael@0 | 40 | bool IsAvrcpConnected(); |
michael@0 | 41 | void UpdateMetaData(const nsAString& aTitle, |
michael@0 | 42 | const nsAString& aArtist, |
michael@0 | 43 | const nsAString& aAlbum, |
michael@0 | 44 | uint64_t aMediaNumber, |
michael@0 | 45 | uint64_t aTotalMediaCount, |
michael@0 | 46 | uint32_t aDuration); |
michael@0 | 47 | void UpdatePlayStatus(uint32_t aDuration, |
michael@0 | 48 | uint32_t aPosition, |
michael@0 | 49 | ControlPlayStatus aPlayStatus); |
michael@0 | 50 | void UpdateRegisterNotification(int aEventId, int aParam); |
michael@0 | 51 | void GetAlbum(nsAString& aAlbum); |
michael@0 | 52 | uint32_t GetDuration(); |
michael@0 | 53 | ControlPlayStatus GetPlayStatus(); |
michael@0 | 54 | uint32_t GetPosition(); |
michael@0 | 55 | uint64_t GetMediaNumber(); |
michael@0 | 56 | uint64_t GetTotalMediaNumber(); |
michael@0 | 57 | void GetTitle(nsAString& aTitle); |
michael@0 | 58 | void GetArtist(nsAString& aArtist); |
michael@0 | 59 | |
michael@0 | 60 | private: |
michael@0 | 61 | class SinkPropertyChangedHandler; |
michael@0 | 62 | BluetoothA2dpManager(); |
michael@0 | 63 | bool Init(); |
michael@0 | 64 | void ResetA2dp(); |
michael@0 | 65 | void ResetAvrcp(); |
michael@0 | 66 | |
michael@0 | 67 | void HandleShutdown(); |
michael@0 | 68 | void NotifyConnectionStatusChanged(); |
michael@0 | 69 | |
michael@0 | 70 | nsString mDeviceAddress; |
michael@0 | 71 | nsRefPtr<BluetoothProfileController> mController; |
michael@0 | 72 | |
michael@0 | 73 | // A2DP data member |
michael@0 | 74 | bool mA2dpConnected; |
michael@0 | 75 | SinkState mSinkState; |
michael@0 | 76 | |
michael@0 | 77 | // AVRCP data member |
michael@0 | 78 | bool mAvrcpConnected; |
michael@0 | 79 | nsString mAlbum; |
michael@0 | 80 | nsString mArtist; |
michael@0 | 81 | nsString mTitle; |
michael@0 | 82 | uint32_t mDuration; |
michael@0 | 83 | uint64_t mMediaNumber; |
michael@0 | 84 | uint64_t mTotalMediaCount; |
michael@0 | 85 | uint32_t mPosition; |
michael@0 | 86 | /* |
michael@0 | 87 | * mPlaybackInterval specifies the time interval (in seconds) at which |
michael@0 | 88 | * the change in playback position will be notified. If the song is being |
michael@0 | 89 | * forwarded / rewound, a notification will be received whenever the playback |
michael@0 | 90 | * position will change by this value. |
michael@0 | 91 | */ |
michael@0 | 92 | uint32_t mPlaybackInterval; |
michael@0 | 93 | ControlPlayStatus mPlayStatus; |
michael@0 | 94 | /* |
michael@0 | 95 | * Notification types: 1. INTERIM 2. CHANGED |
michael@0 | 96 | * 1. The initial response to this Notify command shall be an INTERIM |
michael@0 | 97 | * response with current status. |
michael@0 | 98 | * 2. The following response shall be a CHANGED response with the updated |
michael@0 | 99 | * status. |
michael@0 | 100 | * mPlayStatusChangedNotifType, mTrackChangedNotifType, |
michael@0 | 101 | * mPlayPosChangedNotifType represents current RegisterNotification |
michael@0 | 102 | * notification type. |
michael@0 | 103 | */ |
michael@0 | 104 | int mPlayStatusChangedNotifyType; |
michael@0 | 105 | int mTrackChangedNotifyType; |
michael@0 | 106 | int mPlayPosChangedNotifyType; |
michael@0 | 107 | }; |
michael@0 | 108 | |
michael@0 | 109 | END_BLUETOOTH_NAMESPACE |
michael@0 | 110 | |
michael@0 | 111 | #endif |