Bug 1247056 - DecDoc::StoreEvent for singular playback issues/solutions - r=jwwang
MozReview-Commit-ID: GYoitdB8Sj0
--- a/dom/media/DecoderDoctorDiagnostics.cpp
+++ b/dom/media/DecoderDoctorDiagnostics.cpp
@@ -12,16 +12,17 @@
#include "nsContentUtils.h"
#include "nsGkAtoms.h"
#include "nsIDocument.h"
#include "nsIObserverService.h"
#include "nsIScriptError.h"
#include "nsITimer.h"
#include "nsIWeakReference.h"
#include "nsPluginHost.h"
+#include "nsPrintfCString.h"
#include "VideoUtils.h"
#if defined(XP_WIN)
#include "mozilla/WindowsVersion.h"
#endif
static mozilla::LazyLogModule sDecoderDoctorLog("DecoderDoctor");
#define DD_LOG(level, arg, ...) MOZ_LOG(sDecoderDoctorLog, level, (arg, ##__VA_ARGS__))
@@ -467,16 +468,20 @@ DecoderDoctorDocumentWatcher::Synthesize
diag.mDecoderDoctorDiagnostics.KeySystem());
DecoderDoctorDiagnostics::KeySystemIssue issue =
diag.mDecoderDoctorDiagnostics.GetKeySystemIssue();
if (issue != DecoderDoctorDiagnostics::eUnset) {
lastKeySystemIssue = issue;
}
}
break;
+ case DecoderDoctorDiagnostics::eEvent:
+ // Events shouldn't be stored for processing.
+ MOZ_ASSERT(false);
+ break;
default:
MOZ_ASSERT(diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eFormatSupportCheck
|| diag.mDecoderDoctorDiagnostics.Type()
== DecoderDoctorDiagnostics::eMediaKeySystemAccessRequest);
break;
}
}
@@ -599,25 +604,25 @@ DecoderDoctorDocumentWatcher::Synthesize
this, mDocument);
}
void
DecoderDoctorDocumentWatcher::AddDiagnostics(DecoderDoctorDiagnostics&& aDiagnostics,
const char* aCallSite)
{
MOZ_ASSERT(NS_IsMainThread());
+ MOZ_ASSERT(aDiagnostics.Type() != DecoderDoctorDiagnostics::eEvent);
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));
+ mDiagnosticsSequence.AppendElement(Diagnostics(Move(aDiagnostics), aCallSite));
EnsureTimerIsStarted();
}
NS_IMETHODIMP
DecoderDoctorDocumentWatcher::Notify(nsITimer* timer)
{
MOZ_ASSERT(NS_IsMainThread());
MOZ_ASSERT(timer == mTimer);
@@ -722,29 +727,56 @@ DecoderDoctorDiagnostics::StoreMediaKeyS
DD_WARN("DecoderDoctorDiagnostics[%p]::StoreMediaKeySystemAccess(nsIDocument* aDocument=%p, keysystem='%s', supported=%d, call site '%s') - Could not create document watcher",
this, aDocument, 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.
+ // StoreMediaKeySystemAccess 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);
}
+void
+DecoderDoctorDiagnostics::StoreEvent(nsIDocument* aDocument,
+ const DecoderDoctorEvent& aEvent,
+ const char* aCallSite)
+{
+ MOZ_ASSERT(NS_IsMainThread());
+ // Make sure we only store once.
+ MOZ_ASSERT(mDiagnosticsType == eUnsaved);
+ mDiagnosticsType = eEvent;
+ mEvent = aEvent;
+
+ if (NS_WARN_IF(!aDocument)) {
+ DD_WARN("DecoderDoctorDiagnostics[%p]::StoreEvent(nsIDocument* aDocument=nullptr, aEvent=%s, call site '%s')",
+ this, GetDescription().get(), aCallSite);
+ return;
+ }
+
+ // TODO: Handle event here.
+}
+
+static const char*
+EventDomainString(DecoderDoctorEvent::Domain aDomain)
+{
+ switch (aDomain) {
+ // TODO
+ }
+ return "?";
+}
+
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();
@@ -776,16 +808,21 @@ DecoderDoctorDiagnostics::GetDescription
switch (mKeySystemIssue) {
case eUnset:
break;
case eWidevineWithNoWMF:
s += ", Widevine with no WMF";
break;
}
break;
+ case eEvent:
+ s = nsPrintfCString("event domain %s result=%u",
+ EventDomainString(mEvent.mDomain), mEvent.mResult);
+ break;
default:
+ MOZ_ASSERT_UNREACHABLE("Unexpected DiagnosticsType");
s = "?";
break;
}
return s;
}
} // namespace mozilla
--- a/dom/media/DecoderDoctorDiagnostics.h
+++ b/dom/media/DecoderDoctorDiagnostics.h
@@ -8,16 +8,23 @@
#define DecoderDoctorDiagnostics_h_
#include "nsString.h"
class nsIDocument;
namespace mozilla {
+struct DecoderDoctorEvent {
+ enum Domain {
+ // TODO
+ } mDomain;
+ nsresult mResult;
+};
+
// DecoderDoctorDiagnostics class, used to gather data from PDMs/DecoderTraits,
// and then notify the user about issues preventing (or worsening) playback.
//
// The expected usage is:
// 1. Instantiate a DecoderDoctorDiagnostics in a function (close to the point
// where a webpage is trying to know whether some MIME types can be played,
// or trying to play a media file).
// 2. Pass a pointer to the DecoderDoctorDiagnostics structure to one of the
@@ -41,20 +48,25 @@ public:
bool aCanPlay,
const char* aCallSite);
void StoreMediaKeySystemAccess(nsIDocument* aDocument,
const nsAString& aKeySystem,
bool aIsSupported,
const char* aCallSite);
+ void StoreEvent(nsIDocument* aDocument,
+ const DecoderDoctorEvent& aEvent,
+ const char* aCallSite);
+
enum DiagnosticsType {
eUnsaved,
eFormatSupportCheck,
- eMediaKeySystemAccessRequest
+ eMediaKeySystemAccessRequest,
+ eEvent
};
DiagnosticsType Type() const { return mDiagnosticsType; }
// Description string, for logging purposes; only call on stored diags.
nsCString GetDescription() const;
// Methods to record diagnostic information:
@@ -86,16 +98,21 @@ public:
{
mKeySystemIssue = aKeySystemIssue;
}
KeySystemIssue GetKeySystemIssue() const
{
return mKeySystemIssue;
}
+ DecoderDoctorEvent event() const
+ {
+ return mEvent;
+ }
+
private:
// Currently-known type of diagnostics. Set from one of the 'Store...' methods.
// This helps ensure diagnostics are only stored once,
// and makes it easy to know what information they contain.
DiagnosticsType mDiagnosticsType = eUnsaved;
nsString mFormat;
// True if there is at least one decoder that can play that format.
@@ -106,13 +123,15 @@ private:
bool mGMPPDMFailedToStartup = false;
bool mVideoNotSupported = false;
bool mAudioNotSupported = false;
nsCString mGMP;
nsString mKeySystem;
bool mIsKeySystemSupported = false;
KeySystemIssue mKeySystemIssue = eUnset;
+
+ DecoderDoctorEvent mEvent;
};
} // namespace mozilla
#endif