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

Side by Side Diff: media/base/android/media_decoder_job.cc

Issue 257323003: Remove the IPC to request DemuxerConfigs when config changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: adding CHECK to enforce the optional demuxer_configs only has 0 or 1 element Created 6 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/media_source_player.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/base/android/media_decoder_job.h" 5 #include "media/base/android/media_decoder_job.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (HasData()) { 95 if (HasData()) {
96 DVLOG(1) << __FUNCTION__ << " : using previously received data"; 96 DVLOG(1) << __FUNCTION__ << " : using previously received data";
97 ui_task_runner_->PostTask(FROM_HERE, prefetch_cb); 97 ui_task_runner_->PostTask(FROM_HERE, prefetch_cb);
98 return; 98 return;
99 } 99 }
100 100
101 DVLOG(1) << __FUNCTION__ << " : requesting data"; 101 DVLOG(1) << __FUNCTION__ << " : requesting data";
102 RequestData(prefetch_cb); 102 RequestData(prefetch_cb);
103 } 103 }
104 104
105 bool MediaDecoderJob::Decode( 105 scoped_ptr<DemuxerConfigs> MediaDecoderJob::Decode(
106 base::TimeTicks start_time_ticks, 106 base::TimeTicks start_time_ticks,
107 base::TimeDelta start_presentation_timestamp, 107 base::TimeDelta start_presentation_timestamp,
108 const DecoderCallback& callback) { 108 const DecoderCallback& callback) {
109 DCHECK(decode_cb_.is_null()); 109 DCHECK(decode_cb_.is_null());
110 DCHECK(on_data_received_cb_.is_null()); 110 DCHECK(on_data_received_cb_.is_null());
111 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 111 DCHECK(ui_task_runner_->BelongsToCurrentThread());
112 112
113 decode_cb_ = callback; 113 decode_cb_ = callback;
114 114
115 if (!HasData()) { 115 if (!HasData()) {
116 RequestData(base::Bind(&MediaDecoderJob::DecodeCurrentAccessUnit, 116 RequestData(base::Bind(&MediaDecoderJob::DecodeCurrentAccessUnit,
117 base::Unretained(this), 117 base::Unretained(this),
118 start_time_ticks, 118 start_time_ticks,
119 start_presentation_timestamp)); 119 start_presentation_timestamp));
120 return true; 120 return scoped_ptr<DemuxerConfigs>();
121 } 121 }
122 122
123 if (DemuxerStream::kConfigChanged == CurrentAccessUnit().status) { 123 if (DemuxerStream::kConfigChanged == CurrentAccessUnit().status) {
124 // Clear received data because we need to handle a config change.
125 decode_cb_.Reset(); 124 decode_cb_.Reset();
126 ClearData(); 125 size_t index = CurrentReceivedDataChunkIndex();
127 return false; 126 CHECK_EQ(1u, received_data_[index].demuxer_configs.size());
127 return scoped_ptr<DemuxerConfigs>(new DemuxerConfigs(
128 received_data_[index].demuxer_configs[0]));
128 } 129 }
129 130
130 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp); 131 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp);
131 return true; 132 return scoped_ptr<DemuxerConfigs>();
132 } 133 }
133 134
134 void MediaDecoderJob::StopDecode() { 135 void MediaDecoderJob::StopDecode() {
135 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 136 DCHECK(ui_task_runner_->BelongsToCurrentThread());
136 DCHECK(is_decoding()); 137 DCHECK(is_decoding());
137 stop_decode_pending_ = true; 138 stop_decode_pending_ = true;
138 } 139 }
139 140
140 void MediaDecoderJob::Flush() { 141 void MediaDecoderJob::Flush() {
141 DCHECK(decode_cb_.is_null()); 142 DCHECK(decode_cb_.is_null());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 }; 456 };
456 457
457 stop_decode_pending_ = false; 458 stop_decode_pending_ = false;
458 base::ResetAndReturn(&decode_cb_).Run( 459 base::ResetAndReturn(&decode_cb_).Run(
459 status, current_presentation_timestamp, max_presentation_timestamp); 460 status, current_presentation_timestamp, max_presentation_timestamp);
460 } 461 }
461 462
462 const AccessUnit& MediaDecoderJob::CurrentAccessUnit() const { 463 const AccessUnit& MediaDecoderJob::CurrentAccessUnit() const {
463 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 464 DCHECK(ui_task_runner_->BelongsToCurrentThread());
464 DCHECK(HasData()); 465 DCHECK(HasData());
465 int index = NoAccessUnitsRemainingInChunk(true) ? 466 size_t index = CurrentReceivedDataChunkIndex();
467 return received_data_[index].access_units[access_unit_index_[index]];
468 }
469
470 size_t MediaDecoderJob::CurrentReceivedDataChunkIndex() const {
471 return NoAccessUnitsRemainingInChunk(true) ?
466 inactive_demuxer_data_index() : current_demuxer_data_index_; 472 inactive_demuxer_data_index() : current_demuxer_data_index_;
467 return received_data_[index].access_units[access_unit_index_[index]];
468 } 473 }
469 474
470 bool MediaDecoderJob::NoAccessUnitsRemainingInChunk( 475 bool MediaDecoderJob::NoAccessUnitsRemainingInChunk(
471 bool is_active_chunk) const { 476 bool is_active_chunk) const {
472 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 477 DCHECK(ui_task_runner_->BelongsToCurrentThread());
473 size_t index = is_active_chunk ? current_demuxer_data_index_ : 478 size_t index = is_active_chunk ? current_demuxer_data_index_ :
474 inactive_demuxer_data_index(); 479 inactive_demuxer_data_index();
475 return received_data_[index].access_units.size() <= access_unit_index_[index]; 480 return received_data_[index].access_units.size() <= access_unit_index_[index];
476 } 481 }
477 482
(...skipping 25 matching lines...) Expand all
503 } 508 }
504 509
505 void MediaDecoderJob::InitializeReceivedData() { 510 void MediaDecoderJob::InitializeReceivedData() {
506 for (size_t i = 0; i < 2; ++i) { 511 for (size_t i = 0; i < 2; ++i) {
507 received_data_[i] = DemuxerData(); 512 received_data_[i] = DemuxerData();
508 access_unit_index_[i] = 0; 513 access_unit_index_[i] = 0;
509 } 514 }
510 } 515 }
511 516
512 } // namespace media 517 } // namespace media
OLDNEW
« no previous file with comments | « media/base/android/media_decoder_job.h ('k') | media/base/android/media_source_player.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698