| 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/media_codec_bridge.h" | 5 #include "media/base/android/media_codec_bridge.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <limits> | 8 #include <limits> |
| 9 | 9 |
| 10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 const std::string& iv, | 35 const std::string& iv, |
| 36 const std::vector<SubsampleEntry>& subsamples, | 36 const std::vector<SubsampleEntry>& subsamples, |
| 37 const base::TimeDelta& presentation_time) { | 37 const base::TimeDelta& presentation_time) { |
| 38 const std::vector<char> key_vec(key_id.begin(), key_id.end()); | 38 const std::vector<char> key_vec(key_id.begin(), key_id.end()); |
| 39 const std::vector<char> iv_vec(iv.begin(), iv.end()); | 39 const std::vector<char> iv_vec(iv.begin(), iv.end()); |
| 40 return QueueSecureInputBuffer(index, data, data_size, key_vec, iv_vec, | 40 return QueueSecureInputBuffer(index, data, data_size, key_vec, iv_vec, |
| 41 subsamples.empty() ? nullptr : &subsamples[0], | 41 subsamples.empty() ? nullptr : &subsamples[0], |
| 42 subsamples.size(), presentation_time); | 42 subsamples.size(), presentation_time); |
| 43 } | 43 } |
| 44 | 44 |
| 45 MediaCodecStatus MediaCodecBridge::CopyFromOutputBuffer(int index, |
| 46 size_t offset, |
| 47 void* dst, |
| 48 size_t num) { |
| 49 const uint8_t* src_data = nullptr; |
| 50 size_t src_capacity = 0; |
| 51 MediaCodecStatus status = |
| 52 GetOutputBufferAddress(index, offset, &src_data, &src_capacity); |
| 53 if (status == MEDIA_CODEC_OK) { |
| 54 CHECK_GE(src_capacity, num); |
| 55 memcpy(dst, src_data, num); |
| 56 } |
| 57 return status; |
| 58 } |
| 59 |
| 45 bool MediaCodecBridge::FillInputBuffer(int index, | 60 bool MediaCodecBridge::FillInputBuffer(int index, |
| 46 const uint8_t* data, | 61 const uint8_t* data, |
| 47 size_t size) { | 62 size_t size) { |
| 48 uint8_t* dst = nullptr; | 63 uint8_t* dst = nullptr; |
| 49 size_t capacity = 0; | 64 size_t capacity = 0; |
| 50 if (GetInputBuffer(index, &dst, &capacity) != MEDIA_CODEC_OK) { | 65 if (GetInputBuffer(index, &dst, &capacity) != MEDIA_CODEC_OK) { |
| 51 LOG(ERROR) << "GetInputBuffer failed"; | 66 LOG(ERROR) << "GetInputBuffer failed"; |
| 52 return false; | 67 return false; |
| 53 } | 68 } |
| 54 CHECK(dst); | 69 CHECK(dst); |
| 55 | 70 |
| 56 if (size > capacity) { | 71 if (size > capacity) { |
| 57 LOG(ERROR) << "Input buffer size " << size | 72 LOG(ERROR) << "Input buffer size " << size |
| 58 << " exceeds MediaCodec input buffer capacity: " << capacity; | 73 << " exceeds MediaCodec input buffer capacity: " << capacity; |
| 59 return false; | 74 return false; |
| 60 } | 75 } |
| 61 | 76 |
| 62 memcpy(dst, data, size); | 77 memcpy(dst, data, size); |
| 63 return true; | 78 return true; |
| 64 } | 79 } |
| 65 | 80 |
| 66 } // namespace media | 81 } // namespace media |
| OLD | NEW |