Bug 1343409 - HTMLMediaElement::MozRequestDebugInfo returns EMEInfo. r=cpearce

MozReview-Commit-ID: 1iQP3OJmwdP

--HG--
extra : rebase_source : 171155ab5e58cac8cc9db9109a5c2fc88b1930d3
This commit is contained in:
karo 2017-03-01 12:56:29 +13:00
parent 9746f81e53
commit 3c2b014e09
6 changed files with 68 additions and 0 deletions

View File

@ -120,6 +120,7 @@ static mozilla::LazyLogModule gMediaElementEventsLog("nsMediaElementEvents");
#include "mozilla/dom/HTMLVideoElement.h"
#include "mozilla/dom/VideoPlaybackQuality.h"
#include "HTMLMediaElement.h"
using namespace mozilla::layers;
using mozilla::net::nsMediaFragmentURIParser;
@ -1482,6 +1483,14 @@ HTMLMediaElement::MozRequestDebugInfo(ErrorResult& aRv)
nsAutoString result;
GetMozDebugReaderData(result);
if (mMediaKeys) {
nsString EMEInfo;
GetEMEInfo(EMEInfo);
result.AppendLiteral("EME Info: ");
result.Append(EMEInfo);
result.AppendLiteral("\n");
}
if (mDecoder) {
mDecoder->RequestDebugInfo()->Then(
AbstractThread::MainThread(), __func__,
@ -7345,6 +7354,25 @@ HTMLMediaElement::AsyncRejectPendingPlayPromises(nsresult aError)
event.forget());
}
void
HTMLMediaElement::GetEMEInfo(nsString& aEMEInfo)
{
if (!mMediaKeys) {
return;
}
nsString keySystem;
mMediaKeys->GetKeySystem(keySystem);
nsString sessionsInfo;
mMediaKeys->GetSessionsInfo(sessionsInfo);
aEMEInfo.AppendLiteral("Key System=");
aEMEInfo.Append(keySystem);
aEMEInfo.AppendLiteral(" SessionsInfo=");
aEMEInfo.Append(sessionsInfo);
}
bool HasDebuggerPrivilege(JSContext* aCx, JSObject* aObj)
{
return nsContentUtils::CallerHasPermission(aCx,

View File

@ -287,6 +287,8 @@ public:
// called to notify that the principal of the decoder's media resource has changed.
void NotifyDecoderPrincipalChanged() final override;
void GetEMEInfo(nsString& aEMEInfo);
// An interface for observing principal changes on the media elements
// MediaDecoder. This will also be notified if the active CORSMode changes.
class DecoderPrincipalChangeObserver

View File

@ -95,6 +95,13 @@ MediaKeyStatusMap::GetKeyAtIndex(uint32_t aIndex) const
return TypedArrayCreator<ArrayBuffer>(mStatuses[aIndex].mKeyId);
}
nsString
MediaKeyStatusMap::GetKeyIDAsHexString(uint32_t aIndex) const
{
MOZ_ASSERT(aIndex < GetIterableLength());
return NS_ConvertUTF8toUTF16(ToHexString(mStatuses[aIndex].mKeyId));
}
MediaKeyStatus
MediaKeyStatusMap::GetValueAtIndex(uint32_t aIndex) const
{

View File

@ -53,6 +53,7 @@ public:
uint32_t GetIterableLength() const;
TypedArrayCreator<ArrayBuffer> GetKeyAtIndex(uint32_t aIndex) const;
nsString GetKeyIDAsHexString(uint32_t aIndex) const;
MediaKeyStatus GetValueAtIndex(uint32_t aIndex) const;
void Update(const nsTArray<CDMCaps::KeyStatus>& keys);

View File

@ -577,5 +577,33 @@ MediaKeys::Unbind()
mElement = nullptr;
}
void
MediaKeys::GetSessionsInfo(nsString& sessionsInfo)
{
for (KeySessionHashMap::Iterator it = mKeySessions.Iter();
!it.Done();
it.Next()) {
MediaKeySession* keySession = it.Data();
nsString sessionID;
keySession->GetSessionId(sessionID);
sessionsInfo.AppendLiteral("(sid:");
sessionsInfo.Append(sessionID);
MediaKeyStatusMap* keyStatusMap = keySession->KeyStatuses();
for (uint32_t i = 0; i < keyStatusMap->GetIterableLength(); i++) {
nsString keyID = keyStatusMap->GetKeyIDAsHexString(i);
sessionsInfo.AppendLiteral("(kid:");
sessionsInfo.Append(keyID);
using IntegerType = typename std::underlying_type<MediaKeyStatus>::type;
auto idx = static_cast<IntegerType>(keyStatusMap->GetValueAtIndex(i));
const char* keyStatus = MediaKeyStatusValues::strings[idx].value;
sessionsInfo.AppendLiteral(" status:");
sessionsInfo.Append(
NS_ConvertUTF8toUTF16((nsDependentCString(keyStatus))));
sessionsInfo.AppendLiteral(")");
}
sessionsInfo.AppendLiteral(")");
}
}
} // namespace dom
} // namespace mozilla

View File

@ -128,6 +128,8 @@ public:
// Returns true if this MediaKeys has been bound to a media element.
bool IsBoundToMediaElement() const;
void GetSessionsInfo(nsString& sessionsInfo);
private:
// Instantiate CDMProxy instance.