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 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
764 jintArray strides = jni()->NewIntArray(3); | 764 jintArray strides = jni()->NewIntArray(3); |
765 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); | 765 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); |
766 strides_array[0] = frame->GetYPitch(); | 766 strides_array[0] = frame->GetYPitch(); |
767 strides_array[1] = frame->GetUPitch(); | 767 strides_array[1] = frame->GetUPitch(); |
768 strides_array[2] = frame->GetVPitch(); | 768 strides_array[2] = frame->GetVPitch(); |
769 jni()->ReleaseIntArrayElements(strides, strides_array, 0); | 769 jni()->ReleaseIntArrayElements(strides, strides_array, 0); |
770 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); | 770 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); |
771 jobject y_buffer = | 771 jobject y_buffer = |
772 jni()->NewDirectByteBuffer(const_cast<uint8_t*>(frame->GetYPlane()), | 772 jni()->NewDirectByteBuffer(const_cast<uint8_t*>(frame->GetYPlane()), |
773 frame->GetYPitch() * frame->GetHeight()); | 773 frame->GetYPitch() * frame->GetHeight()); |
| 774 size_t chroma_size = |
| 775 ((frame->width() + 1) / 2) * ((frame->height() + 1) / 2); |
774 jobject u_buffer = jni()->NewDirectByteBuffer( | 776 jobject u_buffer = jni()->NewDirectByteBuffer( |
775 const_cast<uint8_t*>(frame->GetUPlane()), frame->GetChromaSize()); | 777 const_cast<uint8_t*>(frame->GetUPlane()), chroma_size); |
776 jobject v_buffer = jni()->NewDirectByteBuffer( | 778 jobject v_buffer = jni()->NewDirectByteBuffer( |
777 const_cast<uint8_t*>(frame->GetVPlane()), frame->GetChromaSize()); | 779 const_cast<uint8_t*>(frame->GetVPlane()), chroma_size); |
778 jni()->SetObjectArrayElement(planes, 0, y_buffer); | 780 jni()->SetObjectArrayElement(planes, 0, y_buffer); |
779 jni()->SetObjectArrayElement(planes, 1, u_buffer); | 781 jni()->SetObjectArrayElement(planes, 1, u_buffer); |
780 jni()->SetObjectArrayElement(planes, 2, v_buffer); | 782 jni()->SetObjectArrayElement(planes, 2, v_buffer); |
781 return jni()->NewObject( | 783 return jni()->NewObject( |
782 *j_frame_class_, j_i420_frame_ctor_id_, | 784 *j_frame_class_, j_i420_frame_ctor_id_, |
783 frame->GetWidth(), frame->GetHeight(), | 785 frame->width(), frame->height(), |
784 static_cast<int>(frame->GetVideoRotation()), | 786 static_cast<int>(frame->GetVideoRotation()), |
785 strides, planes, javaShallowCopy(frame)); | 787 strides, planes, javaShallowCopy(frame)); |
786 } | 788 } |
787 | 789 |
788 // Return a VideoRenderer.I420Frame referring texture object in |frame|. | 790 // Return a VideoRenderer.I420Frame referring texture object in |frame|. |
789 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { | 791 jobject CricketToJavaTextureFrame(const cricket::VideoFrame* frame) { |
790 NativeHandleImpl* handle = | 792 NativeHandleImpl* handle = |
791 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); | 793 reinterpret_cast<NativeHandleImpl*>(frame->GetNativeHandle()); |
792 jfloatArray sampling_matrix = jni()->NewFloatArray(16); | 794 jfloatArray sampling_matrix = jni()->NewFloatArray(16); |
793 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); | 795 jni()->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); |
794 return jni()->NewObject( | 796 return jni()->NewObject( |
795 *j_frame_class_, j_texture_frame_ctor_id_, | 797 *j_frame_class_, j_texture_frame_ctor_id_, |
796 frame->GetWidth(), frame->GetHeight(), | 798 frame->width(), frame->height(), |
797 static_cast<int>(frame->GetVideoRotation()), | 799 static_cast<int>(frame->GetVideoRotation()), |
798 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); | 800 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); |
799 } | 801 } |
800 | 802 |
801 JNIEnv* jni() { | 803 JNIEnv* jni() { |
802 return AttachCurrentThreadIfNeeded(); | 804 return AttachCurrentThreadIfNeeded(); |
803 } | 805 } |
804 | 806 |
805 ScopedGlobalRef<jobject> j_callbacks_; | 807 ScopedGlobalRef<jobject> j_callbacks_; |
806 jmethodID j_render_frame_id_; | 808 jmethodID j_render_frame_id_; |
(...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2139 return JavaStringFromStdString( | 2141 return JavaStringFromStdString( |
2140 jni, | 2142 jni, |
2141 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2143 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2142 } | 2144 } |
2143 | 2145 |
2144 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2146 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2145 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2147 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2146 } | 2148 } |
2147 | 2149 |
2148 } // namespace webrtc_jni | 2150 } // namespace webrtc_jni |
OLD | NEW |