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