Merge RTCConfiguration with RTCMediaConstraints in Java/Obj-C wrappers.

The intention of SetConfiguration is that it modifies the configuration,
while keeping the constraints passed into CreatePeerConnection. Right
now that's now happening. See bug for more explanation.

BUG=webrtc:6942

Review-Url: https://codereview.webrtc.org/2603653002
Cr-Commit-Position: refs/heads/master@{#15974}
This commit is contained in:
deadbeef
2017-01-09 16:05:28 -08:00
committed by Commit bot
parent 953c2cea5e
commit 5d0b6d8da3
3 changed files with 20 additions and 8 deletions

View File

@ -209,7 +209,9 @@ public class PeerConnection {
public native void setRemoteDescription(SdpObserver observer, SessionDescription sdp); public native void setRemoteDescription(SdpObserver observer, SessionDescription sdp);
public native boolean setConfiguration(RTCConfiguration config); public boolean setConfiguration(RTCConfiguration config) {
return nativeSetConfiguration(config, nativeObserver);
}
public boolean addIceCandidate(IceCandidate candidate) { public boolean addIceCandidate(IceCandidate candidate) {
return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp); return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
@ -311,6 +313,8 @@ public class PeerConnection {
private static native void freeObserver(long nativeObserver); private static native void freeObserver(long nativeObserver);
public native boolean nativeSetConfiguration(RTCConfiguration config, long nativeObserver);
private native boolean nativeAddIceCandidate( private native boolean nativeAddIceCandidate(
String sdpMid, int sdpMLineIndex, String iceCandidateSdp); String sdpMid, int sdpMLineIndex, String iceCandidateSdp);

View File

@ -1810,8 +1810,9 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p); PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p);
observer->SetConstraints(new ConstraintsWrapper(jni, j_constraints)); observer->SetConstraints(new ConstraintsWrapper(jni, j_constraints));
rtc::scoped_refptr<PeerConnectionInterface> pc(f->CreatePeerConnection( CopyConstraintsIntoRtcConfiguration(observer->constraints(), &rtc_config);
rtc_config, observer->constraints(), NULL, NULL, observer)); rtc::scoped_refptr<PeerConnectionInterface> pc(
f->CreatePeerConnection(rtc_config, nullptr, nullptr, observer));
return (jlong)pc.release(); return (jlong)pc.release();
} }
@ -1926,11 +1927,15 @@ JOW(void, PeerConnection_setRemoteDescription)(
observer, JavaSdpToNativeSdp(jni, j_sdp)); observer, JavaSdpToNativeSdp(jni, j_sdp));
} }
JOW(jboolean, PeerConnection_setConfiguration)( JOW(jboolean, PeerConnection_nativeSetConfiguration)(
JNIEnv* jni, jobject j_pc, jobject j_rtc_config) { JNIEnv* jni, jobject j_pc, jobject j_rtc_config, jlong native_observer) {
// Need to merge constraints into RTCConfiguration again, which are stored
// in the observer object.
PCOJava* observer = reinterpret_cast<PCOJava*>(native_observer);
PeerConnectionInterface::RTCConfiguration rtc_config( PeerConnectionInterface::RTCConfiguration rtc_config(
PeerConnectionInterface::RTCConfigurationType::kAggressive); PeerConnectionInterface::RTCConfigurationType::kAggressive);
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config); JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
CopyConstraintsIntoRtcConfiguration(observer->constraints(), &rtc_config);
return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config); return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
} }

View File

@ -207,6 +207,7 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
NSMutableArray<RTCMediaStream *> *_localStreams; NSMutableArray<RTCMediaStream *> *_localStreams;
std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer; std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection; rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
std::unique_ptr<webrtc::MediaConstraints> _nativeConstraints;
BOOL _hasStartedRtcEventLog; BOOL _hasStartedRtcEventLog;
} }
@ -224,11 +225,11 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
} }
if (self = [super init]) { if (self = [super init]) {
_observer.reset(new webrtc::PeerConnectionDelegateAdapter(self)); _observer.reset(new webrtc::PeerConnectionDelegateAdapter(self));
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints = _nativeConstraints = constraints.nativeConstraints;
constraints.nativeConstraints; CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
config.get());
_peerConnection = _peerConnection =
factory.nativeFactory->CreatePeerConnection(*config, factory.nativeFactory->CreatePeerConnection(*config,
nativeConstraints.get(),
nullptr, nullptr,
nullptr, nullptr,
_observer.get()); _observer.get());
@ -282,6 +283,8 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
if (!config) { if (!config) {
return NO; return NO;
} }
CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
config.get());
return _peerConnection->SetConfiguration(*config); return _peerConnection->SetConfiguration(*config);
} }