Allow injection of network controller factory in Java.

Bug: webrtc:9155
Change-Id: I3303a5a9d13a2b7028c24ceede4565b0f4350d7d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/133570
Commit-Queue: Sebastian Jansson <srte@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27686}
This commit is contained in:
Sebastian Jansson 2019-04-18 13:40:56 +02:00 committed by Commit Bot
parent 76723ae836
commit ad60afbd0f
4 changed files with 40 additions and 2 deletions

View file

@ -295,6 +295,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/NetworkControllerFactoryFactory.java",
"api/org/webrtc/NetworkStatePredictorFactoryFactory.java", "api/org/webrtc/NetworkStatePredictorFactoryFactory.java",
"api/org/webrtc/MediaTransportFactoryFactory.java", "api/org/webrtc/MediaTransportFactoryFactory.java",
"api/org/webrtc/FrameDecryptor.java", "api/org/webrtc/FrameDecryptor.java",

View file

@ -0,0 +1,20 @@
/*
* Copyright 2019 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::NetworkControllerFactory instances. */
public interface NetworkControllerFactoryFactory {
/**
* Dynamically allocates a webrtc::NetworkControllerFactory instance and returns a pointer to
* it. The caller takes ownership of the object.
*/
public long createNativeNetworkControllerFactory();
}

View file

@ -173,6 +173,7 @@ public class PeerConnectionFactory {
@Nullable private VideoDecoderFactory videoDecoderFactory; @Nullable private VideoDecoderFactory videoDecoderFactory;
@Nullable private AudioProcessingFactory audioProcessingFactory; @Nullable private AudioProcessingFactory audioProcessingFactory;
@Nullable private FecControllerFactoryFactoryInterface fecControllerFactoryFactory; @Nullable private FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
@Nullable private NetworkControllerFactoryFactory networkControllerFactoryFactory;
@Nullable private NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory; @Nullable private NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory;
@Nullable private MediaTransportFactoryFactory mediaTransportFactoryFactory; @Nullable private MediaTransportFactoryFactory mediaTransportFactoryFactory;
@ -233,6 +234,12 @@ public class PeerConnectionFactory {
return this; return this;
} }
public Builder setNetworkControllerFactoryFactory(
NetworkControllerFactoryFactory networkControllerFactoryFactory) {
this.networkControllerFactoryFactory = networkControllerFactoryFactory;
return this;
}
public Builder setNetworkStatePredictorFactoryFactory( public Builder setNetworkStatePredictorFactoryFactory(
NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory) { NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory) {
this.networkStatePredictorFactoryFactory = networkStatePredictorFactoryFactory; this.networkStatePredictorFactoryFactory = networkStatePredictorFactoryFactory;
@ -259,6 +266,9 @@ public class PeerConnectionFactory {
videoDecoderFactory, videoDecoderFactory,
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(), audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(), fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(),
networkControllerFactoryFactory == null
? 0
: networkControllerFactoryFactory.createNativeNetworkControllerFactory(),
networkStatePredictorFactoryFactory == null networkStatePredictorFactoryFactory == null
? 0 ? 0
: networkStatePredictorFactoryFactory.createNativeNetworkStatePredictorFactory(), : networkStatePredictorFactoryFactory.createNativeNetworkStatePredictorFactory(),
@ -585,8 +595,8 @@ public class PeerConnectionFactory {
Options options, long nativeAudioDeviceModule, long audioEncoderFactory, Options options, long nativeAudioDeviceModule, long audioEncoderFactory,
long audioDecoderFactory, VideoEncoderFactory encoderFactory, long audioDecoderFactory, VideoEncoderFactory encoderFactory,
VideoDecoderFactory decoderFactory, long nativeAudioProcessor, VideoDecoderFactory decoderFactory, long nativeAudioProcessor,
long nativeFecControllerFactory, long nativeNetworkStatePredictorFactory, long nativeFecControllerFactory, long nativeNetworkControllerFactory,
long mediaTransportFactory); long nativeNetworkStatePredictorFactory, 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,

View file

@ -253,6 +253,8 @@ ScopedJavaLocalRef<jobject> CreatePeerConnectionFactoryForJava(
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<NetworkControllerFactoryInterface>
network_controller_factory,
std::unique_ptr<NetworkStatePredictorFactoryInterface> std::unique_ptr<NetworkStatePredictorFactoryInterface>
network_state_predictor_factory, network_state_predictor_factory,
std::unique_ptr<MediaTransportFactory> media_transport_factory) { std::unique_ptr<MediaTransportFactory> media_transport_factory) {
@ -308,6 +310,8 @@ ScopedJavaLocalRef<jobject> CreatePeerConnectionFactoryForJava(
dependencies.call_factory = std::move(call_factory); dependencies.call_factory = std::move(call_factory);
dependencies.event_log_factory = std::move(rtc_event_log_factory); dependencies.event_log_factory = std::move(rtc_event_log_factory);
dependencies.fec_controller_factory = std::move(fec_controller_factory); dependencies.fec_controller_factory = std::move(fec_controller_factory);
dependencies.network_controller_factory =
std::move(network_controller_factory);
dependencies.network_state_predictor_factory = dependencies.network_state_predictor_factory =
std::move(network_state_predictor_factory); std::move(network_state_predictor_factory);
dependencies.media_transport_factory = std::move(media_transport_factory); dependencies.media_transport_factory = std::move(media_transport_factory);
@ -339,6 +343,7 @@ JNI_PeerConnectionFactory_CreatePeerConnectionFactory(
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_network_controller_factory,
jlong native_network_state_predictor_factory, jlong native_network_state_predictor_factory,
jlong native_media_transport_factory) { jlong native_media_transport_factory) {
rtc::scoped_refptr<AudioProcessing> audio_processor = rtc::scoped_refptr<AudioProcessing> audio_processor =
@ -352,6 +357,8 @@ JNI_PeerConnectionFactory_CreatePeerConnectionFactory(
audio_processor ? audio_processor : CreateAudioProcessing(), audio_processor ? audio_processor : CreateAudioProcessing(),
TakeOwnershipOfUniquePtr<FecControllerFactoryInterface>( TakeOwnershipOfUniquePtr<FecControllerFactoryInterface>(
native_fec_controller_factory), native_fec_controller_factory),
TakeOwnershipOfUniquePtr<NetworkControllerFactoryInterface>(
native_network_controller_factory),
TakeOwnershipOfUniquePtr<NetworkStatePredictorFactoryInterface>( TakeOwnershipOfUniquePtr<NetworkStatePredictorFactoryInterface>(
native_network_state_predictor_factory), native_network_state_predictor_factory),
TakeOwnershipOfUniquePtr<MediaTransportFactory>( TakeOwnershipOfUniquePtr<MediaTransportFactory>(