OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2015 Google Inc. | 3 * Copyright 2015 Google Inc. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 13 matching lines...) Expand all Loading... |
24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 */ | 26 */ |
27 | 27 |
28 #include "talk/app/webrtc/java/jni/native_handle_impl.h" | 28 #include "talk/app/webrtc/java/jni/native_handle_impl.h" |
29 | 29 |
30 #include "webrtc/base/checks.h" | 30 #include "webrtc/base/checks.h" |
31 | 31 |
32 namespace webrtc_jni { | 32 namespace webrtc_jni { |
33 | 33 |
34 NativeHandleImpl::NativeHandleImpl() : texture_object_(NULL), texture_id_(-1) {} | 34 NativeHandleImpl::NativeHandleImpl(JNIEnv* jni, |
35 | 35 jint j_oes_texture_id, |
36 void* NativeHandleImpl::GetHandle() { | 36 jfloatArray j_transform_matrix) |
37 return texture_object_; | 37 : oes_texture_id(j_oes_texture_id) { |
38 } | 38 RTC_CHECK_EQ(16, jni->GetArrayLength(j_transform_matrix)); |
39 | 39 jfloat* transform_matrix_ptr = |
40 int NativeHandleImpl::GetTextureId() { | 40 jni->GetFloatArrayElements(j_transform_matrix, nullptr); |
41 return texture_id_; | 41 for (int i = 0; i < 16; ++i) { |
42 } | 42 sampling_matrix[i] = transform_matrix_ptr[i]; |
43 | 43 } |
44 void NativeHandleImpl::SetTextureObject(void* texture_object, int texture_id) { | 44 jni->ReleaseFloatArrayElements(j_transform_matrix, transform_matrix_ptr, 0); |
45 texture_object_ = reinterpret_cast<jobject>(texture_object); | |
46 texture_id_ = texture_id; | |
47 } | |
48 | |
49 JniNativeHandleBuffer::JniNativeHandleBuffer(void* native_handle, | |
50 int width, | |
51 int height) | |
52 : NativeHandleBuffer(native_handle, width, height) {} | |
53 | |
54 rtc::scoped_refptr<webrtc::VideoFrameBuffer> | |
55 JniNativeHandleBuffer::NativeToI420Buffer() { | |
56 // TODO(pbos): Implement before using this in the encoder pipeline (or | |
57 // remove the RTC_CHECK() in VideoCapture). | |
58 RTC_NOTREACHED(); | |
59 return nullptr; | |
60 } | 45 } |
61 | 46 |
62 } // namespace webrtc_jni | 47 } // namespace webrtc_jni |
OLD | NEW |