| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/sdk_media_codec_bridge.h" | 5 #include "media/base/android/sdk_media_codec_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 size_t offset, | 572 size_t offset, |
| 573 bool postpone, | 573 bool postpone, |
| 574 int64_t* playback_pos) { | 574 int64_t* playback_pos) { |
| 575 DCHECK_LE(0, index); | 575 DCHECK_LE(0, index); |
| 576 int numBytes = base::checked_cast<int>(size); | 576 int numBytes = base::checked_cast<int>(size); |
| 577 | 577 |
| 578 const uint8_t* buffer = nullptr; | 578 const uint8_t* buffer = nullptr; |
| 579 size_t capacity = 0; | 579 size_t capacity = 0; |
| 580 MediaCodecStatus status = | 580 MediaCodecStatus status = |
| 581 GetOutputBufferAddress(index, offset, &buffer, &capacity); | 581 GetOutputBufferAddress(index, offset, &buffer, &capacity); |
| 582 if (status == MEDIA_CODEC_ERROR) | 582 if (status != MEDIA_CODEC_OK) { |
| 583 DLOG(ERROR) << __FUNCTION__ |
| 584 << ": GetOutputBufferAddress() failed for index:" << index; |
| 583 return status; | 585 return status; |
| 586 } |
| 584 | 587 |
| 585 numBytes = std::min(base::checked_cast<int>(capacity), numBytes); | 588 numBytes = std::min(base::checked_cast<int>(capacity), numBytes); |
| 586 CHECK_GE(numBytes, 0); | 589 CHECK_GE(numBytes, 0); |
| 587 | 590 |
| 588 JNIEnv* env = AttachCurrentThread(); | 591 JNIEnv* env = AttachCurrentThread(); |
| 589 ScopedJavaLocalRef<jbyteArray> byte_array = | 592 ScopedJavaLocalRef<jbyteArray> byte_array = |
| 590 base::android::ToJavaByteArray(env, buffer, numBytes); | 593 base::android::ToJavaByteArray(env, buffer, numBytes); |
| 591 *playback_pos = Java_MediaCodecBridge_playOutputBuffer( | 594 *playback_pos = Java_MediaCodecBridge_playOutputBuffer( |
| 592 env, media_codec(), byte_array.obj(), postpone); | 595 env, media_codec(), byte_array.obj(), postpone); |
| 593 return status; | 596 return status; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 695 if (adaptive_playback_supported_for_testing_ == 0) | 698 if (adaptive_playback_supported_for_testing_ == 0) |
| 696 return false; | 699 return false; |
| 697 else if (adaptive_playback_supported_for_testing_ > 0) | 700 else if (adaptive_playback_supported_for_testing_ > 0) |
| 698 return true; | 701 return true; |
| 699 JNIEnv* env = AttachCurrentThread(); | 702 JNIEnv* env = AttachCurrentThread(); |
| 700 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), | 703 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), |
| 701 width, height); | 704 width, height); |
| 702 } | 705 } |
| 703 | 706 |
| 704 } // namespace media | 707 } // namespace media |
| OLD | NEW |