Add MediaTransportInterface factory to the Jni bindings
Java apps currently have no way of setting MediaTransportInterface on the PeerConnectionFactory. This change adds that ability. Bug: webrtc:9719 Change-Id: I312893a153b5b3d978912cba4db60cd97001c8f3 Reviewed-on: https://webrtc-review.googlesource.com/c/105740 Commit-Queue: Peter Slatala <psla@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25217}
This commit is contained in:
committed by
Commit Bot
parent
9b1d67982f
commit
4e5074e0d2
@ -279,6 +279,7 @@ if (is_android) {
|
|||||||
"api/org/webrtc/DataChannel.java",
|
"api/org/webrtc/DataChannel.java",
|
||||||
"api/org/webrtc/DtmfSender.java",
|
"api/org/webrtc/DtmfSender.java",
|
||||||
"api/org/webrtc/FecControllerFactoryFactoryInterface.java",
|
"api/org/webrtc/FecControllerFactoryFactoryInterface.java",
|
||||||
|
"api/org/webrtc/MediaTransportFactoryFactory.java",
|
||||||
"api/org/webrtc/FrameDecryptor.java",
|
"api/org/webrtc/FrameDecryptor.java",
|
||||||
"api/org/webrtc/FrameEncryptor.java",
|
"api/org/webrtc/FrameEncryptor.java",
|
||||||
"api/org/webrtc/IceCandidate.java",
|
"api/org/webrtc/IceCandidate.java",
|
||||||
|
|||||||
22
sdk/android/api/org/webrtc/MediaTransportFactoryFactory.java
Normal file
22
sdk/android/api/org/webrtc/MediaTransportFactoryFactory.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
|
||||||
|
*
|
||||||
|
* Use of this source code is governed by a BSD-style license
|
||||||
|
* that can be found in the LICENSE file in the root of the source
|
||||||
|
* tree. An additional intellectual property rights grant can be found
|
||||||
|
* in the file PATENTS. All contributing project authors may
|
||||||
|
* be found in the AUTHORS file in the root of the source tree.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.webrtc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Factory for creating webrtc::MediaTransportFactory instances.
|
||||||
|
*/
|
||||||
|
public interface MediaTransportFactoryFactory {
|
||||||
|
/**
|
||||||
|
* Dynamically allocates a webrtc::MediaTransportFactory instance and returns a pointer to it.
|
||||||
|
* The caller takes ownership of the object.
|
||||||
|
*/
|
||||||
|
public long createNativeMediaTransportFactory();
|
||||||
|
}
|
||||||
@ -158,6 +158,7 @@ public class PeerConnectionFactory {
|
|||||||
private @Nullable VideoDecoderFactory decoderFactory;
|
private @Nullable VideoDecoderFactory decoderFactory;
|
||||||
private @Nullable AudioProcessingFactory audioProcessingFactory;
|
private @Nullable AudioProcessingFactory audioProcessingFactory;
|
||||||
private @Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
|
private @Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
|
||||||
|
private @Nullable MediaTransportFactoryFactory mediaTransportFactoryFactory;
|
||||||
|
|
||||||
private Builder() {}
|
private Builder() {}
|
||||||
|
|
||||||
@ -196,9 +197,16 @@ public class PeerConnectionFactory {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Sets a MediaTransportFactoryFactory for a PeerConnectionFactory. */
|
||||||
|
public Builder setMediaTransportFactoryFactory(
|
||||||
|
MediaTransportFactoryFactory mediaTransportFactoryFactory) {
|
||||||
|
this.mediaTransportFactoryFactory = mediaTransportFactoryFactory;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PeerConnectionFactory createPeerConnectionFactory() {
|
public PeerConnectionFactory createPeerConnectionFactory() {
|
||||||
return new PeerConnectionFactory(options, audioDeviceModule, encoderFactory, decoderFactory,
|
return new PeerConnectionFactory(options, audioDeviceModule, encoderFactory, decoderFactory,
|
||||||
audioProcessingFactory, fecControllerFactoryFactory);
|
audioProcessingFactory, fecControllerFactoryFactory, mediaTransportFactoryFactory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,13 +287,17 @@ public class PeerConnectionFactory {
|
|||||||
private PeerConnectionFactory(Options options, @Nullable AudioDeviceModule audioDeviceModule,
|
private PeerConnectionFactory(Options options, @Nullable AudioDeviceModule audioDeviceModule,
|
||||||
@Nullable VideoEncoderFactory encoderFactory, @Nullable VideoDecoderFactory decoderFactory,
|
@Nullable VideoEncoderFactory encoderFactory, @Nullable VideoDecoderFactory decoderFactory,
|
||||||
@Nullable AudioProcessingFactory audioProcessingFactory,
|
@Nullable AudioProcessingFactory audioProcessingFactory,
|
||||||
@Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory) {
|
@Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory,
|
||||||
|
@Nullable MediaTransportFactoryFactory mediaTransportFactoryFactory) {
|
||||||
checkInitializeHasBeenCalled();
|
checkInitializeHasBeenCalled();
|
||||||
nativeFactory = nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
|
nativeFactory = nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
|
||||||
audioDeviceModule == null ? 0 : audioDeviceModule.getNativeAudioDeviceModulePointer(),
|
audioDeviceModule == null ? 0 : audioDeviceModule.getNativeAudioDeviceModulePointer(),
|
||||||
encoderFactory, decoderFactory,
|
encoderFactory, decoderFactory,
|
||||||
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
|
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
|
||||||
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative());
|
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(),
|
||||||
|
mediaTransportFactoryFactory == null
|
||||||
|
? 0
|
||||||
|
: mediaTransportFactoryFactory.createNativeMediaTransportFactory());
|
||||||
if (nativeFactory == 0) {
|
if (nativeFactory == 0) {
|
||||||
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
|
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
|
||||||
}
|
}
|
||||||
@ -489,7 +501,7 @@ public class PeerConnectionFactory {
|
|||||||
private static native long nativeCreatePeerConnectionFactory(Context context, Options options,
|
private static native long nativeCreatePeerConnectionFactory(Context context, Options options,
|
||||||
long nativeAudioDeviceModule, VideoEncoderFactory encoderFactory,
|
long nativeAudioDeviceModule, VideoEncoderFactory encoderFactory,
|
||||||
VideoDecoderFactory decoderFactory, long nativeAudioProcessor,
|
VideoDecoderFactory decoderFactory, long nativeAudioProcessor,
|
||||||
long nativeFecControllerFactory);
|
long nativeFecControllerFactory, long mediaTransportFactory);
|
||||||
private static native long nativeCreatePeerConnection(long factory,
|
private static native long nativeCreatePeerConnection(long factory,
|
||||||
PeerConnection.RTCConfiguration rtcConfig, MediaConstraints constraints, long nativeObserver,
|
PeerConnection.RTCConfiguration rtcConfig, MediaConstraints constraints, long nativeObserver,
|
||||||
SSLCertificateVerifier sslCertificateVerifier);
|
SSLCertificateVerifier sslCertificateVerifier);
|
||||||
|
|||||||
@ -199,6 +199,9 @@ static void JNI_PeerConnectionFactory_ShutdownInternalTracer(
|
|||||||
rtc::tracing::ShutdownInternalTracer();
|
rtc::tracing::ShutdownInternalTracer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Following parameters are optional:
|
||||||
|
// |audio_device_module|, |jencoder_factory|, |jdecoder_factory|,
|
||||||
|
// |audio_processor|, |media_transport_factory|, |fec_controller_factory|.
|
||||||
jlong CreatePeerConnectionFactoryForJava(
|
jlong CreatePeerConnectionFactoryForJava(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
const JavaParamRef<jobject>& jcontext,
|
const JavaParamRef<jobject>& jcontext,
|
||||||
@ -207,7 +210,8 @@ jlong CreatePeerConnectionFactoryForJava(
|
|||||||
const JavaParamRef<jobject>& jencoder_factory,
|
const JavaParamRef<jobject>& jencoder_factory,
|
||||||
const JavaParamRef<jobject>& jdecoder_factory,
|
const JavaParamRef<jobject>& jdecoder_factory,
|
||||||
rtc::scoped_refptr<AudioProcessing> audio_processor,
|
rtc::scoped_refptr<AudioProcessing> audio_processor,
|
||||||
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory) {
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory,
|
||||||
|
std::unique_ptr<MediaTransportFactory> media_transport_factory) {
|
||||||
// talk/ assumes pretty widely that the current Thread is ThreadManager'd, but
|
// talk/ assumes pretty widely that the current Thread is ThreadManager'd, but
|
||||||
// ThreadManager only WrapCurrentThread()s the thread where it is first
|
// ThreadManager only WrapCurrentThread()s the thread where it is first
|
||||||
// created. Since the semantics around when auto-wrapping happens in
|
// created. Since the semantics around when auto-wrapping happens in
|
||||||
@ -257,12 +261,19 @@ jlong CreatePeerConnectionFactoryForJava(
|
|||||||
std::unique_ptr<VideoDecoderFactory>(
|
std::unique_ptr<VideoDecoderFactory>(
|
||||||
CreateVideoDecoderFactory(jni, jdecoder_factory)),
|
CreateVideoDecoderFactory(jni, jdecoder_factory)),
|
||||||
audio_mixer, audio_processor));
|
audio_mixer, audio_processor));
|
||||||
|
PeerConnectionFactoryDependencies dependencies;
|
||||||
|
dependencies.network_thread = network_thread.get();
|
||||||
|
dependencies.worker_thread = worker_thread.get();
|
||||||
|
dependencies.signaling_thread = signaling_thread.get();
|
||||||
|
dependencies.media_engine = std::move(media_engine);
|
||||||
|
dependencies.call_factory = std::move(call_factory);
|
||||||
|
dependencies.event_log_factory = std::move(rtc_event_log_factory);
|
||||||
|
dependencies.fec_controller_factory = std::move(fec_controller_factory);
|
||||||
|
dependencies.media_transport_factory = std::move(media_transport_factory);
|
||||||
|
|
||||||
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
|
rtc::scoped_refptr<PeerConnectionFactoryInterface> factory(
|
||||||
CreateModularPeerConnectionFactory(
|
CreateModularPeerConnectionFactory(std::move(dependencies)));
|
||||||
network_thread.get(), worker_thread.get(), signaling_thread.get(),
|
|
||||||
std::move(media_engine), std::move(call_factory),
|
|
||||||
std::move(rtc_event_log_factory), std::move(fec_controller_factory)));
|
|
||||||
RTC_CHECK(factory) << "Failed to create the peer connection factory; "
|
RTC_CHECK(factory) << "Failed to create the peer connection factory; "
|
||||||
<< "WebRTC/libjingle init likely failed on this device";
|
<< "WebRTC/libjingle init likely failed on this device";
|
||||||
// TODO(honghaiz): Maybe put the options as the argument of
|
// TODO(honghaiz): Maybe put the options as the argument of
|
||||||
@ -286,18 +297,21 @@ static jlong JNI_PeerConnectionFactory_CreatePeerConnectionFactory(
|
|||||||
const JavaParamRef<jobject>& jencoder_factory,
|
const JavaParamRef<jobject>& jencoder_factory,
|
||||||
const JavaParamRef<jobject>& jdecoder_factory,
|
const JavaParamRef<jobject>& jdecoder_factory,
|
||||||
jlong native_audio_processor,
|
jlong native_audio_processor,
|
||||||
jlong native_fec_controller_factory) {
|
jlong native_fec_controller_factory,
|
||||||
|
jlong native_media_transport_factory) {
|
||||||
rtc::scoped_refptr<AudioProcessing> audio_processor =
|
rtc::scoped_refptr<AudioProcessing> audio_processor =
|
||||||
reinterpret_cast<AudioProcessing*>(native_audio_processor);
|
reinterpret_cast<AudioProcessing*>(native_audio_processor);
|
||||||
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory(
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory(
|
||||||
reinterpret_cast<FecControllerFactoryInterface*>(
|
reinterpret_cast<FecControllerFactoryInterface*>(
|
||||||
native_fec_controller_factory));
|
native_fec_controller_factory));
|
||||||
|
std::unique_ptr<MediaTransportFactory> media_transport_factory(
|
||||||
|
reinterpret_cast<MediaTransportFactory*>(native_media_transport_factory));
|
||||||
return CreatePeerConnectionFactoryForJava(
|
return CreatePeerConnectionFactoryForJava(
|
||||||
jni, jcontext, joptions,
|
jni, jcontext, joptions,
|
||||||
reinterpret_cast<AudioDeviceModule*>(native_audio_device_module),
|
reinterpret_cast<AudioDeviceModule*>(native_audio_device_module),
|
||||||
jencoder_factory, jdecoder_factory,
|
jencoder_factory, jdecoder_factory,
|
||||||
audio_processor ? audio_processor : CreateAudioProcessing(),
|
audio_processor ? audio_processor : CreateAudioProcessing(),
|
||||||
std::move(fec_controller_factory));
|
std::move(fec_controller_factory), std::move(media_transport_factory));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void JNI_PeerConnectionFactory_FreeFactory(JNIEnv*,
|
static void JNI_PeerConnectionFactory_FreeFactory(JNIEnv*,
|
||||||
|
|||||||
Reference in New Issue
Block a user