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:
@ -209,7 +209,9 @@ public class PeerConnection {
|
||||
|
||||
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) {
|
||||
return nativeAddIceCandidate(candidate.sdpMid, candidate.sdpMLineIndex, candidate.sdp);
|
||||
@ -311,6 +313,8 @@ public class PeerConnection {
|
||||
|
||||
private static native void freeObserver(long nativeObserver);
|
||||
|
||||
public native boolean nativeSetConfiguration(RTCConfiguration config, long nativeObserver);
|
||||
|
||||
private native boolean nativeAddIceCandidate(
|
||||
String sdpMid, int sdpMLineIndex, String iceCandidateSdp);
|
||||
|
||||
|
||||
@ -1810,8 +1810,9 @@ JOW(jlong, PeerConnectionFactory_nativeCreatePeerConnection)(
|
||||
|
||||
PCOJava* observer = reinterpret_cast<PCOJava*>(observer_p);
|
||||
observer->SetConstraints(new ConstraintsWrapper(jni, j_constraints));
|
||||
rtc::scoped_refptr<PeerConnectionInterface> pc(f->CreatePeerConnection(
|
||||
rtc_config, observer->constraints(), NULL, NULL, observer));
|
||||
CopyConstraintsIntoRtcConfiguration(observer->constraints(), &rtc_config);
|
||||
rtc::scoped_refptr<PeerConnectionInterface> pc(
|
||||
f->CreatePeerConnection(rtc_config, nullptr, nullptr, observer));
|
||||
return (jlong)pc.release();
|
||||
}
|
||||
|
||||
@ -1926,11 +1927,15 @@ JOW(void, PeerConnection_setRemoteDescription)(
|
||||
observer, JavaSdpToNativeSdp(jni, j_sdp));
|
||||
}
|
||||
|
||||
JOW(jboolean, PeerConnection_setConfiguration)(
|
||||
JNIEnv* jni, jobject j_pc, jobject j_rtc_config) {
|
||||
JOW(jboolean, PeerConnection_nativeSetConfiguration)(
|
||||
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::RTCConfigurationType::kAggressive);
|
||||
JavaRTCConfigurationToJsepRTCConfiguration(jni, j_rtc_config, &rtc_config);
|
||||
CopyConstraintsIntoRtcConfiguration(observer->constraints(), &rtc_config);
|
||||
return ExtractNativePC(jni, j_pc)->SetConfiguration(rtc_config);
|
||||
}
|
||||
|
||||
|
||||
@ -207,6 +207,7 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
|
||||
NSMutableArray<RTCMediaStream *> *_localStreams;
|
||||
std::unique_ptr<webrtc::PeerConnectionDelegateAdapter> _observer;
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> _peerConnection;
|
||||
std::unique_ptr<webrtc::MediaConstraints> _nativeConstraints;
|
||||
BOOL _hasStartedRtcEventLog;
|
||||
}
|
||||
|
||||
@ -224,11 +225,11 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
|
||||
}
|
||||
if (self = [super init]) {
|
||||
_observer.reset(new webrtc::PeerConnectionDelegateAdapter(self));
|
||||
std::unique_ptr<webrtc::MediaConstraints> nativeConstraints =
|
||||
constraints.nativeConstraints;
|
||||
_nativeConstraints = constraints.nativeConstraints;
|
||||
CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
|
||||
config.get());
|
||||
_peerConnection =
|
||||
factory.nativeFactory->CreatePeerConnection(*config,
|
||||
nativeConstraints.get(),
|
||||
nullptr,
|
||||
nullptr,
|
||||
_observer.get());
|
||||
@ -282,6 +283,8 @@ void PeerConnectionDelegateAdapter::OnIceCandidatesRemoved(
|
||||
if (!config) {
|
||||
return NO;
|
||||
}
|
||||
CopyConstraintsIntoRtcConfiguration(_nativeConstraints.get(),
|
||||
config.get());
|
||||
return _peerConnection->SetConfiguration(*config);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user