Commit db5a7efe authored by John Rummell's avatar John Rummell Committed by Commit Bot

Add UMA to record encryption scheme used by HTML5 video

Record the encryption scheme reported in the video for both the audio and
video streams. Reported when the first AudioDecoderConfig/VideoDecoderConfig
is seen for the file.

BUG=658026
TEST=tested locally

Change-Id: Id210e18f0cedc11800abdce5286eb8488271516a
Reviewed-on: https://chromium-review.googlesource.com/1038784Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Reviewed-by: default avatarXiaohan Wang <xhwang@chromium.org>
Commit-Queue: John Rummell <jrummell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#558897}
parent 163a0bdc
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include "media/audio/null_audio_sink.h" #include "media/audio/null_audio_sink.h"
#include "media/base/bind_to_current_loop.h" #include "media/base/bind_to_current_loop.h"
#include "media/base/cdm_context.h" #include "media/base/cdm_context.h"
#include "media/base/encryption_scheme.h"
#include "media/base/limits.h" #include "media/base/limits.h"
#include "media/base/media_content_type.h" #include "media/base/media_content_type.h"
#include "media/base/media_log.h" #include "media/base/media_log.h"
...@@ -168,6 +169,21 @@ blink::WebLocalizedString::Name GetSwitchToLocalMessage( ...@@ -168,6 +169,21 @@ blink::WebLocalizedString::Name GetSwitchToLocalMessage(
return blink::WebLocalizedString::kMediaRemotingStopNoText; return blink::WebLocalizedString::kMediaRemotingStopNoText;
} }
// These values are persisted to UMA. Entries should not be renumbered and
// numeric values should never be reused.
// TODO(crbug.com/825041): This should use EncryptionMode when kUnencrypted
// removed.
enum class EncryptionSchemeUMA { kCenc = 0, kCbcs = 1, kCount };
EncryptionSchemeUMA DetermineEncryptionSchemeUMAValue(
const EncryptionScheme& encryption_scheme) {
if (encryption_scheme.mode() == EncryptionScheme::CIPHER_MODE_AES_CBC)
return EncryptionSchemeUMA::kCbcs;
DCHECK_EQ(encryption_scheme.mode(), EncryptionScheme::CIPHER_MODE_AES_CTR);
return EncryptionSchemeUMA::kCenc;
}
} // namespace } // namespace
class BufferedDataSourceHostImpl; class BufferedDataSourceHostImpl;
...@@ -1595,7 +1611,15 @@ void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) { ...@@ -1595,7 +1611,15 @@ void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) {
metadata.video_decoder_config.video_rotation(), metadata.video_decoder_config.video_rotation(),
VIDEO_ROTATION_MAX + 1); VIDEO_ROTATION_MAX + 1);
if (HasAudio()) {
RecordEncryptionScheme("Audio",
metadata.audio_decoder_config.encryption_scheme());
}
if (HasVideo()) { if (HasVideo()) {
RecordEncryptionScheme("Video",
metadata.video_decoder_config.encryption_scheme());
if (overlay_enabled_) { if (overlay_enabled_) {
// SurfaceView doesn't support rotated video, so transition back if // SurfaceView doesn't support rotated video, so transition back if
// the video is now rotated. If |always_enable_overlays_|, we keep the // the video is now rotated. If |always_enable_overlays_|, we keep the
...@@ -3187,4 +3211,19 @@ void WebMediaPlayerImpl::RecordTimingUMA(const std::string& key, ...@@ -3187,4 +3211,19 @@ void WebMediaPlayerImpl::RecordTimingUMA(const std::string& key,
base::UmaHistogramMediumTimes(key + ".EME", elapsed); base::UmaHistogramMediumTimes(key + ".EME", elapsed);
} }
void WebMediaPlayerImpl::RecordEncryptionScheme(
const std::string& stream_name,
const EncryptionScheme& encryption_scheme) {
DCHECK(stream_name == "Audio" || stream_name == "Video");
// If the stream is not encrypted, don't record it.
if (encryption_scheme.mode() == EncryptionScheme::CIPHER_MODE_UNENCRYPTED)
return;
base::UmaHistogramEnumeration(
"Media.EME.EncryptionScheme.Initial." + stream_name,
DetermineEncryptionSchemeUMAValue(encryption_scheme),
EncryptionSchemeUMA::kCount);
}
} // namespace media } // namespace media
...@@ -77,6 +77,7 @@ class GLES2Interface; ...@@ -77,6 +77,7 @@ class GLES2Interface;
namespace media { namespace media {
class CdmContextRef; class CdmContextRef;
class ChunkDemuxer; class ChunkDemuxer;
class EncryptionScheme;
class VideoDecodeStatsReporter; class VideoDecodeStatsReporter;
class MediaLog; class MediaLog;
class UrlIndex; class UrlIndex;
...@@ -574,6 +575,11 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl ...@@ -574,6 +575,11 @@ class MEDIA_BLINK_EXPORT WebMediaPlayerImpl
// of |chunk_demuxer_|, while the EME one is only recorded if |is_encrypted_|. // of |chunk_demuxer_|, while the EME one is only recorded if |is_encrypted_|.
void RecordTimingUMA(const std::string& key, base::TimeDelta elapsed); void RecordTimingUMA(const std::string& key, base::TimeDelta elapsed);
// Records the encryption scheme used by the stream |stream_name|. This is
// only recorded when metadata is available.
void RecordEncryptionScheme(const std::string& stream_name,
const EncryptionScheme& encryption_scheme);
blink::WebLocalFrame* const frame_; blink::WebLocalFrame* const frame_;
// The playback state last reported to |delegate_|, to avoid setting duplicate // The playback state last reported to |delegate_|, to avoid setting duplicate
......
...@@ -29522,6 +29522,11 @@ Called by update_use_counter_css.py.--> ...@@ -29522,6 +29522,11 @@ Called by update_use_counter_css.py.-->
<int value="21" label="Gesture requirement overridden by play method."/> <int value="21" label="Gesture requirement overridden by play method."/>
</enum> </enum>
<enum name="MediaEncryptionScheme">
<int value="0" label="CENC"/>
<int value="1" label="CBCS"/>
</enum>
<enum name="MediaEngagementClearReason"> <enum name="MediaEngagementClearReason">
<int value="0" label="Data (all)"/> <int value="0" label="Data (all)"/>
<int value="1" label="Data (range)"/> <int value="1" label="Data (range)"/>
...@@ -37291,6 +37291,26 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries. ...@@ -37291,6 +37291,26 @@ http://cs/file:chrome/histograms.xml - but prefer this file for new entries.
</summary> </summary>
</histogram> </histogram>
<histogram name="Media.EME.EncryptionScheme.Initial.Audio"
units="MediaEncryptionScheme">
<owner>jrummell@chromium.org</owner>
<owner>media-dev@chromium.org</owner>
<summary>
The encryption scheme used by the audio stream in an HTML5 video. Reported
when metadata is available if the initial config is encrypted.
</summary>
</histogram>
<histogram name="Media.EME.EncryptionScheme.Initial.Video"
units="MediaEncryptionScheme">
<owner>jrummell@chromium.org</owner>
<owner>media-dev@chromium.org</owner>
<summary>
The encryption scheme used by the video stream in an HTML5 video. Reported
when metadata is available if the initial config is encrypted.
</summary>
</histogram>
<histogram base="true" name="Media.EME.generateKeyRequest" <histogram base="true" name="Media.EME.generateKeyRequest"
enum="MediaKeyException"> enum="MediaKeyException">
<obsolete> <obsolete>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment