Index: webrtc/sdk/android/src/jni/peerconnection_jni.cc |
diff --git a/webrtc/sdk/android/src/jni/peerconnection_jni.cc b/webrtc/sdk/android/src/jni/peerconnection_jni.cc |
index c07d58faffc6210116057b02cf9d52f3a9432ea8..f0f4c6c32928fb5a9be10316894123d7e586ff83 100644 |
--- a/webrtc/sdk/android/src/jni/peerconnection_jni.cc |
+++ b/webrtc/sdk/android/src/jni/peerconnection_jni.cc |
@@ -61,18 +61,37 @@ |
#include "webrtc/base/ssladapter.h" |
#include "webrtc/base/stringutils.h" |
#include "webrtc/media/base/videocapturer.h" |
-#include "webrtc/media/engine/webrtcvideodecoderfactory.h" |
-#include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
+ |
+// Adding 'nogncheck' to disable the gn include header check. We don't want to |
+// depend on audio and video related targets when build the datachannel only |
+// targets. |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
+#include "webrtc/media/engine/webrtcvideodecoderfactory.h" // nogncheck |
+#include "webrtc/media/engine/webrtcvideoencoderfactory.h" // nogncheck |
+#endif |
+ |
#include "webrtc/modules/utility/include/jvm_android.h" |
#include "webrtc/system_wrappers/include/field_trial.h" |
#include "webrtc/pc/webrtcsdp.h" |
-#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" |
-#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" |
+ |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
+#include "webrtc/sdk/android/src/jni/androidmediadecoder_jni.h" // nogncheck |
+#include "webrtc/sdk/android/src/jni/androidmediaencoder_jni.h" // nogncheck |
+#endif |
+ |
#include "webrtc/sdk/android/src/jni/androidnetworkmonitor_jni.h" |
-#include "webrtc/sdk/android/src/jni/androidvideotracksource.h" |
+ |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
+#include "webrtc/sdk/android/src/jni/androidvideotracksource.h" // nogncheck |
+#endif |
+ |
#include "webrtc/sdk/android/src/jni/classreferenceholder.h" |
#include "webrtc/sdk/android/src/jni/jni_helpers.h" |
-#include "webrtc/sdk/android/src/jni/native_handle_impl.h" |
+ |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
+#include "webrtc/sdk/android/src/jni/native_handle_impl.h" // nogncheck |
+#endif |
+ |
#include "webrtc/sdk/android/src/jni/rtcstatscollectorcallbackwrapper.h" |
// Adding 'nogncheck' to disable the gn include headers check. |
// We don't want to depend on 'system_wrappers:field_trial_default' because |
@@ -80,7 +99,7 @@ |
#include "webrtc/system_wrappers/include/field_trial_default.h" // nogncheck |
#include "webrtc/system_wrappers/include/logcat_trace_context.h" |
#include "webrtc/system_wrappers/include/trace.h" |
-#include "webrtc/voice_engine/include/voe_base.h" |
+#include "webrtc/voice_engine/include/voe_base.h" // nogncheck |
using cricket::WebRtcVideoDecoderFactory; |
using cricket::WebRtcVideoEncoderFactory; |
@@ -920,15 +939,23 @@ class JavaVideoRendererWrapper |
// Return a VideoRenderer.I420Frame referring texture object in |frame|. |
jobject CricketToJavaTextureFrame(const webrtc::VideoFrame* frame) { |
+ jfloatArray sampling_matrix; |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
NativeHandleImpl* handle = reinterpret_cast<NativeHandleImpl*>( |
frame->video_frame_buffer()->native_handle()); |
- jfloatArray sampling_matrix = handle->sampling_matrix.ToJava(jni()); |
- |
+ sampling_matrix = handle->sampling_matrix.ToJava(jni()); |
return jni()->NewObject( |
- *j_frame_class_, j_texture_frame_ctor_id_, |
- frame->width(), frame->height(), |
- static_cast<int>(frame->rotation()), |
+ *j_frame_class_, j_texture_frame_ctor_id_, frame->width(), |
+ frame->height(), static_cast<int>(frame->rotation()), |
handle->oes_texture_id, sampling_matrix, javaShallowCopy(frame)); |
+#else |
+ jint texture_id = 0; |
+ sampling_matrix = jni()->NewFloatArray(16); |
+ return jni()->NewObject(*j_frame_class_, j_texture_frame_ctor_id_, |
+ frame->width(), frame->height(), |
+ static_cast<int>(frame->rotation()), texture_id, |
+ sampling_matrix, javaShallowCopy(frame)); |
+#endif |
} |
JNIEnv* jni() { |
@@ -1353,10 +1380,12 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnectionFactory)( |
options = ParseOptionsFromJava(jni, joptions); |
} |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
if (video_hw_acceleration_enabled) { |
encoder_factory = new MediaCodecVideoEncoderFactory(); |
decoder_factory = new MediaCodecVideoDecoderFactory(); |
} |
+#endif |
// Do not create network_monitor_factory only if the options are |
// provided and disable_network_monitor therein is set to true. |
if (!(has_options && options.disable_network_monitor)) { |
@@ -1416,6 +1445,7 @@ JOW(jlong, PeerConnectionFactory_nativeCreateLocalMediaStream)( |
JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) |
(JNIEnv* jni, jclass, jlong native_factory, jobject j_egl_context, |
jboolean is_screencast) { |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
OwnedFactoryAndThreads* factory = |
reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
@@ -1427,6 +1457,9 @@ JOW(jlong, PeerConnectionFactory_nativeCreateVideoSource) |
factory->worker_thread(), source); |
return (jlong)proxy_source.release(); |
+#else |
+ return (jlong)0; |
+#endif |
} |
JOW(void, PeerConnectionFactory_nativeInitializeVideoCapturer) |
@@ -1436,6 +1469,7 @@ JOW(void, PeerConnectionFactory_nativeInitializeVideoCapturer) |
jobject j_video_capturer, |
jlong native_source, |
jobject j_frame_observer) { |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
LOG(LS_INFO) << "PeerConnectionFactory_nativeInitializeVideoCapturer"; |
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory( |
factoryFromJava(native_factory)); |
@@ -1455,6 +1489,7 @@ JOW(void, PeerConnectionFactory_nativeInitializeVideoCapturer) |
: nullptr, |
j_application_context, j_frame_observer); |
CHECK_EXCEPTION(jni) << "error during VideoCapturer.initialize()"; |
+#endif |
} |
JOW(jlong, PeerConnectionFactory_nativeCreateVideoTrack)( |
@@ -1529,6 +1564,7 @@ JOW(void, PeerConnectionFactory_nativeSetOptions)( |
JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( |
JNIEnv* jni, jclass, jlong native_factory, jobject local_egl_context, |
jobject remote_egl_context) { |
+#if defined(HAVE_WEBRTC_VOICE) && defined(HAVE_WEBRTC_VIDEO) |
OwnedFactoryAndThreads* owned_factory = |
reinterpret_cast<OwnedFactoryAndThreads*>(native_factory); |
@@ -1551,6 +1587,7 @@ JOW(void, PeerConnectionFactory_nativeSetVideoHwAccelerationOptions)( |
LOG(LS_INFO) << "Set EGL context for HW decoding."; |
decoder_factory->SetEGLContext(jni, remote_egl_context); |
} |
+#endif |
} |
static PeerConnectionInterface::IceTransportsType |