OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
11 #include "webrtc/sdk/android/src/jni/wrapped_native_i420_buffer.h" | 11 #include "webrtc/sdk/android/src/jni/wrapped_native_i420_buffer.h" |
12 | 12 |
13 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" | 13 #include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
14 #include "webrtc/sdk/android/src/jni/jni_helpers.h" | 14 #include "webrtc/sdk/android/src/jni/jni_helpers.h" |
15 | 15 |
16 namespace webrtc_jni { | 16 namespace webrtc { |
| 17 namespace jni { |
17 | 18 |
18 // TODO(magjed): Write a test for this function. | 19 // TODO(magjed): Write a test for this function. |
19 jobject WrapI420Buffer( | 20 jobject WrapI420Buffer( |
20 JNIEnv* jni, | 21 JNIEnv* jni, |
21 const rtc::scoped_refptr<webrtc::I420BufferInterface>& i420_buffer) { | 22 const rtc::scoped_refptr<I420BufferInterface>& i420_buffer) { |
22 jclass j_wrapped_native_i420_buffer_class = | 23 jclass j_wrapped_native_i420_buffer_class = |
23 FindClass(jni, "org/webrtc/WrappedNativeI420Buffer"); | 24 FindClass(jni, "org/webrtc/WrappedNativeI420Buffer"); |
24 jmethodID j_wrapped_native_i420_buffer_ctor_id = | 25 jmethodID j_wrapped_native_i420_buffer_ctor_id = |
25 GetMethodID(jni, j_wrapped_native_i420_buffer_class, "<init>", | 26 GetMethodID(jni, j_wrapped_native_i420_buffer_class, "<init>", |
26 "(IILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/" | 27 "(IILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/" |
27 "ByteBuffer;IJ)V"); | 28 "ByteBuffer;IJ)V"); |
28 | 29 |
29 jobject y_buffer = | 30 jobject y_buffer = |
30 jni->NewDirectByteBuffer(const_cast<uint8_t*>(i420_buffer->DataY()), | 31 jni->NewDirectByteBuffer(const_cast<uint8_t*>(i420_buffer->DataY()), |
31 i420_buffer->StrideY() * i420_buffer->height()); | 32 i420_buffer->StrideY() * i420_buffer->height()); |
32 jobject u_buffer = jni->NewDirectByteBuffer( | 33 jobject u_buffer = jni->NewDirectByteBuffer( |
33 const_cast<uint8_t*>(i420_buffer->DataU()), | 34 const_cast<uint8_t*>(i420_buffer->DataU()), |
34 i420_buffer->StrideU() * i420_buffer->ChromaHeight()); | 35 i420_buffer->StrideU() * i420_buffer->ChromaHeight()); |
35 jobject v_buffer = jni->NewDirectByteBuffer( | 36 jobject v_buffer = jni->NewDirectByteBuffer( |
36 const_cast<uint8_t*>(i420_buffer->DataV()), | 37 const_cast<uint8_t*>(i420_buffer->DataV()), |
37 i420_buffer->StrideV() * i420_buffer->ChromaHeight()); | 38 i420_buffer->StrideV() * i420_buffer->ChromaHeight()); |
38 | 39 |
39 jobject j_wrapped_native_i420_buffer = jni->NewObject( | 40 jobject j_wrapped_native_i420_buffer = jni->NewObject( |
40 j_wrapped_native_i420_buffer_class, j_wrapped_native_i420_buffer_ctor_id, | 41 j_wrapped_native_i420_buffer_class, j_wrapped_native_i420_buffer_ctor_id, |
41 i420_buffer->width(), i420_buffer->height(), y_buffer, | 42 i420_buffer->width(), i420_buffer->height(), y_buffer, |
42 i420_buffer->StrideY(), u_buffer, i420_buffer->StrideU(), v_buffer, | 43 i420_buffer->StrideY(), u_buffer, i420_buffer->StrideU(), v_buffer, |
43 i420_buffer->StrideV(), jlongFromPointer(i420_buffer.get())); | 44 i420_buffer->StrideV(), jlongFromPointer(i420_buffer.get())); |
44 CHECK_EXCEPTION(jni); | 45 CHECK_EXCEPTION(jni); |
45 | 46 |
46 return j_wrapped_native_i420_buffer; | 47 return j_wrapped_native_i420_buffer; |
47 } | 48 } |
48 | 49 |
49 } // namespace webrtc_jni | 50 } // namespace jni |
| 51 } // namespace webrtc |
OLD | NEW |