Bug 1334061: P1. Fix headers and coding style. r=gerald

MozReview-Commit-ID: D6ubdaBN0PJ

--HG--
extra : rebase_source : c27f1e5ec4370c1d258aab5bfde4598be9443858
This commit is contained in:
Jean-Yves Avenard 2017-02-15 19:09:29 +01:00
Родитель b1c337cb35
Коммит b43fb544d5
23 изменённых файлов: 163 добавлений и 138 удалений

Просмотреть файл

@ -5,25 +5,26 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "AgnosticDecoderModule.h"
#include "mozilla/Logging.h"
#include "OpusDecoder.h"
#include "VorbisDecoder.h"
#include "VPXDecoder.h"
#include "WAVDecoder.h"
#include "TheoraDecoder.h"
#include "VPXDecoder.h"
#include "VorbisDecoder.h"
#include "WAVDecoder.h"
#include "mozilla/Logging.h"
namespace mozilla {
bool
AgnosticDecoderModule::SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
AgnosticDecoderModule::SupportsMimeType(
const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const
{
bool supports =
VPXDecoder::IsVPX(aMimeType) ||
OpusDataDecoder::IsOpus(aMimeType) ||
VorbisDataDecoder::IsVorbis(aMimeType) ||
WaveDataDecoder::IsWave(aMimeType) ||
TheoraDecoder::IsTheora(aMimeType);
VPXDecoder::IsVPX(aMimeType)
|| OpusDataDecoder::IsOpus(aMimeType)
|| VorbisDataDecoder::IsVorbis(aMimeType)
|| WaveDataDecoder::IsWave(aMimeType)
|| TheoraDecoder::IsTheora(aMimeType);
MOZ_LOG(sPDMLog, LogLevel::Debug, ("Agnostic decoder %s requested type",
supports ? "supports" : "rejects"));
return supports;

Просмотреть файл

@ -5,10 +5,10 @@
namespace mozilla {
class AgnosticDecoderModule : public PlatformDecoderModule {
class AgnosticDecoderModule : public PlatformDecoderModule
{
public:
AgnosticDecoderModule() = default;
virtual ~AgnosticDecoderModule() = default;
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
@ -20,6 +20,7 @@ public:
}
protected:
virtual ~AgnosticDecoderModule() = default;
// Decode thread.
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override;

Просмотреть файл

@ -5,44 +5,47 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImageContainer.h"
#include "MP4Decoder.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 "mp4_demuxer/AnnexB.h"
#include "mp4_demuxer/H264.h"
#include "MP4Decoder.h"
#include "nsAutoPtr.h"
#include "nsRect.h"
#include "PlatformDecoderModule.h"
#include "ReorderQueue.h"
#include "TimeUnits.h"
#include "VideoUtils.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/RefPtr.h"
#include "mozilla/TaskQueue.h"
#include "mozilla/mozalloc.h" // for operator new, and new (fallible)
#include "mp4_demuxer/AnnexB.h"
#include "mp4_demuxer/H264.h"
#include "nsAutoPtr.h"
#include "nsRect.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 {
class BlankMediaDataDecoder : public MediaDataDecoder
{
public:
BlankMediaDataDecoder(BlankMediaDataCreator* aCreator,
const CreateDecoderParams& aParams)
: mCreator(aCreator)
, mMaxRefFrames(aParams.mConfig.GetType() == TrackInfo::kVideoTrack &&
MP4Decoder::IsH264(aParams.mConfig.mMimeType)
? mp4_demuxer::AnnexB::HasSPS(aParams.VideoConfig().mExtraData)
? mp4_demuxer::H264::ComputeMaxRefFrames(aParams.VideoConfig().mExtraData)
: 16
: 0)
, mMaxRefFrames(
aParams.mConfig.GetType() == TrackInfo::kVideoTrack
&& MP4Decoder::IsH264(aParams.mConfig.mMimeType)
? mp4_demuxer::AnnexB::HasSPS(aParams.VideoConfig().mExtraData)
? mp4_demuxer::H264::ComputeMaxRefFrames(
aParams.VideoConfig().mExtraData)
: 16
: 0)
, mType(aParams.mConfig.GetType())
{
}
RefPtr<InitPromise> Init() override {
RefPtr<InitPromise> Init() override
{
return InitPromise::CreateAndResolve(mType, __func__);
}
@ -99,7 +102,8 @@ private:
TrackInfo::TrackType mType;
};
class BlankVideoDataCreator {
class BlankVideoDataCreator
{
public:
BlankVideoDataCreator(uint32_t aFrameWidth,
uint32_t aFrameHeight,
@ -112,8 +116,9 @@ public:
mPicture = gfx::IntRect(0, 0, mFrameWidth, mFrameHeight);
}
already_AddRefed<MediaData>
Create(const media::TimeUnit& aDTS, const media::TimeUnit& aDuration, int64_t aOffsetInStream)
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,
@ -170,7 +175,8 @@ private:
RefPtr<layers::ImageContainer> mImageContainer;
};
class BlankAudioDataCreator {
class BlankAudioDataCreator
{
public:
BlankAudioDataCreator(uint32_t aChannelCount, uint32_t aSampleRate)
: mFrameSum(0), mChannelCount(aChannelCount), mSampleRate(aSampleRate)
@ -185,10 +191,10 @@ public:
// 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)) {
if (!frames.isValid()
|| !mChannelCount
|| !mSampleRate
|| frames.value() > (UINT32_MAX / mChannelCount)) {
return nullptr;
}
AlignedAudioBuffer samples(frames.value() * mChannelCount);
@ -220,12 +226,14 @@ private:
uint32_t mSampleRate;
};
class BlankDecoderModule : public PlatformDecoderModule {
class BlankDecoderModule : public PlatformDecoderModule
{
public:
// Decode thread.
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override {
CreateVideoDecoder(const CreateDecoderParams& aParams) override
{
const VideoInfo& config = aParams.VideoConfig();
BlankVideoDataCreator* creator = new BlankVideoDataCreator(
config.mDisplay.width, config.mDisplay.height, aParams.mImageContainer);
@ -236,7 +244,8 @@ public:
// Decode thread.
already_AddRefed<MediaDataDecoder>
CreateAudioDecoder(const CreateDecoderParams& aParams) override {
CreateAudioDecoder(const CreateDecoderParams& aParams) override
{
const AudioInfo& config = aParams.AudioConfig();
BlankAudioDataCreator* creator = new BlankAudioDataCreator(
config.mChannels, config.mRate);
@ -246,9 +255,8 @@ public:
return decoder.forget();
}
bool
SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override
bool SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override
{
return true;
}

Просмотреть файл

@ -5,11 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "TheoraDecoder.h"
#include "TimeUnits.h"
#include "XiphExtradata.h"
#include "gfx2DGlue.h"
#include "nsError.h"
#include "TimeUnits.h"
#include "mozilla/PodOperations.h"
#include "nsError.h"
#include <algorithm>
@ -80,11 +80,12 @@ TheoraDecoder::Init()
if (!XiphExtradataToHeaders(headers, headerLens,
mInfo.mCodecSpecificConfig->Elements(),
mInfo.mCodecSpecificConfig->Length())) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
}
for (size_t i = 0; i < headers.Length(); i++) {
if (NS_FAILED(DoDecodeHeader(headers[i], headerLens[i]))) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
}
}
if (mPacketCount != 3) {
@ -112,7 +113,8 @@ nsresult
TheoraDecoder::DoDecodeHeader(const unsigned char* aData, size_t aLength)
{
bool bos = mPacketCount == 0;
ogg_packet pkt = InitTheoraPacket(aData, aLength, bos, false, 0, mPacketCount++);
ogg_packet pkt =
InitTheoraPacket(aData, aLength, bos, false, 0, mPacketCount++);
int r = th_decode_headerin(&mTheoraInfo,
&mTheoraComment,
@ -130,7 +132,8 @@ TheoraDecoder::ProcessDecode(MediaRawData* aSample)
size_t aLength = aSample->Size();
bool bos = mPacketCount == 0;
ogg_packet pkt = InitTheoraPacket(aData, aLength, bos, false, aSample->mTimecode, mPacketCount++);
ogg_packet pkt = InitTheoraPacket(
aData, aLength, bos, false, aSample->mTimecode, mPacketCount++);
int ret = th_decode_packetin(mTheoraDecoderContext, &pkt, nullptr);
if (ret == 0 || ret == TH_DUPFRAME) {
@ -176,9 +179,14 @@ TheoraDecoder::ProcessDecode(MediaRawData* aSample)
mInfo.ScaledImageRect(mTheoraInfo.frame_width,
mTheoraInfo.frame_height));
if (!v) {
LOG("Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
mTheoraInfo.frame_width, mTheoraInfo.frame_height, mInfo.mDisplay.width, mInfo.mDisplay.height,
mInfo.mImage.width, mInfo.mImage.height);
LOG(
"Image allocation error source %ldx%ld display %ldx%ld picture %ldx%ld",
mTheoraInfo.frame_width,
mTheoraInfo.frame_height,
mInfo.mDisplay.width,
mInfo.mDisplay.height,
mInfo.mImage.width,
mInfo.mImage.height);
return DecodePromise::CreateAndReject(
MediaResult(NS_ERROR_OUT_OF_MEMORY,
RESULT_DETAIL("Insufficient memory")),

Просмотреть файл

@ -7,22 +7,17 @@
#define TheoraDecoder_h_
#include "PlatformDecoderModule.h"
#include <stdint.h>
#include "ogg/ogg.h"
#include "theora/theoradec.h"
#include <stdint.h>
namespace mozilla {
using namespace layers;
class TheoraDecoder : public MediaDataDecoder
{
public:
explicit TheoraDecoder(const CreateDecoderParams& aParams);
~TheoraDecoder();
RefPtr<InitPromise> Init() override;
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
RefPtr<DecodePromise> Drain() override;
@ -38,11 +33,12 @@ public:
}
private:
~TheoraDecoder();
nsresult DoDecodeHeader(const unsigned char* aData, size_t aLength);
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample);
RefPtr<ImageContainer> mImageContainer;
RefPtr<layers::ImageContainer> mImageContainer;
RefPtr<TaskQueue> mTaskQueue;
// Theora header & decoder state

Просмотреть файл

@ -5,11 +5,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "VPXDecoder.h"
#include "gfx2DGlue.h"
#include "nsError.h"
#include "TimeUnits.h"
#include "gfx2DGlue.h"
#include "mozilla/PodOperations.h"
#include "mozilla/SyncRunnable.h"
#include "nsError.h"
#include "prsystem.h"
#include <algorithm>
@ -292,12 +292,12 @@ VPXDecoder::DecodeAlpha(vpx_image_t** aImgAlpha, const MediaRawData* aSample)
bool
VPXDecoder::IsVPX(const nsACString& aMimeType, uint8_t aCodecMask)
{
return ((aCodecMask & VPXDecoder::VP8) &&
aMimeType.EqualsLiteral("video/webm; codecs=vp8")) ||
((aCodecMask & VPXDecoder::VP9) &&
aMimeType.EqualsLiteral("video/webm; codecs=vp9")) ||
((aCodecMask & VPXDecoder::VP9) &&
aMimeType.EqualsLiteral("video/vp9"));
return ((aCodecMask & VPXDecoder::VP8)
&& aMimeType.EqualsLiteral("video/webm; codecs=vp8"))
|| ((aCodecMask & VPXDecoder::VP9)
&& aMimeType.EqualsLiteral("video/webm; codecs=vp9"))
|| ((aCodecMask & VPXDecoder::VP9)
&& aMimeType.EqualsLiteral("video/vp9"));
}
/* static */

Просмотреть файл

@ -16,13 +16,10 @@
namespace mozilla {
using namespace layers;
class VPXDecoder : public MediaDataDecoder
{
public:
explicit VPXDecoder(const CreateDecoderParams& aParams);
~VPXDecoder();
RefPtr<InitPromise> Init() override;
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
@ -48,10 +45,11 @@ public:
static bool IsVP9(const nsACString& aMimeType);
private:
~VPXDecoder();
RefPtr<DecodePromise> ProcessDecode(MediaRawData* aSample);
MediaResult DecodeAlpha(vpx_image_t** aImgAlpha, const MediaRawData* aSample);
const RefPtr<ImageContainer> mImageContainer;
const RefPtr<layers::ImageContainer> mImageContainer;
const RefPtr<TaskQueue> mTaskQueue;
// VPx decoder state

Просмотреть файл

@ -78,7 +78,8 @@ VorbisDataDecoder::Init()
}
for (size_t i = 0; i < headers.Length(); i++) {
if (NS_FAILED(DecodeHeader(headers[i], headerLens[i]))) {
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR, __func__);
return InitPromise::CreateAndReject(NS_ERROR_DOM_MEDIA_FATAL_ERR,
__func__);
}
}
@ -115,7 +116,8 @@ nsresult
VorbisDataDecoder::DecodeHeader(const unsigned char* aData, size_t aLength)
{
bool bos = mPacketCount == 0;
ogg_packet pkt = InitVorbisPacket(aData, aLength, bos, false, 0, mPacketCount++);
ogg_packet pkt =
InitVorbisPacket(aData, aLength, bos, false, 0, mPacketCount++);
MOZ_ASSERT(mPacketCount <= 3);
int r = vorbis_synthesis_headerin(&mVorbisInfo,
@ -216,8 +218,8 @@ VorbisDataDecoder::ProcessDecode(MediaRawData* aSample)
};
if (!mAudioConverter) {
AudioConfig in(AudioConfig::ChannelLayout(channels, VorbisLayout(channels)),
rate);
AudioConfig in(
AudioConfig::ChannelLayout(channels, VorbisLayout(channels)), rate);
AudioConfig out(channels, rate);
if (!in.IsValid() || !out.IsValid()) {
return DecodePromise::CreateAndReject(

Просмотреть файл

@ -6,9 +6,9 @@
#if !defined(VorbisDecoder_h_)
#define VorbisDecoder_h_
#include "AudioConverter.h"
#include "PlatformDecoderModule.h"
#include "mozilla/Maybe.h"
#include "AudioConverter.h"
#ifdef MOZ_TREMOR
#include "tremor/ivorbiscodec.h"

Просмотреть файл

@ -4,8 +4,8 @@
* 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 "WAVDecoder.h"
#include "AudioSampleFormat.h"
#include "WAVDecoder.h"
#include "mozilla/SyncRunnable.h"
using mp4_demuxer::ByteReader;

Просмотреть файл

@ -6,18 +6,19 @@
#include "EMEDecoderModule.h"
#include "EMEVideoDecoder.h"
#include "GMPDecoderModule.h"
#include "GMPService.h"
#include "MP4Decoder.h"
#include "MediaDataDecoderProxy.h"
#include "MediaInfo.h"
#include "MediaPrefs.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/EMEUtils.h"
#include "mozilla/Unused.h"
#include "nsAutoPtr.h"
#include "nsServiceManagerUtils.h"
#include "MediaInfo.h"
#include "nsClassHashtable.h"
#include "GMPDecoderModule.h"
#include "MP4Decoder.h"
#include "MediaPrefs.h"
#include "mozilla/EMEUtils.h"
#include "nsServiceManagerUtils.h"
namespace mozilla {
@ -191,7 +192,8 @@ private:
RefPtr<MediaDataDecoder> mDecoder;
RefPtr<TaskQueue> mTaskQueue;
RefPtr<CDMProxy> mProxy;
nsClassHashtable<nsRefPtrHashKey<MediaRawData>, DecryptPromiseRequestHolder> mDecrypts;
nsClassHashtable<nsRefPtrHashKey<MediaRawData>, DecryptPromiseRequestHolder>
mDecrypts;
RefPtr<SamplesWaitingForKey> mSamplesWaitingForKey;
MozPromiseRequestHolder<SamplesWaitingForKey::WaitForKeyPromise> mKeyRequest;
MozPromiseHolder<DecodePromise> mDecodePromise;
@ -295,7 +297,8 @@ EMEDecoderModule::~EMEDecoderModule()
static already_AddRefed<MediaDataDecoderProxy>
CreateDecoderWrapper(CDMProxy* aProxy, const CreateDecoderParams& aParams)
{
RefPtr<gmp::GeckoMediaPluginService> s(gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
RefPtr<gmp::GeckoMediaPluginService> s(
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
if (!s) {
return nullptr;
}

Просмотреть файл

@ -7,8 +7,8 @@
#if !defined(EMEDecoderModule_h_)
#define EMEDecoderModule_h_
#include "PlatformDecoderModule.h"
#include "PDMFactory.h"
#include "PlatformDecoderModule.h"
#include "gmp-decryption.h"
namespace mozilla {
@ -20,8 +20,6 @@ class EMEDecoderModule : public PlatformDecoderModule
public:
EMEDecoderModule(CDMProxy* aProxy, PDMFactory* aPDM);
virtual ~EMEDecoderModule();
protected:
// Decode thread.
already_AddRefed<MediaDataDecoder>
@ -35,10 +33,11 @@ protected:
DecoderNeedsConversion(const TrackInfo& aConfig) const override;
bool
SupportsMimeType(const nsACString& aMimeType,
DecoderDoctorDiagnostics* aDiagnostics) const override;
SupportsMimeType(const nsACString &aMimeType,
DecoderDoctorDiagnostics *aDiagnostics) const override;
private:
virtual ~EMEDecoderModule();
RefPtr<CDMProxy> mProxy;
// Will be null if CDM has decoding capability.
RefPtr<PDMFactory> mPDM;

Просмотреть файл

@ -4,13 +4,13 @@
* 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 "mozilla/CDMProxy.h"
#include "EMEVideoDecoder.h"
#include "GMPVideoEncodedFrameImpl.h"
#include "MediaData.h"
#include "MP4Decoder.h"
#include "MediaData.h"
#include "PlatformDecoderModule.h"
#include "VPXDecoder.h"
#include "mozilla/CDMProxy.h"
namespace mozilla {
@ -45,9 +45,11 @@ EMEVideoDecoder::GetNodeId()
GMPUniquePtr<GMPVideoEncodedFrame>
EMEVideoDecoder::CreateFrame(MediaRawData* aSample)
{
GMPUniquePtr<GMPVideoEncodedFrame> frame = GMPVideoDecoder::CreateFrame(aSample);
GMPUniquePtr<GMPVideoEncodedFrame> frame =
GMPVideoDecoder::CreateFrame(aSample);
if (frame && aSample->mCrypto.mValid) {
static_cast<gmp::GMPVideoEncodedFrameImpl*>(frame.get())->InitCrypto(aSample->mCrypto);
static_cast<gmp::GMPVideoEncodedFrameImpl*>(frame.get())
->InitCrypto(aSample->mCrypto);
}
return frame;
}

Просмотреть файл

@ -15,7 +15,8 @@ class CDMProxy;
class MediaRawData;
class TaskQueue;
class EMEVideoDecoder : public GMPVideoDecoder {
class EMEVideoDecoder : public GMPVideoDecoder
{
public:
EMEVideoDecoder(CDMProxy* aProxy, const GMPVideoDecoderParams& aParams);
@ -23,7 +24,8 @@ private:
void InitTags(nsTArray<nsCString>& aTags) override;
nsCString GetNodeId() override;
uint32_t DecryptorId() const override { return mDecryptorId; }
GMPUniquePtr<GMPVideoEncodedFrame> CreateFrame(MediaRawData* aSample) override;
GMPUniquePtr<GMPVideoEncodedFrame>
CreateFrame(MediaRawData* aSample) override;
RefPtr<CDMProxy> mProxy;
uint32_t mDecryptorId;

Просмотреть файл

@ -4,12 +4,12 @@
* 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 "mozilla/CDMProxy.h"
#include "mozilla/CDMCaps.h"
#include "mozilla/TaskQueue.h"
#include "SamplesWaitingForKey.h"
#include "MediaData.h"
#include "MediaEventSource.h"
#include "SamplesWaitingForKey.h"
#include "mozilla/CDMCaps.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/TaskQueue.h"
namespace mozilla {

Просмотреть файл

@ -7,10 +7,10 @@
#ifndef SamplesWaitingForKey_h_
#define SamplesWaitingForKey_h_
#include "MediaInfo.h"
#include "mozilla/MozPromise.h"
#include "mozilla/Mutex.h"
#include "mozilla/RefPtr.h"
#include "MediaInfo.h"
namespace mozilla {
@ -30,8 +30,10 @@ public:
typedef MozPromise<RefPtr<MediaRawData>, bool, /* IsExclusive = */ true>
WaitForKeyPromise;
SamplesWaitingForKey(CDMProxy* aProxy, TrackInfo::TrackType aType,
MediaEventProducer<TrackInfo::TrackType>* aOnWaitingForKey);
SamplesWaitingForKey(
CDMProxy* aProxy,
TrackInfo::TrackType aType,
MediaEventProducer<TrackInfo::TrackType>* aOnWaitingForKey);
// Returns a promise that will be resolved if or when a key for decoding the
// sample becomes usable.

Просмотреть файл

@ -4,19 +4,20 @@
* 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 "GMPDecoderModule.h"
#include "DecoderDoctorDiagnostics.h"
#include "GMPVideoDecoder.h"
#include "GMPDecoderModule.h"
#include "GMPService.h"
#include "GMPUtils.h"
#include "GMPVideoDecoder.h"
#include "MP4Decoder.h"
#include "MediaDataDecoderProxy.h"
#include "MediaPrefs.h"
#include "VideoUtils.h"
#include "mozIGeckoMediaPluginService.h"
#include "nsServiceManagerUtils.h"
#include "mozilla/StaticMutex.h"
#include "gmp-video-decode.h"
#include "MP4Decoder.h"
#include "VPXDecoder.h"
#include "VideoUtils.h"
#include "gmp-video-decode.h"
#include "mozIGeckoMediaPluginService.h"
#include "mozilla/StaticMutex.h"
#include "nsServiceManagerUtils.h"
#ifdef XP_WIN
#include "WMFDecoderModule.h"
#endif
@ -34,7 +35,8 @@ GMPDecoderModule::~GMPDecoderModule()
static already_AddRefed<MediaDataDecoderProxy>
CreateDecoderWrapper()
{
RefPtr<gmp::GeckoMediaPluginService> s(gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
RefPtr<gmp::GeckoMediaPluginService> s(
gmp::GeckoMediaPluginService::GetGeckoMediaPluginService());
if (!s) {
return nullptr;
}
@ -42,16 +44,17 @@ CreateDecoderWrapper()
if (!thread) {
return nullptr;
}
RefPtr<MediaDataDecoderProxy> decoder(new MediaDataDecoderProxy(thread.forget()));
RefPtr<MediaDataDecoderProxy> decoder(
new MediaDataDecoderProxy(thread.forget()));
return decoder.forget();
}
already_AddRefed<MediaDataDecoder>
GMPDecoderModule::CreateVideoDecoder(const CreateDecoderParams& aParams)
{
if (!MP4Decoder::IsH264(aParams.mConfig.mMimeType) &&
!VPXDecoder::IsVP8(aParams.mConfig.mMimeType) &&
!VPXDecoder::IsVP9(aParams.mConfig.mMimeType)) {
if (!MP4Decoder::IsH264(aParams.mConfig.mMimeType)
&& !VPXDecoder::IsVP8(aParams.mConfig.mMimeType)
&& !VPXDecoder::IsVP9(aParams.mConfig.mMimeType)) {
return nullptr;
}
@ -70,7 +73,8 @@ GMPDecoderModule::CreateAudioDecoder(const CreateDecoderParams& aParams)
PlatformDecoderModule::ConversionRequired
GMPDecoderModule::DecoderNeedsConversion(const TrackInfo& aConfig) const
{
// GMPVideoCodecType::kGMPVideoCodecH264 specifies that encoded frames must be in AVCC format.
// GMPVideoCodecType::kGMPVideoCodecH264 specifies that encoded frames must be
// in AVCC format.
if (aConfig.IsVideo() && MP4Decoder::IsH264(aConfig.mMimeType)) {
return ConversionRequired::kNeedAVCC;
} else {

Просмотреть файл

@ -25,12 +25,11 @@
namespace mozilla {
class GMPDecoderModule : public PlatformDecoderModule {
class GMPDecoderModule : public PlatformDecoderModule
{
public:
GMPDecoderModule();
virtual ~GMPDecoderModule();
// Decode thread.
already_AddRefed<MediaDataDecoder>
CreateVideoDecoder(const CreateDecoderParams& aParams) override;
@ -48,6 +47,9 @@ public:
static bool SupportsMimeType(const nsACString& aMimeType,
const Maybe<nsCString>& aGMP);
private:
virtual ~GMPDecoderModule();
};
} // namespace mozilla

Просмотреть файл

@ -5,19 +5,20 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "GMPVideoDecoder.h"
#include "GMPDecoderModule.h"
#include "GMPVideoHost.h"
#include "MediaData.h"
#include "VPXDecoder.h"
#include "mozilla/EndianUtils.h"
#include "prsystem.h"
#include "MediaData.h"
#include "GMPDecoderModule.h"
#include "VPXDecoder.h"
namespace mozilla {
#if defined(DEBUG)
static bool IsOnGMPThread()
{
nsCOMPtr<mozIGeckoMediaPluginService> mps = do_GetService("@mozilla.org/gecko-media-plugin-service;1");
nsCOMPtr<mozIGeckoMediaPluginService> mps =
do_GetService("@mozilla.org/gecko-media-plugin-service;1");
MOZ_ASSERT(mps);
nsCOMPtr<nsIThread> gmpThread;
@ -58,7 +59,8 @@ GMPVideoDecoder::Decoded(GMPVideoi420Frame* aDecodedFrame)
b.mPlanes[i].mSkip = 0;
}
gfx::IntRect pictureRegion(0, 0, decodedFrame->Width(), decodedFrame->Height());
gfx::IntRect pictureRegion(
0, 0, decodedFrame->Width(), decodedFrame->Height());
RefPtr<VideoData> v =
VideoData::CreateAndCopyData(mConfig,
mImageContainer,
@ -172,7 +174,8 @@ GMPVideoDecoder::CreateFrame(MediaRawData* aSample)
return nullptr;
}
GMPUniquePtr<GMPVideoEncodedFrame> frame(static_cast<GMPVideoEncodedFrame*>(ftmp));
GMPUniquePtr<GMPVideoEncodedFrame> frame(
static_cast<GMPVideoEncodedFrame*>(ftmp));
err = frame->CreateEmptyFrame(aSample->Size());
if (GMP_FAILED(err)) {
return nullptr;

Просмотреть файл

@ -10,9 +10,9 @@
#include "GMPVideoDecoderProxy.h"
#include "ImageContainer.h"
#include "MediaDataDecoderProxy.h"
#include "MediaInfo.h"
#include "PlatformDecoderModule.h"
#include "mozIGeckoMediaPluginService.h"
#include "MediaInfo.h"
namespace mozilla {

Просмотреть файл

@ -5,8 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "MediaDataDecoderProxy.h"
#include "MediaData.h"
#include "mozilla/SyncRunnable.h"
namespace mozilla {

Просмотреть файл

@ -12,7 +12,6 @@
#include "mozilla/RefPtr.h"
#include "nsThreadUtils.h"
#include "nscore.h"
#include "GMPService.h"
namespace mozilla {
@ -20,9 +19,9 @@ class MediaDataDecoderProxy : public MediaDataDecoder
{
public:
explicit MediaDataDecoderProxy(already_AddRefed<AbstractThread> aProxyThread)
: mProxyThread(aProxyThread)
: mProxyThread(aProxyThread)
#if defined(DEBUG)
, mIsShutdown(false)
, mIsShutdown(false)
#endif
{
}
@ -33,9 +32,6 @@ public:
mProxyDecoder = aProxyDecoder;
}
// These are called from the decoder thread pool.
// Shutdown run synchronously on the proxy thread, all others are
// asynchronous.
RefPtr<InitPromise> Init() override;
RefPtr<DecodePromise> Decode(MediaRawData* aSample) override;
RefPtr<DecodePromise> Drain() override;

Просмотреть файл

@ -399,7 +399,7 @@ public:
}
nsAutoPtr<DXVA2Manager> mDXVA2Manager;
layers::LayersBackend mBackend;
KnowsCompositor* mKnowsCompositor;
layers::KnowsCompositor* mKnowsCompositor;
nsACString& mFailureReason;
};