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 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); | 764 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); |
765 strides_array[0] = frame->video_frame_buffer()->StrideY(); | 765 strides_array[0] = frame->video_frame_buffer()->StrideY(); |
766 strides_array[1] = frame->video_frame_buffer()->StrideU(); | 766 strides_array[1] = frame->video_frame_buffer()->StrideU(); |
767 strides_array[2] = frame->video_frame_buffer()->StrideV(); | 767 strides_array[2] = frame->video_frame_buffer()->StrideV(); |
768 jni()->ReleaseIntArrayElements(strides, strides_array, 0); | 768 jni()->ReleaseIntArrayElements(strides, strides_array, 0); |
769 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); | 769 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); |
770 jobject y_buffer = jni()->NewDirectByteBuffer( | 770 jobject y_buffer = jni()->NewDirectByteBuffer( |
771 const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()), | 771 const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()), |
772 frame->video_frame_buffer()->StrideY() * | 772 frame->video_frame_buffer()->StrideY() * |
773 frame->video_frame_buffer()->height()); | 773 frame->video_frame_buffer()->height()); |
774 size_t chroma_size = | 774 size_t chroma_height = (frame->height() + 1) / 2; |
775 ((frame->width() + 1) / 2) * ((frame->height() + 1) / 2); | |
776 jobject u_buffer = jni()->NewDirectByteBuffer( | 775 jobject u_buffer = jni()->NewDirectByteBuffer( |
777 const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()), | 776 const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()), |
778 chroma_size); | 777 frame->video_frame_buffer()->StrideU() * chroma_height); |
779 jobject v_buffer = jni()->NewDirectByteBuffer( | 778 jobject v_buffer = jni()->NewDirectByteBuffer( |
780 const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()), | 779 const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()), |
781 chroma_size); | 780 frame->video_frame_buffer()->StrideV() * chroma_height); |
| 781 |
782 jni()->SetObjectArrayElement(planes, 0, y_buffer); | 782 jni()->SetObjectArrayElement(planes, 0, y_buffer); |
783 jni()->SetObjectArrayElement(planes, 1, u_buffer); | 783 jni()->SetObjectArrayElement(planes, 1, u_buffer); |
784 jni()->SetObjectArrayElement(planes, 2, v_buffer); | 784 jni()->SetObjectArrayElement(planes, 2, v_buffer); |
785 return jni()->NewObject( | 785 return jni()->NewObject( |
786 *j_frame_class_, j_i420_frame_ctor_id_, | 786 *j_frame_class_, j_i420_frame_ctor_id_, |
787 frame->width(), frame->height(), | 787 frame->width(), frame->height(), |
788 static_cast<int>(frame->rotation()), | 788 static_cast<int>(frame->rotation()), |
789 strides, planes, javaShallowCopy(frame)); | 789 strides, planes, javaShallowCopy(frame)); |
790 } | 790 } |
791 | 791 |
(...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1881 JOW(void, VideoRenderer_nativeCopyPlane)( | 1881 JOW(void, VideoRenderer_nativeCopyPlane)( |
1882 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, | 1882 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, |
1883 jint src_stride, jobject j_dst_buffer, jint dst_stride) { | 1883 jint src_stride, jobject j_dst_buffer, jint dst_stride) { |
1884 size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer); | 1884 size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer); |
1885 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer); | 1885 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer); |
1886 RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride; | 1886 RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride; |
1887 RTC_CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride; | 1887 RTC_CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride; |
1888 RTC_CHECK(src_size >= src_stride * height) | 1888 RTC_CHECK(src_size >= src_stride * height) |
1889 << "Insufficient source buffer capacity " << src_size; | 1889 << "Insufficient source buffer capacity " << src_size; |
1890 RTC_CHECK(dst_size >= dst_stride * height) | 1890 RTC_CHECK(dst_size >= dst_stride * height) |
1891 << "Isufficient destination buffer capacity " << dst_size; | 1891 << "Insufficient destination buffer capacity " << dst_size; |
1892 uint8_t *src = | 1892 uint8_t *src = |
1893 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer)); | 1893 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer)); |
1894 uint8_t *dst = | 1894 uint8_t *dst = |
1895 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_buffer)); | 1895 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_buffer)); |
1896 if (src_stride == dst_stride) { | 1896 if (src_stride == dst_stride) { |
1897 memcpy(dst, src, src_stride * height); | 1897 memcpy(dst, src, src_stride * height); |
1898 } else { | 1898 } else { |
1899 for (int i = 0; i < height; i++) { | 1899 for (int i = 0; i < height; i++) { |
1900 memcpy(dst, src, width); | 1900 memcpy(dst, src, width); |
1901 src += src_stride; | 1901 src += src_stride; |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2209 return JavaStringFromStdString( | 2209 return JavaStringFromStdString( |
2210 jni, | 2210 jni, |
2211 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2211 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2212 } | 2212 } |
2213 | 2213 |
2214 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2214 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2215 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2215 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2216 } | 2216 } |
2217 | 2217 |
2218 } // namespace webrtc_jni | 2218 } // namespace webrtc_jni |
OLD | NEW |