Log Message
[WebRTC] Introduce asynchronous backend createOffer API https://bugs.webkit.org/show_bug.cgi?id=164365
Patch by Youenn Fablet <[email protected]> on 2016-11-03 Reviewed by Sam Weinig. Covered by existing tests. Removing PeerEndpointBackendClient as it is only RTCPeerConnection. This allows removing virtual for some functions. Moving MediaEndpointPeerClient::m_client to PeerEndpointBackendClient::m_peerConnection and making it a reference. Implementing createOffer at PeerConnectionBackend by splitting it in four sub-functions: - main createOffer, implemented at PeerConnectionBackend. - doCreateOffer implemented by subclasses (MediaEndpointPeerConnection). - createOfferSucceeded/createOfferFailed implemented by PeerConnectionBackend. * CMakeLists.txt: * Modules/mediastream/MediaEndpointPeerConnection.cpp: (WebCore::createMediaEndpointPeerConnection): (WebCore::MediaEndpointPeerConnection::MediaEndpointPeerConnection): (WebCore::MediaEndpointPeerConnection::doCreateOffer): (WebCore::MediaEndpointPeerConnection::createOfferTask): (WebCore::MediaEndpointPeerConnection::createAnswerTask): (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask): (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask): (WebCore::MediaEndpointPeerConnection::addIceCandidateTask): (WebCore::MediaEndpointPeerConnection::createReceiver): (WebCore::MediaEndpointPeerConnection::replaceTrack): (WebCore::MediaEndpointPeerConnection::replaceTrackTask): (WebCore::MediaEndpointPeerConnection::markAsNeedingNegotiation): (WebCore::MediaEndpointPeerConnection::localDescriptionTypeValidForState): (WebCore::MediaEndpointPeerConnection::remoteDescriptionTypeValidForState): (WebCore::MediaEndpointPeerConnection::gotIceCandidate): (WebCore::MediaEndpointPeerConnection::doneGatheringCandidates): (WebCore::MediaEndpointPeerConnection::iceTransportStateChanged): (WebCore::MediaEndpointPeerConnection::createOffer): Deleted. * Modules/mediastream/MediaEndpointPeerConnection.h: * Modules/mediastream/PeerConnectionBackend.cpp: (WebCore::PeerConnectionBackend::createOffer): (WebCore::PeerConnectionBackend::createOfferSucceeded): (WebCore::PeerConnectionBackend::createOfferFailed): (WebCore::createPeerConnectionBackend): Deleted. * Modules/mediastream/PeerConnectionBackend.h: (WebCore::PeerConnectionBackend::PeerConnectionBackend): (WebCore::PeerConnectionBackendClient::~PeerConnectionBackendClient): Deleted. * Modules/mediastream/RTCPeerConnection.cpp: (WebCore::RTCPeerConnection::RTCPeerConnection): * Modules/mediastream/RTCPeerConnection.h: * WebCore.xcodeproj/project.pbxproj:
Modified Paths
- trunk/Source/WebCore/CMakeLists.txt
- trunk/Source/WebCore/ChangeLog
- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp
- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h
- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h
- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
Diff
Modified: trunk/Source/WebCore/CMakeLists.txt (208378 => 208379)
--- trunk/Source/WebCore/CMakeLists.txt 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-11-04 06:34:46 UTC (rev 208379)
@@ -902,6 +902,7 @@
Modules/mediastream/MediaTrackConstraintSet.cpp
Modules/mediastream/MediaTrackConstraints.cpp
Modules/mediastream/NavigatorMediaDevices.cpp
+ Modules/mediastream/PeerConnectionBackend.cpp
Modules/mediastream/RTCConfiguration.cpp
Modules/mediastream/RTCDTMFSender.cpp
Modules/mediastream/RTCDTMFToneChangeEvent.cpp
Modified: trunk/Source/WebCore/ChangeLog (208378 => 208379)
--- trunk/Source/WebCore/ChangeLog 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/ChangeLog 2016-11-04 06:34:46 UTC (rev 208379)
@@ -1,3 +1,56 @@
+2016-11-03 Youenn Fablet <[email protected]>
+
+ [WebRTC] Introduce asynchronous backend createOffer API
+ https://bugs.webkit.org/show_bug.cgi?id=164365
+
+ Reviewed by Sam Weinig.
+
+ Covered by existing tests.
+
+ Removing PeerEndpointBackendClient as it is only RTCPeerConnection.
+ This allows removing virtual for some functions.
+
+ Moving MediaEndpointPeerClient::m_client to PeerEndpointBackendClient::m_peerConnection and making it a reference.
+
+ Implementing createOffer at PeerConnectionBackend by splitting it in four sub-functions:
+ - main createOffer, implemented at PeerConnectionBackend.
+ - doCreateOffer implemented by subclasses (MediaEndpointPeerConnection).
+ - createOfferSucceeded/createOfferFailed implemented by PeerConnectionBackend.
+
+ * CMakeLists.txt:
+ * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+ (WebCore::createMediaEndpointPeerConnection):
+ (WebCore::MediaEndpointPeerConnection::MediaEndpointPeerConnection):
+ (WebCore::MediaEndpointPeerConnection::doCreateOffer):
+ (WebCore::MediaEndpointPeerConnection::createOfferTask):
+ (WebCore::MediaEndpointPeerConnection::createAnswerTask):
+ (WebCore::MediaEndpointPeerConnection::setLocalDescriptionTask):
+ (WebCore::MediaEndpointPeerConnection::setRemoteDescriptionTask):
+ (WebCore::MediaEndpointPeerConnection::addIceCandidateTask):
+ (WebCore::MediaEndpointPeerConnection::createReceiver):
+ (WebCore::MediaEndpointPeerConnection::replaceTrack):
+ (WebCore::MediaEndpointPeerConnection::replaceTrackTask):
+ (WebCore::MediaEndpointPeerConnection::markAsNeedingNegotiation):
+ (WebCore::MediaEndpointPeerConnection::localDescriptionTypeValidForState):
+ (WebCore::MediaEndpointPeerConnection::remoteDescriptionTypeValidForState):
+ (WebCore::MediaEndpointPeerConnection::gotIceCandidate):
+ (WebCore::MediaEndpointPeerConnection::doneGatheringCandidates):
+ (WebCore::MediaEndpointPeerConnection::iceTransportStateChanged):
+ (WebCore::MediaEndpointPeerConnection::createOffer): Deleted.
+ * Modules/mediastream/MediaEndpointPeerConnection.h:
+ * Modules/mediastream/PeerConnectionBackend.cpp:
+ (WebCore::PeerConnectionBackend::createOffer):
+ (WebCore::PeerConnectionBackend::createOfferSucceeded):
+ (WebCore::PeerConnectionBackend::createOfferFailed):
+ (WebCore::createPeerConnectionBackend): Deleted.
+ * Modules/mediastream/PeerConnectionBackend.h:
+ (WebCore::PeerConnectionBackend::PeerConnectionBackend):
+ (WebCore::PeerConnectionBackendClient::~PeerConnectionBackendClient): Deleted.
+ * Modules/mediastream/RTCPeerConnection.cpp:
+ (WebCore::RTCPeerConnection::RTCPeerConnection):
+ * Modules/mediastream/RTCPeerConnection.h:
+ * WebCore.xcodeproj/project.pbxproj:
+
2016-11-03 Antti Koivisto <[email protected]>
REGRESSION (r207717): DumpRenderTree crashed in com.apple.WebCore: WebCore::Style::Scope::flushPendingUpdate + 16
Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp 2016-11-04 06:34:46 UTC (rev 208379)
@@ -45,6 +45,7 @@
#include "RTCIceCandidate.h"
#include "RTCIceCandidateEvent.h"
#include "RTCOfferAnswerOptions.h"
+#include "RTCPeerConnection.h"
#include "RTCRtpTransceiver.h"
#include "RTCTrackEvent.h"
#include "SDPProcessor.h"
@@ -63,9 +64,9 @@
// Size range from 22 to 256 ice-chars defined in RFC 5245.
static const size_t icePasswordSize = 24;
-static std::unique_ptr<PeerConnectionBackend> createMediaEndpointPeerConnection(PeerConnectionBackendClient* client)
+static std::unique_ptr<PeerConnectionBackend> createMediaEndpointPeerConnection(RTCPeerConnection& peerConnection)
{
- return std::unique_ptr<PeerConnectionBackend>(new MediaEndpointPeerConnection(client));
+ return std::unique_ptr<PeerConnectionBackend>(new MediaEndpointPeerConnection(peerConnection));
}
CreatePeerConnectionBackend PeerConnectionBackend::create = createMediaEndpointPeerConnection;
@@ -77,10 +78,10 @@
return base64Encode(randomValues, size);
}
-MediaEndpointPeerConnection::MediaEndpointPeerConnection(PeerConnectionBackendClient* client)
- : m_client(client)
+MediaEndpointPeerConnection::MediaEndpointPeerConnection(RTCPeerConnection& peerConnection)
+ : PeerConnectionBackend(peerConnection)
, m_mediaEndpoint(MediaEndpoint::create(*this))
- , m_sdpProcessor(std::unique_ptr<SDPProcessor>(new SDPProcessor(m_client->scriptExecutionContext())))
+ , m_sdpProcessor(std::unique_ptr<SDPProcessor>(new SDPProcessor(m_peerConnection.scriptExecutionContext())))
, m_cname(randomString(cnameSize))
, m_iceUfrag(randomString(iceUfragSize))
, m_icePassword(randomString(icePasswordSize))
@@ -136,20 +137,17 @@
m_initialDeferredTask = nullptr;
}
-void MediaEndpointPeerConnection::createOffer(RTCOfferOptions&& options, SessionDescriptionPromise&& promise)
+void MediaEndpointPeerConnection::doCreateOffer(RTCOfferOptions&& options)
{
- runTask([this, protectedOptions = WTFMove(options), protectedPromise = WTFMove(promise)]() mutable {
- createOfferTask(protectedOptions, protectedPromise);
+ runTask([this, protectedOptions = WTFMove(options)]() mutable {
+ createOfferTask(protectedOptions);
});
}
-void MediaEndpointPeerConnection::createOfferTask(const RTCOfferOptions&, SessionDescriptionPromise& promise)
+void MediaEndpointPeerConnection::createOfferTask(const RTCOfferOptions&)
{
ASSERT(!m_dtlsFingerprint.isEmpty());
- if (m_client->internalSignalingState() == SignalingState::Closed)
- return;
-
MediaEndpointSessionDescription* localDescription = internalLocalDescription();
RefPtr<MediaEndpointSessionConfiguration> configurationSnapshot = localDescription ?
localDescription->configuration()->clone() : MediaEndpointSessionConfiguration::create();
@@ -156,7 +154,7 @@
configurationSnapshot->setSessionVersion(m_sdpOfferSessionVersion++);
- auto transceivers = RtpTransceiverVector(m_client->getTransceivers());
+ auto transceivers = RtpTransceiverVector(m_peerConnection.getTransceivers());
// Remove any transceiver objects from transceivers that can be matched to an existing media description.
for (auto& mediaDescription : configurationSnapshot->mediaDescriptions()) {
@@ -203,8 +201,13 @@
configurationSnapshot->addMediaDescription(WTFMove(mediaDescription));
}
- auto description = MediaEndpointSessionDescription::create(RTCSessionDescription::SdpType::Offer, WTFMove(configurationSnapshot));
- promise.resolve(*description->toRTCSessionDescription(*m_sdpProcessor));
+ String sdp;
+ SDPProcessor::Result result = m_sdpProcessor->generate(*configurationSnapshot, sdp);
+ if (result != SDPProcessor::Result::Success) {
+ createOfferFailed(OperationError, "SDPProcessor internal error");
+ return;
+ }
+ createOfferSucceeded(WTFMove(sdp));
}
void MediaEndpointPeerConnection::createAnswer(RTCAnswerOptions&& options, SessionDescriptionPromise&& promise)
@@ -218,7 +221,7 @@
{
ASSERT(!m_dtlsFingerprint.isEmpty());
- if (m_client->internalSignalingState() == SignalingState::Closed)
+ if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
return;
if (!internalRemoteDescription()) {
@@ -232,7 +235,7 @@
configurationSnapshot->setSessionVersion(m_sdpAnswerSessionVersion++);
- auto transceivers = RtpTransceiverVector(m_client->getTransceivers());
+ auto transceivers = RtpTransceiverVector(m_peerConnection.getTransceivers());
auto& remoteMediaDescriptions = internalRemoteDescription()->configuration()->mediaDescriptions();
for (unsigned i = 0; i < remoteMediaDescriptions.size(); ++i) {
@@ -318,7 +321,7 @@
void MediaEndpointPeerConnection::setLocalDescriptionTask(RefPtr<RTCSessionDescription>&& description, VoidPromise& promise)
{
- if (m_client->internalSignalingState() == SignalingState::Closed)
+ if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
return;
auto result = MediaEndpointSessionDescription::create(WTFMove(description), *m_sdpProcessor);
@@ -333,7 +336,7 @@
return;
}
- const RtpTransceiverVector& transceivers = m_client->getTransceivers();
+ const RtpTransceiverVector& transceivers = m_peerConnection.getTransceivers();
const MediaDescriptionVector& mediaDescriptions = newDescription->configuration()->mediaDescriptions();
MediaEndpointSessionDescription* localDescription = internalLocalDescription();
unsigned previousNumberOfMediaDescriptions = localDescription ? localDescription->configuration()->mediaDescriptions().size() : 0;
@@ -344,11 +347,11 @@
MediaEndpoint::UpdateResult result = m_mediaEndpoint->updateReceiveConfiguration(newDescription->configuration(), isInitiator);
if (result == MediaEndpoint::UpdateResult::SuccessWithIceRestart) {
- if (m_client->internalIceGatheringState() != IceGatheringState::Gathering)
- m_client->updateIceGatheringState(IceGatheringState::Gathering);
+ if (m_peerConnection.internalIceGatheringState() != IceGatheringState::Gathering)
+ m_peerConnection.updateIceGatheringState(IceGatheringState::Gathering);
- if (m_client->internalIceConnectionState() != IceConnectionState::Completed)
- m_client->updateIceConnectionState(IceConnectionState::Connected);
+ if (m_peerConnection.internalIceConnectionState() != IceConnectionState::Completed)
+ m_peerConnection.updateIceConnectionState(IceConnectionState::Connected);
LOG_ERROR("ICE restart is not implemented");
notImplemented();
@@ -409,16 +412,16 @@
break;
}
- if (newSignalingState != m_client->internalSignalingState()) {
- m_client->setSignalingState(newSignalingState);
- m_client->fireEvent(Event::create(eventNames().signalingstatechangeEvent, false, false));
+ if (newSignalingState != m_peerConnection.internalSignalingState()) {
+ m_peerConnection.setSignalingState(newSignalingState);
+ m_peerConnection.fireEvent(Event::create(eventNames().signalingstatechangeEvent, false, false));
}
- if (m_client->internalIceGatheringState() == IceGatheringState::New && mediaDescriptions.size())
- m_client->updateIceGatheringState(IceGatheringState::Gathering);
+ if (m_peerConnection.internalIceGatheringState() == IceGatheringState::New && mediaDescriptions.size())
+ m_peerConnection.updateIceGatheringState(IceGatheringState::Gathering);
- if (m_client->internalSignalingState() == SignalingState::Stable && m_negotiationNeeded)
- m_client->scheduleNegotiationNeededEvent();
+ if (m_peerConnection.internalSignalingState() == SignalingState::Stable && m_negotiationNeeded)
+ m_peerConnection.scheduleNegotiationNeededEvent();
promise.resolve(nullptr);
}
@@ -447,7 +450,7 @@
void MediaEndpointPeerConnection::setRemoteDescriptionTask(RefPtr<RTCSessionDescription>&& description, VoidPromise& promise)
{
- if (m_client->internalSignalingState() == SignalingState::Closed)
+ if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
return;
auto result = MediaEndpointSessionDescription::create(WTFMove(description), *m_sdpProcessor);
@@ -471,7 +474,7 @@
}
bool isInitiator = newDescription->type() == RTCSessionDescription::SdpType::Answer;
- const RtpTransceiverVector& transceivers = m_client->getTransceivers();
+ const RtpTransceiverVector& transceivers = m_peerConnection.getTransceivers();
RealtimeMediaSourceMap sendSourceMap;
if (internalLocalDescription())
@@ -506,7 +509,7 @@
}
if (!transceiver) {
- auto sender = RTCRtpSender::create(mediaDescription.type, Vector<String>(), m_client->senderClient());
+ auto sender = RTCRtpSender::create(mediaDescription.type, Vector<String>(), m_peerConnection.senderClient());
auto receiver = createReceiver(mediaDescription.mid, mediaDescription.type, mediaDescription.mediaStreamTrackId);
auto newTransceiver = RTCRtpTransceiver::create(WTFMove(sender), WTFMove(receiver));
@@ -515,7 +518,7 @@
newTransceiver->disableSendingDirection();
transceiver = newTransceiver.ptr();
- m_client->addTransceiver(WTFMove(newTransceiver));
+ m_peerConnection.addTransceiver(WTFMove(newTransceiver));
}
}
@@ -539,7 +542,7 @@
stream->addTrack(*receiver.track());
trackEventMediaStreams.add(id, WTFMove(stream));
} else {
- auto newStream = MediaStream::create(*m_client->scriptExecutionContext(), MediaStreamTrackVector({ receiver.track() }));
+ auto newStream = MediaStream::create(*m_peerConnection.scriptExecutionContext(), MediaStreamTrackVector({ receiver.track() }));
m_remoteStreamMap.add(id, newStream.copyRef());
legacyMediaStreamEvents.append(MediaStreamEvent::create(eventNames().addstreamEvent, false, false, newStream.copyRef()));
trackEventMediaStreams.add(id, WTFMove(newStream));
@@ -549,7 +552,7 @@
Vector<RefPtr<MediaStream>> streams;
copyValuesToVector(trackEventMediaStreams, streams);
- m_client->fireEvent(RTCTrackEvent::create(eventNames().trackEvent, false, false,
+ m_peerConnection.fireEvent(RTCTrackEvent::create(eventNames().trackEvent, false, false,
&receiver, receiver.track(), WTFMove(streams), transceiver));
}
}
@@ -556,7 +559,7 @@
// Fire legacy addstream events.
for (auto& event : legacyMediaStreamEvents)
- m_client->fireEvent(*event);
+ m_peerConnection.fireEvent(*event);
SignalingState newSignalingState;
@@ -586,9 +589,9 @@
break;
}
- if (newSignalingState != m_client->internalSignalingState()) {
- m_client->setSignalingState(newSignalingState);
- m_client->fireEvent(Event::create(eventNames().signalingstatechangeEvent, false, false));
+ if (newSignalingState != m_peerConnection.internalSignalingState()) {
+ m_peerConnection.setSignalingState(newSignalingState);
+ m_peerConnection.fireEvent(Event::create(eventNames().signalingstatechangeEvent, false, false));
}
promise.resolve(nullptr);
@@ -635,7 +638,7 @@
void MediaEndpointPeerConnection::addIceCandidateTask(RTCIceCandidate& rtcCandidate, PeerConnection::VoidPromise& promise)
{
- if (m_client->internalSignalingState() == SignalingState::Closed)
+ if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
return;
if (!internalRemoteDescription()) {
@@ -711,7 +714,7 @@
// Create a muted remote source that will be unmuted once media starts arriving.
auto remoteSource = m_mediaEndpoint->createMutedRemoteSource(transceiverMid, sourceType);
auto remoteTrackPrivate = MediaStreamTrackPrivate::create(WTFMove(remoteSource), trackId);
- auto remoteTrack = MediaStreamTrack::create(*m_client->scriptExecutionContext(), *remoteTrackPrivate);
+ auto remoteTrack = MediaStreamTrack::create(*m_peerConnection.scriptExecutionContext(), *remoteTrackPrivate);
return RTCRtpReceiver::create(WTFMove(remoteTrack));
}
@@ -718,7 +721,7 @@
void MediaEndpointPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise&& promise)
{
- RTCRtpTransceiver* transceiver = matchTransceiver(m_client->getTransceivers(), [&sender] (RTCRtpTransceiver& current) {
+ RTCRtpTransceiver* transceiver = matchTransceiver(m_peerConnection.getTransceivers(), [&sender] (RTCRtpTransceiver& current) {
return current.sender() == &sender;
});
ASSERT(transceiver);
@@ -738,7 +741,7 @@
void MediaEndpointPeerConnection::replaceTrackTask(RTCRtpSender& sender, const String& mid, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise& promise)
{
- if (m_client->internalSignalingState() == SignalingState::Closed)
+ if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
return;
m_mediaEndpoint->replaceSendSource(withTrack->source(), mid);
@@ -759,8 +762,8 @@
m_negotiationNeeded = true;
- if (m_client->internalSignalingState() == SignalingState::Stable)
- m_client->scheduleNegotiationNeededEvent();
+ if (m_peerConnection.internalSignalingState() == SignalingState::Stable)
+ m_peerConnection.scheduleNegotiationNeededEvent();
}
void MediaEndpointPeerConnection::emulatePlatformEvent(const String& action)
@@ -770,7 +773,7 @@
bool MediaEndpointPeerConnection::localDescriptionTypeValidForState(RTCSessionDescription::SdpType type) const
{
- switch (m_client->internalSignalingState()) {
+ switch (m_peerConnection.internalSignalingState()) {
case SignalingState::Stable:
return type == RTCSessionDescription::SdpType::Offer;
case SignalingState::HaveLocalOffer:
@@ -789,7 +792,7 @@
bool MediaEndpointPeerConnection::remoteDescriptionTypeValidForState(RTCSessionDescription::SdpType type) const
{
- switch (m_client->internalSignalingState()) {
+ switch (m_peerConnection.internalSignalingState()) {
case SignalingState::Stable:
return type == RTCSessionDescription::SdpType::Offer;
case SignalingState::HaveLocalOffer:
@@ -855,7 +858,7 @@
mediaDescriptions[mediaDescriptionIndex].addIceCandidate(WTFMove(candidate));
- m_client->fireEvent(RTCIceCandidateEvent::create(false, false, RTCIceCandidate::create(candidateLine, mid, mediaDescriptionIndex)));
+ m_peerConnection.fireEvent(RTCIceCandidateEvent::create(false, false, RTCIceCandidate::create(candidateLine, mid, mediaDescriptionIndex)));
}
void MediaEndpointPeerConnection::doneGatheringCandidates(const String& mid)
@@ -862,7 +865,7 @@
{
ASSERT(isMainThread());
- RtpTransceiverVector transceivers = RtpTransceiverVector(m_client->getTransceivers());
+ RtpTransceiverVector transceivers = RtpTransceiverVector(m_peerConnection.getTransceivers());
RTCRtpTransceiver* notifyingTransceiver = matchTransceiverByMid(transceivers, mid);
ASSERT(notifyingTransceiver);
@@ -874,8 +877,8 @@
&& current.iceTransport().gatheringState() != RTCIceTransport::GatheringState::Complete;
});
if (!stillGatheringTransceiver) {
- m_client->fireEvent(RTCIceCandidateEvent::create(false, false, nullptr));
- m_client->updateIceGatheringState(IceGatheringState::Complete);
+ m_peerConnection.fireEvent(RTCIceCandidateEvent::create(false, false, nullptr));
+ m_peerConnection.updateIceGatheringState(IceGatheringState::Complete);
}
}
@@ -928,7 +931,7 @@
{
ASSERT(isMainThread());
- RTCRtpTransceiver* transceiver = matchTransceiverByMid(m_client->getTransceivers(), mid);
+ RTCRtpTransceiver* transceiver = matchTransceiverByMid(m_peerConnection.getTransceivers(), mid);
ASSERT(transceiver);
RTCIceTransport::TransportState transportState = static_cast<RTCIceTransport::TransportState>(mediaEndpointIceTransportState);
@@ -936,11 +939,11 @@
// Determine if the script needs to be notified.
Vector<RTCIceTransport::TransportState> transportStates;
- for (auto& transceiver : m_client->getTransceivers())
+ for (auto& transceiver : m_peerConnection.getTransceivers())
transportStates.append(transceiver->iceTransport().transportState());
RTCIceTransport::TransportState derivedState = deriveAggregatedIceConnectionState(transportStates);
- m_client->updateIceConnectionState(static_cast<IceConnectionState>(derivedState));
+ m_peerConnection.updateIceConnectionState(static_cast<IceConnectionState>(derivedState));
}
} // namespace WebCore
Modified: trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h 2016-11-04 06:34:46 UTC (rev 208379)
@@ -28,8 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef MediaEndpointPeerConnection_h
-#define MediaEndpointPeerConnection_h
+#pragma once
#if ENABLE(WEB_RTC)
@@ -51,11 +50,11 @@
using RtpSenderVector = Vector<RefPtr<RTCRtpSender>>;
using RtpTransceiverVector = Vector<RefPtr<RTCRtpTransceiver>>;
-class MediaEndpointPeerConnection : public PeerConnectionBackend, public MediaEndpointClient {
+class MediaEndpointPeerConnection final : public PeerConnectionBackend, public MediaEndpointClient {
public:
- MediaEndpointPeerConnection(PeerConnectionBackendClient*);
+ MediaEndpointPeerConnection(RTCPeerConnection&);
- void createOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&) override;
+ void doCreateOffer(RTCOfferOptions&&) final;
void createAnswer(RTCAnswerOptions&&, PeerConnection::SessionDescriptionPromise&&) override;
void setLocalDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&) override;
@@ -90,7 +89,7 @@
void runTask(Function<void ()>&&);
void startRunningTasks();
- void createOfferTask(const RTCOfferOptions&, PeerConnection::SessionDescriptionPromise&);
+ void createOfferTask(const RTCOfferOptions&);
void createAnswerTask(const RTCAnswerOptions&, PeerConnection::SessionDescriptionPromise&);
void setLocalDescriptionTask(RefPtr<RTCSessionDescription>&&, PeerConnection::VoidPromise&);
@@ -113,7 +112,6 @@
void doneGatheringCandidates(const String& mid) override;
void iceTransportStateChanged(const String& mid, MediaEndpoint::IceTransportState) override;
- PeerConnectionBackendClient* m_client;
std::unique_ptr<MediaEndpoint> m_mediaEndpoint;
Function<void ()> m_initialDeferredTask;
@@ -145,5 +143,3 @@
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
-
-#endif // MediaEndpointPeerConnection_h
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp 2016-11-04 06:34:46 UTC (rev 208379)
@@ -1,5 +1,6 @@
/*
* Copyright (C) 2015 Ericsson AB. All rights reserved.
+ * Copyright (C) 2016 Apple INC. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -29,19 +30,50 @@
*/
#include "config.h"
-
-#if ENABLE(MEDIA_STREAM)
#include "PeerConnectionBackend.h"
+#if ENABLE(WEB_RTC)
+
+#include "JSRTCSessionDescription.h"
+#include "RTCPeerConnection.h"
+
namespace WebCore {
-static std::unique_ptr<PeerConnectionBackend> createPeerConnectionBackend(PeerConnectionBackendClient*)
+void PeerConnectionBackend::createOffer(RTCOfferOptions&& options, PeerConnection::SessionDescriptionPromise&& promise)
{
- return nullptr;
+ ASSERT(!m_offerAnswerPromise);
+
+ if (m_peerConnection.internalSignalingState() == PeerConnectionStates::SignalingState::Closed)
+ return;
+
+ m_offerAnswerPromise = WTFMove(promise);
+ doCreateOffer(WTFMove(options));
}
-CreatePeerConnectionBackend PeerConnectionBackend::create = createPeerConnectionBackend;
+void PeerConnectionBackend::createOfferSucceeded(String&& sdp)
+{
+ ASSERT(isMainThread());
+ if (m_peerConnection.internalSignalingState() == PeerConnectionStates::SignalingState::Closed)
+ return;
+
+ ASSERT(m_offerAnswerPromise);
+ m_offerAnswerPromise->resolve(RTCSessionDescription::create(RTCSessionDescription::SdpType::Offer, WTFMove(sdp)));
+ m_offerAnswerPromise = Nullopt;
+}
+
+void PeerConnectionBackend::createOfferFailed(ExceptionCode ec, String&& error)
+{
+ ASSERT(isMainThread());
+
+ if (m_peerConnection.internalSignalingState() == PeerConnectionStates::SignalingState::Closed)
+ return;
+
+ ASSERT(m_offerAnswerPromise);
+ m_offerAnswerPromise->reject(ec, WTFMove(error));
+ m_offerAnswerPromise = Nullopt;
+}
+
} // namespace WebCore
-#endif // ENABLE(MEDIA_STREAM)
+#endif // ENABLE(WEB_RTC)
Modified: trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/PeerConnectionBackend.h 2016-11-04 06:34:46 UTC (rev 208379)
@@ -28,8 +28,7 @@
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#ifndef PeerConnectionBackend_h
-#define PeerConnectionBackend_h
+#pragma once
#if ENABLE(WEB_RTC)
@@ -45,6 +44,7 @@
class PeerConnectionBackend;
class RTCConfiguration;
class RTCIceCandidate;
+class RTCPeerConnection;
class RTCRtpReceiver;
class RTCRtpSender;
class RTCRtpSenderClient;
@@ -56,6 +56,8 @@
struct RTCAnswerOptions;
struct RTCOfferOptions;
+using ExceptionCode = int;
+
namespace PeerConnection {
typedef DOMPromise<RTCSessionDescription> SessionDescriptionPromise;
typedef DOMPromise<std::nullptr_t> VoidPromise;
@@ -62,35 +64,20 @@
typedef DOMPromise<RTCStatsResponse> StatsPromise;
}
-class PeerConnectionBackendClient {
-public:
- virtual const Vector<RefPtr<RTCRtpTransceiver>>& getTransceivers() const = 0;
- virtual RTCRtpSenderClient& senderClient() = 0;
- virtual void fireEvent(Event&) = 0;
+typedef std::unique_ptr<PeerConnectionBackend> (*CreatePeerConnectionBackend)(RTCPeerConnection&);
- virtual void addTransceiver(RefPtr<RTCRtpTransceiver>&&) = 0;
- virtual void setSignalingState(PeerConnectionStates::SignalingState) = 0;
- virtual void updateIceGatheringState(PeerConnectionStates::IceGatheringState) = 0;
- virtual void updateIceConnectionState(PeerConnectionStates::IceConnectionState) = 0;
-
- virtual void scheduleNegotiationNeededEvent() = 0;
-
- virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
- virtual PeerConnectionStates::SignalingState internalSignalingState() const = 0;
- virtual PeerConnectionStates::IceGatheringState internalIceGatheringState() const = 0;
- virtual PeerConnectionStates::IceConnectionState internalIceConnectionState() const = 0;
-
- virtual ~PeerConnectionBackendClient() { }
-};
-
-typedef std::unique_ptr<PeerConnectionBackend> (*CreatePeerConnectionBackend)(PeerConnectionBackendClient*);
-
class PeerConnectionBackend {
public:
WEBCORE_EXPORT static CreatePeerConnectionBackend create;
+
+ PeerConnectionBackend(RTCPeerConnection& peerConnection) : m_peerConnection(peerConnection) { }
virtual ~PeerConnectionBackend() { }
- virtual void createOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&) = 0;
+ void createOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&);
+ virtual void doCreateOffer(RTCOfferOptions&&) = 0;
+ void createOfferSucceeded(String&&);
+ void createOfferFailed(ExceptionCode, String&&);
+
virtual void createAnswer(RTCAnswerOptions&&, PeerConnection::SessionDescriptionPromise&&) = 0;
virtual void setLocalDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&) = 0;
@@ -120,10 +107,12 @@
virtual void clearNegotiationNeededState() = 0;
virtual void emulatePlatformEvent(const String& action) = 0;
+
+protected:
+ RTCPeerConnection& m_peerConnection;
+ Optional<PeerConnection::SessionDescriptionPromise> m_offerAnswerPromise;
};
} // namespace WebCore
#endif // ENABLE(WEB_RTC)
-
-#endif // PeerConnectionBackend_h
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp 2016-11-04 06:34:46 UTC (rev 208379)
@@ -69,7 +69,7 @@
RTCPeerConnection::RTCPeerConnection(ScriptExecutionContext& context)
: ActiveDOMObject(&context)
- , m_backend(PeerConnectionBackend::create(this))
+ , m_backend(PeerConnectionBackend::create(*this))
{
}
Modified: trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h (208378 => 208379)
--- trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/Modules/mediastream/RTCPeerConnection.h 2016-11-04 06:34:46 UTC (rev 208379)
@@ -38,7 +38,6 @@
#include "Dictionary.h"
#include "EventTarget.h"
#include "MediaStream.h"
-#include "PeerConnectionBackend.h"
#include "RTCOfferAnswerOptions.h"
#include "RTCRtpTransceiver.h"
#include "ScriptWrappable.h"
@@ -56,7 +55,7 @@
class RTCSessionDescription;
class RTCStatsCallback;
-class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public PeerConnectionBackendClient, public RTCRtpSenderClient, public EventTargetWithInlineData, public ActiveDOMObject {
+class RTCPeerConnection final : public RefCounted<RTCPeerConnection>, public RTCRtpSenderClient, public EventTargetWithInlineData, public ActiveDOMObject {
public:
static Ref<RTCPeerConnection> create(ScriptExecutionContext&);
~RTCPeerConnection();
@@ -69,7 +68,7 @@
const Vector<RefPtr<RTCRtpSender>>& getSenders() const { return m_transceiverSet->getSenders(); }
const Vector<RefPtr<RTCRtpReceiver>>& getReceivers() const { return m_transceiverSet->getReceivers(); }
- const Vector<RefPtr<RTCRtpTransceiver>>& getTransceivers() const final { return m_transceiverSet->list(); }
+ const Vector<RefPtr<RTCRtpTransceiver>>& getTransceivers() const { return m_transceiverSet->list(); }
// Part of legacy MediaStream-based API (mostly implemented as JS built-ins)
Vector<RefPtr<MediaStream>> getRemoteStreams() const { return m_backend->getRemoteStreams(); }
@@ -126,6 +125,20 @@
// Used for testing with a mock
WEBCORE_EXPORT void emulatePlatformEvent(const String& action);
+ // API used by PeerConnectionBackend and relatives
+ void addTransceiver(RefPtr<RTCRtpTransceiver>&&);
+ void setSignalingState(PeerConnectionStates::SignalingState);
+ void updateIceGatheringState(PeerConnectionStates::IceGatheringState);
+ void updateIceConnectionState(PeerConnectionStates::IceConnectionState);
+
+ void scheduleNegotiationNeededEvent();
+
+ RTCRtpSenderClient& senderClient() { return *this; }
+ void fireEvent(Event&);
+ PeerConnectionStates::SignalingState internalSignalingState() const { return m_signalingState; }
+ PeerConnectionStates::IceGatheringState internalIceGatheringState() const { return m_iceGatheringState; }
+ PeerConnectionStates::IceConnectionState internalIceConnectionState() const { return m_iceConnectionState; }
+
private:
RTCPeerConnection(ScriptExecutionContext&);
@@ -140,20 +153,6 @@
const char* activeDOMObjectName() const final;
bool canSuspendForDocumentSuspension() const final;
- // PeerConnectionBackendClient
- void addTransceiver(RefPtr<RTCRtpTransceiver>&&) final;
- void setSignalingState(PeerConnectionStates::SignalingState) final;
- void updateIceGatheringState(PeerConnectionStates::IceGatheringState) final;
- void updateIceConnectionState(PeerConnectionStates::IceConnectionState) final;
-
- void scheduleNegotiationNeededEvent() final;
-
- RTCRtpSenderClient& senderClient() final { return *this; }
- void fireEvent(Event&) final;
- PeerConnectionStates::SignalingState internalSignalingState() const final { return m_signalingState; }
- PeerConnectionStates::IceGatheringState internalIceGatheringState() const final { return m_iceGatheringState; }
- PeerConnectionStates::IceConnectionState internalIceConnectionState() const final { return m_iceConnectionState; }
-
// RTCRtpSenderClient
void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) final;
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (208378 => 208379)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-04 06:21:06 UTC (rev 208378)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-11-04 06:34:46 UTC (rev 208379)
@@ -1607,6 +1607,7 @@
41D015CB0F4B5C71004A662F /* ContentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41D015C90F4B5C71004A662F /* ContentType.cpp */; };
41E1B1D00FF5986900576B3B /* AbstractWorker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */; };
41E1B1D10FF5986900576B3B /* AbstractWorker.h in Headers */ = {isa = PBXBuildFile; fileRef = 41E1B1CB0FF5986900576B3B /* AbstractWorker.h */; };
+ 41E408391DCB748900EFCE19 /* PeerConnectionBackend.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41E408381DCB747900EFCE19 /* PeerConnectionBackend.cpp */; };
41F062140F5F192600A07EAC /* InspectorDatabaseResource.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */; };
41F062150F5F192600A07EAC /* InspectorDatabaseResource.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */; };
41F066E40F64BCF600A07EAC /* ScriptGlobalObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 41F066E20F64BCF600A07EAC /* ScriptGlobalObject.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8675,6 +8676,7 @@
41E1B1CA0FF5986900576B3B /* AbstractWorker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AbstractWorker.cpp; sourceTree = "<group>"; };
41E1B1CB0FF5986900576B3B /* AbstractWorker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AbstractWorker.h; sourceTree = "<group>"; };
41E1B1CC0FF5986900576B3B /* AbstractWorker.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AbstractWorker.idl; sourceTree = "<group>"; };
+ 41E408381DCB747900EFCE19 /* PeerConnectionBackend.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PeerConnectionBackend.cpp; sourceTree = "<group>"; };
41F062120F5F192600A07EAC /* InspectorDatabaseResource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorDatabaseResource.h; sourceTree = "<group>"; };
41F062130F5F192600A07EAC /* InspectorDatabaseResource.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = InspectorDatabaseResource.cpp; sourceTree = "<group>"; };
41F066E20F64BCF600A07EAC /* ScriptGlobalObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptGlobalObject.h; sourceTree = "<group>"; };
@@ -14901,6 +14903,7 @@
0704A4031D6DE9F10086DCDB /* OverconstrainedError.idl */,
072A703E1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.h */,
072A703F1D6E8F6200DF0AFC /* OverconstrainedErrorEvent.idl */,
+ 41E408381DCB747900EFCE19 /* PeerConnectionBackend.cpp */,
5E2C434D1BCEE2E50001E2BC /* PeerConnectionBackend.h */,
5E2C434F1BCEE2E50001E2BC /* RTCConfiguration.cpp */,
07AB996518DA3C010018771E /* RTCConfiguration.h */,
@@ -28639,6 +28642,7 @@
31BC742D1AAFF45C006B4340 /* CSSAnimationTriggerScrollValue.cpp in Sources */,
CAE9F90F146441F000C245B0 /* CSSAspectRatioValue.cpp in Sources */,
94DE5C811D7F3A1400164F2A /* CSSAtRuleID.cpp in Sources */,
+ 41E408391DCB748900EFCE19 /* PeerConnectionBackend.cpp in Sources */,
FBD6AF8B15EF25E5008B7110 /* CSSBasicShapes.cpp in Sources */,
E16A84F914C85CCC002977DF /* CSSBorderImage.cpp in Sources */,
BC274B31140EBED800EADFA6 /* CSSBorderImageSliceValue.cpp in Sources */,
_______________________________________________ webkit-changes mailing list [email protected] https://lists.webkit.org/mailman/listinfo/webkit-changes
