Remove other gonk widget conditionals and unused files.

Tag #288.
pull/1/head
wolfbeast 4 years ago committed by Roy Tam
parent 5830ff1f2b
commit 74df182488
  1. 11
      accessible/jsat/PointerAdapter.jsm
  2. 19
      build/gyp.mozbuild
  3. 13
      devtools/shared/discovery/discovery.js
  4. 5
      dom/base/moz.build
  5. 3
      dom/canvas/test/webgl-mochitest/driver-info.js
  6. 5
      dom/events/moz.build
  7. 4
      dom/geolocation/moz.build
  8. 2
      dom/indexedDB/test/unit/xpcshell-child-process.ini
  9. 1
      dom/indexedDB/test/unit/xpcshell-parent-process.ini
  10. 2
      dom/ipc/moz.build
  11. 84
      dom/media/encoder/fmp4_muxer/AMRBox.cpp
  12. 50
      dom/media/encoder/fmp4_muxer/AMRBox.h
  13. 87
      dom/media/encoder/fmp4_muxer/AVCBox.cpp
  14. 59
      dom/media/encoder/fmp4_muxer/AVCBox.h
  15. 84
      dom/media/encoder/fmp4_muxer/EVRCBox.cpp
  16. 50
      dom/media/encoder/fmp4_muxer/EVRCBox.h
  17. 415
      dom/media/encoder/fmp4_muxer/ISOControl.cpp
  18. 250
      dom/media/encoder/fmp4_muxer/ISOControl.h
  19. 1550
      dom/media/encoder/fmp4_muxer/ISOMediaBoxes.cpp
  20. 781
      dom/media/encoder/fmp4_muxer/ISOMediaBoxes.h
  21. 229
      dom/media/encoder/fmp4_muxer/ISOMediaWriter.cpp
  22. 108
      dom/media/encoder/fmp4_muxer/ISOMediaWriter.h
  23. 131
      dom/media/encoder/fmp4_muxer/ISOTrackMetadata.h
  24. 138
      dom/media/encoder/fmp4_muxer/MP4ESDS.cpp
  25. 87
      dom/media/encoder/fmp4_muxer/MP4ESDS.h
  26. 57
      dom/media/encoder/fmp4_muxer/MuxerOperation.h
  27. 22
      dom/media/encoder/fmp4_muxer/moz.build
  28. 13
      dom/media/encoder/moz.build
  29. 667
      dom/media/platforms/omx/GonkOmxPlatformLayer.cpp
  30. 205
      dom/media/platforms/omx/GonkOmxPlatformLayer.h
  31. 23
      dom/media/platforms/omx/moz.build
  32. 2
      dom/media/standalone/moz.build
  33. 10
      dom/media/systemservices/moz.build
  34. 7
      dom/moz.build
  35. 655
      dom/network/EthernetManager.js
  36. 2
      dom/network/EthernetManager.manifest
  37. 200
      dom/network/NetUtils.cpp
  38. 75
      dom/network/NetUtils.h
  39. 1285
      dom/network/NetworkStatsDB.jsm
  40. 388
      dom/network/NetworkStatsManager.js
  41. 14
      dom/network/NetworkStatsManager.manifest
  42. 1171
      dom/network/NetworkStatsService.jsm
  43. 90
      dom/network/NetworkStatsServiceProxy.js
  44. 2
      dom/network/NetworkStatsServiceProxy.manifest
  45. 6
      dom/network/interfaces/moz.build
  46. 137
      dom/network/interfaces/nsIEthernetManager.idl
  47. 64
      dom/network/interfaces/nsINetworkStatsServiceProxy.idl
  48. 22
      dom/network/moz.build
  49. 1
      dom/permission/tests/mochitest.ini
  50. 217
      dom/speakermanager/SpeakerManager.cpp
  51. 66
      dom/speakermanager/SpeakerManager.h
  52. 224
      dom/speakermanager/SpeakerManagerService.cpp
  53. 79
      dom/speakermanager/SpeakerManagerService.h
  54. 121
      dom/speakermanager/SpeakerManagerServiceChild.cpp
  55. 44
      dom/speakermanager/SpeakerManagerServiceChild.h
  56. 23
      dom/speakermanager/moz.build
  57. 3
      dom/speakermanager/tests/mochitest.ini
  58. 53
      dom/speakermanager/tests/test_speakermanager.html
  59. 92
      dom/tethering/TetheringManager.js
  60. 4
      dom/tethering/TetheringManager.manifest
  61. 12
      dom/tethering/moz.build
  62. 768
      dom/tethering/tests/marionette/head.js
  63. 7
      dom/tethering/tests/marionette/manifest.ini
  64. 37
      dom/tethering/tests/marionette/test_wifi_tethering_dun.js
  65. 12
      dom/tethering/tests/marionette/test_wifi_tethering_enabled.js
  66. 73
      dom/webidl/MozNetworkStats.webidl
  67. 13
      dom/webidl/MozNetworkStatsAlarm.webidl
  68. 12
      dom/webidl/MozNetworkStatsData.webidl
  69. 26
      dom/webidl/MozNetworkStatsInterface.webidl
  70. 96
      dom/webidl/MozNetworkStatsManager.webidl
  71. 18
      dom/webidl/MozSpeakerManager.webidl
  72. 46
      dom/webidl/MozWifiCapabilities.webidl
  73. 43
      dom/webidl/MozWifiConnectionInfoEvent.webidl
  74. 347
      dom/webidl/MozWifiManager.webidl
  75. 147
      dom/webidl/MozWifiP2pManager.webidl
  76. 20
      dom/webidl/MozWifiP2pStatusChangeEvent.webidl
  77. 19
      dom/webidl/MozWifiStationInfoEvent.webidl
  78. 27
      dom/webidl/MozWifiStatusChangeEvent.webidl
  79. 27
      dom/webidl/moz.build
  80. 543
      dom/wifi/DOMWifiManager.js
  81. 18
      dom/wifi/DOMWifiManager.manifest
  82. 328
      dom/wifi/DOMWifiP2pManager.js
  83. 6
      dom/wifi/DOMWifiP2pManager.manifest
  84. 205
      dom/wifi/StateMachine.jsm
  85. 536
      dom/wifi/WifiCertService.cpp
  86. 40
      dom/wifi/WifiCertService.h
  87. 594
      dom/wifi/WifiCommand.jsm
  88. 188
      dom/wifi/WifiHotspotUtils.cpp
  89. 46
      dom/wifi/WifiHotspotUtils.h
  90. 154
      dom/wifi/WifiNetUtil.jsm
  91. 1649
      dom/wifi/WifiP2pManager.jsm
  92. 319
      dom/wifi/WifiP2pWorkerObserver.jsm
  93. 357
      dom/wifi/WifiProxyService.cpp
  94. 49
      dom/wifi/WifiProxyService.h
  95. 521
      dom/wifi/WifiUtils.cpp
  96. 107
      dom/wifi/WifiUtils.h
  97. 9
      dom/wifi/WifiWorker.h
  98. 3928
      dom/wifi/WifiWorker.js
  99. 1
      dom/wifi/WifiWorker.manifest
  100. 41
      dom/wifi/moz.build
  101. Some files were not shown because too many files have changed in this diff Show More

