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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
10 #include "base/threading/thread_task_runner_handle.h" | 10 #include "base/threading/thread_task_runner_handle.h" |
11 #include "base/trace_event/trace_event.h" | 11 #include "base/trace_event/trace_event.h" |
12 #include "media/base/android/media_drm_bridge.h" | 12 #include "media/base/android/media_drm_bridge.h" |
13 #include "media/base/bind_to_current_loop.h" | 13 #include "media/base/bind_to_current_loop.h" |
| 14 #include "media/base/media_util.h" |
14 #include "media/base/timestamp_constants.h" | 15 #include "media/base/timestamp_constants.h" |
15 | 16 |
16 namespace media { | 17 namespace media { |
17 | 18 |
18 // Timeout value for media codec operations. Because the first | 19 // Timeout value for media codec operations. Because the first |
19 // DequeInputBuffer() can take about 150 milliseconds, use 250 milliseconds | 20 // DequeInputBuffer() can take about 150 milliseconds, use 250 milliseconds |
20 // here. See http://b/9357571. | 21 // here. See http://b/9357571. |
21 static const int kMediaCodecTimeoutInMilliseconds = 250; | 22 static const int kMediaCodecTimeoutInMilliseconds = 250; |
22 | 23 |
23 MediaDecoderJob::MediaDecoderJob( | 24 MediaDecoderJob::MediaDecoderJob( |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 278 |
278 if (unit.key_id.empty() || unit.iv.empty()) { | 279 if (unit.key_id.empty() || unit.iv.empty()) { |
279 DCHECK(unit.iv.empty() || !unit.key_id.empty()); | 280 DCHECK(unit.iv.empty() || !unit.key_id.empty()); |
280 return media_codec_bridge_->QueueInputBuffer( | 281 return media_codec_bridge_->QueueInputBuffer( |
281 input_buf_index, &unit.data[0], unit.data.size(), unit.timestamp); | 282 input_buf_index, &unit.data[0], unit.data.size(), unit.timestamp); |
282 } | 283 } |
283 | 284 |
284 MediaCodecStatus status = media_codec_bridge_->QueueSecureInputBuffer( | 285 MediaCodecStatus status = media_codec_bridge_->QueueSecureInputBuffer( |
285 input_buf_index, &unit.data[0], unit.data.size(), unit.key_id, unit.iv, | 286 input_buf_index, &unit.data[0], unit.data.size(), unit.key_id, unit.iv, |
286 unit.subsamples.empty() ? NULL : &unit.subsamples[0], | 287 unit.subsamples.empty() ? NULL : &unit.subsamples[0], |
287 unit.subsamples.size(), unit.timestamp); | 288 unit.subsamples.size(), AesCtrEncryptionScheme(), unit.timestamp); |
288 | 289 |
289 // In case of MEDIA_CODEC_NO_KEY, we must reuse the |input_buf_index_|. | 290 // In case of MEDIA_CODEC_NO_KEY, we must reuse the |input_buf_index_|. |
290 // Otherwise MediaDrm will report errors. | 291 // Otherwise MediaDrm will report errors. |
291 if (status == MEDIA_CODEC_NO_KEY) | 292 if (status == MEDIA_CODEC_NO_KEY) |
292 input_buf_index_ = input_buf_index; | 293 input_buf_index_ = input_buf_index; |
293 | 294 |
294 return status; | 295 return status; |
295 } | 296 } |
296 | 297 |
297 bool MediaDecoderJob::HasData() const { | 298 bool MediaDecoderJob::HasData() const { |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 | 684 |
684 void MediaDecoderJob::ReleaseMediaCodecBridge() { | 685 void MediaDecoderJob::ReleaseMediaCodecBridge() { |
685 if (!media_codec_bridge_) | 686 if (!media_codec_bridge_) |
686 return; | 687 return; |
687 | 688 |
688 media_codec_bridge_.reset(); | 689 media_codec_bridge_.reset(); |
689 input_buf_index_ = -1; | 690 input_buf_index_ = -1; |
690 } | 691 } |
691 | 692 |
692 } // namespace media | 693 } // namespace media |
OLD | NEW |