OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc. | 3 * Copyright 2013 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 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 : j_callbacks_(jni, j_callbacks), | 766 : j_callbacks_(jni, j_callbacks), |
767 j_render_frame_id_(GetMethodID( | 767 j_render_frame_id_(GetMethodID( |
768 jni, GetObjectClass(jni, j_callbacks), "renderFrame", | 768 jni, GetObjectClass(jni, j_callbacks), "renderFrame", |
769 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), | 769 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), |
770 j_frame_class_(jni, | 770 j_frame_class_(jni, |
771 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), | 771 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), |
772 j_i420_frame_ctor_id_(GetMethodID( | 772 j_i420_frame_ctor_id_(GetMethodID( |
773 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")), | 773 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")), |
774 j_texture_frame_ctor_id_(GetMethodID( | 774 j_texture_frame_ctor_id_(GetMethodID( |
775 jni, *j_frame_class_, "<init>", | 775 jni, *j_frame_class_, "<init>", |
776 "(IIILjava/lang/Object;IJ)V")), | 776 "(IIII[FJ)V")), |
777 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { | 777 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { |
778 CHECK_EXCEPTION(jni); | 778 CHECK_EXCEPTION(jni); |
779 } | 779 } |
780 | 780 |
781 virtual ~JavaVideoRendererWrapper() {} | 781 virtual ~JavaVideoRendererWrapper() {} |
782 | 782 |
783 void RenderFrame(const cricket::VideoFrame* video_frame) override { | 783 void RenderFrame(const cricket::VideoFrame* video_frame) override { |
784 ScopedLocalRefFrame local_ref_frame(jni()); | 784 ScopedLocalRefFrame local_ref_frame(jni()); |
785 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) | 785 jobject j_frame = (video_frame->GetNativeHandle() != nullptr) |
786 ? CricketToJavaTextureFrame(video_frame) | 786 ? CricketToJavaTextureFrame(video_frame) |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 *j_frame_class_, j_i420_frame_ctor_id_, | 822 *j_frame_class_, j_i420_frame_ctor_id_, |
823 frame->GetWidth(), frame->GetHeight(), | 823 frame->GetWidth(), frame->GetHeight(), |
824 static_cast<int>(frame->GetVideoRotation()), | 824 static_cast<int>(frame->GetVideoRotation()), |
825 strides, planes, javaShallowCopy(frame)); | 825 strides, planes, javaShallowCopy(frame)); |
826 } | 826 } |
827 | 827 |
828 // Return a VideoRenderer.I420Frame referring texture object in |frame|. | 828 // Return a VideoRenderer.I420Frame referring texture object in |frame|. |
829 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { | 829 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { |
830 NativeHandleImpl* handle = | 830 NativeHandleImpl* handle = |
831 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); | 831 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); |
832 jobject texture_object = reinterpret_cast<jobject>(handle->GetHandle()); | 832 jfloatArray sampling_matrix = jni()->NewFloatArray(16); |
833 int texture_id = handle->GetTextureId(); | 833 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); |
834 return jni()->NewObject( | 834 return jni()->NewObject( |
835 *j_frame_class_, j_texture_frame_ctor_id_, | 835 *j_frame_class_, j_texture_frame_ctor_id_, |
836 frame->GetWidth(), frame->GetHeight(), | 836 frame->GetWidth(), frame->GetHeight(), |
837 static_cast<int>(frame->GetVideoRotation()), | 837 static_cast<int>(frame->GetVideoRotation()), |
838 texture_object, texture_id, javaShallowCopy(frame)); | 838 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); |
839 } | 839 } |
840 | 840 |
841 JNIEnv* jni() { | 841 JNIEnv* jni() { |
842 return AttachCurrentThreadIfNeeded(); | 842 return AttachCurrentThreadIfNeeded(); |
843 } | 843 } |
844 | 844 |
845 ScopedGlobalRef<jobject> j_callbacks_; | 845 ScopedGlobalRef<jobject> j_callbacks_; |
846 jmethodID j_render_frame_id_; | 846 jmethodID j_render_frame_id_; |
847 ScopedGlobalRef<jclass> j_frame_class_; | 847 ScopedGlobalRef<jclass> j_frame_class_; |
848 jmethodID j_i420_frame_ctor_id_; | 848 jmethodID j_i420_frame_ctor_id_; |
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2046 return JavaStringFromStdString( | 2046 return JavaStringFromStdString( |
2047 jni, | 2047 jni, |
2048 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2048 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2049 } | 2049 } |
2050 | 2050 |
2051 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2051 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2052 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2052 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2053 } | 2053 } |
2054 | 2054 |
2055 } // namespace webrtc_jni | 2055 } // namespace webrtc_jni |
OLD | NEW |