зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1194518 - Part 1: Passthrough decoder wrapper, useful to spy on MediaFormatReader-decoder calls. r=jya
--HG-- extra : histedit_source : 6e2024c516d90bb224768d82b1110f141552e683
This commit is contained in:
Родитель
594973b3d3
Коммит
170d3a19e9
|
@ -10,6 +10,7 @@ EXPORTS += [
|
||||||
'agnostic/VPXDecoder.h',
|
'agnostic/VPXDecoder.h',
|
||||||
'PlatformDecoderModule.h',
|
'PlatformDecoderModule.h',
|
||||||
'SharedDecoderManager.h',
|
'SharedDecoderManager.h',
|
||||||
|
'wrappers/FuzzingWrapper.h',
|
||||||
'wrappers/H264Converter.h'
|
'wrappers/H264Converter.h'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -20,6 +21,7 @@ UNIFIED_SOURCES += [
|
||||||
'agnostic/VPXDecoder.cpp',
|
'agnostic/VPXDecoder.cpp',
|
||||||
'PlatformDecoderModule.cpp',
|
'PlatformDecoderModule.cpp',
|
||||||
'SharedDecoderManager.cpp',
|
'SharedDecoderManager.cpp',
|
||||||
|
'wrappers/FuzzingWrapper.cpp',
|
||||||
'wrappers/H264Converter.cpp'
|
'wrappers/H264Converter.cpp'
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,153 @@
|
||||||
|
/* -*- 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 "FuzzingWrapper.h"
|
||||||
|
|
||||||
|
PRLogModuleInfo* GetFuzzingWrapperLog() {
|
||||||
|
static PRLogModuleInfo* log = nullptr;
|
||||||
|
if (!log) {
|
||||||
|
log = PR_NewLogModule("MediaFuzzingWrapper");
|
||||||
|
}
|
||||||
|
return log;
|
||||||
|
}
|
||||||
|
#define DFW_LOGD(arg, ...) MOZ_LOG(GetFuzzingWrapperLog(), mozilla::LogLevel::Debug, ("DecoderFuzzingWrapper(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||||
|
#define DFW_LOGV(arg, ...) MOZ_LOG(GetFuzzingWrapperLog(), mozilla::LogLevel::Verbose, ("DecoderFuzzingWrapper(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||||
|
#define CFW_LOGD(arg, ...) MOZ_LOG(GetFuzzingWrapperLog(), mozilla::LogLevel::Debug, ("DecoderCallbackFuzzingWrapper(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||||
|
#define CFW_LOGV(arg, ...) MOZ_LOG(GetFuzzingWrapperLog(), mozilla::LogLevel::Verbose, ("DecoderCallbackFuzzingWrapper(%p)::%s: " arg, this, __func__, ##__VA_ARGS__))
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
DecoderFuzzingWrapper::DecoderFuzzingWrapper(
|
||||||
|
already_AddRefed<MediaDataDecoder> aDecoder,
|
||||||
|
already_AddRefed<DecoderCallbackFuzzingWrapper> aCallbackWrapper)
|
||||||
|
: mDecoder(aDecoder)
|
||||||
|
, mCallbackWrapper(aCallbackWrapper)
|
||||||
|
{
|
||||||
|
DFW_LOGV("aDecoder=%p aCallbackWrapper=%p", mDecoder.get(), mCallbackWrapper.get());
|
||||||
|
}
|
||||||
|
|
||||||
|
DecoderFuzzingWrapper::~DecoderFuzzingWrapper()
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
}
|
||||||
|
|
||||||
|
nsRefPtr<MediaDataDecoder::InitPromise>
|
||||||
|
DecoderFuzzingWrapper::Init()
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->Init();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
DecoderFuzzingWrapper::Input(MediaRawData* aData)
|
||||||
|
{
|
||||||
|
DFW_LOGV("aData.mTime=%lld", aData->mTime);
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->Input(aData);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
DecoderFuzzingWrapper::Flush()
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->Flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
DecoderFuzzingWrapper::Drain()
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->Drain();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
DecoderFuzzingWrapper::Shutdown()
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->Shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DecoderFuzzingWrapper::IsHardwareAccelerated(nsACString& aFailureReason) const
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->IsHardwareAccelerated(aFailureReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
nsresult
|
||||||
|
DecoderFuzzingWrapper::ConfigurationChanged(const TrackInfo& aConfig)
|
||||||
|
{
|
||||||
|
DFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mDecoder);
|
||||||
|
return mDecoder->ConfigurationChanged(aConfig);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DecoderCallbackFuzzingWrapper::DecoderCallbackFuzzingWrapper(MediaDataDecoderCallback* aCallback)
|
||||||
|
: mCallback(aCallback)
|
||||||
|
{
|
||||||
|
CFW_LOGV("aCallback=%p", aCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
DecoderCallbackFuzzingWrapper::~DecoderCallbackFuzzingWrapper()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DecoderCallbackFuzzingWrapper::Output(MediaData* aData)
|
||||||
|
{
|
||||||
|
CFW_LOGV("aData.mTime=%lld", aData->mTime);
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
mCallback->Output(aData);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DecoderCallbackFuzzingWrapper::Error()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
mCallback->Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DecoderCallbackFuzzingWrapper::InputExhausted()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
mCallback->InputExhausted();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DecoderCallbackFuzzingWrapper::DrainComplete()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
mCallback->DrainComplete();
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
DecoderCallbackFuzzingWrapper::ReleaseMediaResources()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
mCallback->ReleaseMediaResources();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
DecoderCallbackFuzzingWrapper::OnReaderTaskQueue()
|
||||||
|
{
|
||||||
|
CFW_LOGV("");
|
||||||
|
MOZ_ASSERT(mCallback);
|
||||||
|
return mCallback->OnReaderTaskQueue();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace mozilla
|
|
@ -0,0 +1,58 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
#if !defined(FuzzingWrapper_h_)
|
||||||
|
#define FuzzingWrapper_h_
|
||||||
|
|
||||||
|
#include "PlatformDecoderModule.h"
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
|
||||||
|
class DecoderCallbackFuzzingWrapper : public MediaDataDecoderCallback
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(DecoderCallbackFuzzingWrapper)
|
||||||
|
|
||||||
|
explicit DecoderCallbackFuzzingWrapper(MediaDataDecoderCallback* aCallback);
|
||||||
|
|
||||||
|
private:
|
||||||
|
virtual ~DecoderCallbackFuzzingWrapper();
|
||||||
|
|
||||||
|
// MediaDataDecoderCallback implementation.
|
||||||
|
void Output(MediaData* aData) override;
|
||||||
|
void Error() override;
|
||||||
|
void InputExhausted() override;
|
||||||
|
void DrainComplete() override;
|
||||||
|
void ReleaseMediaResources() override;
|
||||||
|
bool OnReaderTaskQueue() override;
|
||||||
|
|
||||||
|
MediaDataDecoderCallback* mCallback;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DecoderFuzzingWrapper : public MediaDataDecoder
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DecoderFuzzingWrapper(already_AddRefed<MediaDataDecoder> aDecoder,
|
||||||
|
already_AddRefed<DecoderCallbackFuzzingWrapper> aCallbackWrapper);
|
||||||
|
virtual ~DecoderFuzzingWrapper();
|
||||||
|
|
||||||
|
private:
|
||||||
|
// MediaDataDecoder implementation.
|
||||||
|
nsRefPtr<InitPromise> Init() override;
|
||||||
|
nsresult Input(MediaRawData* aSample) override;
|
||||||
|
nsresult Flush() override;
|
||||||
|
nsresult Drain() override;
|
||||||
|
nsresult Shutdown() override;
|
||||||
|
bool IsHardwareAccelerated(nsACString& aFailureReason) const override;
|
||||||
|
nsresult ConfigurationChanged(const TrackInfo& aConfig) override;
|
||||||
|
|
||||||
|
nsRefPtr<MediaDataDecoder> mDecoder;
|
||||||
|
nsRefPtr<DecoderCallbackFuzzingWrapper> mCallbackWrapper;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif
|
Загрузка…
Ссылка в новой задаче