From ce1e8006f870c19ae157a20fc509727a091392fd Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 00:15:38 -0700 Subject: [PATCH 01/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/1446f8017d55 Author: Rudy Lu Desc: Merge pull request #22533 from aniruddha-adhikary/master Bug 1029934 - User cannot input Rupee symbol. r=rudylu. ======== https://hg.mozilla.org/integration/gaia-central/rev/a10941940284 Author: Aniruddha Adhikary Desc: Bug 1029934 - User cannot input Rupee symbol --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 40c664fc65a..abb610263f4 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "1b07481115b939288cd034a592faef63395fdae9", + "revision": "1446f8017d55ba64ab0fe21f10b79215f9d7bd77", "repo_path": "/integration/gaia-central" } From 576f7a66df9d43963f17916179f3ba4ef196f442 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 00:22:32 -0700 Subject: [PATCH 02/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index e4a33148dab..d5213a05ee5 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 21cdea57f7f..3593d07bc04 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 4e4cdf664fc..3e0cbbcdf0b 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index e4a33148dab..d5213a05ee5 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index a12399327b4..165a11b8fd5 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 93a53e7cf38..86c39656f15 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index dabee6f130f..e5b49eaa0de 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index bd3b0bcd4bb..f09d30cbf1e 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 6e85251c6ff..36eeb28c9f1 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From ef8069abd72dd953a4bfe455538a0ecf0ec544fc Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 00:31:20 -0700 Subject: [PATCH 03/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ======== https://hg.mozilla.org/integration/gaia-central/rev/addea45d117e Author: Carmen JimĂ©nez Desc: Merge pull request #22094 from empoalp/dial-pause Bug 911055 - [zffos1.1][P3][Dailer]DuT doesn allow to dial a <> (r=drs) ======== https://hg.mozilla.org/integration/gaia-central/rev/8ecd91aac8a9 Author: David Garcia Desc: Bug 911055 - [zffos1.1][P3][Dailer]DuT doesn allow to dial a <> --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index abb610263f4..42f055d233e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "1446f8017d55ba64ab0fe21f10b79215f9d7bd77", + "revision": "addea45d117e22f3ef4171197d9dcd25676572da", "repo_path": "/integration/gaia-central" } From 28eeb4afe77410707278b02c6f39dfa821559832 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 00:33:37 -0700 Subject: [PATCH 04/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index d5213a05ee5..0b51f65d110 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 3593d07bc04..47606c83e4d 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 3e0cbbcdf0b..3d229768f6f 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index d5213a05ee5..0b51f65d110 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 165a11b8fd5..059e870ca11 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 86c39656f15..a23933b9338 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index e5b49eaa0de..de707c53cfb 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index f09d30cbf1e..2adbdc89c02 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 36eeb28c9f1..7f453023f6b 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From c7bb0acd67dcdf6f9cf3b8b7a7f9a0ec7ff8798d Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 04:40:33 -0700 Subject: [PATCH 05/49] Bumping gaia.json for 4 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/0e11e8dd1038 Author: AndreiH Desc: Merge pull request #22554 from viorelaioia/bug_1043293 Bug 1043293 - Follow up with test changes to address failures ======== https://hg.mozilla.org/integration/gaia-central/rev/09aaa8020eab Author: Viorela Ioia Desc: Bug 1043293 - Follow up with test changes to address failures ======== https://hg.mozilla.org/integration/gaia-central/rev/ad3c50bc88bd Author: Jan Jongboom Desc: Merge pull request #22525 from comoyo/reenable_1044984 Bug 1044984 - Reenable worker_test.js. r=RudyL ======== https://hg.mozilla.org/integration/gaia-central/rev/b8046cea5a55 Author: Jan Jongboom Desc: Bug 1044984 - Reenable worker_test.js --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 42f055d233e..ba0371bd70e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "addea45d117e22f3ef4171197d9dcd25676572da", + "revision": "0e11e8dd1038fb4909ae7fe764a3a67f96a033d8", "repo_path": "/integration/gaia-central" } From 24bbb0b8dbdcf88845fd26c8602ae6bef750b2cf Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 04:41:55 -0700 Subject: [PATCH 06/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 4 ++-- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 4 ++-- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 4 ++-- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 12 insertions(+), 12 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 0b51f65d110..fd14123a496 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 47606c83e4d..5747c87a9c7 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + @@ -133,7 +133,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 3d229768f6f..4583a63634d 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 0b51f65d110..fd14123a496 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 059e870ca11..9fa5da8b51e 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + @@ -145,7 +145,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index a23933b9338..f058f1a5a2f 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index de707c53cfb..a25d5b967ee 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 2adbdc89c02..dbb361d1ddf 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + @@ -129,7 +129,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 7f453023f6b..a0bdb934880 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 18c28adadad38c4ee62ad0c83da40f02dc74855f Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:44:47 +0200 Subject: [PATCH 07/49] Bug 1038591: Convert Bluetooth data types in |BluetoothInterface|, r=shuang With this patch, |BluetoothInterface| is responsible for converting all Bluetooth data types to Bluedroid types. All callers have been adapted. --- .../bluedroid/BluetoothInterface.cpp | 342 ++++++++++++++++-- dom/bluetooth/bluedroid/BluetoothInterface.h | 37 +- .../bluedroid/BluetoothServiceBluedroid.cpp | 87 +---- 3 files changed, 340 insertions(+), 126 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index a91774ccfc8..95f7fe70103 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -19,6 +19,166 @@ template struct interface_traits { }; +// +// Conversion +// + +static nsresult +Convert(const nsAString& aIn, bt_property_type_t& aOut) +{ + if (aIn.EqualsLiteral("Name")) { + aOut = BT_PROPERTY_BDNAME; + } else if (aIn.EqualsLiteral("Discoverable")) { + aOut = BT_PROPERTY_ADAPTER_SCAN_MODE; + } else if (aIn.EqualsLiteral("DiscoverableTimeout")) { + aOut = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT; + } else { + BT_LOGR("Invalid property name: %s", NS_ConvertUTF16toUTF8(aIn).get()); + return NS_ERROR_ILLEGAL_VALUE; + } + return NS_OK; +} + +static nsresult +Convert(bool aIn, bt_scan_mode_t& aOut) +{ + static const bt_scan_mode_t sScanMode[] = { + [false] = BT_SCAN_MODE_CONNECTABLE, + [true] = BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE + }; + if (aIn >= MOZ_ARRAY_LENGTH(sScanMode)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sScanMode[aIn]; + return NS_OK; +} + +struct ConvertNamedValue +{ + ConvertNamedValue(const BluetoothNamedValue& aNamedValue) + : mNamedValue(aNamedValue) + { } + + const BluetoothNamedValue& mNamedValue; + + // temporary fields + nsCString mStringValue; + bt_scan_mode_t mScanMode; +}; + +static nsresult +Convert(ConvertNamedValue& aIn, bt_property_t& aOut) +{ + nsresult rv = Convert(aIn.mNamedValue.name(), aOut.type); + if (NS_FAILED(rv)) { + return rv; + } + + if (aIn.mNamedValue.value().type() == BluetoothValue::Tuint32_t) { + // Set discoverable timeout + aOut.val = + reinterpret_cast(aIn.mNamedValue.value().get_uint32_t()); + } else if (aIn.mNamedValue.value().type() == BluetoothValue::TnsString) { + // Set name + aIn.mStringValue = + NS_ConvertUTF16toUTF8(aIn.mNamedValue.value().get_nsString()); + aOut.val = + const_cast(static_cast(aIn.mStringValue.get())); + aOut.len = strlen(static_cast(aOut.val)); + } else if (aIn.mNamedValue.value().type() == BluetoothValue::Tbool) { + // Set scan mode + rv = Convert(aIn.mNamedValue.value().get_bool(), aIn.mScanMode); + if (NS_FAILED(rv)) { + return rv; + } + aOut.val = &aIn.mScanMode; + aOut.len = sizeof(aIn.mScanMode); + } else { + BT_LOGR("Invalid property value type"); + return NS_ERROR_ILLEGAL_VALUE; + } + + return NS_OK; +} + +static nsresult +Convert(const nsAString& aIn, bt_bdaddr_t& aOut) +{ + NS_ConvertUTF16toUTF8 bdAddressUTF8(aIn); + const char* str = bdAddressUTF8.get(); + + for (size_t i = 0; i < MOZ_ARRAY_LENGTH(aOut.address); ++i, ++str) { + aOut.address[i] = + static_cast(strtoul(str, const_cast(&str), 16)); + } + + return NS_OK; +} + +static nsresult +Convert(const nsAString& aIn, bt_ssp_variant_t& aOut) +{ + if (aIn.EqualsLiteral("PasskeyConfirmation")) { + aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION; + } else if (aIn.EqualsLiteral("PasskeyEntry")) { + aOut = BT_SSP_VARIANT_PASSKEY_ENTRY; + } else if (aIn.EqualsLiteral("Consent")) { + aOut = BT_SSP_VARIANT_CONSENT; + } else if (aIn.EqualsLiteral("PasskeyNotification")) { + aOut = BT_SSP_VARIANT_PASSKEY_NOTIFICATION; + } else { + BT_LOGR("Invalid SSP variant name: %s", NS_ConvertUTF16toUTF8(aIn).get()); + aOut = BT_SSP_VARIANT_PASSKEY_CONFIRMATION; // silences compiler warning + return NS_ERROR_ILLEGAL_VALUE; + } + return NS_OK; +} + +static nsresult +Convert(const bool& aIn, uint8_t& aOut) +{ + // casting converts true/false to either 1 or 0 + aOut = static_cast(aIn); + return NS_OK; +} + +static nsresult +Convert(const uint8_t aIn[16], bt_uuid_t& aOut) +{ + if (sizeof(aOut.uu) != 16) { + return NS_ERROR_ILLEGAL_VALUE; + } + + memcpy(aOut.uu, aIn, sizeof(aOut.uu)); + + return NS_OK; +} + +static nsresult +Convert(const nsAString& aIn, bt_pin_code_t& aOut) +{ + if (aIn.Length() > MOZ_ARRAY_LENGTH(aOut.pin)) { + return NS_ERROR_ILLEGAL_VALUE; + } + + NS_ConvertUTF16toUTF8 pinCodeUTF8(aIn); + const char* str = pinCodeUTF8.get(); + + nsAString::size_type i; + + // Fill pin into aOut + for (i = 0; i < aIn.Length(); ++i, ++str) { + aOut.pin[i] = static_cast(*str); + } + + // Clear remaining bytes in aOut + size_t ntrailing = + (MOZ_ARRAY_LENGTH(aOut.pin) - aIn.Length()) * sizeof(aOut.pin[0]); + memset(aOut.pin + aIn.Length(), 0, ntrailing); + + return NS_OK; +} + // // Result handling // @@ -1314,23 +1474,41 @@ BluetoothInterface::GetAdapterProperties(BluetoothResultHandler* aRes) } void -BluetoothInterface::GetAdapterProperty(bt_property_type_t aType, +BluetoothInterface::GetAdapterProperty(const nsAString& aName, BluetoothResultHandler* aRes) { - int status = mInterface->get_adapter_property(aType); + int status; + bt_property_type_t type; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (false /* TODO: we don't support any values for aName currently */) { + status = mInterface->get_adapter_property(type); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, - &BluetoothResultHandler::GetAdapterProperty, + &BluetoothResultHandler::GetAdapterProperties, status); } } void -BluetoothInterface::SetAdapterProperty(const bt_property_t* aProperty, +BluetoothInterface::SetAdapterProperty(const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { - int status = mInterface->set_adapter_property(aProperty); + int status; + ConvertNamedValue convertProperty(aProperty); + bt_property_t property; + + if (NS_SUCCEEDED(Convert(convertProperty, property))) { + status = mInterface->set_adapter_property(&property); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1342,10 +1520,17 @@ BluetoothInterface::SetAdapterProperty(const bt_property_t* aProperty, /* Remote Device Properties */ void -BluetoothInterface::GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr, +BluetoothInterface::GetRemoteDeviceProperties(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes) { - int status = mInterface->get_remote_device_properties(aRemoteAddr); + int status; + bt_bdaddr_t addr; + + if (NS_SUCCEEDED(Convert(aRemoteAddr, addr))) { + status = mInterface->get_remote_device_properties(&addr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1355,11 +1540,23 @@ BluetoothInterface::GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr, } void -BluetoothInterface::GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, - bt_property_type_t aType, +BluetoothInterface::GetRemoteDeviceProperty(const nsAString& aRemoteAddr, + const nsAString& aName, BluetoothResultHandler* aRes) { - int status = mInterface->get_remote_device_property(aRemoteAddr, aType); + int status; + bt_bdaddr_t remoteAddr; + bt_property_type_t name; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && + false /* TODO: we don't support any values for aName currently */) { + status = mInterface->get_remote_device_property(&remoteAddr, name); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1369,11 +1566,23 @@ BluetoothInterface::GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, } void -BluetoothInterface::SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, - const bt_property_t* aProperty, +BluetoothInterface::SetRemoteDeviceProperty(const nsAString& aRemoteAddr, + const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes) { - int status = mInterface->set_remote_device_property(aRemoteAddr, aProperty); + int status; + bt_bdaddr_t remoteAddr; + bt_property_t property; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && + false /* TODO: we don't support any values for aProperty currently */) { + status = mInterface->set_remote_device_property(&remoteAddr, &property); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1385,11 +1594,20 @@ BluetoothInterface::SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, /* Remote Services */ void -BluetoothInterface::GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr, - bt_uuid_t* aUuid, +BluetoothInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr, + const uint8_t aUuid[16], BluetoothResultHandler* aRes) { - int status = mInterface->get_remote_service_record(aRemoteAddr, aUuid); + int status; + bt_bdaddr_t remoteAddr; + bt_uuid_t uuid; + + if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr)) && + NS_SUCCEEDED(Convert(aUuid, uuid))) { + status = mInterface->get_remote_service_record(&remoteAddr, &uuid); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1399,10 +1617,17 @@ BluetoothInterface::GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr, } void -BluetoothInterface::GetRemoteServices(bt_bdaddr_t* aRemoteAddr, +BluetoothInterface::GetRemoteServices(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes) { - int status = mInterface->get_remote_services(aRemoteAddr); + int status; + bt_bdaddr_t remoteAddr; + + if (NS_SUCCEEDED(Convert(aRemoteAddr, remoteAddr))) { + status = mInterface->get_remote_services(&remoteAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1440,10 +1665,17 @@ BluetoothInterface::CancelDiscovery(BluetoothResultHandler* aRes) /* Bonds */ void -BluetoothInterface::CreateBond(const bt_bdaddr_t* aBdAddr, +BluetoothInterface::CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { - int status = mInterface->create_bond(aBdAddr); + bt_bdaddr_t bdAddr; + int status; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->create_bond(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1453,10 +1685,17 @@ BluetoothInterface::CreateBond(const bt_bdaddr_t* aBdAddr, } void -BluetoothInterface::RemoveBond(const bt_bdaddr_t* aBdAddr, +BluetoothInterface::RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { - int status = mInterface->remove_bond(aBdAddr); + bt_bdaddr_t bdAddr; + int status; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->remove_bond(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1466,10 +1705,17 @@ BluetoothInterface::RemoveBond(const bt_bdaddr_t* aBdAddr, } void -BluetoothInterface::CancelBond(const bt_bdaddr_t* aBdAddr, +BluetoothInterface::CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes) { - int status = mInterface->cancel_bond(aBdAddr); + bt_bdaddr_t bdAddr; + int status; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->cancel_bond(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1481,11 +1727,23 @@ BluetoothInterface::CancelBond(const bt_bdaddr_t* aBdAddr, /* Authentication */ void -BluetoothInterface::PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept, - uint8_t aPinLen, bt_pin_code_t* aPinCode, +BluetoothInterface::PinReply(const nsAString& aBdAddr, bool aAccept, + const nsAString& aPinCode, BluetoothResultHandler* aRes) { - int status = mInterface->pin_reply(aBdAddr, aAccept, aPinLen, aPinCode); + int status; + bt_bdaddr_t bdAddr; + uint8_t accept; + bt_pin_code_t pinCode; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && + NS_SUCCEEDED(Convert(aAccept, accept)) && + NS_SUCCEEDED(Convert(aPinCode, pinCode))) { + status = mInterface->pin_reply(&bdAddr, accept, aPinCode.Length(), + &pinCode); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1495,12 +1753,23 @@ BluetoothInterface::PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept, } void -BluetoothInterface::SspReply(const bt_bdaddr_t* aBdAddr, - bt_ssp_variant_t aVariant, - uint8_t aAccept, uint32_t aPasskey, +BluetoothInterface::SspReply(const nsAString& aBdAddr, + const nsAString& aVariant, + bool aAccept, uint32_t aPasskey, BluetoothResultHandler* aRes) { - int status = mInterface->ssp_reply(aBdAddr, aVariant, aAccept, aPasskey); + int status; + bt_bdaddr_t bdAddr; + bt_ssp_variant_t variant; + uint8_t accept; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && + NS_SUCCEEDED(Convert(aVariant, variant)) && + NS_SUCCEEDED(Convert(aAccept, accept))) { + status = mInterface->ssp_reply(&bdAddr, variant, accept, aPasskey); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, @@ -1512,10 +1781,17 @@ BluetoothInterface::SspReply(const bt_bdaddr_t* aBdAddr, /* DUT Mode */ void -BluetoothInterface::DutModeConfigure(uint8_t aEnable, +BluetoothInterface::DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes) { - int status = mInterface->dut_mode_configure(aEnable); + int status; + uint8_t enable; + + if (NS_SUCCEEDED(Convert(aEnable, enable))) { + status = mInterface->dut_mode_configure(enable); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothResult(aRes, diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 0038e5653bb..095ce32a189 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -15,6 +15,7 @@ #include #endif #include "BluetoothCommon.h" +#include "mozilla/dom/bluetooth/BluetoothTypes.h" BEGIN_BLUETOOTH_NAMESPACE @@ -371,28 +372,28 @@ public: /* Adapter Properties */ void GetAdapterProperties(BluetoothResultHandler* aRes); - void GetAdapterProperty(bt_property_type_t aType, + void GetAdapterProperty(const nsAString& aName, BluetoothResultHandler* aRes); - void SetAdapterProperty(const bt_property_t* aProperty, + void SetAdapterProperty(const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes); /* Remote Device Properties */ - void GetRemoteDeviceProperties(bt_bdaddr_t *aRemoteAddr, + void GetRemoteDeviceProperties(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes); - void GetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, - bt_property_type_t aType, + void GetRemoteDeviceProperty(const nsAString& aRemoteAddr, + const nsAString& aName, BluetoothResultHandler* aRes); - void SetRemoteDeviceProperty(bt_bdaddr_t* aRemoteAddr, - const bt_property_t* aProperty, + void SetRemoteDeviceProperty(const nsAString& aRemoteAddr, + const BluetoothNamedValue& aProperty, BluetoothResultHandler* aRes); /* Remote Services */ - void GetRemoteServiceRecord(bt_bdaddr_t* aRemoteAddr, - bt_uuid_t* aUuid, + void GetRemoteServiceRecord(const nsAString& aRemoteAddr, + const uint8_t aUuid[16], BluetoothResultHandler* aRes); - void GetRemoteServices(bt_bdaddr_t* aRemoteAddr, + void GetRemoteServices(const nsAString& aRemoteAddr, BluetoothResultHandler* aRes); /* Discovery */ @@ -402,23 +403,23 @@ public: /* Bonds */ - void CreateBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes); - void RemoveBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes); - void CancelBond(const bt_bdaddr_t* aBdAddr, BluetoothResultHandler* aRes); + void CreateBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes); + void RemoveBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes); + void CancelBond(const nsAString& aBdAddr, BluetoothResultHandler* aRes); /* Authentication */ - void PinReply(const bt_bdaddr_t* aBdAddr, uint8_t aAccept, - uint8_t aPinLen, bt_pin_code_t* aPinCode, + void PinReply(const nsAString& aBdAddr, bool aAccept, + const nsAString& aPinCode, BluetoothResultHandler* aRes); - void SspReply(const bt_bdaddr_t* aBdAddr, bt_ssp_variant_t aVariant, - uint8_t aAccept, uint32_t aPasskey, + void SspReply(const nsAString& aBdAddr, const nsAString& aVariant, + bool aAccept, uint32_t aPasskey, BluetoothResultHandler* aRes); /* DUT Mode */ - void DutModeConfigure(uint8_t aEnable, BluetoothResultHandler* aRes); + void DutModeConfigure(bool aEnable, BluetoothResultHandler* aRes); void DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, BluetoothResultHandler* aRes); diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index ed0513bb561..f901c2f9048 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -127,15 +127,10 @@ public: sUnbondingRunnableArray.Clear(); // Bluetooth scan mode is NONE by default - bt_scan_mode_t mode = BT_SCAN_MODE_CONNECTABLE; - bt_property_t prop; - prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE; - prop.val = (void*)&mode; - prop.len = sizeof(mode); - NS_ENSURE_TRUE(sBtInterface, NS_ERROR_FAILURE); - sBtInterface->SetAdapterProperty(&prop, - new SetAdapterPropertyResultHandler()); + sBtInterface->SetAdapterProperty( + BluetoothNamedValue(NS_ConvertUTF8toUTF16("Discoverable"), true), + new SetAdapterPropertyResultHandler()); // Try to fire event 'AdapterAdded' to fit the original behaviour when // we used BlueZ as backend. @@ -1183,10 +1178,7 @@ BluetoothServiceBluedroid::GetConnectedDevicePropertiesInternal( for (int i = 0; i < requestedDeviceCount; i++) { // Retrieve all properties of devices - bt_bdaddr_t addressType; - StringToBdAddressType(deviceAddresses[i], &addressType); - - sBtInterface->GetRemoteDeviceProperties(&addressType, + sBtInterface->GetRemoteDeviceProperties(deviceAddresses[i], new GetRemoteDevicePropertiesResultHandler(deviceAddresses[i])); } @@ -1213,10 +1205,7 @@ BluetoothServiceBluedroid::GetPairedDevicePropertiesInternal( for (int i = 0; i < requestedDeviceCount; i++) { // Retrieve all properties of devices - bt_bdaddr_t addressType; - StringToBdAddressType(aDeviceAddress[i], &addressType); - - sBtInterface->GetRemoteDeviceProperties(&addressType, + sBtInterface->GetRemoteDeviceProperties(aDeviceAddress[i], new GetRemoteDevicePropertiesResultHandler(aDeviceAddress[i])); } @@ -1315,49 +1304,11 @@ BluetoothServiceBluedroid::SetProperty(BluetoothObjectType aType, BluetoothReplyRunnable* aRunnable) { MOZ_ASSERT(NS_IsMainThread()); - ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK); - const nsString propName = aValue.name(); - bt_property_t prop; - bt_scan_mode_t scanMode; - nsCString str; - - // For Bluedroid, it's necessary to check property name for SetProperty - if (propName.EqualsLiteral("Name")) { - prop.type = BT_PROPERTY_BDNAME; - } else if (propName.EqualsLiteral("Discoverable")) { - prop.type = BT_PROPERTY_ADAPTER_SCAN_MODE; - } else if (propName.EqualsLiteral("DiscoverableTimeout")) { - prop.type = BT_PROPERTY_ADAPTER_DISCOVERY_TIMEOUT; - } else { - BT_LOGR("Warning: Property type is not supported yet, type: %d", prop.type); - } - - if (aValue.value().type() == BluetoothValue::Tuint32_t) { - // Set discoverable timeout - prop.val = (void*)aValue.value().get_uint32_t(); - } else if (aValue.value().type() == BluetoothValue::TnsString) { - // Set name - str = NS_ConvertUTF16toUTF8(aValue.value().get_nsString()); - const char* name = str.get(); - prop.val = (void*)name; - prop.len = strlen(name); - } else if (aValue.value().type() == BluetoothValue::Tbool) { - scanMode = aValue.value().get_bool() ? - BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE : - BT_SCAN_MODE_CONNECTABLE; - - prop.val = (void*)&scanMode; - prop.len = sizeof(scanMode); - } else { - BT_LOGR("SetProperty but the property cannot be recognized correctly."); - return NS_OK; - } - sSetPropertyRunnableArray.AppendElement(aRunnable); - sBtInterface->SetAdapterProperty(&prop, + sBtInterface->SetAdapterProperty(aValue, new SetAdapterPropertyResultHandler(aRunnable)); return NS_OK; @@ -1406,12 +1357,9 @@ BluetoothServiceBluedroid::CreatePairedDeviceInternal( ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK); - bt_bdaddr_t remoteAddress; - StringToBdAddressType(aDeviceAddress, &remoteAddress); - sBondingRunnableArray.AppendElement(aRunnable); - sBtInterface->CreateBond(&remoteAddress, + sBtInterface->CreateBond(aDeviceAddress, new CreateBondResultHandler(aRunnable)); return NS_OK; @@ -1442,13 +1390,9 @@ BluetoothServiceBluedroid::RemoveDeviceInternal( ENSURE_BLUETOOTH_IS_READY(aRunnable, NS_OK); - bt_bdaddr_t remoteAddress; - StringToBdAddressType(aDeviceAddress, &remoteAddress); - - PRUint32 i = sUnbondingRunnableArray.Length(); sUnbondingRunnableArray.AppendElement(aRunnable); - sBtInterface->RemoveBond(&remoteAddress, + sBtInterface->RemoveBond(aDeviceAddress, new RemoveBondResultHandler(aRunnable)); return NS_OK; @@ -1484,12 +1428,7 @@ BluetoothServiceBluedroid::SetPinCodeInternal( ENSURE_BLUETOOTH_IS_READY(aRunnable, false); - bt_bdaddr_t remoteAddress; - StringToBdAddressType(aDeviceAddress, &remoteAddress); - - sBtInterface->PinReply( - &remoteAddress, true, aPinCode.Length(), - (bt_pin_code_t*)NS_ConvertUTF16toUTF8(aPinCode).get(), + sBtInterface->PinReply(aDeviceAddress, true, aPinCode, new PinReplyResultHandler(aRunnable)); return true; @@ -1534,11 +1473,9 @@ BluetoothServiceBluedroid::SetPairingConfirmationInternal( ENSURE_BLUETOOTH_IS_READY(aRunnable, false); - bt_bdaddr_t remoteAddress; - StringToBdAddressType(aDeviceAddress, &remoteAddress); - - sBtInterface->SspReply(&remoteAddress, (bt_ssp_variant_t)0, aConfirm, 0, - new SspReplyResultHandler(aRunnable)); + sBtInterface->SspReply(aDeviceAddress, + NS_ConvertUTF8toUTF16("PasskeyConfirmation"), + aConfirm, 0, new SspReplyResultHandler(aRunnable)); return true; } From 8feb4fd363358b5c52ad6ceedf7f73208ed8fd4d Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:44:56 +0200 Subject: [PATCH 08/49] Bug 1038591: Convert Bluetooth Socket data types in |BluetoothSocketInterface|, r=shuang With this patch |BluetoothSocketInterface| is responsible for converting all Bluetooth data types to Bluedroid types. All callers have been adapted. --- .../bluedroid/BluetoothInterface.cpp | 104 ++++++++++++++---- dom/bluetooth/bluedroid/BluetoothInterface.h | 14 ++- dom/bluetooth/bluedroid/BluetoothSocket.cpp | 31 +++--- 3 files changed, 108 insertions(+), 41 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index 95f7fe70103..c5195da0a17 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -179,6 +179,50 @@ Convert(const nsAString& aIn, bt_pin_code_t& aOut) return NS_OK; } +static nsresult +Convert(const bt_bdaddr_t& aIn, nsAString& aOut) +{ + char str[BLUETOOTH_ADDRESS_LENGTH + 1]; + + int res = snprintf(str, sizeof(str), "%02x:%02x:%02x:%02x:%02x:%02x", + static_cast(aIn.address[0]), + static_cast(aIn.address[1]), + static_cast(aIn.address[2]), + static_cast(aIn.address[3]), + static_cast(aIn.address[4]), + static_cast(aIn.address[5])); + if (res < 0) { + return NS_ERROR_ILLEGAL_VALUE; + } else if ((size_t)res >= sizeof(str)) { + return NS_ERROR_OUT_OF_MEMORY; /* string buffer too small */ + } + + aOut = NS_ConvertUTF8toUTF16(str); + + return NS_OK; +} + +static nsresult +Convert(BluetoothSocketType aIn, btsock_type_t& aOut) +{ + // FIXME: Array member [0] is currently invalid, but required + // by gcc. Start values in |BluetoothSocketType| at index + // 0 to fix this problem. + static const btsock_type_t sSocketType[] = { + [0] = static_cast(0), // invalid, [0] required by gcc + [BluetoothSocketType::RFCOMM] = BTSOCK_RFCOMM, + [BluetoothSocketType::SCO] = BTSOCK_SCO, + [BluetoothSocketType::L2CAP] = BTSOCK_L2CAP, + // EL2CAP is not supported by Bluedroid + }; + if (aIn == BluetoothSocketType::EL2CAP || + aIn >= MOZ_ARRAY_LENGTH(sSocketType) || !sSocketType[aIn]) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sSocketType[aIn]; + return NS_OK; +} + // // Result handling // @@ -347,16 +391,26 @@ DispatchBluetoothSocketResult( } void -BluetoothSocketInterface::Listen(btsock_type_t aType, - const char* aServiceName, - const uint8_t* aServiceUuid, - int aChannel, int aFlags, +BluetoothSocketInterface::Listen(BluetoothSocketType aType, + const nsAString& aServiceName, + const uint8_t aServiceUuid[16], + int aChannel, bool aEncrypt, bool aAuth, BluetoothSocketResultHandler* aRes) { int fd; + bt_status_t status; + btsock_type_t type = BTSOCK_RFCOMM; // silences compiler warning + + if (NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->listen(type, + NS_ConvertUTF16toUTF8(aServiceName).get(), + aServiceUuid, aChannel, &fd, + (BTSOCK_FLAG_ENCRYPT * aEncrypt) | + (BTSOCK_FLAG_AUTH * aAuth)); + } else { + status = BT_STATUS_PARM_INVALID; + } - bt_status_t status = mInterface->listen(aType, aServiceName, aServiceUuid, - aChannel, &fd, aFlags); if (aRes) { DispatchBluetoothSocketResult(aRes, &BluetoothSocketResultHandler::Listen, fd, status); @@ -567,11 +621,12 @@ private: void ReadBdAddress(unsigned long aOffset, nsAString& aBdAddress) const { - char str[18]; - sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", - mBuf[aOffset + 0], mBuf[aOffset + 1], mBuf[aOffset + 2], - mBuf[aOffset + 3], mBuf[aOffset + 4], mBuf[aOffset + 5]); - aBdAddress.AssignLiteral(str); + const bt_bdaddr_t* bdAddress = + reinterpret_cast(mBuf+aOffset); + + if (NS_FAILED(Convert(*bdAddress, aBdAddress))) { + aBdAddress.AssignLiteral(BLUETOOTH_ADDRESS_NONE); + } } MessageLoopForIO::FileDescriptorWatcher mWatcher; @@ -651,23 +706,34 @@ private: }; void -BluetoothSocketInterface::Connect(const bt_bdaddr_t* aBdAddr, - btsock_type_t aType, const uint8_t* aUuid, - int aChannel, int aFlags, +BluetoothSocketInterface::Connect(const nsAString& aBdAddr, + BluetoothSocketType aType, + const uint8_t aUuid[16], + int aChannel, bool aEncrypt, bool aAuth, BluetoothSocketResultHandler* aRes) { int fd; + bt_status_t status; + bt_bdaddr_t bdAddr; + btsock_type_t type = BTSOCK_RFCOMM; // silences compiler warning + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr)) && + NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->connect(&bdAddr, type, aUuid, aChannel, &fd, + (BTSOCK_FLAG_ENCRYPT * aEncrypt) | + (BTSOCK_FLAG_AUTH * aAuth)); + } else { + status = BT_STATUS_PARM_INVALID; + } - bt_status_t status = mInterface->connect(aBdAddr, aType, aUuid, aChannel, - &fd, aFlags); if (status == BT_STATUS_SUCCESS) { /* receive Bluedroid's socket-setup messages */ Task* t = new SocketMessageWatcherTask(new ConnectWatcher(fd, aRes)); XRE_GetIOMessageLoop()->PostTask(FROM_HERE, t); } else if (aRes) { - DispatchBluetoothSocketResult(aRes, - &BluetoothSocketResultHandler::Connect, - -1, EmptyString(), 0, status); + DispatchBluetoothSocketResult(aRes, + &BluetoothSocketResultHandler::Connect, + -1, EmptyString(), 0, status); } } diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 095ce32a189..9f9acc8f158 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -51,12 +51,16 @@ public: // Init and Cleanup is handled by BluetoothInterface - void Listen(btsock_type_t aType, - const char* aServiceName, const uint8_t* aServiceUuid, - int aChannel, int aFlags, BluetoothSocketResultHandler* aRes); + void Listen(BluetoothSocketType aType, + const nsAString& aServiceName, + const uint8_t aServiceUuid[16], + int aChannel, bool aEncrypt, bool aAuth, + BluetoothSocketResultHandler* aRes); - void Connect(const bt_bdaddr_t* aBdAddr, btsock_type_t aType, - const uint8_t* aUuid, int aChannel, int aFlags, + void Connect(const nsAString& aBdAddr, + BluetoothSocketType aType, + const uint8_t aUuid[16], + int aChannel, bool aEncrypt, bool aAuth, BluetoothSocketResultHandler* aRes); void Accept(int aFd, BluetoothSocketResultHandler* aRes); diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.cpp b/dom/bluetooth/bluedroid/BluetoothSocket.cpp index 10b93d4d5d6..805ba662544 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp +++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp @@ -851,17 +851,14 @@ BluetoothSocket::Connect(const nsAString& aDeviceAddress, int aChannel) mImpl = new DroidSocketImpl(XRE_GetIOMessageLoop(), this, aDeviceAddress, aChannel, mAuth, mEncrypt); - bt_bdaddr_t remoteBdAddress; - StringToBdAddressType(aDeviceAddress, &remoteBdAddress); - // TODO: uuid as argument - sBluetoothSocketInterface->Connect(&remoteBdAddress, - BTSOCK_RFCOMM, - UUID_OBEX_OBJECT_PUSH, - aChannel, - (BTSOCK_FLAG_ENCRYPT * mEncrypt) | - (BTSOCK_FLAG_AUTH * mAuth), - new ConnectSocketResultHandler(mImpl)); + sBluetoothSocketInterface->Connect( + aDeviceAddress, + BluetoothSocketType::RFCOMM, + UUID_OBEX_OBJECT_PUSH, + aChannel, mEncrypt, mAuth, + new ConnectSocketResultHandler(mImpl)); + return true; } @@ -902,13 +899,13 @@ BluetoothSocket::Listen(int aChannel) mImpl = new DroidSocketImpl(XRE_GetIOMessageLoop(), this, aChannel, mAuth, mEncrypt); - sBluetoothSocketInterface->Listen(BTSOCK_RFCOMM, - "OBEX Object Push", - UUID_OBEX_OBJECT_PUSH, - aChannel, - (BTSOCK_FLAG_ENCRYPT * mEncrypt) | - (BTSOCK_FLAG_AUTH * mAuth), - new ListenResultHandler(mImpl)); + sBluetoothSocketInterface->Listen( + BluetoothSocketType::RFCOMM, + NS_LITERAL_STRING("OBEX Object Push"), + UUID_OBEX_OBJECT_PUSH, + aChannel, mEncrypt, mAuth, + new ListenResultHandler(mImpl)); + return true; } From f15dfc8ccd108f559fe98bb2e1dbbd0de7dfb5a6 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:45:05 +0200 Subject: [PATCH 09/49] Bug 1038591: Convert Bluetooth Handsfree data types in |BluetoothHandsfreeInterface|, r=shuang With this patch |BluetoothHandsfreeInterface| is responsible for converting all Bluetooth data types to Bluedroid types. All callers have been adapted. --- dom/bluetooth/BluetoothCommon.h | 51 +++ .../bluedroid/BluetoothInterface.cpp | 294 ++++++++++++++++-- dom/bluetooth/bluedroid/BluetoothInterface.h | 33 +- .../bluedroid/hfp/BluetoothHfpManager.cpp | 108 +++---- .../bluedroid/hfp/BluetoothHfpManager.h | 13 +- 5 files changed, 388 insertions(+), 111 deletions(-) diff --git a/dom/bluetooth/BluetoothCommon.h b/dom/bluetooth/BluetoothCommon.h index 4f93cc93572..84eeba2f0ee 100644 --- a/dom/bluetooth/BluetoothCommon.h +++ b/dom/bluetooth/BluetoothCommon.h @@ -139,6 +139,57 @@ enum BluetoothSocketType { EL2CAP = 4 }; +enum BluetoothHandsfreeAtResponse { + HFP_AT_RESPONSE_ERROR, + HFP_AT_RESPONSE_OK +}; + +enum BluetoothHandsfreeCallAddressType { + HFP_CALL_ADDRESS_TYPE_UNKNOWN, + HFP_CALL_ADDRESS_TYPE_INTERNATIONAL +}; + +enum BluetoothHandsfreeCallDirection { + HFP_CALL_DIRECTION_OUTGOING, + HFP_CALL_DIRECTION_INCOMING +}; + +enum BluetoothHandsfreeCallMode { + HFP_CALL_MODE_VOICE, + HFP_CALL_MODE_DATA, + HFP_CALL_MODE_FAX +}; + +enum BluetoothHandsfreeCallMptyType { + HFP_CALL_MPTY_TYPE_SINGLE, + HFP_CALL_MPTY_TYPE_MULTI +}; + +enum BluetoothHandsfreeCallState { + HFP_CALL_STATE_ACTIVE, + HFP_CALL_STATE_HELD, + HFP_CALL_STATE_DIALING, + HFP_CALL_STATE_ALERTING, + HFP_CALL_STATE_INCOMING, + HFP_CALL_STATE_WAITING, + HFP_CALL_STATE_IDLE +}; + +enum BluetoothHandsfreeNetworkState { + HFP_NETWORK_STATE_NOT_AVAILABLE, + HFP_NETWORK_STATE_AVAILABLE +}; + +enum BluetoothHandsfreeServiceType { + HFP_SERVICE_TYPE_HOME, + HFP_SERVICE_TYPE_ROAMING +}; + +enum BluetoothHandsfreeVolumeType { + HFP_VOLUME_TYPE_SPEAKER, + HFP_VOLUME_TYPE_MICROPHONE +}; + class BluetoothSignal; typedef mozilla::Observer BluetoothSignalObserver; diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index c5195da0a17..b4d8e83d7a4 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -223,6 +223,138 @@ Convert(BluetoothSocketType aIn, btsock_type_t& aOut) return NS_OK; } +static nsresult +Convert(BluetoothHandsfreeAtResponse aIn, bthf_at_response_t& aOut) +{ + static const bthf_at_response_t sAtResponse[] = { + [HFP_AT_RESPONSE_ERROR] = BTHF_AT_RESPONSE_ERROR, + [HFP_AT_RESPONSE_OK] = BTHF_AT_RESPONSE_OK + }; + if (aIn >= MOZ_ARRAY_LENGTH(sAtResponse)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sAtResponse[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeCallAddressType aIn, bthf_call_addrtype_t& aOut) +{ + static const bthf_call_addrtype_t sCallAddressType[] = { + [HFP_CALL_ADDRESS_TYPE_UNKNOWN] = BTHF_CALL_ADDRTYPE_UNKNOWN, + [HFP_CALL_ADDRESS_TYPE_INTERNATIONAL] = BTHF_CALL_ADDRTYPE_INTERNATIONAL + }; + if (aIn >= MOZ_ARRAY_LENGTH(sCallAddressType)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sCallAddressType[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeCallDirection aIn, bthf_call_direction_t& aOut) +{ + static const bthf_call_direction_t sCallDirection[] = { + [HFP_CALL_DIRECTION_OUTGOING] = BTHF_CALL_DIRECTION_OUTGOING, + [HFP_CALL_DIRECTION_INCOMING] = BTHF_CALL_DIRECTION_INCOMING + }; + if (aIn >= MOZ_ARRAY_LENGTH(sCallDirection)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sCallDirection[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeCallMode aIn, bthf_call_mode_t& aOut) +{ + static const bthf_call_mode_t sCallMode[] = { + [HFP_CALL_MODE_VOICE] = BTHF_CALL_TYPE_VOICE, + [HFP_CALL_MODE_DATA] = BTHF_CALL_TYPE_DATA, + [HFP_CALL_MODE_FAX] = BTHF_CALL_TYPE_FAX + }; + if (aIn >= MOZ_ARRAY_LENGTH(sCallMode)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sCallMode[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeCallMptyType aIn, bthf_call_mpty_type_t& aOut) +{ + static const bthf_call_mpty_type_t sCallMptyType[] = { + [HFP_CALL_MPTY_TYPE_SINGLE] = BTHF_CALL_MPTY_TYPE_SINGLE, + [HFP_CALL_MPTY_TYPE_MULTI] = BTHF_CALL_MPTY_TYPE_MULTI + }; + if (aIn >= MOZ_ARRAY_LENGTH(sCallMptyType)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sCallMptyType[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeCallState aIn, bthf_call_state_t& aOut) +{ + static const bthf_call_state_t sCallState[] = { + [HFP_CALL_STATE_ACTIVE] = BTHF_CALL_STATE_ACTIVE, + [HFP_CALL_STATE_HELD] = BTHF_CALL_STATE_HELD, + [HFP_CALL_STATE_DIALING] = BTHF_CALL_STATE_DIALING, + [HFP_CALL_STATE_ALERTING] = BTHF_CALL_STATE_ALERTING, + [HFP_CALL_STATE_INCOMING] = BTHF_CALL_STATE_INCOMING, + [HFP_CALL_STATE_WAITING] = BTHF_CALL_STATE_WAITING, + [HFP_CALL_STATE_IDLE] = BTHF_CALL_STATE_IDLE + }; + if (aIn >= MOZ_ARRAY_LENGTH(sCallState)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sCallState[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeNetworkState aIn, bthf_network_state_t& aOut) +{ + static const bthf_network_state_t sNetworkState[] = { + [HFP_NETWORK_STATE_NOT_AVAILABLE] = BTHF_NETWORK_STATE_NOT_AVAILABLE, + [HFP_NETWORK_STATE_AVAILABLE] = BTHF_NETWORK_STATE_AVAILABLE + }; + if (aIn >= MOZ_ARRAY_LENGTH(sNetworkState)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sNetworkState[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeServiceType aIn, bthf_service_type_t& aOut) +{ + static const bthf_service_type_t sServiceType[] = { + [HFP_SERVICE_TYPE_HOME] = BTHF_SERVICE_TYPE_HOME, + [HFP_SERVICE_TYPE_ROAMING] = BTHF_SERVICE_TYPE_ROAMING + }; + if (aIn >= MOZ_ARRAY_LENGTH(sServiceType)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sServiceType[aIn]; + return NS_OK; +} + +static nsresult +Convert(BluetoothHandsfreeVolumeType aIn, bthf_volume_type_t& aOut) +{ + static const bthf_volume_type_t sVolumeType[] = { + [HFP_VOLUME_TYPE_SPEAKER] = BTHF_VOLUME_TYPE_SPK, + [HFP_VOLUME_TYPE_MICROPHONE] = BTHF_VOLUME_TYPE_MIC + }; + if (aIn >= MOZ_ARRAY_LENGTH(sVolumeType)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sVolumeType[aIn]; + return NS_OK; +} + // // Result handling // @@ -875,10 +1007,17 @@ BluetoothHandsfreeInterface::Cleanup(BluetoothHandsfreeResultHandler* aRes) /* Connect / Disconnect */ void -BluetoothHandsfreeInterface::Connect(bt_bdaddr_t* aBdAddr, +BluetoothHandsfreeInterface::Connect(const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->connect(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->connect(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -887,10 +1026,17 @@ BluetoothHandsfreeInterface::Connect(bt_bdaddr_t* aBdAddr, } void -BluetoothHandsfreeInterface::Disconnect(bt_bdaddr_t* aBdAddr, - BluetoothHandsfreeResultHandler* aRes) +BluetoothHandsfreeInterface::Disconnect( + const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->disconnect(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->disconnect(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -900,9 +1046,16 @@ BluetoothHandsfreeInterface::Disconnect(bt_bdaddr_t* aBdAddr, void BluetoothHandsfreeInterface::ConnectAudio( - bt_bdaddr_t* aBdAddr, BluetoothHandsfreeResultHandler* aRes) + const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->connect_audio(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->connect_audio(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -912,9 +1065,16 @@ BluetoothHandsfreeInterface::ConnectAudio( void BluetoothHandsfreeInterface::DisconnectAudio( - bt_bdaddr_t* aBdAddr, BluetoothHandsfreeResultHandler* aRes) + const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->disconnect_audio(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->disconnect_audio(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -952,9 +1112,17 @@ BluetoothHandsfreeInterface::StopVoiceRecognition( void BluetoothHandsfreeInterface::VolumeControl( - bthf_volume_type_t aType, int aVolume, BluetoothHandsfreeResultHandler* aRes) + BluetoothHandsfreeVolumeType aType, int aVolume, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->volume_control(aType, aVolume); + bt_status_t status; + bthf_volume_type_t type = BTHF_VOLUME_TYPE_SPK; + + if (NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->volume_control(type, aVolume); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -966,11 +1134,21 @@ BluetoothHandsfreeInterface::VolumeControl( void BluetoothHandsfreeInterface::DeviceStatusNotification( - bthf_network_state_t aNtkState, bthf_service_type_t aSvcType, int aSignal, + BluetoothHandsfreeNetworkState aNtkState, + BluetoothHandsfreeServiceType aSvcType, int aSignal, int aBattChg, BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->device_status_notification( - aNtkState, aSvcType, aSignal, aBattChg); + bt_status_t status; + bthf_network_state_t ntkState = BTHF_NETWORK_STATE_NOT_AVAILABLE; + bthf_service_type_t svcType = BTHF_SERVICE_TYPE_HOME; + + if (NS_SUCCEEDED(Convert(aNtkState, ntkState)) && + NS_SUCCEEDED(Convert(aSvcType, svcType))) { + status = mInterface->device_status_notification(ntkState, svcType, + aSignal, aBattChg); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -995,12 +1173,22 @@ BluetoothHandsfreeInterface::CopsResponse( void BluetoothHandsfreeInterface::CindResponse( - int aSvc, int aNumActive, int aNumHeld, bthf_call_state_t aCallSetupState, - int aSignal, int aRoam, int aBattChg, BluetoothHandsfreeResultHandler* aRes) + int aSvc, int aNumActive, int aNumHeld, + BluetoothHandsfreeCallState aCallSetupState, + int aSignal, int aRoam, int aBattChg, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->cind_response(aSvc, aNumActive, aNumHeld, - aCallSetupState, aSignal, - aRoam, aBattChg); + bt_status_t status; + bthf_call_state_t callSetupState = BTHF_CALL_STATE_ACTIVE; + + if (NS_SUCCEEDED(Convert(aCallSetupState, callSetupState))) { + status = mInterface->cind_response(aSvc, aNumActive, aNumHeld, + callSetupState, aSignal, + aRoam, aBattChg); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothHandsfreeResult( aRes, &BluetoothHandsfreeResultHandler::CindResponse, status); @@ -1020,11 +1208,18 @@ BluetoothHandsfreeInterface::FormattedAtResponse( } void -BluetoothHandsfreeInterface::AtResponse(bthf_at_response_t aResponseCode, - int aErrorCode, - BluetoothHandsfreeResultHandler* aRes) +BluetoothHandsfreeInterface::AtResponse( + BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->at_response(aResponseCode, aErrorCode); + bt_status_t status; + bthf_at_response_t responseCode = BTHF_AT_RESPONSE_ERROR; + + if (NS_SUCCEEDED(Convert(aResponseCode, responseCode))) { + status = mInterface->at_response(responseCode, aErrorCode); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothHandsfreeResult( @@ -1034,12 +1229,34 @@ BluetoothHandsfreeInterface::AtResponse(bthf_at_response_t aResponseCode, void BluetoothHandsfreeInterface::ClccResponse( - int aIndex, bthf_call_direction_t aDir, bthf_call_state_t aState, - bthf_call_mode_t aMode, bthf_call_mpty_type_t aMpty, const char* aNumber, - bthf_call_addrtype_t aType, BluetoothHandsfreeResultHandler* aRes) + int aIndex, + BluetoothHandsfreeCallDirection aDir, + BluetoothHandsfreeCallState aState, + BluetoothHandsfreeCallMode aMode, + BluetoothHandsfreeCallMptyType aMpty, + const nsAString& aNumber, + BluetoothHandsfreeCallAddressType aType, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->clcc_response(aIndex, aDir, aState, aMode, - aMpty, aNumber, aType); + bt_status_t status; + bthf_call_direction_t dir = BTHF_CALL_DIRECTION_OUTGOING; + bthf_call_state_t state = BTHF_CALL_STATE_ACTIVE; + bthf_call_mode_t mode = BTHF_CALL_TYPE_VOICE; + bthf_call_mpty_type_t mpty = BTHF_CALL_MPTY_TYPE_SINGLE; + bthf_call_addrtype_t type = BTHF_CALL_ADDRTYPE_UNKNOWN; + + if (NS_SUCCEEDED(Convert(aDir, dir)) && + NS_SUCCEEDED(Convert(aState, state)) && + NS_SUCCEEDED(Convert(aMode, mode)) && + NS_SUCCEEDED(Convert(aMpty, mpty)) && + NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->clcc_response(aIndex, dir, state, mode, mpty, + NS_ConvertUTF16toUTF8(aNumber).get(), + type); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothHandsfreeResult( aRes, &BluetoothHandsfreeResultHandler::ClccResponse, status); @@ -1050,12 +1267,23 @@ BluetoothHandsfreeInterface::ClccResponse( void BluetoothHandsfreeInterface::PhoneStateChange(int aNumActive, int aNumHeld, - bthf_call_state_t aCallSetupState, const char* aNumber, - bthf_call_addrtype_t aType, BluetoothHandsfreeResultHandler* aRes) + BluetoothHandsfreeCallState aCallSetupState, const nsAString& aNumber, + BluetoothHandsfreeCallAddressType aType, + BluetoothHandsfreeResultHandler* aRes) { - bt_status_t status = mInterface->phone_state_change(aNumActive, aNumHeld, - aCallSetupState, - aNumber, aType); + bt_status_t status; + bthf_call_state_t callSetupState = BTHF_CALL_STATE_ACTIVE; + bthf_call_addrtype_t type = BTHF_CALL_ADDRTYPE_UNKNOWN; + + if (NS_SUCCEEDED(Convert(aCallSetupState, callSetupState)) && + NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->phone_state_change( + aNumActive, aNumHeld, callSetupState, + NS_ConvertUTF16toUTF8(aNumber).get(), type); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothHandsfreeResult( aRes, &BluetoothHandsfreeResultHandler::PhoneStateChange, status); diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 9f9acc8f158..28a4a2e0128 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -123,13 +123,13 @@ public: /* Connect / Disconnect */ - void Connect(bt_bdaddr_t* aBdAddr, + void Connect(const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes); - void Disconnect(bt_bdaddr_t* aBdAddr, + void Disconnect(const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes); - void ConnectAudio(bt_bdaddr_t* aBdAddr, + void ConnectAudio(const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes); - void DisconnectAudio(bt_bdaddr_t* aBdAddr, + void DisconnectAudio(const nsAString& aBdAddr, BluetoothHandsfreeResultHandler* aRes); /* Voice Recognition */ @@ -139,13 +139,13 @@ public: /* Volume */ - void VolumeControl(bthf_volume_type_t aType, int aVolume, + void VolumeControl(BluetoothHandsfreeVolumeType aType, int aVolume, BluetoothHandsfreeResultHandler* aRes); /* Device status */ - void DeviceStatusNotification(bthf_network_state_t aNtkState, - bthf_service_type_t aSvcType, + void DeviceStatusNotification(BluetoothHandsfreeNetworkState aNtkState, + BluetoothHandsfreeServiceType aSvcType, int aSignal, int aBattChg, BluetoothHandsfreeResultHandler* aRes); @@ -154,24 +154,27 @@ public: void CopsResponse(const char* aCops, BluetoothHandsfreeResultHandler* aRes); void CindResponse(int aSvc, int aNumActive, int aNumHeld, - bthf_call_state_t aCallSetupState, int aSignal, + BluetoothHandsfreeCallState aCallSetupState, int aSignal, int aRoam, int aBattChg, BluetoothHandsfreeResultHandler* aRes); void FormattedAtResponse(const char* aRsp, BluetoothHandsfreeResultHandler* aRes); - void AtResponse(bthf_at_response_t aResponseCode, int aErrorCode, + void AtResponse(BluetoothHandsfreeAtResponse aResponseCode, int aErrorCode, BluetoothHandsfreeResultHandler* aRes); - void ClccResponse(int aIndex, bthf_call_direction_t aDir, - bthf_call_state_t aState, bthf_call_mode_t aMode, - bthf_call_mpty_type_t aMpty, const char* aNumber, - bthf_call_addrtype_t aType, + void ClccResponse(int aIndex, BluetoothHandsfreeCallDirection aDir, + BluetoothHandsfreeCallState aState, + BluetoothHandsfreeCallMode aMode, + BluetoothHandsfreeCallMptyType aMpty, + const nsAString& aNumber, + BluetoothHandsfreeCallAddressType aType, BluetoothHandsfreeResultHandler* aRes); /* Phone State */ void PhoneStateChange(int aNumActive, int aNumHeld, - bthf_call_state_t aCallSetupState, - const char* aNumber, bthf_call_addrtype_t aType, + BluetoothHandsfreeCallState aCallSetupState, + const nsAString& aNumber, + BluetoothHandsfreeCallAddressType aType, BluetoothHandsfreeResultHandler* aRes); protected: diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index 0ee78799597..d74f24f4c56 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -251,7 +251,7 @@ private: if (!sBluetoothHfpManager->mDialingRequestProcessed) { sBluetoothHfpManager->mDialingRequestProcessed = true; - sBluetoothHfpManager->SendResponse(BTHF_AT_RESPONSE_ERROR); + sBluetoothHfpManager->SendResponse(HFP_AT_RESPONSE_ERROR); } } }; @@ -325,11 +325,13 @@ void Call::Set(const nsAString& aNumber, const bool aIsOutgoing) { mNumber = aNumber; - mDirection = (aIsOutgoing) ? BTHF_CALL_DIRECTION_OUTGOING : - BTHF_CALL_DIRECTION_INCOMING; + mDirection = (aIsOutgoing) ? HFP_CALL_DIRECTION_OUTGOING : + HFP_CALL_DIRECTION_INCOMING; // Same logic as implementation in ril_worker.js if (aNumber.Length() && aNumber[0] == '+') { - mType = BTHF_CALL_ADDRTYPE_INTERNATIONAL; + mType = HFP_CALL_ADDRESS_TYPE_INTERNATIONAL; + } else { + mType = HFP_CALL_ADDRESS_TYPE_UNKNOWN; } } @@ -337,9 +339,9 @@ void Call::Reset() { mState = nsITelephonyService::CALL_STATE_DISCONNECTED; - mDirection = BTHF_CALL_DIRECTION_OUTGOING; + mDirection = HFP_CALL_DIRECTION_OUTGOING; mNumber.Truncate(); - mType = BTHF_CALL_ADDRTYPE_UNKNOWN; + mType = HFP_CALL_ADDRESS_TYPE_UNKNOWN; } bool @@ -379,8 +381,8 @@ BluetoothHfpManager::Cleanup() mConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED; mPrevConnectionState = BTHF_CONNECTION_STATE_DISCONNECTED; mBattChg = 5; - mService = 0; - mRoam = 0; + mService = HFP_NETWORK_STATE_NOT_AVAILABLE; + mRoam = HFP_SERVICE_TYPE_HOME; mSignal = 0; mController = nullptr; @@ -745,7 +747,7 @@ BluetoothHfpManager::ProcessAtChld(bthf_chld_type_t aChld) BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER, NS_ConvertUTF8toUTF16(message)); - SendResponse(BTHF_AT_RESPONSE_OK); + SendResponse(HFP_AT_RESPONSE_OK); } void BluetoothHfpManager::ProcessDialCall(char *aNumber) @@ -777,7 +779,7 @@ void BluetoothHfpManager::ProcessDialCall(char *aNumber) newMsg += StringHead(message, message.Length() - 1); BT_HF_DISPATCH_MAIN(MainThreadTaskCmd::NOTIFY_DIALER, NS_ConvertUTF8toUTF16(newMsg)); - SendResponse(BTHF_AT_RESPONSE_OK); + SendResponse(HFP_AT_RESPONSE_OK); } } @@ -794,7 +796,7 @@ BluetoothHfpManager::ProcessAtCnum() SendLine(message.get()); } - SendResponse(BTHF_AT_RESPONSE_OK); + SendResponse(HFP_AT_RESPONSE_OK); } class CindResponseResultHandler MOZ_FINAL @@ -815,7 +817,8 @@ BluetoothHfpManager::ProcessAtCind() int numActive = GetNumberOfCalls(nsITelephonyService::CALL_STATE_CONNECTED); int numHeld = GetNumberOfCalls(nsITelephonyService::CALL_STATE_HELD); - bthf_call_state_t callState = ConvertToBthfCallState(GetCallSetupState()); + BluetoothHandsfreeCallState callState = + ConvertToBluetoothHandsfreeCallState(GetCallSetupState()); sBluetoothHfpInterface->CindResponse(mService, numActive, numHeld, callState, mSignal, mRoam, mBattChg, @@ -859,7 +862,7 @@ BluetoothHfpManager::ProcessAtClcc() SendCLCC(mCdmaSecondCall, 2); } - SendResponse(BTHF_AT_RESPONSE_OK); + SendResponse(HFP_AT_RESPONSE_OK); } class AtResponseResultHandler MOZ_FINAL @@ -880,7 +883,7 @@ BluetoothHfpManager::ProcessUnknownAt(char *aAtString) NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface); - sBluetoothHfpInterface->AtResponse(BTHF_AT_RESPONSE_ERROR, 0, + sBluetoothHfpInterface->AtResponse(HFP_AT_RESPONSE_ERROR, 0, new AtResponseResultHandler()); } @@ -1047,7 +1050,7 @@ BluetoothHfpManager::HandleVolumeChanged(const nsAString& aData) // Only send volume back when there's a connected headset if (IsConnected()) { NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface); - sBluetoothHfpInterface->VolumeControl(BTHF_VOLUME_TYPE_SPK, mCurrentVgs, + sBluetoothHfpInterface->VolumeControl(HFP_VOLUME_TYPE_SPEAKER, mCurrentVgs, new VolumeControlResultHandler()); } } @@ -1070,7 +1073,7 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId) // Roam bool roaming; voiceInfo->GetRoaming(&roaming); - mRoam = (roaming) ? 1 : 0; + mRoam = (roaming) ? HFP_SERVICE_TYPE_ROAMING : HFP_SERVICE_TYPE_HOME; // Service nsString regState; @@ -1081,7 +1084,8 @@ BluetoothHfpManager::HandleVoiceConnectionChanged(uint32_t aClientId) // Notify BluetoothRilListener of service change mListener->ServiceChanged(aClientId, service); } - mService = service; + mService = service ? HFP_NETWORK_STATE_AVAILABLE : + HFP_NETWORK_STATE_NOT_AVAILABLE; // Signal JSContext* cx = nsContentUtils::GetSafeJSContext(); @@ -1157,21 +1161,22 @@ BluetoothHfpManager::SendCLCC(Call& aCall, int aIndex) nsITelephonyService::CALL_STATE_DISCONNECTED); NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface); - bthf_call_state_t callState = ConvertToBthfCallState(aCall.mState); + BluetoothHandsfreeCallState callState = + ConvertToBluetoothHandsfreeCallState(aCall.mState); if (mPhoneType == PhoneType::CDMA && aIndex == 1 && aCall.IsActive()) { - callState = (mCdmaSecondCall.IsActive()) ? BTHF_CALL_STATE_HELD : - BTHF_CALL_STATE_ACTIVE; + callState = (mCdmaSecondCall.IsActive()) ? HFP_CALL_STATE_HELD : + HFP_CALL_STATE_ACTIVE; } - if (callState == BTHF_CALL_STATE_INCOMING && + if (callState == HFP_CALL_STATE_INCOMING && FindFirstCall(nsITelephonyService::CALL_STATE_CONNECTED)) { - callState = BTHF_CALL_STATE_WAITING; + callState = HFP_CALL_STATE_WAITING; } sBluetoothHfpInterface->ClccResponse( - aIndex, aCall.mDirection, callState, BTHF_CALL_TYPE_VOICE, - BTHF_CALL_MPTY_TYPE_SINGLE, NS_ConvertUTF16toUTF8(aCall.mNumber).get(), + aIndex, aCall.mDirection, callState, HFP_CALL_MODE_VOICE, + HFP_CALL_MPTY_TYPE_SINGLE, aCall.mNumber, aCall.mType, new ClccResponseResultHandler()); } @@ -1196,7 +1201,7 @@ BluetoothHfpManager::SendLine(const char* aMessage) } void -BluetoothHfpManager::SendResponse(bthf_at_response_t aResponseCode) +BluetoothHfpManager::SendResponse(BluetoothHandsfreeAtResponse aResponseCode) { NS_ENSURE_TRUE_VOID(sBluetoothHfpInterface); @@ -1222,18 +1227,17 @@ BluetoothHfpManager::UpdatePhoneCIND(uint32_t aCallIndex) int numActive = GetNumberOfCalls(nsITelephonyService::CALL_STATE_CONNECTED); int numHeld = GetNumberOfCalls(nsITelephonyService::CALL_STATE_HELD); - bthf_call_state_t callSetupState = - ConvertToBthfCallState(GetCallSetupState()); - nsAutoCString number = - NS_ConvertUTF16toUTF8(mCurrentCallArray[aCallIndex].mNumber); - bthf_call_addrtype_t type = mCurrentCallArray[aCallIndex].mType; + BluetoothHandsfreeCallState callSetupState = + ConvertToBluetoothHandsfreeCallState(GetCallSetupState()); + BluetoothHandsfreeCallAddressType type = mCurrentCallArray[aCallIndex].mType; BT_LOGR("[%d] state %d => BTHF: active[%d] held[%d] setupstate[%d]", aCallIndex, mCurrentCallArray[aCallIndex].mState, numActive, numHeld, callSetupState); sBluetoothHfpInterface->PhoneStateChange( - numActive, numHeld, callSetupState, number.get(), type, + numActive, numHeld, callSetupState, + mCurrentCallArray[aCallIndex].mNumber, type, new PhoneStateChangeResultHandler()); } @@ -1254,8 +1258,8 @@ BluetoothHfpManager::UpdateDeviceCIND() { if (sBluetoothHfpInterface) { sBluetoothHfpInterface->DeviceStatusNotification( - (bthf_network_state_t) mService, - (bthf_service_type_t) mRoam, + mService, + mRoam, mSignal, mBattChg, new DeviceStatusNotificationResultHandler()); } @@ -1309,24 +1313,24 @@ BluetoothHfpManager::GetCallSetupState() return nsITelephonyService::CALL_STATE_DISCONNECTED; } -bthf_call_state_t -BluetoothHfpManager::ConvertToBthfCallState(int aCallState) +BluetoothHandsfreeCallState +BluetoothHfpManager::ConvertToBluetoothHandsfreeCallState(int aCallState) const { - bthf_call_state_t state; + BluetoothHandsfreeCallState state; // Refer to AOSP BluetoothPhoneService.convertCallState if (aCallState == nsITelephonyService::CALL_STATE_INCOMING) { - state = BTHF_CALL_STATE_INCOMING; + state = HFP_CALL_STATE_INCOMING; } else if (aCallState == nsITelephonyService::CALL_STATE_DIALING) { - state = BTHF_CALL_STATE_DIALING; + state = HFP_CALL_STATE_DIALING; } else if (aCallState == nsITelephonyService::CALL_STATE_ALERTING) { - state = BTHF_CALL_STATE_ALERTING; + state = HFP_CALL_STATE_ALERTING; } else if (aCallState == nsITelephonyService::CALL_STATE_CONNECTED) { - state = BTHF_CALL_STATE_ACTIVE; + state = HFP_CALL_STATE_ACTIVE; } else if (aCallState == nsITelephonyService::CALL_STATE_HELD) { - state = BTHF_CALL_STATE_HELD; + state = HFP_CALL_STATE_HELD; } else { // disconnected - state = BTHF_CALL_STATE_IDLE; + state = HFP_CALL_STATE_IDLE; } return state; @@ -1400,7 +1404,7 @@ BluetoothHfpManager::HandleCallStateChanged(uint32_t aCallIndex, case nsITelephonyService::CALL_STATE_DIALING: // We've send Dialer a dialing request and this is the response. if (!mDialingRequestProcessed) { - SendResponse(BTHF_AT_RESPONSE_OK); + SendResponse(HFP_AT_RESPONSE_OK); mDialingRequestProcessed = true; } break; @@ -1513,9 +1517,7 @@ BluetoothHfpManager::ConnectSco() NS_ENSURE_TRUE(IsConnected() && !IsScoConnected(), false); NS_ENSURE_TRUE(sBluetoothHfpInterface, false); - bt_bdaddr_t deviceBdAddress; - StringToBdAddressType(mDeviceAddress, &deviceBdAddress); - sBluetoothHfpInterface->ConnectAudio(&deviceBdAddress, + sBluetoothHfpInterface->ConnectAudio(mDeviceAddress, new ConnectAudioResultHandler()); return true; @@ -1538,9 +1540,7 @@ BluetoothHfpManager::DisconnectSco() NS_ENSURE_TRUE(IsScoConnected(), false); NS_ENSURE_TRUE(sBluetoothHfpInterface, false); - bt_bdaddr_t deviceBdAddress; - StringToBdAddressType(mDeviceAddress, &deviceBdAddress); - sBluetoothHfpInterface->DisconnectAudio(&deviceBdAddress, + sBluetoothHfpInterface->DisconnectAudio(mDeviceAddress, new DisconnectAudioResultHandler()); return true; @@ -1607,13 +1607,10 @@ BluetoothHfpManager::Connect(const nsAString& aDeviceAddress, return; } - bt_bdaddr_t deviceBdAddress; - StringToBdAddressType(aDeviceAddress, &deviceBdAddress); - mDeviceAddress = aDeviceAddress; mController = aController; - sBluetoothHfpInterface->Connect(&deviceBdAddress, + sBluetoothHfpInterface->Connect(mDeviceAddress, new ConnectResultHandler(this)); } @@ -1658,12 +1655,9 @@ BluetoothHfpManager::Disconnect(BluetoothProfileController* aController) return; } - bt_bdaddr_t deviceBdAddress; - StringToBdAddressType(mDeviceAddress, &deviceBdAddress); - mController = aController; - sBluetoothHfpInterface->Disconnect(&deviceBdAddress, + sBluetoothHfpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler(this)); } diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h index 7fe8420ddb8..dc61e85f232 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.h @@ -66,8 +66,8 @@ public: uint16_t mState; nsString mNumber; - bthf_call_direction_t mDirection; // 0: outgoing call; 1: incoming call - bthf_call_addrtype_t mType; + BluetoothHandsfreeCallDirection mDirection; + BluetoothHandsfreeCallAddressType mType; }; class BluetoothHfpManager : public BluetoothHfpManagerBase @@ -153,21 +153,22 @@ private: uint32_t GetNumberOfCalls(uint16_t aState); uint16_t GetCallSetupState(); bool IsTransitionState(uint16_t aCallState, bool aIsConference); - bthf_call_state_t ConvertToBthfCallState(int aCallState); + BluetoothHandsfreeCallState + ConvertToBluetoothHandsfreeCallState(int aCallState) const; void UpdatePhoneCIND(uint32_t aCallIndex); void UpdateDeviceCIND(); void SendCLCC(Call& aCall, int aIndex); void SendLine(const char* aMessage); - void SendResponse(bthf_at_response_t aResponseCode); + void SendResponse(BluetoothHandsfreeAtResponse aResponseCode); int mConnectionState; int mPrevConnectionState; int mAudioState; // Device CIND int mBattChg; - int mService; - int mRoam; + BluetoothHandsfreeNetworkState mService; + BluetoothHandsfreeServiceType mRoam; int mSignal; int mCurrentVgs; From 2537fcb8d5d085509abd35bca6233b290d0f36d3 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:45:14 +0200 Subject: [PATCH 10/49] Bug 1038591: Convert Bluetooth A2DP data types in |BluetoothA2dpInterface|, r=shuang With this patch |BluetoothA2dpInterface| is responsible for converting all Bluetooth data types to Bluedroid types. All callers have been adapted. --- .../bluedroid/BluetoothA2dpManager.cpp | 10 ++------- .../bluedroid/BluetoothInterface.cpp | 22 +++++++++++++++---- dom/bluetooth/bluedroid/BluetoothInterface.h | 4 ++-- 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp index 781b3a5aed9..48ae4010b00 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp @@ -822,10 +822,7 @@ BluetoothA2dpManager::Connect(const nsAString& aDeviceAddress, return; } - bt_bdaddr_t remoteAddress; - StringToBdAddressType(aDeviceAddress, &remoteAddress); - - sBtA2dpInterface->Connect(&remoteAddress, new ConnectResultHandler()); + sBtA2dpInterface->Connect(aDeviceAddress, new ConnectResultHandler()); } void @@ -879,10 +876,7 @@ BluetoothA2dpManager::Disconnect(BluetoothProfileController* aController) return; } - bt_bdaddr_t remoteAddress; - StringToBdAddressType(mDeviceAddress, &remoteAddress); - - sBtA2dpInterface->Disconnect(&remoteAddress, new DisconnectResultHandler()); + sBtA2dpInterface->Disconnect(mDeviceAddress, new DisconnectResultHandler()); } void diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index b4d8e83d7a4..5778265a1f9 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -1371,10 +1371,17 @@ BluetoothA2dpInterface::Cleanup(BluetoothA2dpResultHandler* aRes) } void -BluetoothA2dpInterface::Connect(bt_bdaddr_t *aBdAddr, +BluetoothA2dpInterface::Connect(const nsAString& aBdAddr, BluetoothA2dpResultHandler* aRes) { - bt_status_t status = mInterface->connect(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->connect(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Connect, @@ -1383,10 +1390,17 @@ BluetoothA2dpInterface::Connect(bt_bdaddr_t *aBdAddr, } void -BluetoothA2dpInterface::Disconnect(bt_bdaddr_t *aBdAddr, +BluetoothA2dpInterface::Disconnect(const nsAString& aBdAddr, BluetoothA2dpResultHandler* aRes) { - bt_status_t status = mInterface->disconnect(aBdAddr); + bt_status_t status; + bt_bdaddr_t bdAddr; + + if (NS_SUCCEEDED(Convert(aBdAddr, bdAddr))) { + status = mInterface->disconnect(&bdAddr); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Disconnect, diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 28a4a2e0128..f052b5a1dea 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -216,9 +216,9 @@ public: BluetoothA2dpResultHandler* aRes); void Cleanup(BluetoothA2dpResultHandler* aRes); - void Connect(bt_bdaddr_t *aBdAddr, + void Connect(const nsAString& aBdAddr, BluetoothA2dpResultHandler* aRes); - void Disconnect(bt_bdaddr_t *aBdAddr, + void Disconnect(const nsAString& aBdAddr, BluetoothA2dpResultHandler* aRes); protected: From c0139dd29650c81081f5a6180178adf6917f2e8a Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:45:22 +0200 Subject: [PATCH 11/49] Bug 1038591: Convert Bluetooth AVRCP data types in |BluetoothAvrcpInterface|, r=shuang With this patch |BluetoothAvrcpInterface| is responsible for converting all Bluetooth data types to Bluedroid types. All callers have been adapted. --- dom/bluetooth/BluetoothCommon.h | 43 +++ .../bluedroid/BluetoothA2dpManager.cpp | 148 +++++---- .../bluedroid/BluetoothA2dpManager.h | 8 +- .../bluedroid/BluetoothInterface.cpp | 294 ++++++++++++++++-- dom/bluetooth/bluedroid/BluetoothInterface.h | 26 +- 5 files changed, 421 insertions(+), 98 deletions(-) diff --git a/dom/bluetooth/BluetoothCommon.h b/dom/bluetooth/BluetoothCommon.h index 84eeba2f0ee..424b9909cd0 100644 --- a/dom/bluetooth/BluetoothCommon.h +++ b/dom/bluetooth/BluetoothCommon.h @@ -214,6 +214,49 @@ enum ControlPlayStatus { PLAYSTATUS_ERROR = 0xFF, }; +enum BluetoothAvrcpPlayerAttribute { + AVRCP_PLAYER_ATTRIBUTE_EQUALIZER, + AVRCP_PLAYER_ATTRIBUTE_REPEAT, + AVRCP_PLAYER_ATTRIBUTE_SHUFFLE, + AVRCP_PLAYER_ATTRIBUTE_SCAN +}; + +enum BluetoothAvrcpStatus { + AVRCP_STATUS_BAD_COMMAND, + AVRCP_STATUS_BAD_PARAMETER, + AVRCP_STATUS_NOT_FOUND, + AVRCP_STATUS_INTERNAL_ERROR, + AVRCP_STATUS_SUCCESS +}; + +enum BluetoothAvrcpEvent { + AVRCP_EVENT_PLAY_STATUS_CHANGED, + AVRCP_EVENT_TRACK_CHANGE, + AVRCP_EVENT_TRACK_REACHED_END, + AVRCP_EVENT_TRACK_REACHED_START, + AVRCP_EVENT_PLAY_POS_CHANGED, + AVRCP_EVENT_APP_SETTINGS_CHANGED +}; + +enum BluetoothAvrcpNotification { + AVRCP_NTF_INTERIM, + AVRCP_NTF_CHANGED +}; + +struct BluetoothAvrcpElementAttribute { + uint32_t mId; + nsString mValue; +}; + +struct BluetoothAvrcpNotificationParam { + ControlPlayStatus mPlayStatus; + uint8_t mTrack[8]; + uint32_t mSongPos; + uint8_t mNumAttr; + uint8_t mIds[256]; + uint8_t mValues[256]; +}; + END_BLUETOOTH_NAMESPACE #endif // mozilla_dom_bluetooth_bluetoothcommon_h__ diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp index 48ae4010b00..5809fb66b29 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp @@ -89,8 +89,8 @@ public: class UpdateRegisterNotificationTask : public nsRunnable { public: - UpdateRegisterNotificationTask(btrc_event_id_t aEventId, uint32_t aParam) - : mEventId(aEventId) + UpdateRegisterNotificationTask(BluetoothAvrcpEvent aEvent, uint32_t aParam) + : mEvent(aEvent) , mParam(aParam) { MOZ_ASSERT(!NS_IsMainThread()); @@ -102,11 +102,11 @@ public: BluetoothA2dpManager* a2dp = BluetoothA2dpManager::Get(); NS_ENSURE_TRUE(a2dp, NS_OK); - a2dp->UpdateRegisterNotification(mEventId, mParam); + a2dp->UpdateRegisterNotification(mEvent, mParam); return NS_OK; } private: - btrc_event_id_t mEventId; + BluetoothAvrcpEvent mEvent; uint32_t mParam; }; @@ -149,33 +149,35 @@ ConvertAttributeString(int aAttrId, nsAString& aAttrStr) class UpdateElementAttrsTask : public nsRunnable { public: - UpdateElementAttrsTask(uint8_t aNumAttr, btrc_media_attr_t* aPlayerAttrs) - : mNumAttr(aNumAttr) - , mPlayerAttrs(aPlayerAttrs) + UpdateElementAttrsTask(uint8_t aNumAttr, const btrc_media_attr_t* aPlayerAttrs) + : mNumAttr(aNumAttr) { MOZ_ASSERT(!NS_IsMainThread()); + + mAttrs = new BluetoothAvrcpElementAttribute[mNumAttr]; + + for (uint8_t i = 0; i < mNumAttr; ++i) { + mAttrs[i].mId = aPlayerAttrs[i]; + } } nsresult Run() { MOZ_ASSERT(NS_IsMainThread()); - btrc_element_attr_val_t* attrs = new btrc_element_attr_val_t[mNumAttr]; - for (int i = 0; i < mNumAttr; i++) { - nsAutoString attrText; - attrs[i].attr_id = mPlayerAttrs[i]; - ConvertAttributeString(mPlayerAttrs[i], attrText); - strcpy((char *)attrs[i].text, NS_ConvertUTF16toUTF8(attrText).get()); + for (uint8_t i = 0; i < mNumAttr; ++i) { + ConvertAttributeString(mAttrs[i].mId, mAttrs[i].mValue); } NS_ENSURE_TRUE(sBtAvrcpInterface, NS_OK); - sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, attrs, nullptr); + sBtAvrcpInterface->GetElementAttrRsp(mNumAttr, mAttrs, nullptr); return NS_OK; } + private: uint8_t mNumAttr; - btrc_media_attr_t* mPlayerAttrs; + nsAutoArrayPtr mAttrs; }; class UpdatePassthroughCmdTask : public nsRunnable @@ -342,9 +344,30 @@ AvrcpGetElementAttrCallback(uint8_t aNumAttr, btrc_media_attr_t* aPlayerAttrs) static void AvrcpRegisterNotificationCallback(btrc_event_id_t aEventId, uint32_t aParam) { + BluetoothAvrcpEvent event; + MOZ_ASSERT(!NS_IsMainThread()); - NS_DispatchToMainThread(new UpdateRegisterNotificationTask(aEventId, aParam)); + switch (aEventId) { + case BTRC_EVT_PLAY_STATUS_CHANGED: + event = AVRCP_EVENT_PLAY_STATUS_CHANGED; + case BTRC_EVT_TRACK_CHANGE: + event = AVRCP_EVENT_TRACK_CHANGE; + case BTRC_EVT_TRACK_REACHED_END: + event = AVRCP_EVENT_TRACK_REACHED_END; + case BTRC_EVT_TRACK_REACHED_START: + event = AVRCP_EVENT_TRACK_REACHED_START; + case BTRC_EVT_PLAY_POS_CHANGED: + event = AVRCP_EVENT_PLAY_POS_CHANGED; + case BTRC_EVT_APP_SETTINGS_CHANGED: + event = AVRCP_EVENT_APP_SETTINGS_CHANGED; + break; + default: + BT_LOGR("Unknown event 0x%x", aEventId); + return; + } + + NS_DispatchToMainThread(new UpdateRegisterNotificationTask(event, aParam)); } /* @@ -1097,26 +1120,25 @@ BluetoothA2dpManager::UpdateMetaData(const nsAString& aTitle, // Send track changed and position changed if track num is not the same. // See also AVRCP 1.3 Spec 5.4.2 if (mMediaNumber != aMediaNumber && - mTrackChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) { - btrc_register_notification_t param; + mTrackChangedNotifyType == AVRCP_NTF_INTERIM) { + BluetoothAvrcpNotificationParam param; // convert to network big endian format // since track stores as uint8[8] // 56 = 8 * (BTRC_UID_SIZE -1) for (int i = 0; i < BTRC_UID_SIZE; ++i) { - param.track[i] = (aMediaNumber >> (56 - 8 * i)); + param.mTrack[i] = (aMediaNumber >> (56 - 8 * i)); } - mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED; - sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_TRACK_CHANGE, - BTRC_NOTIFICATION_TYPE_CHANGED, - ¶m, nullptr); - if (mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) { - param.song_pos = mPosition; + mTrackChangedNotifyType = AVRCP_NTF_CHANGED; + sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_TRACK_CHANGE, + AVRCP_NTF_CHANGED, + param, nullptr); + if (mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) { + param.mSongPos = mPosition; // EVENT_PLAYBACK_POS_CHANGED shall be notified if changed current track - mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED; - sBtAvrcpInterface->RegisterNotificationRsp( - BTRC_EVT_PLAY_POS_CHANGED, - BTRC_NOTIFICATION_TYPE_CHANGED, - ¶m, nullptr); + mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED; + sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED, + AVRCP_NTF_CHANGED, + param, nullptr); } } @@ -1143,27 +1165,27 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration, #if ANDROID_VERSION > 17 NS_ENSURE_TRUE_VOID(sBtAvrcpInterface); // always update playstatus first - sBtAvrcpInterface->GetPlayStatusRsp((btrc_play_status_t)aPlayStatus, - aDuration, aPosition, nullptr); + sBtAvrcpInterface->GetPlayStatusRsp(aPlayStatus, aDuration, + aPosition, nullptr); // when play status changed, send both play status and position if (mPlayStatus != aPlayStatus && - mPlayStatusChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) { - btrc_register_notification_t param; - param.play_status = (btrc_play_status_t)aPlayStatus; - mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED; - sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_STATUS_CHANGED, - BTRC_NOTIFICATION_TYPE_CHANGED, - ¶m, nullptr); + mPlayStatusChangedNotifyType == AVRCP_NTF_INTERIM) { + BluetoothAvrcpNotificationParam param; + param.mPlayStatus = aPlayStatus; + mPlayStatusChangedNotifyType = AVRCP_NTF_CHANGED; + sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_STATUS_CHANGED, + AVRCP_NTF_CHANGED, + param, nullptr); } if (mPosition != aPosition && - mPlayPosChangedNotifyType == BTRC_NOTIFICATION_TYPE_INTERIM) { - btrc_register_notification_t param; - param.song_pos = aPosition; - mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_CHANGED; - sBtAvrcpInterface->RegisterNotificationRsp(BTRC_EVT_PLAY_POS_CHANGED, - BTRC_NOTIFICATION_TYPE_CHANGED, - ¶m, nullptr); + mPlayPosChangedNotifyType == AVRCP_NTF_INTERIM) { + BluetoothAvrcpNotificationParam param; + param.mSongPos = aPosition; + mPlayPosChangedNotifyType = AVRCP_NTF_CHANGED; + sBtAvrcpInterface->RegisterNotificationRsp(AVRCP_EVENT_PLAY_POS_CHANGED, + AVRCP_NTF_CHANGED, + param, nullptr); } mDuration = aDuration; @@ -1180,21 +1202,22 @@ BluetoothA2dpManager::UpdatePlayStatus(uint32_t aDuration, * aParam is only valid when position changed */ void -BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam) +BluetoothA2dpManager::UpdateRegisterNotification(BluetoothAvrcpEvent aEvent, + uint32_t aParam) { MOZ_ASSERT(NS_IsMainThread()); #if ANDROID_VERSION > 17 NS_ENSURE_TRUE_VOID(sBtAvrcpInterface); - btrc_register_notification_t param; + BluetoothAvrcpNotificationParam param; - switch (aEventId) { - case BTRC_EVT_PLAY_STATUS_CHANGED: - mPlayStatusChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM; - param.play_status = (btrc_play_status_t)mPlayStatus; + switch (aEvent) { + case AVRCP_EVENT_PLAY_STATUS_CHANGED: + mPlayStatusChangedNotifyType = AVRCP_NTF_INTERIM; + param.mPlayStatus = mPlayStatus; break; - case BTRC_EVT_TRACK_CHANGE: + case AVRCP_EVENT_TRACK_CHANGE: // In AVRCP 1.3 and 1.4, the identifier parameter of EVENT_TRACK_CHANGED // is different. // AVRCP 1.4: If no track is selected, we shall return 0xFFFFFFFFFFFFFFFF, @@ -1202,26 +1225,26 @@ BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam) // version 1.4 is to allow for new UID feature. As for AVRCP 1.3, we shall // return 0xFFFFFFFF. Since PTS enforces to check this part to comply with // the most updated spec. - mTrackChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM; + mTrackChangedNotifyType = AVRCP_NTF_INTERIM; // needs to convert to network big endian format since track stores // as uint8[8]. 56 = 8 * (BTRC_UID_SIZE -1). for (int index = 0; index < BTRC_UID_SIZE; ++index) { // We cannot easily check if a track is selected, so whenever A2DP is // streaming, we assume a track is selected. if (mSinkState == BluetoothA2dpManager::SinkState::SINK_PLAYING) { - param.track[index] = 0x0; + param.mTrack[index] = 0x0; } else { - param.track[index] = 0xFF; + param.mTrack[index] = 0xFF; } } break; - case BTRC_EVT_PLAY_POS_CHANGED: + case AVRCP_EVENT_PLAY_POS_CHANGED: // If no track is selected, return 0xFFFFFFFF in the INTERIM response - mPlayPosChangedNotifyType = BTRC_NOTIFICATION_TYPE_INTERIM; + mPlayPosChangedNotifyType = AVRCP_NTF_INTERIM; if (mSinkState == BluetoothA2dpManager::SinkState::SINK_PLAYING) { - param.song_pos = mPosition; + param.mSongPos = mPosition; } else { - param.song_pos = 0xFFFFFFFF; + param.mSongPos = 0xFFFFFFFF; } mPlaybackInterval = aParam; break; @@ -1229,9 +1252,8 @@ BluetoothA2dpManager::UpdateRegisterNotification(int aEventId, int aParam) break; } - sBtAvrcpInterface->RegisterNotificationRsp((btrc_event_id_t)aEventId, - BTRC_NOTIFICATION_TYPE_INTERIM, - ¶m, nullptr); + sBtAvrcpInterface->RegisterNotificationRsp(aEvent, AVRCP_NTF_INTERIM, + param, nullptr); #endif } diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h index 52490e3f418..b37decab42a 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.h +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.h @@ -52,7 +52,7 @@ public: void UpdatePlayStatus(uint32_t aDuration, uint32_t aPosition, ControlPlayStatus aPlayStatus); - void UpdateRegisterNotification(int aEventId, int aParam); + void UpdateRegisterNotification(BluetoothAvrcpEvent aEvent, uint32_t aParam); void GetAlbum(nsAString& aAlbum); uint32_t GetDuration(); ControlPlayStatus GetPlayStatus(); @@ -105,9 +105,9 @@ private: * mPlayPosChangedNotifType represents current RegisterNotification * notification type. */ - int mPlayStatusChangedNotifyType; - int mTrackChangedNotifyType; - int mPlayPosChangedNotifyType; + BluetoothAvrcpNotification mPlayStatusChangedNotifyType; + BluetoothAvrcpNotification mTrackChangedNotifyType; + BluetoothAvrcpNotification mPlayPosChangedNotifyType; }; END_BLUETOOTH_NAMESPACE diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index 5778265a1f9..a9356bd0887 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -355,6 +355,153 @@ Convert(BluetoothHandsfreeVolumeType aIn, bthf_volume_type_t& aOut) return NS_OK; } +#if ANDROID_VERSION >= 18 +static nsresult +Convert(ControlPlayStatus aIn, btrc_play_status_t& aOut) +{ + static const btrc_play_status_t sPlayStatus[] = { + [PLAYSTATUS_STOPPED] = BTRC_PLAYSTATE_STOPPED, + [PLAYSTATUS_PLAYING] = BTRC_PLAYSTATE_PLAYING, + [PLAYSTATUS_PAUSED] = BTRC_PLAYSTATE_PAUSED, + [PLAYSTATUS_FWD_SEEK] = BTRC_PLAYSTATE_FWD_SEEK, + [PLAYSTATUS_REV_SEEK] = BTRC_PLAYSTATE_REV_SEEK + }; + if (aIn >= MOZ_ARRAY_LENGTH(sPlayStatus)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sPlayStatus[aIn]; + return NS_OK; +} + +static nsresult +Convert(enum BluetoothAvrcpPlayerAttribute aIn, btrc_player_attr_t& aOut) +{ + static const btrc_player_attr_t sPlayerAttr[] = { + [AVRCP_PLAYER_ATTRIBUTE_EQUALIZER] = BTRC_PLAYER_ATTR_EQUALIZER, + [AVRCP_PLAYER_ATTRIBUTE_REPEAT] = BTRC_PLAYER_ATTR_REPEAT, + [AVRCP_PLAYER_ATTRIBUTE_SHUFFLE] = BTRC_PLAYER_ATTR_SHUFFLE, + [AVRCP_PLAYER_ATTRIBUTE_SCAN] = BTRC_PLAYER_ATTR_SCAN + }; + if (aIn >= MOZ_ARRAY_LENGTH(sPlayerAttr)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sPlayerAttr[aIn]; + return NS_OK; +} + +static nsresult +Convert(enum BluetoothAvrcpStatus aIn, btrc_status_t& aOut) +{ + static const btrc_status_t sStatus[] = { + [AVRCP_STATUS_BAD_COMMAND] = BTRC_STS_BAD_CMD, + [AVRCP_STATUS_BAD_PARAMETER] = BTRC_STS_BAD_PARAM, + [AVRCP_STATUS_NOT_FOUND] = BTRC_STS_NOT_FOUND, + [AVRCP_STATUS_INTERNAL_ERROR] = BTRC_STS_INTERNAL_ERR, + [AVRCP_STATUS_SUCCESS] = BTRC_STS_NO_ERROR + }; + if (aIn >= MOZ_ARRAY_LENGTH(sStatus)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sStatus[aIn]; + return NS_OK; +} + +static nsresult +Convert(enum BluetoothAvrcpEvent aIn, btrc_event_id_t& aOut) +{ + static const btrc_event_id_t sEventId[] = { + [AVRCP_EVENT_PLAY_STATUS_CHANGED] = BTRC_EVT_PLAY_STATUS_CHANGED, + [AVRCP_EVENT_TRACK_CHANGE] = BTRC_EVT_TRACK_CHANGE, + [AVRCP_EVENT_TRACK_REACHED_END] = BTRC_EVT_TRACK_REACHED_END, + [AVRCP_EVENT_TRACK_REACHED_START] = BTRC_EVT_TRACK_REACHED_START, + [AVRCP_EVENT_PLAY_POS_CHANGED] = BTRC_EVT_PLAY_POS_CHANGED, + [AVRCP_EVENT_APP_SETTINGS_CHANGED] = BTRC_EVT_APP_SETTINGS_CHANGED + }; + if (aIn >= MOZ_ARRAY_LENGTH(sEventId)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sEventId[aIn]; + return NS_OK; +} + +static nsresult +Convert(enum BluetoothAvrcpNotification aIn, btrc_notification_type_t& aOut) +{ + static const btrc_notification_type_t sNotificationType[] = { + [AVRCP_NTF_INTERIM] = BTRC_NOTIFICATION_TYPE_INTERIM, + [AVRCP_NTF_CHANGED] = BTRC_NOTIFICATION_TYPE_CHANGED + }; + if (aIn >= MOZ_ARRAY_LENGTH(sNotificationType)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sNotificationType[aIn]; + return NS_OK; +} + +static nsresult +Convert(const BluetoothAvrcpElementAttribute& aIn, btrc_element_attr_val_t& aOut) +{ + const NS_ConvertUTF16toUTF8 value(aIn.mValue); + size_t len = std::min(strlen(value.get()), sizeof(aOut.text) - 1); + + memcpy(aOut.text, value.get(), len); + aOut.text[len] = '\0'; + aOut.attr_id = aIn.mId; + + return NS_OK; +} + +#endif + +/* |ConvertArray| is a helper for converting arrays. Pass an + * instance of this structure as the first argument to |Convert| + * to convert an array. The output type has to support the array + * subscript operator. + */ +template +struct ConvertArray +{ + ConvertArray(const T* aData, unsigned long aLength) + : mData(aData) + , mLength(aLength) + { } + + const T* mData; + unsigned long mLength; +}; + +/* This implementation of |Convert| converts the elements of an + * array one-by-one. The result data structures must have enough + * memory allocated. + */ +template +static nsresult +Convert(const ConvertArray& aIn, Tout& aOut) +{ + for (unsigned long i = 0; i < aIn.mLength; ++i) { + nsresult rv = Convert(aIn.mData[i], aOut[i]); + if (NS_FAILED(rv)) { + return rv; + } + } + return NS_OK; +} + +/* This implementation of |Convert| is a helper that automatically + * allocates enough memory to hold the conversion results. The + * actual conversion is performed by the array-conversion helper + * above. + */ +template +static nsresult +Convert(const ConvertArray& aIn, nsAutoArrayPtr& aOut) +{ + aOut = new Tout[aIn.mLength]; + Tout* out = aOut.get(); + + return Convert(aIn, out); +} + // // Result handling // @@ -1490,12 +1637,19 @@ BluetoothAvrcpInterface::Cleanup(BluetoothAvrcpResultHandler* aRes) } void -BluetoothAvrcpInterface::GetPlayStatusRsp(btrc_play_status_t aPlayStatus, +BluetoothAvrcpInterface::GetPlayStatusRsp(ControlPlayStatus aPlayStatus, uint32_t aSongLen, uint32_t aSongPos, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->get_play_status_rsp(aPlayStatus, aSongLen, - aSongPos); + bt_status_t status; + btrc_play_status_t playStatus = BTRC_PLAYSTATE_STOPPED; + + if (!(NS_FAILED(Convert(aPlayStatus, playStatus)))) { + status = mInterface->get_play_status_rsp(playStatus, aSongLen, aSongPos); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothAvrcpResult( aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp, status); @@ -1504,10 +1658,18 @@ BluetoothAvrcpInterface::GetPlayStatusRsp(btrc_play_status_t aPlayStatus, void BluetoothAvrcpInterface::ListPlayerAppAttrRsp( - int aNumAttr, btrc_player_attr_t* aPAttrs, + int aNumAttr, const BluetoothAvrcpPlayerAttribute* aPAttrs, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->list_player_app_attr_rsp(aNumAttr, aPAttrs); + bt_status_t status; + ConvertArray pAttrsArray(aPAttrs, aNumAttr); + nsAutoArrayPtr pAttrs; + + if (NS_SUCCEEDED(Convert(pAttrsArray, pAttrs))) { + status = mInterface->list_player_app_attr_rsp(aNumAttr, pAttrs); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothAvrcpResult( @@ -1529,9 +1691,20 @@ BluetoothAvrcpInterface::ListPlayerAppValueRsp( void BluetoothAvrcpInterface::GetPlayerAppValueRsp( - btrc_player_settings_t* aPVals, BluetoothAvrcpResultHandler* aRes) + uint8_t aNumAttrs, const uint8_t* aIds, const uint8_t* aValues, + BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->get_player_app_value_rsp(aPVals); + bt_status_t status; + btrc_player_settings_t pVals; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (false /* TODO: we don't support any player app values currently */) { + status = mInterface->get_player_app_value_rsp(&pVals); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothAvrcpResult( @@ -1541,11 +1714,21 @@ BluetoothAvrcpInterface::GetPlayerAppValueRsp( void BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp( - int aNumAttr, btrc_player_setting_text_t* aPAttrs, + int aNumAttr, const uint8_t* aIds, const char** aTexts, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->get_player_app_attr_text_rsp(aNumAttr, - aPAttrs); + bt_status_t status; + btrc_player_setting_text_t* aPAttrs; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (false /* TODO: we don't support any attributes currently */) { + status = mInterface->get_player_app_attr_text_rsp(aNumAttr, aPAttrs); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothAvrcpResult( aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp, status); @@ -1554,11 +1737,21 @@ BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp( void BluetoothAvrcpInterface::GetPlayerAppValueTextRsp( - int aNumVal, btrc_player_setting_text_t* aPVals, + int aNumVal, const uint8_t* aIds, const char** aTexts, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->get_player_app_value_text_rsp(aNumVal, - aPVals); + bt_status_t status; + btrc_player_setting_text_t* pVals; + + /* FIXME: you need to implement the missing conversion functions */ + NS_NOTREACHED("Conversion function missing"); + + if (false /* TODO: we don't support any values currently */) { + status = mInterface->get_player_app_value_text_rsp(aNumVal, pVals); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothAvrcpResult( aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp, status); @@ -1567,10 +1760,18 @@ BluetoothAvrcpInterface::GetPlayerAppValueTextRsp( void BluetoothAvrcpInterface::GetElementAttrRsp( - uint8_t aNumAttr, btrc_element_attr_val_t* aPAttrs, + uint8_t aNumAttr, const BluetoothAvrcpElementAttribute* aAttrs, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->get_element_attr_rsp(aNumAttr, aPAttrs); + bt_status_t status; + ConvertArray pAttrsArray(aAttrs, aNumAttr); + nsAutoArrayPtr pAttrs; + + if (NS_SUCCEEDED(Convert(pAttrsArray, pAttrs))) { + status = mInterface->get_element_attr_rsp(aNumAttr, pAttrs); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothAvrcpResult( @@ -1580,9 +1781,16 @@ BluetoothAvrcpInterface::GetElementAttrRsp( void BluetoothAvrcpInterface::SetPlayerAppValueRsp( - btrc_status_t aRspStatus, BluetoothAvrcpResultHandler* aRes) + BluetoothAvrcpStatus aRspStatus, BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->set_player_app_value_rsp(aRspStatus); + bt_status_t status; + btrc_status_t rspStatus = BTRC_STS_BAD_CMD; // silences compiler warning + + if (NS_SUCCEEDED(Convert(aRspStatus, rspStatus))) { + status = mInterface->set_player_app_value_rsp(rspStatus); + } else { + status = BT_STATUS_PARM_INVALID; + } if (aRes) { DispatchBluetoothAvrcpResult( @@ -1592,11 +1800,55 @@ BluetoothAvrcpInterface::SetPlayerAppValueRsp( void BluetoothAvrcpInterface::RegisterNotificationRsp( - btrc_event_id_t aEventId, btrc_notification_type_t aType, - btrc_register_notification_t* aPParam, BluetoothAvrcpResultHandler* aRes) + BluetoothAvrcpEvent aEvent, BluetoothAvrcpNotification aType, + const BluetoothAvrcpNotificationParam& aParam, + BluetoothAvrcpResultHandler* aRes) { - bt_status_t status = mInterface->register_notification_rsp(aEventId, aType, - aPParam); + nsresult rv; + bt_status_t status; + btrc_event_id_t event = { }; + btrc_notification_type_t type = BTRC_NOTIFICATION_TYPE_INTERIM; + btrc_register_notification_t param; + + switch (aEvent) { + case AVRCP_EVENT_PLAY_STATUS_CHANGED: + rv = Convert(aParam.mPlayStatus, param.play_status); + break; + case AVRCP_EVENT_TRACK_CHANGE: + MOZ_ASSERT(sizeof(aParam.mTrack) == sizeof(param.track)); + memcpy(param.track, aParam.mTrack, sizeof(param.track)); + rv = NS_OK; + break; + case AVRCP_EVENT_TRACK_REACHED_END: + NS_NOTREACHED("Unknown conversion"); + rv = NS_ERROR_ILLEGAL_VALUE; + break; + case AVRCP_EVENT_TRACK_REACHED_START: + NS_NOTREACHED("Unknown conversion"); + rv = NS_ERROR_ILLEGAL_VALUE; + break; + case AVRCP_EVENT_PLAY_POS_CHANGED: + param.song_pos = aParam.mSongPos; + rv = NS_OK; + break; + case AVRCP_EVENT_APP_SETTINGS_CHANGED: + NS_NOTREACHED("Unknown conversion"); + rv = NS_ERROR_ILLEGAL_VALUE; + break; + default: + NS_NOTREACHED("Unknown conversion"); + rv = NS_ERROR_ILLEGAL_VALUE; + break; + } + + if (NS_SUCCEEDED(rv) && + NS_SUCCEEDED(Convert(aEvent, event)) && + NS_SUCCEEDED(Convert(aType, type))) { + status = mInterface->register_notification_rsp(event, type, ¶m); + } else { + status = BT_STATUS_PARM_INVALID; + } + if (aRes) { DispatchBluetoothAvrcpResult( aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp, status); diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index f052b5a1dea..58f5e3c862a 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -276,33 +276,39 @@ public: BluetoothAvrcpResultHandler* aRes); void Cleanup(BluetoothAvrcpResultHandler* aRes); - void GetPlayStatusRsp(btrc_play_status_t aPlayStatus, + void GetPlayStatusRsp(ControlPlayStatus aPlayStatus, uint32_t aSongLen, uint32_t aSongPos, BluetoothAvrcpResultHandler* aRes); - void ListPlayerAppAttrRsp(int aNumAttr, btrc_player_attr_t* aPAttrs, + void ListPlayerAppAttrRsp(int aNumAttr, + const BluetoothAvrcpPlayerAttribute* aPAttrs, BluetoothAvrcpResultHandler* aRes); void ListPlayerAppValueRsp(int aNumVal, uint8_t* aPVals, BluetoothAvrcpResultHandler* aRes); - void GetPlayerAppValueRsp(btrc_player_settings_t* aPVals, + /* TODO: redesign this interface once we actually use it */ + void GetPlayerAppValueRsp(uint8_t aNumAttrs, + const uint8_t* aIds, const uint8_t* aValues, BluetoothAvrcpResultHandler* aRes); + /* TODO: redesign this interface once we actually use it */ void GetPlayerAppAttrTextRsp(int aNumAttr, - btrc_player_setting_text_t* aPAttrs, + const uint8_t* aIds, const char** aTexts, BluetoothAvrcpResultHandler* aRes); + /* TODO: redesign this interface once we actually use it */ void GetPlayerAppValueTextRsp(int aNumVal, - btrc_player_setting_text_t* aPVals, + const uint8_t* aIds, const char** aTexts, BluetoothAvrcpResultHandler* aRes); - void GetElementAttrRsp(uint8_t aNumAttr, btrc_element_attr_val_t* aPAttrs, + void GetElementAttrRsp(uint8_t aNumAttr, + const BluetoothAvrcpElementAttribute* aAttr, BluetoothAvrcpResultHandler* aRes); - void SetPlayerAppValueRsp(btrc_status_t aRspStatus, + void SetPlayerAppValueRsp(BluetoothAvrcpStatus aRspStatus, BluetoothAvrcpResultHandler* aRes); - void RegisterNotificationRsp(btrc_event_id_t aEventId, - btrc_notification_type_t aType, - btrc_register_notification_t* aPParam, + void RegisterNotificationRsp(BluetoothAvrcpEvent aEvent, + BluetoothAvrcpNotification aType, + const BluetoothAvrcpNotificationParam& aParam, BluetoothAvrcpResultHandler* aRes); void SetVolume(uint8_t aVolume, BluetoothAvrcpResultHandler* aRes); From 4c49c527b7da7a5d78d2e967fa62468c09378500 Mon Sep 17 00:00:00 2001 From: Thomas Zimmermann Date: Wed, 6 Aug 2014 11:45:32 +0200 Subject: [PATCH 12/49] Bug 1038591: Convert Bluedroid status codes and error handlers, r=shuang This patch converts Bluedroid status codes in Gecko to the backend-neutral data type |BluetoothStatus|. All error handlers have been adapted. The Bluedroid type |bt_status_t| only remains in |BluetoothInterface|. --- dom/bluetooth/BluetoothCommon.h | 14 + .../bluedroid/BluetoothA2dpManager.cpp | 12 +- .../bluedroid/BluetoothInterface.cpp | 243 +++++++++++------- dom/bluetooth/bluedroid/BluetoothInterface.h | 18 +- .../bluedroid/BluetoothServiceBluedroid.cpp | 38 +-- dom/bluetooth/bluedroid/BluetoothSocket.cpp | 6 +- .../bluedroid/hfp/BluetoothHfpManager.cpp | 28 +- 7 files changed, 222 insertions(+), 137 deletions(-) diff --git a/dom/bluetooth/BluetoothCommon.h b/dom/bluetooth/BluetoothCommon.h index 424b9909cd0..85825f16302 100644 --- a/dom/bluetooth/BluetoothCommon.h +++ b/dom/bluetooth/BluetoothCommon.h @@ -132,6 +132,20 @@ extern bool gBluetoothDebugFlag; BEGIN_BLUETOOTH_NAMESPACE +enum BluetoothStatus { + STATUS_SUCCESS, + STATUS_FAIL, + STATUS_NOT_READY, + STATUS_NOMEM, + STATUS_BUSY, + STATUS_DONE, + STATUS_UNSUPPORTED, + STATUS_PARM_INVALID, + STATUS_UNHANDLED, + STATUS_AUTH_FAILURE, + STATUS_RMT_DEV_DOWN +}; + enum BluetoothSocketType { RFCOMM = 1, SCO = 2, diff --git a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp index 5809fb66b29..88227438623 100644 --- a/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp +++ b/dom/bluetooth/bluedroid/BluetoothA2dpManager.cpp @@ -523,7 +523,7 @@ public: : mRes(aRes) { } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothAvrcpInterface::Init failed: %d", (int)aStatus); @@ -551,7 +551,7 @@ public: : mRes(aRes) { } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothA2dpInterface::Init failed: %d", (int)aStatus); @@ -682,7 +682,7 @@ public: : mRes(aRes) { } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothAvrcpInterface::Cleanup failed: %d", (int)aStatus); @@ -711,7 +711,7 @@ public: : mRes(aRes) { } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothA2dpInterface::Cleanup failed: %d", (int)aStatus); @@ -808,7 +808,7 @@ BluetoothA2dpManager::OnConnectError() class ConnectResultHandler MOZ_FINAL : public BluetoothA2dpResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_LOGR("BluetoothA2dpInterface::Connect failed: %d", (int)aStatus); @@ -859,7 +859,7 @@ BluetoothA2dpManager::OnDisconnectError() class DisconnectResultHandler MOZ_FINAL : public BluetoothA2dpResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_LOGR("BluetoothA2dpInterface::Disconnect failed: %d", (int)aStatus); diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.cpp b/dom/bluetooth/bluedroid/BluetoothInterface.cpp index a9356bd0887..d338263ddd5 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.cpp +++ b/dom/bluetooth/bluedroid/BluetoothInterface.cpp @@ -23,6 +23,35 @@ struct interface_traits // Conversion // +static nsresult +Convert(bt_status_t aIn, BluetoothStatus& aOut) +{ + static const BluetoothStatus sStatus[] = { + [BT_STATUS_SUCCESS] = STATUS_SUCCESS, + [BT_STATUS_FAIL] = STATUS_FAIL, + [BT_STATUS_NOT_READY] = STATUS_NOT_READY, + [BT_STATUS_NOMEM] = STATUS_NOMEM, + [BT_STATUS_BUSY] = STATUS_BUSY, + [BT_STATUS_DONE] = STATUS_DONE, + [BT_STATUS_UNSUPPORTED] = STATUS_UNSUPPORTED, + [BT_STATUS_PARM_INVALID] = STATUS_PARM_INVALID, + [BT_STATUS_UNHANDLED] = STATUS_UNHANDLED, + [BT_STATUS_AUTH_FAILURE] = STATUS_AUTH_FAILURE, + [BT_STATUS_RMT_DEV_DOWN] = STATUS_RMT_DEV_DOWN + }; + if (aIn >= MOZ_ARRAY_LENGTH(sStatus)) { + return NS_ERROR_ILLEGAL_VALUE; + } + aOut = sStatus[aIn]; + return NS_OK; +} + +static nsresult +Convert(int aIn, BluetoothStatus& aOut) +{ + return Convert(static_cast(aIn), aOut); +} + static nsresult Convert(const nsAString& aIn, bt_property_type_t& aOut) { @@ -502,6 +531,20 @@ Convert(const ConvertArray& aIn, nsAutoArrayPtr& aOut) return Convert(aIn, out); } +/* |ConvertDefault| is a helper function to return the result of a + * conversion or a default value if the conversion fails. + */ +template +static Tout +ConvertDefault(const Tin& aIn, const Tout& aDefault) +{ + Tout out = aDefault; // assignment silences compiler warning + if (NS_FAILED(Convert(aIn, out))) { + return aDefault; + } + return out; +} + // // Result handling // @@ -619,19 +662,19 @@ typedef typedef BluetoothInterfaceRunnable1 + BluetoothStatus, BluetoothStatus> BluetoothSocketErrorRunnable; static nsresult DispatchBluetoothSocketResult(BluetoothSocketResultHandler* aRes, void (BluetoothSocketResultHandler::*aMethod)(int), - int aArg, bt_status_t aStatus) + int aArg, BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothSocketIntResultRunnable(aRes, aMethod, aArg); } else { runnable = new BluetoothSocketErrorRunnable(aRes, @@ -648,13 +691,13 @@ static nsresult DispatchBluetoothSocketResult( BluetoothSocketResultHandler* aRes, void (BluetoothSocketResultHandler::*aMethod)(int, const nsAString&, int), - int aArg1, const nsAString& aArg2, int aArg3, bt_status_t aStatus) + int aArg1, const nsAString& aArg2, int aArg3, BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothSocketIntStringIntResultRunnable(aRes, aMethod, aArg1, aArg2, aArg3); @@ -692,7 +735,7 @@ BluetoothSocketInterface::Listen(BluetoothSocketType aType, if (aRes) { DispatchBluetoothSocketResult(aRes, &BluetoothSocketResultHandler::Listen, - fd, status); + fd, ConvertDefault(status, STATUS_FAIL)); } } @@ -735,11 +778,11 @@ public: virtual ~SocketMessageWatcher() { } - virtual void Proceed(bt_status_t aStatus) = 0; + virtual void Proceed(BluetoothStatus aStatus) = 0; void OnFileCanReadWithoutBlocking(int aFd) MOZ_OVERRIDE { - bt_status_t status; + BluetoothStatus status; switch (mLen) { case 0: @@ -750,11 +793,11 @@ public: break; default: /* message-size error */ - status = BT_STATUS_FAIL; + status = STATUS_FAIL; break; } - if (IsComplete() || status != BT_STATUS_SUCCESS) { + if (IsComplete() || status != STATUS_SUCCESS) { mWatcher.StopWatchingFileDescriptor(); Proceed(status); } @@ -816,7 +859,7 @@ public: } private: - bt_status_t RecvMsg1() + BluetoothStatus RecvMsg1() { struct iovec iv; memset(&iv, 0, sizeof(iv)); @@ -830,15 +873,15 @@ private: ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL)); if (res < 0) { - return BT_STATUS_FAIL; + return STATUS_FAIL; } mLen += res; - return BT_STATUS_SUCCESS; + return STATUS_SUCCESS; } - bt_status_t RecvMsg2() + BluetoothStatus RecvMsg2() { struct iovec iv; memset(&iv, 0, sizeof(iv)); @@ -855,13 +898,13 @@ private: ssize_t res = TEMP_FAILURE_RETRY(recvmsg(mFd, &msg, MSG_NOSIGNAL)); if (res < 0) { - return BT_STATUS_FAIL; + return STATUS_FAIL; } mLen += res; if (msg.msg_flags & (MSG_CTRUNC | MSG_OOB | MSG_ERRQUEUE)) { - return BT_STATUS_FAIL; + return STATUS_FAIL; } struct cmsghdr *cmsgptr = CMSG_FIRSTHDR(&msg); @@ -879,7 +922,7 @@ private: } } - return BT_STATUS_SUCCESS; + return STATUS_SUCCESS; } int16_t ReadInt16(unsigned long aOffset) const @@ -968,7 +1011,7 @@ public: , mRes(aRes) { } - void Proceed(bt_status_t aStatus) MOZ_OVERRIDE + void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE { if (mRes) { DispatchBluetoothSocketResult(mRes, @@ -1012,7 +1055,8 @@ BluetoothSocketInterface::Connect(const nsAString& aBdAddr, } else if (aRes) { DispatchBluetoothSocketResult(aRes, &BluetoothSocketResultHandler::Connect, - -1, EmptyString(), 0, status); + -1, EmptyString(), 0, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1034,7 +1078,7 @@ public: MOZ_ASSERT(mRes); } - void Proceed(bt_status_t aStatus) MOZ_OVERRIDE + void Proceed(BluetoothStatus aStatus) MOZ_OVERRIDE { if (mRes) { DispatchBluetoothSocketResult(mRes, @@ -1090,20 +1134,20 @@ typedef typedef BluetoothInterfaceRunnable1 + BluetoothStatus, BluetoothStatus> BluetoothHandsfreeErrorRunnable; static nsresult DispatchBluetoothHandsfreeResult( BluetoothHandsfreeResultHandler* aRes, void (BluetoothHandsfreeResultHandler::*aMethod)(), - bt_status_t aStatus) + BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothHandsfreeResultRunnable(aRes, aMethod); } else { runnable = new BluetoothHandsfreeErrorRunnable(aRes, @@ -1135,7 +1179,7 @@ BluetoothHandsfreeInterface::Init(bthf_callbacks_t* aCallbacks, if (aRes) { DispatchBluetoothHandsfreeResult(aRes, &BluetoothHandsfreeResultHandler::Init, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1147,7 +1191,7 @@ BluetoothHandsfreeInterface::Cleanup(BluetoothHandsfreeResultHandler* aRes) if (aRes) { DispatchBluetoothHandsfreeResult(aRes, &BluetoothHandsfreeResultHandler::Cleanup, - BT_STATUS_SUCCESS); + STATUS_SUCCESS); } } @@ -1168,7 +1212,8 @@ BluetoothHandsfreeInterface::Connect(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::Connect, status); + aRes, &BluetoothHandsfreeResultHandler::Connect, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1187,7 +1232,8 @@ BluetoothHandsfreeInterface::Disconnect( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::Disconnect, status); + aRes, &BluetoothHandsfreeResultHandler::Disconnect, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1206,7 +1252,8 @@ BluetoothHandsfreeInterface::ConnectAudio( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::ConnectAudio, status); + aRes, &BluetoothHandsfreeResultHandler::ConnectAudio, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1225,7 +1272,8 @@ BluetoothHandsfreeInterface::DisconnectAudio( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::DisconnectAudio, status); + aRes, &BluetoothHandsfreeResultHandler::DisconnectAudio, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1239,7 +1287,8 @@ BluetoothHandsfreeInterface::StartVoiceRecognition( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::StartVoiceRecognition, status); + aRes, &BluetoothHandsfreeResultHandler::StartVoiceRecognition, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1251,7 +1300,8 @@ BluetoothHandsfreeInterface::StopVoiceRecognition( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::StopVoiceRecognition, status); + aRes, &BluetoothHandsfreeResultHandler::StopVoiceRecognition, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1273,7 +1323,8 @@ BluetoothHandsfreeInterface::VolumeControl( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::VolumeControl, status); + aRes, &BluetoothHandsfreeResultHandler::VolumeControl, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1300,7 +1351,7 @@ BluetoothHandsfreeInterface::DeviceStatusNotification( if (aRes) { DispatchBluetoothHandsfreeResult( aRes, &BluetoothHandsfreeResultHandler::DeviceStatusNotification, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1314,7 +1365,8 @@ BluetoothHandsfreeInterface::CopsResponse( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::CopsResponse, status); + aRes, &BluetoothHandsfreeResultHandler::CopsResponse, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1338,7 +1390,8 @@ BluetoothHandsfreeInterface::CindResponse( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::CindResponse, status); + aRes, &BluetoothHandsfreeResultHandler::CindResponse, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1350,7 +1403,8 @@ BluetoothHandsfreeInterface::FormattedAtResponse( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::FormattedAtResponse, status); + aRes, &BluetoothHandsfreeResultHandler::FormattedAtResponse, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1370,7 +1424,8 @@ BluetoothHandsfreeInterface::AtResponse( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::AtResponse, status); + aRes, &BluetoothHandsfreeResultHandler::AtResponse, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1406,7 +1461,8 @@ BluetoothHandsfreeInterface::ClccResponse( if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::ClccResponse, status); + aRes, &BluetoothHandsfreeResultHandler::ClccResponse, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1433,7 +1489,8 @@ BluetoothHandsfreeInterface::PhoneStateChange(int aNumActive, int aNumHeld, if (aRes) { DispatchBluetoothHandsfreeResult( - aRes, &BluetoothHandsfreeResultHandler::PhoneStateChange, status); + aRes, &BluetoothHandsfreeResultHandler::PhoneStateChange, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1458,20 +1515,20 @@ typedef typedef BluetoothInterfaceRunnable1 + BluetoothStatus, BluetoothStatus> BluetoothA2dpErrorRunnable; static nsresult DispatchBluetoothA2dpResult( BluetoothA2dpResultHandler* aRes, void (BluetoothA2dpResultHandler::*aMethod)(), - bt_status_t aStatus) + BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothA2dpResultRunnable(aRes, aMethod); } else { runnable = new BluetoothA2dpErrorRunnable(aRes, @@ -1502,7 +1559,7 @@ BluetoothA2dpInterface::Init(btav_callbacks_t* aCallbacks, if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Init, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1513,7 +1570,7 @@ BluetoothA2dpInterface::Cleanup(BluetoothA2dpResultHandler* aRes) if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Cleanup, - BT_STATUS_SUCCESS); + STATUS_SUCCESS); } } @@ -1532,7 +1589,7 @@ BluetoothA2dpInterface::Connect(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Connect, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1551,7 +1608,7 @@ BluetoothA2dpInterface::Disconnect(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothA2dpResult(aRes, &BluetoothA2dpResultHandler::Disconnect, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1577,20 +1634,20 @@ typedef typedef BluetoothInterfaceRunnable1 + BluetoothStatus, BluetoothStatus> BluetoothAvrcpErrorRunnable; static nsresult DispatchBluetoothAvrcpResult( BluetoothAvrcpResultHandler* aRes, void (BluetoothAvrcpResultHandler::*aMethod)(), - bt_status_t aStatus) + BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothAvrcpResultRunnable(aRes, aMethod); } else { runnable = new BluetoothAvrcpErrorRunnable(aRes, @@ -1621,7 +1678,7 @@ BluetoothAvrcpInterface::Init(btrc_callbacks_t* aCallbacks, if (aRes) { DispatchBluetoothAvrcpResult(aRes, &BluetoothAvrcpResultHandler::Init, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -1632,7 +1689,7 @@ BluetoothAvrcpInterface::Cleanup(BluetoothAvrcpResultHandler* aRes) if (aRes) { DispatchBluetoothAvrcpResult(aRes, &BluetoothAvrcpResultHandler::Cleanup, - BT_STATUS_SUCCESS); + STATUS_SUCCESS); } } @@ -1652,7 +1709,8 @@ BluetoothAvrcpInterface::GetPlayStatusRsp(ControlPlayStatus aPlayStatus, if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp, status); + aRes, &BluetoothAvrcpResultHandler::GetPlayStatusRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1673,7 +1731,8 @@ BluetoothAvrcpInterface::ListPlayerAppAttrRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp, status); + aRes, &BluetoothAvrcpResultHandler::ListPlayerAppAttrRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1685,7 +1744,8 @@ BluetoothAvrcpInterface::ListPlayerAppValueRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp, status); + aRes, &BluetoothAvrcpResultHandler::ListPlayerAppValueRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1708,7 +1768,8 @@ BluetoothAvrcpInterface::GetPlayerAppValueRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp, status); + aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1731,7 +1792,8 @@ BluetoothAvrcpInterface::GetPlayerAppAttrTextRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp, status); + aRes, &BluetoothAvrcpResultHandler::GetPlayerAppAttrTextRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1754,7 +1816,8 @@ BluetoothAvrcpInterface::GetPlayerAppValueTextRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp, status); + aRes, &BluetoothAvrcpResultHandler::GetPlayerAppValueTextRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1775,7 +1838,8 @@ BluetoothAvrcpInterface::GetElementAttrRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp, status); + aRes, &BluetoothAvrcpResultHandler::GetElementAttrRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1794,7 +1858,8 @@ BluetoothAvrcpInterface::SetPlayerAppValueRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp, status); + aRes, &BluetoothAvrcpResultHandler::SetPlayerAppValueRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1851,7 +1916,8 @@ BluetoothAvrcpInterface::RegisterNotificationRsp( if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp, status); + aRes, &BluetoothAvrcpResultHandler::RegisterNotificationRsp, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1867,7 +1933,8 @@ BluetoothAvrcpInterface::SetVolume(uint8_t aVolume, if (aRes) { DispatchBluetoothAvrcpResult( - aRes, &BluetoothAvrcpResultHandler::SetVolume, status); + aRes, &BluetoothAvrcpResultHandler::SetVolume, + ConvertDefault(status, STATUS_FAIL)); } } #endif @@ -1881,19 +1948,20 @@ typedef BluetoothResultRunnable; typedef - BluetoothInterfaceRunnable1 + BluetoothInterfaceRunnable1 BluetoothErrorRunnable; static nsresult DispatchBluetoothResult(BluetoothResultHandler* aRes, void (BluetoothResultHandler::*aMethod)(), - int aStatus) + BluetoothStatus aStatus) { MOZ_ASSERT(aRes); nsRunnable* runnable; - if (aStatus == BT_STATUS_SUCCESS) { + if (aStatus == STATUS_SUCCESS) { runnable = new BluetoothResultRunnable(aRes, aMethod); } else { runnable = new @@ -1984,7 +2052,8 @@ BluetoothInterface::Init(bt_callbacks_t* aCallbacks, int status = mInterface->init(aCallbacks); if (aRes) { - DispatchBluetoothResult(aRes, &BluetoothResultHandler::Init, status); + DispatchBluetoothResult(aRes, &BluetoothResultHandler::Init, + ConvertDefault(status, STATUS_FAIL)); } } @@ -1995,7 +2064,7 @@ BluetoothInterface::Cleanup(BluetoothResultHandler* aRes) if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::Cleanup, - BT_STATUS_SUCCESS); + STATUS_SUCCESS); } } @@ -2005,7 +2074,8 @@ BluetoothInterface::Enable(BluetoothResultHandler* aRes) int status = mInterface->enable(); if (aRes) { - DispatchBluetoothResult(aRes, &BluetoothResultHandler::Enable, status); + DispatchBluetoothResult(aRes, &BluetoothResultHandler::Enable, + ConvertDefault(status, STATUS_FAIL)); } } @@ -2015,7 +2085,8 @@ BluetoothInterface::Disable(BluetoothResultHandler* aRes) int status = mInterface->disable(); if (aRes) { - DispatchBluetoothResult(aRes, &BluetoothResultHandler::Disable, status); + DispatchBluetoothResult(aRes, &BluetoothResultHandler::Disable, + ConvertDefault(status, STATUS_FAIL)); } } @@ -2029,7 +2100,7 @@ BluetoothInterface::GetAdapterProperties(BluetoothResultHandler* aRes) if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetAdapterProperties, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2052,7 +2123,7 @@ BluetoothInterface::GetAdapterProperty(const nsAString& aName, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetAdapterProperties, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2073,7 +2144,7 @@ BluetoothInterface::SetAdapterProperty(const BluetoothNamedValue& aProperty, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::SetAdapterProperty, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2095,7 +2166,7 @@ BluetoothInterface::GetRemoteDeviceProperties(const nsAString& aRemoteAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetRemoteDeviceProperties, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2121,7 +2192,7 @@ BluetoothInterface::GetRemoteDeviceProperty(const nsAString& aRemoteAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetRemoteDeviceProperty, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2147,7 +2218,7 @@ BluetoothInterface::SetRemoteDeviceProperty(const nsAString& aRemoteAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::SetRemoteDeviceProperty, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2172,7 +2243,7 @@ BluetoothInterface::GetRemoteServiceRecord(const nsAString& aRemoteAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetRemoteServiceRecord, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2192,7 +2263,7 @@ BluetoothInterface::GetRemoteServices(const nsAString& aRemoteAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::GetRemoteServices, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2206,7 +2277,7 @@ BluetoothInterface::StartDiscovery(BluetoothResultHandler* aRes) if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::StartDiscovery, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2218,7 +2289,7 @@ BluetoothInterface::CancelDiscovery(BluetoothResultHandler* aRes) if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::CancelDiscovery, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2240,7 +2311,7 @@ BluetoothInterface::CreateBond(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::CreateBond, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2260,7 +2331,7 @@ BluetoothInterface::RemoveBond(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::RemoveBond, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2280,7 +2351,7 @@ BluetoothInterface::CancelBond(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::CancelBond, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2308,7 +2379,7 @@ BluetoothInterface::PinReply(const nsAString& aBdAddr, bool aAccept, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::PinReply, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2334,7 +2405,7 @@ BluetoothInterface::SspReply(const nsAString& aBdAddr, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::SspReply, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2356,7 +2427,7 @@ BluetoothInterface::DutModeConfigure(bool aEnable, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::DutModeConfigure, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2369,7 +2440,7 @@ BluetoothInterface::DutModeSend(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::DutModeSend, - status); + ConvertDefault(status, STATUS_FAIL)); } } @@ -2388,7 +2459,7 @@ BluetoothInterface::LeTestMode(uint16_t aOpcode, uint8_t* aBuf, uint8_t aLen, if (aRes) { DispatchBluetoothResult(aRes, &BluetoothResultHandler::LeTestMode, - status); + ConvertDefault(status, STATUS_FAIL)); } } diff --git a/dom/bluetooth/bluedroid/BluetoothInterface.h b/dom/bluetooth/bluedroid/BluetoothInterface.h index 58f5e3c862a..3720e33e73e 100644 --- a/dom/bluetooth/bluedroid/BluetoothInterface.h +++ b/dom/bluetooth/bluedroid/BluetoothInterface.h @@ -32,9 +32,9 @@ public: virtual ~BluetoothSocketResultHandler() { } - virtual void OnError(bt_status_t aStatus) + virtual void OnError(BluetoothStatus aStatus) { - BT_WARNING("received error code %d", (int)aStatus); + BT_WARNING("Received error code %d", (int)aStatus); } virtual void Listen(int aSockFd) { } @@ -84,7 +84,7 @@ public: virtual ~BluetoothHandsfreeResultHandler() { } - virtual void OnError(bt_status_t aStatus) + virtual void OnError(BluetoothStatus aStatus) { BT_WARNING("Received error code %d", (int)aStatus); } @@ -196,9 +196,9 @@ public: virtual ~BluetoothA2dpResultHandler() { } - virtual void OnError(bt_status_t aStatus) + virtual void OnError(BluetoothStatus aStatus) { - BT_WARNING("received error code %d", (int)aStatus); + BT_WARNING("Received error code %d", (int)aStatus); } virtual void Init() { } @@ -240,9 +240,9 @@ public: virtual ~BluetoothAvrcpResultHandler() { } - virtual void OnError(bt_status_t aStatus) + virtual void OnError(BluetoothStatus aStatus) { - BT_WARNING("received error code %d", (int)aStatus); + BT_WARNING("Received error code %d", (int)aStatus); } virtual void Init() { } @@ -333,9 +333,9 @@ public: virtual ~BluetoothResultHandler() { } - virtual void OnError(int aStatus) + virtual void OnError(BluetoothStatus aStatus) { - BT_LOGR("received error code %d", aStatus); + BT_LOGR("Received error code %d", aStatus); } virtual void Init() { } diff --git a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp index f901c2f9048..758ad680b82 100644 --- a/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp +++ b/dom/bluetooth/bluedroid/BluetoothServiceBluedroid.cpp @@ -108,7 +108,7 @@ public: : public BluetoothResultHandler { public: - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_LOGR("Fail to set: BT_SCAN_MODE_CONNECTABLE"); } @@ -845,7 +845,7 @@ EnsureBluetoothHalLoad() class EnableResultHandler MOZ_FINAL : public BluetoothResultHandler { public: - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); @@ -918,7 +918,7 @@ public: } } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); @@ -960,7 +960,7 @@ StartGonkBluetooth() class DisableResultHandler MOZ_FINAL : public BluetoothResultHandler { public: - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); @@ -999,7 +999,7 @@ StopGonkBluetooth() static void ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable, - int aStatusCode, const nsAString& aCustomMsg) + BluetoothStatus aStatusCode, const nsAString& aCustomMsg) { MOZ_ASSERT(aBluetoothReplyRunnable, "Reply runnable is nullptr"); @@ -1008,17 +1008,17 @@ ReplyStatusError(BluetoothReplyRunnable* aBluetoothReplyRunnable, nsAutoString replyError; replyError.Assign(aCustomMsg); - if (aStatusCode == BT_STATUS_BUSY) { + if (aStatusCode == STATUS_BUSY) { replyError.AppendLiteral(":BT_STATUS_BUSY"); - } else if (aStatusCode == BT_STATUS_NOT_READY) { + } else if (aStatusCode == STATUS_NOT_READY) { replyError.AppendLiteral(":BT_STATUS_NOT_READY"); - } else if (aStatusCode == BT_STATUS_DONE) { + } else if (aStatusCode == STATUS_DONE) { replyError.AppendLiteral(":BT_STATUS_DONE"); - } else if (aStatusCode == BT_STATUS_AUTH_FAILURE) { + } else if (aStatusCode == STATUS_AUTH_FAILURE) { replyError.AppendLiteral(":BT_STATUS_AUTH_FAILURE"); - } else if (aStatusCode == BT_STATUS_RMT_DEV_DOWN) { + } else if (aStatusCode == STATUS_RMT_DEV_DOWN) { replyError.AppendLiteral(":BT_STATUS_RMT_DEV_DOWN"); - } else if (aStatusCode == BT_STATUS_FAIL) { + } else if (aStatusCode == STATUS_FAIL) { replyError.AppendLiteral(":BT_STATUS_FAIL"); } @@ -1118,7 +1118,7 @@ public: : mDeviceAddress(aDeviceAddress) { } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); @@ -1225,7 +1225,7 @@ public: DispatchBluetoothReply(mRunnable, true, EmptyString()); } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("StartDiscovery")); @@ -1260,7 +1260,7 @@ public: DispatchBluetoothReply(mRunnable, true, EmptyString()); } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("StopDiscovery")); @@ -1289,7 +1289,7 @@ public: : mRunnable(aRunnable) { } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetProperty")); @@ -1338,7 +1338,7 @@ public: : mRunnable(aRunnable) { } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { sBondingRunnableArray.RemoveElement(mRunnable); ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("CreatedPairedDevice")); @@ -1372,7 +1372,7 @@ public: : mRunnable(aRunnable) { } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { sUnbondingRunnableArray.RemoveElement(mRunnable); ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("RemoveDevice")); @@ -1410,7 +1410,7 @@ public: DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString()); } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetPinCode")); } @@ -1454,7 +1454,7 @@ public: DispatchBluetoothReply(mRunnable, BluetoothValue(true), EmptyString()); } - void OnError(int aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { ReplyStatusError(mRunnable, aStatus, NS_LITERAL_STRING("SetPairingConfirmation")); diff --git a/dom/bluetooth/bluedroid/BluetoothSocket.cpp b/dom/bluetooth/bluedroid/BluetoothSocket.cpp index 805ba662544..0145417890b 100644 --- a/dom/bluetooth/bluedroid/BluetoothSocket.cpp +++ b/dom/bluetooth/bluedroid/BluetoothSocket.cpp @@ -650,7 +650,7 @@ public: XRE_GetIOMessageLoop()->PostTask(FROM_HERE, new AcceptTask(mImpl, aFd)); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); BT_LOGR("BluetoothSocketInterface::Accept failed: %d", (int)aStatus); @@ -832,7 +832,7 @@ public: new SocketConnectTask(mImpl, aFd)); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); BT_WARNING("Connect failed: %d", (int)aStatus); @@ -879,7 +879,7 @@ public: new SocketListenTask(mImpl, aFd)); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { MOZ_ASSERT(NS_IsMainThread()); diff --git a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp index d74f24f4c56..163b35b2b36 100644 --- a/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp +++ b/dom/bluetooth/bluedroid/hfp/BluetoothHfpManager.cpp @@ -447,7 +447,7 @@ public: MOZ_ASSERT(mInterface); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::Init failed: %d", (int)aStatus); if (mRes) { @@ -554,7 +554,7 @@ public: : mRes(aRes) { } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::Cleanup failed: %d", (int)aStatus); if (mRes) { @@ -803,7 +803,7 @@ class CindResponseResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::CindResponse failed: %d", (int)aStatus); @@ -829,7 +829,7 @@ class CopsResponseResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::CopsResponse failed: %d", (int)aStatus); @@ -869,7 +869,7 @@ class AtResponseResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::AtResponse failed: %d", (int)aStatus); @@ -999,7 +999,7 @@ class VolumeControlResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::VolumeControl failed: %d", (int)aStatus); @@ -1147,7 +1147,7 @@ class ClccResponseResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::ClccResponse failed: %d", (int)aStatus); @@ -1184,7 +1184,7 @@ class FormattedAtResponseResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::FormattedAtResponse failed: %d", (int)aStatus); @@ -1213,7 +1213,7 @@ class PhoneStateChangeResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::PhoneStateChange failed: %d", (int)aStatus); @@ -1245,7 +1245,7 @@ class DeviceStatusNotificationResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING( "BluetoothHandsfreeInterface::DeviceStatusNotification failed: %d", @@ -1501,7 +1501,7 @@ class ConnectAudioResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::ConnectAudio failed: %d", (int)aStatus); @@ -1527,7 +1527,7 @@ class DisconnectAudioResultHandler MOZ_FINAL : public BluetoothHandsfreeResultHandler { public: - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::DisconnectAudio failed: %d", (int)aStatus); @@ -1578,7 +1578,7 @@ public: MOZ_ASSERT(mHfpManager); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::Connect failed: %d", (int)aStatus); @@ -1631,7 +1631,7 @@ public: MOZ_ASSERT(mHfpManager); } - void OnError(bt_status_t aStatus) MOZ_OVERRIDE + void OnError(BluetoothStatus aStatus) MOZ_OVERRIDE { BT_WARNING("BluetoothHandsfreeInterface::Disconnect failed: %d", (int)aStatus); From e142a5852c598d620b362cb9026d483b716d9244 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:00:31 -0700 Subject: [PATCH 13/49] Bumping gaia.json for 1 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/ae687e2db868 Author: Zac Desc: Bug 1048953 - Disable test_new_event_appears_on_all_views on TBPL due to bug 1048953 a=testonly --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index ba0371bd70e..b2eea8ac49f 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "0e11e8dd1038fb4909ae7fe764a3a67f96a033d8", + "revision": "ae687e2db868671374627489fb05ab45987ff5d0", "repo_path": "/integration/gaia-central" } From 103c98f3a00420d16c5ee4f2cc725a33d8dbb6b4 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:02:04 -0700 Subject: [PATCH 14/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index fd14123a496..795c01e4177 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 5747c87a9c7..74511451016 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 4583a63634d..ff0c07ae106 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index fd14123a496..795c01e4177 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 9fa5da8b51e..56521cf6a53 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index f058f1a5a2f..78aeea601dd 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index a25d5b967ee..f6e5da515ad 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index dbb361d1ddf..eb0faf217a3 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index a0bdb934880..3f00edd6db5 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 04b2c9c78957582950ea8f595f337dfc9fb9e595 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:15:34 -0700 Subject: [PATCH 15/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ======== https://hg.mozilla.org/integration/gaia-central/rev/17892a41a093 Author: Germán Toro del Valle Desc: Merge pull request #21867 from gtorodelvalle/callscreen-bug-1024506-call-option-buttons Bug 1024506 - While call is "connecting", "Add other call", "Keypad" and "microphone" buttons should be disabled ======== https://hg.mozilla.org/integration/gaia-central/rev/64581952209f Author: German Toro del Valle Desc: Bug 1024506 - While call is "connecting", "Add other call", "Keypad" and "microphone" buttons should be disabled. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index b2eea8ac49f..56bd8acee55 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "ae687e2db868671374627489fb05ab45987ff5d0", + "revision": "17892a41a093463e0f9d46b7ccfca1b618ffd60c", "repo_path": "/integration/gaia-central" } From 7b7e63f0067b139839ce6609f9e9d53413d1c7bf Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:21:21 -0700 Subject: [PATCH 16/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 795c01e4177..e0215314c52 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 74511451016..40821f36feb 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index ff0c07ae106..94398967eff 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 795c01e4177..e0215314c52 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 56521cf6a53..fd4958de689 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 78aeea601dd..c8536ab21da 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index f6e5da515ad..75f195e7819 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index eb0faf217a3..5c00f3ddf3e 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 3f00edd6db5..4a89b3d12bc 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From f2af9a99ade8aa5b7be12905bf353e93c684613c Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:30:29 -0700 Subject: [PATCH 17/49] Bumping gaia.json for 1 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/1edc393a4af0 Author: Zac Desc: Revert "Revert "Bug 1033975 - Resolve Python suite crash handling"" This reverts commit bc16638fff952754efbdfd6f84b8e068c12b4f6f. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 56bd8acee55..6b7e0c6808e 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "17892a41a093463e0f9d46b7ccfca1b618ffd60c", + "revision": "1edc393a4af0a61f6633087d9868eff5dd52ce35", "repo_path": "/integration/gaia-central" } From d026b5119a928f96e26804d695d502df81f9536e Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:36:13 -0700 Subject: [PATCH 18/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index e0215314c52..2d3e08b3ebf 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 40821f36feb..713c9ba9a3b 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 94398967eff..51efb698bbe 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index e0215314c52..2d3e08b3ebf 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index fd4958de689..67f8aeef2e1 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index c8536ab21da..6c4dde9f0cc 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 75f195e7819..72b7eadbea4 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 5c00f3ddf3e..07aadfc8c61 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 4a89b3d12bc..610db2dbb9b 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From f13099157792ff01b294aff847d9f902b83bce4b Mon Sep 17 00:00:00 2001 From: Blake Wu Date: Wed, 6 Aug 2014 00:17:00 -0400 Subject: [PATCH 19/49] Bug 941302 - Part 1: Enable FMP4 For B2G. r=glandium --- configure.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/configure.in b/configure.in index f37e7721c96..97dfe4a71fe 100644 --- a/configure.in +++ b/configure.in @@ -261,6 +261,7 @@ if test -n "$gonkdir" ; then MOZ_OMX_ENCODER=1 AC_SUBST(MOZ_OMX_ENCODER) AC_DEFINE(MOZ_OMX_ENCODER) + MOZ_FMP4=1 ;; 19) GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include" @@ -275,7 +276,7 @@ if test -n "$gonkdir" ; then MOZ_AUDIO_OFFLOAD=1 AC_SUBST(MOZ_AUDIO_OFFLOAD) AC_DEFINE(MOZ_AUDIO_OFFLOAD) - + MOZ_FMP4=1 ;; *) AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION]) @@ -3776,7 +3777,11 @@ MOZ_WEBM=1 MOZ_GSTREAMER= MOZ_DIRECTSHOW= MOZ_WMF= -MOZ_FMP4= +if test -n "$MOZ_FMP4"; then + MOZ_FMP4=1 +else + MOZ_FMP4 = +fi MOZ_EME=1 MOZ_FFMPEG= MOZ_WEBRTC=1 From 5829b276b27fb87047ff7e0bd6f95eb106aa205d Mon Sep 17 00:00:00 2001 From: Blake Wu Date: Wed, 6 Aug 2014 00:19:00 -0400 Subject: [PATCH 20/49] Bug 941302 - Part 2: Changes in MediaCodecProxy. r=edwin --- content/media/omx/MediaCodecProxy.cpp | 110 +++++++++++++++++++++++++- content/media/omx/MediaCodecProxy.h | 22 +++++- 2 files changed, 129 insertions(+), 3 deletions(-) diff --git a/content/media/omx/MediaCodecProxy.cpp b/content/media/omx/MediaCodecProxy.cpp index 82e73bc671d..29ad7a50d39 100644 --- a/content/media/omx/MediaCodecProxy.cpp +++ b/content/media/omx/MediaCodecProxy.cpp @@ -5,11 +5,16 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaCodecProxy.h" - #include - #include +#include +#include +#include +#define LOG_TAG "MediaCodecProxy" +#include +#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) +#define TIMEOUT_DEQUEUE_INPUTBUFFER_MS 1000000ll namespace android { sp @@ -389,4 +394,105 @@ MediaCodecProxy::resourceCanceled() } } +bool MediaCodecProxy::Prepare() +{ + + status_t err; + if (start() != OK) { + ALOG("Couldn't start MediaCodec"); + return false; + } + if (getInputBuffers(&mInputBuffers) != OK) { + ALOG("Couldn't get input buffers from MediaCodec"); + return false; + } + if (getOutputBuffers(&mOutputBuffers) != OK) { + ALOG("Couldn't get output buffers from MediaCodec"); + return false; + } + + return true; +} + +status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize, + int64_t aTimestampUsecs, uint64_t aflags) +{ + if (mCodec == nullptr) { + ALOG("MediaCodec has not been inited from input!"); + return NO_INIT; + } + + size_t index; + status_t err = dequeueInputBuffer(&index, TIMEOUT_DEQUEUE_INPUTBUFFER_MS); + if (err != OK) { + ALOG("dequeueInputBuffer returned %d", err); + return err; + } + const sp &dstBuffer = mInputBuffers.itemAt(index); + + CHECK_LE(aDataSize, dstBuffer->capacity()); + dstBuffer->setRange(0, aDataSize); + + memcpy(dstBuffer->data(), aData, aDataSize); + err = queueInputBuffer(index, 0, dstBuffer->size(), aTimestampUsecs, aflags); + if (err != OK) { + ALOG("queueInputBuffer returned %d", err); + return err; + } + return err; +} + +status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs) +{ + + if (mCodec == nullptr) { + ALOG("MediaCodec has not been inited from output!"); + return NO_INIT; + } + + size_t index = 0; + size_t offset = 0; + size_t size = 0; + int64_t timeUs = 0; + uint32_t flags = 0; + + *aBuffer = nullptr; + + status_t err = dequeueOutputBuffer(&index, &offset, &size, + &timeUs, &flags, aTimeoutUs); + if (err != OK) { + ALOG("Output returned %d", err); + return err; + } + + MediaBuffer *buffer; + + buffer = new MediaBuffer(mOutputBuffers.itemAt(index)); + sp metaData = buffer->meta_data(); + metaData->setInt32(kKeyBufferIndex, index); + metaData->setInt64(kKeyTime, timeUs); + buffer->set_range(buffer->range_offset(), size); + *aBuffer = buffer; + return err; +} + +bool MediaCodecProxy::IsWaitingResources() +{ + return mCodec == nullptr; +} + +bool MediaCodecProxy::IsDormantNeeded() +{ + return mCodecLooper.get() ? true : false; +} + +void MediaCodecProxy::ReleaseMediaResources() +{ + if (mCodec.get()) { + mCodec->stop(); + mCodec->release(); + mCodec.clear(); + } +} + } // namespace android diff --git a/content/media/omx/MediaCodecProxy.h b/content/media/omx/MediaCodecProxy.h index 3b4435b2466..91a683ae069 100644 --- a/content/media/omx/MediaCodecProxy.h +++ b/content/media/omx/MediaCodecProxy.h @@ -10,12 +10,18 @@ #include #include +#include #include #include "MediaResourceHandler.h" namespace android { - +// This class is intended to be a proxy for MediaCodec with codec resource +// management. Basically user can use it like MediaCodec, but need to handle +// the listener when Codec is reserved for Async case. A good example is +// MediaCodecReader.cpp. Another useage is to use configure(), Prepare(), +// Input(), and Output(). It is used in GonkVideoDecoderManager.cpp which +// doesn't need to handle the buffers for codec. class MediaCodecProxy : public MediaResourceHandler::ResourceListener { public: @@ -34,6 +40,9 @@ public: virtual void codecCanceled() = 0; }; + enum { + kKeyBufferIndex = 'bfin', + }; // Check whether MediaCodec has been allocated. bool allocated() const; @@ -104,6 +113,13 @@ public: // pending, an error is pending. void requestActivityNotification(const sp &aNotify); + status_t Input(const uint8_t* aData, uint32_t aDataSize, + int64_t aTimestampUsecs, uint64_t flags); + status_t Output(MediaBuffer** aBuffer, int64_t aTimeoutUs); + bool Prepare(); + bool IsWaitingResources(); + bool IsDormantNeeded(); + void ReleaseMediaResources(); protected: virtual ~MediaCodecProxy(); @@ -149,6 +165,10 @@ private: // MediaCodec instance mutable RWLock mCodecLock; sp mCodec; + //MediaCodec buffers to hold input/output data. + Vector > mInputBuffers; + Vector > mOutputBuffers; + }; } // namespace android From 43424f9a1384106f5a33cd1c6f3a2787c816713b Mon Sep 17 00:00:00 2001 From: Blake Wu Date: Wed, 6 Aug 2014 00:20:00 -0400 Subject: [PATCH 21/49] Bug 941302 - Part 3: Changes for Adding Gonk Decode Module. r=cpearce --- b2g/app/b2g.js | 5 +- content/media/fmp4/MP4Decoder.cpp | 7 +++ content/media/fmp4/MP4Reader.cpp | 56 +++++++++++++++++++- content/media/fmp4/MP4Reader.h | 12 +++++ content/media/fmp4/PlatformDecoderModule.cpp | 14 +++++ content/media/fmp4/PlatformDecoderModule.h | 14 +++++ content/media/fmp4/moz.build | 4 ++ 7 files changed, 109 insertions(+), 3 deletions(-) diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 9e46b6dcc3e..4505b1b9091 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -309,7 +309,10 @@ pref("dom.indexedDB.warningQuota", 5); pref("media.preload.default", 1); // default to preload none pref("media.preload.auto", 2); // preload metadata if preload=auto pref("media.cache_size", 4096); // 4MB media cache - +#ifdef MOZ_FMP4 +// Enable/Disable Gonk Decoder Module +pref("media.fragmented-mp4.gonk.enabled", false); +#endif // The default number of decoded video frames that are enqueued in // MediaDecoderReader's mVideoQueue. pref("media.video-queue.default-size", 3); diff --git a/content/media/fmp4/MP4Decoder.cpp b/content/media/fmp4/MP4Decoder.cpp index e5acefa77e7..1040cef5a64 100644 --- a/content/media/fmp4/MP4Decoder.cpp +++ b/content/media/fmp4/MP4Decoder.cpp @@ -131,6 +131,12 @@ IsAppleAvailable() #endif } +static bool +IsGonkMP4DecoderAvailable() +{ + return Preferences::GetBool("media.fragmented-mp4.gonk.enabled", false); +} + static bool HavePlatformMPEGDecoders() { @@ -141,6 +147,7 @@ HavePlatformMPEGDecoders() #endif IsFFmpegAvailable() || IsAppleAvailable() || + IsGonkMP4DecoderAvailable() || // TODO: Other platforms... false; } diff --git a/content/media/fmp4/MP4Reader.cpp b/content/media/fmp4/MP4Reader.cpp index 69a91ec1949..b3e60771e8e 100644 --- a/content/media/fmp4/MP4Reader.cpp +++ b/content/media/fmp4/MP4Reader.cpp @@ -230,8 +230,14 @@ private: nsString mInitDataType; }; -bool MP4Reader::IsWaitingMediaResources() -{ +bool MP4Reader::IsWaitingOnCodecResource() { +#ifdef MOZ_GONK_MEDIACODEC + return mVideo.mDecoder && mVideo.mDecoder->IsWaitingMediaResources(); +#endif + return false; +} + +bool MP4Reader::IsWaitingOnCDMResource() { nsRefPtr proxy; { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); @@ -253,6 +259,15 @@ bool MP4Reader::IsWaitingMediaResources() } } +bool MP4Reader::IsWaitingMediaResources() +{ + // IsWaitingOnCDMResource() *must* come first, because we don't know whether + // we can create a decoder until the CDM is initialized and it has told us + // whether *it* will decode, or whether we need to create a PDM to do the + // decoding + return IsWaitingOnCDMResource() || IsWaitingOnCodecResource(); +} + void MP4Reader::ExtractCryptoInitData(nsTArray& aInitData) { @@ -294,7 +309,12 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo, // an encrypted stream and we need to wait for a CDM to be set, we don't // need to reinit the demuxer. mDemuxerInitialized = true; + } else if (mPlatform && !IsWaitingMediaResources()) { + *aInfo = mInfo; + *aTags = nullptr; + return NS_OK; } + if (mDemuxer->Crypto().valid) { if (!sIsEMEEnabled) { // TODO: Need to signal DRM/EME required somehow... @@ -735,4 +755,36 @@ MP4Reader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) return NS_OK; } +bool MP4Reader::IsDormantNeeded() +{ +#ifdef MOZ_GONK_MEDIACODEC + return mVideo.mDecoder && mVideo.mDecoder->IsDormantNeeded(); +#endif + return false; +} + +void MP4Reader::ReleaseMediaResources() +{ +#ifdef MOZ_GONK_MEDIACODEC + // Before freeing a video codec, all video buffers needed to be released + // even from graphics pipeline. + VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); + if (container) { + container->ClearCurrentFrame(); + } + if (mVideo.mDecoder) { + mVideo.mDecoder->ReleaseMediaResources(); + } +#endif +} + +void MP4Reader::NotifyResourcesStatusChanged() +{ +#ifdef MOZ_GONK_MEDIACODEC + if (mDecoder) { + mDecoder->NotifyWaitingForResourcesStatusChanged(); + } +#endif +} + } // namespace mozilla diff --git a/content/media/fmp4/MP4Reader.h b/content/media/fmp4/MP4Reader.h index 7045c68272a..2e6fbb10a7f 100644 --- a/content/media/fmp4/MP4Reader.h +++ b/content/media/fmp4/MP4Reader.h @@ -59,7 +59,10 @@ public: virtual nsresult GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) MOZ_OVERRIDE; + // For Media Resource Management virtual bool IsWaitingMediaResources() MOZ_OVERRIDE; + virtual bool IsDormantNeeded() MOZ_OVERRIDE; + virtual void ReleaseMediaResources() MOZ_OVERRIDE; virtual nsresult ResetDecode() MOZ_OVERRIDE; @@ -84,6 +87,9 @@ private: bool Decode(mp4_demuxer::TrackType aTrack); void Flush(mp4_demuxer::TrackType aTrack); void DrainComplete(mp4_demuxer::TrackType aTrack); + void NotifyResourcesStatusChanged(); + bool IsWaitingOnCodecResource(); + bool IsWaitingOnCDMResource(); nsAutoPtr mDemuxer; nsAutoPtr mPlatform; @@ -108,6 +114,12 @@ private: virtual void DrainComplete() MOZ_OVERRIDE { mReader->DrainComplete(mType); } + virtual void NotifyResourcesStatusChanged() MOZ_OVERRIDE { + mReader->NotifyResourcesStatusChanged(); + } + virtual void ReleaseMediaResources() MOZ_OVERRIDE { + mReader->ReleaseMediaResources(); + } private: MP4Reader* mReader; mp4_demuxer::TrackType mType; diff --git a/content/media/fmp4/PlatformDecoderModule.cpp b/content/media/fmp4/PlatformDecoderModule.cpp index 3acffc29a30..846bce6c6a2 100644 --- a/content/media/fmp4/PlatformDecoderModule.cpp +++ b/content/media/fmp4/PlatformDecoderModule.cpp @@ -14,6 +14,10 @@ #ifdef MOZ_APPLEMEDIA #include "AppleDecoderModule.h" #endif +#ifdef MOZ_GONK_MEDIACODEC +#include "GonkDecoderModule.h" +#endif + #include "mozilla/Preferences.h" #include "EMEDecoderModule.h" #include "mozilla/CDMProxy.h" @@ -26,6 +30,7 @@ extern PlatformDecoderModule* CreateBlankDecoderModule(); bool PlatformDecoderModule::sUseBlankDecoder = false; bool PlatformDecoderModule::sFFmpegDecoderEnabled = false; +bool PlatformDecoderModule::sGonkDecoderEnabled = false; /* static */ void @@ -42,6 +47,10 @@ PlatformDecoderModule::Init() "media.fragmented-mp4.use-blank-decoder"); Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled, "media.fragmented-mp4.ffmpeg.enabled", false); +#ifdef MOZ_GONK_MEDIACODEC + Preferences::AddBoolVarCache(&sGonkDecoderEnabled, + "media.fragmented-mp4.gonk.enabled", false); +#endif #ifdef XP_WIN WMFDecoderModule::Init(); #endif @@ -128,6 +137,11 @@ PlatformDecoderModule::Create() if (NS_SUCCEEDED(m->Startup())) { return m.forget(); } +#endif +#ifdef MOZ_GONK_MEDIACODEC + if (sGonkDecoderEnabled) { + return new GonkDecoderModule(); + } #endif return nullptr; } diff --git a/content/media/fmp4/PlatformDecoderModule.h b/content/media/fmp4/PlatformDecoderModule.h index 7f4f85b09f8..90ebfba8024 100644 --- a/content/media/fmp4/PlatformDecoderModule.h +++ b/content/media/fmp4/PlatformDecoderModule.h @@ -123,6 +123,7 @@ protected: // Caches pref media.fragmented-mp4.use-blank-decoder static bool sUseBlankDecoder; static bool sFFmpegDecoderEnabled; + static bool sGonkDecoderEnabled; }; // A callback used by MediaDataDecoder to return output/errors to the @@ -144,6 +145,10 @@ public: virtual void InputExhausted() = 0; virtual void DrainComplete() = 0; + + virtual void NotifyResourcesStatusChanged() {}; + + virtual void ReleaseMediaResources() {}; }; // MediaDataDecoder is the interface exposed by decoders created by the @@ -209,6 +214,15 @@ public: // returned. virtual nsresult Shutdown() = 0; + // For Codec Resource Management + virtual bool IsWaitingMediaResources() { + return false; + }; + virtual bool IsDormantNeeded() { + return false; + }; + virtual void ReleaseMediaResources() {}; + virtual void ReleaseDecoder() {}; }; } // namespace mozilla diff --git a/content/media/fmp4/moz.build b/content/media/fmp4/moz.build index d26f6f1b983..63a8cfabb66 100644 --- a/content/media/fmp4/moz.build +++ b/content/media/fmp4/moz.build @@ -68,6 +68,10 @@ LOCAL_INCLUDES += [ '../base', ] +if CONFIG['ANDROID_VERSION'] >= '18'and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': + DEFINES['MOZ_GONK_MEDIACODEC'] = True + DIRS += ['gonk'] + FINAL_LIBRARY = 'xul' FAIL_ON_WARNINGS = True From 43f4b98d650dd8e4e04f2cc6c85243000aa6e335 Mon Sep 17 00:00:00 2001 From: Blake Wu Date: Wed, 6 Aug 2014 00:22:00 -0400 Subject: [PATCH 22/49] Bug 941302 - Part 4: Changes in demuxer to make aac_profile public. r=ajones --- media/libstagefright/binding/include/mp4_demuxer/DecoderData.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index c59fded4f00..23e32467d09 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -97,6 +97,7 @@ public: uint32_t bits_per_sample; uint32_t samples_per_second; int8_t frequency_index; + int8_t aac_profile; mozilla::Vector extra_data; mozilla::Vector audio_specific_config; CryptoTrack crypto; @@ -107,7 +108,6 @@ public: private: friend class MP4Demuxer; - int8_t aac_profile; }; class VideoDecoderConfig : public TrackConfig From 23ba64f0df98e2f3e510f48c374a6c6a37cafe53 Mon Sep 17 00:00:00 2001 From: Blake Wu Date: Wed, 6 Aug 2014 00:23:00 -0400 Subject: [PATCH 23/49] Bug 941302 - Part 5: Add Gonk Decoder Module. r=cpearce --- .../fmp4/gonk/GonkAudioDecoderManager.cpp | 197 ++++++++ .../media/fmp4/gonk/GonkAudioDecoderManager.h | 51 ++ content/media/fmp4/gonk/GonkDecoderModule.cpp | 61 +++ content/media/fmp4/gonk/GonkDecoderModule.h | 41 ++ .../media/fmp4/gonk/GonkMediaDataDecoder.cpp | 154 ++++++ .../media/fmp4/gonk/GonkMediaDataDecoder.h | 92 ++++ .../fmp4/gonk/GonkVideoDecoderManager.cpp | 456 ++++++++++++++++++ .../media/fmp4/gonk/GonkVideoDecoderManager.h | 125 +++++ content/media/fmp4/gonk/moz.build | 32 ++ 9 files changed, 1209 insertions(+) create mode 100644 content/media/fmp4/gonk/GonkAudioDecoderManager.cpp create mode 100644 content/media/fmp4/gonk/GonkAudioDecoderManager.h create mode 100644 content/media/fmp4/gonk/GonkDecoderModule.cpp create mode 100644 content/media/fmp4/gonk/GonkDecoderModule.h create mode 100644 content/media/fmp4/gonk/GonkMediaDataDecoder.cpp create mode 100644 content/media/fmp4/gonk/GonkMediaDataDecoder.h create mode 100644 content/media/fmp4/gonk/GonkVideoDecoderManager.cpp create mode 100644 content/media/fmp4/gonk/GonkVideoDecoderManager.h create mode 100644 content/media/fmp4/gonk/moz.build diff --git a/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp b/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp new file mode 100644 index 00000000000..6192d489959 --- /dev/null +++ b/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp @@ -0,0 +1,197 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +#include "GonkAudioDecoderManager.h" +#include "MediaDecoderReader.h" +#include "VideoUtils.h" +#include "nsTArray.h" +#include "prlog.h" +#include "stagefright/MediaBuffer.h" +#include "stagefright/MetaData.h" +#include "stagefright/MediaErrors.h" +#include +#include "media/openmax/OMX_Audio.h" + +#define LOG_TAG "GonkAudioDecoderManager" +#include +#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) + +#ifdef PR_LOGGING +PRLogModuleInfo* GetDemuxerLog(); +#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) +#else +#define LOG(...) +#endif +#define READ_OUTPUT_BUFFER_TIMEOUT_US 3000 + +using namespace android; +typedef android::MediaCodecProxy MediaCodecProxy; + +namespace mozilla { + +GonkAudioDecoderManager::GonkAudioDecoderManager( + const mp4_demuxer::AudioDecoderConfig& aConfig) + : mAudioChannels(aConfig.channel_count) + , mAudioRate(aConfig.samples_per_second) + , mAudioProfile(aConfig.aac_profile) + , mAudioBuffer(nullptr) +{ + MOZ_COUNT_CTOR(GonkAudioDecoderManager); + MOZ_ASSERT(mAudioChannels); + mUserData.AppendElements(&aConfig.audio_specific_config[0], + aConfig.audio_specific_config.length()); +} + +GonkAudioDecoderManager::~GonkAudioDecoderManager() +{ + MOZ_COUNT_DTOR(GonkAudioDecoderManager); +} + +android::sp +GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback) +{ + if (mLooper != nullptr) { + return nullptr; + } + // Create ALooper + mLooper = new ALooper; + mLooper->setName("GonkAudioDecoderManager"); + mLooper->start(); + + mDecoder = MediaCodecProxy::CreateByType(mLooper, "audio/mp4a-latm", false, false, nullptr); + if (!mDecoder.get()) { + return nullptr; + } + sp format = new AMessage; + // Fixed values + ALOG("Init Audio channel no:%d, sample-rate:%d", mAudioChannels, mAudioRate); + format->setString("mime", "audio/mp4a-latm"); + format->setInt32("channel-count", mAudioChannels); + format->setInt32("sample-rate", mAudioRate); + format->setInt32("aac-profile", mAudioProfile); + format->setInt32("is-adts", true); + status_t err = mDecoder->configure(format, nullptr, nullptr, 0); + if (err != OK || !mDecoder->Prepare()) { + return nullptr; + } + status_t rv = mDecoder->Input(mUserData.Elements(), mUserData.Length(), 0, + android::MediaCodec::BUFFER_FLAG_CODECCONFIG); + + if (rv == OK) { + return mDecoder; + } else { + ALOG("Failed to input codec specific data!"); + return nullptr; + } +} + +nsresult +GonkAudioDecoderManager::CreateAudioData(int64_t aStreamOffset, AudioData **v) { + + void *data; + size_t dataOffset; + size_t size; + int64_t timeUs; + + if (!mAudioBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { + return NS_ERROR_UNEXPECTED; + } + data = mAudioBuffer->data(); + dataOffset = mAudioBuffer->range_offset(); + size = mAudioBuffer->range_length(); + + nsAutoArrayPtr buffer(new AudioDataValue[size/2] ); + memcpy(buffer.get(), data+dataOffset, size); + uint32_t frames = size / (2 * mAudioChannels); + + CheckedInt64 duration = FramesToUsecs(frames, mAudioRate); + if (!duration.isValid()) { + return NS_ERROR_UNEXPECTED; + } + *v = new AudioData(aStreamOffset, timeUs, duration.value(), frames, buffer.forget(), + mAudioChannels); + ReleaseAudioBuffer(); + return NS_OK; +} + +nsresult +GonkAudioDecoderManager::Output(int64_t aStreamOffset, + nsAutoPtr& aOutData) +{ + aOutData = nullptr; + status_t err; + err = mDecoder->Output(&mAudioBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US); + + switch (err) { + case OK: + { + if (mAudioBuffer && mAudioBuffer->range_length() != 0) { + int64_t timeUs; + if (!mAudioBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { + return NS_ERROR_UNEXPECTED; + } + } + AudioData* data = nullptr; + nsresult rv = CreateAudioData(aStreamOffset, &data); + // Frame should be non null only when we succeeded. + if (rv != NS_OK) { + return NS_ERROR_UNEXPECTED; + } + aOutData = data; + return NS_OK; + } + case android::INFO_FORMAT_CHANGED: + case android::INFO_OUTPUT_BUFFERS_CHANGED: + { + // If the format changed, update our cached info. + ALOG("Decoder format changed"); + return Output(aStreamOffset, aOutData); + } + case -EAGAIN: + { + return NS_ERROR_NOT_AVAILABLE; + } + case android::ERROR_END_OF_STREAM: + { + ALOG("End of Stream"); + return NS_ERROR_ABORT; + } + case -ETIMEDOUT: + { + ALOG("Timeout. can try again next time"); + return NS_ERROR_UNEXPECTED; + } + default: + { + ALOG("Decoder failed, err=%d", err); + return NS_ERROR_UNEXPECTED; + } + } + + return NS_OK; +} + +void GonkAudioDecoderManager::ReleaseAudioBuffer() { + if (mAudioBuffer) { + sp metaData = mAudioBuffer->meta_data(); + int32_t index; + metaData->findInt32(android::MediaCodecProxy::kKeyBufferIndex, &index); + mAudioBuffer->release(); + mAudioBuffer = nullptr; + mDecoder->releaseOutputBuffer(index); + } +} + +nsresult +GonkAudioDecoderManager::Input(mp4_demuxer::MP4Sample* aSample) +{ + const uint8_t* data = reinterpret_cast(aSample->data); + uint32_t length = aSample->size; + status_t rv = mDecoder->Input(data, length, aSample->composition_timestamp, 0); + return rv == OK ? NS_OK : NS_ERROR_UNEXPECTED; +} + +} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkAudioDecoderManager.h b/content/media/fmp4/gonk/GonkAudioDecoderManager.h new file mode 100644 index 00000000000..fc40d58dadc --- /dev/null +++ b/content/media/fmp4/gonk/GonkAudioDecoderManager.h @@ -0,0 +1,51 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +#if !defined(GonkAudioDecoderManager_h_) +#define GonkAudioDecoderManager_h_ + +#include "mozilla/RefPtr.h" +#include "MP4Reader.h" +#include "GonkMediaDataDecoder.h" + +using namespace android; + +namespace mozilla { + +class GonkAudioDecoderManager : public GonkDecoderManager { +typedef android::MediaCodecProxy MediaCodecProxy; +public: + GonkAudioDecoderManager(const mp4_demuxer::AudioDecoderConfig& aConfig); + ~GonkAudioDecoderManager(); + + virtual android::sp Init(MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; + + virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE; + + virtual nsresult Output(int64_t aStreamOffset, + nsAutoPtr& aOutput) MOZ_OVERRIDE; +private: + + nsresult CreateAudioData(int64_t aStreamOffset, + AudioData** aOutData); + + void ReleaseAudioBuffer(); + // MediaCodedc's wrapper that performs the decoding. + android::sp mDecoder; + + const uint32_t mAudioChannels; + const uint32_t mAudioRate; + const uint32_t mAudioProfile; + nsTArray mUserData; + + MediaDataDecoderCallback* mReaderCallback; + android::MediaBuffer* mAudioBuffer; + android::sp mLooper; +}; + +} // namespace mozilla + +#endif // GonkAudioDecoderManager_h_ diff --git a/content/media/fmp4/gonk/GonkDecoderModule.cpp b/content/media/fmp4/gonk/GonkDecoderModule.cpp new file mode 100644 index 00000000000..022fd303505 --- /dev/null +++ b/content/media/fmp4/gonk/GonkDecoderModule.cpp @@ -0,0 +1,61 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ +#include "GonkDecoderModule.h" +#include "GonkVideoDecoderManager.h" +#include "GonkAudioDecoderManager.h" +#include "mozilla/Preferences.h" +#include "mozilla/DebugOnly.h" +#include "GonkMediaDataDecoder.h" + +namespace mozilla { +GonkDecoderModule::GonkDecoderModule() +{ +} + +GonkDecoderModule::~GonkDecoderModule() +{ +} + +/* static */ +void +GonkDecoderModule::Init() +{ + MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); +} + +nsresult +GonkDecoderModule::Shutdown() +{ + MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); + + return NS_OK; +} + +already_AddRefed +GonkDecoderModule::CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig, + mozilla::layers::LayersBackend aLayersBackend, + mozilla::layers::ImageContainer* aImageContainer, + MediaTaskQueue* aVideoTaskQueue, + MediaDataDecoderCallback* aCallback) +{ + nsRefPtr decoder = + new GonkMediaDataDecoder(new GonkVideoDecoderManager(aImageContainer,aConfig), + aVideoTaskQueue, aCallback); + return decoder.forget(); +} + +already_AddRefed +GonkDecoderModule::CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig, + MediaTaskQueue* aAudioTaskQueue, + MediaDataDecoderCallback* aCallback) +{ + nsRefPtr decoder = + new GonkMediaDataDecoder(new GonkAudioDecoderManager(aConfig), aAudioTaskQueue, + aCallback); + return decoder.forget(); +} + +} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkDecoderModule.h b/content/media/fmp4/gonk/GonkDecoderModule.h new file mode 100644 index 00000000000..95c0e08a4cf --- /dev/null +++ b/content/media/fmp4/gonk/GonkDecoderModule.h @@ -0,0 +1,41 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +#if !defined(GonkPlatformDecoderModule_h_) +#define GonkPlatformDecoderModule_h_ + +#include "PlatformDecoderModule.h" + +namespace mozilla { + +class GonkDecoderModule : public PlatformDecoderModule { +public: + GonkDecoderModule(); + virtual ~GonkDecoderModule(); + + // Called when the decoders have shutdown. + virtual nsresult Shutdown() MOZ_OVERRIDE; + + // Decode thread. + virtual already_AddRefed + CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig, + mozilla::layers::LayersBackend aLayersBackend, + mozilla::layers::ImageContainer* aImageContainer, + MediaTaskQueue* aVideoTaskQueue, + MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; + + // Decode thread. + virtual already_AddRefed + CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig, + MediaTaskQueue* aAudioTaskQueue, + MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; + + static void Init(); +}; + +} // namespace mozilla + +#endif diff --git a/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp b/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp new file mode 100644 index 00000000000..a37b18541c1 --- /dev/null +++ b/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp @@ -0,0 +1,154 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ +#include "mp4_demuxer/mp4_demuxer.h" +#include "GonkMediaDataDecoder.h" +#include "VideoUtils.h" +#include "nsTArray.h" + +#include "prlog.h" +#define LOG_TAG "GonkMediaDataDecoder(blake)" +#include +#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) + +#ifdef PR_LOGGING +PRLogModuleInfo* GetDemuxerLog(); +#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) +#else +#define LOG(...) +#endif + +using namespace android; + +namespace mozilla { + +GonkMediaDataDecoder::GonkMediaDataDecoder(GonkDecoderManager* aManager, + MediaTaskQueue* aTaskQueue, + MediaDataDecoderCallback* aCallback) + : mTaskQueue(aTaskQueue) + , mCallback(aCallback) + , mManager(aManager) +{ + MOZ_COUNT_CTOR(GonkMediaDataDecoder); +} + +GonkMediaDataDecoder::~GonkMediaDataDecoder() +{ + MOZ_COUNT_DTOR(GonkMediaDataDecoder); +} + +nsresult +GonkMediaDataDecoder::Init() +{ + mDecoder = mManager->Init(mCallback); + return mDecoder.get() ? NS_OK : NS_ERROR_UNEXPECTED; +} + +nsresult +GonkMediaDataDecoder::Shutdown() +{ + mDecoder->stop(); + mDecoder = nullptr; + return NS_OK; +} + +// Inserts data into the decoder's pipeline. +nsresult +GonkMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample) +{ + mTaskQueue->Dispatch( + NS_NewRunnableMethodWithArg>( + this, + &GonkMediaDataDecoder::ProcessDecode, + nsAutoPtr(aSample))); + return NS_OK; +} + +void +GonkMediaDataDecoder::ProcessDecode(mp4_demuxer::MP4Sample* aSample) +{ + nsresult rv = mManager->Input(aSample); + if (rv != NS_OK) { + NS_WARNING("GonkAudioDecoder failed to input data"); + ALOG("Failed to input data err: %d",rv); + mCallback->Error(); + return; + } + + mLastStreamOffset = aSample->byte_offset; + ProcessOutput(); +} + +void +GonkMediaDataDecoder::ProcessOutput() +{ + nsAutoPtr output; + nsresult rv; + while (true) { + rv = mManager->Output(mLastStreamOffset, output); + if (rv == NS_OK) { + mCallback->Output(output.forget()); + continue; + } + else { + break; + } + } + + if (rv == NS_ERROR_NOT_AVAILABLE) { + mCallback->InputExhausted(); + return; + } + if (rv != NS_OK) { + NS_WARNING("GonkMediaDataDecoder failed to output data"); + ALOG("Failed to output data"); + mCallback->Error(); + } +} + +nsresult +GonkMediaDataDecoder::Flush() +{ + // Flush the input task queue. This cancels all pending Decode() calls. + // Note this blocks until the task queue finishes its current job, if + // it's executing at all. Note the MP4Reader ignores all output while + // flushing. + mTaskQueue->Flush(); + + status_t err = mDecoder->flush(); + return err == OK ? NS_OK : NS_ERROR_FAILURE; +} + +void +GonkMediaDataDecoder::ProcessDrain() +{ + // Then extract all available output. + ProcessOutput(); + mCallback->DrainComplete(); +} + +nsresult +GonkMediaDataDecoder::Drain() +{ + mTaskQueue->Dispatch(NS_NewRunnableMethod(this, &GonkMediaDataDecoder::ProcessDrain)); + return NS_OK; +} + +bool +GonkMediaDataDecoder::IsWaitingMediaResources() { + return mDecoder->IsWaitingResources(); +} + +bool +GonkMediaDataDecoder::IsDormantNeeded() { + return mDecoder->IsDormantNeeded(); +} + +void +GonkMediaDataDecoder::ReleaseMediaResources() { + mDecoder->ReleaseMediaResources(); +} + +} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkMediaDataDecoder.h b/content/media/fmp4/gonk/GonkMediaDataDecoder.h new file mode 100644 index 00000000000..76e35469abf --- /dev/null +++ b/content/media/fmp4/gonk/GonkMediaDataDecoder.h @@ -0,0 +1,92 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +#if !defined(GonkMediaDataDecoder_h_) +#define GonkMediaDataDecoder_h_ +#include "mp4_demuxer/mp4_demuxer.h" +#include "mozilla/RefPtr.h" +#include "MP4Reader.h" +#include "MediaCodecProxy.h" + +namespace mozilla { + +// Manage the data flow from inputting encoded data and outputting decode data. +class GonkDecoderManager { +public: + virtual ~GonkDecoderManager() {} + + // Creates and initializs the GonkDecoder. + // Returns nullptr on failure. + virtual android::sp Init(MediaDataDecoderCallback* aCallback) = 0; + + // Produces decoded output, it blocks until output can be produced or a timeout + // is expired or until EOS. Returns NS_OK on success, or NS_ERROR_NOT_AVAILABLE + // if there's not enough data to produce more output. If this returns a failure + // code other than NS_ERROR_NOT_AVAILABLE, an error will be reported to the + // MP4Reader. + virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) = 0; + virtual nsresult Output(int64_t aStreamOffset, + nsAutoPtr& aOutput) = 0; + +}; + +// Samples are decoded using the GonkDecoder (MediaCodec) +// created by the GonkDecoderManager. This class implements +// the higher-level logic that drives mapping the Gonk to the async +// MediaDataDecoder interface. The specifics of decoding the exact stream +// type are handled by GonkDecoderManager and the GonkDecoder it creates. +class GonkMediaDataDecoder : public MediaDataDecoder { +public: + GonkMediaDataDecoder(GonkDecoderManager* aDecoderManager, + MediaTaskQueue* aTaskQueue, + MediaDataDecoderCallback* aCallback); + + ~GonkMediaDataDecoder(); + + virtual nsresult Init() MOZ_OVERRIDE; + + virtual nsresult Input(mp4_demuxer::MP4Sample* aSample); + + virtual nsresult Flush() MOZ_OVERRIDE; + + virtual nsresult Drain() MOZ_OVERRIDE; + + virtual nsresult Shutdown() MOZ_OVERRIDE; + + virtual bool IsWaitingMediaResources() MOZ_OVERRIDE; + + virtual bool IsDormantNeeded() MOZ_OVERRIDE; + + virtual void ReleaseMediaResources() MOZ_OVERRIDE; + +private: + + // Called on the task queue. Inserts the sample into the decoder, and + // extracts output if available. + void ProcessDecode(mp4_demuxer::MP4Sample* aSample); + + // Called on the task queue. Extracts output if available, and delivers + // it to the reader. Called after ProcessDecode() and ProcessDrain(). + void ProcessOutput(); + + // Called on the task queue. Orders the Gonk to drain, and then extracts + // all available output. + void ProcessDrain(); + + RefPtr mTaskQueue; + MediaDataDecoderCallback* mCallback; + + android::sp mDecoder; + nsAutoPtr mManager; + + // The last offset into the media resource that was passed into Input(). + // This is used to approximate the decoder's position in the media resource. + int64_t mLastStreamOffset; +}; + +} // namespace mozilla + +#endif // GonkMediaDataDecoder_h_ diff --git a/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp b/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp new file mode 100644 index 00000000000..241e5fdc9e6 --- /dev/null +++ b/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp @@ -0,0 +1,456 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ +#include +#include +#include +#include "GonkVideoDecoderManager.h" +#include "MediaDecoderReader.h" +#include "ImageContainer.h" +#include "VideoUtils.h" +#include "nsThreadUtils.h" +#include "Layers.h" +#include "prlog.h" +#include "stagefright/MediaBuffer.h" +#include "stagefright/MetaData.h" +#include "stagefright/MediaErrors.h" +#include +#include +#include "mp4_demuxer/AnnexB.h" + +#define READ_OUTPUT_BUFFER_TIMEOUT_US 3000 + +#define LOG_TAG "GonkVideoDecoderManager" +#include +#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) + +#ifdef PR_LOGGING +PRLogModuleInfo* GetDemuxerLog(); +#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) +#else +#define LOG(...) +#endif +using namespace mozilla::layers; +using namespace android; +typedef android::MediaCodecProxy MediaCodecProxy; + +namespace mozilla { +enum { + kNotifyCodecReserved = 'core', + kNotifyCodecCanceled = 'coca', +}; + +GonkVideoDecoderManager::GonkVideoDecoderManager( + mozilla::layers::ImageContainer* aImageContainer, + const mp4_demuxer::VideoDecoderConfig& aConfig) + : mImageContainer(aImageContainer) + , mConfig(aConfig) + , mReaderCallback(nullptr) + , mColorConverterBufferSize(0) +{ + NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread."); + MOZ_ASSERT(mImageContainer); + MOZ_COUNT_CTOR(GonkVideoDecoderManager); + mVideoWidth = aConfig.display_width; + mVideoHeight = aConfig.display_height; + mDisplayWidth = aConfig.display_width; + mDisplayHeight = aConfig.display_width; + mInfo.mVideo.mHasVideo = true; + nsIntSize displaySize(mDisplayWidth, mDisplayHeight); + mInfo.mVideo.mDisplay = displaySize; + + nsIntRect pictureRect(0, 0, mVideoWidth, mVideoHeight); + nsIntSize frameSize(mVideoWidth, mVideoHeight); + mPicture = pictureRect; + mInitialFrame = frameSize; + mHandler = new MessageHandler(this); + mVideoListener = new VideoResourceListener(this); + +} + +GonkVideoDecoderManager::~GonkVideoDecoderManager() +{ + MOZ_COUNT_DTOR(GonkVideoDecoderManager); +} + +android::sp +GonkVideoDecoderManager::Init(MediaDataDecoderCallback* aCallback) +{ + nsIntSize displaySize(mDisplayWidth, mDisplayHeight); + nsIntRect pictureRect(0, 0, mVideoWidth, mVideoHeight); + // Validate the container-reported frame and pictureRect sizes. This ensures + // that our video frame creation code doesn't overflow. + nsIntSize frameSize(mVideoWidth, mVideoHeight); + if (!IsValidVideoRegion(frameSize, pictureRect, displaySize)) { + ALOG("It is not a valid region"); + return nullptr; + } + + mReaderCallback = aCallback; + + if (mLooper.get() != nullptr) { + return nullptr; + } + // Create ALooper + mLooper = new ALooper; + mLooper->setName("GonkVideoDecoderManager"); + // Register AMessage handler to ALooper. + mLooper->registerHandler(mHandler); + // Start ALooper thread. + if (mLooper->start() != OK) { + return nullptr; + } + mDecoder = MediaCodecProxy::CreateByType(mLooper, "video/avc", false, true, mVideoListener); + return mDecoder; +} + +nsresult +GonkVideoDecoderManager::CreateVideoData(int64_t aStreamOffset, VideoData **v) +{ + *v = nullptr; + int64_t timeUs; + int32_t keyFrame; + if (!mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { + ALOG("Decoder did not return frame time"); + return NS_ERROR_UNEXPECTED; + } + + if (!mVideoBuffer->meta_data()->findInt32(kKeyIsSyncFrame, &keyFrame)) { + keyFrame = 0; + } + + gfx::IntRect picture = ToIntRect(mPicture); + if (mFrameInfo.mWidth != mInitialFrame.width || + mFrameInfo.mHeight != mInitialFrame.height) { + + // Frame size is different from what the container reports. This is legal, + // and we will preserve the ratio of the crop rectangle as it + // was reported relative to the picture size reported by the container. + picture.x = (mPicture.x * mFrameInfo.mWidth) / mInitialFrame.width; + picture.y = (mPicture.y * mFrameInfo.mHeight) / mInitialFrame.height; + picture.width = (mFrameInfo.mWidth * mPicture.width) / mInitialFrame.width; + picture.height = (mFrameInfo.mHeight * mPicture.height) / mInitialFrame.height; + } + + if (!(mVideoBuffer != nullptr && mVideoBuffer->size() > 0 && mVideoBuffer->data() != nullptr)) { + ALOG("mVideoBuffer is not valid!"); + return NS_ERROR_UNEXPECTED; + } + + uint8_t *yuv420p_buffer = (uint8_t *)mVideoBuffer->data(); + int32_t stride = mFrameInfo.mStride; + int32_t slice_height = mFrameInfo.mSliceHeight; + + // Converts to OMX_COLOR_FormatYUV420Planar + if (mFrameInfo.mColorFormat != OMX_COLOR_FormatYUV420Planar) { + ARect crop; + crop.top = 0; + crop.bottom = mFrameInfo.mHeight; + crop.left = 0; + crop.right = mFrameInfo.mWidth; + yuv420p_buffer = GetColorConverterBuffer(mFrameInfo.mWidth, mFrameInfo.mHeight); + if (mColorConverter.convertDecoderOutputToI420(mVideoBuffer->data(), + mFrameInfo.mWidth, mFrameInfo.mHeight, crop, yuv420p_buffer) != OK) { + ReleaseVideoBuffer(); + ALOG("Color conversion failed!"); + return NS_ERROR_UNEXPECTED; + } + stride = mFrameInfo.mWidth; + slice_height = mFrameInfo.mHeight; + } + + size_t yuv420p_y_size = stride * slice_height; + size_t yuv420p_u_size = ((stride + 1) / 2) * ((slice_height + 1) / 2); + uint8_t *yuv420p_y = yuv420p_buffer; + uint8_t *yuv420p_u = yuv420p_y + yuv420p_y_size; + uint8_t *yuv420p_v = yuv420p_u + yuv420p_u_size; + + // This is the approximate byte position in the stream. + int64_t pos = aStreamOffset; + + VideoData::YCbCrBuffer b; + b.mPlanes[0].mData = yuv420p_y; + b.mPlanes[0].mWidth = mFrameInfo.mWidth; + b.mPlanes[0].mHeight = mFrameInfo.mHeight; + b.mPlanes[0].mStride = stride; + b.mPlanes[0].mOffset = 0; + b.mPlanes[0].mSkip = 0; + + b.mPlanes[1].mData = yuv420p_u; + b.mPlanes[1].mWidth = (mFrameInfo.mWidth + 1) / 2; + b.mPlanes[1].mHeight = (mFrameInfo.mHeight + 1) / 2; + b.mPlanes[1].mStride = (stride + 1) / 2; + b.mPlanes[1].mOffset = 0; + b.mPlanes[1].mSkip = 0; + + b.mPlanes[2].mData = yuv420p_v; + b.mPlanes[2].mWidth =(mFrameInfo.mWidth + 1) / 2; + b.mPlanes[2].mHeight = (mFrameInfo.mHeight + 1) / 2; + b.mPlanes[2].mStride = (stride + 1) / 2; + b.mPlanes[2].mOffset = 0; + b.mPlanes[2].mSkip = 0; + + *v = VideoData::Create( + mInfo.mVideo, + mImageContainer, + pos, + timeUs, + 1, // We don't know the duration. + b, + keyFrame, + -1, + picture); + ReleaseVideoBuffer(); + return NS_OK; +} + +bool +GonkVideoDecoderManager::SetVideoFormat() +{ + // read video metadata from MediaCodec + sp codecFormat; + if (mDecoder->getOutputFormat(&codecFormat) == OK) { + AString mime; + int32_t width = 0; + int32_t height = 0; + int32_t stride = 0; + int32_t slice_height = 0; + int32_t color_format = 0; + int32_t crop_left = 0; + int32_t crop_top = 0; + int32_t crop_right = 0; + int32_t crop_bottom = 0; + if (!codecFormat->findString("mime", &mime) || + !codecFormat->findInt32("width", &width) || + !codecFormat->findInt32("height", &height) || + !codecFormat->findInt32("stride", &stride) || + !codecFormat->findInt32("slice-height", &slice_height) || + !codecFormat->findInt32("color-format", &color_format) || + !codecFormat->findRect("crop", &crop_left, &crop_top, &crop_right, &crop_bottom)) { + ALOG("Failed to find values"); + return false; + } + mFrameInfo.mWidth = width; + mFrameInfo.mHeight = height; + mFrameInfo.mStride = stride; + mFrameInfo.mSliceHeight = slice_height; + mFrameInfo.mColorFormat = color_format; + + nsIntSize displaySize(width, height); + if (!IsValidVideoRegion(mInitialFrame, mPicture, displaySize)) { + ALOG("It is not a valid region"); + return false; + } + } + return true; +} + +// Blocks until decoded sample is produced by the deoder. +nsresult +GonkVideoDecoderManager::Output(int64_t aStreamOffset, + nsAutoPtr& aOutData) +{ + aOutData = nullptr; + status_t err; + if (mDecoder == nullptr) { + ALOG("Decoder is not inited"); + return NS_ERROR_UNEXPECTED; + } + err = mDecoder->Output(&mVideoBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US); + + switch (err) { + case OK: + { + VideoData* data = nullptr; + nsresult rv = CreateVideoData(aStreamOffset, &data); + // Frame should be non null only when we succeeded. + if (rv != NS_OK || data == nullptr){ + ALOG("Error unexpected in CreateVideoData"); + return NS_ERROR_UNEXPECTED; + } + aOutData = data; + return NS_OK; + } + case android::INFO_FORMAT_CHANGED: + case android::INFO_OUTPUT_BUFFERS_CHANGED: + { + // If the format changed, update our cached info. + ALOG("Decoder format changed"); + if (!SetVideoFormat()) { + return NS_ERROR_UNEXPECTED; + } + else + return Output(aStreamOffset, aOutData); + } + case -EAGAIN: + { + return NS_ERROR_NOT_AVAILABLE; + } + case android::ERROR_END_OF_STREAM: + { + ALOG("End of Stream"); + return NS_ERROR_ABORT; + } + case -ETIMEDOUT: + { + ALOG("Timeout. can try again next time"); + return NS_ERROR_UNEXPECTED; + } + default: + { + ALOG("Decoder failed, err=%d", err); + return NS_ERROR_UNEXPECTED; + } + } + + return NS_OK; +} + +void GonkVideoDecoderManager::ReleaseVideoBuffer() { + if (mVideoBuffer) { + sp metaData = mVideoBuffer->meta_data(); + int32_t index; + metaData->findInt32(android::MediaCodecProxy::kKeyBufferIndex, &index); + mVideoBuffer->release(); + mVideoBuffer = nullptr; + mDecoder->releaseOutputBuffer(index); + } +} + +nsresult +GonkVideoDecoderManager::Input(mp4_demuxer::MP4Sample* aSample) +{ + // We must prepare samples in AVC Annex B. + mp4_demuxer::AnnexB::ConvertSample(aSample, mConfig.annex_b); + // Forward sample data to the decoder. + + const uint8_t* data = reinterpret_cast(aSample->data); + uint32_t length = aSample->size; + if (mDecoder == nullptr) { + ALOG("Decoder is not inited"); + return NS_ERROR_UNEXPECTED; + } + status_t rv = mDecoder->Input(data, length, aSample->composition_timestamp, 0); + return (rv == OK) ? NS_OK : NS_ERROR_FAILURE; +} + +void +GonkVideoDecoderManager::codecReserved() +{ + sp format = new AMessage; + // Fixed values + format->setString("mime", "video/avc"); + format->setInt32("width", mVideoWidth); + format->setInt32("height", mVideoHeight); + + mDecoder->configure(format, nullptr, nullptr, 0); + mDecoder->Prepare(); + SetVideoFormat(); + + if (mHandler != nullptr) { + // post kNotifyCodecReserved to MediaCodecReader::mLooper thread. + sp notify = new AMessage(kNotifyCodecReserved, mHandler->id()); + notify->post(); + } +} + +void +GonkVideoDecoderManager::codecCanceled() +{ + mDecoder = nullptr; + if (mHandler != nullptr) { + // post kNotifyCodecCanceled to MediaCodecReader::mLooper thread. + sp notify = new AMessage(kNotifyCodecCanceled, mHandler->id()); + notify->post(); + } + +} + +// Called on GonkVideoDecoderManager::mLooper thread. +void +GonkVideoDecoderManager::onMessageReceived(const sp &aMessage) +{ + switch (aMessage->what()) { + case kNotifyCodecReserved: + { + // Our decode may have acquired the hardware resource that it needs + // to start. Notify the state machine to resume loading metadata. + mReaderCallback->NotifyResourcesStatusChanged(); + break; + } + + case kNotifyCodecCanceled: + { + mReaderCallback->ReleaseMediaResources(); + break; + } + + default: + TRESPASS(); + break; + } +} + +GonkVideoDecoderManager::MessageHandler::MessageHandler(GonkVideoDecoderManager *aManager) + : mManager(aManager) +{ +} + +GonkVideoDecoderManager::MessageHandler::~MessageHandler() +{ + mManager = nullptr; +} + +void +GonkVideoDecoderManager::MessageHandler::onMessageReceived(const android::sp &aMessage) +{ + if (mManager != nullptr) { + mManager->onMessageReceived(aMessage); + } +} + +GonkVideoDecoderManager::VideoResourceListener::VideoResourceListener(GonkVideoDecoderManager *aManager) + : mManager(aManager) +{ +} + +GonkVideoDecoderManager::VideoResourceListener::~VideoResourceListener() +{ + mManager = nullptr; +} + +void +GonkVideoDecoderManager::VideoResourceListener::codecReserved() +{ + if (mManager != nullptr) { + mManager->codecReserved(); + } +} + +void +GonkVideoDecoderManager::VideoResourceListener::codecCanceled() +{ + if (mManager != nullptr) { + mManager->codecCanceled(); + } +} + +uint8_t * +GonkVideoDecoderManager::GetColorConverterBuffer(int32_t aWidth, int32_t aHeight) +{ + // Allocate a temporary YUV420Planer buffer. + size_t yuv420p_y_size = aWidth * aHeight; + size_t yuv420p_u_size = ((aWidth + 1) / 2) * ((aHeight + 1) / 2); + size_t yuv420p_v_size = yuv420p_u_size; + size_t yuv420p_size = yuv420p_y_size + yuv420p_u_size + yuv420p_v_size; + if (mColorConverterBufferSize != yuv420p_size) { + mColorConverterBuffer = nullptr; // release the previous buffer first + mColorConverterBuffer = new uint8_t[yuv420p_size]; + mColorConverterBufferSize = yuv420p_size; + } + return mColorConverterBuffer.get(); +} + +} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkVideoDecoderManager.h b/content/media/fmp4/gonk/GonkVideoDecoderManager.h new file mode 100644 index 00000000000..54d2a86bb78 --- /dev/null +++ b/content/media/fmp4/gonk/GonkVideoDecoderManager.h @@ -0,0 +1,125 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim:set ts=2 sw=2 sts=2 et cindent: */ +/* 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/. */ + +#if !defined(GonkVideoDecoderManager_h_) +#define GonkVideoDecoderManager_h_ + +#include "MP4Reader.h" +#include "nsRect.h" +#include "GonkMediaDataDecoder.h" +#include "mozilla/RefPtr.h" +#include "I420ColorConverterHelper.h" + +using namespace android; +namespace mozilla { + +class GonkVideoDecoderManager : public GonkDecoderManager { +typedef android::MediaCodecProxy MediaCodecProxy; + +public: + GonkVideoDecoderManager(mozilla::layers::ImageContainer* aImageContainer, + const mp4_demuxer::VideoDecoderConfig& aConfig); + + ~GonkVideoDecoderManager(); + + virtual android::sp Init(MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; + + virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE; + + virtual nsresult Output(int64_t aStreamOffset, + nsAutoPtr& aOutput) MOZ_OVERRIDE; + +private: + struct FrameInfo + { + int32_t mWidth = 0; + int32_t mHeight = 0; + int32_t mStride = 0; + int32_t mSliceHeight = 0; + int32_t mColorFormat = 0; + int32_t mCropLeft = 0; + int32_t mCropTop = 0; + int32_t mCropRight = 0; + int32_t mCropBottom = 0; + }; + class MessageHandler : public android::AHandler + { + public: + MessageHandler(GonkVideoDecoderManager *aManager); + ~MessageHandler(); + + virtual void onMessageReceived(const android::sp &aMessage); + + private: + // Forbidden + MessageHandler() MOZ_DELETE; + MessageHandler(const MessageHandler &rhs) MOZ_DELETE; + const MessageHandler &operator=(const MessageHandler &rhs) MOZ_DELETE; + + GonkVideoDecoderManager *mManager; + }; + friend class MessageHandler; + + class VideoResourceListener : public android::MediaCodecProxy::CodecResourceListener + { + public: + VideoResourceListener(GonkVideoDecoderManager *aManager); + ~VideoResourceListener(); + + virtual void codecReserved() MOZ_OVERRIDE; + virtual void codecCanceled() MOZ_OVERRIDE; + + private: + // Forbidden + VideoResourceListener() MOZ_DELETE; + VideoResourceListener(const VideoResourceListener &rhs) MOZ_DELETE; + const VideoResourceListener &operator=(const VideoResourceListener &rhs) MOZ_DELETE; + + GonkVideoDecoderManager *mManager; + }; + friend class VideoResourceListener; + + bool SetVideoFormat(); + + nsresult CreateVideoData(int64_t aStreamOffset, VideoData** aOutData); + void ReleaseVideoBuffer(); + uint8_t* GetColorConverterBuffer(int32_t aWidth, int32_t aHeight); + + // For codec resource management + void codecReserved(); + void codecCanceled(); + void onMessageReceived(const sp &aMessage); + + const mp4_demuxer::VideoDecoderConfig& mConfig; + uint32_t mVideoWidth; + uint32_t mVideoHeight; + uint32_t mDisplayWidth; + uint32_t mDisplayHeight; + nsIntRect mPicture; + nsIntSize mInitialFrame; + + android::sp mDecoder; + nsRefPtr mImageContainer; + MediaDataDecoderCallback* mCallback; + + android::MediaBuffer* mVideoBuffer; + + MediaDataDecoderCallback* mReaderCallback; + MediaInfo mInfo; + android::sp mVideoListener; + android::sp mHandler; + android::sp mLooper; + FrameInfo mFrameInfo; + + // color converter + android::I420ColorConverterHelper mColorConverter; + nsAutoArrayPtr mColorConverterBuffer; + size_t mColorConverterBufferSize; +}; + +} // namespace mozilla + +#endif // GonkVideoDecoderManager_h_ diff --git a/content/media/fmp4/gonk/moz.build b/content/media/fmp4/gonk/moz.build new file mode 100644 index 00000000000..c936fbadc54 --- /dev/null +++ b/content/media/fmp4/gonk/moz.build @@ -0,0 +1,32 @@ +# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- +# vim: set filetype=python: +# 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/. + +EXPORTS += [ + 'GonkAudioDecoderManager.h', + 'GonkDecoderModule.h', + 'GonkMediaDataDecoder.h', + 'GonkVideoDecoderManager.h', +] +UNIFIED_SOURCES += [ + 'GonkAudioDecoderManager.cpp', + 'GonkDecoderModule.cpp', + 'GonkMediaDataDecoder.cpp', + 'GonkVideoDecoderManager.cpp', +] +LOCAL_INCLUDES += [ + '/content/media/omx/', + '/content/media/omx/mediaresourcemanager', +] +include('/ipc/chromium/chromium-config.mozbuild') + +FINAL_LIBRARY = 'xul' + +FAIL_ON_WARNINGS = True + +CXXFLAGS += [ + '-I%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [ + 'frameworks/native/opengl/include',] +] From e6f0efb45a208278e27ff8bfd9d925e20d2b89a7 Mon Sep 17 00:00:00 2001 From: Krzysztof Mioduszewski Date: Wed, 6 Aug 2014 01:17:00 -0400 Subject: [PATCH 24/49] Bug 1042651 - B2G NFC: getNFCPeer and getNFCTag should not throw. r=smaug, r=allstars.chh --- dom/nfc/nsNfc.js | 6 ++-- dom/nfc/tests/marionette/test_nfc_peer.js | 35 ++++++++++++++--------- dom/webidl/MozNFC.webidl | 13 ++++++--- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/dom/nfc/nsNfc.js b/dom/nfc/nsNfc.js index 668d6baf6c4..ca1a16b3598 100644 --- a/dom/nfc/nsNfc.js +++ b/dom/nfc/nsNfc.js @@ -200,14 +200,12 @@ mozNfc.prototype = { if (this._nfcContentHelper.setSessionToken(sessionToken)) { return this._window.MozNFCTag._create(this._window, obj); } - throw new Error("Unable to create NFCTag object, Reason: Bad SessionToken " + - sessionToken); + return null; }, getNFCPeer: function getNFCPeer(sessionToken) { if (!sessionToken || !this._nfcContentHelper.setSessionToken(sessionToken)) { - throw new Error("Unable to create NFCPeer object, Reason: Bad SessionToken " + - sessionToken); + return null; } if (!this.nfcObject) { diff --git a/dom/nfc/tests/marionette/test_nfc_peer.js b/dom/nfc/tests/marionette/test_nfc_peer.js index 62ecf5ccb10..7cfba0e24cb 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer.js +++ b/dom/nfc/tests/marionette/test_nfc_peer.js @@ -85,18 +85,6 @@ function testCheckP2PRegFailure() { toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0)); } -function testCheckNfcPeerObjForInvalidToken() { - try { - // Use a'fakeSessionToken' - let peer = nfc.getNFCPeer("fakeSessionToken"); - ok(false, "Should not get a NFCPeer object."); - } catch (ex) { - ok(true, "Exception expected"); - } - - toggleNFC(false).then(runNextTest); -} - function testPeerLostShouldNotBeCalled() { nfc.onpeerlost = function () { ok(false, "onpeerlost shouldn't be called"); @@ -151,12 +139,31 @@ function testPeerShouldThrow() { toggleNFC(false).then(runNextTest); } +function testPeerInvalidToken() { + let peer = nfc.getNFCPeer("fakeSessionToken"); + is(peer, null, "NFCPeer should be null on wrong session token"); + + runNextTest(); +} + +/** + * Added for completeness in Bug 1042651, + * TODO: remove once Bug 963531 lands + */ +function testTagInvalidToken() { + let tag = nfc.getNFCTag("fakeSessionToken"); + is(tag, null, "NFCTag should be null on wrong session token"); + + runNextTest(); +} + let tests = [ testPeerReady, testCheckP2PRegFailure, - testCheckNfcPeerObjForInvalidToken, testPeerLostShouldNotBeCalled, - testPeerShouldThrow + testPeerShouldThrow, + testPeerInvalidToken, + testTagInvalidToken ]; SpecialPowers.pushPermissions( diff --git a/dom/webidl/MozNFC.webidl b/dom/webidl/MozNFC.webidl index 770644fef1f..aead123fc10 100644 --- a/dom/webidl/MozNFC.webidl +++ b/dom/webidl/MozNFC.webidl @@ -46,10 +46,15 @@ interface MozNFCManager { NavigatorProperty="mozNfc", Func="Navigator::HasNFCSupport"] interface MozNFC : EventTarget { - [Throws] - MozNFCTag getNFCTag(DOMString sessionId); - [Throws] - MozNFCPeer getNFCPeer(DOMString sessionId); + /** + * Returns MozNFCTag object or null in case of invalid sessionToken + */ + MozNFCTag? getNFCTag(DOMString sessionToken); + + /** + * Returns MozNFCPeer object or null in case of invalid sessionToken + */ + MozNFCPeer? getNFCPeer(DOMString sessionToken); /** * This event will be fired when another NFCPeer is detected, and user confirms From 4bf3238df2809cfe4f1f4fb38f445d3c3d6a1930 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:45:40 -0700 Subject: [PATCH 25/49] Bumping gaia.json for 6 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/d3338ca9a7f9 Author: Ryan VanderMeulen Desc: Merge pull request #22399 from tauzen/Bug1042651 B2G NFC: getNFCPeer and getNFCTag should not throw error, r=alive ======== https://hg.mozilla.org/integration/gaia-central/rev/e0f585c33ae8 Author: Krzysztof Mioduszewski Desc: B2G NFC: getNFCPeer and getNFCTag should not throw error, r=alive ======== https://hg.mozilla.org/integration/gaia-central/rev/9939b489aecc Author: Ryan VanderMeulen Desc: Merge pull request #22519 from tauzen/Bug1047263 Bug 1047263 - Marionnette web-api tests on emulator-jb fail with "TypeError: apns is undefined", r=arthur.chen ======== https://hg.mozilla.org/integration/gaia-central/rev/60632664a6fc Author: Krzysztof Mioduszewski Desc: Bug 1047263 - Marionnette web-api tests on emulator-jb fail with "TypeError: apns is undefined", r=arthurcc ======== https://hg.mozilla.org/integration/gaia-central/rev/bcea11cb8964 Author: Ryan VanderMeulen Desc: Merge pull request #22413 from guilherme-pg/bug1037232-unverified Bug 1037232 - Display an error message for unverified accounts. r=arthur... ======== https://hg.mozilla.org/integration/gaia-central/rev/768ba55bb23e Author: Guilherme Goncalves Desc: Bug 1037232 - Display an error message for unverified accounts. r=arthurcc --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 6b7e0c6808e..30dd8e2d084 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "1edc393a4af0a61f6633087d9868eff5dd52ce35", + "revision": "d3338ca9a7f9ac85c699b012a6fa1f75607355ae", "repo_path": "/integration/gaia-central" } From bfc99c27a96d026631eee9be09e6aefd714736eb Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 05:51:34 -0700 Subject: [PATCH 26/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 4 ++-- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 2d3e08b3ebf..f902764b622 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 713c9ba9a3b..e552cd90d75 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 51efb698bbe..09a25de2cdf 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 2d3e08b3ebf..f902764b622 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 67f8aeef2e1..48a388a8f43 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + @@ -122,7 +122,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 6c4dde9f0cc..47f976d6c9c 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 72b7eadbea4..4bbaf79f923 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 07aadfc8c61..380dc648a9d 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 610db2dbb9b..7b07b7cb0d3 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From fd7b09d71533e2265c8453b204508518fcd849e0 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 06:25:26 -0700 Subject: [PATCH 27/49] Bumping gaia.json for 6 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/a7f08415f2dc Author: Yoshi Huang Desc: Merge pull request #22394 from allstarschh/Bug1046554 Bug1046554 - B2G NFC: pass NFCPeerEvent in onpeerready. r=johu, dkuo, punam, francisco, daleharvey. ======== https://hg.mozilla.org/integration/gaia-central/rev/12b7fb3d3e03 Author: Yoshi Huang Desc: Bug 1046554 - Part 5: Contacts app change. ======== https://hg.mozilla.org/integration/gaia-central/rev/4879e5a9f1b1 Author: Yoshi Huang Desc: Bug 1046554 - Part 4: Browser app change ======== https://hg.mozilla.org/integration/gaia-central/rev/634ebfbade08 Author: Yoshi Huang Desc: Bug 1046554 - Part 3: Music app change ======== https://hg.mozilla.org/integration/gaia-central/rev/15a0a4b70a6a Author: Yoshi Huang Desc: Bug 1046554 - Part 2: Video app change. ======== https://hg.mozilla.org/integration/gaia-central/rev/431cdd4e81ab Author: Yoshi Huang Desc: Bug 1046554 - Part 1: Gallery change. --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 30dd8e2d084..e9d46cb0daf 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "d3338ca9a7f9ac85c699b012a6fa1f75607355ae", + "revision": "a7f08415f2dce053abf20e45599ae951eda2f126", "repo_path": "/integration/gaia-central" } From 31df978485b2489521ab6c45cbb595ec219fdb5c Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 06:31:24 -0700 Subject: [PATCH 28/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index f902764b622..eccd675dd69 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index e552cd90d75..6a364a36f96 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 09a25de2cdf..ce731c4c81c 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index f902764b622..eccd675dd69 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 48a388a8f43..dfcbaaf5724 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 47f976d6c9c..afbef3a1bb7 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 4bbaf79f923..0644209b34d 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 380dc648a9d..dde53e6bcfb 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 7b07b7cb0d3..de3e43c05c2 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 04f4c12a1294499dbf0d597bbb0bb73beaae89b5 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:10:25 -0700 Subject: [PATCH 29/49] Bumping gaia.json for 6 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/ac620baf3886 Author: Kevin Grandon Desc: Merge pull request #22530 from KevinGrandon/bug_1048991_rocketbar_home_handling Bug 1048991 - Home button on search screen should take you back to homescreen ======== https://hg.mozilla.org/integration/gaia-central/rev/7f065fa1403e Author: Kevin Grandon Desc: Bug 1048991 - Home button on search screen should take you back to homescreen r=arcturus ======== https://hg.mozilla.org/integration/gaia-central/rev/2c759a65311b Author: Kevin Grandon Desc: Merge pull request #22538 from KevinGrandon/bug_1049154_search_home_screen_naming Bug 1049154 - [Search] Home screen naming consistency ======== https://hg.mozilla.org/integration/gaia-central/rev/5a80457d4ce4 Author: Kevin Grandon Desc: Bug 1049154 - [Search] Home screen naming consistency r=amirn ======== https://hg.mozilla.org/integration/gaia-central/rev/32ed163c3856 Author: Kevin Grandon Desc: Merge pull request #22537 from KevinGrandon/bug_1049154_collection_home_screen_naming Bug 1049154 - [Collection App] Home screen naming consistency ======== https://hg.mozilla.org/integration/gaia-central/rev/6d25e1e8c417 Author: Kevin Grandon Desc: Bug 1049154 - [Collection App] Home screen naming consistency r=amirn --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index e9d46cb0daf..80bb29cad0d 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "a7f08415f2dce053abf20e45599ae951eda2f126", + "revision": "ac620baf38865a64ffdf316790be67d2297718d4", "repo_path": "/integration/gaia-central" } From 0401de79b1a670c7b94a27a089e1e503bb3765e9 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:12:30 -0700 Subject: [PATCH 30/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index eccd675dd69..86a48013459 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 6a364a36f96..b0aa4261efc 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index ce731c4c81c..a46c9bf7405 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index eccd675dd69..86a48013459 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index dfcbaaf5724..2579c0c5567 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index afbef3a1bb7..2f78df9aaba 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 0644209b34d..1d34dd99a0c 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index dde53e6bcfb..7f1f5bf5f4b 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index de3e43c05c2..dc79111724c 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 2d686df88d2b26b825e3fa1c6fa659c5d2cda294 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:20:31 -0700 Subject: [PATCH 31/49] Bumping gaia.json for 4 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/e4ab19024fdb Author: Kevin Grandon Desc: Merge pull request #22579 from mozilla-b2g/revert-22394-Bug1046554 Revert "Bug1046554 - B2G NFC: pass NFCPeerEvent in onpeerready" ======== https://hg.mozilla.org/integration/gaia-central/rev/f1bb1338b084 Author: Kevin Grandon Desc: Revert "Bug1046554 - B2G NFC: pass NFCPeerEvent in onpeerready" ======== https://hg.mozilla.org/integration/gaia-central/rev/c7e57d826840 Author: Kevin Grandon Desc: Revert "Bug 1046554 - Follow-up, fix linter issues r=me" This reverts commit 25701a4f9fc4bd1d1dc4a1d4bedfe66ee8c94502. ======== https://hg.mozilla.org/integration/gaia-central/rev/970179885d4a Author: Kevin Grandon Desc: Bug 1046554 - Follow-up, fix linter issues r=me --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 80bb29cad0d..3dc7b5b9e2c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "ac620baf38865a64ffdf316790be67d2297718d4", + "revision": "e4ab19024fdb3b126bef28f7b9d46d539bbc2482", "repo_path": "/integration/gaia-central" } From 8a343d87d5dc3b3ab8f320e01b1cab604285de1a Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:27:33 -0700 Subject: [PATCH 32/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 86a48013459..7a1baa06a9c 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index b0aa4261efc..5a67eed4496 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index a46c9bf7405..6947e03f979 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 86a48013459..7a1baa06a9c 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 2579c0c5567..0c7ce7c3e65 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 2f78df9aaba..f28c0952040 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 1d34dd99a0c..8eee7d79cf1 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 7f1f5bf5f4b..4ebb7d5e9dd 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index dc79111724c..7bee1ad23e0 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 1950fdec826bfd41d57b9349a23a7832590d162c Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:50:33 -0700 Subject: [PATCH 33/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/20cccc8cefa6 Author: Kevin Grandon Desc: Merge pull request #22436 from KevinGrandon/bug_1045701_smart_collection_icon_build_master Bug 1045701 - Part 1 [Collection App] - Use proper icon regardless of device size ======== https://hg.mozilla.org/integration/gaia-central/rev/ffcac71067d3 Author: Kevin Grandon Desc: Bug 1045701 - Part 1 [Collection App] - Use proper icon regardless of device size r=yurenju --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 3dc7b5b9e2c..f867dfb83bf 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "e4ab19024fdb3b126bef28f7b9d46d539bbc2482", + "revision": "20cccc8cefa6a587fd36e4c1f7d65b2dffbe02fd", "repo_path": "/integration/gaia-central" } From aa504bcee52cb7c5e2205a275f1befd42ee9bfb9 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 08:58:15 -0700 Subject: [PATCH 34/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 7a1baa06a9c..f7cd30081fa 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 5a67eed4496..218085b433a 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 6947e03f979..6a4188f9d06 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 7a1baa06a9c..f7cd30081fa 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 0c7ce7c3e65..af0598936ae 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index f28c0952040..e0e56cc14ce 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 8eee7d79cf1..9d880973fb8 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 4ebb7d5e9dd..6773adf159f 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 7bee1ad23e0..d16e2e53d93 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 2fb6a472ac0387b3d511b69d03f596f1730b9be0 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 09:35:28 -0700 Subject: [PATCH 35/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/417937307d7d Author: vingtetun <21@vingtetun.org> Desc: Merge pull request #16432 from heycam/typo Bug 974228 - Fix typo in name of Icon.savePosition. ======== https://hg.mozilla.org/integration/gaia-central/rev/279fc0bbf08d Author: Cameron McCormack Desc: Bug 974228 - Fix typo in name of Icon.savePosition. r=21 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index f867dfb83bf..0f11ef84a10 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "20cccc8cefa6a587fd36e4c1f7d65b2dffbe02fd", + "revision": "417937307d7d6340d71d5542f44f4e4f09a8bd0b", "repo_path": "/integration/gaia-central" } From ebfd9e1ebfa284c3810eec167d72bbe2afbe6dc4 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 09:42:18 -0700 Subject: [PATCH 36/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index f7cd30081fa..ae7df2cd277 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 218085b433a..0b1b64a905a 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 6a4188f9d06..1becdad1c77 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index f7cd30081fa..ae7df2cd277 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index af0598936ae..cc4b3764401 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index e0e56cc14ce..a24e5900dff 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 9d880973fb8..d68be10c3af 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 6773adf159f..9d42c453606 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index d16e2e53d93..a7de2a2eabb 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 00dac32040d2e8dc8a1227bfa899a38d31d38fb1 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 6 Aug 2014 12:41:05 -0400 Subject: [PATCH 37/49] Bug 1042959 - Ensure that we always use the actual old screen size in HandlePossibleViewportChange. r=botond --- dom/ipc/TabChild.cpp | 26 +++++++++++++++++++------- dom/ipc/TabChild.h | 2 +- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/dom/ipc/TabChild.cpp b/dom/ipc/TabChild.cpp index 3d617c8abfe..f7e51bf67b9 100644 --- a/dom/ipc/TabChild.cpp +++ b/dom/ipc/TabChild.cpp @@ -78,6 +78,7 @@ #include "mozilla/gfx/Matrix.h" #include "UnitTransforms.h" #include "ClientLayerManager.h" +#include "LayersLogging.h" #include "nsColorPickerProxy.h" @@ -88,6 +89,9 @@ #define BROWSER_ELEMENT_CHILD_SCRIPT \ NS_LITERAL_STRING("chrome://global/content/BrowserElementChild.js") +#define TABC_LOG(...) +// #define TABC_LOG(...) printf_stderr("TABC: " __VA_ARGS__) + using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::ipc; @@ -174,12 +178,16 @@ TabChildBase::InitializeRootMetrics() // as the resolution. mLastRootMetrics.mResolution = mLastRootMetrics.mCumulativeResolution / LayoutDeviceToParentLayerScale(1); mLastRootMetrics.SetScrollOffset(CSSPoint(0, 0)); + + TABC_LOG("After InitializeRootMetrics, mLastRootMetrics is %s\n", + Stringify(mLastRootMetrics).c_str()); } void TabChildBase::SetCSSViewport(const CSSSize& aSize) { mOldViewportSize = aSize; + TABC_LOG("Setting CSS viewport to %s\n", Stringify(aSize).c_str()); if (mContentDocumentIsDisplayed) { nsCOMPtr utils(GetDOMWindowUtils()); @@ -213,12 +221,15 @@ TabChildBase::GetPageSize(nsCOMPtr aDocument, const CSSSize& aViewp } bool -TabChildBase::HandlePossibleViewportChange() +TabChildBase::HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize) { if (!IsAsyncPanZoomEnabled()) { return false; } + TABC_LOG("HandlePossibleViewportChange aOldScreenSize=%s mInnerSize=%s\n", + Stringify(aOldScreenSize).c_str(), Stringify(mInnerSize).c_str()); + nsCOMPtr document(GetDocument()); nsCOMPtr utils(GetDOMWindowUtils()); @@ -249,6 +260,8 @@ TabChildBase::HandlePossibleViewportChange() return false; } + TABC_LOG("HandlePossibleViewportChange mOldViewportSize=%s viewport=%s\n", + Stringify(mOldViewportSize).c_str(), Stringify(viewport).c_str()); CSSSize oldBrowserSize = mOldViewportSize; mLastRootMetrics.mViewport.SizeTo(viewport); if (oldBrowserSize == CSSSize()) { @@ -269,9 +282,7 @@ TabChildBase::HandlePossibleViewportChange() return false; } - ScreenIntSize oldScreenSize = ViewAs( - RoundedToInt(mLastRootMetrics.mCompositionBounds).Size(), - PixelCastJustification::ScreenToParentLayerForRoot); + ScreenIntSize oldScreenSize = aOldScreenSize; if (oldScreenSize == ScreenIntSize()) { oldScreenSize = mInnerSize; } @@ -748,7 +759,7 @@ TabChild::HandleEvent(nsIDOMEvent* aEvent) if (eventType.EqualsLiteral("DOMMetaAdded")) { // This meta data may or may not have been a meta viewport tag. If it was, // we should handle it immediately. - HandlePossibleViewportChange(); + HandlePossibleViewportChange(mInnerSize); } return NS_OK; @@ -799,7 +810,7 @@ TabChild::Observe(nsISupports *aSubject, InitializeRootMetrics(); utils->SetResolution(mLastRootMetrics.mResolution.scale, mLastRootMetrics.mResolution.scale); - HandlePossibleViewportChange(); + HandlePossibleViewportChange(mInnerSize); } } } @@ -1750,6 +1761,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const } mOrientation = orientation; + ScreenIntSize oldScreenSize = mInnerSize; mInnerSize = ScreenIntSize::FromUnknownSize( gfx::IntSize(size.width, size.height)); mWidget->Resize(0, 0, size.width, size.height, @@ -1767,7 +1779,7 @@ TabChild::RecvUpdateDimensions(const nsRect& rect, const nsIntSize& size, const InitializeRootMetrics(); } - HandlePossibleViewportChange(); + HandlePossibleViewportChange(oldScreenSize); return true; } diff --git a/dom/ipc/TabChild.h b/dom/ipc/TabChild.h index 1a0a78ae08b..35447c3a197 100644 --- a/dom/ipc/TabChild.h +++ b/dom/ipc/TabChild.h @@ -178,7 +178,7 @@ public: // viewport data on a document may have changed. If it didn't // change, this function doesn't do anything. However, it should // not be called all the time as it is fairly expensive. - bool HandlePossibleViewportChange(); + bool HandlePossibleViewportChange(const ScreenIntSize& aOldScreenSize); virtual bool DoUpdateZoomConstraints(const uint32_t& aPresShellId, const mozilla::layers::FrameMetrics::ViewID& aViewId, const bool& aIsRoot, From e87bda79bd09a84188cefd0791208be543cef35c Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 6 Aug 2014 12:54:17 -0400 Subject: [PATCH 38/49] Backed out 5 changesets (bug 941302) for non-unified bustage. a=backout Backed out changeset 73cfc50bcd37 (bug 941302) Backed out changeset 13efa442f3bd (bug 941302) Backed out changeset 6cf06baf92e1 (bug 941302) Backed out changeset 0ee6c16041e0 (bug 941302) Backed out changeset 2bc3c5dfbe97 (bug 941302) --- b2g/app/b2g.js | 5 +- configure.in | 9 +- content/media/fmp4/MP4Decoder.cpp | 7 - content/media/fmp4/MP4Reader.cpp | 56 +-- content/media/fmp4/MP4Reader.h | 12 - content/media/fmp4/PlatformDecoderModule.cpp | 14 - content/media/fmp4/PlatformDecoderModule.h | 14 - .../fmp4/gonk/GonkAudioDecoderManager.cpp | 197 -------- .../media/fmp4/gonk/GonkAudioDecoderManager.h | 51 -- content/media/fmp4/gonk/GonkDecoderModule.cpp | 61 --- content/media/fmp4/gonk/GonkDecoderModule.h | 41 -- .../media/fmp4/gonk/GonkMediaDataDecoder.cpp | 154 ------ .../media/fmp4/gonk/GonkMediaDataDecoder.h | 92 ---- .../fmp4/gonk/GonkVideoDecoderManager.cpp | 456 ------------------ .../media/fmp4/gonk/GonkVideoDecoderManager.h | 125 ----- content/media/fmp4/gonk/moz.build | 32 -- content/media/fmp4/moz.build | 4 - content/media/omx/MediaCodecProxy.cpp | 114 +---- content/media/omx/MediaCodecProxy.h | 22 +- .../binding/include/mp4_demuxer/DecoderData.h | 2 +- 20 files changed, 11 insertions(+), 1457 deletions(-) delete mode 100644 content/media/fmp4/gonk/GonkAudioDecoderManager.cpp delete mode 100644 content/media/fmp4/gonk/GonkAudioDecoderManager.h delete mode 100644 content/media/fmp4/gonk/GonkDecoderModule.cpp delete mode 100644 content/media/fmp4/gonk/GonkDecoderModule.h delete mode 100644 content/media/fmp4/gonk/GonkMediaDataDecoder.cpp delete mode 100644 content/media/fmp4/gonk/GonkMediaDataDecoder.h delete mode 100644 content/media/fmp4/gonk/GonkVideoDecoderManager.cpp delete mode 100644 content/media/fmp4/gonk/GonkVideoDecoderManager.h delete mode 100644 content/media/fmp4/gonk/moz.build diff --git a/b2g/app/b2g.js b/b2g/app/b2g.js index 4505b1b9091..9e46b6dcc3e 100644 --- a/b2g/app/b2g.js +++ b/b2g/app/b2g.js @@ -309,10 +309,7 @@ pref("dom.indexedDB.warningQuota", 5); pref("media.preload.default", 1); // default to preload none pref("media.preload.auto", 2); // preload metadata if preload=auto pref("media.cache_size", 4096); // 4MB media cache -#ifdef MOZ_FMP4 -// Enable/Disable Gonk Decoder Module -pref("media.fragmented-mp4.gonk.enabled", false); -#endif + // The default number of decoded video frames that are enqueued in // MediaDecoderReader's mVideoQueue. pref("media.video-queue.default-size", 3); diff --git a/configure.in b/configure.in index 9b8b1ba4896..ac2909ad176 100644 --- a/configure.in +++ b/configure.in @@ -261,7 +261,6 @@ if test -n "$gonkdir" ; then MOZ_OMX_ENCODER=1 AC_SUBST(MOZ_OMX_ENCODER) AC_DEFINE(MOZ_OMX_ENCODER) - MOZ_FMP4=1 ;; 19) GONK_INCLUDES="-I$gonkdir/frameworks/native/include -I$gonkdir/frameworks/av/include -I$gonkdir/frameworks/av/include/media -I$gonkdir/frameworks/av/include/camera -I$gonkdir/frameworks/native/include/media/openmax -I$gonkdir/frameworks/av/media/libstagefright/include" @@ -276,7 +275,7 @@ if test -n "$gonkdir" ; then MOZ_AUDIO_OFFLOAD=1 AC_SUBST(MOZ_AUDIO_OFFLOAD) AC_DEFINE(MOZ_AUDIO_OFFLOAD) - MOZ_FMP4=1 + ;; *) AC_MSG_ERROR([Unsupported platform version: $ANDROID_VERSION]) @@ -3776,11 +3775,7 @@ MOZ_WEBM=1 MOZ_GSTREAMER= MOZ_DIRECTSHOW= MOZ_WMF= -if test -n "$MOZ_FMP4"; then - MOZ_FMP4=1 -else - MOZ_FMP4 = -fi +MOZ_FMP4= MOZ_EME=1 MOZ_FFMPEG= MOZ_WEBRTC=1 diff --git a/content/media/fmp4/MP4Decoder.cpp b/content/media/fmp4/MP4Decoder.cpp index 1040cef5a64..e5acefa77e7 100644 --- a/content/media/fmp4/MP4Decoder.cpp +++ b/content/media/fmp4/MP4Decoder.cpp @@ -131,12 +131,6 @@ IsAppleAvailable() #endif } -static bool -IsGonkMP4DecoderAvailable() -{ - return Preferences::GetBool("media.fragmented-mp4.gonk.enabled", false); -} - static bool HavePlatformMPEGDecoders() { @@ -147,7 +141,6 @@ HavePlatformMPEGDecoders() #endif IsFFmpegAvailable() || IsAppleAvailable() || - IsGonkMP4DecoderAvailable() || // TODO: Other platforms... false; } diff --git a/content/media/fmp4/MP4Reader.cpp b/content/media/fmp4/MP4Reader.cpp index b3e60771e8e..69a91ec1949 100644 --- a/content/media/fmp4/MP4Reader.cpp +++ b/content/media/fmp4/MP4Reader.cpp @@ -230,14 +230,8 @@ private: nsString mInitDataType; }; -bool MP4Reader::IsWaitingOnCodecResource() { -#ifdef MOZ_GONK_MEDIACODEC - return mVideo.mDecoder && mVideo.mDecoder->IsWaitingMediaResources(); -#endif - return false; -} - -bool MP4Reader::IsWaitingOnCDMResource() { +bool MP4Reader::IsWaitingMediaResources() +{ nsRefPtr proxy; { ReentrantMonitorAutoEnter mon(mDecoder->GetReentrantMonitor()); @@ -259,15 +253,6 @@ bool MP4Reader::IsWaitingOnCDMResource() { } } -bool MP4Reader::IsWaitingMediaResources() -{ - // IsWaitingOnCDMResource() *must* come first, because we don't know whether - // we can create a decoder until the CDM is initialized and it has told us - // whether *it* will decode, or whether we need to create a PDM to do the - // decoding - return IsWaitingOnCDMResource() || IsWaitingOnCodecResource(); -} - void MP4Reader::ExtractCryptoInitData(nsTArray& aInitData) { @@ -309,12 +294,7 @@ MP4Reader::ReadMetadata(MediaInfo* aInfo, // an encrypted stream and we need to wait for a CDM to be set, we don't // need to reinit the demuxer. mDemuxerInitialized = true; - } else if (mPlatform && !IsWaitingMediaResources()) { - *aInfo = mInfo; - *aTags = nullptr; - return NS_OK; } - if (mDemuxer->Crypto().valid) { if (!sIsEMEEnabled) { // TODO: Need to signal DRM/EME required somehow... @@ -755,36 +735,4 @@ MP4Reader::GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) return NS_OK; } -bool MP4Reader::IsDormantNeeded() -{ -#ifdef MOZ_GONK_MEDIACODEC - return mVideo.mDecoder && mVideo.mDecoder->IsDormantNeeded(); -#endif - return false; -} - -void MP4Reader::ReleaseMediaResources() -{ -#ifdef MOZ_GONK_MEDIACODEC - // Before freeing a video codec, all video buffers needed to be released - // even from graphics pipeline. - VideoFrameContainer* container = mDecoder->GetVideoFrameContainer(); - if (container) { - container->ClearCurrentFrame(); - } - if (mVideo.mDecoder) { - mVideo.mDecoder->ReleaseMediaResources(); - } -#endif -} - -void MP4Reader::NotifyResourcesStatusChanged() -{ -#ifdef MOZ_GONK_MEDIACODEC - if (mDecoder) { - mDecoder->NotifyWaitingForResourcesStatusChanged(); - } -#endif -} - } // namespace mozilla diff --git a/content/media/fmp4/MP4Reader.h b/content/media/fmp4/MP4Reader.h index 2e6fbb10a7f..7045c68272a 100644 --- a/content/media/fmp4/MP4Reader.h +++ b/content/media/fmp4/MP4Reader.h @@ -59,10 +59,7 @@ public: virtual nsresult GetBuffered(dom::TimeRanges* aBuffered, int64_t aStartTime) MOZ_OVERRIDE; - // For Media Resource Management virtual bool IsWaitingMediaResources() MOZ_OVERRIDE; - virtual bool IsDormantNeeded() MOZ_OVERRIDE; - virtual void ReleaseMediaResources() MOZ_OVERRIDE; virtual nsresult ResetDecode() MOZ_OVERRIDE; @@ -87,9 +84,6 @@ private: bool Decode(mp4_demuxer::TrackType aTrack); void Flush(mp4_demuxer::TrackType aTrack); void DrainComplete(mp4_demuxer::TrackType aTrack); - void NotifyResourcesStatusChanged(); - bool IsWaitingOnCodecResource(); - bool IsWaitingOnCDMResource(); nsAutoPtr mDemuxer; nsAutoPtr mPlatform; @@ -114,12 +108,6 @@ private: virtual void DrainComplete() MOZ_OVERRIDE { mReader->DrainComplete(mType); } - virtual void NotifyResourcesStatusChanged() MOZ_OVERRIDE { - mReader->NotifyResourcesStatusChanged(); - } - virtual void ReleaseMediaResources() MOZ_OVERRIDE { - mReader->ReleaseMediaResources(); - } private: MP4Reader* mReader; mp4_demuxer::TrackType mType; diff --git a/content/media/fmp4/PlatformDecoderModule.cpp b/content/media/fmp4/PlatformDecoderModule.cpp index 846bce6c6a2..3acffc29a30 100644 --- a/content/media/fmp4/PlatformDecoderModule.cpp +++ b/content/media/fmp4/PlatformDecoderModule.cpp @@ -14,10 +14,6 @@ #ifdef MOZ_APPLEMEDIA #include "AppleDecoderModule.h" #endif -#ifdef MOZ_GONK_MEDIACODEC -#include "GonkDecoderModule.h" -#endif - #include "mozilla/Preferences.h" #include "EMEDecoderModule.h" #include "mozilla/CDMProxy.h" @@ -30,7 +26,6 @@ extern PlatformDecoderModule* CreateBlankDecoderModule(); bool PlatformDecoderModule::sUseBlankDecoder = false; bool PlatformDecoderModule::sFFmpegDecoderEnabled = false; -bool PlatformDecoderModule::sGonkDecoderEnabled = false; /* static */ void @@ -47,10 +42,6 @@ PlatformDecoderModule::Init() "media.fragmented-mp4.use-blank-decoder"); Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled, "media.fragmented-mp4.ffmpeg.enabled", false); -#ifdef MOZ_GONK_MEDIACODEC - Preferences::AddBoolVarCache(&sGonkDecoderEnabled, - "media.fragmented-mp4.gonk.enabled", false); -#endif #ifdef XP_WIN WMFDecoderModule::Init(); #endif @@ -137,11 +128,6 @@ PlatformDecoderModule::Create() if (NS_SUCCEEDED(m->Startup())) { return m.forget(); } -#endif -#ifdef MOZ_GONK_MEDIACODEC - if (sGonkDecoderEnabled) { - return new GonkDecoderModule(); - } #endif return nullptr; } diff --git a/content/media/fmp4/PlatformDecoderModule.h b/content/media/fmp4/PlatformDecoderModule.h index 90ebfba8024..7f4f85b09f8 100644 --- a/content/media/fmp4/PlatformDecoderModule.h +++ b/content/media/fmp4/PlatformDecoderModule.h @@ -123,7 +123,6 @@ protected: // Caches pref media.fragmented-mp4.use-blank-decoder static bool sUseBlankDecoder; static bool sFFmpegDecoderEnabled; - static bool sGonkDecoderEnabled; }; // A callback used by MediaDataDecoder to return output/errors to the @@ -145,10 +144,6 @@ public: virtual void InputExhausted() = 0; virtual void DrainComplete() = 0; - - virtual void NotifyResourcesStatusChanged() {}; - - virtual void ReleaseMediaResources() {}; }; // MediaDataDecoder is the interface exposed by decoders created by the @@ -214,15 +209,6 @@ public: // returned. virtual nsresult Shutdown() = 0; - // For Codec Resource Management - virtual bool IsWaitingMediaResources() { - return false; - }; - virtual bool IsDormantNeeded() { - return false; - }; - virtual void ReleaseMediaResources() {}; - virtual void ReleaseDecoder() {}; }; } // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp b/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp deleted file mode 100644 index 6192d489959..00000000000 --- a/content/media/fmp4/gonk/GonkAudioDecoderManager.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ - -#include "GonkAudioDecoderManager.h" -#include "MediaDecoderReader.h" -#include "VideoUtils.h" -#include "nsTArray.h" -#include "prlog.h" -#include "stagefright/MediaBuffer.h" -#include "stagefright/MetaData.h" -#include "stagefright/MediaErrors.h" -#include -#include "media/openmax/OMX_Audio.h" - -#define LOG_TAG "GonkAudioDecoderManager" -#include -#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) - -#ifdef PR_LOGGING -PRLogModuleInfo* GetDemuxerLog(); -#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) -#else -#define LOG(...) -#endif -#define READ_OUTPUT_BUFFER_TIMEOUT_US 3000 - -using namespace android; -typedef android::MediaCodecProxy MediaCodecProxy; - -namespace mozilla { - -GonkAudioDecoderManager::GonkAudioDecoderManager( - const mp4_demuxer::AudioDecoderConfig& aConfig) - : mAudioChannels(aConfig.channel_count) - , mAudioRate(aConfig.samples_per_second) - , mAudioProfile(aConfig.aac_profile) - , mAudioBuffer(nullptr) -{ - MOZ_COUNT_CTOR(GonkAudioDecoderManager); - MOZ_ASSERT(mAudioChannels); - mUserData.AppendElements(&aConfig.audio_specific_config[0], - aConfig.audio_specific_config.length()); -} - -GonkAudioDecoderManager::~GonkAudioDecoderManager() -{ - MOZ_COUNT_DTOR(GonkAudioDecoderManager); -} - -android::sp -GonkAudioDecoderManager::Init(MediaDataDecoderCallback* aCallback) -{ - if (mLooper != nullptr) { - return nullptr; - } - // Create ALooper - mLooper = new ALooper; - mLooper->setName("GonkAudioDecoderManager"); - mLooper->start(); - - mDecoder = MediaCodecProxy::CreateByType(mLooper, "audio/mp4a-latm", false, false, nullptr); - if (!mDecoder.get()) { - return nullptr; - } - sp format = new AMessage; - // Fixed values - ALOG("Init Audio channel no:%d, sample-rate:%d", mAudioChannels, mAudioRate); - format->setString("mime", "audio/mp4a-latm"); - format->setInt32("channel-count", mAudioChannels); - format->setInt32("sample-rate", mAudioRate); - format->setInt32("aac-profile", mAudioProfile); - format->setInt32("is-adts", true); - status_t err = mDecoder->configure(format, nullptr, nullptr, 0); - if (err != OK || !mDecoder->Prepare()) { - return nullptr; - } - status_t rv = mDecoder->Input(mUserData.Elements(), mUserData.Length(), 0, - android::MediaCodec::BUFFER_FLAG_CODECCONFIG); - - if (rv == OK) { - return mDecoder; - } else { - ALOG("Failed to input codec specific data!"); - return nullptr; - } -} - -nsresult -GonkAudioDecoderManager::CreateAudioData(int64_t aStreamOffset, AudioData **v) { - - void *data; - size_t dataOffset; - size_t size; - int64_t timeUs; - - if (!mAudioBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { - return NS_ERROR_UNEXPECTED; - } - data = mAudioBuffer->data(); - dataOffset = mAudioBuffer->range_offset(); - size = mAudioBuffer->range_length(); - - nsAutoArrayPtr buffer(new AudioDataValue[size/2] ); - memcpy(buffer.get(), data+dataOffset, size); - uint32_t frames = size / (2 * mAudioChannels); - - CheckedInt64 duration = FramesToUsecs(frames, mAudioRate); - if (!duration.isValid()) { - return NS_ERROR_UNEXPECTED; - } - *v = new AudioData(aStreamOffset, timeUs, duration.value(), frames, buffer.forget(), - mAudioChannels); - ReleaseAudioBuffer(); - return NS_OK; -} - -nsresult -GonkAudioDecoderManager::Output(int64_t aStreamOffset, - nsAutoPtr& aOutData) -{ - aOutData = nullptr; - status_t err; - err = mDecoder->Output(&mAudioBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US); - - switch (err) { - case OK: - { - if (mAudioBuffer && mAudioBuffer->range_length() != 0) { - int64_t timeUs; - if (!mAudioBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { - return NS_ERROR_UNEXPECTED; - } - } - AudioData* data = nullptr; - nsresult rv = CreateAudioData(aStreamOffset, &data); - // Frame should be non null only when we succeeded. - if (rv != NS_OK) { - return NS_ERROR_UNEXPECTED; - } - aOutData = data; - return NS_OK; - } - case android::INFO_FORMAT_CHANGED: - case android::INFO_OUTPUT_BUFFERS_CHANGED: - { - // If the format changed, update our cached info. - ALOG("Decoder format changed"); - return Output(aStreamOffset, aOutData); - } - case -EAGAIN: - { - return NS_ERROR_NOT_AVAILABLE; - } - case android::ERROR_END_OF_STREAM: - { - ALOG("End of Stream"); - return NS_ERROR_ABORT; - } - case -ETIMEDOUT: - { - ALOG("Timeout. can try again next time"); - return NS_ERROR_UNEXPECTED; - } - default: - { - ALOG("Decoder failed, err=%d", err); - return NS_ERROR_UNEXPECTED; - } - } - - return NS_OK; -} - -void GonkAudioDecoderManager::ReleaseAudioBuffer() { - if (mAudioBuffer) { - sp metaData = mAudioBuffer->meta_data(); - int32_t index; - metaData->findInt32(android::MediaCodecProxy::kKeyBufferIndex, &index); - mAudioBuffer->release(); - mAudioBuffer = nullptr; - mDecoder->releaseOutputBuffer(index); - } -} - -nsresult -GonkAudioDecoderManager::Input(mp4_demuxer::MP4Sample* aSample) -{ - const uint8_t* data = reinterpret_cast(aSample->data); - uint32_t length = aSample->size; - status_t rv = mDecoder->Input(data, length, aSample->composition_timestamp, 0); - return rv == OK ? NS_OK : NS_ERROR_UNEXPECTED; -} - -} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkAudioDecoderManager.h b/content/media/fmp4/gonk/GonkAudioDecoderManager.h deleted file mode 100644 index fc40d58dadc..00000000000 --- a/content/media/fmp4/gonk/GonkAudioDecoderManager.h +++ /dev/null @@ -1,51 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ - -#if !defined(GonkAudioDecoderManager_h_) -#define GonkAudioDecoderManager_h_ - -#include "mozilla/RefPtr.h" -#include "MP4Reader.h" -#include "GonkMediaDataDecoder.h" - -using namespace android; - -namespace mozilla { - -class GonkAudioDecoderManager : public GonkDecoderManager { -typedef android::MediaCodecProxy MediaCodecProxy; -public: - GonkAudioDecoderManager(const mp4_demuxer::AudioDecoderConfig& aConfig); - ~GonkAudioDecoderManager(); - - virtual android::sp Init(MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; - - virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE; - - virtual nsresult Output(int64_t aStreamOffset, - nsAutoPtr& aOutput) MOZ_OVERRIDE; -private: - - nsresult CreateAudioData(int64_t aStreamOffset, - AudioData** aOutData); - - void ReleaseAudioBuffer(); - // MediaCodedc's wrapper that performs the decoding. - android::sp mDecoder; - - const uint32_t mAudioChannels; - const uint32_t mAudioRate; - const uint32_t mAudioProfile; - nsTArray mUserData; - - MediaDataDecoderCallback* mReaderCallback; - android::MediaBuffer* mAudioBuffer; - android::sp mLooper; -}; - -} // namespace mozilla - -#endif // GonkAudioDecoderManager_h_ diff --git a/content/media/fmp4/gonk/GonkDecoderModule.cpp b/content/media/fmp4/gonk/GonkDecoderModule.cpp deleted file mode 100644 index 022fd303505..00000000000 --- a/content/media/fmp4/gonk/GonkDecoderModule.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ -#include "GonkDecoderModule.h" -#include "GonkVideoDecoderManager.h" -#include "GonkAudioDecoderManager.h" -#include "mozilla/Preferences.h" -#include "mozilla/DebugOnly.h" -#include "GonkMediaDataDecoder.h" - -namespace mozilla { -GonkDecoderModule::GonkDecoderModule() -{ -} - -GonkDecoderModule::~GonkDecoderModule() -{ -} - -/* static */ -void -GonkDecoderModule::Init() -{ - MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); -} - -nsresult -GonkDecoderModule::Shutdown() -{ - MOZ_ASSERT(NS_IsMainThread(), "Must be on main thread."); - - return NS_OK; -} - -already_AddRefed -GonkDecoderModule::CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig, - mozilla::layers::LayersBackend aLayersBackend, - mozilla::layers::ImageContainer* aImageContainer, - MediaTaskQueue* aVideoTaskQueue, - MediaDataDecoderCallback* aCallback) -{ - nsRefPtr decoder = - new GonkMediaDataDecoder(new GonkVideoDecoderManager(aImageContainer,aConfig), - aVideoTaskQueue, aCallback); - return decoder.forget(); -} - -already_AddRefed -GonkDecoderModule::CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig, - MediaTaskQueue* aAudioTaskQueue, - MediaDataDecoderCallback* aCallback) -{ - nsRefPtr decoder = - new GonkMediaDataDecoder(new GonkAudioDecoderManager(aConfig), aAudioTaskQueue, - aCallback); - return decoder.forget(); -} - -} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkDecoderModule.h b/content/media/fmp4/gonk/GonkDecoderModule.h deleted file mode 100644 index 95c0e08a4cf..00000000000 --- a/content/media/fmp4/gonk/GonkDecoderModule.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ - -#if !defined(GonkPlatformDecoderModule_h_) -#define GonkPlatformDecoderModule_h_ - -#include "PlatformDecoderModule.h" - -namespace mozilla { - -class GonkDecoderModule : public PlatformDecoderModule { -public: - GonkDecoderModule(); - virtual ~GonkDecoderModule(); - - // Called when the decoders have shutdown. - virtual nsresult Shutdown() MOZ_OVERRIDE; - - // Decode thread. - virtual already_AddRefed - CreateH264Decoder(const mp4_demuxer::VideoDecoderConfig& aConfig, - mozilla::layers::LayersBackend aLayersBackend, - mozilla::layers::ImageContainer* aImageContainer, - MediaTaskQueue* aVideoTaskQueue, - MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; - - // Decode thread. - virtual already_AddRefed - CreateAACDecoder(const mp4_demuxer::AudioDecoderConfig& aConfig, - MediaTaskQueue* aAudioTaskQueue, - MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; - - static void Init(); -}; - -} // namespace mozilla - -#endif diff --git a/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp b/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp deleted file mode 100644 index a37b18541c1..00000000000 --- a/content/media/fmp4/gonk/GonkMediaDataDecoder.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ -#include "mp4_demuxer/mp4_demuxer.h" -#include "GonkMediaDataDecoder.h" -#include "VideoUtils.h" -#include "nsTArray.h" - -#include "prlog.h" -#define LOG_TAG "GonkMediaDataDecoder(blake)" -#include -#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) - -#ifdef PR_LOGGING -PRLogModuleInfo* GetDemuxerLog(); -#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) -#else -#define LOG(...) -#endif - -using namespace android; - -namespace mozilla { - -GonkMediaDataDecoder::GonkMediaDataDecoder(GonkDecoderManager* aManager, - MediaTaskQueue* aTaskQueue, - MediaDataDecoderCallback* aCallback) - : mTaskQueue(aTaskQueue) - , mCallback(aCallback) - , mManager(aManager) -{ - MOZ_COUNT_CTOR(GonkMediaDataDecoder); -} - -GonkMediaDataDecoder::~GonkMediaDataDecoder() -{ - MOZ_COUNT_DTOR(GonkMediaDataDecoder); -} - -nsresult -GonkMediaDataDecoder::Init() -{ - mDecoder = mManager->Init(mCallback); - return mDecoder.get() ? NS_OK : NS_ERROR_UNEXPECTED; -} - -nsresult -GonkMediaDataDecoder::Shutdown() -{ - mDecoder->stop(); - mDecoder = nullptr; - return NS_OK; -} - -// Inserts data into the decoder's pipeline. -nsresult -GonkMediaDataDecoder::Input(mp4_demuxer::MP4Sample* aSample) -{ - mTaskQueue->Dispatch( - NS_NewRunnableMethodWithArg>( - this, - &GonkMediaDataDecoder::ProcessDecode, - nsAutoPtr(aSample))); - return NS_OK; -} - -void -GonkMediaDataDecoder::ProcessDecode(mp4_demuxer::MP4Sample* aSample) -{ - nsresult rv = mManager->Input(aSample); - if (rv != NS_OK) { - NS_WARNING("GonkAudioDecoder failed to input data"); - ALOG("Failed to input data err: %d",rv); - mCallback->Error(); - return; - } - - mLastStreamOffset = aSample->byte_offset; - ProcessOutput(); -} - -void -GonkMediaDataDecoder::ProcessOutput() -{ - nsAutoPtr output; - nsresult rv; - while (true) { - rv = mManager->Output(mLastStreamOffset, output); - if (rv == NS_OK) { - mCallback->Output(output.forget()); - continue; - } - else { - break; - } - } - - if (rv == NS_ERROR_NOT_AVAILABLE) { - mCallback->InputExhausted(); - return; - } - if (rv != NS_OK) { - NS_WARNING("GonkMediaDataDecoder failed to output data"); - ALOG("Failed to output data"); - mCallback->Error(); - } -} - -nsresult -GonkMediaDataDecoder::Flush() -{ - // Flush the input task queue. This cancels all pending Decode() calls. - // Note this blocks until the task queue finishes its current job, if - // it's executing at all. Note the MP4Reader ignores all output while - // flushing. - mTaskQueue->Flush(); - - status_t err = mDecoder->flush(); - return err == OK ? NS_OK : NS_ERROR_FAILURE; -} - -void -GonkMediaDataDecoder::ProcessDrain() -{ - // Then extract all available output. - ProcessOutput(); - mCallback->DrainComplete(); -} - -nsresult -GonkMediaDataDecoder::Drain() -{ - mTaskQueue->Dispatch(NS_NewRunnableMethod(this, &GonkMediaDataDecoder::ProcessDrain)); - return NS_OK; -} - -bool -GonkMediaDataDecoder::IsWaitingMediaResources() { - return mDecoder->IsWaitingResources(); -} - -bool -GonkMediaDataDecoder::IsDormantNeeded() { - return mDecoder->IsDormantNeeded(); -} - -void -GonkMediaDataDecoder::ReleaseMediaResources() { - mDecoder->ReleaseMediaResources(); -} - -} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkMediaDataDecoder.h b/content/media/fmp4/gonk/GonkMediaDataDecoder.h deleted file mode 100644 index 76e35469abf..00000000000 --- a/content/media/fmp4/gonk/GonkMediaDataDecoder.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ - -#if !defined(GonkMediaDataDecoder_h_) -#define GonkMediaDataDecoder_h_ -#include "mp4_demuxer/mp4_demuxer.h" -#include "mozilla/RefPtr.h" -#include "MP4Reader.h" -#include "MediaCodecProxy.h" - -namespace mozilla { - -// Manage the data flow from inputting encoded data and outputting decode data. -class GonkDecoderManager { -public: - virtual ~GonkDecoderManager() {} - - // Creates and initializs the GonkDecoder. - // Returns nullptr on failure. - virtual android::sp Init(MediaDataDecoderCallback* aCallback) = 0; - - // Produces decoded output, it blocks until output can be produced or a timeout - // is expired or until EOS. Returns NS_OK on success, or NS_ERROR_NOT_AVAILABLE - // if there's not enough data to produce more output. If this returns a failure - // code other than NS_ERROR_NOT_AVAILABLE, an error will be reported to the - // MP4Reader. - virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) = 0; - virtual nsresult Output(int64_t aStreamOffset, - nsAutoPtr& aOutput) = 0; - -}; - -// Samples are decoded using the GonkDecoder (MediaCodec) -// created by the GonkDecoderManager. This class implements -// the higher-level logic that drives mapping the Gonk to the async -// MediaDataDecoder interface. The specifics of decoding the exact stream -// type are handled by GonkDecoderManager and the GonkDecoder it creates. -class GonkMediaDataDecoder : public MediaDataDecoder { -public: - GonkMediaDataDecoder(GonkDecoderManager* aDecoderManager, - MediaTaskQueue* aTaskQueue, - MediaDataDecoderCallback* aCallback); - - ~GonkMediaDataDecoder(); - - virtual nsresult Init() MOZ_OVERRIDE; - - virtual nsresult Input(mp4_demuxer::MP4Sample* aSample); - - virtual nsresult Flush() MOZ_OVERRIDE; - - virtual nsresult Drain() MOZ_OVERRIDE; - - virtual nsresult Shutdown() MOZ_OVERRIDE; - - virtual bool IsWaitingMediaResources() MOZ_OVERRIDE; - - virtual bool IsDormantNeeded() MOZ_OVERRIDE; - - virtual void ReleaseMediaResources() MOZ_OVERRIDE; - -private: - - // Called on the task queue. Inserts the sample into the decoder, and - // extracts output if available. - void ProcessDecode(mp4_demuxer::MP4Sample* aSample); - - // Called on the task queue. Extracts output if available, and delivers - // it to the reader. Called after ProcessDecode() and ProcessDrain(). - void ProcessOutput(); - - // Called on the task queue. Orders the Gonk to drain, and then extracts - // all available output. - void ProcessDrain(); - - RefPtr mTaskQueue; - MediaDataDecoderCallback* mCallback; - - android::sp mDecoder; - nsAutoPtr mManager; - - // The last offset into the media resource that was passed into Input(). - // This is used to approximate the decoder's position in the media resource. - int64_t mLastStreamOffset; -}; - -} // namespace mozilla - -#endif // GonkMediaDataDecoder_h_ diff --git a/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp b/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp deleted file mode 100644 index 241e5fdc9e6..00000000000 --- a/content/media/fmp4/gonk/GonkVideoDecoderManager.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ -#include -#include -#include -#include "GonkVideoDecoderManager.h" -#include "MediaDecoderReader.h" -#include "ImageContainer.h" -#include "VideoUtils.h" -#include "nsThreadUtils.h" -#include "Layers.h" -#include "prlog.h" -#include "stagefright/MediaBuffer.h" -#include "stagefright/MetaData.h" -#include "stagefright/MediaErrors.h" -#include -#include -#include "mp4_demuxer/AnnexB.h" - -#define READ_OUTPUT_BUFFER_TIMEOUT_US 3000 - -#define LOG_TAG "GonkVideoDecoderManager" -#include -#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) - -#ifdef PR_LOGGING -PRLogModuleInfo* GetDemuxerLog(); -#define LOG(...) PR_LOG(GetDemuxerLog(), PR_LOG_DEBUG, (__VA_ARGS__)) -#else -#define LOG(...) -#endif -using namespace mozilla::layers; -using namespace android; -typedef android::MediaCodecProxy MediaCodecProxy; - -namespace mozilla { -enum { - kNotifyCodecReserved = 'core', - kNotifyCodecCanceled = 'coca', -}; - -GonkVideoDecoderManager::GonkVideoDecoderManager( - mozilla::layers::ImageContainer* aImageContainer, - const mp4_demuxer::VideoDecoderConfig& aConfig) - : mImageContainer(aImageContainer) - , mConfig(aConfig) - , mReaderCallback(nullptr) - , mColorConverterBufferSize(0) -{ - NS_ASSERTION(!NS_IsMainThread(), "Should not be on main thread."); - MOZ_ASSERT(mImageContainer); - MOZ_COUNT_CTOR(GonkVideoDecoderManager); - mVideoWidth = aConfig.display_width; - mVideoHeight = aConfig.display_height; - mDisplayWidth = aConfig.display_width; - mDisplayHeight = aConfig.display_width; - mInfo.mVideo.mHasVideo = true; - nsIntSize displaySize(mDisplayWidth, mDisplayHeight); - mInfo.mVideo.mDisplay = displaySize; - - nsIntRect pictureRect(0, 0, mVideoWidth, mVideoHeight); - nsIntSize frameSize(mVideoWidth, mVideoHeight); - mPicture = pictureRect; - mInitialFrame = frameSize; - mHandler = new MessageHandler(this); - mVideoListener = new VideoResourceListener(this); - -} - -GonkVideoDecoderManager::~GonkVideoDecoderManager() -{ - MOZ_COUNT_DTOR(GonkVideoDecoderManager); -} - -android::sp -GonkVideoDecoderManager::Init(MediaDataDecoderCallback* aCallback) -{ - nsIntSize displaySize(mDisplayWidth, mDisplayHeight); - nsIntRect pictureRect(0, 0, mVideoWidth, mVideoHeight); - // Validate the container-reported frame and pictureRect sizes. This ensures - // that our video frame creation code doesn't overflow. - nsIntSize frameSize(mVideoWidth, mVideoHeight); - if (!IsValidVideoRegion(frameSize, pictureRect, displaySize)) { - ALOG("It is not a valid region"); - return nullptr; - } - - mReaderCallback = aCallback; - - if (mLooper.get() != nullptr) { - return nullptr; - } - // Create ALooper - mLooper = new ALooper; - mLooper->setName("GonkVideoDecoderManager"); - // Register AMessage handler to ALooper. - mLooper->registerHandler(mHandler); - // Start ALooper thread. - if (mLooper->start() != OK) { - return nullptr; - } - mDecoder = MediaCodecProxy::CreateByType(mLooper, "video/avc", false, true, mVideoListener); - return mDecoder; -} - -nsresult -GonkVideoDecoderManager::CreateVideoData(int64_t aStreamOffset, VideoData **v) -{ - *v = nullptr; - int64_t timeUs; - int32_t keyFrame; - if (!mVideoBuffer->meta_data()->findInt64(kKeyTime, &timeUs)) { - ALOG("Decoder did not return frame time"); - return NS_ERROR_UNEXPECTED; - } - - if (!mVideoBuffer->meta_data()->findInt32(kKeyIsSyncFrame, &keyFrame)) { - keyFrame = 0; - } - - gfx::IntRect picture = ToIntRect(mPicture); - if (mFrameInfo.mWidth != mInitialFrame.width || - mFrameInfo.mHeight != mInitialFrame.height) { - - // Frame size is different from what the container reports. This is legal, - // and we will preserve the ratio of the crop rectangle as it - // was reported relative to the picture size reported by the container. - picture.x = (mPicture.x * mFrameInfo.mWidth) / mInitialFrame.width; - picture.y = (mPicture.y * mFrameInfo.mHeight) / mInitialFrame.height; - picture.width = (mFrameInfo.mWidth * mPicture.width) / mInitialFrame.width; - picture.height = (mFrameInfo.mHeight * mPicture.height) / mInitialFrame.height; - } - - if (!(mVideoBuffer != nullptr && mVideoBuffer->size() > 0 && mVideoBuffer->data() != nullptr)) { - ALOG("mVideoBuffer is not valid!"); - return NS_ERROR_UNEXPECTED; - } - - uint8_t *yuv420p_buffer = (uint8_t *)mVideoBuffer->data(); - int32_t stride = mFrameInfo.mStride; - int32_t slice_height = mFrameInfo.mSliceHeight; - - // Converts to OMX_COLOR_FormatYUV420Planar - if (mFrameInfo.mColorFormat != OMX_COLOR_FormatYUV420Planar) { - ARect crop; - crop.top = 0; - crop.bottom = mFrameInfo.mHeight; - crop.left = 0; - crop.right = mFrameInfo.mWidth; - yuv420p_buffer = GetColorConverterBuffer(mFrameInfo.mWidth, mFrameInfo.mHeight); - if (mColorConverter.convertDecoderOutputToI420(mVideoBuffer->data(), - mFrameInfo.mWidth, mFrameInfo.mHeight, crop, yuv420p_buffer) != OK) { - ReleaseVideoBuffer(); - ALOG("Color conversion failed!"); - return NS_ERROR_UNEXPECTED; - } - stride = mFrameInfo.mWidth; - slice_height = mFrameInfo.mHeight; - } - - size_t yuv420p_y_size = stride * slice_height; - size_t yuv420p_u_size = ((stride + 1) / 2) * ((slice_height + 1) / 2); - uint8_t *yuv420p_y = yuv420p_buffer; - uint8_t *yuv420p_u = yuv420p_y + yuv420p_y_size; - uint8_t *yuv420p_v = yuv420p_u + yuv420p_u_size; - - // This is the approximate byte position in the stream. - int64_t pos = aStreamOffset; - - VideoData::YCbCrBuffer b; - b.mPlanes[0].mData = yuv420p_y; - b.mPlanes[0].mWidth = mFrameInfo.mWidth; - b.mPlanes[0].mHeight = mFrameInfo.mHeight; - b.mPlanes[0].mStride = stride; - b.mPlanes[0].mOffset = 0; - b.mPlanes[0].mSkip = 0; - - b.mPlanes[1].mData = yuv420p_u; - b.mPlanes[1].mWidth = (mFrameInfo.mWidth + 1) / 2; - b.mPlanes[1].mHeight = (mFrameInfo.mHeight + 1) / 2; - b.mPlanes[1].mStride = (stride + 1) / 2; - b.mPlanes[1].mOffset = 0; - b.mPlanes[1].mSkip = 0; - - b.mPlanes[2].mData = yuv420p_v; - b.mPlanes[2].mWidth =(mFrameInfo.mWidth + 1) / 2; - b.mPlanes[2].mHeight = (mFrameInfo.mHeight + 1) / 2; - b.mPlanes[2].mStride = (stride + 1) / 2; - b.mPlanes[2].mOffset = 0; - b.mPlanes[2].mSkip = 0; - - *v = VideoData::Create( - mInfo.mVideo, - mImageContainer, - pos, - timeUs, - 1, // We don't know the duration. - b, - keyFrame, - -1, - picture); - ReleaseVideoBuffer(); - return NS_OK; -} - -bool -GonkVideoDecoderManager::SetVideoFormat() -{ - // read video metadata from MediaCodec - sp codecFormat; - if (mDecoder->getOutputFormat(&codecFormat) == OK) { - AString mime; - int32_t width = 0; - int32_t height = 0; - int32_t stride = 0; - int32_t slice_height = 0; - int32_t color_format = 0; - int32_t crop_left = 0; - int32_t crop_top = 0; - int32_t crop_right = 0; - int32_t crop_bottom = 0; - if (!codecFormat->findString("mime", &mime) || - !codecFormat->findInt32("width", &width) || - !codecFormat->findInt32("height", &height) || - !codecFormat->findInt32("stride", &stride) || - !codecFormat->findInt32("slice-height", &slice_height) || - !codecFormat->findInt32("color-format", &color_format) || - !codecFormat->findRect("crop", &crop_left, &crop_top, &crop_right, &crop_bottom)) { - ALOG("Failed to find values"); - return false; - } - mFrameInfo.mWidth = width; - mFrameInfo.mHeight = height; - mFrameInfo.mStride = stride; - mFrameInfo.mSliceHeight = slice_height; - mFrameInfo.mColorFormat = color_format; - - nsIntSize displaySize(width, height); - if (!IsValidVideoRegion(mInitialFrame, mPicture, displaySize)) { - ALOG("It is not a valid region"); - return false; - } - } - return true; -} - -// Blocks until decoded sample is produced by the deoder. -nsresult -GonkVideoDecoderManager::Output(int64_t aStreamOffset, - nsAutoPtr& aOutData) -{ - aOutData = nullptr; - status_t err; - if (mDecoder == nullptr) { - ALOG("Decoder is not inited"); - return NS_ERROR_UNEXPECTED; - } - err = mDecoder->Output(&mVideoBuffer, READ_OUTPUT_BUFFER_TIMEOUT_US); - - switch (err) { - case OK: - { - VideoData* data = nullptr; - nsresult rv = CreateVideoData(aStreamOffset, &data); - // Frame should be non null only when we succeeded. - if (rv != NS_OK || data == nullptr){ - ALOG("Error unexpected in CreateVideoData"); - return NS_ERROR_UNEXPECTED; - } - aOutData = data; - return NS_OK; - } - case android::INFO_FORMAT_CHANGED: - case android::INFO_OUTPUT_BUFFERS_CHANGED: - { - // If the format changed, update our cached info. - ALOG("Decoder format changed"); - if (!SetVideoFormat()) { - return NS_ERROR_UNEXPECTED; - } - else - return Output(aStreamOffset, aOutData); - } - case -EAGAIN: - { - return NS_ERROR_NOT_AVAILABLE; - } - case android::ERROR_END_OF_STREAM: - { - ALOG("End of Stream"); - return NS_ERROR_ABORT; - } - case -ETIMEDOUT: - { - ALOG("Timeout. can try again next time"); - return NS_ERROR_UNEXPECTED; - } - default: - { - ALOG("Decoder failed, err=%d", err); - return NS_ERROR_UNEXPECTED; - } - } - - return NS_OK; -} - -void GonkVideoDecoderManager::ReleaseVideoBuffer() { - if (mVideoBuffer) { - sp metaData = mVideoBuffer->meta_data(); - int32_t index; - metaData->findInt32(android::MediaCodecProxy::kKeyBufferIndex, &index); - mVideoBuffer->release(); - mVideoBuffer = nullptr; - mDecoder->releaseOutputBuffer(index); - } -} - -nsresult -GonkVideoDecoderManager::Input(mp4_demuxer::MP4Sample* aSample) -{ - // We must prepare samples in AVC Annex B. - mp4_demuxer::AnnexB::ConvertSample(aSample, mConfig.annex_b); - // Forward sample data to the decoder. - - const uint8_t* data = reinterpret_cast(aSample->data); - uint32_t length = aSample->size; - if (mDecoder == nullptr) { - ALOG("Decoder is not inited"); - return NS_ERROR_UNEXPECTED; - } - status_t rv = mDecoder->Input(data, length, aSample->composition_timestamp, 0); - return (rv == OK) ? NS_OK : NS_ERROR_FAILURE; -} - -void -GonkVideoDecoderManager::codecReserved() -{ - sp format = new AMessage; - // Fixed values - format->setString("mime", "video/avc"); - format->setInt32("width", mVideoWidth); - format->setInt32("height", mVideoHeight); - - mDecoder->configure(format, nullptr, nullptr, 0); - mDecoder->Prepare(); - SetVideoFormat(); - - if (mHandler != nullptr) { - // post kNotifyCodecReserved to MediaCodecReader::mLooper thread. - sp notify = new AMessage(kNotifyCodecReserved, mHandler->id()); - notify->post(); - } -} - -void -GonkVideoDecoderManager::codecCanceled() -{ - mDecoder = nullptr; - if (mHandler != nullptr) { - // post kNotifyCodecCanceled to MediaCodecReader::mLooper thread. - sp notify = new AMessage(kNotifyCodecCanceled, mHandler->id()); - notify->post(); - } - -} - -// Called on GonkVideoDecoderManager::mLooper thread. -void -GonkVideoDecoderManager::onMessageReceived(const sp &aMessage) -{ - switch (aMessage->what()) { - case kNotifyCodecReserved: - { - // Our decode may have acquired the hardware resource that it needs - // to start. Notify the state machine to resume loading metadata. - mReaderCallback->NotifyResourcesStatusChanged(); - break; - } - - case kNotifyCodecCanceled: - { - mReaderCallback->ReleaseMediaResources(); - break; - } - - default: - TRESPASS(); - break; - } -} - -GonkVideoDecoderManager::MessageHandler::MessageHandler(GonkVideoDecoderManager *aManager) - : mManager(aManager) -{ -} - -GonkVideoDecoderManager::MessageHandler::~MessageHandler() -{ - mManager = nullptr; -} - -void -GonkVideoDecoderManager::MessageHandler::onMessageReceived(const android::sp &aMessage) -{ - if (mManager != nullptr) { - mManager->onMessageReceived(aMessage); - } -} - -GonkVideoDecoderManager::VideoResourceListener::VideoResourceListener(GonkVideoDecoderManager *aManager) - : mManager(aManager) -{ -} - -GonkVideoDecoderManager::VideoResourceListener::~VideoResourceListener() -{ - mManager = nullptr; -} - -void -GonkVideoDecoderManager::VideoResourceListener::codecReserved() -{ - if (mManager != nullptr) { - mManager->codecReserved(); - } -} - -void -GonkVideoDecoderManager::VideoResourceListener::codecCanceled() -{ - if (mManager != nullptr) { - mManager->codecCanceled(); - } -} - -uint8_t * -GonkVideoDecoderManager::GetColorConverterBuffer(int32_t aWidth, int32_t aHeight) -{ - // Allocate a temporary YUV420Planer buffer. - size_t yuv420p_y_size = aWidth * aHeight; - size_t yuv420p_u_size = ((aWidth + 1) / 2) * ((aHeight + 1) / 2); - size_t yuv420p_v_size = yuv420p_u_size; - size_t yuv420p_size = yuv420p_y_size + yuv420p_u_size + yuv420p_v_size; - if (mColorConverterBufferSize != yuv420p_size) { - mColorConverterBuffer = nullptr; // release the previous buffer first - mColorConverterBuffer = new uint8_t[yuv420p_size]; - mColorConverterBufferSize = yuv420p_size; - } - return mColorConverterBuffer.get(); -} - -} // namespace mozilla diff --git a/content/media/fmp4/gonk/GonkVideoDecoderManager.h b/content/media/fmp4/gonk/GonkVideoDecoderManager.h deleted file mode 100644 index 54d2a86bb78..00000000000 --- a/content/media/fmp4/gonk/GonkVideoDecoderManager.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim:set ts=2 sw=2 sts=2 et cindent: */ -/* 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/. */ - -#if !defined(GonkVideoDecoderManager_h_) -#define GonkVideoDecoderManager_h_ - -#include "MP4Reader.h" -#include "nsRect.h" -#include "GonkMediaDataDecoder.h" -#include "mozilla/RefPtr.h" -#include "I420ColorConverterHelper.h" - -using namespace android; -namespace mozilla { - -class GonkVideoDecoderManager : public GonkDecoderManager { -typedef android::MediaCodecProxy MediaCodecProxy; - -public: - GonkVideoDecoderManager(mozilla::layers::ImageContainer* aImageContainer, - const mp4_demuxer::VideoDecoderConfig& aConfig); - - ~GonkVideoDecoderManager(); - - virtual android::sp Init(MediaDataDecoderCallback* aCallback) MOZ_OVERRIDE; - - virtual nsresult Input(mp4_demuxer::MP4Sample* aSample) MOZ_OVERRIDE; - - virtual nsresult Output(int64_t aStreamOffset, - nsAutoPtr& aOutput) MOZ_OVERRIDE; - -private: - struct FrameInfo - { - int32_t mWidth = 0; - int32_t mHeight = 0; - int32_t mStride = 0; - int32_t mSliceHeight = 0; - int32_t mColorFormat = 0; - int32_t mCropLeft = 0; - int32_t mCropTop = 0; - int32_t mCropRight = 0; - int32_t mCropBottom = 0; - }; - class MessageHandler : public android::AHandler - { - public: - MessageHandler(GonkVideoDecoderManager *aManager); - ~MessageHandler(); - - virtual void onMessageReceived(const android::sp &aMessage); - - private: - // Forbidden - MessageHandler() MOZ_DELETE; - MessageHandler(const MessageHandler &rhs) MOZ_DELETE; - const MessageHandler &operator=(const MessageHandler &rhs) MOZ_DELETE; - - GonkVideoDecoderManager *mManager; - }; - friend class MessageHandler; - - class VideoResourceListener : public android::MediaCodecProxy::CodecResourceListener - { - public: - VideoResourceListener(GonkVideoDecoderManager *aManager); - ~VideoResourceListener(); - - virtual void codecReserved() MOZ_OVERRIDE; - virtual void codecCanceled() MOZ_OVERRIDE; - - private: - // Forbidden - VideoResourceListener() MOZ_DELETE; - VideoResourceListener(const VideoResourceListener &rhs) MOZ_DELETE; - const VideoResourceListener &operator=(const VideoResourceListener &rhs) MOZ_DELETE; - - GonkVideoDecoderManager *mManager; - }; - friend class VideoResourceListener; - - bool SetVideoFormat(); - - nsresult CreateVideoData(int64_t aStreamOffset, VideoData** aOutData); - void ReleaseVideoBuffer(); - uint8_t* GetColorConverterBuffer(int32_t aWidth, int32_t aHeight); - - // For codec resource management - void codecReserved(); - void codecCanceled(); - void onMessageReceived(const sp &aMessage); - - const mp4_demuxer::VideoDecoderConfig& mConfig; - uint32_t mVideoWidth; - uint32_t mVideoHeight; - uint32_t mDisplayWidth; - uint32_t mDisplayHeight; - nsIntRect mPicture; - nsIntSize mInitialFrame; - - android::sp mDecoder; - nsRefPtr mImageContainer; - MediaDataDecoderCallback* mCallback; - - android::MediaBuffer* mVideoBuffer; - - MediaDataDecoderCallback* mReaderCallback; - MediaInfo mInfo; - android::sp mVideoListener; - android::sp mHandler; - android::sp mLooper; - FrameInfo mFrameInfo; - - // color converter - android::I420ColorConverterHelper mColorConverter; - nsAutoArrayPtr mColorConverterBuffer; - size_t mColorConverterBufferSize; -}; - -} // namespace mozilla - -#endif // GonkVideoDecoderManager_h_ diff --git a/content/media/fmp4/gonk/moz.build b/content/media/fmp4/gonk/moz.build deleted file mode 100644 index c936fbadc54..00000000000 --- a/content/media/fmp4/gonk/moz.build +++ /dev/null @@ -1,32 +0,0 @@ -# -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*- -# vim: set filetype=python: -# 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/. - -EXPORTS += [ - 'GonkAudioDecoderManager.h', - 'GonkDecoderModule.h', - 'GonkMediaDataDecoder.h', - 'GonkVideoDecoderManager.h', -] -UNIFIED_SOURCES += [ - 'GonkAudioDecoderManager.cpp', - 'GonkDecoderModule.cpp', - 'GonkMediaDataDecoder.cpp', - 'GonkVideoDecoderManager.cpp', -] -LOCAL_INCLUDES += [ - '/content/media/omx/', - '/content/media/omx/mediaresourcemanager', -] -include('/ipc/chromium/chromium-config.mozbuild') - -FINAL_LIBRARY = 'xul' - -FAIL_ON_WARNINGS = True - -CXXFLAGS += [ - '-I%s/%s' % (CONFIG['ANDROID_SOURCE'], d) for d in [ - 'frameworks/native/opengl/include',] -] diff --git a/content/media/fmp4/moz.build b/content/media/fmp4/moz.build index d5544c95b19..3af0be01fff 100644 --- a/content/media/fmp4/moz.build +++ b/content/media/fmp4/moz.build @@ -68,10 +68,6 @@ LOCAL_INCLUDES += [ '../base', ] -if CONFIG['ANDROID_VERSION'] >= '18'and CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk': - DEFINES['MOZ_GONK_MEDIACODEC'] = True - DIRS += ['gonk'] - FINAL_LIBRARY = 'xul' FAIL_ON_WARNINGS = True diff --git a/content/media/omx/MediaCodecProxy.cpp b/content/media/omx/MediaCodecProxy.cpp index 29ad7a50d39..82e73bc671d 100644 --- a/content/media/omx/MediaCodecProxy.cpp +++ b/content/media/omx/MediaCodecProxy.cpp @@ -5,16 +5,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "MediaCodecProxy.h" -#include -#include -#include -#include -#include -#define LOG_TAG "MediaCodecProxy" -#include -#define ALOG(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) -#define TIMEOUT_DEQUEUE_INPUTBUFFER_MS 1000000ll +#include + +#include + namespace android { sp @@ -394,105 +389,4 @@ MediaCodecProxy::resourceCanceled() } } -bool MediaCodecProxy::Prepare() -{ - - status_t err; - if (start() != OK) { - ALOG("Couldn't start MediaCodec"); - return false; - } - if (getInputBuffers(&mInputBuffers) != OK) { - ALOG("Couldn't get input buffers from MediaCodec"); - return false; - } - if (getOutputBuffers(&mOutputBuffers) != OK) { - ALOG("Couldn't get output buffers from MediaCodec"); - return false; - } - - return true; -} - -status_t MediaCodecProxy::Input(const uint8_t* aData, uint32_t aDataSize, - int64_t aTimestampUsecs, uint64_t aflags) -{ - if (mCodec == nullptr) { - ALOG("MediaCodec has not been inited from input!"); - return NO_INIT; - } - - size_t index; - status_t err = dequeueInputBuffer(&index, TIMEOUT_DEQUEUE_INPUTBUFFER_MS); - if (err != OK) { - ALOG("dequeueInputBuffer returned %d", err); - return err; - } - const sp &dstBuffer = mInputBuffers.itemAt(index); - - CHECK_LE(aDataSize, dstBuffer->capacity()); - dstBuffer->setRange(0, aDataSize); - - memcpy(dstBuffer->data(), aData, aDataSize); - err = queueInputBuffer(index, 0, dstBuffer->size(), aTimestampUsecs, aflags); - if (err != OK) { - ALOG("queueInputBuffer returned %d", err); - return err; - } - return err; -} - -status_t MediaCodecProxy::Output(MediaBuffer** aBuffer, int64_t aTimeoutUs) -{ - - if (mCodec == nullptr) { - ALOG("MediaCodec has not been inited from output!"); - return NO_INIT; - } - - size_t index = 0; - size_t offset = 0; - size_t size = 0; - int64_t timeUs = 0; - uint32_t flags = 0; - - *aBuffer = nullptr; - - status_t err = dequeueOutputBuffer(&index, &offset, &size, - &timeUs, &flags, aTimeoutUs); - if (err != OK) { - ALOG("Output returned %d", err); - return err; - } - - MediaBuffer *buffer; - - buffer = new MediaBuffer(mOutputBuffers.itemAt(index)); - sp metaData = buffer->meta_data(); - metaData->setInt32(kKeyBufferIndex, index); - metaData->setInt64(kKeyTime, timeUs); - buffer->set_range(buffer->range_offset(), size); - *aBuffer = buffer; - return err; -} - -bool MediaCodecProxy::IsWaitingResources() -{ - return mCodec == nullptr; -} - -bool MediaCodecProxy::IsDormantNeeded() -{ - return mCodecLooper.get() ? true : false; -} - -void MediaCodecProxy::ReleaseMediaResources() -{ - if (mCodec.get()) { - mCodec->stop(); - mCodec->release(); - mCodec.clear(); - } -} - } // namespace android diff --git a/content/media/omx/MediaCodecProxy.h b/content/media/omx/MediaCodecProxy.h index 91a683ae069..3b4435b2466 100644 --- a/content/media/omx/MediaCodecProxy.h +++ b/content/media/omx/MediaCodecProxy.h @@ -10,18 +10,12 @@ #include #include -#include #include #include "MediaResourceHandler.h" namespace android { -// This class is intended to be a proxy for MediaCodec with codec resource -// management. Basically user can use it like MediaCodec, but need to handle -// the listener when Codec is reserved for Async case. A good example is -// MediaCodecReader.cpp. Another useage is to use configure(), Prepare(), -// Input(), and Output(). It is used in GonkVideoDecoderManager.cpp which -// doesn't need to handle the buffers for codec. + class MediaCodecProxy : public MediaResourceHandler::ResourceListener { public: @@ -40,9 +34,6 @@ public: virtual void codecCanceled() = 0; }; - enum { - kKeyBufferIndex = 'bfin', - }; // Check whether MediaCodec has been allocated. bool allocated() const; @@ -113,13 +104,6 @@ public: // pending, an error is pending. void requestActivityNotification(const sp &aNotify); - status_t Input(const uint8_t* aData, uint32_t aDataSize, - int64_t aTimestampUsecs, uint64_t flags); - status_t Output(MediaBuffer** aBuffer, int64_t aTimeoutUs); - bool Prepare(); - bool IsWaitingResources(); - bool IsDormantNeeded(); - void ReleaseMediaResources(); protected: virtual ~MediaCodecProxy(); @@ -165,10 +149,6 @@ private: // MediaCodec instance mutable RWLock mCodecLock; sp mCodec; - //MediaCodec buffers to hold input/output data. - Vector > mInputBuffers; - Vector > mOutputBuffers; - }; } // namespace android diff --git a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h index 23e32467d09..c59fded4f00 100644 --- a/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h +++ b/media/libstagefright/binding/include/mp4_demuxer/DecoderData.h @@ -97,7 +97,6 @@ public: uint32_t bits_per_sample; uint32_t samples_per_second; int8_t frequency_index; - int8_t aac_profile; mozilla::Vector extra_data; mozilla::Vector audio_specific_config; CryptoTrack crypto; @@ -108,6 +107,7 @@ public: private: friend class MP4Demuxer; + int8_t aac_profile; }; class VideoDecoderConfig : public TrackConfig From 551c2f4350c93b5233d410e734d19e6acbe506fc Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 09:55:47 -0700 Subject: [PATCH 39/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6affb05ae328 Author: vingtetun <21@vingtetun.org> Desc: Merge pull request #16437 from heycam/rm-prefixes Bug 974266 - Remove property prefixes that are no longer needed. ======== https://hg.mozilla.org/integration/gaia-central/rev/21343fab8888 Author: Cameron McCormack Desc: Bug 974266 - Remove property prefixes that are no longer needed. r=21 --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 0f11ef84a10..e9fd792ce90 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "417937307d7d6340d71d5542f44f4e4f09a8bd0b", + "revision": "6affb05ae3283942609e9411b2d1d659bd67a8a4", "repo_path": "/integration/gaia-central" } From ba5088981def7b0da72e2589e28f0c7799a82e34 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 09:58:43 -0700 Subject: [PATCH 40/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index ae7df2cd277..20d43147ed5 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 0b1b64a905a..72135e3b405 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 1becdad1c77..b41329f12ed 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index ae7df2cd277..20d43147ed5 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index cc4b3764401..88f2d46ef44 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index a24e5900dff..0b83f30439e 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index d68be10c3af..5cd07c3533e 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 9d42c453606..cb0e08ff0a5 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index a7de2a2eabb..3838f3b6762 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From 0ea679871838213d539f169a8d8aa7e26633f8c0 Mon Sep 17 00:00:00 2001 From: Ryan VanderMeulen Date: Wed, 6 Aug 2014 15:37:54 -0400 Subject: [PATCH 41/49] Backed out changeset b8c53e689955 (bug 1042651) because it depends on the patch from bug 1046554 which was backed out. --- dom/nfc/nsNfc.js | 6 ++-- dom/nfc/tests/marionette/test_nfc_peer.js | 35 +++++++++-------------- dom/webidl/MozNFC.webidl | 13 +++------ 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/dom/nfc/nsNfc.js b/dom/nfc/nsNfc.js index ca1a16b3598..668d6baf6c4 100644 --- a/dom/nfc/nsNfc.js +++ b/dom/nfc/nsNfc.js @@ -200,12 +200,14 @@ mozNfc.prototype = { if (this._nfcContentHelper.setSessionToken(sessionToken)) { return this._window.MozNFCTag._create(this._window, obj); } - return null; + throw new Error("Unable to create NFCTag object, Reason: Bad SessionToken " + + sessionToken); }, getNFCPeer: function getNFCPeer(sessionToken) { if (!sessionToken || !this._nfcContentHelper.setSessionToken(sessionToken)) { - return null; + throw new Error("Unable to create NFCPeer object, Reason: Bad SessionToken " + + sessionToken); } if (!this.nfcObject) { diff --git a/dom/nfc/tests/marionette/test_nfc_peer.js b/dom/nfc/tests/marionette/test_nfc_peer.js index 7cfba0e24cb..62ecf5ccb10 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer.js +++ b/dom/nfc/tests/marionette/test_nfc_peer.js @@ -85,6 +85,18 @@ function testCheckP2PRegFailure() { toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0)); } +function testCheckNfcPeerObjForInvalidToken() { + try { + // Use a'fakeSessionToken' + let peer = nfc.getNFCPeer("fakeSessionToken"); + ok(false, "Should not get a NFCPeer object."); + } catch (ex) { + ok(true, "Exception expected"); + } + + toggleNFC(false).then(runNextTest); +} + function testPeerLostShouldNotBeCalled() { nfc.onpeerlost = function () { ok(false, "onpeerlost shouldn't be called"); @@ -139,31 +151,12 @@ function testPeerShouldThrow() { toggleNFC(false).then(runNextTest); } -function testPeerInvalidToken() { - let peer = nfc.getNFCPeer("fakeSessionToken"); - is(peer, null, "NFCPeer should be null on wrong session token"); - - runNextTest(); -} - -/** - * Added for completeness in Bug 1042651, - * TODO: remove once Bug 963531 lands - */ -function testTagInvalidToken() { - let tag = nfc.getNFCTag("fakeSessionToken"); - is(tag, null, "NFCTag should be null on wrong session token"); - - runNextTest(); -} - let tests = [ testPeerReady, testCheckP2PRegFailure, + testCheckNfcPeerObjForInvalidToken, testPeerLostShouldNotBeCalled, - testPeerShouldThrow, - testPeerInvalidToken, - testTagInvalidToken + testPeerShouldThrow ]; SpecialPowers.pushPermissions( diff --git a/dom/webidl/MozNFC.webidl b/dom/webidl/MozNFC.webidl index aead123fc10..770644fef1f 100644 --- a/dom/webidl/MozNFC.webidl +++ b/dom/webidl/MozNFC.webidl @@ -46,15 +46,10 @@ interface MozNFCManager { NavigatorProperty="mozNfc", Func="Navigator::HasNFCSupport"] interface MozNFC : EventTarget { - /** - * Returns MozNFCTag object or null in case of invalid sessionToken - */ - MozNFCTag? getNFCTag(DOMString sessionToken); - - /** - * Returns MozNFCPeer object or null in case of invalid sessionToken - */ - MozNFCPeer? getNFCPeer(DOMString sessionToken); + [Throws] + MozNFCTag getNFCTag(DOMString sessionId); + [Throws] + MozNFCPeer getNFCPeer(DOMString sessionId); /** * This event will be fired when another NFCPeer is detected, and user confirms From d426d698c526bbc5d7420346a0e938b9bdde9914 Mon Sep 17 00:00:00 2001 From: Krzysztof Mioduszewski Date: Tue, 5 Aug 2014 05:06:00 -0400 Subject: [PATCH 42/49] Bug 1042651 - B2G NFC: getNFCPeer and getNFCTag should not throw error. r=smaug, r=allstars.chh, a=me --- dom/nfc/nsNfc.js | 6 ++-- dom/nfc/tests/marionette/test_nfc_peer.js | 35 ++++++++++++++--------- dom/webidl/MozNFC.webidl | 13 ++++++--- 3 files changed, 32 insertions(+), 22 deletions(-) diff --git a/dom/nfc/nsNfc.js b/dom/nfc/nsNfc.js index 3cc1c08d88b..ccbaad40202 100644 --- a/dom/nfc/nsNfc.js +++ b/dom/nfc/nsNfc.js @@ -204,14 +204,12 @@ mozNfc.prototype = { if (this._nfcContentHelper.setSessionToken(sessionToken)) { return this._window.MozNFCTag._create(this._window, obj); } - throw new Error("Unable to create NFCTag object, Reason: Bad SessionToken " + - sessionToken); + return null; }, getNFCPeer: function getNFCPeer(sessionToken) { if (!sessionToken || !this._nfcContentHelper.setSessionToken(sessionToken)) { - throw new Error("Unable to create NFCPeer object, Reason: Bad SessionToken " + - sessionToken); + return null; } if (!this.nfcObject) { diff --git a/dom/nfc/tests/marionette/test_nfc_peer.js b/dom/nfc/tests/marionette/test_nfc_peer.js index 62ecf5ccb10..7cfba0e24cb 100644 --- a/dom/nfc/tests/marionette/test_nfc_peer.js +++ b/dom/nfc/tests/marionette/test_nfc_peer.js @@ -85,18 +85,6 @@ function testCheckP2PRegFailure() { toggleNFC(true).then(() => NCI.activateRE(emulator.P2P_RE_INDEX_0)); } -function testCheckNfcPeerObjForInvalidToken() { - try { - // Use a'fakeSessionToken' - let peer = nfc.getNFCPeer("fakeSessionToken"); - ok(false, "Should not get a NFCPeer object."); - } catch (ex) { - ok(true, "Exception expected"); - } - - toggleNFC(false).then(runNextTest); -} - function testPeerLostShouldNotBeCalled() { nfc.onpeerlost = function () { ok(false, "onpeerlost shouldn't be called"); @@ -151,12 +139,31 @@ function testPeerShouldThrow() { toggleNFC(false).then(runNextTest); } +function testPeerInvalidToken() { + let peer = nfc.getNFCPeer("fakeSessionToken"); + is(peer, null, "NFCPeer should be null on wrong session token"); + + runNextTest(); +} + +/** + * Added for completeness in Bug 1042651, + * TODO: remove once Bug 963531 lands + */ +function testTagInvalidToken() { + let tag = nfc.getNFCTag("fakeSessionToken"); + is(tag, null, "NFCTag should be null on wrong session token"); + + runNextTest(); +} + let tests = [ testPeerReady, testCheckP2PRegFailure, - testCheckNfcPeerObjForInvalidToken, testPeerLostShouldNotBeCalled, - testPeerShouldThrow + testPeerShouldThrow, + testPeerInvalidToken, + testTagInvalidToken ]; SpecialPowers.pushPermissions( diff --git a/dom/webidl/MozNFC.webidl b/dom/webidl/MozNFC.webidl index a615e94184a..3ffda0e2722 100644 --- a/dom/webidl/MozNFC.webidl +++ b/dom/webidl/MozNFC.webidl @@ -46,10 +46,15 @@ interface MozNFCManager { NavigatorProperty="mozNfc", Func="Navigator::HasNFCSupport"] interface MozNFC : EventTarget { - [Throws] - MozNFCTag getNFCTag(DOMString sessionId); - [Throws] - MozNFCPeer getNFCPeer(DOMString sessionId); + /** + * Returns MozNFCTag object or null in case of invalid sessionToken + */ + MozNFCTag? getNFCTag(DOMString sessionToken); + + /** + * Returns MozNFCPeer object or null in case of invalid sessionToken + */ + MozNFCPeer? getNFCPeer(DOMString sessionToken); [CheckPermissions="nfc-write"] attribute EventHandler onpeerready; From a7644779280126e415c9b3f8980e66b373b91cfc Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 13:01:50 -0700 Subject: [PATCH 43/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-kk/sources.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index b41329f12ed..7eccf0c31b4 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -12,7 +12,7 @@ - + From d6bf70c5ab64bcb5dc90875fe075a84f1705dd0d Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 13:10:23 -0700 Subject: [PATCH 44/49] Bumping gaia.json for 6 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/aa934b827342 Author: Pavel Ivanov Desc: Merge pull request #22501 from pivanov/bug-1037606 Bug 1037606 - The placeholder text shown when the list of contacts is empty is left aligned in RTL mode ======== https://hg.mozilla.org/integration/gaia-central/rev/90b0ffacd479 Author: Pavel Ivanov Desc: Bug 1037606 - The placeholder text shown when the list of contacts is empty is left aligned in RTL mode ======== https://hg.mozilla.org/integration/gaia-central/rev/893149213746 Author: Pavel Ivanov Desc: Merge pull request #22502 from pivanov/bug-1037607 Bug 1037607 - The drop-down fields in the add contact dialog are left aligned ======== https://hg.mozilla.org/integration/gaia-central/rev/46944f3c88fb Author: Pavel Ivanov Desc: Bug 1037607 - The drop-down fields in the add contact dialog are left aligned ======== https://hg.mozilla.org/integration/gaia-central/rev/17f156ed4f0a Author: vingtetun <21@vingtetun.org> Desc: Merge pull request #22586 from vingtetun/system.dialog.size2 Bug 1047411 - Firefox Accounts UI misplaced. r=alive ======== https://hg.mozilla.org/integration/gaia-central/rev/8938b405f3ba Author: Vivien Nicolas Desc: Bug 1047411 - Firefox Accounts UI misplaced. r=alive --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index e9fd792ce90..7032e0814e1 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "6affb05ae3283942609e9411b2d1d659bd67a8a4", + "revision": "aa934b82734277331ead4666fa115b6cfedbdaae", "repo_path": "/integration/gaia-central" } From 8333cb76f190ca3240f62c6a7039294065607e60 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 13:12:09 -0700 Subject: [PATCH 45/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 20d43147ed5..6d9e100b7ac 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 72135e3b405..91604246593 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 7eccf0c31b4..acd969c25a0 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 20d43147ed5..6d9e100b7ac 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 88f2d46ef44..9d72dec441a 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 0b83f30439e..79b5a5579bb 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 5cd07c3533e..5c90ac0c53d 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index cb0e08ff0a5..339d5fd49c1 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 3838f3b6762..f06bbc83cde 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From fa0f8a5bbec322ec104a0f5e54ccdcb8f07c6358 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 13:35:31 -0700 Subject: [PATCH 46/49] Bumping gaia.json for 4 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/cffb8e7efe8a Author: Kevin Grandon Desc: Merge pull request #22504 from KevinGrandon/bug_1048629_remove_haida_flag Bug 1048629 - Remove rocketbar.enabled setting ======== https://hg.mozilla.org/integration/gaia-central/rev/aed32eb077b6 Author: Kevin Grandon Desc: Bug 1048629 - Remove HAIDA setting from build scripts R=alive R=yurenju F=sfoster ======== https://hg.mozilla.org/integration/gaia-central/rev/6aec0bd4b583 Author: vingtetun <21@vingtetun.org> Desc: Merge pull request #22590 from vingtetun/low.battery.red Bug 1049759 - Low battery indicator on the browser chrome titlebar is no... ======== https://hg.mozilla.org/integration/gaia-central/rev/62df7c175df3 Author: Vivien Nicolas Desc: Bug 1049759 - Low battery indicator on the browser chrome titlebar is not red. r=kgrandon --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index 7032e0814e1..baf5f3c343c 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "aa934b82734277331ead4666fa115b6cfedbdaae", + "revision": "cffb8e7efe8a20181c00289e2d027326702c460c", "repo_path": "/integration/gaia-central" } From cdfff332df8f1037517ff7d6f87d15b89f8a77df Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 13:41:18 -0700 Subject: [PATCH 47/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 6d9e100b7ac..9bc810e298c 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 91604246593..16715439410 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index acd969c25a0..035cd0305c8 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 6d9e100b7ac..9bc810e298c 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 9d72dec441a..4a8ce9766a8 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index 79b5a5579bb..a50c6b4b615 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index 5c90ac0c53d..d6f4ba3243e 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 339d5fd49c1..43a686046c0 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index f06bbc83cde..170742b7cdb 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - + From d772922fe2ad3df40e79392e3d614a00befe44a3 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 14:05:30 -0700 Subject: [PATCH 48/49] Bumping gaia.json for 2 gaia revision(s) a=gaia-bump ======== https://hg.mozilla.org/integration/gaia-central/rev/6b8f72fc133b Author: Kevin Grandon Desc: Merge pull request #22587 from KevinGrandon/bug_1049678_wc_text_content Bug 1049678 - [GaiaGrid] Remove textContent workaround ======== https://hg.mozilla.org/integration/gaia-central/rev/ef49448d1ede Author: Kevin Grandon Desc: Bug 1049678 - [GaiaGrid] Remove textContent workaround r=wilsonpage --- b2g/config/gaia.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/b2g/config/gaia.json b/b2g/config/gaia.json index baf5f3c343c..27ccaeb4a49 100644 --- a/b2g/config/gaia.json +++ b/b2g/config/gaia.json @@ -4,6 +4,6 @@ "remote": "", "branch": "" }, - "revision": "cffb8e7efe8a20181c00289e2d027326702c460c", + "revision": "6b8f72fc133bcfe4cf58a133a2f5e24ae2c25ad6", "repo_path": "/integration/gaia-central" } From d62beeb890e051b0860748462bc868f51d2090d9 Mon Sep 17 00:00:00 2001 From: B2G Bumper Bot Date: Wed, 6 Aug 2014 14:11:16 -0700 Subject: [PATCH 49/49] Bumping manifests a=b2g-bump --- b2g/config/emulator-ics/sources.xml | 2 +- b2g/config/emulator-jb/sources.xml | 2 +- b2g/config/emulator-kk/sources.xml | 2 +- b2g/config/emulator/sources.xml | 2 +- b2g/config/flame/sources.xml | 2 +- b2g/config/hamachi/sources.xml | 2 +- b2g/config/helix/sources.xml | 2 +- b2g/config/nexus-4/sources.xml | 2 +- b2g/config/wasabi/sources.xml | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/b2g/config/emulator-ics/sources.xml b/b2g/config/emulator-ics/sources.xml index 9bc810e298c..89242f6140a 100644 --- a/b2g/config/emulator-ics/sources.xml +++ b/b2g/config/emulator-ics/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/emulator-jb/sources.xml b/b2g/config/emulator-jb/sources.xml index 16715439410..0739425b0bd 100644 --- a/b2g/config/emulator-jb/sources.xml +++ b/b2g/config/emulator-jb/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/emulator-kk/sources.xml b/b2g/config/emulator-kk/sources.xml index 035cd0305c8..d243887ac68 100644 --- a/b2g/config/emulator-kk/sources.xml +++ b/b2g/config/emulator-kk/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/emulator/sources.xml b/b2g/config/emulator/sources.xml index 9bc810e298c..89242f6140a 100644 --- a/b2g/config/emulator/sources.xml +++ b/b2g/config/emulator/sources.xml @@ -19,7 +19,7 @@ - + diff --git a/b2g/config/flame/sources.xml b/b2g/config/flame/sources.xml index 4a8ce9766a8..729cc5e5414 100644 --- a/b2g/config/flame/sources.xml +++ b/b2g/config/flame/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/hamachi/sources.xml b/b2g/config/hamachi/sources.xml index a50c6b4b615..2899012a40e 100644 --- a/b2g/config/hamachi/sources.xml +++ b/b2g/config/hamachi/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/helix/sources.xml b/b2g/config/helix/sources.xml index d6f4ba3243e..248c079c4f7 100644 --- a/b2g/config/helix/sources.xml +++ b/b2g/config/helix/sources.xml @@ -15,7 +15,7 @@ - + diff --git a/b2g/config/nexus-4/sources.xml b/b2g/config/nexus-4/sources.xml index 43a686046c0..ebedeade13e 100644 --- a/b2g/config/nexus-4/sources.xml +++ b/b2g/config/nexus-4/sources.xml @@ -17,7 +17,7 @@ - + diff --git a/b2g/config/wasabi/sources.xml b/b2g/config/wasabi/sources.xml index 170742b7cdb..5099889993e 100644 --- a/b2g/config/wasabi/sources.xml +++ b/b2g/config/wasabi/sources.xml @@ -17,7 +17,7 @@ - +