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_jni { |
17 | 17 |
18 // TODO(magjed): Write a test for this function. | 18 // TODO(magjed): Write a test for this function. |
19 jobject WrapI420Buffer( | 19 jobject WrapI420Buffer( |
| 20 JNIEnv* jni, |
20 const rtc::scoped_refptr<webrtc::I420BufferInterface>& i420_buffer) { | 21 const rtc::scoped_refptr<webrtc::I420BufferInterface>& i420_buffer) { |
21 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | |
22 ScopedLocalRefFrame local_ref_frame(jni); | |
23 | |
24 jclass j_wrapped_native_i420_buffer_class = | 22 jclass j_wrapped_native_i420_buffer_class = |
25 FindClass(jni, "org/webrtc/WrappedNativeI420Buffer"); | 23 FindClass(jni, "org/webrtc/WrappedNativeI420Buffer"); |
26 jmethodID j_wrapped_native_i420_buffer_ctor_id = | 24 jmethodID j_wrapped_native_i420_buffer_ctor_id = |
27 GetMethodID(jni, j_wrapped_native_i420_buffer_class, "<init>", | 25 GetMethodID(jni, j_wrapped_native_i420_buffer_class, "<init>", |
28 "(IILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/" | 26 "(IILjava/nio/ByteBuffer;ILjava/nio/ByteBuffer;ILjava/nio/" |
29 "ByteBuffer;IJ)V"); | 27 "ByteBuffer;IJ)V"); |
30 | 28 |
31 jobject y_buffer = | 29 jobject y_buffer = |
32 jni->NewDirectByteBuffer(const_cast<uint8_t*>(i420_buffer->DataY()), | 30 jni->NewDirectByteBuffer(const_cast<uint8_t*>(i420_buffer->DataY()), |
33 i420_buffer->StrideY() * i420_buffer->height()); | 31 i420_buffer->StrideY() * i420_buffer->height()); |
(...skipping 18 matching lines...) Expand all Loading... |
52 (JNIEnv* jni, jclass, jlong j_buffer_pointer) { | 50 (JNIEnv* jni, jclass, jlong j_buffer_pointer) { |
53 reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->AddRef(); | 51 reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->AddRef(); |
54 } | 52 } |
55 | 53 |
56 JOW(void, WrappedNativeI420Buffer_nativeRelease) | 54 JOW(void, WrappedNativeI420Buffer_nativeRelease) |
57 (JNIEnv* jni, jclass, jlong j_buffer_pointer) { | 55 (JNIEnv* jni, jclass, jlong j_buffer_pointer) { |
58 reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->Release(); | 56 reinterpret_cast<webrtc::VideoFrameBuffer*>(j_buffer_pointer)->Release(); |
59 } | 57 } |
60 | 58 |
61 } // namespace webrtc_jni | 59 } // namespace webrtc_jni |
OLD | NEW |