diff --git a/cobalt/media/base/metrics_provider.cc b/cobalt/media/base/metrics_provider.cc
index b6b4d72a5916..7bc8896377dc 100644
--- a/cobalt/media/base/metrics_provider.cc
+++ b/cobalt/media/base/metrics_provider.cc
@@ -151,6 +151,72 @@ void MediaMetricsProvider::ReportActionLatencyUMA(
UMA_HISTOGRAM_TIMES("Cobalt.Media.SbPlayer.Destroy.LatencyTiming",
action_duration);
break;
+ case MediaAction::SBPLAYER_GET_PREFERRED_OUTPUT_MODE:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.GetPreferredOutputMode.LatencyTiming",
+ action_duration, base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(5), 50);
+ break;
+ case MediaAction::SBPLAYER_SEEK:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.Seek.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(5), 50);
+ break;
+ case MediaAction::SBPLAYER_WRITE_END_OF_STREAM_AUDIO:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.WriteEndOfStream.Audio.LatencyTiming",
+ action_duration, base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(25), 50);
+ break;
+ case MediaAction::SBPLAYER_WRITE_END_OF_STREAM_VIDEO:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.WriteEndOfStream.Video.LatencyTiming",
+ action_duration, base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(25), 50);
+ break;
+ case MediaAction::SBPLAYER_SET_BOUNDS:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.SetBounds.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(50),
+ base::TimeDelta::FromMilliseconds(60), 50);
+ break;
+ case MediaAction::SBPLAYER_SET_PLAYBACK_RATE:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.SetPlaybackRate.LatencyTiming",
+ action_duration, base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(50), 50);
+ break;
+ case MediaAction::SBPLAYER_SET_VOLUME:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.SetVolume.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(50), 50);
+ break;
+ case MediaAction::SBPLAYER_GET_INFO:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.GetInfo.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(20), 50);
+ break;
+ case MediaAction::SBPLAYER_GET_CURRENT_FRAME:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.GetCurrentFrame.LatencyTiming",
+ action_duration, base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(250), 50);
+ break;
+ case MediaAction::SBPLAYER_GET_AUDIO_CONFIG:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbPlayer.GetAudioConfig.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(1),
+ base::TimeDelta::FromMilliseconds(50), 50);
+ break;
+ case MediaAction::SBDRM_CREATE:
+ UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
+ "Cobalt.Media.SbDrm.Create.LatencyTiming", action_duration,
+ base::TimeDelta::FromMicroseconds(500),
+ base::TimeDelta::FromMilliseconds(250), 50);
+ break;
case MediaAction::SBDRM_DESTROY:
UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
"Cobalt.Media.SbDrm.Destroy.LatencyTiming", action_duration,
diff --git a/cobalt/media/base/metrics_provider.h b/cobalt/media/base/metrics_provider.h
index 56a5c8328f00..135b2601716f 100644
--- a/cobalt/media/base/metrics_provider.h
+++ b/cobalt/media/base/metrics_provider.h
@@ -44,6 +44,17 @@ enum class MediaAction : uint8_t {
SBPLAYER_CREATE,
SBPLAYER_CREATE_URL_PLAYER,
SBPLAYER_DESTROY,
+ SBPLAYER_GET_PREFERRED_OUTPUT_MODE,
+ SBPLAYER_SEEK,
+ SBPLAYER_WRITE_END_OF_STREAM_AUDIO,
+ SBPLAYER_WRITE_END_OF_STREAM_VIDEO,
+ SBPLAYER_SET_BOUNDS,
+ SBPLAYER_SET_PLAYBACK_RATE,
+ SBPLAYER_SET_VOLUME,
+ SBPLAYER_GET_INFO,
+ SBPLAYER_GET_CURRENT_FRAME,
+ SBPLAYER_GET_AUDIO_CONFIG,
+ SBDRM_CREATE,
SBDRM_DESTROY,
SBDRM_GENERATE_SESSION_UPDATE_REQUEST,
SBDRM_UPDATE_SESSION,
diff --git a/cobalt/media/base/metrics_provider_test.cc b/cobalt/media/base/metrics_provider_test.cc
index 46a5470605fa..cd490f1c1aa1 100644
--- a/cobalt/media/base/metrics_provider_test.cc
+++ b/cobalt/media/base/metrics_provider_test.cc
@@ -94,6 +94,112 @@ TEST_F(MediaMetricsProviderTest, SbPlayerDestroy) {
std::string(kUmaPrefix) + "SbPlayer.Destroy.LatencyTiming", 100, 1);
}
+TEST_F(MediaMetricsProviderTest, SbPlayerGetPreferredOutputMode) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_GET_PREFERRED_OUTPUT_MODE);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_GET_PREFERRED_OUTPUT_MODE);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.GetPreferredOutputMode.LatencyTiming",
+ 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerSeek) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_SEEK);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_SEEK);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.Seek.LatencyTiming", 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerSetBounds) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.SetBounds.LatencyTiming", 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerSetPlaybackRate) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_SET_PLAYBACK_RATE);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_SET_PLAYBACK_RATE);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.SetPlaybackRate.LatencyTiming", 570,
+ 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerSetVolume) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_SET_VOLUME);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_SET_VOLUME);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.SetVolume.LatencyTiming", 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerGetInfo) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_GET_INFO);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.GetInfo.LatencyTiming", 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerGetCurrentFrame) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_GET_CURRENT_FRAME);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_GET_CURRENT_FRAME);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.GetCurrentFrame.LatencyTiming", 570,
+ 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerGetAudioConfig) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_GET_AUDIO_CONFIG);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_GET_AUDIO_CONFIG);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.GetAudioConfig.LatencyTiming", 570,
+ 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerWriteEndOfStreamAudio) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_WRITE_END_OF_STREAM_AUDIO);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_WRITE_END_OF_STREAM_AUDIO);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.WriteEndOfStream.Audio.LatencyTiming",
+ 570, 1);
+}
+
+TEST_F(MediaMetricsProviderTest, SbPlayerWriteEndOfStreamVideo) {
+ metrics_.StartTrackingAction(MediaAction::SBPLAYER_WRITE_END_OF_STREAM_VIDEO);
+
+ clock_.Advance(base::TimeDelta::FromMicroseconds(570));
+ metrics_.EndTrackingAction(MediaAction::SBPLAYER_WRITE_END_OF_STREAM_VIDEO);
+
+ histogram_tester_.ExpectUniqueSample(
+ std::string(kUmaPrefix) + "SbPlayer.WriteEndOfStream.Video.LatencyTiming",
+ 570, 1);
+}
+
TEST_F(MediaMetricsProviderTest, SbDrmCloseSession) {
metrics_.StartTrackingAction(MediaAction::SBDRM_CLOSE_SESSION);
diff --git a/cobalt/media/base/sbplayer_interface.cc b/cobalt/media/base/sbplayer_interface.cc
index ec7b76d1acc1..6b367d4c15ef 100644
--- a/cobalt/media/base/sbplayer_interface.cc
+++ b/cobalt/media/base/sbplayer_interface.cc
@@ -79,7 +79,12 @@ SbPlayer DefaultSbPlayerInterface::Create(
SbPlayerOutputMode DefaultSbPlayerInterface::GetPreferredOutputMode(
const SbPlayerCreationParam* creation_param) {
- return SbPlayerGetPreferredOutputMode(creation_param);
+ media_metrics_provider_.StartTrackingAction(
+ MediaAction::SBPLAYER_GET_PREFERRED_OUTPUT_MODE);
+ auto output_mode = SbPlayerGetPreferredOutputMode(creation_param);
+ media_metrics_provider_.EndTrackingAction(
+ MediaAction::SBPLAYER_GET_PREFERRED_OUTPUT_MODE);
+ return output_mode;
}
void DefaultSbPlayerInterface::Destroy(SbPlayer player) {
@@ -91,11 +96,13 @@ void DefaultSbPlayerInterface::Destroy(SbPlayer player) {
void DefaultSbPlayerInterface::Seek(SbPlayer player,
base::TimeDelta seek_to_timestamp,
int ticket) {
+ media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SEEK);
#if SB_API_VERSION >= 15
SbPlayerSeek(player, seek_to_timestamp.InMicroseconds(), ticket);
#else // SB_API_VERSION >= 15
SbPlayerSeek2(player, seek_to_timestamp.InMicroseconds(), ticket);
#endif // SB_API_VERSION >= 15
+ media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SEEK);
}
bool DefaultSbPlayerInterface::IsEnhancedAudioExtensionEnabled() const {
@@ -131,35 +138,57 @@ int DefaultSbPlayerInterface::GetMaximumNumberOfSamplesPerWrite(
void DefaultSbPlayerInterface::WriteEndOfStream(SbPlayer player,
SbMediaType stream_type) {
+ auto media_action = (stream_type == kSbMediaTypeAudio)
+ ? MediaAction::SBPLAYER_WRITE_END_OF_STREAM_AUDIO
+ : MediaAction::SBPLAYER_WRITE_END_OF_STREAM_VIDEO;
+ media_metrics_provider_.StartTrackingAction(media_action);
SbPlayerWriteEndOfStream(player, stream_type);
+ media_metrics_provider_.EndTrackingAction(media_action);
}
void DefaultSbPlayerInterface::SetBounds(SbPlayer player, int z_index, int x,
int y, int width, int height) {
+ media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
SbPlayerSetBounds(player, z_index, x, y, width, height);
+ media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SET_BOUNDS);
}
bool DefaultSbPlayerInterface::SetPlaybackRate(SbPlayer player,
double playback_rate) {
- return SbPlayerSetPlaybackRate(player, playback_rate);
+ media_metrics_provider_.StartTrackingAction(
+ MediaAction::SBPLAYER_SET_PLAYBACK_RATE);
+ auto set_playback_rate = SbPlayerSetPlaybackRate(player, playback_rate);
+ media_metrics_provider_.EndTrackingAction(
+ MediaAction::SBPLAYER_SET_PLAYBACK_RATE);
+ return set_playback_rate;
}
void DefaultSbPlayerInterface::SetVolume(SbPlayer player, double volume) {
+ media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_SET_VOLUME);
SbPlayerSetVolume(player, volume);
+ media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_SET_VOLUME);
}
void DefaultSbPlayerInterface::GetInfo(SbPlayer player,
#if SB_API_VERSION >= 15
SbPlayerInfo* out_player_info) {
+ media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO);
SbPlayerGetInfo(player, out_player_info);
#else // SB_API_VERSION >= 15
SbPlayerInfo2* out_player_info2) {
+ media_metrics_provider_.StartTrackingAction(MediaAction::SBPLAYER_GET_INFO);
SbPlayerGetInfo2(player, out_player_info2);
#endif // SB_API_VERSION >= 15
+ media_metrics_provider_.EndTrackingAction(MediaAction::SBPLAYER_GET_INFO);
}
SbDecodeTarget DefaultSbPlayerInterface::GetCurrentFrame(SbPlayer player) {
- return SbPlayerGetCurrentFrame(player);
+ media_metrics_provider_.StartTrackingAction(
+ MediaAction::SBPLAYER_GET_CURRENT_FRAME);
+ auto current_frame = SbPlayerGetCurrentFrame(player);
+ media_metrics_provider_.EndTrackingAction(
+ MediaAction::SBPLAYER_GET_CURRENT_FRAME);
+ return current_frame;
}
#if SB_HAS(PLAYER_WITH_URL)
@@ -199,7 +228,13 @@ void DefaultSbPlayerInterface::GetUrlPlayerExtraInfo(
bool DefaultSbPlayerInterface::GetAudioConfiguration(
SbPlayer player, int index,
SbMediaAudioConfiguration* out_audio_configuration) {
- return SbPlayerGetAudioConfiguration(player, index, out_audio_configuration);
+ media_metrics_provider_.StartTrackingAction(
+ MediaAction::SBPLAYER_GET_AUDIO_CONFIG);
+ auto audio_configuration =
+ SbPlayerGetAudioConfiguration(player, index, out_audio_configuration);
+ media_metrics_provider_.EndTrackingAction(
+ MediaAction::SBPLAYER_GET_AUDIO_CONFIG);
+ return audio_configuration;
}
#endif // SB_API_VERSION >= 15
diff --git a/tools/metrics/histograms/metadata/cobalt/histograms.xml b/tools/metrics/histograms/metadata/cobalt/histograms.xml
index 1cc9ae95c457..b2930b763b72 100644
--- a/tools/metrics/histograms/metadata/cobalt/histograms.xml
+++ b/tools/metrics/histograms/metadata/cobalt/histograms.xml
@@ -338,6 +338,96 @@ Always run the pretty print utility on this file after editing:
Timing data for the destruction of SbPlayer.
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for getting audio configuration.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for getting frame.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for getting media info.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for getting preferred output mode.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for setting seek.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for setting bounds.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for setting playback rate.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for setting volume.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for writing end of audio stream.
+
+
+
+
+
+ borongchen@google.com
+ cobalt-team@google.com
+ Timing data for writing end of video stream.
+
+