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

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

Issue 2273573003: Support for video file instead of camera and output video out to file (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixed copyright header for start_loopback_stubbed_camera_saved_video_out.py 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_GE(src_size, src_stride * height * 3 / 2);
2016 RTC_CHECK_GE(dst_size, dst_stride * height * 3 / 2);
2017 uint8_t* src =
2018 reinterpret_cast<uint8_t*>(jni->GetByteArrayElements(j_src_buffer, 0));
2019 uint8_t* dst =
2020 reinterpret_cast<uint8_t*>(jni->GetByteArrayElements(j_dst_buffer, 0));
2021 uint8_t* src_y = src;
2022 size_t src_stride_y = src_stride;
2023 uint8_t* src_u = src + src_stride * height;
2024 size_t src_stride_u = src_stride / 2;
2025 uint8_t* src_v = src + src_stride * height * 5 / 4;
2026 size_t src_stride_v = src_stride / 2;
2027
2028 uint8_t* dst_y = dst;
2029 size_t dst_stride_y = dst_stride;
2030 size_t dst_stride_uv = dst_stride;
2031 uint8_t* dst_uv = dst + dst_stride * height;
2032
2033 libyuv::I420ToNV21(src_y, src_stride_y, src_u, src_stride_u, src_v,
2034 src_stride_v, dst_y, dst_stride_y, dst_uv, dst_stride_uv,
2035 width, height);
2036 }
2037
2038 JOW(void, VideoFileRenderer_nativeI420Scale)(
2039 JNIEnv *jni, jclass,
2040 jobject j_src_buffer_y, jint j_src_stride_y,
2041 jobject j_src_buffer_u, jint j_src_stride_u,
2042 jobject j_src_buffer_v, jint j_src_stride_v,
2043 jint width, jint height,
2044 jbyteArray j_dst_buffer, jint dstWidth, jint dstHeight) {
2045 size_t src_size_y = jni->GetDirectBufferCapacity(j_src_buffer_y);
2046 size_t src_size_u = jni->GetDirectBufferCapacity(j_src_buffer_u);
2047 size_t src_size_v = jni->GetDirectBufferCapacity(j_src_buffer_v);
2048 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer);
2049 int dst_stride = dstWidth;
2050 RTC_CHECK_GE(src_size_y, j_src_stride_y * height);
2051 RTC_CHECK_GE(src_size_u, j_src_stride_u * height / 4);
2052 RTC_CHECK_GE(src_size_v, j_src_stride_v * height / 4);
2053 RTC_CHECK_GE(dst_size, dst_stride * height * 3 / 2);
2054 uint8_t* src_y =
2055 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_y));
2056 uint8_t* src_u =
2057 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_u));
2058 uint8_t* src_v =
2059 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer_v));
2060 uint8_t* dst =
2061 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_buffer));
2062
2063 uint8_t* dst_y = dst;
2064 size_t dst_stride_y = dst_stride;
2065 uint8_t* dst_u = dst + dst_stride * dstHeight;
2066 size_t dst_stride_u = dst_stride / 2;
2067 uint8_t* dst_v = dst + dst_stride * dstHeight * 5 / 4;
2068 size_t dst_stride_v = dst_stride / 2;
2069
2070 int ret = libyuv::I420Scale(
2071 src_y, j_src_stride_y, src_u, j_src_stride_u, src_v, j_src_stride_v,
2072 width, height, dst_y, dst_stride_y, dst_u, dst_stride_u, dst_v,
2073 dst_stride_v, dstWidth, dstHeight, libyuv::kFilterBilinear);
2074 if (ret) {
2075 LOG(LS_ERROR) << "Error scaling I420 frame: " << ret;
2076 }
2077 }
2078
2006 JOW(jstring, MediaStreamTrack_nativeId)(JNIEnv* jni, jclass, jlong j_p) { 2079 JOW(jstring, MediaStreamTrack_nativeId)(JNIEnv* jni, jclass, jlong j_p) {
2007 return JavaStringFromStdString( 2080 return JavaStringFromStdString(
2008 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->id()); 2081 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->id());
2009 } 2082 }
2010 2083
2011 JOW(jstring, MediaStreamTrack_nativeKind)(JNIEnv* jni, jclass, jlong j_p) { 2084 JOW(jstring, MediaStreamTrack_nativeKind)(JNIEnv* jni, jclass, jlong j_p) {
2012 return JavaStringFromStdString( 2085 return JavaStringFromStdString(
2013 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->kind()); 2086 jni, reinterpret_cast<MediaStreamTrackInterface*>(j_p)->kind());
2014 } 2087 }
2015 2088
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
2319 return JavaStringFromStdString( 2392 return JavaStringFromStdString(
2320 jni, 2393 jni,
2321 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); 2394 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id());
2322 } 2395 }
2323 2396
2324 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { 2397 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) {
2325 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); 2398 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release();
2326 } 2399 }
2327 2400
2328 } // namespace webrtc_jni 2401 } // namespace webrtc_jni
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698