@ -46,17 +46,6 @@ var PointerRelay = { // jshint ignore:line
'touchend' : true };
break;
case 'gonk':
this._eventsOfInterest = {
'touchstart' : true,
'touchmove' : true,
'touchend' : true,
'mousedown' : false,
'mousemove' : false,
'mouseup': false,
'click': false };
break;
default:
// Desktop.
this._eventsOfInterest = {

@ -79,22 +79,15 @@ if os == 'WINNT':
MSVS_OS_BITS=64 if CONFIG['HAVE_64BIT_BUILD'] else 32,
)
elif os == 'Android':
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
gyp_vars['build_with_gonk'] = 1
gyp_vars['moz_widget_toolkit_gonk'] = 1
gyp_vars['opus_complexity'] = 1
if int(CONFIG['ANDROID_VERSION']) >= 18:
gyp_vars['moz_webrtc_omx'] = 1
else:
gyp_vars.update(
gtest_target_type='executable',
moz_webrtc_mediacodec=1,
android_toolchain=CONFIG.get('ANDROID_TOOLCHAIN', ''),
)
gyp_vars.update(
gtest_target_type='executable',
moz_webrtc_mediacodec=1,
android_toolchain=CONFIG.get('ANDROID_TOOLCHAIN', ''),
)
flavors = {
'WINNT': 'win',
'Android': 'linux' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk' else 'android',
'Android': 'android',
'Linux': 'linux',
'Darwin': 'mac' if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa' else 'ios',
'SunOS': 'solaris',

@ -181,18 +181,7 @@ LocalDevice.prototype = {
* Triggers the |name| setter to persist if needed.
*/
_generate: function () {
if (Services.appinfo.widgetToolkit == "gonk") {
// For Firefox OS devices, create one from the device name plus a little
// randomness. The goal is just to distinguish devices in an office
// environment where many people may have the same device model for
// testing purposes (which would otherwise all report the same name).
let name = libcutils.property_get("ro.product.device");
// Pick a random number from [0, 2^32)
let randomID = Math.floor(Math.random() * Math.pow(2, 32));
// To hex and zero pad
randomID = ("00000000" + randomID.toString(16)).slice(-8);
this.name = name + "-" + randomID;
} else if (Services.appinfo.widgetToolkit == "android") {
if (Services.appinfo.widgetToolkit == "android") {
// For Firefox for Android, use the device's model name.
// TODO: Bug 1180997: Find the right way to expose an editable name
this.name = sysInfo.get("device");

@ -462,11 +462,6 @@ LOCAL_INCLUDES += [
'/xpcom/ds',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
LOCAL_INCLUDES += [
'../system/gonk',
]
if CONFIG['MOZ_WEBRTC']:
LOCAL_INCLUDES += [
'/netwerk/sctp/datachannel',

@ -81,9 +81,6 @@ DriverInfo = (function() {
var versionMatch = /Mac OS X (\d+.\d+)/.exec(navigator.userAgent);
version = versionMatch ? parseFloat(versionMatch[1]) : null;
} else if (runtime.widgetToolkit == 'gonk') {
os = OS.B2G;
} else if (navigator.appVersion.indexOf('Android') != -1) {
os = OS.ANDROID;
// From layout/tools/reftest/reftest.js:

@ -153,10 +153,5 @@ LOCAL_INCLUDES += [
'/layout/xul/tree/',
]
if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
LOCAL_INCLUDES += [
'/dom/wifi',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wno-error=shadow']

@ -30,10 +30,6 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'android':
LOCAL_INCLUDES += [
'/dom/system/android',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'gonk':
LOCAL_INCLUDES += [
'/dom/system/gonk',
]
elif CONFIG['MOZ_WIDGET_TOOLKIT'] == 'cocoa':
LOCAL_INCLUDES += [
'/dom/system/mac',

@ -6,7 +6,7 @@
dupe-manifest =
head = xpcshell-head-child-process.js
tail =
skip-if = toolkit == 'android' || toolkit == 'gonk'
skip-if = toolkit == 'android'
support-files =
GlobalObjectsChild.js
GlobalObjectsComponent.js

@ -6,7 +6,6 @@
dupe-manifest =
head = xpcshell-head-parent-process.js
tail =
skip-if = toolkit == 'gonk'
support-files =
bug1056939_profile.zip
defaultStorageUpgrade_profile.zip

@ -147,7 +147,7 @@ if CONFIG['OS_ARCH'] != 'WINNT':
DEFINES['BIN_SUFFIX'] = '"%s"' % CONFIG['BIN_SUFFIX']
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2', 'gonk'):
if CONFIG['MOZ_WIDGET_TOOLKIT'] in ('android', 'gtk2'):
DEFINES['MOZ_ENABLE_FREETYPE'] = True
if CONFIG['MOZ_TOOLKIT_SEARCH']:

@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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 "ISOControl.h"
#include "ISOMediaBoxes.h"
#include "AMRBox.h"
#include "ISOTrackMetadata.h"
namespace mozilla {
nsresult
AMRSampleEntry::Generate(uint32_t* aBoxSize)
{
uint32_t box_size;
nsresult rv = amr_special_box->Generate(&box_size);
NS_ENSURE_SUCCESS(rv, rv);
size += box_size;
*aBoxSize = size;
return NS_OK;
}
nsresult
AMRSampleEntry::Write()
{
BoxSizeChecker checker(mControl, size);
nsresult rv;
rv = AudioSampleEntry::Write();
NS_ENSURE_SUCCESS(rv, rv);
rv = amr_special_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
AMRSampleEntry::AMRSampleEntry(ISOControl* aControl)
: AudioSampleEntry(NS_LITERAL_CSTRING("samr"), aControl)
{
amr_special_box = new AMRSpecificBox(aControl);
MOZ_COUNT_CTOR(AMRSampleEntry);
}
AMRSampleEntry::~AMRSampleEntry()
{
MOZ_COUNT_DTOR(AMRSampleEntry);
}
nsresult
AMRSpecificBox::Generate(uint32_t* aBoxSize)
{
nsresult rv;
FragmentBuffer* frag = mControl->GetFragment(Audio_Track);
rv = frag->GetCSD(amrDecSpecInfo);
NS_ENSURE_SUCCESS(rv, rv);
size += amrDecSpecInfo.Length();
*aBoxSize = size;
return NS_OK;
}
nsresult
AMRSpecificBox::Write()
{
BoxSizeChecker checker(mControl, size);
Box::Write();
mControl->Write(amrDecSpecInfo.Elements(), amrDecSpecInfo.Length());
return NS_OK;
}
AMRSpecificBox::AMRSpecificBox(ISOControl* aControl)
: Box(NS_LITERAL_CSTRING("damr"), aControl)
{
MOZ_COUNT_CTOR(AMRSpecificBox);
}
AMRSpecificBox::~AMRSpecificBox()
{
MOZ_COUNT_DTOR(AMRSpecificBox);
}
}

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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/. */
#ifndef AMRBOX_h_
#define AMRBOX_h_
#include "nsTArray.h"
#include "MuxerOperation.h"
namespace mozilla {
class ISOControl;
// 3GPP TS 26.244 6.7 'AMRSpecificBox field for AMRSampleEntry box'
// Box type: 'damr'
class AMRSpecificBox : public Box {
public:
// 3GPP members
nsTArray<uint8_t> amrDecSpecInfo;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// AMRSpecificBox methods
AMRSpecificBox(ISOControl* aControl);
~AMRSpecificBox();
};
// 3GPP TS 26.244 6.5 'AMRSampleEntry box'
// Box type: 'sawb'
class AMRSampleEntry : public AudioSampleEntry {
public:
// 3GPP members
RefPtr<AMRSpecificBox> amr_special_box;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// AMRSampleEntry methods
AMRSampleEntry(ISOControl* aControl);
~AMRSampleEntry();
};
}
#endif // AMRBOX_h_

@ -1,87 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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 <climits>
#include "ISOControl.h"
#include "ISOMediaBoxes.h"
#include "AVCBox.h"
namespace mozilla {
nsresult
AVCSampleEntry::Generate(uint32_t* aBoxSize)
{
uint32_t avc_box_size = 0;
nsresult rv;
rv = avcConfigBox->Generate(&avc_box_size);
NS_ENSURE_SUCCESS(rv, rv);
size += avc_box_size;
*aBoxSize = size;
return NS_OK;
}
nsresult
AVCSampleEntry::Write()
{
BoxSizeChecker checker(mControl, size);
nsresult rv;
rv = VisualSampleEntry::Write();
NS_ENSURE_SUCCESS(rv, rv);
rv = avcConfigBox->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
AVCSampleEntry::AVCSampleEntry(ISOControl* aControl)
: VisualSampleEntry(NS_LITERAL_CSTRING("avc1"), aControl)
{
avcConfigBox = new AVCConfigurationBox(aControl);
MOZ_COUNT_CTOR(AVCSampleEntry);
}
AVCSampleEntry::~AVCSampleEntry()
{
MOZ_COUNT_DTOR(AVCSampleEntry);
}
AVCConfigurationBox::AVCConfigurationBox(ISOControl* aControl)
: Box(NS_LITERAL_CSTRING("avcC"), aControl)
{
MOZ_COUNT_CTOR(AVCConfigurationBox);
}
AVCConfigurationBox::~AVCConfigurationBox()
{
MOZ_COUNT_DTOR(AVCConfigurationBox);
}
nsresult
AVCConfigurationBox::Generate(uint32_t* aBoxSize)
{
nsresult rv;
FragmentBuffer* frag = mControl->GetFragment(Video_Track);
rv = frag->GetCSD(avcConfig);
NS_ENSURE_SUCCESS(rv, rv);
size += avcConfig.Length();
*aBoxSize = size;
return NS_OK;
}
nsresult
AVCConfigurationBox::Write()
{
BoxSizeChecker checker(mControl, size);
Box::Write();
mControl->Write(avcConfig.Elements(), avcConfig.Length());
return NS_OK;
}
}

@ -1,59 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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/. */
#ifndef AVCBox_h_
#define AVCBox_h_
#include "nsTArray.h"
#include "ISOMediaBoxes.h"
namespace mozilla {
class ISOControl;
// 14496-12 8.5.2.2
#define resolution_72_dpi 0x00480000
#define video_depth 0x0018
// 14496-15 5.3.4.1 'Sample description name and format'
// Box type: 'avcC'
class AVCConfigurationBox : public Box {
public:
// ISO BMFF members
// avcConfig is CodecSpecificData from 14496-15 '5.3.4.1 Sample description
// name and format.
// These data are generated by encoder and we encapsulated the generated
// bitstream into box directly.
nsTArray<uint8_t> avcConfig;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// AVCConfigurationBox methods
AVCConfigurationBox(ISOControl* aControl);
~AVCConfigurationBox();
};
// 14496-15 5.3.4.1 'Sample description name and format'
// Box type: 'avc1'
class AVCSampleEntry : public VisualSampleEntry {
public:
// ISO BMFF members
RefPtr<AVCConfigurationBox> avcConfigBox;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// VisualSampleEntry methods
AVCSampleEntry(ISOControl* aControl);
~AVCSampleEntry();
};
}
#endif // AVCBox_h_

@ -1,84 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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 "ISOControl.h"
#include "ISOMediaBoxes.h"
#include "EVRCBox.h"
#include "ISOTrackMetadata.h"
namespace mozilla {
nsresult
EVRCSampleEntry::Generate(uint32_t* aBoxSize)
{
uint32_t box_size;
nsresult rv = evrc_special_box->Generate(&box_size);
NS_ENSURE_SUCCESS(rv, rv);
size += box_size;
*aBoxSize = size;
return NS_OK;
}
nsresult
EVRCSampleEntry::Write()
{
BoxSizeChecker checker(mControl, size);
nsresult rv;
rv = AudioSampleEntry::Write();
NS_ENSURE_SUCCESS(rv, rv);
rv = evrc_special_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
EVRCSampleEntry::EVRCSampleEntry(ISOControl* aControl)
: AudioSampleEntry(NS_LITERAL_CSTRING("sevc"), aControl)
{
evrc_special_box = new EVRCSpecificBox(aControl);
MOZ_COUNT_CTOR(EVRCSampleEntry);
}
EVRCSampleEntry::~EVRCSampleEntry()
{
MOZ_COUNT_DTOR(EVRCSampleEntry);
}
nsresult
EVRCSpecificBox::Generate(uint32_t* aBoxSize)
{
nsresult rv;
FragmentBuffer* frag = mControl->GetFragment(Audio_Track);
rv = frag->GetCSD(evrcDecSpecInfo);
NS_ENSURE_SUCCESS(rv, rv);
size += evrcDecSpecInfo.Length();
*aBoxSize = size;
return NS_OK;
}
nsresult
EVRCSpecificBox::Write()
{
BoxSizeChecker checker(mControl, size);
Box::Write();
mControl->Write(evrcDecSpecInfo.Elements(), evrcDecSpecInfo.Length());
return NS_OK;
}
EVRCSpecificBox::EVRCSpecificBox(ISOControl* aControl)
: Box(NS_LITERAL_CSTRING("devc"), aControl)
{
MOZ_COUNT_CTOR(EVRCSpecificBox);
}
EVRCSpecificBox::~EVRCSpecificBox()
{
MOZ_COUNT_DTOR(EVRCSpecificBox);
}
}

@ -1,50 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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/. */
#ifndef EVRCBOX_h_
#define EVRCBOX_h_
#include "nsTArray.h"
#include "MuxerOperation.h"
namespace mozilla {
class ISOControl;
// 3GPP TS 26.244 6.7 'EVRCSpecificBox field for EVRCSampleEntry box'
// Box type: 'devc'
class EVRCSpecificBox : public Box {
public:
// 3GPP members
nsTArray<uint8_t> evrcDecSpecInfo;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// EVRCSpecificBox methods
EVRCSpecificBox(ISOControl* aControl);
~EVRCSpecificBox();
};
// 3GPP TS 26.244 6.5 'EVRCSampleEntry box'
// Box type: 'sevc'
class EVRCSampleEntry : public AudioSampleEntry {
public:
// 3GPP members
RefPtr<EVRCSpecificBox> evrc_special_box;
// MuxerOperation methods
nsresult Generate(uint32_t* aBoxSize) override;
nsresult Write() override;
// EVRCSampleEntry methods
EVRCSampleEntry(ISOControl* aControl);
~EVRCSampleEntry();
};
}
#endif // EVRCBOX_h_

@ -1,415 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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 <time.h>
#include "nsAutoPtr.h"
#include "ISOControl.h"
#include "ISOMediaBoxes.h"
#include "EncodedFrameContainer.h"
namespace mozilla {
// For MP4 creation_time and modification_time offset from January 1, 1904 to
// January 1, 1970.
#define iso_time_offset 2082844800
FragmentBuffer::FragmentBuffer(uint32_t aTrackType, uint32_t aFragDuration)
: mTrackType(aTrackType)
, mFragDuration(aFragDuration)
, mMediaStartTime(0)
, mFragmentNumber(0)
, mLastFrameTimeOfLastFragment(0)
, mEOS(false)
{
mFragArray.AppendElement();
MOZ_COUNT_CTOR(FragmentBuffer);
}
FragmentBuffer::~FragmentBuffer()
{
MOZ_COUNT_DTOR(FragmentBuffer);
}
bool
FragmentBuffer::HasEnoughData()
{
// Audio or video frame is enough to form a moof.
return (mFragArray.Length() > 1);
}
nsresult
FragmentBuffer::GetCSD(nsTArray<uint8_t>& aCSD)
{
if (!mCSDFrame) {
return NS_ERROR_FAILURE;
}
aCSD.AppendElements(mCSDFrame->GetFrameData().Elements(),
mCSDFrame->GetFrameData().Length());
return NS_OK;
}
nsresult
FragmentBuffer::AddFrame(EncodedFrame* aFrame)
{
// already EOS, it rejects all new data.
if (mEOS) {
MOZ_ASSERT(0);
return NS_OK;
}
EncodedFrame::FrameType type = aFrame->GetFrameType();
if (type == EncodedFrame::AAC_CSD || type == EncodedFrame::AVC_CSD ||
type == EncodedFrame::AMR_AUDIO_CSD || type == EncodedFrame::EVRC_AUDIO_CSD) {
mCSDFrame = aFrame;
// Use CSD's timestamp as the start time. Encoder should send CSD frame first
// and then data frames.
mMediaStartTime = aFrame->GetTimeStamp();
mFragmentNumber = 1;
return NS_OK;
}
// if the timestamp is incorrect, abort it.
if (aFrame->GetTimeStamp() < mMediaStartTime) {
MOZ_ASSERT(false);
return NS_ERROR_FAILURE;
}
mFragArray.LastElement().AppendElement(aFrame);
// check if current fragment is reach the fragment duration.
if ((aFrame->GetTimeStamp() - mMediaStartTime) >= (mFragDuration * mFragmentNumber)) {
mFragArray.AppendElement();
mFragmentNumber++;
}
return NS_OK;
}
nsresult
FragmentBuffer::GetFirstFragment(nsTArray<RefPtr<EncodedFrame>>& aFragment,
bool aFlush)
{
// It should be called only if there is a complete fragment in mFragArray.
if (mFragArray.Length() <= 1 && !mEOS) {
MOZ_ASSERT(false);
return NS_ERROR_FAILURE;
}
if (aFlush) {
aFragment.SwapElements(mFragArray.ElementAt(0));
mFragArray.RemoveElementAt(0);
} else {
aFragment.AppendElements(mFragArray.ElementAt(0));
}
return NS_OK;
}
uint32_t
FragmentBuffer::GetFirstFragmentSampleNumber()
{
return mFragArray.ElementAt(0).Length();
}
uint32_t
FragmentBuffer::GetFirstFragmentSampleSize()
{
uint32_t size = 0;
uint32_t len = mFragArray.ElementAt(0).Length();
for (uint32_t i = 0; i < len; i++) {
size += mFragArray.ElementAt(0).ElementAt(i)->GetFrameData().Length();
}
return size;
}
ISOControl::ISOControl(uint32_t aMuxingType)
: mMuxingType(aMuxingType)
, mAudioFragmentBuffer(nullptr)
, mVideoFragmentBuffer(nullptr)
, mFragNum(0)
, mOutputSize(0)
, mBitCount(0)
, mBit(0)
{
// Create a data array for first mp4 Box, ftyp.
mOutBuffers.SetLength(1);
MOZ_COUNT_CTOR(ISOControl);
}
ISOControl::~ISOControl()
{
MOZ_COUNT_DTOR(ISOControl);
}
uint32_t
ISOControl::GetNextTrackID()
{
return (mMetaArray.Length() + 1);
}
uint32_t
ISOControl::GetTrackID(TrackMetadataBase::MetadataKind aKind)
{
for (uint32_t i = 0; i < mMetaArray.Length(); i++) {
if (mMetaArray[i]->GetKind() == aKind) {
return (i + 1);
}
}
// Track ID shouldn't be 0. It must be something wrong here.
MOZ_ASSERT(0);
return 0;
}
nsresult
ISOControl::SetMetadata(TrackMetadataBase* aTrackMeta)
{
if (aTrackMeta->GetKind() == TrackMetadataBase::METADATA_AAC ||
aTrackMeta->GetKind() == TrackMetadataBase::METADATA_AMR ||
aTrackMeta->GetKind() == TrackMetadataBase::METADATA_AVC ||
aTrackMeta->GetKind() == TrackMetadataBase::METADATA_EVRC) {
mMetaArray.AppendElement(aTrackMeta);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
nsresult
ISOControl::GetAudioMetadata(RefPtr<AudioTrackMetadata>& aAudMeta)
{
for (uint32_t i = 0; i < mMetaArray.Length() ; i++) {
if (mMetaArray[i]->GetKind() == TrackMetadataBase::METADATA_AAC ||
mMetaArray[i]->GetKind() == TrackMetadataBase::METADATA_AMR ||
mMetaArray[i]->GetKind() == TrackMetadataBase::METADATA_EVRC) {
aAudMeta = static_cast<AudioTrackMetadata*>(mMetaArray[i].get());
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
nsresult
ISOControl::GetVideoMetadata(RefPtr<VideoTrackMetadata>& aVidMeta)
{
for (uint32_t i = 0; i < mMetaArray.Length() ; i++) {
if (mMetaArray[i]->GetKind() == TrackMetadataBase::METADATA_AVC) {
aVidMeta = static_cast<VideoTrackMetadata*>(mMetaArray[i].get());
return NS_OK;
}
}
return NS_ERROR_FAILURE;
}
bool
ISOControl::HasAudioTrack()
{
RefPtr<AudioTrackMetadata> audMeta;
GetAudioMetadata(audMeta);
return audMeta;
}
bool
ISOControl::HasVideoTrack()
{
RefPtr<VideoTrackMetadata> vidMeta;
GetVideoMetadata(vidMeta);
return vidMeta;
}
nsresult
ISOControl::SetFragment(FragmentBuffer* aFragment)
{
if (aFragment->GetType() == Audio_Track) {
mAudioFragmentBuffer = aFragment;
} else {
mVideoFragmentBuffer = aFragment;
}
return NS_OK;
}
FragmentBuffer*
ISOControl::GetFragment(uint32_t aType)
{
if (aType == Audio_Track) {
return mAudioFragmentBuffer;
} else if (aType == Video_Track){
return mVideoFragmentBuffer;
}
MOZ_ASSERT(0);
return nullptr;
}
nsresult
ISOControl::GetBufs(nsTArray<nsTArray<uint8_t>>* aOutputBufs)
{
uint32_t len = mOutBuffers.Length();
for (uint32_t i = 0; i < len; i++) {
mOutBuffers[i].SwapElements(*aOutputBufs->AppendElement());
}
return FlushBuf();
}
nsresult
ISOControl::FlushBuf()
{
mOutBuffers.SetLength(1);
return NS_OK;
}
uint32_t
ISOControl::WriteAVData(nsTArray<uint8_t>& aArray)
{
MOZ_ASSERT(!mBitCount);
uint32_t len = aArray.Length();
if (!len) {
return 0;
}
mOutputSize += len;
// The last element already has data, allocated a new element for pointer
// swapping.
if (mOutBuffers.LastElement().Length()) {
mOutBuffers.AppendElement();
}
// Swap the video/audio data pointer.
mOutBuffers.LastElement().SwapElements(aArray);
// Following data could be boxes, so appending a new uint8_t array here.
mOutBuffers.AppendElement();
return len;
}
uint32_t
ISOControl::WriteBits(uint64_t aBits, size_t aNumBits)
{
uint8_t output_byte = 0;
MOZ_ASSERT(aNumBits <= 64);
// TODO: rewritten following with bitset?
for (size_t i = aNumBits; i > 0; i--) {
mBit |= (((aBits >> (i - 1)) & 1) << (8 - ++mBitCount));
if (mBitCount == 8) {
Write(&mBit, sizeof(uint8_t));
mBit = 0;
mBitCount = 0;
output_byte++;
}
}
return output_byte;
}
uint32_t
ISOControl::Write(uint8_t* aBuf, uint32_t aSize)
{
mOutBuffers.LastElement().AppendElements(aBuf, aSize);
mOutputSize += aSize;
return aSize;
}
uint32_t
ISOControl::Write(uint8_t aData)
{
MOZ_ASSERT(!mBitCount);
Write((uint8_t*)&aData, sizeof(uint8_t));
return sizeof(uint8_t);
}
uint32_t
ISOControl::GetBufPos()
{
uint32_t len = mOutBuffers.Length();
uint32_t pos = 0;
for (uint32_t i = 0; i < len; i++) {
pos += mOutBuffers.ElementAt(i).Length();
}
return pos;
}
uint32_t
ISOControl::WriteFourCC(const char* aType)
{
// Bit operation should be aligned to byte before writing any byte data.
MOZ_ASSERT(!mBitCount);
uint32_t size = strlen(aType);
if (size == 4) {
return Write((uint8_t*)aType, size);
}
return 0;
}
nsresult
ISOControl::GenerateFtyp()
{
nsresult rv;
uint32_t size;
nsAutoPtr<FileTypeBox> type_box(new FileTypeBox(this));
rv = type_box->Generate(&size);
NS_ENSURE_SUCCESS(rv, rv);
rv = type_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult
ISOControl::GenerateMoov()
{
nsresult rv;
uint32_t size;
nsAutoPtr<MovieBox> moov_box(new MovieBox(this));
rv = moov_box->Generate(&size);
NS_ENSURE_SUCCESS(rv, rv);
rv = moov_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
nsresult
ISOControl::GenerateMoof(uint32_t aTrackType)
{
mFragNum++;
nsresult rv;
uint32_t size;
uint64_t first_sample_offset = mOutputSize;
nsAutoPtr<MovieFragmentBox> moof_box(new MovieFragmentBox(aTrackType, this));
nsAutoPtr<MediaDataBox> mdat_box(new MediaDataBox(aTrackType, this));
rv = moof_box->Generate(&size);
NS_ENSURE_SUCCESS(rv, rv);
first_sample_offset += size;
rv = mdat_box->Generate(&size);
NS_ENSURE_SUCCESS(rv, rv);
first_sample_offset += mdat_box->FirstSampleOffsetInMediaDataBox();
// correct offset info
nsTArray<RefPtr<MuxerOperation>> tfhds;
rv = moof_box->Find(NS_LITERAL_CSTRING("tfhd"), tfhds);
NS_ENSURE_SUCCESS(rv, rv);
uint32_t len = tfhds.Length();
for (uint32_t i = 0; i < len; i++) {
TrackFragmentHeaderBox* tfhd = (TrackFragmentHeaderBox*) tfhds.ElementAt(i).get();
rv = tfhd->UpdateBaseDataOffset(first_sample_offset);
NS_ENSURE_SUCCESS(rv, rv);
}
rv = moof_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
rv = mdat_box->Write();
NS_ENSURE_SUCCESS(rv, rv);
return NS_OK;
}
uint32_t
ISOControl::GetTime()
{
return (uint64_t)time(nullptr) + iso_time_offset;
}
}

@ -1,250 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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/. */
#ifndef ISOCOMPOSITOR_H_
#define ISOCOMPOSITOR_H_
#include "mozilla/EndianUtils.h"
#include "nsTArray.h"
#include "ISOTrackMetadata.h"
#include "EncodedFrameContainer.h"
namespace mozilla {
class Box;
class ISOControl;
/**
* This class collects elementary stream data to form a fragment.
* ISOMediaWriter will check if the data is enough; if yes, the corresponding
* moof will be created and write to ISOControl.
* Each audio and video has its own fragment and only one during the whole
* life cycle, when a fragment is formed in ISOControl, Flush() needs to
* be called to reset it.
*/
class FragmentBuffer {
public:
// aTrackType: it could be Audio_Track or Video_Track.
// aFragDuration: it is the fragment duration. (microsecond per unit)
// Audio and video have the same fragment duration.
FragmentBuffer(uint32_t aTrackType, uint32_t aFragDuration);
~FragmentBuffer();
// Get samples of first fragment, that will swap all the elements in the
// mFragArray[0] when aFlush = true, and caller is responsible for drop
// EncodedFrame reference count.
nsresult GetFirstFragment(nsTArray<RefPtr<EncodedFrame>>& aFragment,
bool aFlush = false);
// Add sample frame to the last element fragment of mFragArray. If sample
// number is enough, it will append a new fragment element. And the new
// sample will be added to the new fragment element of mFragArray.
nsresult AddFrame(EncodedFrame* aFrame);
// Get total sample size of first complete fragment size.
uint32_t GetFirstFragmentSampleSize();
// Get sample number of first complete fragment.
uint32_t GetFirstFragmentSampleNumber();
// Check if it accumulates enough frame data.
// It returns true when data is enough to form a fragment.
bool HasEnoughData();
// Called by ISOMediaWriter when TrackEncoder has sent the last frame. The
// remains frame data will form the last moof and move the state machine to
// in ISOMediaWriter to last phrase.
nsresult SetEndOfStream() {
mEOS = true;
return NS_OK;
}
bool EOS() { return mEOS; }
// CSD (codec specific data), it is generated by encoder and the data depends
// on codec type. This data will be sent as a special frame from encoder to
// ISOMediaWriter and pass to this class via AddFrame().
nsresult GetCSD(nsTArray<uint8_t>& aCSD);
bool HasCSD() { return mCSDFrame; }
uint32_t GetType() { return mTrackType; }
void SetLastFragmentLastFrameTime(uint32_t aTime) {
mLastFrameTimeOfLastFragment = aTime;
}
uint32_t GetLastFragmentLastFrameTime() {
return mLastFrameTimeOfLastFragment;
}
private:
uint32_t mTrackType;
// Fragment duration, microsecond per unit.
uint32_t mFragDuration;
// Media start time, microsecond per unit.
// Together with mFragDuration, mFragmentNumber and EncodedFrame->GetTimeStamp(),
// when the difference between current frame time and mMediaStartTime is
// exceeded current fragment ceiling timeframe, that means current fragment has
// enough data and a new element in mFragArray will be added.
uint64_t mMediaStartTime;
// Current fragment number. It will be increase when a new element of
// mFragArray is created.
// Note:
// It only means the fragment number of current accumulated frames, not
// the current 'creating' fragment mFragNum in ISOControl.
uint32_t mFragmentNumber;
// The last frame time stamp of last fragment. It is for calculating the
// play duration of first frame in current fragment. The frame duration is
// defined as "current frame timestamp - last frame timestamp" here. So it
// needs to keep the last timestamp of last fragment.
uint32_t mLastFrameTimeOfLastFragment;
// Array of fragments, each element has enough samples to form a
// complete fragment.
nsTArray<nsTArray<RefPtr<EncodedFrame>>> mFragArray;
// Codec specific data frame, it will be generated by encoder and send to
// ISOMediaWriter through WriteEncodedTrack(). The data will be vary depends
// on codec type.
RefPtr<EncodedFrame> mCSDFrame;
// END_OF_STREAM from ContainerWriter
bool mEOS;
};
/**
* ISOControl will be carried to each box when box is created. It is the main
* bridge for box to output stream to ContainerWriter and retrieve information.
* ISOControl acts 3 different roles:
* 1. Holds the pointer of audio metadata, video metadata, fragment and
* pass them to boxes.
* 2. Provide the functions to generate the base structure of MP4; they are
* GenerateFtyp, GenerateMoov, GenerateMoof, and GenerateMfra.
* 3. The actually writer used by MuxOperation::Write() in each box. It provides
* writing methods for different kind of data; they are Write, WriteArray,
* WriteBits...etc.
*/
class ISOControl {
friend class Box;
public:
ISOControl(uint32_t aMuxingType);
~ISOControl();
nsresult GenerateFtyp();
nsresult GenerateMoov();
nsresult GenerateMoof(uint32_t aTrackType);
// Swap elementary stream pointer to output buffers.
uint32_t WriteAVData(nsTArray<uint8_t>& aArray);
uint32_t Write(uint8_t* aBuf, uint32_t aSize);
uint32_t Write(uint8_t aData);
template <typename T>
uint32_t Write(T aData) {
MOZ_ASSERT(!mBitCount);
aData = NativeEndian::swapToNetworkOrder(aData);
Write((uint8_t*)&aData, sizeof(T));
return sizeof(T);
}
template <typename T>
uint32_t WriteArray(const T &aArray, uint32_t aSize) {
MOZ_ASSERT(!mBitCount);
uint32_t size = 0;
for (uint32_t i = 0; i < aSize; i++) {
size += Write(aArray[i]);
}
return size;
}
uint32_t WriteFourCC(const char* aType);
// Bit writing. Note: it needs to be byte-boundary before using
// others non-bit writing function.
uint32_t WriteBits(uint64_t aBits, size_t aNumBits);
// This is called by GetContainerData and swap all the buffers to aOutputBuffers.
nsresult GetBufs(nsTArray<nsTArray<uint8_t>>* aOutputBufs);
// Presentation time in seconds since midnight, Jan. 1, 1904, in UTC time.
uint32_t GetTime();
// current fragment number
uint32_t GetCurFragmentNumber() { return mFragNum; }
nsresult SetFragment(FragmentBuffer* aFragment);
FragmentBuffer* GetFragment(uint32_t aType);
uint32_t GetMuxingType() { return mMuxingType; }
nsresult SetMetadata(TrackMetadataBase* aTrackMeta);
nsresult GetAudioMetadata(RefPtr<AudioTrackMetadata>& aAudMeta);
nsresult GetVideoMetadata(RefPtr<VideoTrackMetadata>& aVidMeta);
// Track ID is the Metadata index in mMetaArray. It allows only 1 audio
// track and 1 video track in this muxer. In this muxer, it is prohibt to have
// mutiple audio track or video track in the same file.
uint32_t GetTrackID(TrackMetadataBase::MetadataKind aKind);
uint32_t GetNextTrackID();
bool HasAudioTrack();
bool HasVideoTrack();
private:
uint32_t GetBufPos();
nsresult FlushBuf();
// One of value in TYPE_XXX, defined in ISOMediaWriter.
uint32_t mMuxingType;
// Audio and video fragments are owned by ISOMediaWriter.
// They don't need to worry about pointer going stale because ISOMediaWriter's
// lifetime is longer than ISOControl.
FragmentBuffer* mAudioFragmentBuffer;
FragmentBuffer* mVideoFragmentBuffer;
// Generated fragment number
uint32_t mFragNum;
// The (index + 1) will be the track ID.
nsTArray<RefPtr<TrackMetadataBase>> mMetaArray;
// Array of output buffers.
// To save memory usage, audio/video sample will be swapped into a new element
// of this array.
//
// For example,
// mOutBuffers[0] --> boxes (allocated by muxer)
// mOutBuffers[1] --> video raw data (allocated by encoder)
// mOutBuffers[2] --> video raw data (allocated by encoder)
// mOutBuffers[3] --> video raw data (allocated by encoder)
// mOutBuffers[4] --> boxes (allocated by muxer)
// mOutBuffers[5] --> audio raw data (allocated by encoder)
// ...etc.
//
nsTArray<nsTArray<uint8_t>> mOutBuffers;
// Accumulate output size from Write().
uint64_t mOutputSize;
// Bit writing operation. Note: the mBitCount should be 0 before any
// byte-boundary writing method be called (Write(uint32_t), Write(uint16_t)...etc);
// otherwise, there will be assertion on these functions.
uint8_t mBitCount;
uint8_t mBit;
};
}
#endif

File diff suppressed because it is too large Load Diff

@ -1,781 +0,0 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
/* 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/. */
#ifndef ISOMediaBoxes_h_
#define ISOMediaBoxes_h_
#include <bitset>
#include "nsString.h"
#include "nsTArray.h"
#include "nsAutoPtr.h"
#include "MuxerOperation.h"
#include "mozilla/UniquePtr.h"
#define WRITE_FULLBOX(_compositor, _size) \
BoxSizeChecker checker(_compositor, _size); \
FullBox::Write();
#define FOURCC(a, b, c, d) ( ((a) << 24) | ((b) << 16) | ((c) << 8) | (d) )
namespace mozilla {
/**
* track type from spec 8.4.3.3
*/
#define Audio_Track 0x01
#define Video_Track 0x02
class AudioTrackMetadata;
class VideoTrackMetadata;
class ISOControl;
/**
* This is the base class for all ISO media format boxes.
* It provides the fields of box type(four CC) and size.
* The data members in the beginning of a Box (or its descendants)
* are the 14496-12 defined member. Other members prefix with 'm'
* are private control data.
*
* This class is for inherited only, it shouldn't be instanced directly.
*/
class Box : public MuxerOperation {
protected:
// ISO BMFF members
uint32_t size; // 14496-12 4-2 'Object Structure'. Size of this box.
nsCString boxType; // four CC name, all table names are listed in
// 14496-12 table 1.
public:
// MuxerOperation methods
nsresult Write() override;
nsresult Find(const nsACString& aType,
nsTArray<RefPtr<MuxerOperation>>& aOperations) override;
// This helper class will compare the written size in Write() and the size in
// Generate(). If their are not equal, it will assert.
class BoxSizeChecker {
public:
BoxSizeChecker(ISOControl* aControl, uint32_t aSize);
~BoxSizeChecker();
uint32_t ori_size;
uint32_t box_size;
ISOControl* mControl;
};
protected:
Box() = delete;
Box(const nsACString& aType, ISOControl* aControl);
ISOControl* mControl;
RefPtr<AudioTrackMetadata> mAudioMeta;
RefPtr<VideoTrackMetadata> mVideoMeta;
};
/**
* FullBox (and its descendants) is the box which contains the 'real' data
* members. It is the edge in the ISO box structure and it doesn't contain
* any box.
*
* This class is for inherited only, it shouldn't be instanced directly.
*/
class FullBox : public Box {
public:
// ISO BMFF members
uint8_t version; // 14496-12 4.2 'Object Structure'
std::bitset<24> flags; //
// MuxerOperation methods
nsresult Write() override;
protected:
// FullBox methods
FullBox(const nsACString& aType, uint8_t aVersion, uint32_t aFlags,
ISOControl* aControl);
FullBox() = delete;
};
/**
* The default implementation of the container box.
* Basically, the container box inherits this class and overrides the
* constructor only.
*
* According to 14496-12 3.1.1 'container box', a container box is
* 'box whose sole purpose is to contain and group a set of related boxes'