michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_bluetooth_bluetootha2dpmanager_h__ michael@0: #define mozilla_dom_bluetooth_bluetootha2dpmanager_h__ michael@0: michael@0: #include "BluetoothCommon.h" michael@0: #include "BluetoothProfileController.h" michael@0: #include "BluetoothProfileManagerBase.h" michael@0: michael@0: BEGIN_BLUETOOTH_NAMESPACE michael@0: class BluetoothA2dpManager : public BluetoothProfileManagerBase michael@0: { michael@0: public: michael@0: BT_DECL_PROFILE_MGR_BASE michael@0: virtual void GetName(nsACString& aName) michael@0: { michael@0: aName.AssignLiteral("A2DP"); michael@0: } michael@0: michael@0: enum SinkState { michael@0: SINK_UNKNOWN, michael@0: SINK_DISCONNECTED, michael@0: SINK_CONNECTING, michael@0: SINK_CONNECTED, michael@0: SINK_PLAYING, michael@0: }; michael@0: michael@0: static BluetoothA2dpManager* Get(); michael@0: virtual ~BluetoothA2dpManager(); michael@0: michael@0: // A2DP-specific functions michael@0: void HandleSinkPropertyChanged(const BluetoothSignal& aSignal); michael@0: michael@0: // AVRCP-specific functions michael@0: void SetAvrcpConnected(bool aConnected); michael@0: bool IsAvrcpConnected(); michael@0: void UpdateMetaData(const nsAString& aTitle, michael@0: const nsAString& aArtist, michael@0: const nsAString& aAlbum, michael@0: uint64_t aMediaNumber, michael@0: uint64_t aTotalMediaCount, michael@0: uint32_t aDuration); michael@0: void UpdatePlayStatus(uint32_t aDuration, michael@0: uint32_t aPosition, michael@0: ControlPlayStatus aPlayStatus); michael@0: void UpdateRegisterNotification(int aEventId, int aParam); michael@0: void GetAlbum(nsAString& aAlbum); michael@0: uint32_t GetDuration(); michael@0: ControlPlayStatus GetPlayStatus(); michael@0: uint32_t GetPosition(); michael@0: uint64_t GetMediaNumber(); michael@0: uint64_t GetTotalMediaNumber(); michael@0: void GetTitle(nsAString& aTitle); michael@0: void GetArtist(nsAString& aArtist); michael@0: michael@0: private: michael@0: class SinkPropertyChangedHandler; michael@0: BluetoothA2dpManager(); michael@0: bool Init(); michael@0: void ResetA2dp(); michael@0: void ResetAvrcp(); michael@0: michael@0: void HandleShutdown(); michael@0: void NotifyConnectionStatusChanged(); michael@0: michael@0: nsString mDeviceAddress; michael@0: nsRefPtr mController; michael@0: michael@0: // A2DP data member michael@0: bool mA2dpConnected; michael@0: SinkState mSinkState; michael@0: michael@0: // AVRCP data member michael@0: bool mAvrcpConnected; michael@0: nsString mAlbum; michael@0: nsString mArtist; michael@0: nsString mTitle; michael@0: uint32_t mDuration; michael@0: uint64_t mMediaNumber; michael@0: uint64_t mTotalMediaCount; michael@0: uint32_t mPosition; michael@0: /* michael@0: * mPlaybackInterval specifies the time interval (in seconds) at which michael@0: * the change in playback position will be notified. If the song is being michael@0: * forwarded / rewound, a notification will be received whenever the playback michael@0: * position will change by this value. michael@0: */ michael@0: uint32_t mPlaybackInterval; michael@0: ControlPlayStatus mPlayStatus; michael@0: /* michael@0: * Notification types: 1. INTERIM 2. CHANGED michael@0: * 1. The initial response to this Notify command shall be an INTERIM michael@0: * response with current status. michael@0: * 2. The following response shall be a CHANGED response with the updated michael@0: * status. michael@0: * mPlayStatusChangedNotifType, mTrackChangedNotifType, michael@0: * mPlayPosChangedNotifType represents current RegisterNotification michael@0: * notification type. michael@0: */ michael@0: int mPlayStatusChangedNotifyType; michael@0: int mTrackChangedNotifyType; michael@0: int mPlayPosChangedNotifyType; michael@0: }; michael@0: michael@0: END_BLUETOOTH_NAMESPACE michael@0: michael@0: #endif