Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: webrtc/api/android/jni/peerconnection_jni.cc

Issue 2405463002: Testing of FileVideoCapturer (Closed)
Patch Set: Cleaned up and changed which pixels are compared in FileVideoCaputurerTest Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 25 matching lines...) Expand all
36 // impossible to tell which JNI call broke). 36 // impossible to tell which JNI call broke).
37 37
38 #include <jni.h> 38 #include <jni.h>
39 #undef JNIEXPORT 39 #undef JNIEXPORT
40 #define JNIEXPORT __attribute__((visibility("default"))) 40 #define JNIEXPORT __attribute__((visibility("default")))
41 41
42 #include <limits> 42 #include <limits>
43 #include <memory> 43 #include <memory>
44 #include <utility> 44 #include <utility>
45 45
46 #include "third_party/libyuv/include/libyuv/convert_from.h"
47 #include "third_party/libyuv/include/libyuv/scale.h"
46 #include "webrtc/api/androidvideotracksource.h" 48 #include "webrtc/api/androidvideotracksource.h"
47 #include "webrtc/api/android/jni/androidmediadecoder_jni.h" 49 #include "webrtc/api/android/jni/androidmediadecoder_jni.h"
48 #include "webrtc/api/android/jni/androidmediaencoder_jni.h" 50 #include "webrtc/api/android/jni/androidmediaencoder_jni.h"
49 #include "webrtc/api/android/jni/androidnetworkmonitor_jni.h" 51 #include "webrtc/api/android/jni/androidnetworkmonitor_jni.h"
50 #include "webrtc/api/android/jni/classreferenceholder.h" 52 #include "webrtc/api/android/jni/classreferenceholder.h"
51 #include "webrtc/api/android/jni/jni_helpers.h" 53 #include "webrtc/api/android/jni/jni_helpers.h"
52 #include "webrtc/api/android/jni/native_handle_impl.h" 54 #include "webrtc/api/android/jni/native_handle_impl.h"
53 #include "webrtc/api/mediaconstraintsinterface.h" 55 #include "webrtc/api/mediaconstraintsinterface.h"
54 #include "webrtc/api/peerconnectioninterface.h" 56 #include "webrtc/api/peerconnectioninterface.h"
55 #include "webrtc/api/rtpreceiverinterface.h" 57 #include "webrtc/api/rtpreceiverinterface.h"
(...skipping 1940 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 memcpy(dst, src, src_stride * height); 1998 memcpy(dst, src, src_stride * height);
1997 } else { 1999 } else {
1998 for (int i = 0; i < height; i++) { 2000 for (int i = 0; i < height; i++) {
1999 memcpy(dst, src, width); 2001 memcpy(dst, src, width);
2000 src += src_stride; 2002 src += src_stride;
2001 dst += dst_stride; 2003 dst += dst_stride;
2002 } 2004 }
2003 } 2005 }
2004 } 2006 }
2005 2007
2008 JOW(void, FileVideoCapturer_nativeI420ToNV21)(
2009 JNIEnv *jni, jclass, jbyteArray j_src_buffer, jint width, jint height,
2010 jbyteArray j_dst_buffer) {
2011 size_t src_size = jni->GetArrayLength(j_src_buffer);
2012 size_t dst_size = jni->GetArrayLength(j_dst_buffer);
2013 int src_stride = width;
2014 int dst_stride = width;
2015 RTC_CHECK(src_size >= src_stride * height * 3 / 2)
2016 << "Insufficient source buffer capacity " << src_size;
2017 RTC_CHECK(dst_size >= dst_stride * height * 3 / 2)
2018 << "Insufficient destination buffer capacity " << dst_size;
2019 uint8_t* src =
2020 reinterpret_cast<uint8_t*>(jni->GetByteArrayElements(j_src_buffer, 0));
2021 uint8_t* dst =
2022 reinterpret_cast<uint8_t*>(jni->GetByteArrayElements(j_dst_buffer, 0));
2023 uint8_t* src_y = src;
2024 size_t src_stride_y = src_stride;
2025 uint8_t* src_u = src + src_stride * height;
2026 size_t src_stride_u = src_stride / 2;
2027 uint8_t* src_v = src + src_stride * height * 5 / 4;
2028 size_t src_stride_v = src_stride / 2;
2029
2030 uint8_t* dst_y = dst;
2031 size_t dst_stride_y = dst_stride;
2032 size_t dst_stride_uv = dst_stride;
2033 uint8_t* dst_uv = dst + dst_stride * height;
2034
2035 libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v,
2036 src_stride_v, dst_y, dst_stride_y, dst_uv, dst_stride_uv,
2037 width, height);
2038 }
2039
2040 JOW(void, VideoFileRenderer_nativeI420Scale)(
2041 JNIEnv *jni, jclass,
2042 jobject j_src_buffer_y, jint j_src_stride_y,
2043 jobject j_src_buffer_u, jint j_src_stride_u,
2044 jobject j_src_buffer_v, jint j_src_stride_v,
2045 jint width, jint height,
2046 jbyteArray j_dst_buffer, jint dstWidth, jint dstHeight) {
2047 size_t src_size_y = jni->GetDirectBufferCapacity(j_src_buffer_y);
2048 size_t src_size_u = jni->GetDirectBufferCapacity(j_src_buffer_u);
2049 size_t src_size_v = jni->GetDirectBufferCapacity(j_src_buffer_v);
2050 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer);
2051 int dst_stride = dstWidth;
2052 RTC_CHECK(src_size_y >= j_src_stride_y * height)
2053 << "Insufficient source y buffer capacity " << src_size_y;
2054 RTC_CHECK(src_size_u >= j_src_stride_u * height / 4)
2055 << "Insufficient source u buffer capacity " << src_size_u;
2056 RTC_CHECK(src_size_v >= j_src_stride_v * height / 4)
2057 << "Insufficient source v buffer capacity " << src_size_v;
2058 RTC_CHECK(dst_size >= dst_stride * height * 3 / 2)
2059 << "Insufficient destination buffer capacity " << dst_size;
2060 uint8_t* src_y =
2061 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_y));
2062 uint8_t* src_u =
2063 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_u));
2064 uint8_t* src_v =
2065 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_v));
2066 uint8_t* dst =
2067 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_buffer));
2068
2069 uint8_t* dst_y = dst;
2070 size_t dst_stride_y = dst_stride;
2071 uint8_t* dst_u = dst + dst_stride * dstHeight;
2072 size_t dst_stride_u = dst_stride / 2;
2073 uint8_t* dst_v = dst + dst_stride * dstHeight * 5 / 4;
2074 size_t dst_stride_v = dst_stride / 2;
2075
2076 int ret = libyuv::I420Scale(
2077 src_y, j_src_stride_y, src_u, j_src_stride_u, src_v, j_src_stride_v,
2078 width, height, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
2079 dst_stride_v, dstWidth, dstHeight, libyuv::kFilterBilinear);
2080 if (ret) {
2081 LOG(LS_ERROR) << "Error scaling I420 frame: " << ret;
2082 }
2083 }
2084
2006 JOW(jstring, MediaStreamTrack_nativeId)(JNIEnv* jni, jclass, jlong j_p) { 2085 JOW(jstring, MediaStreamTrack_nativeId)(JNIEnv* jni, jclass, jlong j_p) {
2007 return JavaStringFromStdString( 2086 return JavaStringFromStdString(
2008 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->id()); 2087 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->id());
2009 } 2088 }
2010 2089
2011 JOW(jstring, MediaStreamTrack_nativeKind)(JNIEnv* jni, jclass, jlong j_p) { 2090 JOW(jstring, MediaStreamTrack_nativeKind)(JNIEnv* jni, jclass, jlong j_p) {
2012 return JavaStringFromStdString( 2091 return JavaStringFromStdString(
2013 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->kind()); 2092 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->kind());
2014 } 2093 }
2015 2094
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 return JavaStringFromStdString( 2398 return JavaStringFromStdString(
2320 jni, 2399 jni,
2321 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2400 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2322 } 2401 }
2323 2402
2324 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2403 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2325 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2404 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2326 } 2405 }
2327 2406
2328 } // namespace webrtc_jni 2407 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698