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 | |
60 bool MediaCodecBridge::FillInputBuffer(int index, | 45 bool MediaCodecBridge::FillInputBuffer(int index, |
61 const uint8_t* data, | 46 const uint8_t* data, |
62 size_t size) { | 47 size_t size) { |
63 uint8_t* dst = nullptr; | 48 uint8_t* dst = nullptr; |
64 size_t capacity = 0; | 49 size_t capacity = 0; |
65 if (GetInputBuffer(index, &dst, &capacity) != MEDIA_CODEC_OK) { | 50 if (GetInputBuffer(index, &dst, &capacity) != MEDIA_CODEC_OK) { |
66 LOG(ERROR) << "GetInputBuffer failed"; | 51 LOG(ERROR) << "GetInputBuffer failed"; |
67 return false; | 52 return false; |
68 } | 53 } |
69 CHECK(dst); | 54 CHECK(dst); |
70 | 55 |
71 if (size > capacity) { | 56 if (size > capacity) { |
72 LOG(ERROR) << "Input buffer size " << size | 57 LOG(ERROR) << "Input buffer size " << size |
73 << " exceeds MediaCodec input buffer capacity: " << capacity; | 58 << " exceeds MediaCodec input buffer capacity: " << capacity; |
74 return false; | 59 return false; |
75 } | 60 } |
76 | 61 |
77 memcpy(dst, data, size); | 62 memcpy(dst, data, size); |
78 return true; | 63 return true; |
79 } | 64 } |
80 | 65 |
81 } // namespace media | 66 } // namespace media |
OLD | NEW |