Index: Source/modules/mediastream/RTCPeerConnection.cpp |
diff --git a/Source/modules/mediastream/RTCPeerConnection.cpp b/Source/modules/mediastream/RTCPeerConnection.cpp |
index 51a5d99241a3b761e296aeab803183121f94da90..b91c40dfce8e8317a49b8c44d8ddd87d7c42be80 100644 |
--- a/Source/modules/mediastream/RTCPeerConnection.cpp |
+++ b/Source/modules/mediastream/RTCPeerConnection.cpp |
@@ -241,6 +241,8 @@ RTCPeerConnection* RTCPeerConnection::create(ExecutionContext* context, const Di |
RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration* configuration, WebMediaConstraints constraints, ExceptionState& exceptionState) |
: ActiveDOMObject(context) |
+ , m_pendingLocalDescription(nullptr) |
+ , m_pendingRemoteDescription(nullptr) |
, m_signalingState(SignalingStateStable) |
, m_iceGatheringState(ICEGatheringStateNew) |
, m_iceConnectionState(ICEConnectionStateNew) |
@@ -275,6 +277,8 @@ RTCPeerConnection::RTCPeerConnection(ExecutionContext* context, RTCConfiguration |
exceptionState.throwDOMException(NotSupportedError, "Failed to initialize native PeerConnection."); |
return; |
} |
+ m_localDescription = RTCSessionDescription::create(m_peerHandler->localDescription()); |
+ m_remoteDescription = RTCSessionDescription::create(m_peerHandler->remoteDescription()); |
} |
RTCPeerConnection::~RTCPeerConnection() |
@@ -335,15 +339,16 @@ void RTCPeerConnection::setLocalDescription(RTCSessionDescription* sessionDescri |
RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), this, successCallback, errorCallback); |
m_peerHandler->setLocalDescription(request, sessionDescription->webSessionDescription()); |
+ m_pendingLocalDescription = sessionDescription; |
} |
-RTCSessionDescription* RTCPeerConnection::localDescription(ExceptionState& exceptionState) |
+RTCSessionDescription* RTCPeerConnection::localDescription() |
{ |
- WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescription(); |
- if (webSessionDescription.isNull()) |
+ if (!m_peerHandler || m_peerHandler->localDescription().isNull()) |
return nullptr; |
- return RTCSessionDescription::create(webSessionDescription); |
+ updateLocalSessionDescriptionIfNeeded(false); |
+ return m_localDescription; |
} |
void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescription, VoidCallback* successCallback, RTCErrorCallback* errorCallback, ExceptionState& exceptionState) |
@@ -358,15 +363,16 @@ void RTCPeerConnection::setRemoteDescription(RTCSessionDescription* sessionDescr |
RTCVoidRequest* request = RTCVoidRequestImpl::create(executionContext(), this, successCallback, errorCallback); |
m_peerHandler->setRemoteDescription(request, sessionDescription->webSessionDescription()); |
+ m_pendingRemoteDescription = sessionDescription; |
} |
-RTCSessionDescription* RTCPeerConnection::remoteDescription(ExceptionState& exceptionState) |
+RTCSessionDescription* RTCPeerConnection::remoteDescription() |
{ |
- WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescription(); |
- if (webSessionDescription.isNull()) |
+ if (!m_peerHandler || m_peerHandler->remoteDescription().isNull()) |
return nullptr; |
- return RTCSessionDescription::create(webSessionDescription); |
+ updateRemoteSessionDescriptionIfNeeded(false); |
+ return m_remoteDescription; |
} |
void RTCPeerConnection::updateIce(const Dictionary& rtcConfiguration, const Dictionary& mediaConstraints, ExceptionState& exceptionState) |
@@ -627,6 +633,44 @@ void RTCPeerConnection::close(ExceptionState& exceptionState) |
closeInternal(); |
} |
+void RTCPeerConnection::updateLocalSessionDescriptionIfNeeded(bool pending) |
+{ |
+ if (!m_peerHandler) |
+ return; |
+ WebRTCSessionDescription webSessionDescription = m_peerHandler->localDescription(); |
+ if (webSessionDescription.isNull()) |
+ return; |
+ |
+ if (pending) { |
Jens Widell
2015/05/05 06:31:20
This code path has essentially nothing in common w
changbin
2015/05/05 07:02:29
Therefore, your proposal would be,
1. Move out 'if
Jens Widell
2015/05/05 07:17:21
Correct.
Though 2 is somewhat optional. Keeping t
|
+ m_localDescription = m_pendingLocalDescription; |
+ return; |
+ } |
+ |
+ if (!m_localDescription || m_localDescription->webSessionDescription().isNull() |
+ || m_localDescription->webSessionDescription() != webSessionDescription) { |
+ m_localDescription = RTCSessionDescription::create(webSessionDescription); |
+ } |
+} |
+ |
+void RTCPeerConnection::updateRemoteSessionDescriptionIfNeeded(bool pending) |
+{ |
+ if (!m_peerHandler) |
+ return; |
+ WebRTCSessionDescription webSessionDescription = m_peerHandler->remoteDescription(); |
+ if (webSessionDescription.isNull()) |
+ return; |
+ |
+ if (pending) { |
+ m_remoteDescription = m_pendingRemoteDescription; |
+ return; |
+ } |
+ |
+ if (!m_remoteDescription || m_remoteDescription->webSessionDescription().isNull() |
+ || m_remoteDescription->webSessionDescription() != webSessionDescription) { |
+ m_remoteDescription = RTCSessionDescription::create(webSessionDescription); |
+ } |
+} |
+ |
void RTCPeerConnection::negotiationNeeded() |
{ |
ASSERT(!m_closed); |
@@ -824,6 +868,10 @@ DEFINE_TRACE(RTCPeerConnection) |
visitor->trace(m_localStreams); |
visitor->trace(m_remoteStreams); |
visitor->trace(m_dataChannels); |
+ visitor->trace(m_localDescription); |
+ visitor->trace(m_remoteDescription); |
+ visitor->trace(m_pendingLocalDescription); |
+ visitor->trace(m_pendingRemoteDescription); |
#if ENABLE(OILPAN) |
visitor->trace(m_scheduledEvents); |
#endif |