Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 bool MediaDecoderJob::Decode( |
|
wolenetz
2014/05/02 22:25:30
It seems to me more understandable to just return
qinmin
2014/05/05 20:52:19
Done.
wolenetz
2014/05/05 22:06:55
Oops - I swapped my false / true mapping in my ori
| |
| 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 true; |
| 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. |
| 125 decode_cb_.Reset(); | 125 decode_cb_.Reset(); |
|
wolenetz
2014/05/02 22:25:30
I'm confused: previously we needed to ClearData().
qinmin
2014/05/05 20:52:19
If there is a config change, MediaDecoderJob will
wolenetz
2014/05/05 22:06:55
sgtm thanks
| |
| 126 ClearData(); | |
| 127 return false; | 126 return false; |
| 128 } | 127 } |
| 129 | 128 |
| 130 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp); | 129 DecodeCurrentAccessUnit(start_time_ticks, start_presentation_timestamp); |
| 131 return true; | 130 return true; |
| 132 } | 131 } |
| 133 | 132 |
| 134 void MediaDecoderJob::StopDecode() { | 133 void MediaDecoderJob::StopDecode() { |
| 135 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 134 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 136 DCHECK(is_decoding()); | 135 DCHECK(is_decoding()); |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 147 | 146 |
| 148 void MediaDecoderJob::BeginPrerolling(base::TimeDelta preroll_timestamp) { | 147 void MediaDecoderJob::BeginPrerolling(base::TimeDelta preroll_timestamp) { |
| 149 DVLOG(1) << __FUNCTION__ << "(" << preroll_timestamp.InSecondsF() << ")"; | 148 DVLOG(1) << __FUNCTION__ << "(" << preroll_timestamp.InSecondsF() << ")"; |
| 150 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 149 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 151 DCHECK(!is_decoding()); | 150 DCHECK(!is_decoding()); |
| 152 | 151 |
| 153 preroll_timestamp_ = preroll_timestamp; | 152 preroll_timestamp_ = preroll_timestamp; |
| 154 prerolling_ = true; | 153 prerolling_ = true; |
| 155 } | 154 } |
| 156 | 155 |
| 156 DemuxerConfigs* MediaDecoderJob::GetDemuxerConfigs() { | |
| 157 DVLOG(1) << __FUNCTION__; | |
| 158 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | |
| 159 DCHECK(!is_decoding()); | |
| 160 | |
| 161 int index = NoAccessUnitsRemainingInChunk(true) ? | |
|
wolenetz
2014/05/02 22:25:30
nit: seems like some code duplication of CurrentAc
qinmin
2014/05/05 20:52:19
Done.
| |
| 162 inactive_demuxer_data_index() : current_demuxer_data_index_; | |
| 163 if (received_data_[index].demuxer_configs.size() > 0) | |
| 164 return &(received_data_[index].demuxer_configs[0]); | |
| 165 return NULL; | |
| 166 } | |
| 167 | |
| 157 void MediaDecoderJob::Release() { | 168 void MediaDecoderJob::Release() { |
| 158 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 169 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 159 DVLOG(1) << __FUNCTION__; | 170 DVLOG(1) << __FUNCTION__; |
| 160 | 171 |
| 161 // If the decoder job is not waiting for data, and is still decoding, we | 172 // If the decoder job is not waiting for data, and is still decoding, we |
| 162 // cannot delete the job immediately. | 173 // cannot delete the job immediately. |
| 163 destroy_pending_ = on_data_received_cb_.is_null() && is_decoding(); | 174 destroy_pending_ = on_data_received_cb_.is_null() && is_decoding(); |
| 164 | 175 |
| 165 request_data_cb_.Reset(); | 176 request_data_cb_.Reset(); |
| 166 on_data_received_cb_.Reset(); | 177 on_data_received_cb_.Reset(); |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 261 } | 272 } |
| 262 | 273 |
| 263 void MediaDecoderJob::DecodeCurrentAccessUnit( | 274 void MediaDecoderJob::DecodeCurrentAccessUnit( |
| 264 base::TimeTicks start_time_ticks, | 275 base::TimeTicks start_time_ticks, |
| 265 base::TimeDelta start_presentation_timestamp) { | 276 base::TimeDelta start_presentation_timestamp) { |
| 266 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 277 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 267 DCHECK(!decode_cb_.is_null()); | 278 DCHECK(!decode_cb_.is_null()); |
| 268 | 279 |
| 269 RequestCurrentChunkIfEmpty(); | 280 RequestCurrentChunkIfEmpty(); |
| 270 const AccessUnit& access_unit = CurrentAccessUnit(); | 281 const AccessUnit& access_unit = CurrentAccessUnit(); |
| 271 // If the first access unit is a config change, request the player to dequeue | 282 // If the first access unit is a config change, request the player to dequeue |
|
wolenetz
2014/05/02 22:25:30
nit: Now, if the first AU is a config change, shou
qinmin
2014/05/05 20:52:19
When MSP calls decode(), if there is no data avail
wolenetz
2014/05/05 22:06:55
sgtm thanks
| |
| 272 // the input buffer again so that it can request config data. | 283 // the input buffer again so that it can request config data. |
| 273 if (access_unit.status == DemuxerStream::kConfigChanged) { | 284 if (access_unit.status == DemuxerStream::kConfigChanged) { |
| 274 ui_task_runner_->PostTask(FROM_HERE, | 285 ui_task_runner_->PostTask(FROM_HERE, |
| 275 base::Bind(&MediaDecoderJob::OnDecodeCompleted, | 286 base::Bind(&MediaDecoderJob::OnDecodeCompleted, |
| 276 base::Unretained(this), | 287 base::Unretained(this), |
| 277 MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER, | 288 MEDIA_CODEC_DEQUEUE_INPUT_AGAIN_LATER, |
| 278 kNoTimestamp(), kNoTimestamp())); | 289 kNoTimestamp(), kNoTimestamp())); |
| 279 return; | 290 return; |
| 280 } | 291 } |
| 281 | 292 |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 489 DCHECK(ui_task_runner_->BelongsToCurrentThread()); | 500 DCHECK(ui_task_runner_->BelongsToCurrentThread()); |
| 490 DCHECK(HasData()); | 501 DCHECK(HasData()); |
| 491 if (!NoAccessUnitsRemainingInChunk(true)) | 502 if (!NoAccessUnitsRemainingInChunk(true)) |
| 492 return; | 503 return; |
| 493 | 504 |
| 494 // Requests new data if the the last access unit of the next chunk is not EOS. | 505 // Requests new data if the the last access unit of the next chunk is not EOS. |
| 495 current_demuxer_data_index_ = inactive_demuxer_data_index(); | 506 current_demuxer_data_index_ = inactive_demuxer_data_index(); |
| 496 const AccessUnit last_access_unit = | 507 const AccessUnit last_access_unit = |
| 497 received_data_[current_demuxer_data_index_].access_units.back(); | 508 received_data_[current_demuxer_data_index_].access_units.back(); |
| 498 if (!last_access_unit.end_of_stream && | 509 if (!last_access_unit.end_of_stream && |
| 499 last_access_unit.status != DemuxerStream::kConfigChanged && | 510 last_access_unit.status != DemuxerStream::kConfigChanged && |
|
wolenetz
2014/05/02 22:25:30
If it is kConfigChanged, and ClearData() never occ
qinmin
2014/05/05 20:52:19
if it is kConfigChanged, MDJ will get recreated an
wolenetz
2014/05/05 22:06:55
sgtm thanks
| |
| 500 last_access_unit.status != DemuxerStream::kAborted) { | 511 last_access_unit.status != DemuxerStream::kAborted) { |
| 501 RequestData(base::Closure()); | 512 RequestData(base::Closure()); |
| 502 } | 513 } |
| 503 } | 514 } |
| 504 | 515 |
| 505 void MediaDecoderJob::InitializeReceivedData() { | 516 void MediaDecoderJob::InitializeReceivedData() { |
| 506 for (size_t i = 0; i < 2; ++i) { | 517 for (size_t i = 0; i < 2; ++i) { |
| 507 received_data_[i] = DemuxerData(); | 518 received_data_[i] = DemuxerData(); |
| 508 access_unit_index_[i] = 0; | 519 access_unit_index_[i] = 0; |
| 509 } | 520 } |
| 510 } | 521 } |
| 511 | 522 |
| 512 } // namespace media | 523 } // namespace media |
| OLD | NEW |