зеркало из https://github.com/mozilla/gecko-dev.git
Bug 842948 - Patch 5: Implement UpdateNotification, r=echou
This commit is contained in:
Родитель
797a139da7
Коммит
088093d5d4
|
@ -360,6 +360,12 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration,
|
|||
mPlayStatus = aPlayStatus;
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothA2dpManager::GetAlbum(nsAString& aAlbum)
|
||||
{
|
||||
aAlbum.Assign(mAlbum);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
BluetoothA2dpManager::GetDuration()
|
||||
{
|
||||
|
|
|
@ -58,6 +58,7 @@ public:
|
|||
void UpdatePlayStatus(uint32_t aDuration,
|
||||
uint32_t aPosition,
|
||||
ControlPlayStatus aPlayStatus);
|
||||
void GetAlbum(nsAString& aAlbum);
|
||||
uint32_t GetDuration();
|
||||
ControlPlayStatus GetPlayStatus();
|
||||
uint32_t GetPosition();
|
||||
|
|
|
@ -2948,6 +2948,16 @@ BluetoothDBusService::SendMetaData(const nsAString& aTitle,
|
|||
|
||||
runnable.forget();
|
||||
|
||||
nsAutoString prevTitle, prevAlbum;
|
||||
a2dp->GetTitle(prevTitle);
|
||||
a2dp->GetAlbum(prevAlbum);
|
||||
|
||||
if (aMediaNumber != a2dp->GetMediaNumber() ||
|
||||
!aTitle.Equals(prevTitle) ||
|
||||
!aAlbum.Equals(prevAlbum)) {
|
||||
UpdateNotification(ControlEventId::EVENT_TRACK_CHANGED, aMediaNumber);
|
||||
}
|
||||
|
||||
a2dp->UpdateMetaData(aTitle, aArtist, aAlbum,
|
||||
aMediaNumber, aTotalMediaCount, aDuration);
|
||||
}
|
||||
|
@ -3031,6 +3041,20 @@ BluetoothDBusService::SendPlayStatus(uint32_t aDuration,
|
|||
|
||||
runnable.forget();
|
||||
|
||||
ControlEventId eventId = ControlEventId::EVENT_UNKNOWN;
|
||||
uint64_t data;
|
||||
if (aPosition != a2dp->GetPosition()) {
|
||||
eventId = ControlEventId::EVENT_PLAYBACK_POS_CHANGED;
|
||||
data = aPosition;
|
||||
} else if (playStatus != a2dp->GetPlayStatus()) {
|
||||
eventId = ControlEventId::EVENT_PLAYBACK_STATUS_CHANGED;
|
||||
data = tempPlayStatus;
|
||||
}
|
||||
|
||||
if (eventId != ControlEventId::EVENT_UNKNOWN) {
|
||||
UpdateNotification(eventId, data);
|
||||
}
|
||||
|
||||
a2dp->UpdatePlayStatus(aDuration, aPosition, playStatus);
|
||||
}
|
||||
|
||||
|
@ -3076,3 +3100,33 @@ BluetoothDBusService::UpdatePlayStatus(uint32_t aDuration,
|
|||
NS_ENSURE_TRUE_VOID(ret);
|
||||
}
|
||||
|
||||
void
|
||||
BluetoothDBusService::UpdateNotification(ControlEventId aEventId,
|
||||
uint64_t aData)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
NS_ENSURE_TRUE_VOID(this->IsReady());
|
||||
|
||||
BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get();
|
||||
NS_ENSURE_TRUE_VOID(a2dp);
|
||||
MOZ_ASSERT(a2dp->IsConnected());
|
||||
MOZ_ASSERT(a2dp->IsAvrcpConnected());
|
||||
|
||||
nsAutoString address;
|
||||
a2dp->GetAddress(address);
|
||||
nsString objectPath =
|
||||
GetObjectPathFromAddress(sAdapterPath, address);
|
||||
uint16_t eventId = aEventId;
|
||||
|
||||
bool ret = dbus_func_args_async(mConnection,
|
||||
-1,
|
||||
ControlCallback,
|
||||
nullptr,
|
||||
NS_ConvertUTF16toUTF8(objectPath).get(),
|
||||
DBUS_CTL_IFACE,
|
||||
"UpdateNotification",
|
||||
DBUS_TYPE_UINT16, &eventId,
|
||||
DBUS_TYPE_UINT64, &aData,
|
||||
DBUS_TYPE_INVALID);
|
||||
NS_ENSURE_TRUE_VOID(ret);
|
||||
}
|
||||
|
|
|
@ -163,6 +163,23 @@ public:
|
|||
const nsAString& aMessage) MOZ_OVERRIDE;
|
||||
|
||||
private:
|
||||
/**
|
||||
* For DBus Control method of "UpdateNotification", event id should be
|
||||
* specified as following:
|
||||
* (Please see specification of AVRCP 1.3, Table 5.28 for more details.)
|
||||
*/
|
||||
enum ControlEventId {
|
||||
EVENT_PLAYBACK_STATUS_CHANGED = 0x01,
|
||||
EVENT_TRACK_CHANGED = 0x02,
|
||||
EVENT_TRACK_REACHED_END = 0x03,
|
||||
EVENT_TRACK_REACHED_START = 0x04,
|
||||
EVENT_PLAYBACK_POS_CHANGED = 0x05,
|
||||
EVENT_BATT_STATUS_CHANGED = 0x06,
|
||||
EVENT_SYSTEM_STATUS_CHANGED = 0x07,
|
||||
EVENT_PLAYER_APPLICATION_SETTING_CHANGED = 0x08,
|
||||
EVENT_UNKNOWN
|
||||
};
|
||||
|
||||
nsresult SendGetPropertyMessage(const nsAString& aPath,
|
||||
const char* aInterface,
|
||||
void (*aCB)(DBusMessage *, void *),
|
||||
|
@ -175,6 +192,8 @@ private:
|
|||
const BluetoothNamedValue& aValue,
|
||||
BluetoothReplyRunnable* aRunnable);
|
||||
|
||||
void UpdateNotification(ControlEventId aEventId, uint64_t aData);
|
||||
|
||||
void DisconnectAllAcls(const nsAString& aAdapterPath);
|
||||
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче