Index: media/base/android/media_source_player.cc |
diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc |
index 7fbd9c0757ef8569ef69c61dc829302400d338bf..39209913508a71a8a3525f1723c942cfda867840 100644 |
--- a/media/base/android/media_source_player.cc |
+++ b/media/base/android/media_source_player.cc |
@@ -47,19 +47,24 @@ MediaSourcePlayer::MediaSourcePlayer( |
is_waiting_for_video_decoder_(false), |
prerolling_(true), |
weak_factory_(this) { |
+ media_stat_.reset(new MediaStatistics()); |
+ |
audio_decoder_job_.reset(new AudioDecoderJob( |
base::Bind(&DemuxerAndroid::RequestDemuxerData, |
base::Unretained(demuxer_.get()), |
DemuxerStream::AUDIO), |
base::Bind(&MediaSourcePlayer::OnDemuxerConfigsChanged, |
- weak_factory_.GetWeakPtr()))); |
+ weak_factory_.GetWeakPtr()), |
+ &media_stat_->audio_frames())); |
video_decoder_job_.reset(new VideoDecoderJob( |
base::Bind(&DemuxerAndroid::RequestDemuxerData, |
base::Unretained(demuxer_.get()), |
DemuxerStream::VIDEO), |
base::Bind(request_media_resources_cb_, player_id), |
base::Bind(&MediaSourcePlayer::OnDemuxerConfigsChanged, |
- weak_factory_.GetWeakPtr()))); |
+ weak_factory_.GetWeakPtr()), |
+ &media_stat_->video_frames())); |
+ |
demuxer_->Initialize(this); |
interpolator_.SetUpperBound(base::TimeDelta()); |
weak_this_ = weak_factory_.GetWeakPtr(); |
@@ -467,6 +472,7 @@ void MediaSourcePlayer::MediaDecoderCallback( |
DVLOG(1) << __FUNCTION__ << " : decode error"; |
Release(); |
manager()->OnError(player_id(), MEDIA_ERROR_DECODE); |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
} |
@@ -477,6 +483,7 @@ void MediaSourcePlayer::MediaDecoderCallback( |
// any other pending events only after handling EOS detection. |
if (IsEventPending(SEEK_EVENT_PENDING)) { |
ProcessPendingEvents(); |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
} |
@@ -494,16 +501,20 @@ void MediaSourcePlayer::MediaDecoderCallback( |
if (pending_event_ != NO_EVENT_PENDING) { |
ProcessPendingEvents(); |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
} |
- if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) |
+ if (status == MEDIA_CODEC_OUTPUT_END_OF_STREAM) { |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
+ } |
if (!playing_) { |
if (is_clock_manager) |
interpolator_.StopInterpolating(); |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
} |
@@ -515,6 +526,7 @@ void MediaSourcePlayer::MediaDecoderCallback( |
is_waiting_for_key_ = true; |
manager()->OnWaitingForDecryptionKey(player_id()); |
} |
+ media_stat_->StopAndReport(GetCurrentTime()); |
xhwang
2015/09/30 21:02:57
Why should we StopAndReport() after ResumePlayback
Tima Vaisburd
2015/10/01 20:05:15
Aha, this is the place that you explained to me!
U
|
return; |
} |
@@ -531,8 +543,10 @@ void MediaSourcePlayer::MediaDecoderCallback( |
// If the status is MEDIA_CODEC_ABORT, stop decoding new data. The player is |
// in the middle of a seek or stop event and needs to wait for the IPCs to |
// come. |
- if (status == MEDIA_CODEC_ABORT) |
+ if (status == MEDIA_CODEC_ABORT) { |
+ media_stat_->StopAndReport(GetCurrentTime()); |
return; |
+ } |
if (prerolling_ && IsPrerollFinished(is_audio)) { |
if (IsPrerollFinished(!is_audio)) { |
@@ -654,6 +668,8 @@ bool MediaSourcePlayer::VideoFinished() { |
void MediaSourcePlayer::OnDecoderStarved() { |
DVLOG(1) << __FUNCTION__; |
+ media_stat_->AddStarvation(); |
+ |
SetPendingEvent(PREFETCH_REQUEST_EVENT_PENDING); |
ProcessPendingEvents(); |
} |
@@ -720,6 +736,8 @@ void MediaSourcePlayer::OnPrefetchDone() { |
if (!interpolator_.interpolating()) |
interpolator_.StartInterpolating(); |
+ media_stat_->Start(start_presentation_timestamp_); |
+ |
if (!AudioFinished()) |
DecodeMoreAudio(); |