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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 #include "webrtc/system_wrappers/include/field_trial_default.h" | 74 #include "webrtc/system_wrappers/include/field_trial_default.h" |
75 #include "webrtc/system_wrappers/include/logcat_trace_context.h" | 75 #include "webrtc/system_wrappers/include/logcat_trace_context.h" |
76 #include "webrtc/system_wrappers/include/trace.h" | 76 #include "webrtc/system_wrappers/include/trace.h" |
77 #include "webrtc/voice_engine/include/voe_base.h" | 77 #include "webrtc/voice_engine/include/voe_base.h" |
78 | 78 |
79 using cricket::WebRtcVideoDecoderFactory; | 79 using cricket::WebRtcVideoDecoderFactory; |
80 using cricket::WebRtcVideoEncoderFactory; | 80 using cricket::WebRtcVideoEncoderFactory; |
81 using rtc::Bind; | 81 using rtc::Bind; |
82 using rtc::Thread; | 82 using rtc::Thread; |
83 using rtc::ThreadManager; | 83 using rtc::ThreadManager; |
84 using rtc::scoped_ptr; | |
85 using webrtc::AudioSourceInterface; | 84 using webrtc::AudioSourceInterface; |
86 using webrtc::AudioTrackInterface; | 85 using webrtc::AudioTrackInterface; |
87 using webrtc::AudioTrackVector; | 86 using webrtc::AudioTrackVector; |
88 using webrtc::CreateSessionDescriptionObserver; | 87 using webrtc::CreateSessionDescriptionObserver; |
89 using webrtc::DataBuffer; | 88 using webrtc::DataBuffer; |
90 using webrtc::DataChannelInit; | 89 using webrtc::DataChannelInit; |
91 using webrtc::DataChannelInterface; | 90 using webrtc::DataChannelInterface; |
92 using webrtc::DataChannelObserver; | 91 using webrtc::DataChannelObserver; |
93 using webrtc::IceCandidateInterface; | 92 using webrtc::IceCandidateInterface; |
94 using webrtc::LogcatTraceContext; | 93 using webrtc::LogcatTraceContext; |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 const jmethodID j_media_stream_ctor_; | 420 const jmethodID j_media_stream_ctor_; |
422 const ScopedGlobalRef<jclass> j_audio_track_class_; | 421 const ScopedGlobalRef<jclass> j_audio_track_class_; |
423 const jmethodID j_audio_track_ctor_; | 422 const jmethodID j_audio_track_ctor_; |
424 const ScopedGlobalRef<jclass> j_video_track_class_; | 423 const ScopedGlobalRef<jclass> j_video_track_class_; |
425 const jmethodID j_video_track_ctor_; | 424 const jmethodID j_video_track_ctor_; |
426 const ScopedGlobalRef<jclass> j_data_channel_class_; | 425 const ScopedGlobalRef<jclass> j_data_channel_class_; |
427 const jmethodID j_data_channel_ctor_; | 426 const jmethodID j_data_channel_ctor_; |
428 // C++ -> Java remote streams. The stored jobects are global refs and must be | 427 // C++ -> Java remote streams. The stored jobects are global refs and must be |
429 // manually deleted upon removal. Use DisposeRemoteStream(). | 428 // manually deleted upon removal. Use DisposeRemoteStream(). |
430 NativeToJavaStreamsMap remote_streams_; | 429 NativeToJavaStreamsMap remote_streams_; |
431 scoped_ptr<ConstraintsWrapper> constraints_; | 430 std::unique_ptr<ConstraintsWrapper> constraints_; |
432 }; | 431 }; |
433 | 432 |
434 // Wrapper for a Java MediaConstraints object. Copies all needed data so when | 433 // Wrapper for a Java MediaConstraints object. Copies all needed data so when |
435 // the constructor returns the Java object is no longer needed. | 434 // the constructor returns the Java object is no longer needed. |
436 class ConstraintsWrapper : public MediaConstraintsInterface { | 435 class ConstraintsWrapper : public MediaConstraintsInterface { |
437 public: | 436 public: |
438 ConstraintsWrapper(JNIEnv* jni, jobject j_constraints) { | 437 ConstraintsWrapper(JNIEnv* jni, jobject j_constraints) { |
439 PopulateConstraintsFromJavaPairList( | 438 PopulateConstraintsFromJavaPairList( |
440 jni, j_constraints, "mandatory", &mandatory_); | 439 jni, j_constraints, "mandatory", &mandatory_); |
441 PopulateConstraintsFromJavaPairList( | 440 PopulateConstraintsFromJavaPairList( |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 jstring j_error_string = JavaStringFromStdString(jni(), error); | 542 jstring j_error_string = JavaStringFromStdString(jni(), error); |
544 jni()->CallVoidMethod(*j_observer_global_, m, j_error_string); | 543 jni()->CallVoidMethod(*j_observer_global_, m, j_error_string); |
545 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; | 544 CHECK_EXCEPTION(jni()) << "error during CallVoidMethod"; |
546 } | 545 } |
547 | 546 |
548 JNIEnv* jni() { | 547 JNIEnv* jni() { |
549 return AttachCurrentThreadIfNeeded(); | 548 return AttachCurrentThreadIfNeeded(); |
550 } | 549 } |
551 | 550 |
552 private: | 551 private: |
553 scoped_ptr<ConstraintsWrapper> constraints_; | 552 std::unique_ptr<ConstraintsWrapper> constraints_; |
554 const ScopedGlobalRef<jobject> j_observer_global_; | 553 const ScopedGlobalRef<jobject> j_observer_global_; |
555 const ScopedGlobalRef<jclass> j_observer_class_; | 554 const ScopedGlobalRef<jclass> j_observer_class_; |
556 }; | 555 }; |
557 | 556 |
558 class CreateSdpObserverWrapper | 557 class CreateSdpObserverWrapper |
559 : public SdpObserverWrapper<CreateSessionDescriptionObserver> { | 558 : public SdpObserverWrapper<CreateSessionDescriptionObserver> { |
560 public: | 559 public: |
561 CreateSdpObserverWrapper(JNIEnv* jni, jobject j_observer, | 560 CreateSdpObserverWrapper(JNIEnv* jni, jobject j_observer, |
562 ConstraintsWrapper* constraints) | 561 ConstraintsWrapper* constraints) |
563 : SdpObserverWrapper(jni, j_observer, constraints) {} | 562 : SdpObserverWrapper(jni, j_observer, constraints) {} |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 | 815 |
817 static DataChannelInterface* ExtractNativeDC(JNIEnv* jni, jobject j_dc) { | 816 static DataChannelInterface* ExtractNativeDC(JNIEnv* jni, jobject j_dc) { |
818 jfieldID native_dc_id = GetFieldID(jni, | 817 jfieldID native_dc_id = GetFieldID(jni, |
819 GetObjectClass(jni, j_dc), "nativeDataChannel", "J"); | 818 GetObjectClass(jni, j_dc), "nativeDataChannel", "J"); |
820 jlong j_d = GetLongField(jni, j_dc, native_dc_id); | 819 jlong j_d = GetLongField(jni, j_dc, native_dc_id); |
821 return reinterpret_cast<DataChannelInterface*>(j_d); | 820 return reinterpret_cast<DataChannelInterface*>(j_d); |
822 } | 821 } |
823 | 822 |
824 JOW(jlong, DataChannel_registerObserverNative)( | 823 JOW(jlong, DataChannel_registerObserverNative)( |
825 JNIEnv* jni, jobject j_dc, jobject j_observer) { | 824 JNIEnv* jni, jobject j_dc, jobject j_observer) { |
826 scoped_ptr<DataChannelObserverWrapper> observer( | 825 std::unique_ptr<DataChannelObserverWrapper> observer( |
827 new DataChannelObserverWrapper(jni, j_observer)); | 826 new DataChannelObserverWrapper(jni, j_observer)); |
828 ExtractNativeDC(jni, j_dc)->RegisterObserver(observer.get()); | 827 ExtractNativeDC(jni, j_dc)->RegisterObserver(observer.get()); |
829 return jlongFromPointer(observer.release()); | 828 return jlongFromPointer(observer.release()); |
830 } | 829 } |
831 | 830 |
832 JOW(void, DataChannel_unregisterObserverNative)( | 831 JOW(void, DataChannel_unregisterObserverNative)( |
833 JNIEnv* jni, jobject j_dc, jlong native_observer) { | 832 JNIEnv* jni, jobject j_dc, jlong native_observer) { |
834 ExtractNativeDC(jni, j_dc)->UnregisterObserver(); | 833 ExtractNativeDC(jni, j_dc)->UnregisterObserver(); |
835 delete reinterpret_cast<DataChannelObserverWrapper*>(native_observer); | 834 delete reinterpret_cast<DataChannelObserverWrapper*>(native_observer); |
836 } | 835 } |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 WebRtcVideoDecoderFactory* decoder_factory() { return decoder_factory_; } | 1060 WebRtcVideoDecoderFactory* decoder_factory() { return decoder_factory_; } |
1062 rtc::NetworkMonitorFactory* network_monitor_factory() { | 1061 rtc::NetworkMonitorFactory* network_monitor_factory() { |
1063 return network_monitor_factory_; | 1062 return network_monitor_factory_; |
1064 } | 1063 } |
1065 void clear_network_monitor_factory() { network_monitor_factory_ = nullptr; } | 1064 void clear_network_monitor_factory() { network_monitor_factory_ = nullptr; } |
1066 void InvokeJavaCallbacksOnFactoryThreads(); | 1065 void InvokeJavaCallbacksOnFactoryThreads(); |
1067 | 1066 |
1068 private: | 1067 private: |
1069 void JavaCallbackOnFactoryThreads(); | 1068 void JavaCallbackOnFactoryThreads(); |
1070 | 1069 |
1071 const scoped_ptr<Thread> worker_thread_; | 1070 const std::unique_ptr<Thread> worker_thread_; |
1072 const scoped_ptr<Thread> signaling_thread_; | 1071 const std::unique_ptr<Thread> signaling_thread_; |
1073 WebRtcVideoEncoderFactory* encoder_factory_; | 1072 WebRtcVideoEncoderFactory* encoder_factory_; |
1074 WebRtcVideoDecoderFactory* decoder_factory_; | 1073 WebRtcVideoDecoderFactory* decoder_factory_; |
1075 rtc::NetworkMonitorFactory* network_monitor_factory_; | 1074 rtc::NetworkMonitorFactory* network_monitor_factory_; |
1076 PeerConnectionFactoryInterface* factory_; // Const after ctor except dtor. | 1075 PeerConnectionFactoryInterface* factory_; // Const after ctor except dtor. |
1077 }; | 1076 }; |
1078 | 1077 |
1079 void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() { | 1078 void OwnedFactoryAndThreads::JavaCallbackOnFactoryThreads() { |
1080 JNIEnv* jni = AttachCurrentThreadIfNeeded(); | 1079 JNIEnv* jni = AttachCurrentThreadIfNeeded(); |
1081 ScopedLocalRefFrame local_ref_frame(jni); | 1080 ScopedLocalRefFrame local_ref_frame(jni); |
1082 jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory"); | 1081 jclass j_factory_class = FindClass(jni, "org/webrtc/PeerConnectionFactory"); |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 return (jlong)stream.release(); | 1218 return (jlong)stream.release(); |
1220 } | 1219 } |
1221 | 1220 |
1222 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource)( | 1221 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource)( |
1223 JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, | 1222 JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, |
1224 jobject j_video_capturer, jobject j_constraints) { | 1223 jobject j_video_capturer, jobject j_constraints) { |
1225 // Create a cricket::VideoCapturer from |j_video_capturer|. | 1224 // Create a cricket::VideoCapturer from |j_video_capturer|. |
1226 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = | 1225 rtc::scoped_refptr<webrtc::AndroidVideoCapturerDelegate> delegate = |
1227 new rtc::RefCountedObject<AndroidVideoCapturerJni>( | 1226 new rtc::RefCountedObject<AndroidVideoCapturerJni>( |
1228 jni, j_video_capturer, j_egl_context); | 1227 jni, j_video_capturer, j_egl_context); |
1229 rtc::scoped_ptr<cricket::VideoCapturer> capturer( | 1228 std::unique_ptr<cricket::VideoCapturer> capturer( |
1230 new webrtc::AndroidVideoCapturer(delegate)); | 1229 new webrtc::AndroidVideoCapturer(delegate)); |
1231 // Create a webrtc::VideoTrackSourceInterface from the cricket::VideoCapturer, | 1230 // Create a webrtc::VideoTrackSourceInterface from the cricket::VideoCapturer, |
1232 // native factory and constraints. | 1231 // native factory and constraints. |
1233 scoped_ptr<ConstraintsWrapper> constraints( | 1232 std::unique_ptr<ConstraintsWrapper> constraints( |
1234 new ConstraintsWrapper(jni, j_constraints)); | 1233 new ConstraintsWrapper(jni, j_constraints)); |
1235 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1234 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1236 factoryFromJava(native_factory)); | 1235 factoryFromJava(native_factory)); |
1237 rtc::scoped_refptr<VideoTrackSourceInterface> source( | 1236 rtc::scoped_refptr<VideoTrackSourceInterface> source( |
1238 factory->CreateVideoSource(capturer.release(), constraints.get())); | 1237 factory->CreateVideoSource(capturer.release(), constraints.get())); |
1239 return (jlong)source.release(); | 1238 return (jlong)source.release(); |
1240 } | 1239 } |
1241 | 1240 |
1242 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)( | 1241 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)( |
1243 JNIEnv* jni, jclass, jlong native_factory, jstring id, | 1242 JNIEnv* jni, jclass, jlong native_factory, jstring id, |
1244 jlong native_source) { | 1243 jlong native_source) { |
1245 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1244 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1246 factoryFromJava(native_factory)); | 1245 factoryFromJava(native_factory)); |
1247 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack( | 1246 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack( |
1248 JavaToStdString(jni, id), | 1247 JavaToStdString(jni, id), |
1249 reinterpret_cast<VideoTrackSourceInterface*>(native_source))); | 1248 reinterpret_cast<VideoTrackSourceInterface*>(native_source))); |
1250 return (jlong)track.release(); | 1249 return (jlong)track.release(); |
1251 } | 1250 } |
1252 | 1251 |
1253 JOW(jlong, PeerConnectionFactory_nativeCreateAudioSource)( | 1252 JOW(jlong, PeerConnectionFactory_nativeCreateAudioSource)( |
1254 JNIEnv* jni, jclass, jlong native_factory, jobject j_constraints) { | 1253 JNIEnv* jni, jclass, jlong native_factory, jobject j_constraints) { |
1255 scoped_ptr<ConstraintsWrapper> constraints( | 1254 std::unique_ptr<ConstraintsWrapper> constraints( |
1256 new ConstraintsWrapper(jni, j_constraints)); | 1255 new ConstraintsWrapper(jni, j_constraints)); |
1257 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1256 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1258 factoryFromJava(native_factory)); | 1257 factoryFromJava(native_factory)); |
1259 rtc::scoped_refptr<AudioSourceInterface> source( | 1258 rtc::scoped_refptr<AudioSourceInterface> source( |
1260 factory->CreateAudioSource(constraints.get())); | 1259 factory->CreateAudioSource(constraints.get())); |
1261 return (jlong)source.release(); | 1260 return (jlong)source.release(); |
1262 } | 1261 } |
1263 | 1262 |
1264 JOW(jlong, PeerConnectionFactory_nativeCreateAudioTrack)( | 1263 JOW(jlong, PeerConnectionFactory_nativeCreateAudioTrack)( |
1265 JNIEnv* jni, jclass, jlong native_factory, jstring id, | 1264 JNIEnv* jni, jclass, jlong native_factory, jstring id, |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1700 PeerConnectionInterface::RTCConfiguration rtc_config; | 1699 PeerConnectionInterface::RTCConfiguration rtc_config; |
1701 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); | 1700 JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); |
1702 return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config); | 1701 return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config); |
1703 } | 1702 } |
1704 | 1703 |
1705 JOW(jboolean, PeerConnection_nativeAddIceCandidate)( | 1704 JOW(jboolean, PeerConnection_nativeAddIceCandidate)( |
1706 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid, | 1705 JNIEnv* jni, jobject j_pc, jstring j_sdp_mid, |
1707 jint j_sdp_mline_index, jstring j_candidate_sdp) { | 1706 jint j_sdp_mline_index, jstring j_candidate_sdp) { |
1708 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid); | 1707 std::string sdp_mid = JavaToStdString(jni, j_sdp_mid); |
1709 std::string sdp = JavaToStdString(jni, j_candidate_sdp); | 1708 std::string sdp = JavaToStdString(jni, j_candidate_sdp); |
1710 scoped_ptr<IceCandidateInterface> candidate( | 1709 std::unique_ptr<IceCandidateInterface> candidate( |
1711 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL)); | 1710 webrtc::CreateIceCandidate(sdp_mid, j_sdp_mline_index, sdp, NULL)); |
1712 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get()); | 1711 return ExtractNativePC(jni, j_pc)->AddIceCandidate(candidate.get()); |
1713 } | 1712 } |
1714 | 1713 |
1715 static cricket::Candidate GetCandidateFromJava(JNIEnv* jni, | 1714 static cricket::Candidate GetCandidateFromJava(JNIEnv* jni, |
1716 jobject j_candidate) { | 1715 jobject j_candidate) { |
1717 jclass j_candidate_class = GetObjectClass(jni, j_candidate); | 1716 jclass j_candidate_class = GetObjectClass(jni, j_candidate); |
1718 jfieldID j_sdp_mid_id = | 1717 jfieldID j_sdp_mid_id = |
1719 GetFieldID(jni, j_candidate_class, "sdpMid", "Ljava/lang/String;"); | 1718 GetFieldID(jni, j_candidate_class, "sdpMid", "Ljava/lang/String;"); |
1720 std::string sdp_mid = | 1719 std::string sdp_mid = |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1865 } | 1864 } |
1866 | 1865 |
1867 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { | 1866 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { |
1868 rtc::scoped_refptr<MediaSourceInterface> p( | 1867 rtc::scoped_refptr<MediaSourceInterface> p( |
1869 reinterpret_cast<MediaSourceInterface*>(j_p)); | 1868 reinterpret_cast<MediaSourceInterface*>(j_p)); |
1870 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); | 1869 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); |
1871 } | 1870 } |
1872 | 1871 |
1873 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)( | 1872 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)( |
1874 JNIEnv* jni, jclass, jobject j_callbacks) { | 1873 JNIEnv* jni, jclass, jobject j_callbacks) { |
1875 scoped_ptr<JavaVideoRendererWrapper> renderer( | 1874 std::unique_ptr<JavaVideoRendererWrapper> renderer( |
1876 new JavaVideoRendererWrapper(jni, j_callbacks)); | 1875 new JavaVideoRendererWrapper(jni, j_callbacks)); |
1877 return (jlong)renderer.release(); | 1876 return (jlong)renderer.release(); |
1878 } | 1877 } |
1879 | 1878 |
1880 JOW(void, VideoRenderer_nativeCopyPlane)( | 1879 JOW(void, VideoRenderer_nativeCopyPlane)( |
1881 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, | 1880 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, |
1882 jint src_stride, jobject j_dst_buffer, jint dst_stride) { | 1881 jint src_stride, jobject j_dst_buffer, jint dst_stride) { |
1883 size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer); | 1882 size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer); |
1884 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer); | 1883 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer); |
1885 RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride; | 1884 RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride; |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1979 JNIEnv* jni, jclass, jlong j_sink) { | 1978 JNIEnv* jni, jclass, jlong j_sink) { |
1980 rtc::CallSessionFileRotatingLogSink* sink = | 1979 rtc::CallSessionFileRotatingLogSink* sink = |
1981 reinterpret_cast<rtc::CallSessionFileRotatingLogSink*>(j_sink); | 1980 reinterpret_cast<rtc::CallSessionFileRotatingLogSink*>(j_sink); |
1982 rtc::LogMessage::RemoveLogToStream(sink); | 1981 rtc::LogMessage::RemoveLogToStream(sink); |
1983 delete sink; | 1982 delete sink; |
1984 } | 1983 } |
1985 | 1984 |
1986 JOW(jbyteArray, CallSessionFileRotatingLogSink_nativeGetLogData)( | 1985 JOW(jbyteArray, CallSessionFileRotatingLogSink_nativeGetLogData)( |
1987 JNIEnv* jni, jclass, jstring j_dirPath) { | 1986 JNIEnv* jni, jclass, jstring j_dirPath) { |
1988 std::string dir_path = JavaToStdString(jni, j_dirPath); | 1987 std::string dir_path = JavaToStdString(jni, j_dirPath); |
1989 rtc::scoped_ptr<rtc::CallSessionFileRotatingStream> stream( | 1988 std::unique_ptr<rtc::CallSessionFileRotatingStream> stream( |
1990 new rtc::CallSessionFileRotatingStream(dir_path)); | 1989 new rtc::CallSessionFileRotatingStream(dir_path)); |
1991 if (!stream->Open()) { | 1990 if (!stream->Open()) { |
1992 LOG_V(rtc::LoggingSeverity::LS_WARNING) << | 1991 LOG_V(rtc::LoggingSeverity::LS_WARNING) << |
1993 "Failed to open CallSessionFileRotatingStream for path " << dir_path; | 1992 "Failed to open CallSessionFileRotatingStream for path " << dir_path; |
1994 return jni->NewByteArray(0); | 1993 return jni->NewByteArray(0); |
1995 } | 1994 } |
1996 size_t log_size = 0; | 1995 size_t log_size = 0; |
1997 if (!stream->GetSize(&log_size) || log_size == 0) { | 1996 if (!stream->GetSize(&log_size) || log_size == 0) { |
1998 LOG_V(rtc::LoggingSeverity::LS_WARNING) << | 1997 LOG_V(rtc::LoggingSeverity::LS_WARNING) << |
1999 "CallSessionFileRotatingStream returns 0 size for path " << dir_path; | 1998 "CallSessionFileRotatingStream returns 0 size for path " << dir_path; |
2000 return jni->NewByteArray(0); | 1999 return jni->NewByteArray(0); |
2001 } | 2000 } |
2002 | 2001 |
2003 size_t read = 0; | 2002 size_t read = 0; |
2004 rtc::scoped_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); | 2003 std::unique_ptr<jbyte> buffer(static_cast<jbyte*>(malloc(log_size))); |
2005 stream->ReadAll(buffer.get(), log_size, &read, nullptr); | 2004 stream->ReadAll(buffer.get(), log_size, &read, nullptr); |
2006 | 2005 |
2007 jbyteArray result = jni->NewByteArray(read); | 2006 jbyteArray result = jni->NewByteArray(read); |
2008 jni->SetByteArrayRegion(result, 0, read, buffer.get()); | 2007 jni->SetByteArrayRegion(result, 0, read, buffer.get()); |
2009 | 2008 |
2010 return result; | 2009 return result; |
2011 } | 2010 } |
2012 | 2011 |
2013 JOW(jboolean, RtpSender_nativeSetTrack)(JNIEnv* jni, | 2012 JOW(jboolean, RtpSender_nativeSetTrack)(JNIEnv* jni, |
2014 jclass, | 2013 jclass, |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 return JavaStringFromStdString( | 2207 return JavaStringFromStdString( |
2209 jni, | 2208 jni, |
2210 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); | 2209 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->id()); |
2211 } | 2210 } |
2212 | 2211 |
2213 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { | 2212 JOW(void, RtpReceiver_free)(JNIEnv* jni, jclass, jlong j_rtp_receiver_pointer) { |
2214 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); | 2213 reinterpret_cast<RtpReceiverInterface*>(j_rtp_receiver_pointer)->Release(); |
2215 } | 2214 } |
2216 | 2215 |
2217 } // namespace webrtc_jni | 2216 } // namespace webrtc_jni |
OLD | NEW |