1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111 |
- #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/rtc_stats_collector.h"
- #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/webrtc_session_description_factory.h"
- #include "rtc_base/experiments/field_trial_parser.h"
- #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"
- #include "rtc_base/weak_ptr.h"
- namespace webrtc {
- class MediaStreamObserver;
- class VideoRtpReceiver;
- class RtcEventLog;
- class SdpOfferAnswerHandler;
- class PeerConnection : public PeerConnectionInternal,
- public JsepTransportController::Observer,
- public RtpSenderBase::SetStreamsObserver,
- public rtc::MessageHandler,
- public sigslot::has_slots<> {
- public:
-
-
- enum class UsageEvent : int {
- TURN_SERVER_ADDED = 0x01,
- STUN_SERVER_ADDED = 0x02,
- DATA_ADDED = 0x04,
- AUDIO_ADDED = 0x08,
- VIDEO_ADDED = 0x10,
-
- SET_LOCAL_DESCRIPTION_SUCCEEDED = 0x20,
-
- SET_REMOTE_DESCRIPTION_SUCCEEDED = 0x40,
-
-
- CANDIDATE_COLLECTED = 0x80,
-
- ADD_ICE_CANDIDATE_SUCCEEDED = 0x100,
- ICE_STATE_CONNECTED = 0x200,
- CLOSE_CALLED = 0x400,
-
- PRIVATE_CANDIDATE_COLLECTED = 0x800,
-
-
- REMOTE_PRIVATE_CANDIDATE_ADDED = 0x1000,
-
- MDNS_CANDIDATE_COLLECTED = 0x2000,
-
-
- REMOTE_MDNS_CANDIDATE_ADDED = 0x4000,
-
- IPV6_CANDIDATE_COLLECTED = 0x8000,
-
-
- REMOTE_IPV6_CANDIDATE_ADDED = 0x10000,
-
-
-
- REMOTE_CANDIDATE_ADDED = 0x20000,
-
-
-
-
-
- DIRECT_CONNECTION_SELECTED = 0x40000,
- MAX_VALUE = 0x80000,
- };
- 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;
- 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;
-
-
-
-
-
-
-
- std::unique_ptr<rtc::SSLCertificate> GetRemoteAudioSSLCertificate();
-
- 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;
- std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
- const override;
- rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
- const std::string& label,
- const DataChannelInit* config) override;
-
- bool GetStats(StatsObserver* observer,
- webrtc::MediaStreamTrackInterface* track,
- StatsOutputLevel level) override;
-
- void GetStats(RTCStatsCollectorCallback* callback) override;
- 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;
- 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;
-
- void CreateOffer(CreateSessionDescriptionObserver* observer,
- const RTCOfferAnswerOptions& options) override;
- void CreateAnswer(CreateSessionDescriptionObserver* observer,
- const RTCOfferAnswerOptions& options) override;
- void SetLocalDescription(
- std::unique_ptr<SessionDescriptionInterface> desc,
- rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
- override;
- void SetLocalDescription(
- rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
- override;
-
-
- void SetLocalDescription(SetSessionDescriptionObserver* observer,
- SessionDescriptionInterface* desc) override;
- void SetLocalDescription(SetSessionDescriptionObserver* observer) override;
- void SetRemoteDescription(
- std::unique_ptr<SessionDescriptionInterface> desc,
- rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
- override;
-
-
- 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;
- 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();
- }
-
- 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;
-
- void NoteDataAddedEvent() { NoteUsageEvent(UsageEvent::DATA_ADDED); }
-
- PeerConnectionObserver* Observer() const;
- bool IsClosed() const {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return sdp_handler_.signaling_state() == PeerConnectionInterface::kClosed;
- }
-
- bool GetSctpSslRole(rtc::SSLRole* role);
-
- void OnSctpDataChannelClosed(DataChannelInterface* channel);
- bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override;
-
- 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_;
- }
- rtc::scoped_refptr<StreamCollection> remote_streams_internal() const {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return remote_streams_;
- }
- rtc::UniqueStringGenerator* mid_generator() {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return &mid_generator_;
- }
-
- void ReturnHistogramVeryQuicklyForTesting() {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return_histogram_very_quickly_ = true;
- }
- void RequestUsagePatternReportForTesting();
- absl::optional<std::string> sctp_mid() {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return sctp_mid_s_;
- }
- protected:
- ~PeerConnection() override;
- private:
-
-
- friend class SdpOfferAnswerHandler;
- 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;
-
-
- uint32_t first_ssrc;
- };
-
- void OnMessage(rtc::Message* msg) override;
-
-
- 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());
-
- void RemoveStoppedTransceivers();
- 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());
- rtc::scoped_refptr<RtpReceiverInterface> RemoveAndStopReceiver(
- const RtpSenderInfo& remote_sender_info) RTC_RUN_ON(signaling_thread());
-
-
- void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream)
- RTC_RUN_ON(signaling_thread());
- void RemoveAudioTrack(AudioTrackInterface* track,
- MediaStreamInterface* stream)
- RTC_RUN_ON(signaling_thread());
- void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream)
- RTC_RUN_ON(signaling_thread());
- void RemoveVideoTrack(VideoTrackInterface* track,
- MediaStreamInterface* stream)
- RTC_RUN_ON(signaling_thread());
-
- RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackUnifiedPlan(
- rtc::scoped_refptr<MediaStreamTrackInterface> track,
- const std::vector<std::string>& stream_ids)
- RTC_RUN_ON(signaling_thread());
-
- RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackPlanB(
- rtc::scoped_refptr<MediaStreamTrackInterface> track,
- const std::vector<std::string>& stream_ids)
- RTC_RUN_ON(signaling_thread());
-
-
- 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());
-
-
- RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
- cricket::MediaType media_type,
- rtc::scoped_refptr<MediaStreamTrackInterface> track,
- const RtpTransceiverInit& init,
- bool fire_callback = true) RTC_RUN_ON(signaling_thread());
- 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);
-
-
- 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());
-
- void OnIceGatheringChange(IceGatheringState new_state)
- RTC_RUN_ON(signaling_thread());
-
- void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate)
- RTC_RUN_ON(signaling_thread());
-
- 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());
-
- void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates)
- RTC_RUN_ON(signaling_thread());
- void OnSelectedCandidatePairChanged(
- const cricket::CandidatePairChangeEvent& event)
- RTC_RUN_ON(signaling_thread());
-
- 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 PostSetSessionDescriptionSuccess(
- SetSessionDescriptionObserver* observer);
- void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
- RTCError&& error);
- void PostCreateSessionDescriptionFailure(
- CreateSessionDescriptionObserver* observer,
- RTCError error);
-
- rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
- GetAssociatedTransceiver(const std::string& mid) const;
-
-
- rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
- GetTransceiverByMLineIndex(size_t mline_index) const;
-
-
-
-
-
-
-
-
- void ProcessRemovalOfRemoteTrack(
- rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
- transceiver,
- std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>* remove_list,
- std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams);
- void RemoveRemoteStreamsIfEmpty(
- const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
- remote_streams,
- std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams);
- void OnNegotiationNeeded();
- RTCError HandleLegacyOfferOptions(const RTCOfferAnswerOptions& options);
- void RemoveRecvDirectionFromReceivingTransceiversOfType(
- cricket::MediaType media_type) RTC_RUN_ON(signaling_thread());
- void AddUpToOneReceivingTransceiverOfType(cricket::MediaType media_type);
- std::vector<
- rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
- GetReceivingTransceiversOfType(cricket::MediaType media_type)
- RTC_RUN_ON(signaling_thread());
-
-
- void GenerateMediaDescriptionOptions(
- const SessionDescriptionInterface* session_desc,
- RtpTransceiverDirection audio_direction,
- RtpTransceiverDirection video_direction,
- absl::optional<size_t>* audio_index,
- absl::optional<size_t>* video_index,
- absl::optional<size_t>* data_index,
- cricket::MediaSessionOptions* session_options);
-
-
- cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForActiveData(
- const std::string& mid) const;
-
-
- cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForRejectedData(
- const std::string& mid) const;
-
-
-
- absl::optional<std::string> GetDataMid() const;
-
-
- void RemoveSenders(cricket::MediaType media_type);
-
-
-
-
-
-
- void UpdateRemoteSendersList(
- const std::vector<cricket::StreamParams>& streams,
- bool default_track_needed,
- cricket::MediaType media_type,
- StreamCollection* new_streams);
-
-
-
- void OnRemoteSenderAdded(const RtpSenderInfo& sender_info,
- cricket::MediaType media_type)
- RTC_RUN_ON(signaling_thread());
-
-
-
- void OnRemoteSenderRemoved(const RtpSenderInfo& sender_info,
- cricket::MediaType media_type)
- RTC_RUN_ON(signaling_thread());
-
-
-
- void UpdateEndedRemoteMediaStreams();
-
-
-
-
- void UpdateLocalSenders(const std::vector<cricket::StreamParams>& streams,
- cricket::MediaType media_type);
-
-
-
-
-
- void OnLocalSenderAdded(const RtpSenderInfo& sender_info,
- cricket::MediaType media_type)
- RTC_RUN_ON(signaling_thread());
-
-
-
-
-
- void OnLocalSenderRemoved(const RtpSenderInfo& sender_info,
- cricket::MediaType media_type)
- RTC_RUN_ON(signaling_thread());
-
-
-
-
-
-
- bool IsUnifiedPlan() const {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan;
- }
-
- rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
- FindSenderForTrack(MediaStreamTrackInterface* track) const
- RTC_RUN_ON(signaling_thread());
-
- rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
- FindSenderById(const std::string& sender_id) const
- RTC_RUN_ON(signaling_thread());
-
- 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,
- const std::string& stream_id,
- const std::string sender_id) const;
-
-
- SctpDataChannel* FindDataChannelBySid(int sid) const
- RTC_RUN_ON(signaling_thread());
-
- struct InitializePortAllocatorResult {
- bool enable_ipv6;
- };
- InitializePortAllocatorResult InitializePortAllocator_n(
- const cricket::ServerAddresses& stun_servers,
- const std::vector<cricket::RelayServerConfig>& turn_servers,
- const RTCConfiguration& configuration);
-
-
- 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);
-
-
- bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output,
- int64_t output_period_ms);
-
-
- void StopRtcEventLog_w();
-
-
-
-
- RTCError ValidateConfiguration(const RTCConfiguration& config) const;
- cricket::ChannelManager* channel_manager() const;
- enum class SessionError {
- kNone,
- kContent,
- kTransport,
- };
-
- SessionError session_error() const {
- RTC_DCHECK_RUN_ON(signaling_thread());
- return session_error_;
- }
- const std::string& session_error_desc() const { return session_error_desc_; }
- cricket::ChannelInterface* GetChannel(const std::string& content_name);
- cricket::IceConfig ParseIceConfig(
- const PeerConnectionInterface::RTCConfiguration& config) const;
- cricket::DataChannelType data_channel_type() const;
-
-
- void OnCertificateReady(
- const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
-
- void SetSessionError(SessionError error, const std::string& error_desc);
-
-
- bool UpdatePayloadTypeDemuxingState(cricket::ContentSource source)
- RTC_RUN_ON(signaling_thread());
-
-
- RTCError PushdownMediaDescription(SdpType type,
- cricket::ContentSource source);
- RTCError PushdownTransportDescription(cricket::ContentSource source,
- SdpType type);
-
-
- static bool GetTransportDescription(
- const cricket::SessionDescription* description,
- const std::string& content_name,
- cricket::TransportDescription* info);
-
-
-
- void EnableSending();
-
- void DestroyAllChannels() RTC_RUN_ON(signaling_thread());
-
-
-
- bool GetLocalCandidateMediaIndex(const std::string& content_name,
- int* sdp_mline_index)
- RTC_RUN_ON(signaling_thread());
-
- bool UseCandidatesInSessionDescription(
- const SessionDescriptionInterface* remote_desc);
-
- bool UseCandidate(const IceCandidateInterface* candidate);
- RTCErrorOr<const cricket::ContentInfo*> FindContentInfo(
- const SessionDescriptionInterface* description,
- const IceCandidateInterface* candidate) RTC_RUN_ON(signaling_thread());
-
-
- void RemoveUnusedChannels(const cricket::SessionDescription* desc);
-
-
-
- RTCError CreateChannels(const cricket::SessionDescription& desc);
-
- cricket::VoiceChannel* CreateVoiceChannel(const std::string& mid);
- cricket::VideoChannel* CreateVideoChannel(const std::string& mid);
- bool CreateDataChannel(const std::string& mid);
- bool SetupDataChannelTransport_n(const std::string& mid)
- RTC_RUN_ON(network_thread());
- void TeardownDataChannelTransport_n() RTC_RUN_ON(network_thread());
- bool ValidateBundleSettings(const cricket::SessionDescription* desc);
- bool HasRtcpMuxEnabled(const cricket::ContentInfo* content);
-
- bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
- SdpType type);
-
-
-
-
- bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate,
- const SessionDescriptionInterface* remote_desc,
- bool* valid);
-
-
- bool SrtpRequired() const RTC_RUN_ON(signaling_thread());
-
- 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);
- const char* SessionErrorToString(SessionError error) const;
- std::string GetSessionErrorMsg();
-
- void ReportSdpFormatReceived(const SessionDescriptionInterface& remote_offer);
-
-
- void ReportNegotiatedSdpSemantics(const SessionDescriptionInterface& answer);
-
-
- void ReportTransportStats() RTC_RUN_ON(signaling_thread());
-
- 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 ReportRemoteIceCandidateAdded(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);
- const std::string GetTransportName(const std::string& content_name)
- RTC_RUN_ON(signaling_thread());
-
-
-
-
-
- void DestroyTransceiverChannel(
- rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
- transceiver);
-
-
- void DestroyDataChannelTransport();
-
-
- void DestroyChannelInterface(cricket::ChannelInterface* channel);
-
-
-
-
-
-
- bool OnTransportChanged(
- const std::string& mid,
- RtpTransportInternal* rtp_transport,
- rtc::scoped_refptr<DtlsTransport> dtls_transport,
- DataChannelTransportInterface* data_channel_transport) override;
-
- void OnSetStreams() override;
-
-
-
- CryptoOptions GetCryptoOptions();
-
- RtpTransportInternal* GetRtpTransport(const std::string& mid)
- RTC_RUN_ON(signaling_thread()) {
- 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();
-
-
-
-
-
-
- const rtc::scoped_refptr<PeerConnectionFactory> factory_;
- PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) =
- nullptr;
-
- std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_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());
-
-
- 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_;
-
- std::unique_ptr<webrtc::IceTransportFactory>
- ice_transport_factory_;
-
-
-
-
- std::unique_ptr<rtc::SSLCertificateVerifier>
- tls_cert_verifier_;
-
-
-
- const std::string rtcp_cname_;
-
- const rtc::scoped_refptr<StreamCollection> local_streams_
- RTC_GUARDED_BY(signaling_thread());
-
- const rtc::scoped_refptr<StreamCollection> remote_streams_
- RTC_GUARDED_BY(signaling_thread());
- std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_
- RTC_GUARDED_BY(signaling_thread());
-
- 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());
-
-
- std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread());
- std::unique_ptr<ScopedTaskSafety> call_safety_
- RTC_GUARDED_BY(worker_thread());
-
-
-
-
- Call* const call_ptr_;
- std::unique_ptr<StatsCollector> stats_
- RTC_GUARDED_BY(signaling_thread());
- rtc::scoped_refptr<RTCStatsCollector> stats_collector_
- RTC_GUARDED_BY(signaling_thread());
- TransceiverList transceivers_;
-
-
- rtc::UniqueStringGenerator mid_generator_ RTC_GUARDED_BY(signaling_thread());
- SessionError session_error_ RTC_GUARDED_BY(signaling_thread()) =
- SessionError::kNone;
- std::string session_error_desc_ RTC_GUARDED_BY(signaling_thread());
- std::string session_id_ RTC_GUARDED_BY(signaling_thread());
- std::unique_ptr<JsepTransportController>
- transport_controller_;
-
-
-
-
-
-
-
-
- absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread());
- absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread());
-
- SdpOfferAnswerHandler sdp_handler_ RTC_GUARDED_BY(signaling_thread());
- bool dtls_enabled_ RTC_GUARDED_BY(signaling_thread()) = false;
-
- cricket::AudioOptions audio_options_ RTC_GUARDED_BY(signaling_thread());
- cricket::VideoOptions video_options_ RTC_GUARDED_BY(signaling_thread());
- int usage_event_accumulator_ RTC_GUARDED_BY(signaling_thread()) = 0;
- bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) =
- false;
-
-
-
-
- rtc::UniqueRandomIdGenerator ssrc_generator_
- RTC_GUARDED_BY(signaling_thread());
-
-
-
-
-
- std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
- video_bitrate_allocator_factory_;
- DataChannelController data_channel_controller_;
- };
- }
- #endif
|