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

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: addressing comments from jschuh 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
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. 124 // Clear received data because we need to handle a config change.
wolenetz 2014/05/08 17:41:47 nit: we no longer clear the data. Sorry I didn't c
qinmin 2014/05/08 17:48:37 Done.
125 decode_cb_.Reset(); 125 decode_cb_.Reset();
126 ClearData(); 126 size_t index = CurrentReceivedDataChunkIndex();
127 return false; 127 if (received_data_[index].demuxer_configs.size() > 0) {
128 return scoped_ptr<DemuxerConfigs>(new DemuxerConfigs(
129 received_data_[index].demuxer_configs[0]));
130 } else {
131 ui_task_runner_->PostTask(FROM_HERE,
132 base::Bind(&MediaDecoderJob::OnDecodeCompleted,
133 base::Unretained(this),
134 MEDIA_CODEC_OK,
wolenetz 2014/05/08 17:41:47 nit: I think this is ok, but we would miss learnin
qinmin 2014/05/08 17:48:37 The crash will crash the browser process, probably
wolenetz 2014/05/08 20:05:25 nit: Can we do a CHECK, then, in media_source_dele
qinmin 2014/05/08 20:50:07 Sounds ok to me. modified the media_source_delegat
135 kNoTimestamp(), kNoTimestamp()));
136 return scoped_ptr<DemuxerConfigs>();
137 }
128 } 138 }
129 139
130 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp); 140 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp);
131 return true; 141 return scoped_ptr<DemuxerConfigs>();
132 } 142 }
133 143
134 void MediaDecoderJob::StopDecode() { 144 void MediaDecoderJob::StopDecode() {
135 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 145 DCHECK(ui_task_runner_->BelongsToCurrentThread());
136 DCHECK(is_decoding()); 146 DCHECK(is_decoding());
137 stop_decode_pending_ = true; 147 stop_decode_pending_ = true;
138 } 148 }
139 149
140 void MediaDecoderJob::Flush() { 150 void MediaDecoderJob::Flush() {
141 DCHECK(decode_cb_.is_null()); 151 DCHECK(decode_cb_.is_null());
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 }; 465 };
456 466
457 stop_decode_pending_ = false; 467 stop_decode_pending_ = false;
458 base::ResetAndReturn(&decode_cb_).Run( 468 base::ResetAndReturn(&decode_cb_).Run(
459 status, current_presentation_timestamp, max_presentation_timestamp); 469 status, current_presentation_timestamp, max_presentation_timestamp);
460 } 470 }
461 471
462 const AccessUnit& MediaDecoderJob::CurrentAccessUnit() const { 472 const AccessUnit& MediaDecoderJob::CurrentAccessUnit() const {
463 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 473 DCHECK(ui_task_runner_->BelongsToCurrentThread());
464 DCHECK(HasData()); 474 DCHECK(HasData());
465 int index = NoAccessUnitsRemainingInChunk(true) ? 475 size_t index = CurrentReceivedDataChunkIndex();
476 return received_data_[index].access_units[access_unit_index_[index]];
477 }
478
479 size_t MediaDecoderJob::CurrentReceivedDataChunkIndex() const {
480 return NoAccessUnitsRemainingInChunk(true) ?
466 inactive_demuxer_data_index() : current_demuxer_data_index_; 481 inactive_demuxer_data_index() : current_demuxer_data_index_;
467 return received_data_[index].access_units[access_unit_index_[index]];
468 } 482 }
469 483
470 bool MediaDecoderJob::NoAccessUnitsRemainingInChunk( 484 bool MediaDecoderJob::NoAccessUnitsRemainingInChunk(
471 bool is_active_chunk) const { 485 bool is_active_chunk) const {
472 DCHECK(ui_task_runner_->BelongsToCurrentThread()); 486 DCHECK(ui_task_runner_->BelongsToCurrentThread());
473 size_t index = is_active_chunk ? current_demuxer_data_index_ : 487 size_t index = is_active_chunk ? current_demuxer_data_index_ :
474 inactive_demuxer_data_index(); 488 inactive_demuxer_data_index();
475 return received_data_[index].access_units.size() <= access_unit_index_[index]; 489 return received_data_[index].access_units.size() <= access_unit_index_[index];
476 } 490 }
477 491
(...skipping 25 matching lines...) Expand all
503 } 517 }
504 518
505 void MediaDecoderJob::InitializeReceivedData() { 519 void MediaDecoderJob::InitializeReceivedData() {
506 for (size_t i = 0; i < 2; ++i) { 520 for (size_t i = 0; i < 2; ++i) {
507 received_data_[i] = DemuxerData(); 521 received_data_[i] = DemuxerData();
508 access_unit_index_[i] = 0; 522 access_unit_index_[i] = 0;
509 } 523 }
510 } 524 }
511 525
512 } // namespace media 526 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698