Bug 1305552 - Add telemetry to track uses of MediaKeySession.generateRequest. r=francois,gerald

This allows us to track how often EME CDMs are used, rather than just created.
The telemetry I added in bug 1304207 is reports whenever a CDM is created, but
some sites, such as the Shaka Player demo site, create CDMs without using them,
so that telemetry isn't a great measure in helping us detect when CDMs aren't
being used. Whereas the telemetry added here will report when the CDMs are used
to negotiate a license, i.e. when the CDMs are actually being used.


MozReview-Commit-ID: ExMIcIIBvS1
This commit is contained in:
Chris Pearce 2016-09-27 15:01:06 +13:00
Родитель 1748bfae57
Коммит f40bbc42f7
5 изменённых файлов: 36 добавлений и 21 удалений

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

@ -154,4 +154,17 @@ IsClearkeyKeySystem(const nsAString& aKeySystem)
return !CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem); return !CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem);
} }
CDMType
ToCDMTypeTelemetryEnum(const nsString& aKeySystem)
{
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
return CDMType::eWidevine;
} else if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
return CDMType::eClearKey;
} else if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
return CDMType::ePrimetime;
}
return CDMType::eUnknown;
}
} // namespace mozilla } // namespace mozilla

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

@ -106,6 +106,16 @@ KeySystemToGMPName(const nsAString& aKeySystem);
bool bool
IsClearkeyKeySystem(const nsAString& aKeySystem); IsClearkeyKeySystem(const nsAString& aKeySystem);
enum CDMType {
eClearKey = 0,
ePrimetime = 1,
eWidevine = 2,
eUnknown = 3
};
CDMType
ToCDMTypeTelemetryEnum(const nsString& aKeySystem);
} // namespace mozilla } // namespace mozilla
#endif // EME_LOG_H_ #endif // EME_LOG_H_

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

@ -199,6 +199,9 @@ MediaKeySession::GenerateRequest(const nsAString& aInitDataType,
return promise.forget(); return promise.forget();
} }
Telemetry::Accumulate(Telemetry::VIDEO_CDM_GENERATE_REQUEST_CALLED,
ToCDMTypeTelemetryEnum(mKeySystem));
// Convert initData to base64 for easier logging. // Convert initData to base64 for easier logging.
// Note: CreateSession() Move()s the data out of the array, so we have // Note: CreateSession() Move()s the data out of the array, so we have
// to copy it here. // to copy it here.

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

@ -401,26 +401,6 @@ MediaKeys::Init(ErrorResult& aRv)
return promise.forget(); return promise.forget();
} }
enum CDMCreatedType {
eClearKey = 0,
ePrimetime = 1,
eWidevine = 2,
eUnknown = 3
};
static CDMCreatedType
ToCDMCreatedTelemetryEnum(const nsString& aKeySystem)
{
if (!CompareUTF8toUTF16(kEMEKeySystemWidevine, aKeySystem)) {
return CDMCreatedType::eWidevine;
} else if (!CompareUTF8toUTF16(kEMEKeySystemClearkey, aKeySystem)) {
return CDMCreatedType::eClearKey;
} else if (!CompareUTF8toUTF16(kEMEKeySystemPrimetime, aKeySystem)) {
return CDMCreatedType::ePrimetime;
}
return CDMCreatedType::eUnknown;
}
void void
MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t aPluginId) MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t aPluginId)
{ {
@ -440,7 +420,7 @@ MediaKeys::OnCDMCreated(PromiseId aId, const nsACString& aNodeId, const uint32_t
mKeySystem, mKeySystem,
MediaKeySystemStatus::Cdm_created); MediaKeySystemStatus::Cdm_created);
Telemetry::Accumulate(Telemetry::VIDEO_CDM_CREATED, ToCDMCreatedTelemetryEnum(mKeySystem)); Telemetry::Accumulate(Telemetry::VIDEO_CDM_CREATED, ToCDMTypeTelemetryEnum(mKeySystem));
} }
already_AddRefed<MediaKeySession> already_AddRefed<MediaKeySession>

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

@ -8716,6 +8716,15 @@
"description": "Note the type of CDM (0=ClearKey, 1=Primetime, 2=Widevine, 3=unknown) every time we successfully instantiate an EME MediaKeys object.", "description": "Note the type of CDM (0=ClearKey, 1=Primetime, 2=Widevine, 3=unknown) every time we successfully instantiate an EME MediaKeys object.",
"releaseChannelCollection": "opt-out" "releaseChannelCollection": "opt-out"
}, },
"VIDEO_CDM_GENERATE_REQUEST_CALLED": {
"alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "58",
"bug_numbers": [1305552],
"kind": "enumerated",
"n_values": 6,
"description": "Note the type of CDM (0=ClearKey, 1=Primetime, 2=Widevine, 3=unknown) every time we call MediaKeySession.generateRequest().",
"releaseChannelCollection": "opt-out"
},
"MEDIA_CODEC_USED": { "MEDIA_CODEC_USED": {
"alert_emails": ["cpearce@mozilla.com"], "alert_emails": ["cpearce@mozilla.com"],
"expires_in_version": "never", "expires_in_version": "never",