1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,111 @@ 1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ 1.5 +/* vim: set ts=2 et sw=2 tw=80: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file, 1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#ifndef mozilla_dom_bluetooth_bluetootha2dpmanager_h__ 1.11 +#define mozilla_dom_bluetooth_bluetootha2dpmanager_h__ 1.12 + 1.13 +#include "BluetoothCommon.h" 1.14 +#include "BluetoothProfileController.h" 1.15 +#include "BluetoothProfileManagerBase.h" 1.16 + 1.17 +BEGIN_BLUETOOTH_NAMESPACE 1.18 +class BluetoothA2dpManager : public BluetoothProfileManagerBase 1.19 +{ 1.20 +public: 1.21 + BT_DECL_PROFILE_MGR_BASE 1.22 + virtual void GetName(nsACString& aName) 1.23 + { 1.24 + aName.AssignLiteral("A2DP"); 1.25 + } 1.26 + 1.27 + enum SinkState { 1.28 + SINK_UNKNOWN, 1.29 + SINK_DISCONNECTED, 1.30 + SINK_CONNECTING, 1.31 + SINK_CONNECTED, 1.32 + SINK_PLAYING, 1.33 + }; 1.34 + 1.35 + static BluetoothA2dpManager* Get(); 1.36 + virtual ~BluetoothA2dpManager(); 1.37 + 1.38 + // A2DP-specific functions 1.39 + void HandleSinkPropertyChanged(const BluetoothSignal& aSignal); 1.40 + 1.41 + // AVRCP-specific functions 1.42 + void SetAvrcpConnected(bool aConnected); 1.43 + bool IsAvrcpConnected(); 1.44 + void UpdateMetaData(const nsAString& aTitle, 1.45 + const nsAString& aArtist, 1.46 + const nsAString& aAlbum, 1.47 + uint64_t aMediaNumber, 1.48 + uint64_t aTotalMediaCount, 1.49 + uint32_t aDuration); 1.50 + void UpdatePlayStatus(uint32_t aDuration, 1.51 + uint32_t aPosition, 1.52 + ControlPlayStatus aPlayStatus); 1.53 + void UpdateRegisterNotification(int aEventId, int aParam); 1.54 + void GetAlbum(nsAString& aAlbum); 1.55 + uint32_t GetDuration(); 1.56 + ControlPlayStatus GetPlayStatus(); 1.57 + uint32_t GetPosition(); 1.58 + uint64_t GetMediaNumber(); 1.59 + uint64_t GetTotalMediaNumber(); 1.60 + void GetTitle(nsAString& aTitle); 1.61 + void GetArtist(nsAString& aArtist); 1.62 + 1.63 +private: 1.64 + class SinkPropertyChangedHandler; 1.65 + BluetoothA2dpManager(); 1.66 + bool Init(); 1.67 + void ResetA2dp(); 1.68 + void ResetAvrcp(); 1.69 + 1.70 + void HandleShutdown(); 1.71 + void NotifyConnectionStatusChanged(); 1.72 + 1.73 + nsString mDeviceAddress; 1.74 + nsRefPtr<BluetoothProfileController> mController; 1.75 + 1.76 + // A2DP data member 1.77 + bool mA2dpConnected; 1.78 + SinkState mSinkState; 1.79 + 1.80 + // AVRCP data member 1.81 + bool mAvrcpConnected; 1.82 + nsString mAlbum; 1.83 + nsString mArtist; 1.84 + nsString mTitle; 1.85 + uint32_t mDuration; 1.86 + uint64_t mMediaNumber; 1.87 + uint64_t mTotalMediaCount; 1.88 + uint32_t mPosition; 1.89 + /* 1.90 + * mPlaybackInterval specifies the time interval (in seconds) at which 1.91 + * the change in playback position will be notified. If the song is being 1.92 + * forwarded / rewound, a notification will be received whenever the playback 1.93 + * position will change by this value. 1.94 + */ 1.95 + uint32_t mPlaybackInterval; 1.96 + ControlPlayStatus mPlayStatus; 1.97 + /* 1.98 + * Notification types: 1. INTERIM 2. CHANGED 1.99 + * 1. The initial response to this Notify command shall be an INTERIM 1.100 + * response with current status. 1.101 + * 2. The following response shall be a CHANGED response with the updated 1.102 + * status. 1.103 + * mPlayStatusChangedNotifType, mTrackChangedNotifType, 1.104 + * mPlayPosChangedNotifType represents current RegisterNotification 1.105 + * notification type. 1.106 + */ 1.107 + int mPlayStatusChangedNotifyType; 1.108 + int mTrackChangedNotifyType; 1.109 + int mPlayPosChangedNotifyType; 1.110 +}; 1.111 + 1.112 +END_BLUETOOTH_NAMESPACE 1.113 + 1.114 +#endif