diff options
Diffstat (limited to 'chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h')
-rw-r--r-- | chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h | 171 |
1 files changed, 111 insertions, 60 deletions
diff --git a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h index fc779f36c01..43782a7271e 100644 --- a/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h +++ b/chromium/third_party/blink/renderer/modules/peerconnection/rtc_peer_connection.h @@ -42,10 +42,15 @@ #include "third_party/blink/renderer/modules/crypto/normalize_algorithm.h" #include "third_party/blink/renderer/modules/event_target_modules.h" #include "third_party/blink/renderer/modules/mediastream/media_stream.h" +#include "third_party/blink/renderer/modules/peerconnection/call_setup_state_tracker.h" #include "third_party/blink/renderer/modules/peerconnection/rtc_ice_candidate.h" +#include "third_party/blink/renderer/modules/peerconnection/rtc_peer_connection_controller.h" #include "third_party/blink/renderer/modules/peerconnection/rtc_rtp_transceiver.h" +#include "third_party/blink/renderer/modules/peerconnection/rtc_session_description_enums.h" #include "third_party/blink/renderer/platform/async_method_runner.h" #include "third_party/blink/renderer/platform/heap/heap_allocator.h" +#include "third_party/blink/renderer/platform/peerconnection/rtc_session_description_request.h" +#include "third_party/blink/renderer/platform/peerconnection/rtc_void_request.h" #include "third_party/blink/renderer/platform/scheduler/public/frame_scheduler.h" namespace blink { @@ -72,6 +77,28 @@ class V8RTCSessionDescriptionCallback; class V8RTCStatsCallback; class V8VoidFunction; +// This enum is used to track usage of SDP during the transition of the default +// "sdpSemantics" value from "Plan B" to "Unified Plan". Usage refers to +// operations such as createOffer(), createAnswer(), setLocalDescription() and +// setRemoteDescription(). "Complex" SDP refers to SDP that is not compatible +// between SDP formats. Usage of SDP falls into two categories: "safe" and +// "unsafe". Applications with unsafe usage are predicted to break when the +// default changes. This includes complex SDP usage and relying on the default +// sdpSemantics. kUnknown is used if the SDP format could not be deduced, such +// as if SDP could not be parsed. +enum class SdpUsageCategory { + kSafe = 0, + kUnsafe = 1, + kUnknown = 2, + kMaxValue = kUnknown, +}; + +MODULES_EXPORT SdpUsageCategory +DeduceSdpUsageCategory(const String& sdp_type, + const String& sdp, + bool sdp_semantics_specified, + webrtc::SdpSemantics sdp_semantics); + class MODULES_EXPORT RTCPeerConnection final : public EventTargetWithInlineData, public WebRTCPeerConnectionHandlerClient, @@ -84,29 +111,35 @@ class MODULES_EXPORT RTCPeerConnection final public: static RTCPeerConnection* Create(ExecutionContext*, - const RTCConfiguration&, + const RTCConfiguration*, const Dictionary&, ExceptionState&); + + RTCPeerConnection(ExecutionContext*, + webrtc::PeerConnectionInterface::RTCConfiguration, + bool sdp_semantics_specified, + WebMediaConstraints, + ExceptionState&); ~RTCPeerConnection() override; - ScriptPromise createOffer(ScriptState*, const RTCOfferOptions&); + ScriptPromise createOffer(ScriptState*, const RTCOfferOptions*); ScriptPromise createOffer(ScriptState*, V8RTCSessionDescriptionCallback*, V8RTCPeerConnectionErrorCallback*, const Dictionary&, ExceptionState&); - ScriptPromise createAnswer(ScriptState*, const RTCAnswerOptions&); + ScriptPromise createAnswer(ScriptState*, const RTCAnswerOptions*); ScriptPromise createAnswer(ScriptState*, V8RTCSessionDescriptionCallback*, V8RTCPeerConnectionErrorCallback*, const Dictionary&); ScriptPromise setLocalDescription(ScriptState*, - const RTCSessionDescriptionInit&); + const RTCSessionDescriptionInit*); ScriptPromise setLocalDescription( ScriptState*, - const RTCSessionDescriptionInit&, + const RTCSessionDescriptionInit*, V8VoidFunction*, V8RTCPeerConnectionErrorCallback* = nullptr); RTCSessionDescription* localDescription(); @@ -114,10 +147,10 @@ class MODULES_EXPORT RTCPeerConnection final RTCSessionDescription* pendingLocalDescription(); ScriptPromise setRemoteDescription(ScriptState*, - const RTCSessionDescriptionInit&); + const RTCSessionDescriptionInit*); ScriptPromise setRemoteDescription( ScriptState*, - const RTCSessionDescriptionInit&, + const RTCSessionDescriptionInit*, V8VoidFunction*, V8RTCPeerConnectionErrorCallback* = nullptr); RTCSessionDescription* remoteDescription(); @@ -126,8 +159,8 @@ class MODULES_EXPORT RTCPeerConnection final String signalingState() const; - void getConfiguration(RTCConfiguration&); - void setConfiguration(ScriptState*, const RTCConfiguration&, ExceptionState&); + RTCConfiguration* getConfiguration(ScriptState*) const; + void setConfiguration(ScriptState*, const RTCConfiguration*, ExceptionState&); // Certificate management // http://w3c.github.io/webrtc-pc/#sec.cert-mgmt @@ -149,6 +182,8 @@ class MODULES_EXPORT RTCPeerConnection final String iceConnectionState() const; + String connectionState() const; + // A local stream is any stream associated with a sender. MediaStreamVector getLocalStreams() const; // A remote stream is any stream associated with a receiver. @@ -184,15 +219,15 @@ class MODULES_EXPORT RTCPeerConnection final const HeapVector<Member<RTCRtpSender>>& getSenders() const; const HeapVector<Member<RTCRtpReceiver>>& getReceivers() const; RTCRtpTransceiver* addTransceiver(const MediaStreamTrackOrString&, - const RTCRtpTransceiverInit&, + const RTCRtpTransceiverInit*, ExceptionState&); RTCRtpSender* addTrack(MediaStreamTrack*, MediaStreamVector, ExceptionState&); void removeTrack(RTCRtpSender*, ExceptionState&); - DEFINE_ATTRIBUTE_EVENT_LISTENER(track); + DEFINE_ATTRIBUTE_EVENT_LISTENER(track, kTrack); RTCDataChannel* createDataChannel(ScriptState*, String label, - const RTCDataChannelInit&, + const RTCDataChannelInit*, ExceptionState&); RTCDTMFSender* createDTMFSender(MediaStreamTrack*, ExceptionState&); @@ -209,17 +244,29 @@ class MODULES_EXPORT RTCPeerConnection final bool ShouldFireDefaultCallbacks() { return !closed_ && !stopped_; } bool ShouldFireGetStatsCallback() { return !stopped_; } - DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded); - DEFINE_ATTRIBUTE_EVENT_LISTENER(icecandidate); - DEFINE_ATTRIBUTE_EVENT_LISTENER(signalingstatechange); - DEFINE_ATTRIBUTE_EVENT_LISTENER(addstream); - DEFINE_ATTRIBUTE_EVENT_LISTENER(removestream); - DEFINE_ATTRIBUTE_EVENT_LISTENER(iceconnectionstatechange); - DEFINE_ATTRIBUTE_EVENT_LISTENER(icegatheringstatechange); - DEFINE_ATTRIBUTE_EVENT_LISTENER(datachannel); + DEFINE_ATTRIBUTE_EVENT_LISTENER(negotiationneeded, kNegotiationneeded); + DEFINE_ATTRIBUTE_EVENT_LISTENER(icecandidate, kIcecandidate); + DEFINE_ATTRIBUTE_EVENT_LISTENER(signalingstatechange, kSignalingstatechange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(addstream, kAddstream); + DEFINE_ATTRIBUTE_EVENT_LISTENER(removestream, kRemovestream); + DEFINE_ATTRIBUTE_EVENT_LISTENER(iceconnectionstatechange, + kIceconnectionstatechange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(connectionstatechange, + kConnectionstatechange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(icegatheringstatechange, + kIcegatheringstatechange); + DEFINE_ATTRIBUTE_EVENT_LISTENER(datachannel, kDatachannel); // Utility to note result of CreateOffer / CreateAnswer void NoteSdpCreated(const RTCSessionDescription&); + // Utility to report SDP usage of setLocalDescription / setRemoteDescription. + enum class SetSdpOperationType { + kSetLocalDescription, + kSetRemoteDescription, + }; + void ReportSetSdpUsage( + SetSdpOperationType operation_type, + const RTCSessionDescriptionInit* session_description_init) const; // MediaStreamObserver void OnStreamAddTrack(MediaStream*, MediaStreamTrack*) override; @@ -230,8 +277,12 @@ class MODULES_EXPORT RTCPeerConnection final void DidGenerateICECandidate(scoped_refptr<WebRTCICECandidate>) override; void DidChangeSignalingState( webrtc::PeerConnectionInterface::SignalingState) override; - void DidChangeICEGatheringState(ICEGatheringState) override; - void DidChangeICEConnectionState(ICEConnectionState) override; + void DidChangeIceGatheringState( + webrtc::PeerConnectionInterface::IceGatheringState) override; + void DidChangeIceConnectionState( + webrtc::PeerConnectionInterface::IceConnectionState) override; + void DidChangePeerConnectionState( + webrtc::PeerConnectionInterface::PeerConnectionState) override; void DidAddReceiverPlanB(std::unique_ptr<WebRTCRtpReceiver>) override; void DidRemoveReceiverPlanB(std::unique_ptr<WebRTCRtpReceiver>) override; void DidModifyTransceivers(std::vector<std::unique_ptr<WebRTCRtpTransceiver>>, @@ -258,17 +309,28 @@ class MODULES_EXPORT RTCPeerConnection final static int PeerConnectionCount(); static int PeerConnectionCountLimit(); - // SLD/SRD helper method, public for testing. - // "Complex" Plan B SDP is SDP that is not compatible with Unified Plan, i.e. - // SDP that has multiple tracks listed under the same m= sections. We should - // show a deprecation warning when setLocalDescription() or - // setRemoteDescription() is called and: - // - The SDP is complex Plan B SDP. - // - sdpSemantics was not specified at RTCPeerConnection construction. - // Such calls would normally succeed, but as soon as the default switches to - // Unified Plan they would fail. This decides whether to show deprecation for - // WebFeature::kRTCPeerConnectionComplexPlanBSdpUsingDefaultSdpSemantics. - bool ShouldShowComplexPlanBSdpWarning(const RTCSessionDescriptionInit&) const; + // SLD/SRD Helper method, public for testing. + // This function returns a value that indicates if complex SDP is being used + // and whether a format is explicitly specified. If the SDP is not complex or + // it could not be parsed, base::nullopt is returned. + // When "Complex" SDP (i.e., SDP that has multiple tracks) is used without + // explicitly specifying the SDP format, there may be errors if the + // application assumes a format that differs from the actual default format. + base::Optional<ComplexSdpCategory> CheckForComplexSdp( + const RTCSessionDescriptionInit* session_description_init) const; + + const CallSetupStateTracker& call_setup_state_tracker() const; + void NoteCallSetupStateEventPending( + RTCPeerConnection::SetSdpOperationType operation, + const RTCSessionDescriptionInit& description); + void NoteSessionDescriptionRequestCompleted( + RTCCreateSessionDescriptionOperation operation, + bool success); + void NoteVoidRequestCompleted(RTCSetSessionDescriptionOperation operation, + bool success); + // Checks if the document that the peer connection lives in has ever executed + // getUserMedia(). + bool HasDocumentMedia() const; void Trace(blink::Visitor*) override; @@ -297,12 +359,6 @@ class MODULES_EXPORT RTCPeerConnection final private: BoolFunction setup_function_; }; - - RTCPeerConnection(ExecutionContext*, - webrtc::PeerConnectionInterface::RTCConfiguration, - bool sdp_semantics_specified, - WebMediaConstraints, - ExceptionState&); void Dispose(); void ScheduleDispatchEvent(Event*); @@ -346,19 +402,6 @@ class MODULES_EXPORT RTCPeerConnection final RTCRtpTransceiver* CreateOrUpdateTransceiver( std::unique_ptr<WebRTCRtpTransceiver>); - // https://w3c.github.io/webrtc-pc/#process-remote-track-addition - void ProcessAdditionOfRemoteTrack( - RTCRtpTransceiver* transceiver, - const WebVector<WebString>& stream_ids, - HeapVector<std::pair<Member<MediaStream>, Member<MediaStreamTrack>>>* - add_list, - HeapVector<Member<RTCRtpTransceiver>>* track_events); - // https://w3c.github.io/webrtc-pc/#process-remote-track-removal - void ProcessRemovalOfRemoteTrack( - RTCRtpTransceiver* transceiver, - HeapVector<std::pair<Member<MediaStream>, Member<MediaStreamTrack>>>* - remove_list, - HeapVector<Member<MediaStreamTrack>>* mute_tracks); // Update the |receiver->streams()| to the streams indicated by |stream_ids|, // adding to |remove_list| and |add_list| accordingly. // https://w3c.github.io/webrtc-pc/#set-associated-remote-streams @@ -393,26 +436,34 @@ class MODULES_EXPORT RTCPeerConnection final // that are delayed somehow and cause the application to read a "complete" // gathering state twice, missing the "gathering" state in the middle. void ChangeIceGatheringState( - WebRTCPeerConnectionHandlerClient::ICEGatheringState); - bool SetIceGatheringState( - WebRTCPeerConnectionHandlerClient::ICEGatheringState); + webrtc::PeerConnectionInterface::IceGatheringState); + bool SetIceGatheringState(webrtc::PeerConnectionInterface::IceGatheringState); void ChangeIceConnectionState( - WebRTCPeerConnectionHandlerClient::ICEConnectionState); + webrtc::PeerConnectionInterface::IceConnectionState); bool SetIceConnectionState( - WebRTCPeerConnectionHandlerClient::ICEConnectionState); + webrtc::PeerConnectionInterface::IceConnectionState); + + void ChangePeerConnectionState( + webrtc::PeerConnectionInterface::PeerConnectionState); + bool SetPeerConnectionState( + webrtc::PeerConnectionInterface::PeerConnectionState); void CloseInternal(); void RecordRapporMetrics(); DOMException* checkSdpForStateErrors(ExecutionContext*, - const RTCSessionDescriptionInit&, + const RTCSessionDescriptionInit*, String* sdp); + void MaybeWarnAboutUnsafeSdp( + const RTCSessionDescriptionInit* session_description_init) const; webrtc::PeerConnectionInterface::SignalingState signaling_state_; - ICEGatheringState ice_gathering_state_; - ICEConnectionState ice_connection_state_; + webrtc::PeerConnectionInterface::IceGatheringState ice_gathering_state_; + webrtc::PeerConnectionInterface::IceConnectionState ice_connection_state_; + webrtc::PeerConnectionInterface::PeerConnectionState peer_connection_state_; + CallSetupStateTracker call_setup_state_tracker_; // A map containing any track that is in use by the peer connection. This // includes tracks of |rtp_senders_| and |rtp_receivers_|. |