Revert of Adding PeerConnectionInterface::SetConfiguration method. (patchset #4 id:60001 of https://codereview.webrtc.org/1317353005/ )

Reason for revert:
Broke FYI bots because SetConfiguration is pure virtual and MockPeerConnectionImpl doesn't implement it. Need to reland with SetConfiguration not pure virtual.

Original issue's description:
> Adding PeerConnectionInterface::SetConfiguration method.
>
> Also updated the JNI and Objective-C bindings. Later, will have a CL to
> remove UpdateIce, which this method effectively replaces.
>
> BUG=webrtc:4945
>
> Committed: https://crrev.com/70702afbcb8418fe93747e7ed63bcbf5e56b90e9
> Cr-Commit-Position: refs/heads/master@{#10040}

TBR=guoweis@webrtc.org,pthatcher@webrtc.org
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4945

Review URL: https://codereview.webrtc.org/1361263002

Cr-Commit-Position: refs/heads/master@{#10041}
This commit is contained in:
deadbeef
2015-09-23 17:37:11 -07:00
committed by Commit bot
parent 70702afbcb
commit 7603c76ab0
8 changed files with 84 additions and 101 deletions

View File

@ -1360,10 +1360,13 @@ static void JavaIceServersToJsepIceServers(
CHECK_EXCEPTION(jni) << "error during CallBooleanMethod"; CHECK_EXCEPTION(jni) << "error during CallBooleanMethod";
} }
static void JavaRTCConfigurationToJsepRTCConfiguration( JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
JNIEnv* jni, JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config,
jobject j_rtc_config, jobject j_constraints, jlong observer_p) {
PeerConnectionInterface::RTCConfiguration* rtc_config) { rtc::scoped_refptr<PeerConnectionFactoryInterface> f(
reinterpret_cast<PeerConnectionFactoryInterface*>(
factoryFromJava(factory)));
jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config); jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
jfieldID j_ice_transports_type_id = GetFieldID( jfieldID j_ice_transports_type_id = GetFieldID(
@ -1402,38 +1405,26 @@ static void JavaRTCConfigurationToJsepRTCConfiguration(
jfieldID j_ice_connection_receiving_timeout_id = jfieldID j_ice_connection_receiving_timeout_id =
GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I"); GetFieldID(jni, j_rtc_config_class, "iceConnectionReceivingTimeout", "I");
rtc_config->type =
JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type);
rtc_config->bundle_policy =
JavaBundlePolicyToNativeType(jni, j_bundle_policy);
rtc_config->rtcp_mux_policy =
JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy);
rtc_config->tcp_candidate_policy =
JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy);
JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config->servers);
rtc_config->audio_jitter_buffer_max_packets =
GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id);
rtc_config->audio_jitter_buffer_fast_accelerate = GetBooleanField(
jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id);
rtc_config->ice_connection_receiving_timeout =
GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id);
}
JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
JNIEnv *jni, jclass, jlong factory, jobject j_rtc_config,
jobject j_constraints, jlong observer_p) {
rtc::scoped_refptr<PeerConnectionFactoryInterface> f(
reinterpret_cast<PeerConnectionFactoryInterface*>(
factoryFromJava(factory)));
PeerConnectionInterface::RTCConfiguration rtc_config;
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
jclass j_rtc_config_class = GetObjectClass(jni, j_rtc_config);
jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType", jfieldID j_key_type_id = GetFieldID(jni, j_rtc_config_class, "keyType",
"Lorg/webrtc/PeerConnection$KeyType;"); "Lorg/webrtc/PeerConnection$KeyType;");
jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id); jobject j_key_type = GetObjectField(jni, j_rtc_config, j_key_type_id);
PeerConnectionInterface::RTCConfiguration rtc_config;
rtc_config.type =
JavaIceTransportsTypeToNativeType(jni, j_ice_transports_type);
rtc_config.bundle_policy = JavaBundlePolicyToNativeType(jni, j_bundle_policy);
rtc_config.rtcp_mux_policy =
JavaRtcpMuxPolicyToNativeType(jni, j_rtcp_mux_policy);
rtc_config.tcp_candidate_policy =
JavaTcpCandidatePolicyToNativeType(jni, j_tcp_candidate_policy);
JavaIceServersToJsepIceServers(jni, j_ice_servers, &rtc_config.servers);
rtc_config.audio_jitter_buffer_max_packets =
GetIntField(jni, j_rtc_config, j_audio_jitter_buffer_max_packets_id);
rtc_config.audio_jitter_buffer_fast_accelerate = GetBooleanField(
jni, j_rtc_config, j_audio_jitter_buffer_fast_accelerate_id);
rtc_config.ice_connection_receiving_timeout =
GetIntField(jni, j_rtc_config, j_ice_connection_receiving_timeout_id);
// Create ECDSA certificate. // Create ECDSA certificate.
if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) { if (JavaKeyTypeToNativeType(jni, j_key_type) == rtc::KT_ECDSA) {
scoped_ptr<rtc::SSLIdentity> ssl_identity( scoped_ptr<rtc::SSLIdentity> ssl_identity(
@ -1565,11 +1556,13 @@ JOW(void, PeerConnection_setRemoteDescription)(
observer, JavaSdpToNativeSdp(jni, j_sdp)); observer, JavaSdpToNativeSdp(jni, j_sdp));
} }
JOW(jboolean, PeerConnection_setConfiguration)( JOW(jboolean, PeerConnection_updateIce)(
JNIEnv* jni, jobject j_pc, jobject j_rtc_config) { JNIEnv* jni, jobject j_pc, jobject j_ice_servers, jobject j_constraints) {
PeerConnectionInterface::RTCConfiguration rtc_config; PeerConnectionInterface::IceServers ice_servers;
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); JavaIceServersToJsepIceServers(jni, j_ice_servers, &ice_servers);
return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config); scoped_ptr<ConstraintsWrapper> constraints(
new ConstraintsWrapper(jni, j_constraints));
return ExtractNativePC(jni, j_pc)->UpdateIce(ice_servers, constraints.get());
} }
JOW(jboolean, PeerConnection_nativeAddIceCandidate)( JOW(jboolean, PeerConnection_nativeAddIceCandidate)(

View File

@ -190,7 +190,8 @@ public class PeerConnection {
public native void setRemoteDescription( public native void setRemoteDescription(
SdpObserver observer, SessionDescription sdp); SdpObserver observer, SessionDescription sdp);
public native boolean setConfiguration(RTCConfiguration config); public native boolean updateIce(
List<IceServer> iceServers, MediaConstraints constraints);
public boolean addIceCandidate(IceCandidate candidate) { public boolean addIceCandidate(IceCandidate candidate) {
return nativeAddIceCandidate( return nativeAddIceCandidate(

View File

@ -208,9 +208,13 @@ class RTCStatsObserver : public StatsObserver {
self.peerConnection->SetRemoteDescription(observer, sdp.sessionDescription); self.peerConnection->SetRemoteDescription(observer, sdp.sessionDescription);
} }
- (BOOL)setConfiguration:(RTCConfiguration *)configuration { - (BOOL)updateICEServers:(NSArray*)servers
return self.peerConnection->SetConfiguration( constraints:(RTCMediaConstraints*)constraints {
configuration.nativeConfiguration); webrtc::PeerConnectionInterface::IceServers iceServers;
for (RTCICEServer* server in servers) {
iceServers.push_back(server.iceServer);
}
return self.peerConnection->UpdateIce(iceServers, constraints.constraints);
} }
- (RTCSessionDescription*)localDescription { - (RTCSessionDescription*)localDescription {

View File

@ -27,7 +27,6 @@
#import "RTCPeerConnectionDelegate.h" #import "RTCPeerConnectionDelegate.h"
@class RTCConfiguration;
@class RTCDataChannel; @class RTCDataChannel;
@class RTCDataChannelInit; @class RTCDataChannelInit;
@class RTCICECandidate; @class RTCICECandidate;
@ -98,12 +97,10 @@
setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate setRemoteDescriptionWithDelegate:(id<RTCSessionDescriptionDelegate>)delegate
sessionDescription:(RTCSessionDescription *)sdp; sessionDescription:(RTCSessionDescription *)sdp;
// Sets the PeerConnection's global configuration to |configuration|. // Restarts or updates the ICE Agent process of gathering local candidates
// Any changes to STUN/TURN servers or ICE candidate policy will affect the // and pinging remote candidates.
// next gathering phase, and cause the next call to createOffer to generate - (BOOL)updateICEServers:(NSArray *)servers
// new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies constraints:(RTCMediaConstraints *)constraints;
// cannot be changed with this method.
- (BOOL)setConfiguration:(RTCConfiguration *)configuration;
// Provides a remote candidate to the ICE Agent. // Provides a remote candidate to the ICE Agent.
- (BOOL)addICECandidate:(RTCICECandidate *)candidate; - (BOOL)addICECandidate:(RTCICECandidate *)candidate;

View File

@ -658,7 +658,7 @@ bool PeerConnection::UpdateIce(const IceServers& configuration,
return false; return false;
} }
bool PeerConnection::SetConfiguration(const RTCConfiguration& config) { bool PeerConnection::UpdateIce(const RTCConfiguration& config) {
if (port_allocator_) { if (port_allocator_) {
std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns; std::vector<PortAllocatorFactoryInterface::StunConfiguration> stuns;
std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns; std::vector<PortAllocatorFactoryInterface::TurnConfiguration> turns;
@ -675,8 +675,7 @@ bool PeerConnection::SetConfiguration(const RTCConfiguration& config) {
rtc::SocketAddress stun_addr; rtc::SocketAddress stun_addr;
if (!stun_hosts.empty()) { if (!stun_hosts.empty()) {
stun_addr = stun_hosts.front(); stun_addr = stun_hosts.front();
LOG(LS_INFO) << "SetConfiguration: StunServer Address: " LOG(LS_INFO) << "UpdateIce: StunServer Address: " << stun_addr.ToString();
<< stun_addr.ToString();
} }
for (size_t i = 0; i < turns.size(); ++i) { for (size_t i = 0; i < turns.size(); ++i) {
@ -688,7 +687,7 @@ bool PeerConnection::SetConfiguration(const RTCConfiguration& config) {
relay_server.ports.push_back(cricket::ProtocolAddress( relay_server.ports.push_back(cricket::ProtocolAddress(
turns[i].server, protocol, turns[i].secure)); turns[i].server, protocol, turns[i].secure));
relay_server.credentials = credentials; relay_server.credentials = credentials;
LOG(LS_INFO) << "SetConfiguration: TurnServer Address: " LOG(LS_INFO) << "UpdateIce: TurnServer Address: "
<< turns[i].server.ToString(); << turns[i].server.ToString();
} else { } else {
LOG(LS_WARNING) << "Ignoring TURN server " << turns[i].server << ". " LOG(LS_WARNING) << "Ignoring TURN server " << turns[i].server << ". "

View File

@ -64,59 +64,59 @@ class PeerConnection : public PeerConnectionInterface,
PortAllocatorFactoryInterface* allocator_factory, PortAllocatorFactoryInterface* allocator_factory,
rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
PeerConnectionObserver* observer); PeerConnectionObserver* observer);
rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams();
rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams();
bool AddStream(MediaStreamInterface* local_stream) override; virtual bool AddStream(MediaStreamInterface* local_stream);
void RemoveStream(MediaStreamInterface* local_stream) override; virtual void RemoveStream(MediaStreamInterface* local_stream);
rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( virtual rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
AudioTrackInterface* track) override; AudioTrackInterface* track);
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label, const std::string& label,
const DataChannelInit* config) override; const DataChannelInit* config);
bool GetStats(StatsObserver* observer, virtual bool GetStats(StatsObserver* observer,
webrtc::MediaStreamTrackInterface* track, webrtc::MediaStreamTrackInterface* track,
StatsOutputLevel level) override; StatsOutputLevel level);
SignalingState signaling_state() override; virtual SignalingState signaling_state();
// TODO(bemasc): Remove ice_state() when callers are removed. // TODO(bemasc): Remove ice_state() when callers are removed.
IceState ice_state() override; virtual IceState ice_state();
IceConnectionState ice_connection_state() override; virtual IceConnectionState ice_connection_state();
IceGatheringState ice_gathering_state() override; virtual IceGatheringState ice_gathering_state();
const SessionDescriptionInterface* local_description() const override; virtual const SessionDescriptionInterface* local_description() const;
const SessionDescriptionInterface* remote_description() const override; virtual const SessionDescriptionInterface* remote_description() const;
// JSEP01 // JSEP01
void CreateOffer(CreateSessionDescriptionObserver* observer, virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override; const MediaConstraintsInterface* constraints);
void CreateOffer(CreateSessionDescriptionObserver* observer, virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override; const RTCOfferAnswerOptions& options);
void CreateAnswer(CreateSessionDescriptionObserver* observer, virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
const MediaConstraintsInterface* constraints) override; const MediaConstraintsInterface* constraints);
void SetLocalDescription(SetSessionDescriptionObserver* observer, virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) override; SessionDescriptionInterface* desc);
void SetRemoteDescription(SetSessionDescriptionObserver* observer, virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) override; SessionDescriptionInterface* desc);
// TODO(deadbeef) : Deprecated version, remove after all clients are updated. // TODO(mallinath) : Deprecated version, remove after all clients are updated.
bool UpdateIce(const IceServers& configuration, virtual bool UpdateIce(const IceServers& configuration,
const MediaConstraintsInterface* constraints) override; const MediaConstraintsInterface* constraints);
bool SetConfiguration( virtual bool UpdateIce(
const PeerConnectionInterface::RTCConfiguration& config) override; const PeerConnectionInterface::RTCConfiguration& config);
bool AddIceCandidate(const IceCandidateInterface* candidate) override; virtual bool AddIceCandidate(const IceCandidateInterface* candidate);
void RegisterUMAObserver(UMAObserver* observer) override; virtual void RegisterUMAObserver(UMAObserver* observer);
void Close() override; virtual void Close();
protected: protected:
~PeerConnection() override; virtual ~PeerConnection();
private: private:
// Implements MessageHandler. // Implements MessageHandler.
void OnMessage(rtc::Message* msg) override; virtual void OnMessage(rtc::Message* msg);
// Implements MediaStreamSignalingObserver. // Implements MediaStreamSignalingObserver.
void OnAddRemoteStream(MediaStreamInterface* stream) override; void OnAddRemoteStream(MediaStreamInterface* stream) override;

View File

@ -359,16 +359,8 @@ class PeerConnectionInterface : public rtc::RefCountInterface {
SessionDescriptionInterface* desc) = 0; SessionDescriptionInterface* desc) = 0;
// Restarts or updates the ICE Agent process of gathering local candidates // Restarts or updates the ICE Agent process of gathering local candidates
// and pinging remote candidates. // and pinging remote candidates.
// TODO(deadbeef): Remove once Chrome is moved over to SetConfiguration.
virtual bool UpdateIce(const IceServers& configuration, virtual bool UpdateIce(const IceServers& configuration,
const MediaConstraintsInterface* constraints) = 0; const MediaConstraintsInterface* constraints) = 0;
// Sets the PeerConnection's global configuration to |config|.
// Any changes to STUN/TURN servers or ICE candidate policy will affect the
// next gathering phase, and cause the next call to createOffer to generate
// new ICE credentials. Note that the BUNDLE and RTCP-multiplexing policies
// cannot be changed with this method.
virtual bool SetConfiguration(
const PeerConnectionInterface::RTCConfiguration& config) = 0;
// Provides a remote candidate to the ICE Agent. // Provides a remote candidate to the ICE Agent.
// A copy of the |candidate| will be created and added to the remote // A copy of the |candidate| will be created and added to the remote
// description. So the caller of this method still has the ownership of the // description. So the caller of this method still has the ownership of the

View File

@ -60,9 +60,6 @@ BEGIN_PROXY_MAP(PeerConnection)
SessionDescriptionInterface*) SessionDescriptionInterface*)
PROXY_METHOD2(bool, UpdateIce, const IceServers&, PROXY_METHOD2(bool, UpdateIce, const IceServers&,
const MediaConstraintsInterface*) const MediaConstraintsInterface*)
PROXY_METHOD1(bool,
SetConfiguration,
const PeerConnectionInterface::RTCConfiguration&);
PROXY_METHOD1(bool, AddIceCandidate, const IceCandidateInterface*) PROXY_METHOD1(bool, AddIceCandidate, const IceCandidateInterface*)
PROXY_METHOD1(void, RegisterUMAObserver, UMAObserver*) PROXY_METHOD1(void, RegisterUMAObserver, UMAObserver*)
PROXY_METHOD0(SignalingState, signaling_state) PROXY_METHOD0(SignalingState, signaling_state)