mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:18:48 +00:00
fef8b08889
- Bug 1237842 - Unlock mMutex before calling CloseActive. r=cpearce (d0677f1981) - Bug 1230857 - Ensure GMPService has sufficient file permissions to delete GMPs. r=gerald (e7f0c4b2b6) - Bug 1236380 - GMPStorage::mShutdown=true until Init() succeeds - r=cpearce (fde2025f4f) - Bug 1254311: [mp4] Ignore empty raw sample. r=cpearce (216a9417c3) - Bug 1215115 - part1: Replace the vorbis by opus in MediaEncoder and also reomve the VorbisTrackEncoder files. r=rillian (760c559e3c) - Bug 1215115 - part2: Mux opus into webm, remove bitdepth. r=rillian (1c996f0aee) - Bug 1215115 - part3: Fix gtest. Remove TestVorbisTrackEncoder.cpp. r=rillian (5a68915a4a) - Bug 1215115 - part4: Enable MOZ_WEBM_ENCODER by default. r=ted (6638b7fffb) - Bug 1257318: Pass TRACK_EVENT_ENDED events through to the TrackEncoders r=padenot (b92b2dcc94) - Bug 1261007 - Part 3 - Remove the same/redundant code of checking the unique image. r=jolin (608e6477bc) - Bug 1243611 - When EOS, call vpx_codec_encode correctly. r=rillian (83887c89c8) - Bug 1260353 - Remove unnecessary method AnimValuesStyleRule::AddPropertiesToSet() r=hiro (36f5e7fcc9) - Bug 1213775: VP8 automatic resizing breaks ffmpeg-based players; turn it off in VP8TrackEncoder r=jya (23c2a27371) - Bug 1185171 - Modify gmp-test-output-protection.h to prevent failure on machines without a physical monitor attached. r=bobowen (8375c5075d) - Bug 1185171: Add 0xc02625e5 as a valid failure code for GMPOutputProtection test. r=cpearce (1d10a75aeb) - Bug 1151746 - Origin tuples in should include schemes. r=edwin (32610b0cfa) - Bug 1180101 - Test 0 length atom inside moov; r=jya (3fae8aee45) - Bug 1244523: [mp4] P4. Add gtest. r=kentuckyfriedtakahe (3f71b5060a) - Bug 1255626: [gtest] Properly shutdown task queue should error occurs. r=gerald (4ec1bf360e) - Bug 1224363 - Added vp8/ivf test case - r=rillian Bug 1224369 - p1: Test cases given as list - r=rillian Bug 1224369 - p2: Added vp8/ivf test case - r=rillian Bug 1224361 - Added vp8/ivf test case - r=rillian (595ebe09be) - Bug 1231075. Respect the timestamp of video frames and don't pop frames as fast as we can in real-time mode. r=roc. (b72329c0fa) - Bug 1237160: Do not count frames not composited as dropped. r=cpearce (e7e18d0700) - Bug 1233648 - Fix some insufficient includes. r=kinetik. (e36cdd3e05) - Bug 1216460 - [1.1] Refactor data types, fix logs and prevent harmful type promotions in SourceBuffer eviction handling. r=jya (047a7ca64f) - Bug 1259916: [MSE] P1. Fix eviction. r=gerald (13195f392b) - Bug 1216460 - [2.2] Refactor SourceBuffer frame eviction and threshold defaults. r=jya (105962c942) - Bug 1259274: [MSE] P1. Remove unnecessary abstraction layer. r=gerald (e7b7603f30) - Bug 1259274: [MSE] P2. Remove unused code path. r=gerald (dce9fa447c) - Bug 1259274: [MSE] P3. Refactor handling of tasks so they only ever run concurrently. r=gerald (9c3f40d9b8) - Bug 1259274: [MSE] P4. Add AutoTaskQueue convenience class. r=gerald Just like TaskQueue, but doesn't require to be shutdown. (0310ff2b7f) - Bug 1259274: [MSE] P5. Use new AutoTaskQueue with MSE objects. r=gerald (3f72558eb2) - Bug 1259916: [MSE] P2. Bump audio source buffer eviction threshold to 30MB. r=gerald (2ffe148c1a) - Bug 1259916: [MSE] P3. Simplify eviction calculation logic. r=gerald (11250c02bc) - Bug 1199879: [MSE] Use latest demux end time to detect discontinuities. r=gerald (f89bdd763f) - Bug 1239983 - Diags around TrackBuffersMgr promises - r=jya (57f3e58636) - Bug 1258410: [MSE] P1. Abort if mInputDemuxer has been reset. r=gerald (07ca58adb0) - Bug 1258410: [MSE] P2. Disconnect init promise if any pending. r=gerald (0627c5a174) - Bug 1259985 - Add missing return after null-check - r=jya (b6ee457b89) - bit of Bwqug 1259274: [MSE] P3 (200d743676) - Bug 1216560 - [3.1] Make eviction thresholds const. r=jya (b44c78f999) - Bug 1259473 - per comment 14, move actions involving |this| to Init() from the constructor. r=jya. (30c402aacb) - Bug 1258562: MSE] Abort if MediaSource has been shutdown. r=gerald (6fce6bc9db) - Bug 1246358: [MSE] Take pre-roll time into consideration when seeking. r=gerald (dacbcd7f36) - spaces (abbb56d413) - Bug 657791 - Update WebM demuxer to clamp cueless seeks instead of failing. r=kinetik (785ae83126) - Bug 1219178 - [9.1] Make SeekPosition available with tests disabled. a=me for fixing build problems (cd1bdef203) - minor format (4a718e47f2) - Bug 1265399 - Replace 0.7071 with sqrt(0.5) in downmixing equations; r=padenot (2243d331c5) - Bug 1265794: P1. Ensure we can always fit a complete audio frame in an audio buffer. r=rillian (37f575184c) - Bug 1256626. Workaround Microsoft macro silliness. r=me (18930fbccd) - Bug 1264898 - Remove unnecessary |FinishAddTracks| call in |DOMHwMediaStream::Init|. r=jesup, r=pehrsons (1b610cdb4f) - Bug 848994 - p5. Check Silverlight presence - r=cpearce (98b4521ae3) - Bug 848994 - p6. Analyze Windows issues - r=cpearce (9de769166a) - Bug 848994 - p7. Filter front-end notifications - r=cpearce (e3aab89a95) - Bug 1256533 - Use std::deque<int32_t> instead of nsDeque - r=cpearce (e21c02fcab)
661 lines
23 KiB
C++
661 lines
23 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 "DecoderDoctorDiagnostics.h"
|
|
|
|
#include "mozilla/dom/DecoderDoctorNotificationBinding.h"
|
|
#include "mozilla/Logging.h"
|
|
#include "mozilla/Preferences.h"
|
|
#include "nsGkAtoms.h"
|
|
#include "nsIDocument.h"
|
|
#include "nsIObserverService.h"
|
|
#include "nsITimer.h"
|
|
#include "nsIWeakReference.h"
|
|
#include "nsPluginHost.h"
|
|
|
|
static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
|
|
#define DD_LOG(level, arg, ...) MOZ_LOG(sDecoderDoctorLog, level, (arg, ##__VA_ARGS__))
|
|
#define DD_DEBUG(arg, ...) DD_LOG(mozilla::LogLevel::Debug, arg, ##__VA_ARGS__)
|
|
#define DD_INFO(arg, ...) DD_LOG(mozilla::LogLevel::Info, arg, ##__VA_ARGS__)
|
|
#define DD_WARN(arg, ...) DD_LOG(mozilla::LogLevel::Warning, arg, ##__VA_ARGS__)
|
|
|
|
namespace mozilla
|
|
{
|
|
|
|
// Class that collects a sequence of diagnostics from the same document over a
|
|
// small period of time, in order to provide a synthesized analysis.
|
|
//
|
|
// Referenced by the document through a nsINode property, mTimer, and
|
|
// inter-task captures.
|
|
// When notified that the document is dead, or when the timer expires but
|
|
// nothing new happened, StopWatching() will remove the document property and
|
|
// timer (if present), so no more work will happen and the watcher will be
|
|
// destroyed once all references are gone.
|
|
class DecoderDoctorDocumentWatcher : public nsITimerCallback
|
|
{
|
|
public:
|
|
static already_AddRefed<DecoderDoctorDocumentWatcher>
|
|
RetrieveOrCreate(nsIDocument* aDocument);
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSITIMERCALLBACK
|
|
|
|
void AddDiagnostics(DecoderDoctorDiagnostics&& aDiagnostics,
|
|
const char* aCallSite);
|
|
|
|
private:
|
|
explicit DecoderDoctorDocumentWatcher(nsIDocument* aDocument);
|
|
virtual ~DecoderDoctorDocumentWatcher();
|
|
|
|
// This will prevent further work from happening, watcher will deregister
|
|
// itself from document (if requested) and cancel any timer, and soon die.
|
|
void StopWatching(bool aRemoveProperty);
|
|
|
|
// Remove property from document; will call DestroyPropertyCallback.
|
|
void RemovePropertyFromDocument();
|
|
// Callback for property destructor, will be automatically called when the
|
|
// document (in aObject) is being destroyed.
|
|
static void DestroyPropertyCallback(void* aObject,
|
|
nsIAtom* aPropertyName,
|
|
void* aPropertyValue,
|
|
void* aData);
|
|
|
|
static const uint32_t sAnalysisPeriod_ms = 1000;
|
|
void EnsureTimerIsStarted();
|
|
|
|
void ReportAnalysis(dom::DecoderDoctorNotificationType aNotificationType,
|
|
const char* aReportStringId,
|
|
const nsAString& aFormats);
|
|
|
|
void SynthesizeAnalysis();
|
|
|
|
// Raw pointer to an nsIDocument.
|
|
// Must be non-null during construction.
|
|
// Nulled when we want to stop watching, because either:
|
|
// 1. The document has been destroyed (notified through
|
|
// DestroyPropertyCallback).
|
|
// 2. We have not received new diagnostic information within a short time
|
|
// period, so we just stop watching.
|
|
// Once nulled, no more actual work will happen, and the watcher will be
|
|
// destroyed soon.
|
|
nsIDocument* mDocument;
|
|
|
|
struct Diagnostics
|
|
{
|
|
Diagnostics(DecoderDoctorDiagnostics&& aDiagnostics,
|
|
const char* aCallSite)
|
|
: mDecoderDoctorDiagnostics(Move(aDiagnostics))
|
|
, mCallSite(aCallSite)
|
|
{}
|
|
Diagnostics(const Diagnostics&) = delete;
|
|
Diagnostics(Diagnostics&& aOther)
|
|
: mDecoderDoctorDiagnostics(Move(aOther.mDecoderDoctorDiagnostics))
|
|
, mCallSite(Move(aOther.mCallSite))
|
|
{}
|
|
|
|
const DecoderDoctorDiagnostics mDecoderDoctorDiagnostics;
|
|
const nsCString mCallSite;
|
|
};
|
|
typedef nsTArray<Diagnostics> DiagnosticsSequence;
|
|
DiagnosticsSequence mDiagnosticsSequence;
|
|
|
|
nsCOMPtr<nsITimer> mTimer; // Keep timer alive until we run.
|
|
DiagnosticsSequence::size_type mDiagnosticsHandled = 0;
|
|
};
|
|
|
|
|
|
NS_IMPL_ISUPPORTS(DecoderDoctorDocumentWatcher, nsITimerCallback)
|
|
|
|
// static
|
|
already_AddRefed<DecoderDoctorDocumentWatcher>
|
|
DecoderDoctorDocumentWatcher::RetrieveOrCreate(nsIDocument* aDocument)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(aDocument);
|
|
RefPtr<DecoderDoctorDocumentWatcher> watcher =
|
|
static_cast<DecoderDoctorDocumentWatcher*>(
|
|
aDocument->GetProperty(nsGkAtoms::decoderDoctor));
|
|
if (!watcher) {
|
|
watcher = new DecoderDoctorDocumentWatcher(aDocument);
|
|
if (NS_WARN_IF(NS_FAILED(
|
|
aDocument->SetProperty(nsGkAtoms::decoderDoctor,
|
|
watcher.get(),
|
|
DestroyPropertyCallback,
|
|
/*transfer*/ false)))) {
|
|
DD_WARN("DecoderDoctorDocumentWatcher::RetrieveOrCreate(doc=%p) - Could not set property in document, will destroy new watcher[%p]",
|
|
aDocument, watcher.get());
|
|
return nullptr;
|
|
}
|
|
// Document owns watcher through this property.
|
|
// Released in DestroyPropertyCallback().
|
|
NS_ADDREF(watcher.get());
|
|
}
|
|
return watcher.forget();
|
|
}
|
|
|
|
DecoderDoctorDocumentWatcher::DecoderDoctorDocumentWatcher(nsIDocument* aDocument)
|
|
: mDocument(aDocument)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(mDocument);
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p]::DecoderDoctorDocumentWatcher(doc=%p)",
|
|
this, mDocument);
|
|
}
|
|
|
|
DecoderDoctorDocumentWatcher::~DecoderDoctorDocumentWatcher()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p <- expect 0]::~DecoderDoctorDocumentWatcher()",
|
|
this, mDocument);
|
|
// mDocument should have been reset through StopWatching()!
|
|
MOZ_ASSERT(!mDocument);
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::RemovePropertyFromDocument()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
DecoderDoctorDocumentWatcher* watcher =
|
|
static_cast<DecoderDoctorDocumentWatcher*>(
|
|
mDocument->GetProperty(nsGkAtoms::decoderDoctor));
|
|
if (!watcher) {
|
|
return;
|
|
}
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::RemovePropertyFromDocument()\n",
|
|
watcher, watcher->mDocument);
|
|
// This will remove the property and call our DestroyPropertyCallback.
|
|
mDocument->DeleteProperty(nsGkAtoms::decoderDoctor);
|
|
}
|
|
|
|
// Callback for property destructors. |aObject| is the object
|
|
// the property is being removed for, |aPropertyName| is the property
|
|
// being removed, |aPropertyValue| is the value of the property, and |aData|
|
|
// is the opaque destructor data that was passed to SetProperty().
|
|
// static
|
|
void
|
|
DecoderDoctorDocumentWatcher::DestroyPropertyCallback(void* aObject,
|
|
nsIAtom* aPropertyName,
|
|
void* aPropertyValue,
|
|
void*)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
#ifdef DEBUG
|
|
nsIDocument* document = static_cast<nsIDocument*>(aObject);
|
|
#endif
|
|
MOZ_ASSERT(aPropertyName == nsGkAtoms::decoderDoctor);
|
|
DecoderDoctorDocumentWatcher* watcher =
|
|
static_cast<DecoderDoctorDocumentWatcher*>(aPropertyValue);
|
|
MOZ_ASSERT(watcher);
|
|
MOZ_ASSERT(watcher->mDocument == document);
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::DestroyPropertyCallback()\n",
|
|
watcher, watcher->mDocument);
|
|
// 'false': StopWatching should not try and remove the property.
|
|
watcher->StopWatching(false);
|
|
NS_RELEASE(watcher);
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::StopWatching(bool aRemoveProperty)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
// StopWatching() shouldn't be called twice.
|
|
MOZ_ASSERT(mDocument);
|
|
|
|
if (aRemoveProperty) {
|
|
RemovePropertyFromDocument();
|
|
}
|
|
|
|
// Forget document now, this will prevent more work from being started.
|
|
mDocument = nullptr;
|
|
|
|
if (mTimer) {
|
|
mTimer->Cancel();
|
|
mTimer = nullptr;
|
|
}
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::EnsureTimerIsStarted()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (!mTimer) {
|
|
mTimer = do_CreateInstance(NS_TIMER_CONTRACTID);
|
|
if (NS_WARN_IF(!mTimer)) {
|
|
return;
|
|
}
|
|
if (NS_WARN_IF(NS_FAILED(
|
|
mTimer->InitWithCallback(
|
|
this, sAnalysisPeriod_ms, nsITimer::TYPE_ONE_SHOT)))) {
|
|
mTimer = nullptr;
|
|
}
|
|
}
|
|
}
|
|
|
|
static void
|
|
DispatchNotification(nsISupports* aSubject,
|
|
dom::DecoderDoctorNotificationType aNotificationType,
|
|
const nsAString& aFormats)
|
|
{
|
|
if (!aSubject) {
|
|
return;
|
|
}
|
|
dom::DecoderDoctorNotification data;
|
|
data.mType = aNotificationType;
|
|
if (!aFormats.IsEmpty()) {
|
|
data.mFormats.Construct(aFormats);
|
|
}
|
|
nsAutoString json;
|
|
data.ToJSON(json);
|
|
if (json.IsEmpty()) {
|
|
DD_WARN("DecoderDoctorDiagnostics/DispatchEvent() - Could not create json for dispatch");
|
|
// No point in dispatching this notification without data, the front-end
|
|
// wouldn't know what to display.
|
|
return;
|
|
}
|
|
DD_DEBUG("DecoderDoctorDiagnostics/DispatchEvent() %s", NS_ConvertUTF16toUTF8(json).get());
|
|
nsCOMPtr<nsIObserverService> obs = services::GetObserverService();
|
|
if (obs) {
|
|
obs->NotifyObservers(aSubject, "decoder-doctor-notification", json.get());
|
|
}
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::ReportAnalysis(
|
|
dom::DecoderDoctorNotificationType aNotificationType,
|
|
const char* aReportStringId,
|
|
const nsAString& aParams)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (!mDocument) {
|
|
return;
|
|
}
|
|
|
|
// 'params' will only be forwarded for non-empty strings.
|
|
const char16_t* params[1] = { aParams.Data() };
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::ReportAnalysis() ReportToConsole - aMsg='%s' params[0]='%s'",
|
|
this, mDocument, aReportStringId,
|
|
aParams.IsEmpty() ? "<no params>" : NS_ConvertUTF16toUTF8(params[0]).get());
|
|
nsContentUtils::ReportToConsole(nsIScriptError::warningFlag,
|
|
NS_LITERAL_CSTRING("Media"),
|
|
mDocument,
|
|
nsContentUtils::eDOM_PROPERTIES,
|
|
aReportStringId,
|
|
aParams.IsEmpty() ? nullptr : params,
|
|
aParams.IsEmpty() ? 0 : 1);
|
|
|
|
// "media.decoder-doctor.notifications-allowed" controls which notifications
|
|
// may be dispatched to the front-end. It either contains:
|
|
// - '*' -> Allow everything.
|
|
// - Comma-separater list of ids -> Allow if aReportStringId (from
|
|
// dom.properties) is one of them.
|
|
// - Nothing (missing or empty) -> Disable everything.
|
|
nsAdoptingCString filter =
|
|
Preferences::GetCString("media.decoder-doctor.notifications-allowed");
|
|
filter.StripWhitespace();
|
|
bool allowed = false;
|
|
if (!filter || filter.IsEmpty()) {
|
|
// Allow nothing.
|
|
} else if (filter.EqualsLiteral("*")) {
|
|
allowed = true;
|
|
} else for (uint32_t start = 0; start < filter.Length(); ) {
|
|
int32_t comma = filter.FindChar(',', start);
|
|
uint32_t end = (comma >= 0) ? uint32_t(comma) : filter.Length();
|
|
if (strncmp(aReportStringId, filter.Data() + start, end - start) == 0) {
|
|
allowed = true;
|
|
break;
|
|
}
|
|
// Skip comma. End of line will be caught in for 'while' clause.
|
|
start = end + 1;
|
|
}
|
|
if (allowed) {
|
|
DispatchNotification(
|
|
mDocument->GetInnerWindow(), aNotificationType, aParams);
|
|
}
|
|
}
|
|
|
|
enum SilverlightPresence {
|
|
eNoSilverlight,
|
|
eSilverlightDisabled,
|
|
eSilverlightEnabled
|
|
};
|
|
static SilverlightPresence
|
|
CheckSilverlight()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
RefPtr<nsPluginHost> pluginHost = nsPluginHost::GetInst();
|
|
if (!pluginHost) {
|
|
return eNoSilverlight;
|
|
}
|
|
nsTArray<nsCOMPtr<nsIInternalPluginTag>> plugins;
|
|
pluginHost->GetPlugins(plugins, /*aIncludeDisabled*/ true);
|
|
for (const auto& plugin : plugins) {
|
|
for (const auto& mime : plugin->MimeTypes()) {
|
|
if (mime.LowerCaseEqualsLiteral("application/x-silverlight")
|
|
|| mime.LowerCaseEqualsLiteral("application/x-silverlight-2")) {
|
|
return plugin->IsEnabled() ? eSilverlightEnabled : eSilverlightDisabled;
|
|
}
|
|
}
|
|
}
|
|
|
|
return eNoSilverlight;
|
|
}
|
|
|
|
static void AppendToStringList(nsAString& list, const nsAString& item)
|
|
{
|
|
if (!list.IsEmpty()) {
|
|
list += NS_LITERAL_STRING(", ");
|
|
}
|
|
list += item;
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::SynthesizeAnalysis()
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
bool canPlay = false;
|
|
#if defined(XP_WIN)
|
|
bool WMFNeeded = false;
|
|
#endif
|
|
#if defined(MOZ_FFMPEG)
|
|
bool FFMpegNeeded = false;
|
|
#endif
|
|
nsAutoString playableFormats;
|
|
nsAutoString unplayableFormats;
|
|
nsAutoString supportedKeySystems;
|
|
nsAutoString unsupportedKeySystems;
|
|
DecoderDoctorDiagnostics::KeySystemIssue lastKeySystemIssue =
|
|
DecoderDoctorDiagnostics::eUnset;
|
|
|
|
for (auto& diag : mDiagnosticsSequence) {
|
|
switch (diag.mDecoderDoctorDiagnostics.Type()) {
|
|
case DecoderDoctorDiagnostics::eFormatSupportCheck:
|
|
if (diag.mDecoderDoctorDiagnostics.CanPlay()) {
|
|
canPlay = true;
|
|
AppendToStringList(playableFormats,
|
|
diag.mDecoderDoctorDiagnostics.Format());
|
|
} else {
|
|
#if defined(XP_WIN)
|
|
if (diag.mDecoderDoctorDiagnostics.DidWMFFailToLoad()) {
|
|
WMFNeeded = true;
|
|
}
|
|
#endif
|
|
#if defined(MOZ_FFMPEG)
|
|
if (diag.mDecoderDoctorDiagnostics.DidFFmpegFailToLoad()) {
|
|
FFMpegNeeded = true;
|
|
}
|
|
#endif
|
|
AppendToStringList(unplayableFormats,
|
|
diag.mDecoderDoctorDiagnostics.Format());
|
|
}
|
|
break;
|
|
case DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest:
|
|
if (diag.mDecoderDoctorDiagnostics.IsKeySystemSupported()) {
|
|
AppendToStringList(supportedKeySystems,
|
|
diag.mDecoderDoctorDiagnostics.KeySystem());
|
|
} else {
|
|
AppendToStringList(unsupportedKeySystems,
|
|
diag.mDecoderDoctorDiagnostics.KeySystem());
|
|
DecoderDoctorDiagnostics::KeySystemIssue issue =
|
|
diag.mDecoderDoctorDiagnostics.GetKeySystemIssue();
|
|
if (issue != DecoderDoctorDiagnostics::eUnset) {
|
|
lastKeySystemIssue = issue;
|
|
}
|
|
}
|
|
break;
|
|
default:
|
|
MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
|
|
== DecoderDoctorDiagnostics::eFormatSupportCheck
|
|
|| diag.mDecoderDoctorDiagnostics.Type()
|
|
== DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
|
|
break;
|
|
}
|
|
}
|
|
|
|
// Look at Key System issues first, as they may influence format checks.
|
|
if (!unsupportedKeySystems.IsEmpty() && supportedKeySystems.IsEmpty()) {
|
|
// No supported key systems!
|
|
switch (lastKeySystemIssue) {
|
|
case DecoderDoctorDiagnostics::eWidevineWithNoWMF:
|
|
if (CheckSilverlight() != eSilverlightEnabled) {
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unsupported key systems: %s, widevine without WMF nor Silverlight",
|
|
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
|
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
|
|
"MediaWidevineNoWMFNoSilverlight", NS_LITERAL_STRING(""));
|
|
return;
|
|
}
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (!canPlay && !unplayableFormats.IsEmpty()) {
|
|
#if defined(XP_WIN)
|
|
if (WMFNeeded) {
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - formats: %s -> Cannot play media because WMF was not found",
|
|
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
|
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
|
|
"MediaWMFNeeded", unplayableFormats);
|
|
return;
|
|
}
|
|
#endif
|
|
#if defined(MOZ_FFMPEG)
|
|
if (FFMpegNeeded) {
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - unplayable formats: %s -> Cannot play media because platform decoder was not found",
|
|
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
|
ReportAnalysis(dom::DecoderDoctorNotificationType::Platform_decoder_not_found,
|
|
"MediaPlatformDecoderNotFound", unplayableFormats);
|
|
return;
|
|
}
|
|
#endif
|
|
DD_WARN("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Cannot play media, unplayable formats: %s",
|
|
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
|
ReportAnalysis(dom::DecoderDoctorNotificationType::Cannot_play,
|
|
"MediaCannotPlayNoDecoders", unplayableFormats);
|
|
return;
|
|
}
|
|
if (!unplayableFormats.IsEmpty()) {
|
|
DD_INFO("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, but no decoders for some requested formats: %s",
|
|
this, mDocument, NS_ConvertUTF16toUTF8(unplayableFormats).get());
|
|
if (Preferences::GetBool("media.decoder-doctor.verbose", false)) {
|
|
ReportAnalysis(
|
|
dom::DecoderDoctorNotificationType::Can_play_but_some_missing_decoders,
|
|
"MediaNoDecoders", unplayableFormats);
|
|
}
|
|
return;
|
|
}
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::SynthesizeAnalysis() - Can play media, decoders available for all requested formats",
|
|
this, mDocument);
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDocumentWatcher::AddDiagnostics(DecoderDoctorDiagnostics&& aDiagnostics,
|
|
const char* aCallSite)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
|
|
if (!mDocument) {
|
|
return;
|
|
}
|
|
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::AddDiagnostics(DecoderDoctorDiagnostics{%s}, call site '%s')",
|
|
this, mDocument, aDiagnostics.GetDescription().Data(), aCallSite);
|
|
mDiagnosticsSequence.AppendElement(
|
|
Diagnostics(Move(aDiagnostics), aCallSite));
|
|
EnsureTimerIsStarted();
|
|
}
|
|
|
|
NS_IMETHODIMP
|
|
DecoderDoctorDocumentWatcher::Notify(nsITimer* timer)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
MOZ_ASSERT(timer == mTimer);
|
|
|
|
// Forget timer. (Assuming timer keeps itself and us alive during this call.)
|
|
mTimer = nullptr;
|
|
|
|
if (!mDocument) {
|
|
return NS_OK;
|
|
}
|
|
|
|
if (mDiagnosticsSequence.Length() > mDiagnosticsHandled) {
|
|
// We have new diagnostic data.
|
|
mDiagnosticsHandled = mDiagnosticsSequence.Length();
|
|
|
|
SynthesizeAnalysis();
|
|
|
|
// Restart timer, to redo analysis or stop watching this document,
|
|
// depending on whether anything new happens.
|
|
EnsureTimerIsStarted();
|
|
} else {
|
|
DD_DEBUG("DecoderDoctorDocumentWatcher[%p, doc=%p]::Notify() - No new diagnostics to analyze -> Stop watching",
|
|
this, mDocument);
|
|
// Stop watching this document, we don't expect more diagnostics for now.
|
|
// If more diagnostics come in, we'll treat them as another burst, separately.
|
|
// 'true' to remove the property from the document.
|
|
StopWatching(true);
|
|
}
|
|
|
|
return NS_OK;
|
|
}
|
|
|
|
|
|
void
|
|
DecoderDoctorDiagnostics::StoreFormatDiagnostics(nsIDocument* aDocument,
|
|
const nsAString& aFormat,
|
|
bool aCanPlay,
|
|
const char* aCallSite)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
// Make sure we only store once.
|
|
MOZ_ASSERT(mDiagnosticsType == eUnsaved);
|
|
mDiagnosticsType = eFormatSupportCheck;
|
|
|
|
if (NS_WARN_IF(!aDocument)) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreFormatDiagnostics(nsIDocument* aDocument=nullptr, format='%s', can-play=%d, call site '%s')",
|
|
this, NS_ConvertUTF16toUTF8(aFormat).get(), aCanPlay, aCallSite);
|
|
return;
|
|
}
|
|
if (NS_WARN_IF(aFormat.IsEmpty())) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreFormatDiagnostics(nsIDocument* aDocument=%p, format=<empty>, can-play=%d, call site '%s')",
|
|
this, aDocument, aCanPlay, aCallSite);
|
|
return;
|
|
}
|
|
|
|
RefPtr<DecoderDoctorDocumentWatcher> watcher =
|
|
DecoderDoctorDocumentWatcher::RetrieveOrCreate(aDocument);
|
|
|
|
if (NS_WARN_IF(!watcher)) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreFormatDiagnostics(nsIDocument* aDocument=%p, format='%s', can-play=%d, call site '%s') - Could not create document watcher",
|
|
this, aDocument, NS_ConvertUTF16toUTF8(aFormat).get(), aCanPlay, aCallSite);
|
|
return;
|
|
}
|
|
|
|
mFormat = aFormat;
|
|
mCanPlay = aCanPlay;
|
|
|
|
// StoreDiagnostics should only be called once, after all data is available,
|
|
// so it is safe to Move() from this object.
|
|
watcher->AddDiagnostics(Move(*this), aCallSite);
|
|
// Even though it's moved-from, the type should stay set
|
|
// (Only used to ensure that we do store only once.)
|
|
MOZ_ASSERT(mDiagnosticsType == eFormatSupportCheck);
|
|
}
|
|
|
|
void
|
|
DecoderDoctorDiagnostics::StoreMediaKeySystemAccess(nsIDocument* aDocument,
|
|
const nsAString& aKeySystem,
|
|
bool aIsSupported,
|
|
const char* aCallSite)
|
|
{
|
|
MOZ_ASSERT(NS_IsMainThread());
|
|
// Make sure we only store once.
|
|
MOZ_ASSERT(mDiagnosticsType == eUnsaved);
|
|
mDiagnosticsType = eMediaKeySystemAccessRequest;
|
|
|
|
if (NS_WARN_IF(!aDocument)) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreMediaKeySystemAccess(nsIDocument* aDocument=nullptr, keysystem='%s', supported=%d, call site '%s')",
|
|
this, NS_ConvertUTF16toUTF8(aKeySystem).get(), aIsSupported, aCallSite);
|
|
return;
|
|
}
|
|
if (NS_WARN_IF(aKeySystem.IsEmpty())) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreMediaKeySystemAccess(nsIDocument* aDocument=%p, keysystem=<empty>, supported=%d, call site '%s')",
|
|
this, aDocument, aIsSupported, aCallSite);
|
|
return;
|
|
}
|
|
|
|
RefPtr<DecoderDoctorDocumentWatcher> watcher =
|
|
DecoderDoctorDocumentWatcher::RetrieveOrCreate(aDocument);
|
|
|
|
if (NS_WARN_IF(!watcher)) {
|
|
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreMediaKeySystemAccess(nsIDocument* aDocument=%p, keysystem='%s', supported=%d, call site '%s') - Could not create document watcher",
|
|
this, NS_ConvertUTF16toUTF8(aKeySystem).get(), aIsSupported, aCallSite);
|
|
return;
|
|
}
|
|
|
|
mKeySystem = aKeySystem;
|
|
mIsKeySystemSupported = aIsSupported;
|
|
|
|
// StoreDiagnostics should only be called once, after all data is available,
|
|
// so it is safe to Move() from this object.
|
|
watcher->AddDiagnostics(Move(*this), aCallSite);
|
|
// Even though it's moved-from, the type should stay set
|
|
// (Only used to ensure that we do store only once.)
|
|
MOZ_ASSERT(mDiagnosticsType == eMediaKeySystemAccessRequest);
|
|
}
|
|
|
|
nsCString
|
|
DecoderDoctorDiagnostics::GetDescription() const
|
|
{
|
|
MOZ_ASSERT(mDiagnosticsType == eFormatSupportCheck
|
|
|| mDiagnosticsType == eMediaKeySystemAccessRequest);
|
|
nsCString s;
|
|
switch (mDiagnosticsType) {
|
|
case eUnsaved:
|
|
s = "Unsaved diagnostics, cannot get accurate description";
|
|
break;
|
|
case eFormatSupportCheck:
|
|
s = "format='";
|
|
s += NS_ConvertUTF16toUTF8(mFormat).get();
|
|
s += mCanPlay ? "', can play" : "', cannot play";
|
|
if (mWMFFailedToLoad) {
|
|
s += ", Windows platform decoder failed to load";
|
|
}
|
|
if (mFFmpegFailedToLoad) {
|
|
s += ", Linux platform decoder failed to load";
|
|
}
|
|
if (mGMPPDMFailedToStartup) {
|
|
s += ", GMP PDM failed to startup";
|
|
} else if (!mGMP.IsEmpty()) {
|
|
s += ", Using GMP '";
|
|
s += mGMP;
|
|
s += "'";
|
|
}
|
|
break;
|
|
case eMediaKeySystemAccessRequest:
|
|
s = "key system='";
|
|
s += NS_ConvertUTF16toUTF8(mKeySystem).get();
|
|
s += mIsKeySystemSupported ? "', supported" : "', not supported";
|
|
switch (mKeySystemIssue) {
|
|
case eUnset:
|
|
break;
|
|
case eWidevineWithNoWMF:
|
|
s += ", Widevine with no WMF";
|
|
break;
|
|
}
|
|
break;
|
|
default:
|
|
s = "?";
|
|
break;
|
|
}
|
|
return s;
|
|
}
|
|
|
|
} // namespace mozilla
|