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

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

Issue 257323003: Remove the IPC to request DemuxerConfigs when config changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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/media_source_player.cc
diff --git a/media/base/android/media_source_player.cc b/media/base/android/media_source_player.cc
index c4998e8174e6eef78d442af9cb8f3030c20fc934..1c25b697ba111fd093791f06eeb62b25804bbd1a 100644
--- a/media/base/android/media_source_player.cc
+++ b/media/base/android/media_source_player.cc
@@ -300,32 +300,11 @@ void MediaSourcePlayer::OnDemuxerConfigsAvailable(
duration_ = configs.duration;
clock_.SetDuration(duration_);
- audio_codec_ = configs.audio_codec;
- num_channels_ = configs.audio_channels;
- sampling_rate_ = configs.audio_sampling_rate;
- is_audio_encrypted_ = configs.is_audio_encrypted;
- audio_extra_data_ = configs.audio_extra_data;
- video_codec_ = configs.video_codec;
- width_ = configs.video_size.width();
- height_ = configs.video_size.height();
- is_video_encrypted_ = configs.is_video_encrypted;
+ SetDemuxerConfigs(configs, true);
+ SetDemuxerConfigs(configs, false);
manager()->OnMediaMetadataChanged(
player_id(), duration_, width_, height_, true);
-
- if (IsEventPending(CONFIG_CHANGE_EVENT_PENDING)) {
- if (reconfig_audio_decoder_)
- ConfigureAudioDecoderJob();
-
- if (reconfig_video_decoder_)
- ConfigureVideoDecoderJob();
-
- ClearPendingEvent(CONFIG_CHANGE_EVENT_PENDING);
-
- // Resume decoding after the config change if we are still playing.
- if (playing_)
- StartInternal();
- }
}
void MediaSourcePlayer::OnDemuxerDataAvailable(const DemuxerData& data) {
@@ -496,8 +475,16 @@ void MediaSourcePlayer::ProcessPendingEvents() {
if (IsEventPending(CONFIG_CHANGE_EVENT_PENDING)) {
DVLOG(1) << __FUNCTION__ << " : Handling CONFIG_CHANGE_EVENT.";
DCHECK(reconfig_audio_decoder_ || reconfig_video_decoder_);
- demuxer_->RequestDemuxerConfigs();
- return;
+ manager()->OnMediaMetadataChanged(
+ player_id(), duration_, width_, height_, true);
+
+ if (reconfig_audio_decoder_)
+ ConfigureAudioDecoderJob();
+
+ if (reconfig_video_decoder_)
+ ConfigureVideoDecoderJob();
+
+ ClearPendingEvent(CONFIG_CHANGE_EVENT_PENDING);
}
if (IsEventPending(SURFACE_CHANGE_EVENT_PENDING)) {
@@ -524,7 +511,6 @@ void MediaSourcePlayer::ProcessPendingEvents() {
DCHECK(audio_decoder_job_ || AudioFinished());
DCHECK(video_decoder_job_ || VideoFinished());
-
int count = (AudioFinished() ? 0 : 1) + (VideoFinished() ? 0 : 1);
// It is possible that all streams have finished decode, yet starvation
@@ -649,12 +635,13 @@ void MediaSourcePlayer::MediaDecoderCallback(
start_time_ticks_ = base::TimeTicks::Now();
}
- if (is_audio) {
+ if (is_audio)
DecodeMoreAudio();
- return;
- }
+ else
+ DecodeMoreVideo();
- DecodeMoreVideo();
+ if (IsEventPending(CONFIG_CHANGE_EVENT_PENDING))
+ ProcessPendingEvents();
}
void MediaSourcePlayer::DecodeMoreAudio() {
@@ -677,6 +664,9 @@ void MediaSourcePlayer::DecodeMoreAudio() {
// Wait for demuxer ready message.
DCHECK(!reconfig_audio_decoder_);
reconfig_audio_decoder_ = true;
+ DemuxerConfigs* configs = audio_decoder_job_->GetDemuxerConfigs();
+ DCHECK(configs);
+ SetDemuxerConfigs(*configs, true);
// Config change may have just been detected on the other stream. If so,
// don't send a duplicate demuxer config request.
@@ -686,7 +676,6 @@ void MediaSourcePlayer::DecodeMoreAudio() {
}
SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING);
- ProcessPendingEvents();
}
void MediaSourcePlayer::DecodeMoreVideo() {
@@ -714,6 +703,9 @@ void MediaSourcePlayer::DecodeMoreVideo() {
DCHECK(!reconfig_video_decoder_);
reconfig_video_decoder_ = true;
+ DemuxerConfigs* configs = video_decoder_job_->GetDemuxerConfigs();
+ DCHECK(configs);
+ SetDemuxerConfigs(*configs, false);
// Config change may have just been detected on the other stream. If so,
// don't send a duplicate demuxer config request.
@@ -723,7 +715,6 @@ void MediaSourcePlayer::DecodeMoreVideo() {
}
SetPendingEvent(CONFIG_CHANGE_EVENT_PENDING);
- ProcessPendingEvents();
}
void MediaSourcePlayer::PlaybackCompleted(bool is_audio) {
@@ -974,6 +965,9 @@ void MediaSourcePlayer::OnPrefetchDone() {
if (!VideoFinished())
DecodeMoreVideo();
+
+ if (IsEventPending(CONFIG_CHANGE_EVENT_PENDING))
+ ProcessPendingEvents();
}
const char* MediaSourcePlayer::GetEventName(PendingEventFlags event) {
@@ -1014,4 +1008,20 @@ void MediaSourcePlayer::ClearPendingEvent(PendingEventFlags event) {
pending_event_ &= ~event;
}
+void MediaSourcePlayer::SetDemuxerConfigs(const DemuxerConfigs& configs,
+ bool is_audio) {
+ if (is_audio) {
+ audio_codec_ = configs.audio_codec;
+ num_channels_ = configs.audio_channels;
+ sampling_rate_ = configs.audio_sampling_rate;
+ is_audio_encrypted_ = configs.is_audio_encrypted;
+ audio_extra_data_ = configs.audio_extra_data;
+ } else {
+ video_codec_ = configs.video_codec;
+ width_ = configs.video_size.width();
+ height_ = configs.video_size.height();
+ is_video_encrypted_ = configs.is_video_encrypted;
+ }
+}
+
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698