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 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
11 #include "base/android/jni_array.h" | 11 #include "base/android/jni_array.h" |
12 #include "base/android/jni_string.h" | 12 #include "base/android/jni_string.h" |
13 #include "base/basictypes.h" | |
14 #include "base/logging.h" | 13 #include "base/logging.h" |
15 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
16 #include "media/base/decrypt_config.h" | 15 #include "media/base/decrypt_config.h" |
17 | 16 |
18 using base::android::AttachCurrentThread; | 17 using base::android::AttachCurrentThread; |
19 using base::android::ConvertJavaStringToUTF8; | 18 using base::android::ConvertJavaStringToUTF8; |
20 using base::android::ConvertUTF8ToJavaString; | 19 using base::android::ConvertUTF8ToJavaString; |
21 using base::android::JavaIntArrayToIntVector; | 20 using base::android::JavaIntArrayToIntVector; |
22 using base::android::ScopedJavaLocalRef; | 21 using base::android::ScopedJavaLocalRef; |
23 | 22 |
24 namespace media { | 23 namespace media { |
25 | 24 |
26 MediaCodecBridge::MediaCodecBridge() {} | 25 MediaCodecBridge::MediaCodecBridge() {} |
27 | 26 |
28 MediaCodecBridge::~MediaCodecBridge() {} | 27 MediaCodecBridge::~MediaCodecBridge() {} |
29 | 28 |
30 MediaCodecStatus MediaCodecBridge::QueueSecureInputBuffer( | 29 MediaCodecStatus MediaCodecBridge::QueueSecureInputBuffer( |
31 int index, | 30 int index, |
32 const uint8* data, | 31 const uint8_t* data, |
33 size_t data_size, | 32 size_t data_size, |
34 const std::string& key_id, | 33 const std::string& key_id, |
35 const std::string& iv, | 34 const std::string& iv, |
36 const std::vector<SubsampleEntry>& subsamples, | 35 const std::vector<SubsampleEntry>& subsamples, |
37 const base::TimeDelta& presentation_time) { | 36 const base::TimeDelta& presentation_time) { |
38 const std::vector<char> key_vec(key_id.begin(), key_id.end()); | 37 const std::vector<char> key_vec(key_id.begin(), key_id.end()); |
39 const std::vector<char> iv_vec(iv.begin(), iv.end()); | 38 const std::vector<char> iv_vec(iv.begin(), iv.end()); |
40 return QueueSecureInputBuffer(index, data, data_size, key_vec, iv_vec, | 39 return QueueSecureInputBuffer(index, data, data_size, key_vec, iv_vec, |
41 subsamples.empty() ? nullptr : &subsamples[0], | 40 subsamples.empty() ? nullptr : &subsamples[0], |
42 subsamples.size(), presentation_time); | 41 subsamples.size(), presentation_time); |
43 } | 42 } |
44 | 43 |
45 int MediaCodecBridge::GetOutputBuffersCount() { | 44 int MediaCodecBridge::GetOutputBuffersCount() { |
46 return 0; | 45 return 0; |
47 } | 46 } |
48 | 47 |
49 size_t MediaCodecBridge::GetOutputBuffersCapacity() { | 48 size_t MediaCodecBridge::GetOutputBuffersCapacity() { |
50 return 0; | 49 return 0; |
51 } | 50 } |
52 | 51 |
53 bool MediaCodecBridge::FillInputBuffer(int index, | 52 bool MediaCodecBridge::FillInputBuffer(int index, |
54 const uint8* data, | 53 const uint8_t* data, |
55 size_t size) { | 54 size_t size) { |
56 uint8* dst = nullptr; | 55 uint8_t* dst = nullptr; |
57 size_t capacity = 0; | 56 size_t capacity = 0; |
58 GetInputBuffer(index, &dst, &capacity); | 57 GetInputBuffer(index, &dst, &capacity); |
59 CHECK(dst); | 58 CHECK(dst); |
60 | 59 |
61 if (size > capacity) { | 60 if (size > capacity) { |
62 LOG(ERROR) << "Input buffer size " << size | 61 LOG(ERROR) << "Input buffer size " << size |
63 << " exceeds MediaCodec input buffer capacity: " << capacity; | 62 << " exceeds MediaCodec input buffer capacity: " << capacity; |
64 return false; | 63 return false; |
65 } | 64 } |
66 | 65 |
67 memcpy(dst, data, size); | 66 memcpy(dst, data, size); |
68 return true; | 67 return true; |
69 } | 68 } |
70 | 69 |
71 } // namespace media | 70 } // namespace media |
OLD | NEW |