2015-05-03 19:32:37 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-06-08 15:24:29 +00:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
2015-08-04 09:39:30 +00:00
|
|
|
#ifndef mozilla_dom_bluetooth_bluedroid_BluetoothA2dpManager_h
|
|
|
|
#define mozilla_dom_bluetooth_bluedroid_BluetoothA2dpManager_h
|
2013-06-08 15:24:29 +00:00
|
|
|
|
|
|
|
#include "BluetoothCommon.h"
|
2014-09-01 08:11:53 +00:00
|
|
|
#include "BluetoothInterface.h"
|
2013-10-01 07:26:40 +00:00
|
|
|
#include "BluetoothProfileController.h"
|
2013-06-08 15:26:01 +00:00
|
|
|
#include "BluetoothProfileManagerBase.h"
|
2013-06-08 15:24:29 +00:00
|
|
|
|
|
|
|
BEGIN_BLUETOOTH_NAMESPACE
|
2013-06-08 15:26:01 +00:00
|
|
|
class BluetoothA2dpManager : public BluetoothProfileManagerBase
|
2014-09-01 08:11:53 +00:00
|
|
|
, public BluetoothA2dpNotificationHandler
|
2013-06-08 15:24:29 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-10-16 13:20:35 +00:00
|
|
|
static const int MAX_NUM_CLIENTS;
|
|
|
|
|
2013-11-12 03:59:01 +00:00
|
|
|
BT_DECL_PROFILE_MGR_BASE
|
|
|
|
virtual void GetName(nsACString& aName)
|
|
|
|
{
|
|
|
|
aName.AssignLiteral("A2DP");
|
|
|
|
}
|
2013-06-08 15:26:01 +00:00
|
|
|
|
2013-07-29 09:32:34 +00:00
|
|
|
enum SinkState {
|
2013-11-08 04:53:27 +00:00
|
|
|
SINK_UNKNOWN,
|
|
|
|
SINK_DISCONNECTED,
|
2013-07-29 09:32:34 +00:00
|
|
|
SINK_CONNECTING,
|
|
|
|
SINK_CONNECTED,
|
|
|
|
SINK_PLAYING,
|
|
|
|
};
|
|
|
|
|
2013-06-08 15:24:29 +00:00
|
|
|
static BluetoothA2dpManager* Get();
|
2014-07-15 08:56:53 +00:00
|
|
|
static void InitA2dpInterface(BluetoothProfileResultHandler* aRes);
|
|
|
|
static void DeinitA2dpInterface(BluetoothProfileResultHandler* aRes);
|
2013-06-08 15:24:29 +00:00
|
|
|
|
2014-07-23 05:56:23 +00:00
|
|
|
void OnConnectError();
|
|
|
|
void OnDisconnectError();
|
|
|
|
|
2013-09-13 22:51:00 +00:00
|
|
|
// A2DP-specific functions
|
2013-06-20 01:20:16 +00:00
|
|
|
void HandleSinkPropertyChanged(const BluetoothSignal& aSignal);
|
|
|
|
|
2015-05-11 03:47:31 +00:00
|
|
|
void HandleBackendError();
|
2014-01-29 11:13:10 +00:00
|
|
|
|
2015-03-10 12:44:02 +00:00
|
|
|
protected:
|
|
|
|
virtual ~BluetoothA2dpManager();
|
|
|
|
|
2013-06-08 15:24:29 +00:00
|
|
|
private:
|
2015-03-12 12:07:32 +00:00
|
|
|
class ConnectResultHandler;
|
2015-10-16 13:20:35 +00:00
|
|
|
class DeinitProfileResultHandlerRunnable;
|
2015-03-12 12:07:32 +00:00
|
|
|
class DisconnectResultHandler;
|
2015-10-16 13:20:35 +00:00
|
|
|
class InitProfileResultHandlerRunnable;
|
|
|
|
class RegisterModuleResultHandler;
|
|
|
|
class UnregisterModuleResultHandler;
|
2015-03-12 12:07:32 +00:00
|
|
|
|
2013-06-08 15:24:29 +00:00
|
|
|
BluetoothA2dpManager();
|
2014-03-26 09:02:40 +00:00
|
|
|
|
2013-06-20 01:20:16 +00:00
|
|
|
void HandleShutdown();
|
2013-08-02 10:32:57 +00:00
|
|
|
void NotifyConnectionStatusChanged();
|
|
|
|
|
2014-09-01 08:11:53 +00:00
|
|
|
void ConnectionStateNotification(BluetoothA2dpConnectionState aState,
|
2015-09-30 07:42:33 +00:00
|
|
|
const BluetoothAddress& aBdAddr) override;
|
2014-09-01 08:11:53 +00:00
|
|
|
void AudioStateNotification(BluetoothA2dpAudioState aState,
|
2015-09-30 07:42:33 +00:00
|
|
|
const BluetoothAddress& aBdAddr) override;
|
2014-09-01 08:11:53 +00:00
|
|
|
|
2015-10-30 13:54:41 +00:00
|
|
|
BluetoothAddress mDeviceAddress;
|
2015-10-18 05:24:48 +00:00
|
|
|
RefPtr<BluetoothProfileController> mController;
|
2013-07-29 09:32:34 +00:00
|
|
|
|
|
|
|
// A2DP data member
|
|
|
|
bool mA2dpConnected;
|
2013-06-08 15:24:29 +00:00
|
|
|
SinkState mSinkState;
|
|
|
|
};
|
|
|
|
|
|
|
|
END_BLUETOOTH_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|