| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 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 |
| (...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 jni, *j_frame_class_, "<init>", | 735 jni, *j_frame_class_, "<init>", |
| 736 "(IIII[FJ)V")), | 736 "(IIII[FJ)V")), |
| 737 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { | 737 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { |
| 738 CHECK_EXCEPTION(jni); | 738 CHECK_EXCEPTION(jni); |
| 739 } | 739 } |
| 740 | 740 |
| 741 virtual ~JavaVideoRendererWrapper() {} | 741 virtual ~JavaVideoRendererWrapper() {} |
| 742 | 742 |
| 743 void OnFrame(const cricket::VideoFrame& video_frame) override { | 743 void OnFrame(const cricket::VideoFrame& video_frame) override { |
| 744 ScopedLocalRefFrame local_ref_frame(jni()); | 744 ScopedLocalRefFrame local_ref_frame(jni()); |
| 745 jobject j_frame = (video_frame.GetNativeHandle() != nullptr) | 745 jobject j_frame = |
| 746 ? CricketToJavaTextureFrame(&video_frame) | 746 (video_frame.video_frame_buffer()->native_handle() != nullptr) |
| 747 : CricketToJavaI420Frame(&video_frame); | 747 ? CricketToJavaTextureFrame(&video_frame) |
| 748 : CricketToJavaI420Frame(&video_frame); |
| 748 // |j_callbacks_| is responsible for releasing |j_frame| with | 749 // |j_callbacks_| is responsible for releasing |j_frame| with |
| 749 // VideoRenderer.renderFrameDone(). | 750 // VideoRenderer.renderFrameDone(). |
| 750 jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame); | 751 jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame); |
| 751 CHECK_EXCEPTION(jni()); | 752 CHECK_EXCEPTION(jni()); |
| 752 } | 753 } |
| 753 | 754 |
| 754 private: | 755 private: |
| 755 // Make a shallow copy of |frame| to be used with Java. The callee has | 756 // Make a shallow copy of |frame| to be used with Java. The callee has |
| 756 // ownership of the frame, and the frame should be released with | 757 // ownership of the frame, and the frame should be released with |
| 757 // VideoRenderer.releaseNativeFrame(). | 758 // VideoRenderer.releaseNativeFrame(). |
| (...skipping 27 matching lines...) Expand all Loading... |
| 785 jni()->SetObjectArrayElement(planes, 2, v_buffer); | 786 jni()->SetObjectArrayElement(planes, 2, v_buffer); |
| 786 return jni()->NewObject( | 787 return jni()->NewObject( |
| 787 *j_frame_class_, j_i420_frame_ctor_id_, | 788 *j_frame_class_, j_i420_frame_ctor_id_, |
| 788 frame->width(), frame->height(), | 789 frame->width(), frame->height(), |
| 789 static_cast<int>(frame->rotation()), | 790 static_cast<int>(frame->rotation()), |
| 790 strides, planes, javaShallowCopy(frame)); | 791 strides, planes, javaShallowCopy(frame)); |
| 791 } | 792 } |
| 792 | 793 |
| 793 // Return a VideoRenderer.I420Frame referring texture object in |frame|. | 794 // Return a VideoRenderer.I420Frame referring texture object in |frame|. |
| 794 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { | 795 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { |
| 795 NativeHandleImpl* handle = | 796 NativeHandleImpl* handle = reinterpret_cast<NativeHandleImpl*>( |
| 796 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); | 797 frame->video_frame_buffer()->native_handle()); |
| 797 jfloatArray sampling_matrix = jni()->NewFloatArray(16); | 798 jfloatArray sampling_matrix = jni()->NewFloatArray(16); |
| 798 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); | 799 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); |
| 799 return jni()->NewObject( | 800 return jni()->NewObject( |
| 800 *j_frame_class_, j_texture_frame_ctor_id_, | 801 *j_frame_class_, j_texture_frame_ctor_id_, |
| 801 frame->width(), frame->height(), | 802 frame->width(), frame->height(), |
| 802 static_cast<int>(frame->rotation()), | 803 static_cast<int>(frame->rotation()), |
| 803 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); | 804 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); |
| 804 } | 805 } |
| 805 | 806 |
| 806 JNIEnv* jni() { | 807 JNIEnv* jni() { |
| (...skipping 1440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 return JavaStringFromStdString( | 2248 return JavaStringFromStdString( |
| 2248 jni, | 2249 jni, |
| 2249 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2250 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
| 2250 } | 2251 } |
| 2251 | 2252 |
| 2252 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2253 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
| 2253 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2254 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
| 2254 } | 2255 } |
| 2255 | 2256 |
| 2256 } // namespace webrtc_jni | 2257 } // namespace webrtc_jni |
| OLD | NEW |