Commit 8905ee14 authored by Takumi Fujimoto's avatar Takumi Fujimoto Committed by Chromium LUCI CQ

Add media remoting metrics

Media.Remoting.VideoPixelRateSupport
- How big the video resolution is and whether it's supported
Media.Remoting.Compatibility
- Record various reasons why the media may not be compatible with
  remoting

Bug: 1163944
Change-Id: I3c46662b71a7a860d6e63f6db3218c9c576d4305
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2605289Reviewed-by: default avatarJordan Bayles <jophba@chromium.org>
Reviewed-by: default avatarCaitlin Fischer <caitlinfischer@google.com>
Commit-Queue: Takumi Fujimoto <takumif@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842631}
parent 2d53d1ab
......@@ -125,6 +125,7 @@ source_set("media_remoting_tests") {
"fake_media_resource.cc",
"fake_media_resource.h",
"integration_test.cc",
"metrics_unittest.cc",
"proto_utils_unittest.cc",
"rpc_broker_unittest.cc",
]
......
......@@ -46,8 +46,7 @@ SessionMetricsRecorder::SessionMetricsRecorder()
last_channel_layout_(CHANNEL_LAYOUT_NONE),
last_sample_rate_(0),
last_video_codec_(kUnknownVideoCodec),
last_video_profile_(VIDEO_CODEC_PROFILE_UNKNOWN),
remote_playback_is_disabled_(false) {}
last_video_profile_(VIDEO_CODEC_PROFILE_UNKNOWN) {}
SessionMetricsRecorder::~SessionMetricsRecorder() = default;
......@@ -171,6 +170,21 @@ void SessionMetricsRecorder::OnRemotePlaybackDisabled(bool disabled) {
remote_playback_is_disabled_ = disabled;
}
void SessionMetricsRecorder::RecordVideoPixelRateSupport(
PixelRateSupport support) {
if (did_record_pixel_rate_support_) {
return;
}
did_record_pixel_rate_support_ = true;
base::UmaHistogramEnumeration("Media.Remoting.VideoPixelRateSupport",
support);
}
void SessionMetricsRecorder::RecordCompatibility(
RemotingCompatibility compatibility) {
base::UmaHistogramEnumeration("Media.Remoting.Compatibility", compatibility);
}
void SessionMetricsRecorder::RecordAudioConfiguration() {
UMA_HISTOGRAM_ENUMERATION("Media.Remoting.AudioCodec", last_audio_codec_,
kAudioCodecMax + 1);
......@@ -219,7 +233,7 @@ void SessionMetricsRecorder::RecordTrackConfiguration() {
}
RendererMetricsRecorder::RendererMetricsRecorder()
: start_time_(base::TimeTicks::Now()), did_record_first_playout_(false) {}
: start_time_(base::TimeTicks::Now()) {}
RendererMetricsRecorder::~RendererMetricsRecorder() = default;
......
......@@ -15,6 +15,39 @@
namespace media {
namespace remoting {
// The compatibility of a media content with remoting, and the reasons for
// incompatibilities.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class RemotingCompatibility {
kCompatible = 0,
kNoAudioNorVideo = 1,
kEncryptedVideo = 2,
kIncompatibleVideoCodec = 3,
kEncryptedAudio = 4,
kIncompatibleAudioCodec = 5,
kDisabledByPage = 6,
kDurationBelowThreshold = 7,
// Add new values here. Don't re-number existing values.
kMaxValue = kDurationBelowThreshold,
};
// The rate of pixels in a video and whether the receiver supports its playback.
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class PixelRateSupport {
// Pixels per second is at most the equivalent of 1080p 30fps.
k2kSupported = 0,
// More than 1080p 30fps and at most 2160p 30fps.
k4kSupported = 1,
k4kNotSupported = 2,
kOver4kNotSupported = 3,
// Add new values here. Don't re-number existing values.
kMaxValue = kOver4kNotSupported,
};
class SessionMetricsRecorder {
public:
SessionMetricsRecorder();
......@@ -32,6 +65,14 @@ class SessionMetricsRecorder {
void OnPipelineMetadataChanged(const PipelineMetadata& metadata);
void OnRemotePlaybackDisabled(bool disabled);
// Records the rate of pixels in a video (bucketed into FHD, 4K, etc.) and
// whether the receiver supports its playback. Records only on the first call
// for the recorder instance.
void RecordVideoPixelRateSupport(PixelRateSupport support);
// Records the compatibility of a media content with remoting.
void RecordCompatibility(RemotingCompatibility compatibility);
private:
// Whether audio only, video only, or both were played during the session.
//
......@@ -70,7 +111,9 @@ class SessionMetricsRecorder {
// Last known disabled playback state. This can change before/after a remoting
// session as well as during one.
bool remote_playback_is_disabled_;
bool remote_playback_is_disabled_ = false;
bool did_record_pixel_rate_support_ = false;
DISALLOW_COPY_AND_ASSIGN(SessionMetricsRecorder);
};
......@@ -94,7 +137,7 @@ class RendererMetricsRecorder {
private:
const base::TimeTicks start_time_;
bool did_record_first_playout_;
bool did_record_first_playout_ = false;
DISALLOW_COPY_AND_ASSIGN(RendererMetricsRecorder);
};
......
// Copyright 2016 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "media/remoting/metrics.h"
#include <string>
#include "base/test/metrics/histogram_tester.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
using base::Bucket;
using testing::ElementsAre;
namespace media {
namespace remoting {
namespace {
class MediaRemotingMetricsTest : public testing::Test {
protected:
media::remoting::SessionMetricsRecorder recorder_;
};
} // namespace
TEST_F(MediaRemotingMetricsTest, RecordVideoPixelRateSupport) {
constexpr char kPixelRateSupportHistogramName[] =
"Media.Remoting.VideoPixelRateSupport";
base::HistogramTester tester;
tester.ExpectTotalCount(kPixelRateSupportHistogramName, 0);
recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k4kNotSupported);
recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k2kSupported);
recorder_.RecordVideoPixelRateSupport(PixelRateSupport::k4kNotSupported);
// We record only for the first RecordVideoPixelRateSupport() call for the
// given SessionMetricsRecorder instance.
EXPECT_THAT(tester.GetAllSamples(kPixelRateSupportHistogramName),
ElementsAre(Bucket(
static_cast<int>(PixelRateSupport::k4kNotSupported), 1)));
}
TEST_F(MediaRemotingMetricsTest, RecordCompatibility) {
constexpr char kCompatibilityHistogramName[] = "Media.Remoting.Compatibility";
base::HistogramTester tester;
tester.ExpectTotalCount(kCompatibilityHistogramName, 0);
recorder_.RecordCompatibility(RemotingCompatibility::kIncompatibleVideoCodec);
recorder_.RecordCompatibility(RemotingCompatibility::kCompatible);
recorder_.RecordCompatibility(RemotingCompatibility::kIncompatibleVideoCodec);
EXPECT_THAT(
tester.GetAllSamples(kCompatibilityHistogramName),
ElementsAre(
Bucket(static_cast<int>(RemotingCompatibility::kCompatible), 1),
Bucket(
static_cast<int>(RemotingCompatibility::kIncompatibleVideoCodec),
2)));
}
} // namespace remoting
} // namespace media
This diff is collapsed.
......@@ -117,11 +117,14 @@ class RendererController final : public mojom::RemotingSource,
bool IsAudioCodecSupported() const;
bool IsAudioOrVideoSupported() const;
// Returns true if all of the technical requirements for the media pipeline
// and remote rendering are being met. This does not include environmental
// conditions, such as the content being dominant in the viewport, available
// network bandwidth, etc.
bool CanBeRemoting() const;
// Returns |kCompatible| if all of the technical requirements for the media
// pipeline and remote rendering are being met, and the first detected
// reason if incompatible. This does not include environmental conditions,
// such as the content being dominant in the viewport, available network
// bandwidth, etc.
RemotingCompatibility GetVideoCompatibility() const;
RemotingCompatibility GetAudioCompatibility() const;
RemotingCompatibility GetCompatibility() const;
// Determines whether to enter or leave Remoting mode and switches if
// necessary. Each call to this method could cause a remoting session to be
......@@ -146,6 +149,10 @@ class RendererController final : public mojom::RemotingSource,
unsigned decoded_frame_count_before_delay,
base::TimeTicks delayed_start_time);
// Records in a histogram and returns whether the receiver supports the given
// pixel rate.
bool RecordPixelRateSupport(double pixels_per_second);
// Queries on remoting sink capabilities.
bool HasVideoCapability(mojom::RemotingSinkVideoCapability capability) const;
bool HasAudioCapability(mojom::RemotingSinkAudioCapability capability) const;
......
......@@ -64109,6 +64109,17 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
<int value="14" label="User refused to terminate process"/>
</enum>
<enum name="RemotingCompatibility">
<int value="0" label="Compatible"/>
<int value="1" label="Incompatible, no audio nor video"/>
<int value="2" label="Incompatible, encrypted video"/>
<int value="3" label="Incompatible video codec"/>
<int value="4" label="Incompatible, encrypted audio"/>
<int value="5" label="Incompatible audio codec"/>
<int value="6" label="Incompatible, disabled by page"/>
<int value="7" label="Incompatible, duration below threshold"/>
</enum>
<enum name="RemotingStartTrigger">
<int value="0" label="Unknown start trigger"/>
<int value="1" label="Entered fullscreen"/>
......@@ -64151,6 +64162,19 @@ https://www.dmtf.org/sites/default/files/standards/documents/DSP0134_2.7.1.pdf
<int value="3" label="Audio and video"/>
</enum>
<enum name="RemotingVideoPixelRateSupport">
<int value="0"
label="Supported; pixels-per-second is equivalent to at most 1080p
30fps"/>
<int value="1"
label="Supported; equivalent to more than 1080p 30fps and at most 2160p
30fps"/>
<int value="2"
label="Not supported; equivalent to more than 1080p 30fps and at most
2160p 30fps"/>
<int value="3" label="Not supported; equivalent to more than 2160p 30fps"/>
</enum>
<enum name="RemoveCompromisedCredentialsReason">
<int value="0" label="Update - If the credentials was updated."/>
<int value="1" label="Remove - If the credentials was removed."/>
......@@ -2993,6 +2993,17 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
</summary>
</histogram>
<histogram name="Media.Remoting.Compatibility" enum="RemotingCompatibility"
expires_after="2022-02-01">
<owner>takumif@chromium.org</owner>
<owner>openscreen-eng@google.com</owner>
<summary>
Whether the given media is compatible with media remoting. Recorded whenever
the conditions are met to start remoting (e.g. the media element is the
dominant page content and is not paused).
</summary>
</histogram>
<histogram name="Media.Remoting.SessionDuration" units="ms"
expires_after="2021-07-01">
<owner>miu@chromium.org</owner>
......@@ -3101,6 +3112,16 @@ reviews. Googlers can read more about this at go/gwsq-gerrit.
<summary>Video width while remoting content.</summary>
</histogram>
<histogram name="Media.Remoting.VideoPixelRateSupport"
enum="RemotingVideoPixelRateSupport" expires_after="2022-02-01">
<owner>takumif@chromium.org</owner>
<owner>openscreen-eng@google.com</owner>
<summary>
Pixels-per-second in a video and whether the receiver supports its playback.
Recorded whenever we are about to start media remoting a video.
</summary>
</histogram>
<histogram name="Media.RtcLowLatencyVideoRenderer.AverageQueueLengthX10"
units="frames" expires_after="2021-05-31">
<owner>kron@chromium.org</owner>
......
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