Backed out 4 changesets (bug 1240630) for asan failures in mochitest(2) and mochitest(oth) CLOSED TREE

Backed out changeset dc949ca1e1ec (bug 1240630)
Backed out changeset 06abea99a292 (bug 1240630)
Backed out changeset 9d90d4b0b928 (bug 1240630)
Backed out changeset 6162c46b32ff (bug 1240630)

--HG--
rename : dom/media/platforms/ffmpeg/FFmpegVideoDecoder.cpp => dom/media/platforms/ffmpeg/FFmpegH264Decoder.cpp
rename : dom/media/platforms/ffmpeg/FFmpegVideoDecoder.h => dom/media/platforms/ffmpeg/FFmpegH264Decoder.h
extra : commitid : 2Uwik7JWDjE
This commit is contained in:
Wes Kocher 2016-01-20 13:47:41 -08:00
parent de8ca7dcd1
commit 398d96e8e5
19 changed files with 143 additions and 377 deletions

View File

@ -3746,7 +3746,7 @@ if test -n "$MOZ_FMP4"; then
else
MOZ_FMP4=
fi
MOZ_FFMPEG=
MOZ_FFMPEG=1
MOZ_WEBRTC=1
MOZ_PEERCONNECTION=
MOZ_SRTP=
@ -5234,14 +5234,6 @@ fi;
dnl ========================================================
dnl FFmpeg H264/AAC Decoding Support
dnl ========================================================
case "$OS_TARGET" in
WINNT|Android)
;;
*)
MOZ_FFMPEG=1
;;
esac
MOZ_ARG_DISABLE_BOOL(ffmpeg,
[ --disable-ffmpeg Disable FFmpeg for fragmented H264/AAC decoding],
MOZ_FFMPEG=,

View File

@ -9,9 +9,6 @@
#ifdef XP_WIN
#include "WMFDecoderModule.h"
#endif
#ifdef MOZ_FFVPX
#include "FFVPXRuntimeLinker.h"
#endif
#ifdef MOZ_FFMPEG
#include "FFmpegRuntimeLinker.h"
#endif
@ -56,10 +53,6 @@ bool PDMFactory::sAndroidMCDecoderEnabled = false;
bool PDMFactory::sAndroidMCDecoderPreferred = false;
#endif
bool PDMFactory::sGMPDecoderEnabled = false;
#ifdef MOZ_FFVPX
bool PDMFactory::sFFVPXDecoderEnabled = false;
using namespace ffvpx;
#endif
#ifdef MOZ_FFMPEG
bool PDMFactory::sFFmpegDecoderEnabled = false;
#endif
@ -101,10 +94,6 @@ PDMFactory::Init()
Preferences::AddBoolVarCache(&sFFmpegDecoderEnabled,
"media.ffmpeg.enabled", false);
#endif
#ifdef MOZ_FFVPX
Preferences::AddBoolVarCache(&sFFVPXDecoderEnabled,
"media.ffvpx.enabled", false);
#endif
#ifdef XP_WIN
Preferences::AddBoolVarCache(&sWMFDecoderEnabled,
"media.wmf.enabled", false);
@ -123,9 +112,6 @@ PDMFactory::Init()
#ifdef MOZ_APPLEMEDIA
AppleDecoderModule::Init();
#endif
#ifdef MOZ_FFVPX
FFVPXRuntimeLinker::Link();
#endif
#ifdef MOZ_FFMPEG
FFmpegRuntimeLinker::Link();
#endif
@ -276,12 +262,6 @@ PDMFactory::CreatePDMs()
StartupPDM(m);
}
#endif
#ifdef MOZ_FFVPX
if (sFFVPXDecoderEnabled) {
m = FFVPXRuntimeLinker::CreateDecoderModule();
StartupPDM(m);
}
#endif
#ifdef MOZ_FFMPEG
if (sFFmpegDecoderEnabled) {
m = FFmpegRuntimeLinker::CreateDecoderModule();

View File

@ -73,9 +73,6 @@ private:
static bool sAndroidMCDecoderEnabled;
#endif
static bool sGMPDecoderEnabled;
#ifdef MOZ_FFVPX
static bool sFFVPXDecoderEnabled;
#endif
#ifdef MOZ_FFMPEG
static bool sFFmpegDecoderEnabled;
#endif

View File

@ -101,7 +101,7 @@ FFmpegAudioDecoder<LIBAV_VER>::DecodePacket(MediaRawData* aSample)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
AVPacket packet;
AV_CALL(av_init_packet(&packet));
av_init_packet(&packet);
packet.data = const_cast<uint8_t*>(aSample->Data());
packet.size = aSample->Size();
@ -118,7 +118,7 @@ FFmpegAudioDecoder<LIBAV_VER>::DecodePacket(MediaRawData* aSample)
while (packet.size > 0) {
int decoded;
int bytesConsumed =
AV_CALL(avcodec_decode_audio4(mCodecContext, mFrame, &decoded, &packet));
avcodec_decode_audio4(mCodecContext, mFrame, &decoded, &packet);
if (bytesConsumed < 0) {
NS_WARNING("FFmpeg audio decoder error.");

View File

@ -54,7 +54,7 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
StaticMutexAutoLock mon(sMonitor);
if (!(mCodecContext = AV_CALL(avcodec_alloc_context3(codec)))) {
if (!(mCodecContext = avcodec_alloc_context3(codec))) {
NS_WARNING("Couldn't init ffmpeg context");
return NS_ERROR_FAILURE;
}
@ -77,10 +77,10 @@ FFmpegDataDecoder<LIBAV_VER>::InitDecoder()
mCodecContext->flags |= CODEC_FLAG_EMU_EDGE;
}
if (AV_CALL(avcodec_open2(mCodecContext, codec, nullptr)) < 0) {
if (avcodec_open2(mCodecContext, codec, nullptr) < 0) {
NS_WARNING("Couldn't initialise ffmpeg decoder");
AV_CALL(avcodec_close(mCodecContext));
AV_CALL(av_freep(&mCodecContext));
avcodec_close(mCodecContext);
av_freep(&mCodecContext);
return NS_ERROR_FAILURE;
}
@ -141,7 +141,7 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessFlush()
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
if (mCodecContext) {
AV_CALL(avcodec_flush_buffers(mCodecContext));
avcodec_flush_buffers(mCodecContext);
}
MonitorAutoLock mon(mMonitor);
mIsFlushing = false;
@ -154,12 +154,12 @@ FFmpegDataDecoder<LIBAV_VER>::ProcessShutdown()
StaticMutexAutoLock mon(sMonitor);
if (sFFmpegInitDone && mCodecContext) {
AV_CALL(avcodec_close(mCodecContext));
AV_CALL(av_freep(&mCodecContext));
avcodec_close(mCodecContext);
av_freep(&mCodecContext);
#if LIBAVCODEC_VERSION_MAJOR >= 55
AV_CALL(av_frame_free(&mFrame));
av_frame_free(&mFrame);
#elif LIBAVCODEC_VERSION_MAJOR == 54
AV_CALL(avcodec_free_frame(&mFrame));
avcodec_free_frame(&mFrame);
#else
delete mFrame;
mFrame = nullptr;
@ -173,20 +173,20 @@ FFmpegDataDecoder<LIBAV_VER>::PrepareFrame()
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
#if LIBAVCODEC_VERSION_MAJOR >= 55
if (mFrame) {
AV_CALL(av_frame_unref(mFrame));
av_frame_unref(mFrame);
} else {
mFrame = AV_CALL(av_frame_alloc());
mFrame = av_frame_alloc();
}
#elif LIBAVCODEC_VERSION_MAJOR == 54
if (mFrame) {
AV_CALL(avcodec_get_frame_defaults(mFrame));
avcodec_get_frame_defaults(mFrame);
} else {
mFrame = AV_CALL(avcodec_alloc_frame());
mFrame = avcodec_alloc_frame();
}
#else
delete mFrame;
mFrame = new AVFrame;
AV_CALL(avcodec_get_frame_defaults(mFrame));
avcodec_get_frame_defaults(mFrame);
#endif
return mFrame;
}
@ -196,13 +196,13 @@ FFmpegDataDecoder<LIBAV_VER>::FindAVCodec(AVCodecID aCodec)
{
StaticMutexAutoLock mon(sMonitor);
if (!sFFmpegInitDone) {
AV_CALL(avcodec_register_all());
avcodec_register_all();
#ifdef DEBUG
AV_CALL(av_log_set_level(AV_LOG_DEBUG));
av_log_set_level(AV_LOG_DEBUG);
#endif
sFFmpegInitDone = true;
}
return AV_CALL(avcodec_find_decoder(aCodec));
return avcodec_find_decoder(aCodec);
}
} // namespace mozilla

View File

@ -9,7 +9,7 @@
#include "PlatformDecoderModule.h"
#include "FFmpegAudioDecoder.h"
#include "FFmpegVideoDecoder.h"
#include "FFmpegH264Decoder.h"
namespace mozilla
{
@ -37,8 +37,8 @@ public:
MediaDataDecoderCallback* aCallback) override
{
RefPtr<MediaDataDecoder> decoder =
new FFmpegVideoDecoder<V>(aVideoTaskQueue, aCallback, aConfig,
aImageContainer);
new FFmpegH264Decoder<V>(aVideoTaskQueue, aCallback, aConfig,
aImageContainer);
return decoder.forget();
}
@ -47,23 +47,15 @@ public:
FlushableTaskQueue* aAudioTaskQueue,
MediaDataDecoderCallback* aCallback) override
{
#ifdef USING_MOZFFVPX
return nullptr;
#else
RefPtr<MediaDataDecoder> decoder =
new FFmpegAudioDecoder<V>(aAudioTaskQueue, aCallback, aConfig);
return decoder.forget();
#endif
}
bool SupportsMimeType(const nsACString& aMimeType) const override
{
#ifdef USING_MOZFFVPX
AVCodecID audioCodec = AV_CODEC_ID_NONE;
#else
AVCodecID audioCodec = FFmpegAudioDecoder<V>::GetCodecId(aMimeType);
#endif
AVCodecID videoCodec = FFmpegVideoDecoder<V>::GetCodecId(aMimeType);
AVCodecID videoCodec = FFmpegH264Decoder<V>::GetCodecId(aMimeType);
if (audioCodec == AV_CODEC_ID_NONE && videoCodec == AV_CODEC_ID_NONE) {
return false;
}

View File

@ -12,7 +12,7 @@
#include "MediaInfo.h"
#include "FFmpegVideoDecoder.h"
#include "FFmpegH264Decoder.h"
#include "FFmpegLog.h"
#include "mozilla/PodOperations.h"
@ -59,7 +59,7 @@ ChoosePixelFormat(AVCodecContext* aCodecContext, const AVPixelFormat* aFormats)
return AV_PIX_FMT_NONE;
}
FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::PtsCorrectionContext()
FFmpegH264Decoder<LIBAV_VER>::PtsCorrectionContext::PtsCorrectionContext()
: mNumFaultyPts(0)
, mNumFaultyDts(0)
, mLastPts(INT64_MIN)
@ -68,7 +68,7 @@ FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::PtsCorrectionContext()
}
int64_t
FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts)
FFmpegH264Decoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPts, int64_t aDts)
{
int64_t pts = AV_NOPTS_VALUE;
@ -90,7 +90,7 @@ FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::GuessCorrectPts(int64_t aPt
}
void
FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::Reset()
FFmpegH264Decoder<LIBAV_VER>::PtsCorrectionContext::Reset()
{
mNumFaultyPts = 0;
mNumFaultyDts = 0;
@ -98,7 +98,7 @@ FFmpegVideoDecoder<LIBAV_VER>::PtsCorrectionContext::Reset()
mLastDts = INT64_MIN;
}
FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(
FFmpegH264Decoder<LIBAV_VER>::FFmpegH264Decoder(
FlushableTaskQueue* aTaskQueue, MediaDataDecoderCallback* aCallback,
const VideoInfo& aConfig,
ImageContainer* aImageContainer)
@ -108,14 +108,14 @@ FFmpegVideoDecoder<LIBAV_VER>::FFmpegVideoDecoder(
, mImage(aConfig.mImage)
, mCodecParser(nullptr)
{
MOZ_COUNT_CTOR(FFmpegVideoDecoder);
MOZ_COUNT_CTOR(FFmpegH264Decoder);
// Use a new MediaByteBuffer as the object will be modified during initialization.
mExtraData = new MediaByteBuffer;
mExtraData->AppendElements(*aConfig.mExtraData);
}
RefPtr<MediaDataDecoder::InitPromise>
FFmpegVideoDecoder<LIBAV_VER>::Init()
FFmpegH264Decoder<LIBAV_VER>::Init()
{
if (NS_FAILED(InitDecoder())) {
return InitPromise::CreateAndReject(DecoderFailureReason::INIT_ERROR, __func__);
@ -125,7 +125,7 @@ FFmpegVideoDecoder<LIBAV_VER>::Init()
}
void
FFmpegVideoDecoder<LIBAV_VER>::InitCodecContext()
FFmpegH264Decoder<LIBAV_VER>::InitCodecContext()
{
mCodecContext->width = mImage.width;
mCodecContext->height = mImage.height;
@ -151,14 +151,14 @@ FFmpegVideoDecoder<LIBAV_VER>::InitCodecContext()
// FFmpeg will call back to this to negotiate a video pixel format.
mCodecContext->get_format = ChoosePixelFormat;
mCodecParser = AV_CALL(av_parser_init(mCodecID));
mCodecParser = av_parser_init(mCodecID);
if (mCodecParser) {
mCodecParser->flags |= PARSER_FLAG_COMPLETE_FRAMES;
}
}
FFmpegVideoDecoder<LIBAV_VER>::DecodeResult
FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
FFmpegH264Decoder<LIBAV_VER>::DecodeResult
FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@ -175,10 +175,10 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
while (inputSize) {
uint8_t* data;
int size;
int len = AV_CALL(av_parser_parse2(mCodecParser, mCodecContext, &data, &size,
inputData, inputSize,
aSample->mTime, aSample->mTimecode,
aSample->mOffset));
int len = av_parser_parse2(mCodecParser, mCodecContext, &data, &size,
inputData, inputSize,
aSample->mTime, aSample->mTimecode,
aSample->mOffset);
if (size_t(len) > inputSize) {
mCallback->Error();
return DecodeResult::DECODE_ERROR;
@ -203,14 +203,14 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample)
return DoDecodeFrame(aSample, inputData, inputSize);
}
FFmpegVideoDecoder<LIBAV_VER>::DecodeResult
FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
FFmpegH264Decoder<LIBAV_VER>::DecodeResult
FFmpegH264Decoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
uint8_t* aData, int aSize)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
AVPacket packet;
AV_CALL(av_init_packet(&packet));
av_init_packet(&packet);
packet.data = aData;
packet.size = aSize;
@ -237,7 +237,7 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
int decoded;
int bytesConsumed =
AV_CALL(avcodec_decode_video2(mCodecContext, mFrame, &decoded, &packet));
avcodec_decode_video2(mCodecContext, mFrame, &decoded, &packet);
FFMPEG_LOG("DoDecodeFrame:decode_video: rv=%d decoded=%d "
"(Input: pts(%lld) dts(%lld) Output: pts(%lld) "
@ -317,7 +317,7 @@ FFmpegVideoDecoder<LIBAV_VER>::DoDecodeFrame(MediaRawData* aSample,
}
void
FFmpegVideoDecoder<LIBAV_VER>::DecodeFrame(MediaRawData* aSample)
FFmpegH264Decoder<LIBAV_VER>::DecodeFrame(MediaRawData* aSample)
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
@ -328,11 +328,11 @@ FFmpegVideoDecoder<LIBAV_VER>::DecodeFrame(MediaRawData* aSample)
}
nsresult
FFmpegVideoDecoder<LIBAV_VER>::Input(MediaRawData* aSample)
FFmpegH264Decoder<LIBAV_VER>::Input(MediaRawData* aSample)
{
nsCOMPtr<nsIRunnable> runnable(
NS_NewRunnableMethodWithArg<RefPtr<MediaRawData>>(
this, &FFmpegVideoDecoder<LIBAV_VER>::DecodeFrame,
this, &FFmpegH264Decoder<LIBAV_VER>::DecodeFrame,
RefPtr<MediaRawData>(aSample)));
mTaskQueue->Dispatch(runnable.forget());
@ -340,7 +340,7 @@ FFmpegVideoDecoder<LIBAV_VER>::Input(MediaRawData* aSample)
}
void
FFmpegVideoDecoder<LIBAV_VER>::ProcessDrain()
FFmpegH264Decoder<LIBAV_VER>::ProcessDrain()
{
MOZ_ASSERT(mTaskQueue->IsCurrentThreadIn());
RefPtr<MediaRawData> empty(new MediaRawData());
@ -350,24 +350,24 @@ FFmpegVideoDecoder<LIBAV_VER>::ProcessDrain()
}
void
FFmpegVideoDecoder<LIBAV_VER>::ProcessFlush()
FFmpegH264Decoder<LIBAV_VER>::ProcessFlush()
{
mPtsContext.Reset();
mDurationMap.Clear();
FFmpegDataDecoder::ProcessFlush();
}
FFmpegVideoDecoder<LIBAV_VER>::~FFmpegVideoDecoder()
FFmpegH264Decoder<LIBAV_VER>::~FFmpegH264Decoder()
{
MOZ_COUNT_DTOR(FFmpegVideoDecoder);
MOZ_COUNT_DTOR(FFmpegH264Decoder);
if (mCodecParser) {
AV_CALL(av_parser_close(mCodecParser));
av_parser_close(mCodecParser);
mCodecParser = nullptr;
}
}
AVCodecID
FFmpegVideoDecoder<LIBAV_VER>::GetCodecId(const nsACString& aMimeType)
FFmpegH264Decoder<LIBAV_VER>::GetCodecId(const nsACString& aMimeType)
{
if (aMimeType.EqualsLiteral("video/avc") || aMimeType.EqualsLiteral("video/mp4")) {
return AV_CODEC_ID_H264;

View File

@ -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/. */
#ifndef __FFmpegVideoDecoder_h__
#define __FFmpegVideoDecoder_h__
#ifndef __FFmpegH264Decoder_h__
#define __FFmpegH264Decoder_h__
#include "FFmpegDataDecoder.h"
#include "mozilla/Pair.h"
@ -15,12 +15,12 @@ namespace mozilla
{
template <int V>
class FFmpegVideoDecoder : public FFmpegDataDecoder<V>
class FFmpegH264Decoder : public FFmpegDataDecoder<V>
{
};
template <>
class FFmpegVideoDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
class FFmpegH264Decoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
{
typedef mozilla::layers::Image Image;
typedef mozilla::layers::ImageContainer ImageContainer;
@ -32,11 +32,11 @@ class FFmpegVideoDecoder<LIBAV_VER> : public FFmpegDataDecoder<LIBAV_VER>
};
public:
FFmpegVideoDecoder(FlushableTaskQueue* aTaskQueue,
FFmpegH264Decoder(FlushableTaskQueue* aTaskQueue,
MediaDataDecoderCallback* aCallback,
const VideoInfo& aConfig,
ImageContainer* aImageContainer);
virtual ~FFmpegVideoDecoder();
virtual ~FFmpegH264Decoder();
RefPtr<InitPromise> Init() override;
nsresult Input(MediaRawData* aSample) override;
@ -122,4 +122,4 @@ private:
} // namespace mozilla
#endif // __FFmpegVideoDecoder_h__
#endif // __FFmpegH264Decoder_h__

View File

@ -31,29 +31,14 @@ extern "C" {
typedef CodecID AVCodecID;
#endif
#ifdef FFVPX_VERSION
enum { LIBAV_VER = FFVPX_VERSION };
#else
enum { LIBAV_VER = LIBAVCODEC_VERSION_MAJOR };
#endif
namespace mozilla {
#ifdef USING_MOZFFVPX
namespace ffvpx {
#endif
#define AV_FUNC(func, ver) extern decltype(func)* func;
#include "FFmpegFunctionList.h"
#undef AV_FUNC
#ifdef USING_MOZFFVPX
} // namespace ffvpx
#define AV_CALL(func) mozilla::ffvpx::func
#else
#define AV_CALL(func) mozilla::func
#endif
}
#endif // __FFmpegLibs_h__

View File

@ -7,9 +7,18 @@
#include "FFmpegRuntimeLinker.h"
#include "mozilla/ArrayUtils.h"
#include "FFmpegLog.h"
#include "mozilla/Preferences.h"
#include "mozilla/Types.h"
#include "nsIFile.h"
#include "nsXPCOMPrivate.h" // for XUL_DLL
#include "prmem.h"
#include "prlink.h"
#if defined(XP_WIN)
#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#endif
namespace mozilla
{
@ -68,6 +77,7 @@ FFmpegRuntimeLinker::Link()
if (sLinkStatus) {
return sLinkStatus == LinkStatus_SUCCEEDED;
}
MOZ_ASSERT(NS_IsMainThread());
for (size_t i = 0; i < ArrayLength(sLibs); i++) {
@ -90,6 +100,54 @@ FFmpegRuntimeLinker::Link()
}
FFMPEG_LOG(" ]\n");
#ifdef MOZ_FFVPX
// We retrieve the path of the XUL library as this is where mozavcodec and
// mozavutil libs are located.
char* path =
PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFmpegRuntimeLinker::Link);
if (!path) {
return false;
}
nsCOMPtr<nsIFile> xulFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (!xulFile ||
NS_FAILED(xulFile->InitWithNativePath(nsDependentCString(path)))) {
PR_Free(path);
return false;
}
PR_Free(path);
nsCOMPtr<nsIFile> rootDir;
if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) {
return false;
}
nsAutoCString rootPath;
if (NS_FAILED(rootDir->GetNativePath(rootPath))) {
return false;
}
char* libname = NULL;
/* Get the platform-dependent library name of the module */
libname = PR_GetLibraryName(rootPath.get(), "mozavutil");
if (!libname) {
return false;
}
sLinkedUtilLib = MozAVLink(libname);
PR_FreeLibraryName(libname);
libname = PR_GetLibraryName(rootPath.get(), "mozavcodec");
if (!libname) {
Unlink();
return false;
}
sLinkedLib = MozAVLink(libname);
PR_FreeLibraryName(libname);
if (sLinkedLib && sLinkedUtilLib) {
if (Bind("mozavcodec")) {
sLinkStatus = LinkStatus_SUCCEEDED;
return true;
}
}
#endif
Unlink();
sLinkStatus = LinkStatus_FAILED;
@ -160,10 +218,12 @@ FFmpegRuntimeLinker::CreateDecoderModule()
RefPtr<PlatformDecoderModule> module;
switch (major) {
#ifndef XP_WIN
case 53: module = FFmpegDecoderModule<53>::Create(); break;
case 54: module = FFmpegDecoderModule<54>::Create(); break;
case 55:
case 56: module = FFmpegDecoderModule<55>::Create(); break;
#endif
case 57: module = FFmpegDecoderModule<57>::Create(); break;
default: module = nullptr;
}

View File

@ -8,7 +8,7 @@ UNIFIED_SOURCES += [
'../FFmpegAudioDecoder.cpp',
'../FFmpegDataDecoder.cpp',
'../FFmpegDecoderModule.cpp',
'../FFmpegVideoDecoder.cpp',
'../FFmpegH264Decoder.cpp',
]
LOCAL_INCLUDES += [
'..',
@ -21,5 +21,9 @@ if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-unknown-attributes',
]
if CONFIG['_MSC_VER']:
CXXFLAGS += [
'-wd4996', # deprecated declaration
]
FINAL_LIBRARY = 'xul'

View File

@ -1,162 +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 "FFVPXRuntimeLinker.h"
#include "FFmpegRuntimeLinker.h"
#include "FFmpegLog.h"
#include "mozilla/Types.h"
#include "nsIFile.h"
#include "nsXPCOMPrivate.h" // for XUL_DLL
#include "prmem.h"
#include "prlink.h"
#if defined(XP_WIN)
#include "libavcodec/avcodec.h"
#include "libavutil/avutil.h"
#endif
namespace mozilla
{
template <int V> class FFmpegDecoderModule
{
public:
static already_AddRefed<PlatformDecoderModule> Create();
};
namespace ffvpx
{
FFVPXRuntimeLinker::LinkStatus FFVPXRuntimeLinker::sLinkStatus =
LinkStatus_INIT;
PRLibrary* FFVPXRuntimeLinker::sLinkedLib = nullptr;
PRLibrary* FFVPXRuntimeLinker::sLinkedUtilLib = nullptr;
static unsigned (*avcodec_version)() = nullptr;
#ifdef __GNUC__
#define AV_FUNC(func, ver) void (*func)();
#define LIBAVCODEC_ALLVERSION
#else
#define AV_FUNC(func, ver) decltype(func)* func;
#endif
#include "FFmpegFunctionList.h"
#undef AV_FUNC
static PRLibrary*
MozAVLink(const char* aName)
{
PRLibSpec lspec;
lspec.type = PR_LibSpec_Pathname;
lspec.value.pathname = aName;
return PR_LoadLibraryWithFlags(lspec, PR_LD_NOW | PR_LD_LOCAL);
}
/* static */ bool
FFVPXRuntimeLinker::Link()
{
if (sLinkStatus) {
return sLinkStatus == LinkStatus_SUCCEEDED;
}
MOZ_ASSERT(NS_IsMainThread());
// We retrieve the path of the XUL library as this is where mozavcodec and
// mozavutil libs are located.
char* path =
PR_GetLibraryFilePathname(XUL_DLL, (PRFuncPtr)&FFVPXRuntimeLinker::Link);
if (!path) {
return false;
}
nsCOMPtr<nsIFile> xulFile = do_CreateInstance(NS_LOCAL_FILE_CONTRACTID);
if (!xulFile ||
NS_FAILED(xulFile->InitWithNativePath(nsDependentCString(path)))) {
PR_Free(path);
return false;
}
PR_Free(path);
nsCOMPtr<nsIFile> rootDir;
if (NS_FAILED(xulFile->GetParent(getter_AddRefs(rootDir))) || !rootDir) {
return false;
}
nsAutoCString rootPath;
if (NS_FAILED(rootDir->GetNativePath(rootPath))) {
return false;
}
char* libname = NULL;
/* Get the platform-dependent library name of the module */
libname = PR_GetLibraryName(rootPath.get(), "mozavutil");
if (!libname) {
return false;
}
sLinkedUtilLib = MozAVLink(libname);
PR_FreeLibraryName(libname);
libname = PR_GetLibraryName(rootPath.get(), "mozavcodec");
if (libname) {
sLinkedLib = MozAVLink(libname);
PR_FreeLibraryName(libname);
if (sLinkedLib && sLinkedUtilLib) {
if (Bind("mozavcodec")) {
sLinkStatus = LinkStatus_SUCCEEDED;
return true;
}
}
}
Unlink();
sLinkStatus = LinkStatus_FAILED;
return false;
}
/* static */ bool
FFVPXRuntimeLinker::Bind(const char* aLibName)
{
int version = AV_FUNC_57;
#define AV_FUNC(func, ver) \
if ((ver) & version) { \
if (!(func = (decltype(func))PR_FindSymbol(((ver) & AV_FUNC_AVUTIL_MASK) ? sLinkedUtilLib : sLinkedLib, #func))) { \
FFMPEG_LOG("Couldn't load function " #func " from %s.", aLibName); \
return false; \
} \
} else { \
func = (decltype(func))nullptr; \
}
#include "FFmpegFunctionList.h"
#undef AV_FUNC
return true;
}
/* static */ already_AddRefed<PlatformDecoderModule>
FFVPXRuntimeLinker::CreateDecoderModule()
{
if (!Link()) {
return nullptr;
}
return FFmpegDecoderModule<FFVPX_VERSION>::Create();
}
/* static */ void
FFVPXRuntimeLinker::Unlink()
{
if (sLinkedUtilLib && sLinkedUtilLib != sLinkedLib) {
PR_UnloadLibrary(sLinkedUtilLib);
}
if (sLinkedLib) {
PR_UnloadLibrary(sLinkedLib);
sLinkedLib = nullptr;
sLinkStatus = LinkStatus_INIT;
avcodec_version = nullptr;
}
sLinkedUtilLib = nullptr;
}
#undef LIBAVCODEC_ALLVERSION
} // namespace ffvpx
} // namespace mozilla

View File

@ -1,43 +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/. */
#ifndef __FFVPXRuntimeLinker_h__
#define __FFVPXRuntimeLinker_h__
#include "PlatformDecoderModule.h"
struct PRLibrary;
namespace mozilla
{
namespace ffvpx
{
class FFVPXRuntimeLinker
{
public:
static bool Link();
static void Unlink();
static already_AddRefed<PlatformDecoderModule> CreateDecoderModule();
private:
static PRLibrary* sLinkedLib;
static PRLibrary* sLinkedUtilLib;
static enum LinkStatus {
LinkStatus_INIT = 0,
LinkStatus_FAILED,
LinkStatus_SUCCEEDED
} sLinkStatus;
static bool Bind(const char* aLibName);
};
}
}
#endif /* __FFVPXRuntimeLinker_h__ */

View File

@ -1,44 +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/.
LOCAL_INCLUDES += ['/xpcom/build']
EXPORTS += [
'FFVPXRuntimeLinker.h',
]
UNIFIED_SOURCES += [
'../FFmpegDataDecoder.cpp',
'../FFmpegDecoderModule.cpp',
'../FFmpegVideoDecoder.cpp',
]
SOURCES += [
'FFVPXRuntimeLinker.cpp',
]
LOCAL_INCLUDES += [
'..',
'../ffmpeg57/include',
]
if CONFIG['OS_ARCH'] == 'WINNT':
LOCAL_INCLUDES += [
'../ffmpeg57/include',
]
if CONFIG['GNU_CXX']:
CXXFLAGS += [ '-Wno-deprecated-declarations' ]
if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-unknown-attributes',
]
if CONFIG['_MSC_VER']:
CXXFLAGS += [
'-wd4996', # deprecated declaration
]
DEFINES['FFVPX_VERSION'] = 46465650
DEFINES['USING_MOZFFVPX'] = True
FINAL_LIBRARY = 'xul'

View File

@ -8,7 +8,7 @@ UNIFIED_SOURCES += [
'../FFmpegAudioDecoder.cpp',
'../FFmpegDataDecoder.cpp',
'../FFmpegDecoderModule.cpp',
'../FFmpegVideoDecoder.cpp',
'../FFmpegH264Decoder.cpp',
]
LOCAL_INCLUDES += [
'..',

View File

@ -8,7 +8,7 @@ UNIFIED_SOURCES += [
'../FFmpegAudioDecoder.cpp',
'../FFmpegDataDecoder.cpp',
'../FFmpegDecoderModule.cpp',
'../FFmpegVideoDecoder.cpp',
'../FFmpegH264Decoder.cpp',
]
LOCAL_INCLUDES += [
'..',

View File

@ -8,7 +8,7 @@ UNIFIED_SOURCES += [
'../FFmpegAudioDecoder.cpp',
'../FFmpegDataDecoder.cpp',
'../FFmpegDecoderModule.cpp',
'../FFmpegVideoDecoder.cpp',
'../FFmpegH264Decoder.cpp',
]
LOCAL_INCLUDES += [
'..',
@ -21,5 +21,9 @@ if CONFIG['CLANG_CXX']:
CXXFLAGS += [
'-Wno-unknown-attributes',
]
if CONFIG['_MSC_VER']:
CXXFLAGS += [
'-wd4996', # deprecated declaration
]
FINAL_LIBRARY = 'xul'

View File

@ -38,22 +38,26 @@ if CONFIG['MOZ_WMF']:
if CONFIG['MOZ_EME']:
DIRS += ['agnostic/eme']
if CONFIG['MOZ_FFVPX']:
DIRS += [
'ffmpeg/ffvpx',
]
if CONFIG['MOZ_FFMPEG']:
LOCAL_INCLUDES += ['/xpcom/build']
EXPORTS += [
'ffmpeg/FFmpegRuntimeLinker.h',
]
UNIFIED_SOURCES += [
'ffmpeg/FFmpegRuntimeLinker.cpp',
]
if CONFIG['OS_ARCH'] != 'WINNT':
DIRS += [
'ffmpeg/libav53',
'ffmpeg/libav54',
'ffmpeg/libav55',
]
else:
LOCAL_INCLUDES += [
'ffmpeg/ffmpeg57/include',
]
DIRS += [
'ffmpeg/libav53',
'ffmpeg/libav54',
'ffmpeg/libav55',
'ffmpeg/ffmpeg57',
]

View File

@ -329,9 +329,6 @@ pref("media.wmf.skip-blacklist", false);
#if defined(MOZ_FFMPEG)
pref("media.ffmpeg.enabled", true);
#endif
#if defined(MOZ_FFVPX)
pref("media.ffvpx.enabled", true);
#endif
pref("media.gmp.decoder.enabled", false);
pref("media.gmp.decoder.aac", 0);
pref("media.gmp.decoder.h264", 0);