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 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 using webrtc::StatsObserver; | 113 using webrtc::StatsObserver; |
114 using webrtc::StatsReport; | 114 using webrtc::StatsReport; |
115 using webrtc::StatsReports; | 115 using webrtc::StatsReports; |
116 using webrtc::VideoTrackSourceInterface; | 116 using webrtc::VideoTrackSourceInterface; |
117 using webrtc::VideoTrackInterface; | 117 using webrtc::VideoTrackInterface; |
118 using webrtc::VideoTrackVector; | 118 using webrtc::VideoTrackVector; |
119 using webrtc::kVideoCodecVP8; | 119 using webrtc::kVideoCodecVP8; |
120 | 120 |
121 namespace webrtc_jni { | 121 namespace webrtc_jni { |
122 | 122 |
| 123 WebRtcVideoEncoderFactory* CreateVideoEncoderFactory(); |
| 124 |
| 125 WebRtcVideoDecoderFactory* CreateVideoDecoderFactory(); |
| 126 |
| 127 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> |
| 128 CreateAndroidVideoTrackSource(rtc::Thread* signaling_thread, |
| 129 JNIEnv* jni, |
| 130 jobject j_egl_context, |
| 131 bool is_screencast = false); |
| 132 |
| 133 jobject GetSurfaceTextureHelper( |
| 134 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper); |
| 135 |
| 136 void EncoderFactorySetEGLContext(MediaCodecVideoEncoderFactory* encoder_factory, |
| 137 JNIEnv* jni, |
| 138 jobject local_egl_context); |
| 139 |
| 140 void DecoderFactorySetEGLContext(MediaCodecVideoDecoderFactory* decoder_factory, |
| 141 JNIEnv* jni, |
| 142 jobject remote_egl_context); |
| 143 |
123 // Field trials initialization string | 144 // Field trials initialization string |
124 static char *field_trials_init_string = NULL; | 145 static char *field_trials_init_string = NULL; |
125 | 146 |
126 // Set in PeerConnectionFactory_initializeAndroidGlobals(). | 147 // Set in PeerConnectionFactory_initializeAndroidGlobals(). |
127 static bool factory_static_initialized = false; | 148 static bool factory_static_initialized = false; |
128 static bool video_hw_acceleration_enabled = true; | 149 static bool video_hw_acceleration_enabled = true; |
129 static jobject j_application_context = nullptr; | 150 static jobject j_application_context = nullptr; |
130 | 151 |
131 // Return the (singleton) Java Enum object corresponding to |index|; | 152 // Return the (singleton) Java Enum object corresponding to |index|; |
132 // |state_class_fragment| is something like "MediaSource$State". | 153 // |state_class_fragment| is something like "MediaSource$State". |
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 } | 858 } |
838 | 859 |
839 const ScopedGlobalRef<jobject> j_observer_global_; | 860 const ScopedGlobalRef<jobject> j_observer_global_; |
840 const ScopedGlobalRef<jclass> j_observer_class_; | 861 const ScopedGlobalRef<jclass> j_observer_class_; |
841 const ScopedGlobalRef<jclass> j_stats_report_class_; | 862 const ScopedGlobalRef<jclass> j_stats_report_class_; |
842 const jmethodID j_stats_report_ctor_; | 863 const jmethodID j_stats_report_ctor_; |
843 const ScopedGlobalRef<jclass> j_value_class_; | 864 const ScopedGlobalRef<jclass> j_value_class_; |
844 const jmethodID j_value_ctor_; | 865 const jmethodID j_value_ctor_; |
845 }; | 866 }; |
846 | 867 |
847 // Wrapper dispatching rtc::VideoSinkInterface to a Java VideoRenderer | |
848 // instance. | |
849 class JavaVideoRendererWrapper | |
850 : public rtc::VideoSinkInterface<webrtc::VideoFrame> { | |
851 public: | |
852 JavaVideoRendererWrapper(JNIEnv* jni, jobject j_callbacks) | |
853 : j_callbacks_(jni, j_callbacks), | |
854 j_render_frame_id_(GetMethodID( | |
855 jni, GetObjectClass(jni, j_callbacks), "renderFrame", | |
856 "(Lorg/webrtc/VideoRenderer$I420Frame;)V")), | |
857 j_frame_class_(jni, | |
858 FindClass(jni, "org/webrtc/VideoRenderer$I420Frame")), | |
859 j_i420_frame_ctor_id_(GetMethodID( | |
860 jni, *j_frame_class_, "<init>", "(III[I[Ljava/nio/ByteBuffer;J)V")), | |
861 j_texture_frame_ctor_id_(GetMethodID( | |
862 jni, *j_frame_class_, "<init>", | |
863 "(IIII[FJ)V")), | |
864 j_byte_buffer_class_(jni, FindClass(jni, "java/nio/ByteBuffer")) { | |
865 CHECK_EXCEPTION(jni); | |
866 } | |
867 | |
868 virtual ~JavaVideoRendererWrapper() {} | |
869 | |
870 void OnFrame(const webrtc::VideoFrame& video_frame) override { | |
871 ScopedLocalRefFrame local_ref_frame(jni()); | |
872 jobject j_frame = | |
873 (video_frame.video_frame_buffer()->native_handle() != nullptr) | |
874 ? CricketToJavaTextureFrame(&video_frame) | |
875 : CricketToJavaI420Frame(&video_frame); | |
876 // |j_callbacks_| is responsible for releasing |j_frame| with | |
877 // VideoRenderer.renderFrameDone(). | |
878 jni()->CallVoidMethod(*j_callbacks_, j_render_frame_id_, j_frame); | |
879 CHECK_EXCEPTION(jni()); | |
880 } | |
881 | |
882 private: | |
883 // Make a shallow copy of |frame| to be used with Java. The callee has | |
884 // ownership of the frame, and the frame should be released with | |
885 // VideoRenderer.releaseNativeFrame(). | |
886 static jlong javaShallowCopy(const webrtc::VideoFrame* frame) { | |
887 return jlongFromPointer(new webrtc::VideoFrame(*frame)); | |
888 } | |
889 | |
890 // Return a VideoRenderer.I420Frame referring to the data in |frame|. | |
891 jobject CricketToJavaI420Frame(const webrtc::VideoFrame* frame) { | |
892 jintArray strides = jni()->NewIntArray(3); | |
893 jint* strides_array = jni()->GetIntArrayElements(strides, NULL); | |
894 strides_array[0] = frame->video_frame_buffer()->StrideY(); | |
895 strides_array[1] = frame->video_frame_buffer()->StrideU(); | |
896 strides_array[2] = frame->video_frame_buffer()->StrideV(); | |
897 jni()->ReleaseIntArrayElements(strides, strides_array, 0); | |
898 jobjectArray planes = jni()->NewObjectArray(3, *j_byte_buffer_class_, NULL); | |
899 jobject y_buffer = jni()->NewDirectByteBuffer( | |
900 const_cast<uint8_t*>(frame->video_frame_buffer()->DataY()), | |
901 frame->video_frame_buffer()->StrideY() * | |
902 frame->video_frame_buffer()->height()); | |
903 size_t chroma_height = (frame->height() + 1) / 2; | |
904 jobject u_buffer = jni()->NewDirectByteBuffer( | |
905 const_cast<uint8_t*>(frame->video_frame_buffer()->DataU()), | |
906 frame->video_frame_buffer()->StrideU() * chroma_height); | |
907 jobject v_buffer = jni()->NewDirectByteBuffer( | |
908 const_cast<uint8_t*>(frame->video_frame_buffer()->DataV()), | |
909 frame->video_frame_buffer()->StrideV() * chroma_height); | |
910 | |
911 jni()->SetObjectArrayElement(planes, 0, y_buffer); | |
912 jni()->SetObjectArrayElement(planes, 1, u_buffer); | |
913 jni()->SetObjectArrayElement(planes, 2, v_buffer); | |
914 return jni()->NewObject( | |
915 *j_frame_class_, j_i420_frame_ctor_id_, | |
916 frame->width(), frame->height(), | |
917 static_cast<int>(frame->rotation()), | |
918 strides, planes, javaShallowCopy(frame)); | |
919 } | |
920 | |
921 // Return a VideoRenderer.I420Frame referring texture object in |frame|. | |
922 jobject CricketToJavaTextureFrame(const webrtc::VideoFrame* frame) { | |
923 NativeHandleImpl* handle = reinterpret_cast<NativeHandleImpl*>( | |
924 frame->video_frame_buffer()->native_handle()); | |
925 jfloatArray sampling_matrix = handle->sampling_matrix.ToJava(jni()); | |
926 | |
927 return jni()->NewObject( | |
928 *j_frame_class_, j_texture_frame_ctor_id_, | |
929 frame->width(), frame->height(), | |
930 static_cast<int>(frame->rotation()), | |
931 handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); | |
932 } | |
933 | |
934 JNIEnv* jni() { | |
935 return AttachCurrentThreadIfNeeded(); | |
936 } | |
937 | |
938 ScopedGlobalRef<jobject> j_callbacks_; | |
939 jmethodID j_render_frame_id_; | |
940 ScopedGlobalRef<jclass> j_frame_class_; | |
941 jmethodID j_i420_frame_ctor_id_; | |
942 jmethodID j_texture_frame_ctor_id_; | |
943 ScopedGlobalRef<jclass> j_byte_buffer_class_; | |
944 }; | |
945 | |
946 // Adapter between the C++ RtpReceiverObserverInterface and the Java | 868 // Adapter between the C++ RtpReceiverObserverInterface and the Java |
947 // RtpReceiver.Observer interface. Wraps an instance of the Java interface and | 869 // RtpReceiver.Observer interface. Wraps an instance of the Java interface and |
948 // dispatches C++ callbacks to Java. | 870 // dispatches C++ callbacks to Java. |
949 class RtpReceiverObserver : public RtpReceiverObserverInterface { | 871 class RtpReceiverObserver : public RtpReceiverObserverInterface { |
950 public: | 872 public: |
951 RtpReceiverObserver(JNIEnv* jni, jobject j_observer) | 873 RtpReceiverObserver(JNIEnv* jni, jobject j_observer) |
952 : j_observer_global_(jni, j_observer) {} | 874 : j_observer_global_(jni, j_observer) {} |
953 | 875 |
954 ~RtpReceiverObserver() override {} | 876 ~RtpReceiverObserver() override {} |
955 | 877 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1078 | 1000 |
1079 JOW(void, PeerConnection_freeObserver)(JNIEnv*, jclass, jlong j_p) { | 1001 JOW(void, PeerConnection_freeObserver)(JNIEnv*, jclass, jlong j_p) { |
1080 PCOJava* p = reinterpret_cast<PCOJava*>(j_p); | 1002 PCOJava* p = reinterpret_cast<PCOJava*>(j_p); |
1081 delete p; | 1003 delete p; |
1082 } | 1004 } |
1083 | 1005 |
1084 JOW(void, MediaSource_free)(JNIEnv*, jclass, jlong j_p) { | 1006 JOW(void, MediaSource_free)(JNIEnv*, jclass, jlong j_p) { |
1085 reinterpret_cast<rtc::RefCountInterface*>(j_p)->Release(); | 1007 reinterpret_cast<rtc::RefCountInterface*>(j_p)->Release(); |
1086 } | 1008 } |
1087 | 1009 |
1088 JOW(void, VideoRenderer_freeWrappedVideoRenderer)(JNIEnv*, jclass, jlong j_p) { | |
1089 delete reinterpret_cast<JavaVideoRendererWrapper*>(j_p); | |
1090 } | |
1091 | |
1092 JOW(void, VideoRenderer_releaseNativeFrame)( | |
1093 JNIEnv* jni, jclass, jlong j_frame_ptr) { | |
1094 delete reinterpret_cast<const webrtc::VideoFrame*>(j_frame_ptr); | |
1095 } | |
1096 | |
1097 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) { | 1010 JOW(void, MediaStreamTrack_free)(JNIEnv*, jclass, jlong j_p) { |
1098 reinterpret_cast<MediaStreamTrackInterface*>(j_p)->Release(); | 1011 reinterpret_cast<MediaStreamTrackInterface*>(j_p)->Release(); |
1099 } | 1012 } |
1100 | 1013 |
1101 JOW(jboolean, MediaStream_nativeAddAudioTrack)( | 1014 JOW(jboolean, MediaStream_nativeAddAudioTrack)( |
1102 JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) { | 1015 JNIEnv* jni, jclass, jlong pointer, jlong j_audio_track_pointer) { |
1103 return reinterpret_cast<MediaStreamInterface*>(pointer)->AddTrack( | 1016 return reinterpret_cast<MediaStreamInterface*>(pointer)->AddTrack( |
1104 reinterpret_cast<AudioTrackInterface*>(j_audio_track_pointer)); | 1017 reinterpret_cast<AudioTrackInterface*>(j_audio_track_pointer)); |
1105 } | 1018 } |
1106 | 1019 |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1347 WebRtcVideoDecoderFactory* decoder_factory = nullptr; | 1260 WebRtcVideoDecoderFactory* decoder_factory = nullptr; |
1348 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr; | 1261 rtc::NetworkMonitorFactory* network_monitor_factory = nullptr; |
1349 | 1262 |
1350 PeerConnectionFactoryInterface::Options options; | 1263 PeerConnectionFactoryInterface::Options options; |
1351 bool has_options = joptions != NULL; | 1264 bool has_options = joptions != NULL; |
1352 if (has_options) { | 1265 if (has_options) { |
1353 options = ParseOptionsFromJava(jni, joptions); | 1266 options = ParseOptionsFromJava(jni, joptions); |
1354 } | 1267 } |
1355 | 1268 |
1356 if (video_hw_acceleration_enabled) { | 1269 if (video_hw_acceleration_enabled) { |
1357 encoder_factory = new MediaCodecVideoEncoderFactory(); | 1270 encoder_factory = CreateVideoEncoderFactory(); |
1358 decoder_factory = new MediaCodecVideoDecoderFactory(); | 1271 decoder_factory = CreateVideoDecoderFactory(); |
1359 } | 1272 } |
1360 // Do not create network_monitor_factory only if the options are | 1273 // Do not create network_monitor_factory only if the options are |
1361 // provided and disable_network_monitor therein is set to true. | 1274 // provided and disable_network_monitor therein is set to true. |
1362 if (!(has_options && options.disable_network_monitor)) { | 1275 if (!(has_options && options.disable_network_monitor)) { |
1363 network_monitor_factory = new AndroidNetworkMonitorFactory(); | 1276 network_monitor_factory = new AndroidNetworkMonitorFactory(); |
1364 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory); | 1277 rtc::NetworkMonitorFactory::SetFactory(network_monitor_factory); |
1365 } | 1278 } |
1366 | 1279 |
1367 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1280 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1368 webrtc::CreatePeerConnectionFactory( | 1281 webrtc::CreatePeerConnectionFactory( |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1412 factory->CreateLocalMediaStream(JavaToStdString(jni, label))); | 1325 factory->CreateLocalMediaStream(JavaToStdString(jni, label))); |
1413 return (jlong)stream.release(); | 1326 return (jlong)stream.release(); |
1414 } | 1327 } |
1415 | 1328 |
1416 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) | 1329 JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) |
1417 (JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, | 1330 (JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, |
1418 jboolean is_screencast) { | 1331 jboolean is_screencast) { |
1419 OwnedFactoryAndThreads* factory = | 1332 OwnedFactoryAndThreads* factory = |
1420 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); | 1333 reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
1421 | 1334 |
1422 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source( | 1335 rtc::scoped_refptr<webrtc::AndroidVideoTrackSource> source = |
1423 new rtc::RefCountedObject<webrtc::AndroidVideoTrackSource>( | 1336 CreateAndroidVideoTrackSource(factory->signaling_thread(), jni, |
1424 factory->signaling_thread(), jni, j_egl_context, is_screencast)); | 1337 j_egl_context, is_screencast); |
| 1338 if (!source) { |
| 1339 return (jlong)0; |
| 1340 } |
1425 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = | 1341 rtc::scoped_refptr<webrtc::VideoTrackSourceProxy> proxy_source = |
1426 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), | 1342 webrtc::VideoTrackSourceProxy::Create(factory->signaling_thread(), |
1427 factory->worker_thread(), source); | 1343 factory->worker_thread(), source); |
1428 | 1344 |
1429 return (jlong)proxy_source.release(); | 1345 return (jlong)proxy_source.release(); |
1430 } | 1346 } |
1431 | 1347 |
1432 JOW(void, PeerConnectionFactory_nativeInitializeVideoCapturer) | 1348 JOW(void, PeerConnectionFactory_nativeInitializeVideoCapturer) |
1433 (JNIEnv* jni, | 1349 (JNIEnv* jni, |
1434 jclass, | 1350 jclass, |
1435 jlong native_factory, | 1351 jlong native_factory, |
1436 jobject j_video_capturer, | 1352 jobject j_video_capturer, |
1437 jlong native_source, | 1353 jlong native_source, |
1438 jobject j_frame_observer) { | 1354 jobject j_frame_observer) { |
1439 LOG(LS_INFO) << "PeerConnectionFactory_nativeInitializeVideoCapturer"; | 1355 LOG(LS_INFO) << "PeerConnectionFactory_nativeInitializeVideoCapturer"; |
| 1356 |
1440 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1357 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1441 factoryFromJava(native_factory)); | 1358 factoryFromJava(native_factory)); |
| 1359 |
1442 auto proxy_source = | 1360 auto proxy_source = |
1443 reinterpret_cast<webrtc::VideoTrackSourceProxy*>(native_source); | 1361 reinterpret_cast<webrtc::VideoTrackSourceProxy*>(native_source); |
1444 auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( | 1362 auto source = reinterpret_cast<webrtc::AndroidVideoTrackSource*>( |
1445 proxy_source->internal()); | 1363 proxy_source->internal()); |
| 1364 if (!source) { |
| 1365 LOG(LS_WARNING) << "The AndroidVideoTrackSource is unset."; |
| 1366 return; |
| 1367 } |
| 1368 |
1446 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper = | 1369 rtc::scoped_refptr<SurfaceTextureHelper> surface_texture_helper = |
1447 source->surface_texture_helper(); | 1370 source->surface_texture_helper(); |
1448 jni->CallVoidMethod( | 1371 jni->CallVoidMethod( |
1449 j_video_capturer, | 1372 j_video_capturer, |
1450 GetMethodID(jni, FindClass(jni, "org/webrtc/VideoCapturer"), "initialize", | 1373 GetMethodID(jni, FindClass(jni, "org/webrtc/VideoCapturer"), "initialize", |
1451 "(Lorg/webrtc/SurfaceTextureHelper;Landroid/content/" | 1374 "(Lorg/webrtc/SurfaceTextureHelper;Landroid/content/" |
1452 "Context;Lorg/webrtc/VideoCapturer$CapturerObserver;)V"), | 1375 "Context;Lorg/webrtc/VideoCapturer$CapturerObserver;)V"), |
1453 surface_texture_helper | 1376 GetSurfaceTextureHelper(surface_texture_helper), j_application_context, |
1454 ? surface_texture_helper->GetJavaSurfaceTextureHelper() | 1377 j_frame_observer); |
1455 : nullptr, | |
1456 j_application_context, j_frame_observer); | |
1457 CHECK_EXCEPTION(jni) << "error during VideoCapturer.initialize()"; | 1378 CHECK_EXCEPTION(jni) << "error during VideoCapturer.initialize()"; |
1458 } | 1379 } |
1459 | 1380 |
1460 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)( | 1381 JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)( |
1461 JNIEnv* jni, jclass, jlong native_factory, jstring id, | 1382 JNIEnv* jni, jclass, jlong native_factory, jstring id, |
1462 jlong native_source) { | 1383 jlong native_source) { |
1463 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( | 1384 rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
1464 factoryFromJava(native_factory)); | 1385 factoryFromJava(native_factory)); |
1465 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack( | 1386 rtc::scoped_refptr<VideoTrackInterface> track(factory->CreateVideoTrack( |
1466 JavaToStdString(jni, id), | 1387 JavaToStdString(jni, id), |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1534 | 1455 |
1535 jclass j_eglbase14_context_class = | 1456 jclass j_eglbase14_context_class = |
1536 FindClass(jni, "org/webrtc/EglBase14$Context"); | 1457 FindClass(jni, "org/webrtc/EglBase14$Context"); |
1537 | 1458 |
1538 MediaCodecVideoEncoderFactory* encoder_factory = | 1459 MediaCodecVideoEncoderFactory* encoder_factory = |
1539 static_cast<MediaCodecVideoEncoderFactory*> | 1460 static_cast<MediaCodecVideoEncoderFactory*> |
1540 (owned_factory->encoder_factory()); | 1461 (owned_factory->encoder_factory()); |
1541 if (encoder_factory && | 1462 if (encoder_factory && |
1542 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { | 1463 jni->IsInstanceOf(local_egl_context, j_eglbase14_context_class)) { |
1543 LOG(LS_INFO) << "Set EGL context for HW encoding."; | 1464 LOG(LS_INFO) << "Set EGL context for HW encoding."; |
1544 encoder_factory->SetEGLContext(jni, local_egl_context); | 1465 EncoderFactorySetEGLContext(encoder_factory, jni, local_egl_context); |
1545 } | 1466 } |
1546 | 1467 |
1547 MediaCodecVideoDecoderFactory* decoder_factory = | 1468 MediaCodecVideoDecoderFactory* decoder_factory = |
1548 static_cast<MediaCodecVideoDecoderFactory*> | 1469 static_cast<MediaCodecVideoDecoderFactory*> |
1549 (owned_factory->decoder_factory()); | 1470 (owned_factory->decoder_factory()); |
1550 if (decoder_factory) { | 1471 if (decoder_factory) { |
1551 LOG(LS_INFO) << "Set EGL context for HW decoding."; | 1472 LOG(LS_INFO) << "Set EGL context for HW decoding."; |
1552 decoder_factory->SetEGLContext(jni, remote_egl_context); | 1473 DecoderFactorySetEGLContext(decoder_factory, jni, remote_egl_context); |
1553 } | 1474 } |
1554 } | 1475 } |
1555 | 1476 |
1556 static PeerConnectionInterface::IceTransportsType | 1477 static PeerConnectionInterface::IceTransportsType |
1557 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) { | 1478 JavaIceTransportsTypeToNativeType(JNIEnv* jni, jobject j_ice_transports_type) { |
1558 std::string enum_name = GetJavaEnumName( | 1479 std::string enum_name = GetJavaEnumName( |
1559 jni, "org/webrtc/PeerConnection$IceTransportsType", | 1480 jni, "org/webrtc/PeerConnection$IceTransportsType", |
1560 j_ice_transports_type); | 1481 j_ice_transports_type); |
1561 | 1482 |
1562 if (enum_name == "ALL") | 1483 if (enum_name == "ALL") |
(...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2177 ExtractNativePC(jni, j_pc)->Close(); | 2098 ExtractNativePC(jni, j_pc)->Close(); |
2178 return; | 2099 return; |
2179 } | 2100 } |
2180 | 2101 |
2181 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { | 2102 JOW(jobject, MediaSource_nativeState)(JNIEnv* jni, jclass, jlong j_p) { |
2182 rtc::scoped_refptr<MediaSourceInterface> p( | 2103 rtc::scoped_refptr<MediaSourceInterface> p( |
2183 reinterpret_cast<MediaSourceInterface*>(j_p)); | 2104 reinterpret_cast<MediaSourceInterface*>(j_p)); |
2184 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); | 2105 return JavaEnumFromIndex(jni, "MediaSource$State", p->state()); |
2185 } | 2106 } |
2186 | 2107 |
2187 JOW(jlong, VideoRenderer_nativeWrapVideoRenderer)( | |
2188 JNIEnv* jni, jclass, jobject j_callbacks) { | |
2189 std::unique_ptr<JavaVideoRendererWrapper> renderer( | |
2190 new JavaVideoRendererWrapper(jni, j_callbacks)); | |
2191 return (jlong)renderer.release(); | |
2192 } | |
2193 | |
2194 JOW(void, VideoRenderer_nativeCopyPlane)( | |
2195 JNIEnv *jni, jclass, jobject j_src_buffer, jint width, jint height, | |
2196 jint src_stride, jobject j_dst_buffer, jint dst_stride) { | |
2197 size_t src_size = jni->GetDirectBufferCapacity(j_src_buffer); | |
2198 size_t dst_size = jni->GetDirectBufferCapacity(j_dst_buffer); | |
2199 RTC_CHECK(src_stride >= width) << "Wrong source stride " << src_stride; | |
2200 RTC_CHECK(dst_stride >= width) << "Wrong destination stride " << dst_stride; | |
2201 RTC_CHECK(src_size >= src_stride * height) | |
2202 << "Insufficient source buffer capacity " << src_size; | |
2203 RTC_CHECK(dst_size >= dst_stride * height) | |
2204 << "Insufficient destination buffer capacity " << dst_size; | |
2205 uint8_t *src = | |
2206 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_src_buffer)); | |
2207 uint8_t *dst = | |
2208 reinterpret_cast<uint8_t*>(jni->GetDirectBufferAddress(j_dst_buffer)); | |
2209 if (src_stride == dst_stride) { | |
2210 memcpy(dst, src, src_stride * height); | |
2211 } else { | |
2212 for (int i = 0; i < height; i++) { | |
2213 memcpy(dst, src, width); | |
2214 src += src_stride; | |
2215 dst += dst_stride; | |
2216 } | |
2217 } | |
2218 } | |
2219 | |
2220 JOW(void, FileVideoCapturer_nativeI420ToNV21)( | 2108 JOW(void, FileVideoCapturer_nativeI420ToNV21)( |
2221 JNIEnv *jni, jclass, jbyteArray j_src_buffer, jint width, jint height, | 2109 JNIEnv *jni, jclass, jbyteArray j_src_buffer, jint width, jint height, |
2222 jbyteArray j_dst_buffer) { | 2110 jbyteArray j_dst_buffer) { |
2223 size_t src_size = jni->GetArrayLength(j_src_buffer); | 2111 size_t src_size = jni->GetArrayLength(j_src_buffer); |
2224 size_t dst_size = jni->GetArrayLength(j_dst_buffer); | 2112 size_t dst_size = jni->GetArrayLength(j_dst_buffer); |
2225 int src_stride = width; | 2113 int src_stride = width; |
2226 int dst_stride = width; | 2114 int dst_stride = width; |
2227 RTC_CHECK_GE(src_size, src_stride * height * 3 / 2); | 2115 RTC_CHECK_GE(src_size, src_stride * height * 3 / 2); |
2228 RTC_CHECK_GE(dst_size, dst_stride * height * 3 / 2); | 2116 RTC_CHECK_GE(dst_size, dst_stride * height * 3 / 2); |
2229 | 2117 |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2741 return reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer) | 2629 return reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer) |
2742 ->inter_tone_gap(); | 2630 ->inter_tone_gap(); |
2743 } | 2631 } |
2744 | 2632 |
2745 JOW(void, DtmfSender_free) | 2633 JOW(void, DtmfSender_free) |
2746 (JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) { | 2634 (JNIEnv* jni, jclass, jlong j_dtmf_sender_pointer) { |
2747 reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer)->Release(); | 2635 reinterpret_cast<DtmfSenderInterface*>(j_dtmf_sender_pointer)->Release(); |
2748 } | 2636 } |
2749 | 2637 |
2750 } // namespace webrtc_jni | 2638 } // namespace webrtc_jni |
OLD | NEW |