Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(295)

Unified Diff: chromecast/media/cma/pipeline/audio_pipeline_impl.cc

Issue 1776353006: [Chromecast] Add metrics for logging platform A/V bitrate estimates. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix formatting issue Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chromecast/media/cma/pipeline/audio_pipeline_impl.cc
diff --git a/chromecast/media/cma/pipeline/audio_pipeline_impl.cc b/chromecast/media/cma/pipeline/audio_pipeline_impl.cc
index ab5478b7e7d0c5f5e85820262bd15b893a3a60a2..7c5ee777bd86b8fd510f457953f2877556dd6022 100644
--- a/chromecast/media/cma/pipeline/audio_pipeline_impl.cc
+++ b/chromecast/media/cma/pipeline/audio_pipeline_impl.cc
@@ -8,6 +8,8 @@
#include <utility>
#include "base/bind.h"
+#include "base/time/time.h"
+#include "chromecast/base/metrics/cast_metrics_helper.h"
#include "chromecast/media/cma/base/buffering_defs.h"
#include "chromecast/media/cma/base/cma_logging.h"
#include "chromecast/media/cma/base/coded_frame_provider.h"
@@ -20,12 +22,25 @@ namespace media {
namespace {
const size_t kMaxAudioFrameSize = 32 * 1024;
+
+void LogEstimatedAudioBitrate(int bitrate) {
+ CMALOG(kLogControl) << "Estimated audio bitrate is " << bitrate << " kbps";
+ chromecast::metrics::CastMetricsHelper* metrics_helper =
+ chromecast::metrics::CastMetricsHelper::GetInstance();
halliwell 2016/03/10 17:57:54 nit, no need for 'chromecast::'
ejason 2016/03/11 00:24:45 Done.
+ metrics_helper->RecordSimpleActionWithValue("Cast.Platform.AudioBitrate",
+ bitrate);
+}
+
}
AudioPipelineImpl::AudioPipelineImpl(
MediaPipelineBackend::AudioDecoder* decoder,
const AvPipelineClient& client)
- : AvPipelineImpl(decoder, client), audio_decoder_(decoder) {
+ : AvPipelineImpl(decoder, client),
+ audio_decoder_(decoder),
+ last_sample_time_(base::Time()),
+ elapsed_time_delta_(base::TimeDelta()),
+ audio_bytes_for_bitrate_estimation_(0) {
DCHECK(audio_decoder_);
}
@@ -84,6 +99,25 @@ void AudioPipelineImpl::UpdateStatistics() {
delta_stats.audio_bytes_decoded =
current_stats.audio_bytes_decoded - previous_stats_.audio_bytes_decoded;
+ base::Time current_time = base::Time::Now();
+ elapsed_time_delta_ += current_time - last_sample_time_;
halliwell 2016/03/10 17:57:54 If the first time this function is called, we're i
ejason 2016/03/11 00:24:45 I've updated the new logic to handle the first-tim
+ audio_bytes_for_bitrate_estimation_ += delta_stats.audio_bytes_decoded;
+
+ if (state() != kPlaying) {
+ // Invalidate any data that was collected in a window where we were not in
+ // the playing state.
+ elapsed_time_delta_ = base::TimeDelta::FromSeconds(0);
+ audio_bytes_for_bitrate_estimation_ = 0;
halliwell 2016/03/10 17:57:54 shouldn't we reset these things on state transitio
ejason 2016/03/11 00:24:45 The state transitions are handled in media_pipelin
+ } else if (elapsed_time_delta_.InMilliseconds() > 5000) {
+ int estimated_bitrate_in_kbps = 8 * audio_bytes_for_bitrate_estimation_ /
+ elapsed_time_delta_.InMilliseconds();
+ if (estimated_bitrate_in_kbps > 0) {
+ LogEstimatedAudioBitrate(estimated_bitrate_in_kbps);
+ }
+ elapsed_time_delta_ = base::TimeDelta::FromSeconds(0);
+ audio_bytes_for_bitrate_estimation_ = 0;
+ }
+ last_sample_time_ = current_time;
previous_stats_ = current_stats;
client().statistics_cb.Run(delta_stats);

Powered by Google App Engine
This is Rietveld 408576698