diff options
author | jasonroberts <jasonroberts@google.com> | 2016-03-08 19:19:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-09 03:20:07 +0000 |
commit | 29f95615c5159c23bb5227d035daa9b90a580c0a (patch) | |
tree | e06d0b1b97ddd2c891c3e9f3e2dc81201e74e7bc /chromecast | |
parent | 3338dfbd7f61e4ebb5a1e1519e0ef930cd7499d8 (diff) | |
download | chromium_src-29f95615c5159c23bb5227d035daa9b90a580c0a.zip chromium_src-29f95615c5159c23bb5227d035daa9b90a580c0a.tar.gz chromium_src-29f95615c5159c23bb5227d035daa9b90a580c0a.tar.bz2 |
[Chromecast] Add support for logging platform playing states.
This will be used by analytics for the video quality dashboards.
BUG=internal b/26496758
Review URL: https://codereview.chromium.org/1772093002
Cr-Commit-Position: refs/heads/master@{#380048}
Diffstat (limited to 'chromecast')
-rw-r--r-- | chromecast/base/metrics/cast_metrics_test_helper.cc | 4 | ||||
-rw-r--r-- | chromecast/media/cma/pipeline/BUILD.gn | 1 | ||||
-rw-r--r-- | chromecast/media/cma/pipeline/media_pipeline_impl.cc | 23 |
3 files changed, 28 insertions, 0 deletions
diff --git a/chromecast/base/metrics/cast_metrics_test_helper.cc b/chromecast/base/metrics/cast_metrics_test_helper.cc index 043957f..d0ed02a 100644 --- a/chromecast/base/metrics/cast_metrics_test_helper.cc +++ b/chromecast/base/metrics/cast_metrics_test_helper.cc @@ -29,6 +29,7 @@ class CastMetricsHelperStub : public CastMetricsHelper { std::string GetMetricsNameWithAppName( const std::string& prefix, const std::string& suffix) const override; void SetMetricsSink(MetricsSink* delegate) override; + void RecordSimpleAction(const std::string& action) override; private: DISALLOW_COPY_AND_ASSIGN(CastMetricsHelperStub); @@ -79,6 +80,9 @@ void CastMetricsHelperStub::SetMetricsSink(MetricsSink* delegate) { } // namespace +void CastMetricsHelperStub::RecordSimpleAction(const std::string& action) { +} + void InitializeMetricsHelperForTesting() { if (!stub_instance_exists) { new CastMetricsHelperStub(); diff --git a/chromecast/media/cma/pipeline/BUILD.gn b/chromecast/media/cma/pipeline/BUILD.gn index 6b784a5..0db8d65 100644 --- a/chromecast/media/cma/pipeline/BUILD.gn +++ b/chromecast/media/cma/pipeline/BUILD.gn @@ -32,6 +32,7 @@ source_set("pipeline") { deps = [ "//base", + "//chromecast/base/metrics:metrics", "//chromecast/media/base", "//chromecast/media/cdm", "//chromecast/media/cma/backend", diff --git a/chromecast/media/cma/pipeline/media_pipeline_impl.cc b/chromecast/media/cma/pipeline/media_pipeline_impl.cc index 2ae9c51..73dc9ad 100644 --- a/chromecast/media/cma/pipeline/media_pipeline_impl.cc +++ b/chromecast/media/cma/pipeline/media_pipeline_impl.cc @@ -15,6 +15,7 @@ #include "base/single_thread_task_runner.h" #include "base/thread_task_runner_handle.h" #include "base/time/time.h" +#include "chromecast/base/metrics/cast_metrics_helper.h" #include "chromecast/media/cdm/browser_cdm_cast.h" #include "chromecast/media/cma/base/buffering_controller.h" #include "chromecast/media/cma/base/buffering_state.h" @@ -79,6 +80,11 @@ MediaPipelineImpl::~MediaPipelineImpl() { weak_factory_.InvalidateWeakPtrs(); + if (backend_state_ != BACKEND_STATE_UNINITIALIZED && + backend_state_ != BACKEND_STATE_INITIALIZED) + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Ended"); + // Since av pipeline still need to access device components in their // destructor, it's important to delete them first. video_pipeline_.reset(); @@ -198,6 +204,8 @@ void MediaPipelineImpl::StartPlayingFrom(base::TimeDelta time) { return; } backend_state_ = BACKEND_STATE_PLAYING; + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Playing"); // Enable time updates. statistics_rolling_counter_ = 0; @@ -249,6 +257,8 @@ void MediaPipelineImpl::Flush(const base::Closure& flush_cb) { // which may be invalidated later, to hardware. (b/25342604) CHECK(media_pipeline_backend_->Stop()); backend_state_ = BACKEND_STATE_INITIALIZED; + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Ended"); // 3. Flush both the audio and video pipeline. This will flush the frame // provider and invalidate all the unreleased buffers. @@ -270,6 +280,9 @@ void MediaPipelineImpl::Stop() { CMALOG(kLogControl) << __FUNCTION__; DCHECK(thread_checker_.CalledOnValidThread()); DCHECK(audio_pipeline_ || video_pipeline_); + if (backend_state_ != BACKEND_STATE_UNINITIALIZED) + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Ended"); // Cancel pending flush callbacks since we are about to stop/shutdown // audio/video pipelines. This will ensure A/V Flush won't happen in @@ -305,10 +318,14 @@ void MediaPipelineImpl::SetPlaybackRate(double rate) { if (backend_state_ == BACKEND_STATE_PAUSED) { media_pipeline_backend_->Resume(); backend_state_ = BACKEND_STATE_PLAYING; + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Playing"); } } else if (backend_state_ == BACKEND_STATE_PLAYING) { media_pipeline_backend_->Pause(); backend_state_ = BACKEND_STATE_PAUSED; + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Pause"); } } @@ -377,6 +394,8 @@ void MediaPipelineImpl::OnBufferingNotification(bool is_buffering) { if (is_buffering && (backend_state_ == BACKEND_STATE_PLAYING)) { media_pipeline_backend_->Pause(); backend_state_ = BACKEND_STATE_PAUSED; + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Pause"); } else if (!is_buffering && (backend_state_ == BACKEND_STATE_PAUSED)) { // Once we finish buffering, we need to honour the desired playback rate // (rather than just resuming). This way, if playback was paused while @@ -441,6 +460,10 @@ void MediaPipelineImpl::UpdateMediaTime() { void MediaPipelineImpl::OnError(::media::PipelineStatus error) { DCHECK(thread_checker_.CalledOnValidThread()); DCHECK_NE(error, ::media::PIPELINE_OK) << "PIPELINE_OK is not an error!"; + + metrics::CastMetricsHelper::GetInstance()->RecordSimpleAction( + "Cast.Platform.Error"); + if (!client_.error_cb.is_null()) client_.error_cb.Run(error); } |