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

Unified Diff: media/base/android/audio_decoder_job.cc

Issue 1367403003: Added UMA metrics for MediaSourcePlayer and MediaCodecPlayer (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mtplayer-drm
Patch Set: Created 5 years, 3 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: media/base/android/audio_decoder_job.cc
diff --git a/media/base/android/audio_decoder_job.cc b/media/base/android/audio_decoder_job.cc
index 07b828882a29e5d32137c2db08ad08a509308950..0fa322cca9249b0342198b3b502c41bf617e6198 100644
--- a/media/base/android/audio_decoder_job.cc
+++ b/media/base/android/audio_decoder_job.cc
@@ -8,6 +8,7 @@
#include "base/lazy_instance.h"
#include "base/threading/thread.h"
#include "media/base/android/media_codec_bridge.h"
+#include "media/base/android/media_statistics.h"
#include "media/base/audio_timestamp_helper.h"
#include "media/base/timestamp_constants.h"
@@ -35,10 +36,12 @@ base::LazyInstance<AudioDecoderThread>::Leaky
AudioDecoderJob::AudioDecoderJob(
const base::Closure& request_data_cb,
- const base::Closure& on_demuxer_config_changed_cb)
+ const base::Closure& on_demuxer_config_changed_cb,
+ FrameStatistics* frame_statistics)
: MediaDecoderJob(g_audio_decoder_thread.Pointer()->task_runner(),
request_data_cb,
- on_demuxer_config_changed_cb),
+ on_demuxer_config_changed_cb,
+ frame_statistics),
audio_codec_(kUnknownAudioCodec),
num_channels_(0),
config_sampling_rate_(0),
@@ -106,14 +109,28 @@ void AudioDecoderJob::ReleaseOutputBuffer(
int64 head_position = (static_cast<AudioCodecBridge*>(
media_codec_bridge_.get()))->PlayOutputBuffer(
output_buffer_index, size, offset);
+
+ base::TimeTicks current_time = base::TimeTicks::Now();
+
size_t new_frames_count = size / bytes_per_frame_;
frame_count_ += new_frames_count;
audio_timestamp_helper_->AddFrames(new_frames_count);
int64 frames_to_play = frame_count_ - head_position;
DCHECK_GE(frames_to_play, 0);
+
+ const base::TimeDelta last_buffered =
+ audio_timestamp_helper_->GetTimestamp();
+
current_presentation_timestamp =
- audio_timestamp_helper_->GetTimestamp() -
+ last_buffered -
audio_timestamp_helper_->GetFrameDuration(frames_to_play);
+
+ if (frame_statistics_ && !next_frame_time_limit_.is_null() &&
qinmin 2015/09/29 23:47:44 I think we can just check the head_position variab
Tima Vaisburd 2015/09/30 18:50:09 Having the delay makes it possible to track it dow
+ next_frame_time_limit_ < current_time)
+ frame_statistics_->AddLateFrame(current_time - next_frame_time_limit_);
qinmin 2015/09/29 23:47:44 {} needed
Tima Vaisburd 2015/09/30 18:50:09 Done.
+
+ next_frame_time_limit_ =
+ current_time + (last_buffered - current_presentation_timestamp);
} else {
current_presentation_timestamp = kNoTimestamp();
}

Powered by Google App Engine
This is Rietveld 408576698