mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
5d8f4a0ceb
- Bug 1130710 - xre: Use stdint uint*_t instead of nonstandard __uint*_t. r=bsmedberg# Please enter the commit message for your changes. Lines starting (8ee5fbe479) - partial revert of PM (bcd354aa6b) - Bug 1158866 - Enable MAR verification on linux via NSS. r=rstrong (d3a4eff858) - Bug 1159090 - Only append library path for updater if it is a unique value. r=rstrong (5aeece0f47) - Bug 1168720 - Remove use of test env var MOZ_NO_REPLACE_FALLBACK and associated tests that are covered by other tests. r=spohl (4c8fb7266d) - more backport (a30d3a5c9d) - Bug 1158870: Disable mar signing code path in updater for gonk until mar signing is available there. r=bbondy (d08701cdb4) - Bug 1217985 - Don't depend on Windows crypto DLLs (e313b1d3b7) - more backports (fa8e0ff050) - Bug 1168009 - heap-use-after-free (ASAN build) in updater.cpp mstrtok. r=spohl (9ffe217d90) - Bug 1234033 - Unbreak build --with-system-bz2 using Clang. r=dvander (1109f20b70) - backports (3f418fc789) - Bug 1213130 - Make several string function to accept char16ptr_t instead of char16_t*, and remove redundant overloads. rs=froydnj (95a4cb53cd) - Bug 1210871 - don't use reinterpret_cast in nsTHashtable.h; r=erahm (f742409381) - Bug 1217125 - remove pointless includes from nsTHashtable.h; r=mccr8 (ad26d04f77) - Bug 1159081 - Bad PR_SetEnv usage for Gonk. r=dhylands, r=rstrong (855a00ae4b) - bit of Bug 1237140 - Move DefinesAction (d0d8fffb86) - Bug 1157212 - Teach clang-analyzer about XPT_ASSERT; r=froydnj (d75e87012c) - Bug 1208320 - Do not stage some reftest support files before archiving; r=glandium (5a547ca126) - Bug 1208320 - Do not stage reftest test files before archiving; r=glandium (28944e3a87) - Bug 1208320 - Print message when done with archiving; r=glandium (27e0b00dcd) - Bug 1208320 - Decrease compression level of test zip archives; r=glandium (d01f75ea8b) - Bug 1232887 - "make package MOZ_PKG_PRETTYNAMES=1" is busted. r=glandium (9f978b70f0) - Bug 1212609 - Add common test package rules for firefox-ui-tests. r=gps (3fa329714a) - Bug 1239442 - Update common.tests.zip to contain dom/media/test/external-media-sites. r=gps (94e917c5e7) - Bug 1233774 - fix Leak EventTokenBucket on shutdown r=dragana (37db0e5752) - Bug 1241295 - Limit time for PR_Close calls during shutdown in nsUDPSocket. r=mcmanus (451f8663b9) - Bug 1242464 - Call shutdown() before closesocket() and change linger option on windows. r=mcmanus (2b4f7e327c) - Bug 1240122 - threadsafe fix for getselfaddr() r=dragana (0cdeefb33e) - Bug 544986 - 64KB rwin for windows xp r=dragana (cbe034ebf5) - Bug 1239655 - Do not do PR_ConnectContinue during the shutdown. r=mcmanus (2361129b62) - Bug 1240120 - Move external-media-tests to subdirectory to generate correct packaging; r=maja_zf,whimboo (0742e93414) - Bug 1235232 - Fix -Wclass-varargs warnings in dom/media/. r=kentuckyfriedtakahe (b13b325846) - Bug 1231793: Part 1 - Added read functions for Little Endian integers to ByteReader.h. r=jya (6dc6519fe9) - Bug 1231793: Part 2 - Added conversions to AudioSampleFormat.h. r=jya (59d48c4d82) - Bug 1231793: Part 3 - Fixed reading of Metadata tags. r=jya (3931a82ce7) - Bug 1192539 - [2.4] Use MediaCodecList to check for decoder support. r=snorp (35e0427a2b) - Bug 1231793: Part 4 - Added checks for Wave type in AndroidDecoderModule. r=jya (a80b83691c) - Bug 1237836 - Add support for MetadataTags to MediaFormatReader. r=jya (9b813ae38c) - Bug 1231793: Part 5 - Added Wave Data Demuxer and Decoder. r=jya (6f7131a2d8) - Bug 1231793: Part 6 - Enabled the new Wave Data Decoder in DecoderTraits. r=jya (1574922fc7) - Bug 1241677: P1. Add MediaDataDecoder::GetDescriptionName() method. r=cpearce (767413678e) - Bug 1241677: P2. Add media decoder's description to about:media report. r=cpearce (b6d300d864) - Bug 1231793: Part 7 - Fixed various tests. r=jya (baa4a844c1) - Bug 1231793: Part 8 - Added checks for various metadata errors. r=jya (53af45d8de)
284 lines
8.9 KiB
C++
284 lines
8.9 KiB
C++
/* -*- 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 "ImageContainer.h"
|
|
#include "MediaDecoderReader.h"
|
|
#include "MediaInfo.h"
|
|
#include "mozilla/CheckedInt.h"
|
|
#include "mozilla/mozalloc.h" // for operator new, and new (fallible)
|
|
#include "mozilla/RefPtr.h"
|
|
#include "mozilla/TaskQueue.h"
|
|
#include "mozilla/UniquePtr.h"
|
|
#include "mozilla/UniquePtrExtensions.h"
|
|
#include "nsRect.h"
|
|
#include "PlatformDecoderModule.h"
|
|
#include "TimeUnits.h"
|
|
#include "VideoUtils.h"
|
|
|
|
namespace mozilla {
|
|
|
|
// Decoder that uses a passed in object's Create function to create blank
|
|
// MediaData objects.
|
|
template<class BlankMediaDataCreator>
|
|
class BlankMediaDataDecoder : public MediaDataDecoder {
|
|
public:
|
|
|
|
BlankMediaDataDecoder(BlankMediaDataCreator* aCreator,
|
|
FlushableTaskQueue* aTaskQueue,
|
|
MediaDataDecoderCallback* aCallback,
|
|
TrackInfo::TrackType aType)
|
|
: mCreator(aCreator)
|
|
, mTaskQueue(aTaskQueue)
|
|
, mCallback(aCallback)
|
|
, mType(aType)
|
|
{
|
|
}
|
|
|
|
RefPtr<InitPromise> Init() override {
|
|
return InitPromise::CreateAndResolve(mType, __func__);
|
|
}
|
|
|
|
nsresult Shutdown() override {
|
|
return NS_OK;
|
|
}
|
|
|
|
class OutputEvent : public nsRunnable {
|
|
public:
|
|
OutputEvent(MediaRawData* aSample,
|
|
MediaDataDecoderCallback* aCallback,
|
|
BlankMediaDataCreator* aCreator)
|
|
: mSample(aSample)
|
|
, mCreator(aCreator)
|
|
, mCallback(aCallback)
|
|
{
|
|
}
|
|
NS_IMETHOD Run() override
|
|
{
|
|
RefPtr<MediaData> data =
|
|
mCreator->Create(media::TimeUnit::FromMicroseconds(mSample->mTime),
|
|
media::TimeUnit::FromMicroseconds(mSample->mDuration),
|
|
mSample->mOffset);
|
|
if (!data) {
|
|
return NS_ERROR_OUT_OF_MEMORY;
|
|
}
|
|
mCallback->Output(data);
|
|
return NS_OK;
|
|
}
|
|
private:
|
|
RefPtr<MediaRawData> mSample;
|
|
BlankMediaDataCreator* mCreator;
|
|
MediaDataDecoderCallback* mCallback;
|
|
};
|
|
|
|
nsresult Input(MediaRawData* aSample) override
|
|
{
|
|
// The MediaDataDecoder must delete the sample when we're finished
|
|
// with it, so the OutputEvent stores it in an nsAutoPtr and deletes
|
|
// it once it's run.
|
|
RefPtr<nsIRunnable> r(new OutputEvent(aSample, mCallback, mCreator));
|
|
mTaskQueue->Dispatch(r.forget());
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult Flush() override {
|
|
mTaskQueue->Flush();
|
|
return NS_OK;
|
|
}
|
|
|
|
nsresult Drain() override {
|
|
mCallback->DrainComplete();
|
|
return NS_OK;
|
|
}
|
|
|
|
const char* GetDescriptionName() const override
|
|
{
|
|
return "blank media data decoder";
|
|
}
|
|
|
|
private:
|
|
nsAutoPtr<BlankMediaDataCreator> mCreator;
|
|
RefPtr<FlushableTaskQueue> mTaskQueue;
|
|
MediaDataDecoderCallback* mCallback;
|
|
TrackInfo::TrackType mType;
|
|
};
|
|
|
|
class BlankVideoDataCreator {
|
|
public:
|
|
BlankVideoDataCreator(uint32_t aFrameWidth,
|
|
uint32_t aFrameHeight,
|
|
layers::ImageContainer* aImageContainer)
|
|
: mFrameWidth(aFrameWidth)
|
|
, mFrameHeight(aFrameHeight)
|
|
, mImageContainer(aImageContainer)
|
|
{
|
|
mInfo.mDisplay = nsIntSize(mFrameWidth, mFrameHeight);
|
|
mPicture = gfx::IntRect(0, 0, mFrameWidth, mFrameHeight);
|
|
}
|
|
|
|
already_AddRefed<MediaData>
|
|
Create(const media::TimeUnit& aDTS, const media::TimeUnit& aDuration, int64_t aOffsetInStream)
|
|
{
|
|
// Create a fake YUV buffer in a 420 format. That is, an 8bpp Y plane,
|
|
// with a U and V plane that are half the size of the Y plane, i.e 8 bit,
|
|
// 2x2 subsampled. Have the data pointers of each frame point to the
|
|
// first plane, they'll always be zero'd memory anyway.
|
|
auto frame = MakeUnique<uint8_t[]>(mFrameWidth * mFrameHeight);
|
|
memset(frame.get(), 0, mFrameWidth * mFrameHeight);
|
|
VideoData::YCbCrBuffer buffer;
|
|
|
|
// Y plane.
|
|
buffer.mPlanes[0].mData = frame.get();
|
|
buffer.mPlanes[0].mStride = mFrameWidth;
|
|
buffer.mPlanes[0].mHeight = mFrameHeight;
|
|
buffer.mPlanes[0].mWidth = mFrameWidth;
|
|
buffer.mPlanes[0].mOffset = 0;
|
|
buffer.mPlanes[0].mSkip = 0;
|
|
|
|
// Cb plane.
|
|
buffer.mPlanes[1].mData = frame.get();
|
|
buffer.mPlanes[1].mStride = mFrameWidth / 2;
|
|
buffer.mPlanes[1].mHeight = mFrameHeight / 2;
|
|
buffer.mPlanes[1].mWidth = mFrameWidth / 2;
|
|
buffer.mPlanes[1].mOffset = 0;
|
|
buffer.mPlanes[1].mSkip = 0;
|
|
|
|
// Cr plane.
|
|
buffer.mPlanes[2].mData = frame.get();
|
|
buffer.mPlanes[2].mStride = mFrameWidth / 2;
|
|
buffer.mPlanes[2].mHeight = mFrameHeight / 2;
|
|
buffer.mPlanes[2].mWidth = mFrameWidth / 2;
|
|
buffer.mPlanes[2].mOffset = 0;
|
|
buffer.mPlanes[2].mSkip = 0;
|
|
|
|
return VideoData::Create(mInfo,
|
|
mImageContainer,
|
|
nullptr,
|
|
aOffsetInStream,
|
|
aDTS.ToMicroseconds(),
|
|
aDuration.ToMicroseconds(),
|
|
buffer,
|
|
true,
|
|
aDTS.ToMicroseconds(),
|
|
mPicture);
|
|
}
|
|
private:
|
|
VideoInfo mInfo;
|
|
gfx::IntRect mPicture;
|
|
uint32_t mFrameWidth;
|
|
uint32_t mFrameHeight;
|
|
RefPtr<layers::ImageContainer> mImageContainer;
|
|
};
|
|
|
|
|
|
class BlankAudioDataCreator {
|
|
public:
|
|
BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
|
|
: mFrameSum(0), mChannelCount(aChannelCount), mSampleRate(aSampleRate)
|
|
{
|
|
}
|
|
|
|
MediaData* Create(const media::TimeUnit& aDTS,
|
|
const media::TimeUnit& aDuration,
|
|
int64_t aOffsetInStream)
|
|
{
|
|
// Convert duration to frames. We add 1 to duration to account for
|
|
// rounding errors, so we get a consistent tone.
|
|
CheckedInt64 frames =
|
|
UsecsToFrames(aDuration.ToMicroseconds()+1, mSampleRate);
|
|
if (!frames.isValid() ||
|
|
!mChannelCount ||
|
|
!mSampleRate ||
|
|
frames.value() > (UINT32_MAX / mChannelCount)) {
|
|
return nullptr;
|
|
}
|
|
auto samples =
|
|
MakeUniqueFallible<AudioDataValue[]>(frames.value() * mChannelCount);
|
|
if (!samples) {
|
|
return nullptr;
|
|
}
|
|
// Fill the sound buffer with an A4 tone.
|
|
static const float pi = 3.14159265f;
|
|
static const float noteHz = 440.0f;
|
|
for (int i = 0; i < frames.value(); i++) {
|
|
float f = sin(2 * pi * noteHz * mFrameSum / mSampleRate);
|
|
for (unsigned c = 0; c < mChannelCount; c++) {
|
|
samples[i * mChannelCount + c] = AudioDataValue(f);
|
|
}
|
|
mFrameSum++;
|
|
}
|
|
return new AudioData(aOffsetInStream,
|
|
aDTS.ToMicroseconds(),
|
|
aDuration.ToMicroseconds(),
|
|
uint32_t(frames.value()),
|
|
Move(samples),
|
|
mChannelCount,
|
|
mSampleRate);
|
|
}
|
|
|
|
private:
|
|
int64_t mFrameSum;
|
|
uint32_t mChannelCount;
|
|
uint32_t mSampleRate;
|
|
};
|
|
|
|
class BlankDecoderModule : public PlatformDecoderModule {
|
|
public:
|
|
|
|
// Decode thread.
|
|
already_AddRefed<MediaDataDecoder>
|
|
CreateVideoDecoder(const VideoInfo& aConfig,
|
|
layers::LayersBackend aLayersBackend,
|
|
layers::ImageContainer* aImageContainer,
|
|
FlushableTaskQueue* aVideoTaskQueue,
|
|
MediaDataDecoderCallback* aCallback) override {
|
|
BlankVideoDataCreator* creator = new BlankVideoDataCreator(
|
|
aConfig.mDisplay.width, aConfig.mDisplay.height, aImageContainer);
|
|
RefPtr<MediaDataDecoder> decoder =
|
|
new BlankMediaDataDecoder<BlankVideoDataCreator>(creator,
|
|
aVideoTaskQueue,
|
|
aCallback,
|
|
TrackInfo::kVideoTrack);
|
|
return decoder.forget();
|
|
}
|
|
|
|
// Decode thread.
|
|
already_AddRefed<MediaDataDecoder>
|
|
CreateAudioDecoder(const AudioInfo& aConfig,
|
|
FlushableTaskQueue* aAudioTaskQueue,
|
|
MediaDataDecoderCallback* aCallback) override {
|
|
BlankAudioDataCreator* creator = new BlankAudioDataCreator(
|
|
aConfig.mChannels, aConfig.mRate);
|
|
|
|
RefPtr<MediaDataDecoder> decoder =
|
|
new BlankMediaDataDecoder<BlankAudioDataCreator>(creator,
|
|
aAudioTaskQueue,
|
|
aCallback,
|
|
TrackInfo::kAudioTrack);
|
|
return decoder.forget();
|
|
}
|
|
|
|
bool
|
|
SupportsMimeType(const nsACString& aMimeType) const override
|
|
{
|
|
return true;
|
|
}
|
|
|
|
ConversionRequired
|
|
DecoderNeedsConversion(const TrackInfo& aConfig) const override
|
|
{
|
|
return kNeedNone;
|
|
}
|
|
|
|
};
|
|
|
|
already_AddRefed<PlatformDecoderModule> CreateBlankDecoderModule()
|
|
{
|
|
RefPtr<PlatformDecoderModule> pdm = new BlankDecoderModule();
|
|
return pdm.forget();
|
|
}
|
|
|
|
} // namespace mozilla
|