webrtc_m130/pc/peer_connection.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

842 lines
36 KiB
C
Raw Normal View History

/*
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef PC_PEER_CONNECTION_H_
#define PC_PEER_CONNECTION_H_
#include <functional>
#include <map>
#include <memory>
#include <set>
#include <string>
#include <utility>
#include <vector>
#include "api/peer_connection_interface.h"
#include "api/transport/data_channel_transport_interface.h"
#include "api/turn_customizer.h"
#include "pc/data_channel_controller.h"
#include "pc/ice_server_parsing.h"
#include "pc/jsep_transport_controller.h"
#include "pc/peer_connection_factory.h"
#include "pc/peer_connection_internal.h"
#include "pc/peer_connection_message_handler.h"
#include "pc/rtc_stats_collector.h"
Add RtpSenderInterface.SetStreams This is a reland of df5731e44d510e9f23a35b77e9e102eb41919bf4 with fixes to avoid existing chromium tests to fail. Instead of replacing the existing RtpSender::set_stream_ids() to also fire OnRenegotiationNeeded(), this CL keeps the old set_stream_ids() and adds the new RtpSender::SetStreams() which sets the stream IDs and fires the callback. This allows existing callsites to maintain behavior, and reserve SetStreams() for the cases when we want OnRenegotiationNeeded() to fire. Using the SetStreams() name instead of SetStreamIDs() to match the W3C spec and to make it more different that the existing set_stream_ids(). Original change's description: > Improve spec compliance of SetStreamIDs in RtpSenderInterface > > This CL makes RtpSender::SetStreamIDs fire fire negotiationneeded > event if needed and exposes the method on RtpSenderInterface. > > This is a spec-compliance change. > > Bug: webrtc:10129 > Change-Id: I2b98b92665c847102838b094516a79b24de0e47e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135121 > Commit-Queue: Guido Urdaneta <guidou@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27974} Bug: webrtc:10129 Change-Id: Ic0b322bfa25c157e3a39465ef8b486f898eaf6bd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137439 Commit-Queue: Guido Urdaneta <guidou@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27992}
2019-05-20 19:31:53 +02:00
#include "pc/rtp_sender.h"
#include "pc/rtp_transceiver.h"
#include "pc/sctp_transport.h"
#include "pc/sdp_offer_answer.h"
#include "pc/stats_collector.h"
#include "pc/stream_collection.h"
#include "pc/transceiver_list.h"
#include "pc/usage_pattern.h"
#include "pc/webrtc_session_description_factory.h"
#include "rtc_base/experiments/field_trial_parser.h"
Reland "[PeerConnection] Use an OperationsChain in PeerConnection for async ops." This is a reland of 1dddaa1a84330091ca083c950ef2e24a85a48fc8 The regression that caused the original CL to be reverted was the fact that invoking SetLocalDescription() inside of the CreateOffer() callback was no longer executing synchronously and immediately. In this CL, the original CL is patched so that the CreateOffer() operation is marked as completed just before invoking the CreateOffer() callback (versus doing it just afterwards). This ensures that the OperationsChain is popped before the callback runs. The same applies for CreateAnswer(). See diff between Patch Set 1 (Original CL) and the latest Patch Set. Original change's description: > [PeerConnection] Use an OperationsChain in PeerConnection for async ops. > > For background, motivation, requirements and implementation notes, see > https://docs.google.com/document/d/1XLwNN2kUIGGTwz9LQ0NwJNkcybi9oKnynUEZB1jGA14/edit?usp=sharing > > Using the OperationsChain will unblock future CLs from chaining multiple > operations together such as implementing parameterless > setLocalDescription(). > > In this CL, the OperationsChain is used in existing signaling operations > with little intended side-effects. An operation that is chained onto an > empty OperationsChain will for instance execute immediately, and > SetLocalDescription() and SetRemoteDescription() are implemented as > "synchronous operations". > > The lifetime of the PeerConnection is not indended to change as a result > of this CL: All chained operations use a WeakPtr to the PC to ensure > use-after-free does not happen. > > There is one notable change though: CreateOffer() and CreateAnswer() will > asynchronously delay other signaling methods from executing until they > have completed. > > Drive-by fix: This CL also ensures that early failing > CreateOffer/CreateAnswer operation's observers are invoked if the > PeerConnection is destroyed while a PostCreateSessionDescriptionFailure > is pending. > > Bug: webrtc:11019 > Change-Id: I521333e41d20d9bbfb1e721609f2c9db2a5f93a9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157305 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29605} TBR=steveanton@webrtc.org Bug: webrtc:11019 Change-Id: I57b4496e63378c91c24679ee496e21f5cb6a0e59 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158524 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29630}
2019-10-28 12:09:49 +01:00
#include "rtc_base/operations_chain.h"
#include "rtc_base/race_checker.h"
#include "rtc_base/task_utils/pending_task_safety_flag.h"
#include "rtc_base/unique_id_generator.h"
Reland "[PeerConnection] Use an OperationsChain in PeerConnection for async ops." This is a reland of 1dddaa1a84330091ca083c950ef2e24a85a48fc8 The regression that caused the original CL to be reverted was the fact that invoking SetLocalDescription() inside of the CreateOffer() callback was no longer executing synchronously and immediately. In this CL, the original CL is patched so that the CreateOffer() operation is marked as completed just before invoking the CreateOffer() callback (versus doing it just afterwards). This ensures that the OperationsChain is popped before the callback runs. The same applies for CreateAnswer(). See diff between Patch Set 1 (Original CL) and the latest Patch Set. Original change's description: > [PeerConnection] Use an OperationsChain in PeerConnection for async ops. > > For background, motivation, requirements and implementation notes, see > https://docs.google.com/document/d/1XLwNN2kUIGGTwz9LQ0NwJNkcybi9oKnynUEZB1jGA14/edit?usp=sharing > > Using the OperationsChain will unblock future CLs from chaining multiple > operations together such as implementing parameterless > setLocalDescription(). > > In this CL, the OperationsChain is used in existing signaling operations > with little intended side-effects. An operation that is chained onto an > empty OperationsChain will for instance execute immediately, and > SetLocalDescription() and SetRemoteDescription() are implemented as > "synchronous operations". > > The lifetime of the PeerConnection is not indended to change as a result > of this CL: All chained operations use a WeakPtr to the PC to ensure > use-after-free does not happen. > > There is one notable change though: CreateOffer() and CreateAnswer() will > asynchronously delay other signaling methods from executing until they > have completed. > > Drive-by fix: This CL also ensures that early failing > CreateOffer/CreateAnswer operation's observers are invoked if the > PeerConnection is destroyed while a PostCreateSessionDescriptionFailure > is pending. > > Bug: webrtc:11019 > Change-Id: I521333e41d20d9bbfb1e721609f2c9db2a5f93a9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157305 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29605} TBR=steveanton@webrtc.org Bug: webrtc:11019 Change-Id: I57b4496e63378c91c24679ee496e21f5cb6a0e59 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158524 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29630}
2019-10-28 12:09:49 +01:00
#include "rtc_base/weak_ptr.h"
namespace webrtc {
class MediaStreamObserver;
class VideoRtpReceiver;
class RtcEventLog;
class SdpOfferAnswerHandler;
// PeerConnection is the implementation of the PeerConnection object as defined
// by the PeerConnectionInterface API surface.
// The class currently is solely responsible for the following:
// - Managing the session state machine (signaling state).
// - Creating and initializing lower-level objects, like PortAllocator and
// BaseChannels.
// - Owning and managing the life cycle of the RtpSender/RtpReceiver and track
// objects.
// - Tracking the current and pending local/remote session descriptions.
// The class currently is jointly responsible for the following:
// - Parsing and interpreting SDP.
// - Generating offers and answers based on the current state.
// - The ICE state machine.
// - Generating stats.
class PeerConnection : public PeerConnectionInternal,
public JsepTransportController::Observer,
Add RtpSenderInterface.SetStreams This is a reland of df5731e44d510e9f23a35b77e9e102eb41919bf4 with fixes to avoid existing chromium tests to fail. Instead of replacing the existing RtpSender::set_stream_ids() to also fire OnRenegotiationNeeded(), this CL keeps the old set_stream_ids() and adds the new RtpSender::SetStreams() which sets the stream IDs and fires the callback. This allows existing callsites to maintain behavior, and reserve SetStreams() for the cases when we want OnRenegotiationNeeded() to fire. Using the SetStreams() name instead of SetStreamIDs() to match the W3C spec and to make it more different that the existing set_stream_ids(). Original change's description: > Improve spec compliance of SetStreamIDs in RtpSenderInterface > > This CL makes RtpSender::SetStreamIDs fire fire negotiationneeded > event if needed and exposes the method on RtpSenderInterface. > > This is a spec-compliance change. > > Bug: webrtc:10129 > Change-Id: I2b98b92665c847102838b094516a79b24de0e47e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135121 > Commit-Queue: Guido Urdaneta <guidou@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27974} Bug: webrtc:10129 Change-Id: Ic0b322bfa25c157e3a39465ef8b486f898eaf6bd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137439 Commit-Queue: Guido Urdaneta <guidou@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27992}
2019-05-20 19:31:53 +02:00
public RtpSenderBase::SetStreamsObserver,
public sigslot::has_slots<> {
public:
explicit PeerConnection(PeerConnectionFactory* factory,
std::unique_ptr<RtcEventLog> event_log,
std::unique_ptr<Call> call);
bool Initialize(
const PeerConnectionInterface::RTCConfiguration& configuration,
PeerConnectionDependencies dependencies);
rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
bool AddStream(MediaStreamInterface* local_stream) override;
void RemoveStream(MediaStreamInterface* local_stream) override;
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids) override;
bool RemoveTrack(RtpSenderInterface* sender) override;
RTCError RemoveTrackNew(
rtc::scoped_refptr<RtpSenderInterface> sender) override;
Reland "Add AddTransceiver and GetTransceivers to PeerConnection" This reverts commit 8b13f96e2d4b0449e54a3665121a4302ceb56e80. Original change's description: > Revert "Add AddTransceiver and GetTransceivers to PeerConnection" > > This reverts commit f93d2800d9b0d5818a5a383def0aaef3d441df3a. > > Reason for revert: https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2Fios-device%2F5804%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout > > Original change's description: > > Add AddTransceiver and GetTransceivers to PeerConnection > > > > WebRTC 1.0 has added the transceiver API to PeerConnection. This > > is the first step towards exposing this to WebRTC consumers. For > > now, transceivers can be added and fetched but there is not yet > > support for creating offers/answers or setting local/remote > > descriptions. That support ("Unified Plan") will be added in > > follow-up CLs. > > > > The transceiver API is currently only available if the application > > opts in by specifying the kUnifiedPlan SDP semantics when creating > > the PeerConnection. > > > > Bug: webrtc:7600 > > Change-Id: I0b8ee24b489b45bb4c5f60b699bd20c61af01d8e > > Reviewed-on: https://webrtc-review.googlesource.com/23880 > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20896} > > TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org > > Change-Id: Ie91ea4988dba25c20e2532114d3a9d859a932d4c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7600 > Reviewed-on: https://webrtc-review.googlesource.com/26400 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20897} TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org Change-Id: I19fdf08c54f09302794e998a0ffddb82ae0d7b41 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7600 Reviewed-on: https://webrtc-review.googlesource.com/26401 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20898}
2017-11-27 13:01:52 -08:00
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track) override;
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const RtpTransceiverInit& init) override;
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
cricket::MediaType media_type) override;
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
cricket::MediaType media_type,
const RtpTransceiverInit& init) override;
// Gets the DTLS SSL certificate associated with the audio transport on the
// remote side. This will become populated once the DTLS connection with the
// peer has been completed, as indicated by the ICE connection state
// transitioning to kIceConnectionCompleted.
// Note that this will be removed once we implement RTCDtlsTransport which
// has standardized method for getting this information.
// See https://www.w3.org/TR/webrtc/#rtcdtlstransport-interface
std::unique_ptr<rtc::SSLCertificate> GetRemoteAudioSSLCertificate();
// Version of the above method that returns the full certificate chain.
std::unique_ptr<rtc::SSLCertChain> GetRemoteAudioSSLCertChain();
rtc::scoped_refptr<RtpSenderInterface> CreateSender(
const std::string& kind,
const std::string& stream_id) override;
std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
const override;
std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
const override;
Reland "Add AddTransceiver and GetTransceivers to PeerConnection" This reverts commit 8b13f96e2d4b0449e54a3665121a4302ceb56e80. Original change's description: > Revert "Add AddTransceiver and GetTransceivers to PeerConnection" > > This reverts commit f93d2800d9b0d5818a5a383def0aaef3d441df3a. > > Reason for revert: https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2Fios-device%2F5804%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout > > Original change's description: > > Add AddTransceiver and GetTransceivers to PeerConnection > > > > WebRTC 1.0 has added the transceiver API to PeerConnection. This > > is the first step towards exposing this to WebRTC consumers. For > > now, transceivers can be added and fetched but there is not yet > > support for creating offers/answers or setting local/remote > > descriptions. That support ("Unified Plan") will be added in > > follow-up CLs. > > > > The transceiver API is currently only available if the application > > opts in by specifying the kUnifiedPlan SDP semantics when creating > > the PeerConnection. > > > > Bug: webrtc:7600 > > Change-Id: I0b8ee24b489b45bb4c5f60b699bd20c61af01d8e > > Reviewed-on: https://webrtc-review.googlesource.com/23880 > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20896} > > TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org > > Change-Id: Ie91ea4988dba25c20e2532114d3a9d859a932d4c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7600 > Reviewed-on: https://webrtc-review.googlesource.com/26400 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20897} TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org Change-Id: I19fdf08c54f09302794e998a0ffddb82ae0d7b41 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7600 Reviewed-on: https://webrtc-review.googlesource.com/26401 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20898}
2017-11-27 13:01:52 -08:00
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
const override;
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
const std::string& label,
const DataChannelInit* config) override;
2018-03-20 13:24:20 +01:00
// WARNING: LEGACY. See peerconnectioninterface.h
bool GetStats(StatsObserver* observer,
webrtc::MediaStreamTrackInterface* track,
StatsOutputLevel level) override;
2018-03-20 13:24:20 +01:00
// Spec-complaint GetStats(). See peerconnectioninterface.h
void GetStats(RTCStatsCollectorCallback* callback) override;
2018-03-20 13:24:20 +01:00
void GetStats(
rtc::scoped_refptr<RtpSenderInterface> selector,
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
void GetStats(
rtc::scoped_refptr<RtpReceiverInterface> selector,
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
void ClearStatsCache() override;
SignalingState signaling_state() override;
IceConnectionState ice_connection_state() override;
IceConnectionState standardized_ice_connection_state() override;
PeerConnectionState peer_connection_state() override;
IceGatheringState ice_gathering_state() override;
Reland "Expose can_trickle_ice_candidates on PeerConnection" This reverts commit cb8c40138ca170f841bc45fa6771cdfc4b966e5f. Reason for revert: Added missing default. Original change's description: > Revert "Expose can_trickle_ice_candidates on PeerConnection" > > This reverts commit c6a65c8866487c6adc0a7bb472d3bad9389501f9. > > Reason for revert: Breaks downstream due to missing default > > Original change's description: > > Expose can_trickle_ice_candidates on PeerConnection > > > > Bug: chromium:708484 > > Change-Id: I9a40e75066341f0d9f965bd3718bfcb3f0459533 > > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169450 > > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > > Reviewed-by: Taylor <deadbeef@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#30653} > > TBR=deadbeef@webrtc.org,hta@webrtc.org > > Change-Id: Iaa5b977c4237715a8a5127cf167cf6512a3f7059 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: chromium:708484 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169540 > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Commit-Queue: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#30655} TBR=deadbeef@webrtc.org,hta@webrtc.org Change-Id: I608da7781f158b4b02dd226d4dcd5615c4935fa8 Bug: chromium:708484 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169541 Commit-Queue: Harald Alvestrand <hta@webrtc.org> Reviewed-by: Harald Alvestrand <hta@webrtc.org> Cr-Commit-Position: refs/heads/master@{#30656}
2020-03-02 11:20:00 +01:00
absl::optional<bool> can_trickle_ice_candidates() override;
const SessionDescriptionInterface* local_description() const override;
const SessionDescriptionInterface* remote_description() const override;
const SessionDescriptionInterface* current_local_description() const override;
const SessionDescriptionInterface* current_remote_description()
const override;
const SessionDescriptionInterface* pending_local_description() const override;
const SessionDescriptionInterface* pending_remote_description()
const override;
void RestartIce() override;
// JSEP01
void CreateOffer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override;
void CreateAnswer(CreateSessionDescriptionObserver* observer,
const RTCOfferAnswerOptions& options) override;
Reland "[Perfect Negotiation] Implement non-racy version of SetLocalDescription." This is a reland of d4089cae47334a4228b69d6bb23f2e49ebb7496e with the following fix: Invoke MaybeStartGathering as the last step of DoSetLocalDescription. This ensures that candidates and onicegatheringstatechange does not happen before SLD is resolved. This is important for passing external/wpt/webrtc/RTCPeerConnection-iceGatheringState.html. Original change's description: > [Perfect Negotiation] Implement non-racy version of SetLocalDescription. > > BACKGROUND > > When SLD is invoked with SetSessionDescriptionObserver, the observer is > called by posting a message back to the execution thread, delaying the > call. This delay is "artificial" - it's not necessary; the operation is > already complete. It's a post from the signaling thread to the signaling > thread. The rationale for the post was to avoid the observer making > recursive calls back into the PeerConnection. The problem with this is > that by the time the observer is called, the PeerConnection could > already have executed other operations and modified its states. > > This causes the referenced bug: one can have a race where SLD is > resolved "too late" (after a pending SRD is executed) and the signaling > state observed when SLD resolves doesn't make sense. > > When implementing Unified Plan, we fixed similar issues for SRD by > adding a version that takes SetRemoteDescriptionObserverInterface as > argument instead of SetSessionDescriptionObserver. The new version did > not have the delay. The old version had to be kept around not to break > downstream projects that had dependencies both on he delay and on > allowing the PC to be destroyed midst-operation without informing its > observers. > > THIS CL > > This does the old SRD fix for SLD as well: A new observer interface is > added, SetLocalDescriptionObserverInterface, and > PeerConnection::SetLocalDescription() is overloaded. If you call it with > the old observer, you get the delay, but if you call it with the new > observer, you don't get a delay. > > - SetLocalDescriptionObserverInterface is added. > - SetLocalDescription is overloaded. > - The adapter for SetSessionDescriptionObserver that causes the delay > previously only used for SRD is updated to handle both SLD and SRD. > - FakeSetLocalDescriptionObserver is added and > MockSetRemoteDescriptionObserver is renamed "Fake...". > > Bug: chromium:1071733 > Change-Id: I920368e648bede481058ac22f5b8794752a220b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179100 > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31798} TBR=hta@webrtc.org Bug: chromium:1071733 Change-Id: Ic6e8d96afa1c19604762f373716c08dbfa9d178c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180481 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31804}
2020-07-29 12:04:00 +02:00
void SetLocalDescription(
std::unique_ptr<SessionDescriptionInterface> desc,
rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
override;
void SetLocalDescription(
rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
override;
// TODO(https://crbug.com/webrtc/11798): Delete these methods in favor of the
// ones taking SetLocalDescriptionObserverInterface as argument.
void SetLocalDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) override;
void SetLocalDescription(SetSessionDescriptionObserver* observer) override;
Reland "[Perfect Negotiation] Implement non-racy version of SetLocalDescription." This is a reland of d4089cae47334a4228b69d6bb23f2e49ebb7496e with the following fix: Invoke MaybeStartGathering as the last step of DoSetLocalDescription. This ensures that candidates and onicegatheringstatechange does not happen before SLD is resolved. This is important for passing external/wpt/webrtc/RTCPeerConnection-iceGatheringState.html. Original change's description: > [Perfect Negotiation] Implement non-racy version of SetLocalDescription. > > BACKGROUND > > When SLD is invoked with SetSessionDescriptionObserver, the observer is > called by posting a message back to the execution thread, delaying the > call. This delay is "artificial" - it's not necessary; the operation is > already complete. It's a post from the signaling thread to the signaling > thread. The rationale for the post was to avoid the observer making > recursive calls back into the PeerConnection. The problem with this is > that by the time the observer is called, the PeerConnection could > already have executed other operations and modified its states. > > This causes the referenced bug: one can have a race where SLD is > resolved "too late" (after a pending SRD is executed) and the signaling > state observed when SLD resolves doesn't make sense. > > When implementing Unified Plan, we fixed similar issues for SRD by > adding a version that takes SetRemoteDescriptionObserverInterface as > argument instead of SetSessionDescriptionObserver. The new version did > not have the delay. The old version had to be kept around not to break > downstream projects that had dependencies both on he delay and on > allowing the PC to be destroyed midst-operation without informing its > observers. > > THIS CL > > This does the old SRD fix for SLD as well: A new observer interface is > added, SetLocalDescriptionObserverInterface, and > PeerConnection::SetLocalDescription() is overloaded. If you call it with > the old observer, you get the delay, but if you call it with the new > observer, you don't get a delay. > > - SetLocalDescriptionObserverInterface is added. > - SetLocalDescription is overloaded. > - The adapter for SetSessionDescriptionObserver that causes the delay > previously only used for SRD is updated to handle both SLD and SRD. > - FakeSetLocalDescriptionObserver is added and > MockSetRemoteDescriptionObserver is renamed "Fake...". > > Bug: chromium:1071733 > Change-Id: I920368e648bede481058ac22f5b8794752a220b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179100 > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31798} TBR=hta@webrtc.org Bug: chromium:1071733 Change-Id: Ic6e8d96afa1c19604762f373716c08dbfa9d178c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180481 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31804}
2020-07-29 12:04:00 +02:00
Reland "SetRemoteDescriptionObserverInterface added." Description for changes from the original CL: Calling legacy SRD, implemented using SetRemoteDescriptionObserverAdapter wrapping the old observer, was meant to have the exact same behavior as the legacy SRD implementation which invokes the callbacks in a Post. However, in the CL that landed and got reverted (PS1), the Adapter had its own message handler, and callbacks would be invoked even if the PC was destroyed. In PS2 I've changed the Adapter to use the PeerConnection's message handler. If the PC is destroyed, the callback will not be invoked. This gives identical behavior to before this CL, and the legacy behavior is covered by a new unittest. I changed the adapter to be an implementation detail of peerconnection.cc, therefor some stuff was moved, and the only tests covering this is now in peerconnection_rtp_unittest.cc. This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72 Original change's description: > SetRemoteDescriptionObserverInterface added. > > The new observer replaced SetSessionDescriptionObserver for > SetRemoteDescription. Unlike SetSessionDescriptionObserver, > SetRemoteDescriptionObserverInterface is invoked synchronously so > that the you can rely on the state of the PeerConnection to represent > the result of the SetRemoteDescription call in the callback. > > The new observer succeeds or fails with an RTCError. > > This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack > and SetSessionDescriptionObserver, with the benefit that all media > object changes can be processed in a single callback by the application > in a synchronous callback. This will help Chromium keep objects in-sync > across layers and threads in a non-racy and straight-forward way, see > design doc (Proposal 2): > https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing > > An adapter for SetSessionDescriptionObserver is added to allow calling > the old SetRemoteDescription signature and get the old behavior > (OnSuccess/OnFailure callback in a Post) until third parties switch. > > Bug: webrtc:8473 > Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99 > Reviewed-on: https://webrtc-review.googlesource.com/17523 > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > Reviewed-by: Guido Urdaneta <guidou@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20841} TBR=pthatcher@webrtc.org Bug: webrtc:8473 Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5 Reviewed-on: https://webrtc-review.googlesource.com/25640 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Guido Urdaneta <guidou@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
void SetRemoteDescription(
std::unique_ptr<SessionDescriptionInterface> desc,
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
override;
Reland "[Perfect Negotiation] Implement non-racy version of SetLocalDescription." This is a reland of d4089cae47334a4228b69d6bb23f2e49ebb7496e with the following fix: Invoke MaybeStartGathering as the last step of DoSetLocalDescription. This ensures that candidates and onicegatheringstatechange does not happen before SLD is resolved. This is important for passing external/wpt/webrtc/RTCPeerConnection-iceGatheringState.html. Original change's description: > [Perfect Negotiation] Implement non-racy version of SetLocalDescription. > > BACKGROUND > > When SLD is invoked with SetSessionDescriptionObserver, the observer is > called by posting a message back to the execution thread, delaying the > call. This delay is "artificial" - it's not necessary; the operation is > already complete. It's a post from the signaling thread to the signaling > thread. The rationale for the post was to avoid the observer making > recursive calls back into the PeerConnection. The problem with this is > that by the time the observer is called, the PeerConnection could > already have executed other operations and modified its states. > > This causes the referenced bug: one can have a race where SLD is > resolved "too late" (after a pending SRD is executed) and the signaling > state observed when SLD resolves doesn't make sense. > > When implementing Unified Plan, we fixed similar issues for SRD by > adding a version that takes SetRemoteDescriptionObserverInterface as > argument instead of SetSessionDescriptionObserver. The new version did > not have the delay. The old version had to be kept around not to break > downstream projects that had dependencies both on he delay and on > allowing the PC to be destroyed midst-operation without informing its > observers. > > THIS CL > > This does the old SRD fix for SLD as well: A new observer interface is > added, SetLocalDescriptionObserverInterface, and > PeerConnection::SetLocalDescription() is overloaded. If you call it with > the old observer, you get the delay, but if you call it with the new > observer, you don't get a delay. > > - SetLocalDescriptionObserverInterface is added. > - SetLocalDescription is overloaded. > - The adapter for SetSessionDescriptionObserver that causes the delay > previously only used for SRD is updated to handle both SLD and SRD. > - FakeSetLocalDescriptionObserver is added and > MockSetRemoteDescriptionObserver is renamed "Fake...". > > Bug: chromium:1071733 > Change-Id: I920368e648bede481058ac22f5b8794752a220b3 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/179100 > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Reviewed-by: Harald Alvestrand <hta@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#31798} TBR=hta@webrtc.org Bug: chromium:1071733 Change-Id: Ic6e8d96afa1c19604762f373716c08dbfa9d178c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/180481 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31804}
2020-07-29 12:04:00 +02:00
// TODO(https://crbug.com/webrtc/11798): Delete this methods in favor of the
// ones taking SetRemoteDescriptionObserverInterface as argument.
void SetRemoteDescription(SetSessionDescriptionObserver* observer,
SessionDescriptionInterface* desc) override;
PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
RTCError SetConfiguration(
const PeerConnectionInterface::RTCConfiguration& configuration) override;
bool AddIceCandidate(const IceCandidateInterface* candidate) override;
void AddIceCandidate(std::unique_ptr<IceCandidateInterface> candidate,
std::function<void(RTCError)> callback) override;
bool RemoveIceCandidates(
const std::vector<cricket::Candidate>& candidates) override;
RTCError SetBitrate(const BitrateSettings& bitrate) override;
void SetAudioPlayout(bool playout) override;
void SetAudioRecording(bool recording) override;
rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
const std::string& mid) override;
rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMidInternal(
const std::string& mid);
rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const override;
void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
Revert "Revert "Encode log events periodically instead of for every event."" This reverts commit 33c5c7f5e4f018a5103770021328fc530d451d75. Reason for revert: Fix broken API change. TBR=sprang@webrtc.org,solenberg@webrtc.org TBRing because only pc/ and api/ have changed since last LGTMed version. Original change's description: > Revert "Encode log events periodically instead of for every event." > > This reverts commit b154c27e72fddb6c0d7cac69a9c68fff22154519. > > Reason for revert: Broke the internal project. > > Original change's description: > > Encode log events periodically instead of for every event. > > > > Updated unit test to take output_period and random seed as parameters. > > Updated the peerconnection interface to allow passing in an output_period. > > > > This is in preparation of some upcoming CLs that will change the format > > to store batches of delta-encoded values. > > > > > > Bug: webrtc:8111 > > Change-Id: Id5d9844dfad8d8edad346cd7cbebc7eadaaa5416 > > Reviewed-on: https://webrtc-review.googlesource.com/22600 > > Commit-Queue: Björn Terelius <terelius@webrtc.org> > > Reviewed-by: Elad Alon <eladalon@webrtc.org> > > Reviewed-by: Tommi <tommi@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20736} > > Change-Id: I2257c46c014adb8c7c4fb28538635cabed1f2229 > Bug: webrtc:8111 > Reviewed-on: https://webrtc-review.googlesource.com/24160 > Reviewed-by: Zhi Huang <zhihuang@webrtc.org> > Commit-Queue: Zhi Huang <zhihuang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20738} Bug: webrtc:8111 Change-Id: Ie69862cd52d11c1e15adeb6e2caacafe16863c80 Reviewed-on: https://webrtc-review.googlesource.com/24620 Commit-Queue: Björn Terelius <terelius@webrtc.org> Reviewed-by: Elad Alon <eladalon@webrtc.org> Reviewed-by: Zhi Huang <zhihuang@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20811}
2017-11-20 17:38:14 +01:00
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms) override;
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override;
void StopRtcEventLog() override;
void Close() override;
rtc::Thread* signaling_thread() const final {
return factory_->signaling_thread();
}
// PeerConnectionInternal implementation.
rtc::Thread* network_thread() const final {
return factory_->network_thread();
}
rtc::Thread* worker_thread() const final { return factory_->worker_thread(); }
std::string session_id() const override {
RTC_DCHECK_RUN_ON(signaling_thread());
return session_id_;
}
bool initial_offerer() const override {
RTC_DCHECK_RUN_ON(signaling_thread());
return transport_controller_ && transport_controller_->initial_offerer();
}
std::vector<
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
GetTransceiversInternal() const override {
RTC_DCHECK_RUN_ON(signaling_thread());
return transceivers_.List();
}
sigslot::signal1<RtpDataChannel*>& SignalRtpDataChannelCreated() override {
return data_channel_controller_.SignalRtpDataChannelCreated();
}
sigslot::signal1<SctpDataChannel*>& SignalSctpDataChannelCreated() override {
return data_channel_controller_.SignalSctpDataChannelCreated();
}
cricket::RtpDataChannel* rtp_data_channel() const override {
return data_channel_controller_.rtp_data_channel();
}
std::vector<DataChannelStats> GetDataChannelStats() const override;
absl::optional<std::string> sctp_transport_name() const override;
cricket::CandidateStatsList GetPooledCandidateStats() const override;
std::map<std::string, std::string> GetTransportNamesByMid() const override;
std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
const std::set<std::string>& transport_names) override;
Call::Stats GetCallStats() override;
bool GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override;
std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
const std::string& transport_name) override;
bool IceRestartPending(const std::string& content_name) const override;
bool NeedsIceRestart(const std::string& content_name) const override;
bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override;
// Functions needed by DataChannelController
void NoteDataAddedEvent() { NoteUsageEvent(UsageEvent::DATA_ADDED); }
// Returns the observer. Will crash on CHECK if the observer is removed.
PeerConnectionObserver* Observer() const;
bool IsClosed() const {
RTC_DCHECK_RUN_ON(signaling_thread());
return sdp_handler_.signaling_state() == PeerConnectionInterface::kClosed;
}
// Get current SSL role used by SCTP's underlying transport.
bool GetSctpSslRole(rtc::SSLRole* role);
// Handler for the "channel closed" signal
void OnSctpDataChannelClosed(DataChannelInterface* channel);
bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override;
// Functions needed by SdpOfferAnswerHandler
StatsCollector* stats() {
RTC_DCHECK_RUN_ON(signaling_thread());
return stats_.get();
}
DataChannelController* data_channel_controller() {
RTC_DCHECK_RUN_ON(signaling_thread());
return &data_channel_controller_;
}
bool dtls_enabled() const {
RTC_DCHECK_RUN_ON(signaling_thread());
return dtls_enabled_;
}
const PeerConnectionInterface::RTCConfiguration* configuration() const {
RTC_DCHECK_RUN_ON(signaling_thread());
return &configuration_;
}
absl::optional<std::string> sctp_mid() {
RTC_DCHECK_RUN_ON(signaling_thread());
return sctp_mid_s_;
}
PeerConnectionMessageHandler* message_handler() {
RTC_DCHECK_RUN_ON(signaling_thread());
return &message_handler_;
}
// Functions made public for testing.
void ReturnHistogramVeryQuicklyForTesting() {
RTC_DCHECK_RUN_ON(signaling_thread());
return_histogram_very_quickly_ = true;
}
void RequestUsagePatternReportForTesting();
protected:
~PeerConnection() override;
private:
// While refactoring: Allow access from SDP negotiation
// TOOD(https://bugs.webrtc.org/11995): Remove friendship.
friend class SdpOfferAnswerHandler;
Reland "SetRemoteDescriptionObserverInterface added." Description for changes from the original CL: Calling legacy SRD, implemented using SetRemoteDescriptionObserverAdapter wrapping the old observer, was meant to have the exact same behavior as the legacy SRD implementation which invokes the callbacks in a Post. However, in the CL that landed and got reverted (PS1), the Adapter had its own message handler, and callbacks would be invoked even if the PC was destroyed. In PS2 I've changed the Adapter to use the PeerConnection's message handler. If the PC is destroyed, the callback will not be invoked. This gives identical behavior to before this CL, and the legacy behavior is covered by a new unittest. I changed the adapter to be an implementation detail of peerconnection.cc, therefor some stuff was moved, and the only tests covering this is now in peerconnection_rtp_unittest.cc. This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72 Original change's description: > SetRemoteDescriptionObserverInterface added. > > The new observer replaced SetSessionDescriptionObserver for > SetRemoteDescription. Unlike SetSessionDescriptionObserver, > SetRemoteDescriptionObserverInterface is invoked synchronously so > that the you can rely on the state of the PeerConnection to represent > the result of the SetRemoteDescription call in the callback. > > The new observer succeeds or fails with an RTCError. > > This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack > and SetSessionDescriptionObserver, with the benefit that all media > object changes can be processed in a single callback by the application > in a synchronous callback. This will help Chromium keep objects in-sync > across layers and threads in a non-racy and straight-forward way, see > design doc (Proposal 2): > https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing > > An adapter for SetSessionDescriptionObserver is added to allow calling > the old SetRemoteDescription signature and get the old behavior > (OnSuccess/OnFailure callback in a Post) until third parties switch. > > Bug: webrtc:8473 > Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99 > Reviewed-on: https://webrtc-review.googlesource.com/17523 > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > Reviewed-by: Guido Urdaneta <guidou@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20841} TBR=pthatcher@webrtc.org Bug: webrtc:8473 Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5 Reviewed-on: https://webrtc-review.googlesource.com/25640 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Guido Urdaneta <guidou@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
struct RtpSenderInfo {
RtpSenderInfo() : first_ssrc(0) {}
RtpSenderInfo(const std::string& stream_id,
const std::string sender_id,
uint32_t ssrc)
: stream_id(stream_id), sender_id(sender_id), first_ssrc(ssrc) {}
bool operator==(const RtpSenderInfo& other) {
return this->stream_id == other.stream_id &&
this->sender_id == other.sender_id &&
this->first_ssrc == other.first_ssrc;
}
std::string stream_id;
std::string sender_id;
// An RtpSender can have many SSRCs. The first one is used as a sort of ID
// for communicating with the lower layers.
uint32_t first_ssrc;
};
// Plan B helpers for getting the voice/video media channels for the single
// audio/video transceiver, if it exists.
cricket::VoiceMediaChannel* voice_media_channel() const
RTC_RUN_ON(signaling_thread());
cricket::VideoMediaChannel* video_media_channel() const
RTC_RUN_ON(signaling_thread());
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
GetSendersInternal() const;
std::vector<
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
GetReceiversInternal() const RTC_RUN_ON(signaling_thread());
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
GetAudioTransceiver() const;
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
GetVideoTransceiver() const;
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
GetFirstAudioTransceiver() const RTC_RUN_ON(signaling_thread());
Reland "[PeerConnection] Use an OperationsChain in PeerConnection for async ops." This is a reland of 1dddaa1a84330091ca083c950ef2e24a85a48fc8 The regression that caused the original CL to be reverted was the fact that invoking SetLocalDescription() inside of the CreateOffer() callback was no longer executing synchronously and immediately. In this CL, the original CL is patched so that the CreateOffer() operation is marked as completed just before invoking the CreateOffer() callback (versus doing it just afterwards). This ensures that the OperationsChain is popped before the callback runs. The same applies for CreateAnswer(). See diff between Patch Set 1 (Original CL) and the latest Patch Set. Original change's description: > [PeerConnection] Use an OperationsChain in PeerConnection for async ops. > > For background, motivation, requirements and implementation notes, see > https://docs.google.com/document/d/1XLwNN2kUIGGTwz9LQ0NwJNkcybi9oKnynUEZB1jGA14/edit?usp=sharing > > Using the OperationsChain will unblock future CLs from chaining multiple > operations together such as implementing parameterless > setLocalDescription(). > > In this CL, the OperationsChain is used in existing signaling operations > with little intended side-effects. An operation that is chained onto an > empty OperationsChain will for instance execute immediately, and > SetLocalDescription() and SetRemoteDescription() are implemented as > "synchronous operations". > > The lifetime of the PeerConnection is not indended to change as a result > of this CL: All chained operations use a WeakPtr to the PC to ensure > use-after-free does not happen. > > There is one notable change though: CreateOffer() and CreateAnswer() will > asynchronously delay other signaling methods from executing until they > have completed. > > Drive-by fix: This CL also ensures that early failing > CreateOffer/CreateAnswer operation's observers are invoked if the > PeerConnection is destroyed while a PostCreateSessionDescriptionFailure > is pending. > > Bug: webrtc:11019 > Change-Id: I521333e41d20d9bbfb1e721609f2c9db2a5f93a9 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/157305 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29605} TBR=steveanton@webrtc.org Bug: webrtc:11019 Change-Id: I57b4496e63378c91c24679ee496e21f5cb6a0e59 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158524 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29630}
2019-10-28 12:09:49 +01:00
void CreateAudioReceiver(MediaStreamInterface* stream,
const RtpSenderInfo& remote_sender_info)
RTC_RUN_ON(signaling_thread());
void CreateVideoReceiver(MediaStreamInterface* stream,
const RtpSenderInfo& remote_sender_info)
RTC_RUN_ON(signaling_thread());
Reland "Added PeerConnectionObserver::OnRemoveTrack." This reverts commit 6c0c55c31817ecfa32409424495eb68b31828c40. Reason for revert: Fixed the flake. Original change's description: > Revert "Added PeerConnectionObserver::OnRemoveTrack." > > This reverts commit ba97ba7af917d4152f5f3363aba1c1561c6673dc. > > Reason for revert: The new tests have caused several test failures on the test bots; the method FakeAudioMediaStreamTrack:GetSignalLevel, which is not supposed to be called is sometimes called anyway. > > Original change's description: > > Added PeerConnectionObserver::OnRemoveTrack. > > > > This corresponds to processing the removal of a remote track step of > > the spec, with processing the addition of a remote track already > > covered by OnAddTrack. > > https://w3c.github.io/webrtc-pc/#processing-remote-mediastreamtracks > > > > Bug: webrtc:8260, webrtc:8315 > > Change-Id: Ica8be92369733eb3cf1397fb60385d45a9b58700 > > Reviewed-on: https://webrtc-review.googlesource.com/4722 > > Commit-Queue: Henrik Boström <hbos@webrtc.org> > > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20214} > > TBR=steveanton@webrtc.org,deadbeef@webrtc.org,hbos@webrtc.org > > Change-Id: Id2d9533e27227254769b4280a8ff10a47313e714 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:8260, webrtc:8315 > Reviewed-on: https://webrtc-review.googlesource.com/7940 > Reviewed-by: Alex Loiko <aleloi@webrtc.org> > Commit-Queue: Alex Loiko <aleloi@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20218} TBR=steveanton@webrtc.org,deadbeef@webrtc.org,aleloi@webrtc.org,hbos@webrtc.org Change-Id: Iab7500bebf98535754b102874259de43831fff6b No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:8260, webrtc:8315 Reviewed-on: https://webrtc-review.googlesource.com/8180 Commit-Queue: Henrik Boström <hbos@webrtc.org> Reviewed-by: Henrik Boström <hbos@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20227}
2017-10-10 10:05:16 -07:00
rtc::scoped_refptr<RtpReceiverInterface> RemoveAndStopReceiver(
const RtpSenderInfo& remote_sender_info) RTC_RUN_ON(signaling_thread());
// May be called either by AddStream/RemoveStream, or when a track is
// added/removed from a stream previously added via AddStream.
void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream);
void RemoveAudioTrack(AudioTrackInterface* track,
MediaStreamInterface* stream);
void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream);
void RemoveVideoTrack(VideoTrackInterface* track,
MediaStreamInterface* stream);
// AddTrack implementation when Unified Plan is specified.
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackUnifiedPlan(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids)
RTC_RUN_ON(signaling_thread());
// AddTrack implementation when Plan B is specified.
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackPlanB(
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids)
RTC_RUN_ON(signaling_thread());
// Returns the first RtpTransceiver suitable for a newly added track, if such
// transceiver is available.
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
FindFirstTransceiverForAddedTrack(
rtc::scoped_refptr<MediaStreamTrackInterface> track)
RTC_RUN_ON(signaling_thread());
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender)
RTC_RUN_ON(signaling_thread());
// Internal implementation for AddTransceiver family of methods. If
// |fire_callback| is set, fires OnRenegotiationNeeded callback if successful.
Reland "Add AddTransceiver and GetTransceivers to PeerConnection" This reverts commit 8b13f96e2d4b0449e54a3665121a4302ceb56e80. Original change's description: > Revert "Add AddTransceiver and GetTransceivers to PeerConnection" > > This reverts commit f93d2800d9b0d5818a5a383def0aaef3d441df3a. > > Reason for revert: https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2Fios-device%2F5804%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout > > Original change's description: > > Add AddTransceiver and GetTransceivers to PeerConnection > > > > WebRTC 1.0 has added the transceiver API to PeerConnection. This > > is the first step towards exposing this to WebRTC consumers. For > > now, transceivers can be added and fetched but there is not yet > > support for creating offers/answers or setting local/remote > > descriptions. That support ("Unified Plan") will be added in > > follow-up CLs. > > > > The transceiver API is currently only available if the application > > opts in by specifying the kUnifiedPlan SDP semantics when creating > > the PeerConnection. > > > > Bug: webrtc:7600 > > Change-Id: I0b8ee24b489b45bb4c5f60b699bd20c61af01d8e > > Reviewed-on: https://webrtc-review.googlesource.com/23880 > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20896} > > TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org > > Change-Id: Ie91ea4988dba25c20e2532114d3a9d859a932d4c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7600 > Reviewed-on: https://webrtc-review.googlesource.com/26400 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20897} TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org Change-Id: I19fdf08c54f09302794e998a0ffddb82ae0d7b41 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7600 Reviewed-on: https://webrtc-review.googlesource.com/26401 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20898}
2017-11-27 13:01:52 -08:00
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
cricket::MediaType media_type,
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const RtpTransceiverInit& init,
bool fire_callback = true);
Reland "Add AddTransceiver and GetTransceivers to PeerConnection" This reverts commit 8b13f96e2d4b0449e54a3665121a4302ceb56e80. Original change's description: > Revert "Add AddTransceiver and GetTransceivers to PeerConnection" > > This reverts commit f93d2800d9b0d5818a5a383def0aaef3d441df3a. > > Reason for revert: https://logs.chromium.org/v/?s=chromium%2Fbb%2Fchromium.webrtc.fyi%2Fios-device%2F5804%2F%2B%2Frecipes%2Fsteps%2Fcompile%2F0%2Fstdout > > Original change's description: > > Add AddTransceiver and GetTransceivers to PeerConnection > > > > WebRTC 1.0 has added the transceiver API to PeerConnection. This > > is the first step towards exposing this to WebRTC consumers. For > > now, transceivers can be added and fetched but there is not yet > > support for creating offers/answers or setting local/remote > > descriptions. That support ("Unified Plan") will be added in > > follow-up CLs. > > > > The transceiver API is currently only available if the application > > opts in by specifying the kUnifiedPlan SDP semantics when creating > > the PeerConnection. > > > > Bug: webrtc:7600 > > Change-Id: I0b8ee24b489b45bb4c5f60b699bd20c61af01d8e > > Reviewed-on: https://webrtc-review.googlesource.com/23880 > > Commit-Queue: Steve Anton <steveanton@webrtc.org> > > Reviewed-by: Peter Thatcher <pthatcher@webrtc.org> > > Reviewed-by: Henrik Boström <hbos@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20896} > > TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org > > Change-Id: Ie91ea4988dba25c20e2532114d3a9d859a932d4c > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:7600 > Reviewed-on: https://webrtc-review.googlesource.com/26400 > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20897} TBR=steveanton@webrtc.org,zhihuang@webrtc.org,hbos@webrtc.org,pthatcher@webrtc.org Change-Id: I19fdf08c54f09302794e998a0ffddb82ae0d7b41 No-Presubmit: true No-Tree-Checks: true No-Try: true Bug: webrtc:7600 Reviewed-on: https://webrtc-review.googlesource.com/26401 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20898}
2017-11-27 13:01:52 -08:00
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
CreateSender(cricket::MediaType media_type,
const std::string& id,
rtc::scoped_refptr<MediaStreamTrackInterface> track,
const std::vector<std::string>& stream_ids,
const std::vector<RtpEncodingParameters>& send_encodings);
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
CreateReceiver(cricket::MediaType media_type, const std::string& receiver_id);
// Create a new RtpTransceiver of the given type and add it to the list of
// transceivers.
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
CreateAndAddTransceiver(
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender,
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
receiver);
void SetIceConnectionState(IceConnectionState new_state);
void SetStandardizedIceConnectionState(
PeerConnectionInterface::IceConnectionState new_state)
RTC_RUN_ON(signaling_thread());
void SetConnectionState(
PeerConnectionInterface::PeerConnectionState new_state)
RTC_RUN_ON(signaling_thread());
// Called any time the IceGatheringState changes.
void OnIceGatheringChange(IceGatheringState new_state)
RTC_RUN_ON(signaling_thread());
// New ICE candidate has been gathered.
void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate)
RTC_RUN_ON(signaling_thread());
// Gathering of an ICE candidate failed.
void OnIceCandidateError(const std::string& address,
int port,
const std::string& url,
int error_code,
const std::string& error_text)
RTC_RUN_ON(signaling_thread());
// Some local ICE candidates have been removed.
void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates)
RTC_RUN_ON(signaling_thread());
void OnSelectedCandidatePairChanged(
const cricket::CandidatePairChangeEvent& event)
RTC_RUN_ON(signaling_thread());
// Signals from MediaStreamObserver.
void OnAudioTrackAdded(AudioTrackInterface* track,
MediaStreamInterface* stream)
RTC_RUN_ON(signaling_thread());
void OnAudioTrackRemoved(AudioTrackInterface* track,
MediaStreamInterface* stream)
RTC_RUN_ON(signaling_thread());
void OnVideoTrackAdded(VideoTrackInterface* track,
MediaStreamInterface* stream)
RTC_RUN_ON(signaling_thread());
void OnVideoTrackRemoved(VideoTrackInterface* track,
MediaStreamInterface* stream)
RTC_RUN_ON(signaling_thread());
void OnNegotiationNeeded();
// Returns the MID for the data section associated with either the
// RtpDataChannel or SCTP data channel, if it has been set. If no data
// channels are configured this will return nullopt.
absl::optional<std::string> GetDataMid() const;
// Triggered when a remote sender has been seen for the first time in a remote
// session description. It creates a remote MediaStreamTrackInterface
// implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
void OnRemoteSenderAdded(const RtpSenderInfo& sender_info,
MediaStreamInterface* stream,
cricket::MediaType media_type);
// Triggered when a remote sender has been removed from a remote session
// description. It removes the remote sender with id |sender_id| from a remote
// MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
void OnRemoteSenderRemoved(const RtpSenderInfo& sender_info,
MediaStreamInterface* stream,
cricket::MediaType media_type);
// Triggered when a local sender has been seen for the first time in a local
// session description.
// This method triggers CreateAudioSender or CreateVideoSender if the rtp
// streams in the local SessionDescription can be mapped to a MediaStreamTrack
// in a MediaStream in |local_streams_|
void OnLocalSenderAdded(const RtpSenderInfo& sender_info,
cricket::MediaType media_type);
// Triggered when a local sender has been removed from a local session
// description.
// This method triggers DestroyAudioSender or DestroyVideoSender if a stream
// has been removed from the local SessionDescription and the stream can be
// mapped to a MediaStreamTrack in a MediaStream in |local_streams_|.
void OnLocalSenderRemoved(const RtpSenderInfo& sender_info,
cricket::MediaType media_type);
// Returns true if the PeerConnection is configured to use Unified Plan
// semantics for creating offers/answers and setting local/remote
// descriptions. If this is true the RtpTransceiver API will also be available
// to the user. If this is false, Plan B semantics are assumed.
// TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once
// sufficient time has passed.
bool IsUnifiedPlan() const {
RTC_DCHECK_RUN_ON(signaling_thread());
return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan;
}
// Return the RtpSender with the given track attached.
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
FindSenderForTrack(MediaStreamTrackInterface* track) const
RTC_RUN_ON(signaling_thread());
// Return the RtpSender with the given id, or null if none exists.
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
FindSenderById(const std::string& sender_id) const
RTC_RUN_ON(signaling_thread());
// Return the RtpReceiver with the given id, or null if none exists.
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
FindReceiverById(const std::string& receiver_id) const
RTC_RUN_ON(signaling_thread());
std::vector<RtpSenderInfo>* GetRemoteSenderInfos(
cricket::MediaType media_type);
std::vector<RtpSenderInfo>* GetLocalSenderInfos(
cricket::MediaType media_type);
const RtpSenderInfo* FindSenderInfo(const std::vector<RtpSenderInfo>& infos,
Revert "Adds support for multiple or no media stream ids." This reverts commit 1550292efe680ac79a18004705c908b1cdca54cb. Reason for revert: webkit_layout_tests:fast/peerconnection/RTCPeerConnection-sdpSemantics.html is broken, see below. WebRTC roll isn't going through because of it. This CL looks the most suspicious within the 5 in the range. https://chromium-review.googlesource.com/c/chromium/src/+/981899 https://webrtc.googlesource.com/src.git/+log/bb50ce5bb6d5..27f3bf512827 https://ci.chromium.org/p/chromium/builders/luci.chromium.try/linux_chromium_rel_ng/54616 Original change's description: > Adds support for multiple or no media stream ids. > > With Unified Plan SDP semantics, this adds support for specifying > either no media stream ids or multiple media stream ids for a > transceiver/sender/receiver. This includes serializing/deserializing > SDPs with multiple a=msid lines in a m section, or an "a=msid:- > <appdata>" line to indicate the no stream case. Note that this does > not synchronize between multiple streams, this is still just supported > based upon the first media stream id. > > Bug: webrtc:7932, webrtc:7933 > Change-Id: Ib7433929af7b2925abe2824b485b360cec12f275 > Reviewed-on: https://webrtc-review.googlesource.com/61341 > Commit-Queue: Seth Hampson <shampson@webrtc.org> > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#22611} TBR=steveanton@webrtc.org,deadbeef@webrtc.org,shampson@webrtc.org # Not skipping CQ checks because original CL landed > 1 day ago. Bug: webrtc:7932, webrtc:7933 Change-Id: I1d4e4332b518ec32b305c8af07679650059d02bb Reviewed-on: https://webrtc-review.googlesource.com/65000 Reviewed-by: Emircan Uysaler <emircan@webrtc.org> Commit-Queue: Emircan Uysaler <emircan@webrtc.org> Cr-Commit-Position: refs/heads/master@{#22634}
2018-03-27 21:57:18 +00:00
const std::string& stream_id,
const std::string sender_id) const;
// Returns the specified SCTP DataChannel in sctp_data_channels_,
// or nullptr if not found.
SctpDataChannel* FindDataChannelBySid(int sid) const
RTC_RUN_ON(signaling_thread());
// Called when first configuring the port allocator.
struct InitializePortAllocatorResult {
bool enable_ipv6;
};
InitializePortAllocatorResult InitializePortAllocator_n(
const cricket::ServerAddresses& stun_servers,
const std::vector<cricket::RelayServerConfig>& turn_servers,
const RTCConfiguration& configuration);
// Called when SetConfiguration is called to apply the supported subset
// of the configuration on the network thread.
bool ReconfigurePortAllocator_n(
const cricket::ServerAddresses& stun_servers,
const std::vector<cricket::RelayServerConfig>& turn_servers,
IceTransportsType type,
int candidate_pool_size,
PortPrunePolicy turn_port_prune_policy,
webrtc::TurnCustomizer* turn_customizer,
absl::optional<int> stun_candidate_keepalive_interval,
bool have_local_description);
// Starts output of an RTC event log to the given output object.
// This function should only be called from the worker thread.
Revert "Revert "Encode log events periodically instead of for every event."" This reverts commit 33c5c7f5e4f018a5103770021328fc530d451d75. Reason for revert: Fix broken API change. TBR=sprang@webrtc.org,solenberg@webrtc.org TBRing because only pc/ and api/ have changed since last LGTMed version. Original change's description: > Revert "Encode log events periodically instead of for every event." > > This reverts commit b154c27e72fddb6c0d7cac69a9c68fff22154519. > > Reason for revert: Broke the internal project. > > Original change's description: > > Encode log events periodically instead of for every event. > > > > Updated unit test to take output_period and random seed as parameters. > > Updated the peerconnection interface to allow passing in an output_period. > > > > This is in preparation of some upcoming CLs that will change the format > > to store batches of delta-encoded values. > > > > > > Bug: webrtc:8111 > > Change-Id: Id5d9844dfad8d8edad346cd7cbebc7eadaaa5416 > > Reviewed-on: https://webrtc-review.googlesource.com/22600 > > Commit-Queue: Björn Terelius <terelius@webrtc.org> > > Reviewed-by: Elad Alon <eladalon@webrtc.org> > > Reviewed-by: Tommi <tommi@webrtc.org> > > Reviewed-by: Erik Språng <sprang@webrtc.org> > > Reviewed-by: Fredrik Solenberg <solenberg@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#20736} > > Change-Id: I2257c46c014adb8c7c4fb28538635cabed1f2229 > Bug: webrtc:8111 > Reviewed-on: https://webrtc-review.googlesource.com/24160 > Reviewed-by: Zhi Huang <zhihuang@webrtc.org> > Commit-Queue: Zhi Huang <zhihuang@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#20738} Bug: webrtc:8111 Change-Id: Ie69862cd52d11c1e15adeb6e2caacafe16863c80 Reviewed-on: https://webrtc-review.googlesource.com/24620 Commit-Queue: Björn Terelius <terelius@webrtc.org> Reviewed-by: Elad Alon <eladalon@webrtc.org> Reviewed-by: Zhi Huang <zhihuang@webrtc.org> Reviewed-by: Tommi <tommi@webrtc.org> Reviewed-by: Björn Terelius <terelius@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20811}
2017-11-20 17:38:14 +01:00
bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output,
int64_t output_period_ms);
// Stops recording an RTC event log.
// This function should only be called from the worker thread.
void StopRtcEventLog_w();
// Ensures the configuration doesn't have any parameters with invalid values,
// or values that conflict with other parameters.
//
// Returns RTCError::OK() if there are no issues.
RTCError ValidateConfiguration(const RTCConfiguration& config) const;
cricket::ChannelManager* channel_manager() const;
cricket::ChannelInterface* GetChannel(const std::string& content_name);
cricket::IceConfig ParseIceConfig(
const PeerConnectionInterface::RTCConfiguration& config) const;
cricket::DataChannelType data_channel_type() const;
// Called when an RTCCertificate is generated or retrieved by
// WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
void OnCertificateReady(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
// Returns true and the TransportInfo of the given |content_name|
// from |description|. Returns false if it's not available.
static bool GetTransportDescription(
const cricket::SessionDescription* description,
const std::string& content_name,
cricket::TransportDescription* info);
// Returns the media index for a local ice candidate given the content name.
// Returns false if the local session description does not have a media
// content called |content_name|.
bool GetLocalCandidateMediaIndex(const std::string& content_name,
int* sdp_mline_index)
RTC_RUN_ON(signaling_thread());
Changes to enable use of DatagramTransport as a data channel transport. PeerConnection now has a new setting in RTCConfiguration to enable use of datagram transport for data channels. There is also a corresponding field trial, which has both a kill-switch and a way to change the default value. PeerConnection's interaction with MediaTransport for data channels has been refactored to work with DataChannelTransportInterface instead. Adds a DataChannelState and OnStateChanged() to the DataChannelSink callbacks. This allows PeerConnection to listen to the data channel's state directly, instead of indirectly by monitoring media transport state. This is necessary to enable use of non-media-transport (eg. datagram transport) data channel transports. For now, PeerConnection watches the state through MediaTransport as well. This will persist until MediaTransport implements the new callback. Datagram transport use is negotiated. As such, an offer that requests to use datagram transport for data channels may be rejected by the answerer. If the offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data channels with an extra x-opaque parameter for datagram transport. If the opaque parameter is rejected (by an answerer without datagram support), the offerer may fall back to SCTP. If DTLS is not enabled, there is no viable fallback. In this case, the data channels are negotiated as media transport data channels. If the receiver does not understand the x-opaque line, it will reject these data channels, and the offerer's data channels will be closed. Bug: webrtc:9719 Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702 Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
bool SetupDataChannelTransport_n(const std::string& mid)
RTC_RUN_ON(network_thread());
Changes to enable use of DatagramTransport as a data channel transport. PeerConnection now has a new setting in RTCConfiguration to enable use of datagram transport for data channels. There is also a corresponding field trial, which has both a kill-switch and a way to change the default value. PeerConnection's interaction with MediaTransport for data channels has been refactored to work with DataChannelTransportInterface instead. Adds a DataChannelState and OnStateChanged() to the DataChannelSink callbacks. This allows PeerConnection to listen to the data channel's state directly, instead of indirectly by monitoring media transport state. This is necessary to enable use of non-media-transport (eg. datagram transport) data channel transports. For now, PeerConnection watches the state through MediaTransport as well. This will persist until MediaTransport implements the new callback. Datagram transport use is negotiated. As such, an offer that requests to use datagram transport for data channels may be rejected by the answerer. If the offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data channels with an extra x-opaque parameter for datagram transport. If the opaque parameter is rejected (by an answerer without datagram support), the offerer may fall back to SCTP. If DTLS is not enabled, there is no viable fallback. In this case, the data channels are negotiated as media transport data channels. If the receiver does not understand the x-opaque line, it will reject these data channels, and the offerer's data channels will be closed. Bug: webrtc:9719 Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702 Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
void TeardownDataChannelTransport_n() RTC_RUN_ON(network_thread());
bool ValidateBundleSettings(const cricket::SessionDescription* desc);
bool HasRtcpMuxEnabled(const cricket::ContentInfo* content);
// Verifies a=setup attribute as per RFC 5763.
bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
SdpType type);
// Returns true if SRTP (either using DTLS-SRTP or SDES) is required by
// this session.
bool SrtpRequired() const RTC_RUN_ON(signaling_thread());
// JsepTransportController signal handlers.
void OnTransportControllerConnectionState(cricket::IceConnectionState state)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerGatheringState(cricket::IceGatheringState state)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerCandidatesGathered(
const std::string& transport_name,
const std::vector<cricket::Candidate>& candidates)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerCandidateError(
const cricket::IceCandidateErrorEvent& event)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerCandidatesRemoved(
const std::vector<cricket::Candidate>& candidates)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerCandidateChanged(
const cricket::CandidatePairChangeEvent& event)
RTC_RUN_ON(signaling_thread());
void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
// Report the UMA metric SdpFormatReceived for the given remote offer.
void ReportSdpFormatReceived(const SessionDescriptionInterface& remote_offer);
// Invoked when TransportController connection completion is signaled.
// Reports stats for all transports in use.
void ReportTransportStats() RTC_RUN_ON(signaling_thread());
// Gather the usage of IPv4/IPv6 as best connection.
void ReportBestConnectionState(const cricket::TransportStats& stats);
void ReportNegotiatedCiphers(const cricket::TransportStats& stats,
const std::set<cricket::MediaType>& media_types)
RTC_RUN_ON(signaling_thread());
void ReportIceCandidateCollected(const cricket::Candidate& candidate)
RTC_RUN_ON(signaling_thread());
void NoteUsageEvent(UsageEvent event);
void ReportUsagePattern() const RTC_RUN_ON(signaling_thread());
void OnSentPacket_w(const rtc::SentPacket& sent_packet);
// JsepTransportController::Observer override.
//
// Called by |transport_controller_| when processing transport information
// from a session description, and the mapping from m= sections to transports
// changed (as a result of BUNDLE negotiation, or m= sections being
// rejected).
Changes to enable use of DatagramTransport as a data channel transport. PeerConnection now has a new setting in RTCConfiguration to enable use of datagram transport for data channels. There is also a corresponding field trial, which has both a kill-switch and a way to change the default value. PeerConnection's interaction with MediaTransport for data channels has been refactored to work with DataChannelTransportInterface instead. Adds a DataChannelState and OnStateChanged() to the DataChannelSink callbacks. This allows PeerConnection to listen to the data channel's state directly, instead of indirectly by monitoring media transport state. This is necessary to enable use of non-media-transport (eg. datagram transport) data channel transports. For now, PeerConnection watches the state through MediaTransport as well. This will persist until MediaTransport implements the new callback. Datagram transport use is negotiated. As such, an offer that requests to use datagram transport for data channels may be rejected by the answerer. If the offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data channels with an extra x-opaque parameter for datagram transport. If the opaque parameter is rejected (by an answerer without datagram support), the offerer may fall back to SCTP. If DTLS is not enabled, there is no viable fallback. In this case, the data channels are negotiated as media transport data channels. If the receiver does not understand the x-opaque line, it will reject these data channels, and the offerer's data channels will be closed. Bug: webrtc:9719 Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702 Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
bool OnTransportChanged(
const std::string& mid,
RtpTransportInternal* rtp_transport,
rtc::scoped_refptr<DtlsTransport> dtls_transport,
Reland "Reland "Refactor SCTP data channels to use DataChannelTransportInterface."" This is a reland of 487f9a17e426fd14bb06b13e861071b3f15d119b Original change's description: > Reland "Refactor SCTP data channels to use DataChannelTransportInterface." > > Also clears SctpTransport before deleting JsepTransport. > > SctpTransport is ref-counted, but the underlying transport is deleted when > JsepTransport clears the rtp_dtls_transport. This results in crashes when > usrsctp attempts to send outgoing packets through a dangling pointer to the > underlying transport. > > Clearing SctpTransport before DtlsTransport removes the pointer to the > underlying transport before it becomes invalid. > > This fixes a crash in chromium's web platform tests (see > https://chromium-review.googlesource.com/c/chromium/src/+/1776711). > > Original change's description: > > Refactor SCTP data channels to use DataChannelTransportInterface. > > > > This change moves SctpTransport to be owned by JsepTransport, which now > > holds a DataChannelTransport implementation for SCTP when it is used for > > data channels. > > > > This simplifies negotiation and fallback to SCTP. Negotiation can now > > use a composite DataChannelTransport, just as negotiation for RTP uses a > > composite RTP transport. > > > > PeerConnection also has one fewer way it needs to manage data channels. > > It now handles SCTP and datagram- or media-transport-based data channels > > the same way. > > > > There are a few leaky abstractions left. For example, PeerConnection > > calls Start() on the SctpTransport at a particular point in negotiation, > > but does not need to call this for other transports. Similarly, PC > > exposes an interface to the SCTP transport directly to the user; there > > is no equivalent for other transports. > > Bug: webrtc:9719 > Change-Id: I64e94b88afb119fdbf5f22750f88c8a084d53937 > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/151981 > Reviewed-by: Benjamin Wright <benwright@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Commit-Queue: Benjamin Wright <benwright@webrtc.org> > Commit-Queue: Bjorn Mellem <mellem@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#29120} Bug: webrtc:9719 Change-Id: I28481a3de64a3506bc57748106383eeba4ef205c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/152740 Reviewed-by: Artem Titov <titovartem@webrtc.org> Reviewed-by: Benjamin Wright <benwright@webrtc.org> Reviewed-by: Seth Hampson <shampson@webrtc.org> Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Cr-Commit-Position: refs/heads/master@{#29290}
2019-09-23 14:53:54 -07:00
DataChannelTransportInterface* data_channel_transport) override;
Add RtpSenderInterface.SetStreams This is a reland of df5731e44d510e9f23a35b77e9e102eb41919bf4 with fixes to avoid existing chromium tests to fail. Instead of replacing the existing RtpSender::set_stream_ids() to also fire OnRenegotiationNeeded(), this CL keeps the old set_stream_ids() and adds the new RtpSender::SetStreams() which sets the stream IDs and fires the callback. This allows existing callsites to maintain behavior, and reserve SetStreams() for the cases when we want OnRenegotiationNeeded() to fire. Using the SetStreams() name instead of SetStreamIDs() to match the W3C spec and to make it more different that the existing set_stream_ids(). Original change's description: > Improve spec compliance of SetStreamIDs in RtpSenderInterface > > This CL makes RtpSender::SetStreamIDs fire fire negotiationneeded > event if needed and exposes the method on RtpSenderInterface. > > This is a spec-compliance change. > > Bug: webrtc:10129 > Change-Id: I2b98b92665c847102838b094516a79b24de0e47e > Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135121 > Commit-Queue: Guido Urdaneta <guidou@webrtc.org> > Reviewed-by: Steve Anton <steveanton@webrtc.org> > Reviewed-by: Henrik Boström <hbos@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#27974} Bug: webrtc:10129 Change-Id: Ic0b322bfa25c157e3a39465ef8b486f898eaf6bd Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/137439 Commit-Queue: Guido Urdaneta <guidou@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#27992}
2019-05-20 19:31:53 +02:00
// RtpSenderBase::SetStreamsObserver override.
void OnSetStreams() override;
// Returns the CryptoOptions for this PeerConnection. This will always
// return the RTCConfiguration.crypto_options if set and will only default
// back to the PeerConnectionFactory settings if nothing was set.
CryptoOptions GetCryptoOptions();
Reland "Reland "Propagate media transport to media channel."" This is a reland of da65ed2adcfa57ff3288ce01c1602c973fcab00d Original change's description: > Reland "Propagate media transport to media channel." > > This reverts commit 37cf2455a420124b341ad06ac27fa3c4dbd29d3c. > > Reason for revert: <INSERT REASONING HERE> > > Original change's description: > > Revert "Propagate media transport to media channel." > > > > This reverts commit 8c16f745ab92cb6d305283e87fa8a661ae500ce4. > > > > Reason for revert: Breaks downstream project > > > > Original change's description: > > > Propagate media transport to media channel. > > > > > > 1. Pass media transport factory to JSEP transport controller. > > > 2. Pass media transport to voice media channel. > > > 3. Add basic unit test that make sure if peer connection is created with media transport, it is propagated to voice media channel. > > > > > > Change-Id: Ie922db78ade0efd893e019cd2b4441a9947a2f71 > > > Bug: webrtc:9719 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/105542 > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > > Reviewed-by: Peter Slatala <psla@webrtc.org> > > > Commit-Queue: Anton Sukhanov <sukhanov@google.com> > > > Cr-Commit-Position: refs/heads/master@{#25152} > > > > TBR=steveanton@webrtc.org,nisse@webrtc.org,psla@webrtc.org,sukhanov@google.com > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9719 > > Change-Id: Ic78cdc142a2145682ad74eac8b72c71c50f0a5c1 > > Reviewed-on: https://webrtc-review.googlesource.com/c/105840 > > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > > Commit-Queue: Oleh Prypin <oprypin@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#25154} > > TBR=steveanton@webrtc.org,oprypin@webrtc.org,nisse@webrtc.org,sukhanov@webrtc.org,psla@webrtc.org,sukhanov@google.com > > Change-Id: I505ff3451eae81573531faef155ff35d7f894022 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9719 > Reviewed-on: https://webrtc-review.googlesource.com/c/106500 > Reviewed-by: Anton Sukhanov <sukhanov@webrtc.org> > Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#25220} Bug: webrtc:9719 Tbr: Steve Anton <steveanton@webrtc.org> Tbr: Niels Moller <nisse@webrtc.org> Change-Id: Ib45691ba8be9abb89ff8c6dac1861bdf59be4c8d Reviewed-on: https://webrtc-review.googlesource.com/c/106561 Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> Reviewed-by: Peter Slatala <psla@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25240}
2018-10-17 13:15:42 -07:00
// Returns rtp transport, result can not be nullptr.
RtpTransportInternal* GetRtpTransport(const std::string& mid) {
RTC_DCHECK_RUN_ON(signaling_thread());
Reland "Reland "Propagate media transport to media channel."" This is a reland of da65ed2adcfa57ff3288ce01c1602c973fcab00d Original change's description: > Reland "Propagate media transport to media channel." > > This reverts commit 37cf2455a420124b341ad06ac27fa3c4dbd29d3c. > > Reason for revert: <INSERT REASONING HERE> > > Original change's description: > > Revert "Propagate media transport to media channel." > > > > This reverts commit 8c16f745ab92cb6d305283e87fa8a661ae500ce4. > > > > Reason for revert: Breaks downstream project > > > > Original change's description: > > > Propagate media transport to media channel. > > > > > > 1. Pass media transport factory to JSEP transport controller. > > > 2. Pass media transport to voice media channel. > > > 3. Add basic unit test that make sure if peer connection is created with media transport, it is propagated to voice media channel. > > > > > > Change-Id: Ie922db78ade0efd893e019cd2b4441a9947a2f71 > > > Bug: webrtc:9719 > > > Reviewed-on: https://webrtc-review.googlesource.com/c/105542 > > > Reviewed-by: Steve Anton <steveanton@webrtc.org> > > > Reviewed-by: Niels Moller <nisse@webrtc.org> > > > Reviewed-by: Peter Slatala <psla@webrtc.org> > > > Commit-Queue: Anton Sukhanov <sukhanov@google.com> > > > Cr-Commit-Position: refs/heads/master@{#25152} > > > > TBR=steveanton@webrtc.org,nisse@webrtc.org,psla@webrtc.org,sukhanov@google.com > > > > # Not skipping CQ checks because original CL landed > 1 day ago. > > > > Bug: webrtc:9719 > > Change-Id: Ic78cdc142a2145682ad74eac8b72c71c50f0a5c1 > > Reviewed-on: https://webrtc-review.googlesource.com/c/105840 > > Reviewed-by: Oleh Prypin <oprypin@webrtc.org> > > Commit-Queue: Oleh Prypin <oprypin@webrtc.org> > > Cr-Commit-Position: refs/heads/master@{#25154} > > TBR=steveanton@webrtc.org,oprypin@webrtc.org,nisse@webrtc.org,sukhanov@webrtc.org,psla@webrtc.org,sukhanov@google.com > > Change-Id: I505ff3451eae81573531faef155ff35d7f894022 > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: webrtc:9719 > Reviewed-on: https://webrtc-review.googlesource.com/c/106500 > Reviewed-by: Anton Sukhanov <sukhanov@webrtc.org> > Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> > Cr-Commit-Position: refs/heads/master@{#25220} Bug: webrtc:9719 Tbr: Steve Anton <steveanton@webrtc.org> Tbr: Niels Moller <nisse@webrtc.org> Change-Id: Ib45691ba8be9abb89ff8c6dac1861bdf59be4c8d Reviewed-on: https://webrtc-review.googlesource.com/c/106561 Commit-Queue: Anton Sukhanov <sukhanov@webrtc.org> Reviewed-by: Peter Slatala <psla@webrtc.org> Cr-Commit-Position: refs/heads/master@{#25240}
2018-10-17 13:15:42 -07:00
auto rtp_transport = transport_controller_->GetRtpTransport(mid);
RTC_DCHECK(rtp_transport);
return rtp_transport;
}
std::function<void(const rtc::CopyOnWriteBuffer& packet,
int64_t packet_time_us)>
InitializeRtcpCallback();
// Storing the factory as a scoped reference pointer ensures that the memory
// in the PeerConnectionFactoryImpl remains available as long as the
// PeerConnection is running. It is passed to PeerConnection as a raw pointer.
// However, since the reference counting is done in the
// PeerConnectionFactoryInterface all instances created using the raw pointer
// will refer to the same reference count.
const rtc::scoped_refptr<PeerConnectionFactory> factory_;
PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) =
nullptr;
// The EventLog needs to outlive |call_| (and any other object that uses it).
std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_thread());
// Points to the same thing as `event_log_`. Since it's const, we may read the
// pointer (but not touch the object) from any thread.
RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread());
IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) =
kIceConnectionNew;
PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_
RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew;
PeerConnectionInterface::PeerConnectionState connection_state_
RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew;
IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) =
kIceGatheringNew;
PeerConnectionInterface::RTCConfiguration configuration_
RTC_GUARDED_BY(signaling_thread());
// TODO(zstein): |async_resolver_factory_| can currently be nullptr if it
// is not injected. It should be required once chromium supplies it.
std::unique_ptr<AsyncResolverFactory> async_resolver_factory_
RTC_GUARDED_BY(signaling_thread());
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory_;
std::unique_ptr<cricket::PortAllocator>
port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both
// signaling and network thread.
std::unique_ptr<webrtc::IceTransportFactory>
ice_transport_factory_; // TODO(bugs.webrtc.org/9987): Accessed on the
// signaling thread but the underlying raw
// pointer is given to
// |jsep_transport_controller_| and used on the
// network thread.
std::unique_ptr<rtc::SSLCertificateVerifier>
tls_cert_verifier_; // TODO(bugs.webrtc.org/9987): Accessed on both
// signaling and network thread.
// These lists store sender info seen in local/remote descriptions.
std::vector<RtpSenderInfo> remote_audio_sender_infos_
RTC_GUARDED_BY(signaling_thread());
std::vector<RtpSenderInfo> remote_video_sender_infos_
RTC_GUARDED_BY(signaling_thread());
std::vector<RtpSenderInfo> local_audio_sender_infos_
RTC_GUARDED_BY(signaling_thread());
std::vector<RtpSenderInfo> local_video_sender_infos_
RTC_GUARDED_BY(signaling_thread());
// The unique_ptr belongs to the worker thread, but the Call object manages
// its own thread safety.
std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread());
std::unique_ptr<ScopedTaskSafety> call_safety_
RTC_GUARDED_BY(worker_thread());
// Points to the same thing as `call_`. Since it's const, we may read the
// pointer from any thread.
// TODO(bugs.webrtc.org/11992): Remove this workaround (and potential dangling
// pointer).
Call* const call_ptr_;
std::unique_ptr<StatsCollector> stats_
RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_
rtc::scoped_refptr<RTCStatsCollector> stats_collector_
RTC_GUARDED_BY(signaling_thread());
TransceiverList transceivers_;
std::string session_id_ RTC_GUARDED_BY(signaling_thread());
std::unique_ptr<JsepTransportController>
transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both
// signaling and network thread.
// |sctp_mid_| is the content name (MID) in SDP.
Changes to enable use of DatagramTransport as a data channel transport. PeerConnection now has a new setting in RTCConfiguration to enable use of datagram transport for data channels. There is also a corresponding field trial, which has both a kill-switch and a way to change the default value. PeerConnection's interaction with MediaTransport for data channels has been refactored to work with DataChannelTransportInterface instead. Adds a DataChannelState and OnStateChanged() to the DataChannelSink callbacks. This allows PeerConnection to listen to the data channel's state directly, instead of indirectly by monitoring media transport state. This is necessary to enable use of non-media-transport (eg. datagram transport) data channel transports. For now, PeerConnection watches the state through MediaTransport as well. This will persist until MediaTransport implements the new callback. Datagram transport use is negotiated. As such, an offer that requests to use datagram transport for data channels may be rejected by the answerer. If the offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data channels with an extra x-opaque parameter for datagram transport. If the opaque parameter is rejected (by an answerer without datagram support), the offerer may fall back to SCTP. If DTLS is not enabled, there is no viable fallback. In this case, the data channels are negotiated as media transport data channels. If the receiver does not understand the x-opaque line, it will reject these data channels, and the offerer's data channels will be closed. Bug: webrtc:9719 Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702 Commit-Queue: Bjorn Mellem <mellem@webrtc.org> Reviewed-by: Steve Anton <steveanton@webrtc.org> Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
// Note: this is used as the data channel MID by both SCTP and data channel
// transports. It is set when either transport is initialized and unset when
// both transports are deleted.
// There is one copy on the signaling thread and another copy on the
// networking thread. Changes are always initiated from the signaling
// thread, but applied first on the networking thread via an invoke().
absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread());
absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread());
// The machinery for handling offers and answers.
SdpOfferAnswerHandler sdp_handler_ RTC_GUARDED_BY(signaling_thread());
bool dtls_enabled_ RTC_GUARDED_BY(signaling_thread()) = false;
// Member variables for caching global options.
cricket::AudioOptions audio_options_ RTC_GUARDED_BY(signaling_thread());
cricket::VideoOptions video_options_ RTC_GUARDED_BY(signaling_thread());
UsagePattern usage_pattern_ RTC_GUARDED_BY(signaling_thread());
bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) =
false;
// This object should be used to generate any SSRC that is not explicitly
// specified by the user (or by the remote party).
// The generator is not used directly, instead it is passed on to the
// channel manager and the session description factory.
rtc::UniqueRandomIdGenerator ssrc_generator_
RTC_GUARDED_BY(signaling_thread());
// A video bitrate allocator factory.
// This can injected using the PeerConnectionDependencies,
// or else the CreateBuiltinVideoBitrateAllocatorFactory() will be called.
// Note that one can still choose to override this in a MediaEngine
// if one wants too.
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
video_bitrate_allocator_factory_;
DataChannelController data_channel_controller_;
// Machinery for handling messages posted to oneself
PeerConnectionMessageHandler message_handler_;
};
} // namespace webrtc
#endif // PC_PEER_CONNECTION_H_