Backed out 4 changesets (bug 1730020) for causing build bustages. CLOSED TREE

Backed out changeset 580203e4b76a (bug 1730020)
Backed out changeset b57ce3e0f39f (bug 1730020)
Backed out changeset 085fb78aac06 (bug 1730020)
Backed out changeset 8799f103c043 (bug 1730020)
This commit is contained in:
Butkovits Atila 2021-10-04 21:33:41 +03:00
Родитель 5797605523
Коммит 80c02069eb
12 изменённых файлов: 26 добавлений и 463 удалений

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

@ -160,7 +160,6 @@ const presets = {
"ModuleProcessThread",
"NativeAudioCallback",
"PacerThread",
"RemVidChild",
"RenderBackend",
"Renderer",
"SwComposite",

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

@ -8,7 +8,6 @@
#include "ImageContainer.h"
#include "MediaInfo.h"
#include "PerformanceRecorder.h"
#include "VideoUtils.h"
#include "YCbCrUtils.h"
#include "mozilla/layers/ImageBridgeChild.h"
@ -318,9 +317,6 @@ already_AddRefed<VideoData> VideoData::CreateAndCopyData(
return nullptr;
}
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::CopyDecodedVideo,
aInfo.mImage.height);
perfRecorder.Start();
RefPtr<VideoData> v(new VideoData(aOffset, aTime, aDuration, aKeyframe,
aTimecode, aInfo.mDisplay, 0));
@ -341,7 +337,6 @@ already_AddRefed<VideoData> VideoData::CreateAndCopyData(
: aAllocator,
aContainer, data)) {
v->mImage = d3d11Image;
perfRecorder.End();
return v.forget();
}
}
@ -353,7 +348,6 @@ already_AddRefed<VideoData> VideoData::CreateAndCopyData(
PlanarYCbCrData data = ConstructPlanarYCbCrData(aInfo, aBuffer, aPicture);
if (ioImage->SetData(aContainer, data)) {
v->mImage = ioImage;
perfRecorder.End();
return v.forget();
}
}
@ -375,7 +369,6 @@ already_AddRefed<VideoData> VideoData::CreateAndCopyData(
return nullptr;
}
perfRecorder.End();
return v.forget();
}
@ -484,13 +477,6 @@ MediaRawData::MediaRawData(AlignedByteBuffer&& aData,
mAlphaBuffer(std::move(aAlphaData)) {}
already_AddRefed<MediaRawData> MediaRawData::Clone() const {
int32_t sampleHeight = 0;
if (mTrackInfo && mTrackInfo->GetAsVideoInfo()) {
sampleHeight = mTrackInfo->GetAsVideoInfo()->mImage.height;
}
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::CopyDemuxedData,
sampleHeight);
perfRecorder.Start();
RefPtr<MediaRawData> s = new MediaRawData;
s->mTimecode = mTimecode;
s->mTime = mTime;
@ -508,7 +494,6 @@ already_AddRefed<MediaRawData> MediaRawData::Clone() const {
if (!s->mAlphaBuffer.Append(mAlphaBuffer.Data(), mAlphaBuffer.Length())) {
return nullptr;
}
perfRecorder.End();
return s.forget();
}

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

@ -35,7 +35,6 @@
#include "MediaShutdownManager.h"
#include "MediaTrackGraph.h"
#include "MediaTimer.h"
#include "PerformanceRecorder.h"
#include "ReaderProxy.h"
#include "TimeUnits.h"
#include "VideoSegment.h"
@ -194,7 +193,7 @@ class MediaDecoderStateMachine::StateObject {
virtual void HandleAudioDecoded(AudioData* aAudio) {
Crash("Unexpected event!", __func__);
}
virtual void HandleVideoDecoded(VideoData* aVideo) {
virtual void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) {
Crash("Unexpected event!", __func__);
}
virtual void HandleAudioWaited(MediaData::Type aType) {
@ -435,7 +434,9 @@ class MediaDecoderStateMachine::DormantState
void HandlePlayStateChanged(MediaDecoder::PlayState aPlayState) override;
void HandleAudioDecoded(AudioData*) override { MaybeReleaseResources(); }
void HandleVideoDecoded(VideoData*) override { MaybeReleaseResources(); }
void HandleVideoDecoded(VideoData*, TimeStamp) override {
MaybeReleaseResources();
}
void HandleWaitingForAudio() override { MaybeReleaseResources(); }
void HandleWaitingForVideo() override { MaybeReleaseResources(); }
void HandleAudioCanceled() override { MaybeReleaseResources(); }
@ -485,7 +486,7 @@ class MediaDecoderStateMachine::DecodingFirstFrameState
MaybeFinishDecodeFirstFrame();
}
void HandleVideoDecoded(VideoData* aVideo) override {
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override {
mMaster->PushVideo(aVideo);
MaybeFinishDecodeFirstFrame();
}
@ -590,7 +591,7 @@ class MediaDecoderStateMachine::DecodingState
MaybeStopPrerolling();
}
void HandleVideoDecoded(VideoData* aVideo) override {
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override {
const auto currentTime = mMaster->GetMediaTime();
if (aVideo->GetEndTime() < currentTime) {
SLOG("video %" PRId64 " is too late (current=%" PRId64 ")",
@ -1056,7 +1057,8 @@ class MediaDecoderStateMachine::SeekingState
State GetState() const override = 0;
void HandleAudioDecoded(AudioData* aAudio) override = 0;
void HandleVideoDecoded(VideoData* aVideo) override = 0;
void HandleVideoDecoded(VideoData* aVideo,
TimeStamp aDecodeStart) override = 0;
void HandleAudioWaited(MediaData::Type aType) override = 0;
void HandleVideoWaited(MediaData::Type aType) override = 0;
@ -1144,7 +1146,7 @@ class MediaDecoderStateMachine::AccurateSeekingState
MaybeFinishSeek();
}
void HandleVideoDecoded(VideoData* aVideo) override {
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override {
MOZ_ASSERT(!mDoneAudioSeeking || !mDoneVideoSeeking,
"Seek shouldn't be finished");
MOZ_ASSERT(aVideo);
@ -1541,7 +1543,7 @@ class MediaDecoderStateMachine::NextFrameSeekingState
mMaster->PushAudio(aAudio);
}
void HandleVideoDecoded(VideoData* aVideo) override {
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override {
MOZ_ASSERT(aVideo);
MOZ_ASSERT(!mSeekJob.mPromise.IsEmpty(), "Seek shouldn't be finished");
MOZ_ASSERT(NeedMoreVideo());
@ -1928,7 +1930,7 @@ class MediaDecoderStateMachine::BufferingState
mMaster->ScheduleStateMachine();
}
void HandleVideoDecoded(VideoData* aVideo) override {
void HandleVideoDecoded(VideoData* aVideo, TimeStamp aDecodeStart) override {
mMaster->PushVideo(aVideo);
if (!mMaster->HaveEnoughDecodedVideo()) {
mMaster->RequestVideoData(media::TimeUnit());
@ -3272,15 +3274,11 @@ void MediaDecoderStateMachine::RequestAudioData() {
LOGV("Queueing audio task - queued=%zu, decoder-queued=%zu",
AudioQueue().GetSize(), mReader->SizeOfAudioQueueInFrames());
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::RequestData);
perfRecorder.Start();
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestAudioData()
->Then(
OwnerThread(), __func__,
[this, self, perfRecorder(std::move(perfRecorder))](
RefPtr<AudioData> aAudio) mutable {
perfRecorder.End();
[this, self](RefPtr<AudioData> aAudio) {
AUTO_PROFILER_LABEL(
"MediaDecoderStateMachine::RequestAudioData:Resolved",
MEDIA_PLAYBACK);
@ -3333,16 +3331,12 @@ void MediaDecoderStateMachine::RequestVideoData(
VideoQueue().GetSize(), mReader->SizeOfVideoQueueInFrames(),
aCurrentTime.ToMicroseconds());
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::RequestData,
Info().mVideo.mImage.height);
perfRecorder.Start();
TimeStamp videoDecodeStartTime = TimeStamp::Now();
RefPtr<MediaDecoderStateMachine> self = this;
mReader->RequestVideoData(aCurrentTime, aRequestNextKeyFrame)
->Then(
OwnerThread(), __func__,
[this, self, perfRecorder(std::move(perfRecorder))](
RefPtr<VideoData> aVideo) mutable {
perfRecorder.End();
[this, self, videoDecodeStartTime](RefPtr<VideoData> aVideo) {
AUTO_PROFILER_LABEL(
"MediaDecoderStateMachine::RequestVideoData:Resolved",
MEDIA_PLAYBACK);
@ -3354,7 +3348,7 @@ void MediaDecoderStateMachine::RequestVideoData(
LOGV("OnVideoDecoded [%" PRId64 ",%" PRId64 "]",
aVideo->mTime.ToMicroseconds(),
aVideo->GetEndTime().ToMicroseconds());
mStateObj->HandleVideoDecoded(aVideo);
mStateObj->HandleVideoDecoded(aVideo, videoDecodeStartTime);
},
[this, self](const MediaResult& aError) {
AUTO_PROFILER_LABEL(

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

@ -11,17 +11,13 @@
#include <queue>
#include "AllocationPolicy.h"
#include "AOMDecoder.h"
#include "DecoderBenchmark.h"
#include "MediaData.h"
#include "MediaDataDecoderProxy.h"
#include "MediaInfo.h"
#include "MP4Decoder.h"
#include "PDMFactory.h"
#include "PerformanceRecorder.h"
#include "VideoFrameContainer.h"
#include "VideoUtils.h"
#include "VPXDecoder.h"
#include "mozilla/AbstractThread.h"
#include "mozilla/CDMProxy.h"
#include "mozilla/ClearOnShutdown.h"
@ -1459,14 +1455,10 @@ void MediaFormatReader::DoDemuxVideo() {
using SamplesPromise = MediaTrackDemuxer::SamplesPromise;
DDLOG(DDLogCategory::Log, "video_demuxing", DDNoValue{});
PerformanceRecorder perfRecorder(
PerformanceRecorder::Stage::RequestDemux,
mVideo.GetCurrentInfo()->GetAsVideoInfo()->mImage.height);
perfRecorder.Start();
auto p = mVideo.mTrackDemuxer->GetSamples(1);
RefPtr<MediaFormatReader> self = this;
if (mVideo.mFirstDemuxedSampleTime.isNothing()) {
RefPtr<MediaFormatReader> self = this;
p = p->Then(
OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
@ -1487,14 +1479,9 @@ void MediaFormatReader::DoDemuxVideo() {
});
}
p->Then(
OwnerThread(), __func__,
[self, perfRecorder(std::move(perfRecorder))](
RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) mutable {
perfRecorder.End();
self->OnVideoDemuxCompleted(std::move(aSamples));
},
[self](const MediaResult& aError) { self->OnVideoDemuxFailed(aError); })
p->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnVideoDemuxCompleted,
&MediaFormatReader::OnVideoDemuxFailed)
->Track(mVideo.mDemuxRequest);
}
@ -1553,12 +1540,10 @@ void MediaFormatReader::DoDemuxAudio() {
using SamplesPromise = MediaTrackDemuxer::SamplesPromise;
DDLOG(DDLogCategory::Log, "audio_demuxing", DDNoValue{});
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::RequestDemux);
perfRecorder.Start();
auto p = mAudio.mTrackDemuxer->GetSamples(1);
RefPtr<MediaFormatReader> self = this;
if (mAudio.mFirstDemuxedSampleTime.isNothing()) {
RefPtr<MediaFormatReader> self = this;
p = p->Then(
OwnerThread(), __func__,
[self](RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) {
@ -1579,14 +1564,9 @@ void MediaFormatReader::DoDemuxAudio() {
});
}
p->Then(
OwnerThread(), __func__,
[self, perfRecorder(std::move(perfRecorder))](
RefPtr<MediaTrackDemuxer::SamplesHolder> aSamples) mutable {
perfRecorder.End();
self->OnAudioDemuxCompleted(std::move(aSamples));
},
[self](const MediaResult& aError) { self->OnAudioDemuxFailed(aError); })
p->Then(OwnerThread(), __func__, this,
&MediaFormatReader::OnAudioDemuxCompleted,
&MediaFormatReader::OnAudioDemuxFailed)
->Track(mAudio.mDemuxRequest);
}
@ -1885,37 +1865,10 @@ void MediaFormatReader::DecodeDemuxedSamples(TrackType aTrack,
aSample->mTimecode.ToMicroseconds(),
aSample->mDuration.ToMicroseconds(), aSample->mKeyframe ? " kf" : "",
aSample->mEOS ? " eos" : "");
const int32_t height =
aTrack == TrackInfo::kVideoTrack
? decoder.GetCurrentInfo()->GetAsVideoInfo()->mImage.height
: 0;
MediaInfoFlag flag = MediaInfoFlag::None;
flag |=
aSample->mKeyframe ? MediaInfoFlag::KeyFrame : MediaInfoFlag::NonKeyFrame;
if (aTrack == TrackInfo::kVideoTrack) {
flag |= VideoIsHardwareAccelerated() ? MediaInfoFlag::HardwareDecoding
: MediaInfoFlag::SoftwareDecoding;
const nsCString& mimeType = decoder.GetCurrentInfo()->mMimeType;
if (MP4Decoder::IsH264(mimeType)) {
flag |= MediaInfoFlag::VIDEO_H264;
} else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP8)) {
flag |= MediaInfoFlag::VIDEO_VP8;
} else if (VPXDecoder::IsVPX(mimeType, VPXDecoder::VP9)) {
flag |= MediaInfoFlag::VIDEO_VP9;
} else if (AOMDecoder::IsAV1(mimeType)) {
flag |= MediaInfoFlag::VIDEO_AV1;
}
}
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::RequestDecode,
height, flag);
perfRecorder.Start();
decoder.mDecoder->Decode(aSample)
->Then(
mTaskQueue, __func__,
[self, aTrack, &decoder, perfRecorder(std::move(perfRecorder))](
MediaDataDecoder::DecodedData&& aResults) mutable {
perfRecorder.End();
[self, aTrack, &decoder](MediaDataDecoder::DecodedData&& aResults) {
decoder.mDecodeRequest.Complete();
self->NotifyNewOutput(aTrack, std::move(aResults));
},

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

@ -6,7 +6,6 @@
#include "RemoteMediaData.h"
#include "PerformanceRecorder.h"
#include "mozilla/CheckedInt.h"
#include "mozilla/dom/MediaIPCUtils.h"
#include "mozilla/ipc/Shmem.h"
@ -135,23 +134,16 @@ bool ArrayOfRemoteMediaRawData::Fill(
nsTArray<AlignedByteBuffer> dataBuffers(aData.Length());
nsTArray<AlignedByteBuffer> alphaBuffers(aData.Length());
nsTArray<RefPtr<MediaByteBuffer>> extraDataBuffers(aData.Length());
int32_t height = 0;
for (auto&& entry : aData) {
dataBuffers.AppendElement(std::move(entry->mBuffer));
alphaBuffers.AppendElement(std::move(entry->mAlphaBuffer));
extraDataBuffers.AppendElement(std::move(entry->mExtraData));
if (auto&& info = entry->mTrackInfo; info && info->GetAsVideoInfo()) {
height = info->GetAsVideoInfo()->mImage.height;
}
mSamples.AppendElement(RemoteMediaRawData{
MediaDataIPDL(entry->mOffset, entry->mTime, entry->mTimecode,
entry->mDuration, entry->mKeyframe),
entry->mEOS, height, entry->mDiscardPadding,
entry->mEOS, entry->mDiscardPadding,
entry->mOriginalPresentationWindow});
}
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::CopyDemuxedData,
height);
perfRecorder.Start();
mBuffers = RemoteArrayOfByteBuffer(dataBuffers, aAllocator);
if (!mBuffers.IsValid()) {
return false;
@ -161,11 +153,7 @@ bool ArrayOfRemoteMediaRawData::Fill(
return false;
}
mExtraDatas = RemoteArrayOfByteBuffer(extraDataBuffers, aAllocator);
if (!mExtraDatas.IsValid()) {
return false;
}
perfRecorder.End();
return true;
return mExtraDatas.IsValid();
}
already_AddRefed<MediaRawData> ArrayOfRemoteMediaRawData::ElementAt(
@ -179,9 +167,6 @@ already_AddRefed<MediaRawData> ArrayOfRemoteMediaRawData::ElementAt(
mExtraDatas.Count() == Count(),
"Something ain't right here");
const auto& sample = mSamples[aIndex];
PerformanceRecorder perfRecorder(PerformanceRecorder::Stage::CopyDemuxedData,
sample.mHeight);
perfRecorder.Start();
AlignedByteBuffer data = mBuffers.AlignedBufferAt<uint8_t>(aIndex);
if (mBuffers.SizeAt(aIndex) && !data) {
// OOM
@ -206,7 +191,6 @@ already_AddRefed<MediaRawData> ArrayOfRemoteMediaRawData::ElementAt(
rawData->mEOS = sample.mEOS;
rawData->mDiscardPadding = sample.mDiscardPadding;
rawData->mExtraData = mExtraDatas.MediaByteBufferAt(aIndex);
perfRecorder.End();
return rawData.forget();
}
@ -238,7 +222,6 @@ ipc::IPDLParamTraits<ArrayOfRemoteMediaRawData::RemoteMediaRawData>::Write(
IPC::Message* aMsg, ipc::IProtocol* aActor, const paramType& aVar) {
WriteIPDLParam(aMsg, aActor, aVar.mBase);
WriteIPDLParam(aMsg, aActor, aVar.mEOS);
WriteIPDLParam(aMsg, aActor, aVar.mHeight);
WriteIPDLParam(aMsg, aActor, aVar.mDiscardPadding);
WriteIPDLParam(aMsg, aActor, aVar.mOriginalPresentationWindow);
}
@ -250,7 +233,6 @@ ipc::IPDLParamTraits<ArrayOfRemoteMediaRawData::RemoteMediaRawData>::Read(
MediaDataIPDL mBase;
return ReadIPDLParam(aMsg, aIter, aActor, &aVar->mBase) &&
ReadIPDLParam(aMsg, aIter, aActor, &aVar->mEOS) &&
ReadIPDLParam(aMsg, aIter, aActor, &aVar->mHeight) &&
ReadIPDLParam(aMsg, aIter, aActor, &aVar->mDiscardPadding) &&
ReadIPDLParam(aMsg, aIter, aActor, &aVar->mOriginalPresentationWindow);
};

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

@ -232,8 +232,6 @@ class ArrayOfRemoteMediaRawData {
struct RemoteMediaRawData {
MediaDataIPDL mBase;
bool mEOS;
// This will be zero for audio.
int32_t mHeight;
uint32_t mDiscardPadding;
Maybe<media::TimeInterval> mOriginalPresentationWindow;
};

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

@ -12,7 +12,6 @@
#include "ImageContainer.h"
#include "MFTDecoder.h"
#include "MediaTelemetryConstants.h"
#include "PerformanceRecorder.h"
#include "VideoUtils.h"
#include "WMFUtils.h"
#include "gfxCrashReporterUtils.h"
@ -897,9 +896,6 @@ D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
NS_ENSURE_TRUE(mSyncObject, E_FAIL);
}
PerformanceRecorder perfRecorder(
PerformanceRecorder::Stage::CopyDecodedVideo, height);
perfRecorder.Start();
// The D3D11TextureClientAllocator may return a different texture format
// than preferred. In which case the destination texture will be BGRA32.
if (outDesc.Format == inDesc.Format) {
@ -929,7 +925,6 @@ D3D11DXVA2Manager::CopyToImage(IMFSample* aVideoSample,
[&]() -> void { hr = mTransform->Output(&sample); });
NS_ENSURE_TRUE(SUCCEEDED(hr), hr);
}
perfRecorder.End();
}
if (!mutex && mDevice != DeviceManagerDx::Get()->GetCompositorDevice() &&

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

@ -1,125 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* 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 "PerformanceRecorder.h"
#include "mozilla/Logging.h"
#include "mozilla/ProfilerMarkers.h"
#include "nsString.h"
namespace mozilla {
const char* StageToStr(PerformanceRecorder::Stage aStage) {
switch (aStage) {
case PerformanceRecorder::Stage::RequestData:
return "RequestData";
case PerformanceRecorder::Stage::RequestDemux:
return "RequestDemux";
case PerformanceRecorder::Stage::CopyDemuxedData:
return "CopyDemuxedData";
case PerformanceRecorder::Stage::RequestDecode:
return "RequestDecode";
case PerformanceRecorder::Stage::CopyDecodedVideo:
return "CopyDecodedVideo";
default:
return "InvalidStage";
}
}
/* static */
const char* PerformanceRecorder::FindMediaResolution(int32_t aHeight) {
static const struct {
const int32_t mH;
const nsCString mRes;
} sResolutions[] = {{0, "A:0"_ns}, // other followings are for video
{240, "V:0<h<=240"_ns},
{480, "V:240<h<=480"_ns},
{576, "V:480<h<=576"_ns},
{720, "V:576<h<=720"_ns},
{1080, "V:720<h<=1080"_ns},
{1440, "V:1080<h<=1440"_ns},
{2160, "V:1440<h<=2160"_ns},
{INT_MAX, "V:h>2160"_ns}};
const char* resolution = sResolutions[0].mRes.get();
for (auto&& res : sResolutions) {
if (aHeight <= res.mH) {
resolution = res.mRes.get();
break;
}
}
return resolution;
}
/* static */
bool PerformanceRecorder::IsMeasurementEnabled() {
return profiler_can_accept_markers() ||
PerformanceRecorder::sEnableMeasurementForTesting;
}
/* static */
TimeStamp PerformanceRecorder::GetCurrentTimeForMeasurement() {
// The system call to get the clock is rather expensive on Windows. As we
// only report the measurement report via markers, if the marker isn't enabled
// then we won't do any measurement in order to save CPU time.
return IsMeasurementEnabled() ? TimeStamp::Now() : TimeStamp();
}
void PerformanceRecorder::Start() {
MOZ_ASSERT(mStage != Stage::Invalid);
MOZ_ASSERT(!mStartTime);
mStartTime = Some(GetCurrentTimeForMeasurement());
}
void PerformanceRecorder::Reset() {
mStartTime.reset();
mStage = Stage::Invalid;
}
void AppendMediaInfoFlagToName(nsCString& aName, MediaInfoFlag aFlag) {
if (aFlag & MediaInfoFlag::KeyFrame) {
aName.Append("kf,");
}
// Decoding
if (aFlag & MediaInfoFlag::SoftwareDecoding) {
aName.Append("sw,");
} else if (aFlag & MediaInfoFlag::HardwareDecoding) {
aName.Append("hw,");
}
// Codec type
if (aFlag & MediaInfoFlag::VIDEO_AV1) {
aName.Append("av1,");
} else if (aFlag & MediaInfoFlag::VIDEO_H264) {
aName.Append("h264,");
} else if (aFlag & MediaInfoFlag::VIDEO_VP8) {
aName.Append("vp8,");
} else if (aFlag & MediaInfoFlag::VIDEO_VP9) {
aName.Append("vp9,");
}
}
float PerformanceRecorder::End() {
double elapsedTimeUs = 0.0;
if (mStartTime && !mStartTime->IsNull()) {
MOZ_ASSERT(mStage != Stage::Invalid);
if (IsMeasurementEnabled()) {
const auto now = TimeStamp::Now();
elapsedTimeUs = (now - *mStartTime).ToMicroseconds();
MOZ_ASSERT(elapsedTimeUs >= 0, "Elapsed time can't be less than 0!");
nsAutoCString name(StageToStr(mStage));
name.Append(":");
name.Append(FindMediaResolution(mHeight));
name.Append(":");
AppendMediaInfoFlagToName(name, mFlag);
PROFILER_MARKER_UNTYPED(
name, MEDIA_PLAYBACK,
MarkerOptions(MarkerTiming::Interval(*mStartTime, now)));
}
Reset();
}
return elapsedTimeUs;
}
} // namespace mozilla

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

@ -1,134 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set sw=2 ts=8 et ft=cpp : */
/* 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 mozilla_PerformanceRecorder_h
#define mozilla_PerformanceRecorder_h
#include "mozilla/Attributes.h"
#include "mozilla/Maybe.h"
#include "mozilla/TimeStamp.h"
#include "mozilla/TypedEnumBits.h"
#include "nsStringFwd.h"
namespace mozilla {
enum class MediaInfoFlag : uint16_t {
None = (0 << 0),
NonKeyFrame = (1 << 0),
KeyFrame = (1 << 1),
SoftwareDecoding = (1 << 2),
HardwareDecoding = (1 << 3),
VIDEO_AV1 = (1 << 4),
VIDEO_H264 = (1 << 5),
VIDEO_VP8 = (1 << 6),
VIDEO_VP9 = (1 << 7),
};
MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(MediaInfoFlag)
/**
* This class is used to record the passed time on the different stages in the
* media playback pipeline. It needs to call `Start()` and `End()` explicitly
* in order to record the passed time between these two calls.
*/
class PerformanceRecorder {
public:
/**
* This represents the different stages that a media data will go through
* within the playback journey.
*
* |---| |---| |------|
* Copy Demuxed Copy Demuxed Copy Decoded
* Data Data Video
* |------------- | |-----------------------------------|
* Request Demux Request Decode
* |-----------------------------------------------------------|
* Request Data
*
* RequestData : Record the time where MediaDecoderStateMachine(MDSM) starts
* asking for a decoded data to MDSM receives a decoded data.
*
* RequestDemux : Record the time where MediaFormatReader(MFR) starts asking
* a demuxed sample to MFR received a demuxed sample. This stage is a sub-
* stage of RequestData.
*
* CopyDemuxedData : On some situations, we will need to copy the demuxed
* data, which is still not decoded yet so its size is still small. This
* records the time which we spend on copying data. This stage could happen
* multiple times, either being a sub-stage of RequestDemux (in MSE case), or
* being a sub-stage of RequestDecode (when sending data via IPC).
*
* RequestDecode : Record the time where MFR starts asking decoder to return
* a decoded data to MFR receives a decoded data. As the decoder might be
* remote, this stage might include the time spending on IPC trips. This stage
* is a sub-stage of RequestData.
*
* CopyDecodedVideo : If we can't reuse same decoder texture to the
* compositor, then we have to copy video data to to another sharable texture.
* This records the time which we spend on copying data. This stage is a sub-
* stage of RequestDecode.
*/
enum class Stage : uint8_t {
Invalid,
RequestData,
RequestDemux,
CopyDemuxedData,
RequestDecode,
CopyDecodedVideo,
};
explicit PerformanceRecorder(Stage aStage, int32_t aHeight = 0,
MediaInfoFlag aFlag = MediaInfoFlag::None)
: mStage(aStage), mHeight(aHeight), mFlag(aFlag) {}
~PerformanceRecorder() = default;
PerformanceRecorder(PerformanceRecorder&& aRhs) noexcept {
mStage = aRhs.mStage;
mHeight = aRhs.mHeight;
mStartTime = std::move(aRhs.mStartTime);
mFlag = aRhs.mFlag;
aRhs.mStage = Stage::Invalid;
}
PerformanceRecorder& operator=(PerformanceRecorder&& aRhs) noexcept {
MOZ_ASSERT(&aRhs != this, "self-moves are prohibited");
mStage = aRhs.mStage;
mHeight = aRhs.mHeight;
mStartTime = std::move(aRhs.mStartTime);
mFlag = aRhs.mFlag;
aRhs.mStage = Stage::Invalid;
return *this;
}
PerformanceRecorder(const PerformanceRecorder&) = delete;
PerformanceRecorder& operator=(const PerformanceRecorder&) = delete;
void Start();
// Return the passed time if it has started and still valid. Otherwise,
// return 0.
float End();
protected:
void Reset();
static bool IsMeasurementEnabled();
static TimeStamp GetCurrentTimeForMeasurement();
// Return the resolution range for the given height. Eg. V:1080<h<=1440.
static const char* FindMediaResolution(int32_t aHeight);
Stage mStage = Stage::Invalid;
int32_t mHeight;
MediaInfoFlag mFlag = MediaInfoFlag::None;
Maybe<TimeStamp> mStartTime;
// We would enable the measurement on testing.
static inline bool sEnableMeasurementForTesting = false;
};
} // namespace mozilla
#endif // mozilla_PerformanceRecorder_h

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

@ -1,61 +0,0 @@
/* 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 <chrono>
#include <thread>
#include "PerformanceRecorder.h"
#include "gtest/gtest.h"
#include "nsString.h"
using Stage = mozilla::PerformanceRecorder::Stage;
class PerformanceRecorderWrapper : public mozilla::PerformanceRecorder {
public:
PerformanceRecorderWrapper(Stage aStage, int32_t aHeight)
: PerformanceRecorder(aStage, aHeight) {}
const char* Resolution() const { return FindMediaResolution(mHeight); }
static void EnableMeasurementOnNonMarkerSituation() {
sEnableMeasurementForTesting = true;
}
};
TEST(PerformanceRecorder, TestResolution)
{
static const struct {
const int32_t mH;
const char* mRes;
} resolutions[] = {{0, "A:0"},
{240, "V:0<h<=240"},
{480, "V:240<h<=480"},
{576, "V:480<h<=576"},
{720, "V:576<h<=720"},
{1080, "V:720<h<=1080"},
{1440, "V:1080<h<=1440"},
{2160, "V:1440<h<=2160"},
{4320, "V:h>2160"}};
const Stage stage = Stage::RequestDecode;
for (auto&& res : resolutions) {
PerformanceRecorderWrapper w(stage, res.mH);
ASSERT_STREQ(w.Resolution(), res.mRes);
}
}
TEST(PerformanceRecorder, TestMoveOperation)
{
PerformanceRecorderWrapper::EnableMeasurementOnNonMarkerSituation();
const Stage stage = Stage::RequestDecode;
const uint32_t resolution = 1080;
PerformanceRecorderWrapper w1(stage, resolution);
w1.Start();
std::this_thread::sleep_for(std::chrono::milliseconds(1));
// w1 has been moved which won't continue measuring data.
PerformanceRecorderWrapper w2(std::move(w1));
ASSERT_DOUBLE_EQ(w1.End(), 0.0);
ASSERT_TRUE(w2.End() > 0.0);
}

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

@ -1,18 +0,0 @@
# -*- Mode: python; 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/.
UNIFIED_SOURCES += [
"TestPerformanceRecorder.cpp",
]
LOCAL_INCLUDES += [
"/dom/media/utils",
]
FINAL_LIBRARY = "xul-gtest"
if CONFIG["CC_TYPE"] in ("clang", "gcc"):
CXXFLAGS += ["-Wno-error=shadow"]

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

@ -8,17 +8,12 @@ with Files("test/**"):
EXPORTS += [
"MediaElementEventRunners.h",
"PerformanceRecorder.h",
"TelemetryProbesReporter.h",
]
UNIFIED_SOURCES += [
"MediaElementEventRunners.cpp",
"PerformanceRecorder.cpp",
"TelemetryProbesReporter.cpp",
]
if CONFIG["ENABLE_TESTS"]:
DIRS += ["gtest"]
FINAL_LIBRARY = "xul"