2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2012 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#ifndef WEBRTC_API_PEERCONNECTION_H_
|
|
|
|
|
#define WEBRTC_API_PEERCONNECTION_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
#include <string>
|
2016-03-24 03:16:19 -07:00
|
|
|
#include <map>
|
2016-04-27 06:47:29 -07:00
|
|
|
#include <memory>
|
2016-03-24 03:16:19 -07:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/peerconnectionfactory.h"
|
|
|
|
|
#include "webrtc/api/peerconnectioninterface.h"
|
2016-09-15 23:33:01 -07:00
|
|
|
#include "webrtc/api/rtcstatscollector.h"
|
2016-06-06 14:27:39 -07:00
|
|
|
#include "webrtc/api/rtpreceiver.h"
|
|
|
|
|
#include "webrtc/api/rtpsender.h"
|
2016-02-10 10:53:12 +01:00
|
|
|
#include "webrtc/api/statscollector.h"
|
|
|
|
|
#include "webrtc/api/streamcollection.h"
|
|
|
|
|
#include "webrtc/api/webrtcsession.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-12-15 19:24:43 -08:00
|
|
|
class MediaStreamObserver;
|
2016-03-10 18:32:00 +01:00
|
|
|
class VideoRtpReceiver;
|
2016-10-07 11:53:05 -07:00
|
|
|
class RtcEventLog;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
// Populates |session_options| from |rtc_options|, and returns true if options
|
|
|
|
|
// are valid.
|
2016-02-23 17:24:52 -08:00
|
|
|
// |session_options|->transport_options map entries must exist in order for
|
|
|
|
|
// them to be populated from |rtc_options|.
|
2016-03-04 02:51:39 -08:00
|
|
|
bool ExtractMediaSessionOptions(
|
2015-10-14 11:33:11 -07:00
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
|
2016-03-10 13:35:55 -08:00
|
|
|
bool is_offer,
|
2015-10-14 11:33:11 -07:00
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
|
|
|
|
// Populates |session_options| from |constraints|, and returns true if all
|
|
|
|
|
// mandatory constraints are satisfied.
|
2016-02-23 17:24:52 -08:00
|
|
|
// Assumes that |session_options|->transport_options map entries exist.
|
2016-03-04 02:51:39 -08:00
|
|
|
// Will also set defaults if corresponding constraints are not present:
|
|
|
|
|
// recv_audio=true, recv_video=true, bundle_enabled=true.
|
|
|
|
|
// Other fields will be left with existing values.
|
|
|
|
|
//
|
|
|
|
|
// Deprecated. Will be removed once callers that use constraints are gone.
|
|
|
|
|
// TODO(hta): Remove when callers are gone.
|
|
|
|
|
// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
|
2015-10-14 11:33:11 -07:00
|
|
|
bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
2015-12-29 14:14:52 -08:00
|
|
|
// Parses the URLs for each server in |servers| to build |stun_servers| and
|
|
|
|
|
// |turn_servers|.
|
2015-10-06 11:38:28 -07:00
|
|
|
bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
|
2015-12-29 14:14:52 -08:00
|
|
|
cricket::ServerAddresses* stun_servers,
|
|
|
|
|
std::vector<cricket::RelayServerConfig>* turn_servers);
|
2015-10-06 11:38:28 -07:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// PeerConnection implements the PeerConnectionInterface interface.
|
2015-10-14 11:33:11 -07:00
|
|
|
// It uses WebRtcSession to implement the PeerConnection functionality.
|
2013-07-10 00:45:36 +00:00
|
|
|
class PeerConnection : public PeerConnectionInterface,
|
|
|
|
|
public IceObserver,
|
2014-07-29 17:36:52 +00:00
|
|
|
public rtc::MessageHandler,
|
2013-07-10 00:45:36 +00:00
|
|
|
public sigslot::has_slots<> {
|
|
|
|
|
public:
|
|
|
|
|
explicit PeerConnection(PeerConnectionFactory* factory);
|
|
|
|
|
|
2015-11-11 12:55:10 -08:00
|
|
|
bool Initialize(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator,
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
2015-11-11 12:55:10 -08:00
|
|
|
PeerConnectionObserver* observer);
|
|
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
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;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-01-14 15:35:42 -08:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> AddTrack(
|
|
|
|
|
MediaStreamTrackInterface* track,
|
|
|
|
|
std::vector<MediaStreamInterface*> streams) override;
|
|
|
|
|
bool RemoveTrack(RtpSenderInterface* sender) override;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
virtual WebRtcSession* session() { return session_.get(); }
|
|
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
|
|
|
|
|
AudioTrackInterface* track) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-11-25 11:26:01 -08:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> CreateSender(
|
2015-12-18 16:58:44 -08:00
|
|
|
const std::string& kind,
|
|
|
|
|
const std::string& stream_id) override;
|
2015-11-25 11:26:01 -08:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
|
|
|
|
|
const override;
|
|
|
|
|
std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
|
|
|
|
|
const override;
|
|
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& label,
|
2015-09-29 11:56:26 -07:00
|
|
|
const DataChannelInit* config) override;
|
|
|
|
|
bool GetStats(StatsObserver* observer,
|
|
|
|
|
webrtc::MediaStreamTrackInterface* track,
|
|
|
|
|
StatsOutputLevel level) override;
|
2016-09-15 23:33:01 -07:00
|
|
|
void GetStats(RTCStatsCollectorCallback* callback) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
SignalingState signaling_state() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
IceConnectionState ice_connection_state() override;
|
|
|
|
|
IceGatheringState ice_gathering_state() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
const SessionDescriptionInterface* local_description() const override;
|
|
|
|
|
const SessionDescriptionInterface* remote_description() const override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// JSEP01
|
2016-03-04 02:51:39 -08:00
|
|
|
// Deprecated, use version without constraints.
|
2015-09-29 11:56:26 -07:00
|
|
|
void CreateOffer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const MediaConstraintsInterface* constraints) override;
|
|
|
|
|
void CreateOffer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
// Deprecated, use version without constraints.
|
2015-09-29 11:56:26 -07:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const MediaConstraintsInterface* constraints) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
void SetLocalDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
|
|
|
|
void SetRemoteDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
2016-11-16 19:42:04 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
|
2015-09-29 11:56:26 -07:00
|
|
|
bool SetConfiguration(
|
2016-05-13 08:15:11 -07:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
bool AddIceCandidate(const IceCandidateInterface* candidate) override;
|
2016-03-14 11:59:18 -07:00
|
|
|
bool RemoveIceCandidates(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
|
|
|
|
|
void RegisterUMAObserver(UMAObserver* observer) override;
|
|
|
|
|
|
2016-07-04 07:06:55 -07:00
|
|
|
bool StartRtcEventLog(rtc::PlatformFile file,
|
|
|
|
|
int64_t max_size_bytes) override;
|
|
|
|
|
void StopRtcEventLog() override;
|
|
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
void Close() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-11-14 01:41:09 -08:00
|
|
|
sigslot::signal1<DataChannel*> SignalDataChannelCreated;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Virtual for unit tests.
|
|
|
|
|
virtual const std::vector<rtc::scoped_refptr<DataChannel>>&
|
|
|
|
|
sctp_data_channels() const {
|
|
|
|
|
return sctp_data_channels_;
|
2016-03-24 03:16:19 -07:00
|
|
|
}
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
2015-09-29 11:56:26 -07:00
|
|
|
~PeerConnection() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
2015-10-14 11:33:11 -07:00
|
|
|
struct TrackInfo {
|
|
|
|
|
TrackInfo() : ssrc(0) {}
|
|
|
|
|
TrackInfo(const std::string& stream_label,
|
|
|
|
|
const std::string track_id,
|
|
|
|
|
uint32_t ssrc)
|
|
|
|
|
: stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
|
2015-12-08 17:13:40 -08:00
|
|
|
bool operator==(const TrackInfo& other) {
|
|
|
|
|
return this->stream_label == other.stream_label &&
|
|
|
|
|
this->track_id == other.track_id && this->ssrc == other.ssrc;
|
|
|
|
|
}
|
2015-10-14 11:33:11 -07:00
|
|
|
std::string stream_label;
|
|
|
|
|
std::string track_id;
|
|
|
|
|
uint32_t ssrc;
|
|
|
|
|
};
|
|
|
|
|
typedef std::vector<TrackInfo> TrackInfos;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Implements MessageHandler.
|
2015-09-29 11:56:26 -07:00
|
|
|
void OnMessage(rtc::Message* msg) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateAudioReceiver(MediaStreamInterface* stream,
|
2016-03-24 03:16:19 -07:00
|
|
|
const std::string& track_id,
|
2015-10-14 11:33:11 -07:00
|
|
|
uint32_t ssrc);
|
2016-03-10 18:32:00 +01:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateVideoReceiver(MediaStreamInterface* stream,
|
2016-03-10 18:32:00 +01:00
|
|
|
const std::string& track_id,
|
2015-10-14 11:33:11 -07:00
|
|
|
uint32_t ssrc);
|
2016-03-24 03:16:19 -07:00
|
|
|
void DestroyReceiver(const std::string& track_id);
|
2015-10-14 11:33:11 -07:00
|
|
|
void DestroyAudioSender(MediaStreamInterface* stream,
|
|
|
|
|
AudioTrackInterface* audio_track,
|
|
|
|
|
uint32_t ssrc);
|
|
|
|
|
void DestroyVideoSender(MediaStreamInterface* stream,
|
|
|
|
|
VideoTrackInterface* video_track);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Implements IceObserver
|
2015-07-08 11:08:35 -07:00
|
|
|
void OnIceConnectionChange(IceConnectionState new_state) override;
|
|
|
|
|
void OnIceGatheringChange(IceGatheringState new_state) override;
|
|
|
|
|
void OnIceCandidate(const IceCandidateInterface* candidate) override;
|
2016-03-14 11:59:18 -07:00
|
|
|
void OnIceCandidatesRemoved(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates) override;
|
2015-07-08 11:08:35 -07:00
|
|
|
void OnIceConnectionReceivingChange(bool receiving) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Signals from WebRtcSession.
|
2015-10-14 15:02:44 -07:00
|
|
|
void OnSessionStateChange(WebRtcSession* session, WebRtcSession::State state);
|
2013-07-10 00:45:36 +00:00
|
|
|
void ChangeSignalingState(SignalingState signaling_state);
|
|
|
|
|
|
2015-12-15 19:24:43 -08:00
|
|
|
// Signals from MediaStreamObserver.
|
|
|
|
|
void OnAudioTrackAdded(AudioTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnAudioTrackRemoved(AudioTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnVideoTrackAdded(VideoTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnVideoTrackRemoved(VideoTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::Thread* signaling_thread() const {
|
2013-07-10 00:45:36 +00:00
|
|
|
return factory_->signaling_thread();
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-18 16:55:30 -07:00
|
|
|
rtc::Thread* network_thread() const { return factory_->network_thread(); }
|
2016-05-13 08:15:11 -07:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
|
|
|
|
|
const std::string& error);
|
2015-10-14 11:33:11 -07:00
|
|
|
void PostCreateSessionDescriptionFailure(
|
|
|
|
|
CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const std::string& error);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
bool IsClosed() const {
|
|
|
|
|
return signaling_state_ == PeerConnectionInterface::kClosed;
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Returns a MediaSessionOptions struct with options decided by |options|,
|
|
|
|
|
// the local MediaStreams and DataChannels.
|
|
|
|
|
virtual bool GetOptionsForOffer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
|
|
|
|
// Returns a MediaSessionOptions struct with options decided by
|
|
|
|
|
// |constraints|, the local MediaStreams and DataChannels.
|
2016-03-04 02:51:39 -08:00
|
|
|
// Deprecated, use version without constraints.
|
2015-10-14 11:33:11 -07:00
|
|
|
virtual bool GetOptionsForAnswer(
|
|
|
|
|
const MediaConstraintsInterface* constraints,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
2016-03-04 02:51:39 -08:00
|
|
|
virtual bool GetOptionsForAnswer(
|
|
|
|
|
const RTCOfferAnswerOptions& options,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
2016-08-31 08:18:11 -07:00
|
|
|
void InitializeOptionsForAnswer(
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
2016-03-04 02:51:39 -08:00
|
|
|
// Helper function for options processing.
|
|
|
|
|
// Deprecated.
|
|
|
|
|
virtual void FinishOptionsForAnswer(
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2015-11-12 15:33:07 -08:00
|
|
|
// Remove all local and remote tracks of type |media_type|.
|
|
|
|
|
// Called when a media type is rejected (m-line set to port 0).
|
|
|
|
|
void RemoveTracks(cricket::MediaType media_type);
|
|
|
|
|
|
2015-12-08 17:13:40 -08:00
|
|
|
// Makes sure a MediaStreamTrack is created for each StreamParam in |streams|,
|
|
|
|
|
// and existing MediaStreamTracks are removed if there is no corresponding
|
|
|
|
|
// StreamParam. If |default_track_needed| is true, a default MediaStreamTrack
|
|
|
|
|
// is created if it doesn't exist; if false, it's removed if it exists.
|
|
|
|
|
// |media_type| is the type of the |streams| and can be either audio or video.
|
2015-10-14 11:33:11 -07:00
|
|
|
// If a new MediaStream is created it is added to |new_streams|.
|
|
|
|
|
void UpdateRemoteStreamsList(
|
|
|
|
|
const std::vector<cricket::StreamParams>& streams,
|
2015-12-08 17:13:40 -08:00
|
|
|
bool default_track_needed,
|
2015-10-14 11:33:11 -07:00
|
|
|
cricket::MediaType media_type,
|
|
|
|
|
StreamCollection* new_streams);
|
|
|
|
|
|
|
|
|
|
// Triggered when a remote track has been seen for the first time in a remote
|
|
|
|
|
// session description. It creates a remote MediaStreamTrackInterface
|
|
|
|
|
// implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
|
|
|
|
|
void OnRemoteTrackSeen(const std::string& stream_label,
|
|
|
|
|
const std::string& track_id,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
|
|
|
|
|
// Triggered when a remote track has been removed from a remote session
|
|
|
|
|
// description. It removes the remote track with id |track_id| from a remote
|
|
|
|
|
// MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
|
|
|
|
|
void OnRemoteTrackRemoved(const std::string& stream_label,
|
|
|
|
|
const std::string& track_id,
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
|
|
|
|
|
// Finds remote MediaStreams without any tracks and removes them from
|
|
|
|
|
// |remote_streams_| and notifies the observer that the MediaStreams no longer
|
|
|
|
|
// exist.
|
|
|
|
|
void UpdateEndedRemoteMediaStreams();
|
|
|
|
|
|
|
|
|
|
// Loops through the vector of |streams| and finds added and removed
|
|
|
|
|
// StreamParams since last time this method was called.
|
|
|
|
|
// For each new or removed StreamParam, OnLocalTrackSeen or
|
|
|
|
|
// OnLocalTrackRemoved is invoked.
|
|
|
|
|
void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams,
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
|
|
|
|
|
// Triggered when a local track 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 OnLocalTrackSeen(const std::string& stream_label,
|
|
|
|
|
const std::string& track_id,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
|
|
|
|
|
// Triggered when a local track 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 OnLocalTrackRemoved(const std::string& stream_label,
|
|
|
|
|
const std::string& track_id,
|
|
|
|
|
uint32_t ssrc,
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
|
|
|
|
|
void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
|
|
|
|
|
void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
|
|
|
|
|
void UpdateClosingRtpDataChannels(
|
|
|
|
|
const std::vector<std::string>& active_channels,
|
|
|
|
|
bool is_local_update);
|
|
|
|
|
void CreateRemoteRtpDataChannel(const std::string& label,
|
|
|
|
|
uint32_t remote_ssrc);
|
|
|
|
|
|
|
|
|
|
// Creates channel and adds it to the collection of DataChannels that will
|
|
|
|
|
// be offered in a SessionDescription.
|
|
|
|
|
rtc::scoped_refptr<DataChannel> InternalCreateDataChannel(
|
|
|
|
|
const std::string& label,
|
|
|
|
|
const InternalDataChannelInit* config);
|
|
|
|
|
|
|
|
|
|
// Checks if any data channel has been added.
|
|
|
|
|
bool HasDataChannels() const;
|
|
|
|
|
|
|
|
|
|
void AllocateSctpSids(rtc::SSLRole role);
|
|
|
|
|
void OnSctpDataChannelClosed(DataChannel* channel);
|
|
|
|
|
|
|
|
|
|
// Notifications from WebRtcSession relating to BaseChannels.
|
2016-06-27 16:30:35 -07:00
|
|
|
void OnVoiceChannelCreated();
|
2015-10-14 11:33:11 -07:00
|
|
|
void OnVoiceChannelDestroyed();
|
2016-06-27 16:30:35 -07:00
|
|
|
void OnVideoChannelCreated();
|
2015-10-14 11:33:11 -07:00
|
|
|
void OnVideoChannelDestroyed();
|
|
|
|
|
void OnDataChannelCreated();
|
|
|
|
|
void OnDataChannelDestroyed();
|
|
|
|
|
// Called when the cricket::DataChannel receives a message indicating that a
|
|
|
|
|
// webrtc::DataChannel should be opened.
|
|
|
|
|
void OnDataChannelOpenMessage(const std::string& label,
|
|
|
|
|
const InternalDataChannelInit& config);
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
RtpSenderInternal* FindSenderById(const std::string& id);
|
2015-11-25 11:26:01 -08:00
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
std::vector<rtc::scoped_refptr<
|
|
|
|
|
RtpSenderProxyWithInternal<RtpSenderInternal>>>::iterator
|
2015-09-28 16:53:55 -07:00
|
|
|
FindSenderForTrack(MediaStreamTrackInterface* track);
|
2016-06-06 14:27:39 -07:00
|
|
|
std::vector<rtc::scoped_refptr<
|
|
|
|
|
RtpReceiverProxyWithInternal<RtpReceiverInternal>>>::iterator
|
2016-03-24 03:16:19 -07:00
|
|
|
FindReceiverForTrack(const std::string& track_id);
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
TrackInfos* GetRemoteTracks(cricket::MediaType media_type);
|
|
|
|
|
TrackInfos* GetLocalTracks(cricket::MediaType media_type);
|
|
|
|
|
const TrackInfo* FindTrackInfo(const TrackInfos& infos,
|
|
|
|
|
const std::string& stream_label,
|
|
|
|
|
const std::string track_id) const;
|
|
|
|
|
|
|
|
|
|
// Returns the specified SCTP DataChannel in sctp_data_channels_,
|
|
|
|
|
// or nullptr if not found.
|
|
|
|
|
DataChannel* FindDataChannelBySid(int sid) const;
|
|
|
|
|
|
2016-05-13 08:15:11 -07:00
|
|
|
// Called when first configuring the port allocator.
|
2016-05-18 16:55:30 -07:00
|
|
|
bool InitializePortAllocator_n(const RTCConfiguration& configuration);
|
2016-05-13 08:15:11 -07:00
|
|
|
// Called when SetConfiguration is called. Only a subset of the configuration
|
|
|
|
|
// is applied.
|
2016-05-18 16:55:30 -07:00
|
|
|
bool ReconfigurePortAllocator_n(const RTCConfiguration& configuration);
|
2016-05-13 08:15:11 -07:00
|
|
|
|
2016-07-04 07:06:55 -07:00
|
|
|
// Starts recording an Rtc EventLog using the supplied platform file.
|
|
|
|
|
// This function should only be called from the worker thread.
|
|
|
|
|
bool StartRtcEventLog_w(rtc::PlatformFile file, int64_t max_size_bytes);
|
|
|
|
|
// Starts recording an Rtc EventLog using the supplied platform file.
|
|
|
|
|
// This function should only be called from the worker thread.
|
|
|
|
|
void StopRtcEventLog_w();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// 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
|
2015-10-14 11:33:11 -07:00
|
|
|
// PeerConnectionFactoryInterface all instances created using the raw pointer
|
2013-07-10 00:45:36 +00:00
|
|
|
// will refer to the same reference count.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> factory_;
|
2013-07-10 00:45:36 +00:00
|
|
|
PeerConnectionObserver* observer_;
|
2014-05-08 19:54:16 +00:00
|
|
|
UMAObserver* uma_observer_;
|
2013-07-10 00:45:36 +00:00
|
|
|
SignalingState signaling_state_;
|
|
|
|
|
IceConnectionState ice_connection_state_;
|
|
|
|
|
IceGatheringState ice_gathering_state_;
|
2016-11-16 19:42:04 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration configuration_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> port_allocator_;
|
2016-10-07 11:53:05 -07:00
|
|
|
// The EventLog needs to outlive the media controller.
|
|
|
|
|
std::unique_ptr<RtcEventLog> event_log_;
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<MediaControllerInterface> media_controller_;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2016-05-06 18:40:30 -07:00
|
|
|
// One PeerConnection has only one RTCP CNAME.
|
|
|
|
|
// https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
|
|
|
|
|
std::string rtcp_cname_;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Streams added via AddStream.
|
|
|
|
|
rtc::scoped_refptr<StreamCollection> local_streams_;
|
|
|
|
|
// Streams created as a result of SetRemoteDescription.
|
|
|
|
|
rtc::scoped_refptr<StreamCollection> remote_streams_;
|
|
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_;
|
2015-12-15 19:24:43 -08:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// These lists store track info seen in local/remote descriptions.
|
|
|
|
|
TrackInfos remote_audio_tracks_;
|
|
|
|
|
TrackInfos remote_video_tracks_;
|
|
|
|
|
TrackInfos local_audio_tracks_;
|
|
|
|
|
TrackInfos local_video_tracks_;
|
|
|
|
|
|
|
|
|
|
SctpSidAllocator sid_allocator_;
|
|
|
|
|
// label -> DataChannel
|
|
|
|
|
std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
|
|
|
|
|
std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
|
2015-12-14 18:15:29 -08:00
|
|
|
std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2015-12-08 17:13:40 -08:00
|
|
|
bool remote_peer_supports_msid_ = false;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
|
|
|
|
|
senders_;
|
|
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
|
|
|
|
|
receivers_;
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<WebRtcSession> session_;
|
|
|
|
|
std::unique_ptr<StatsCollector> stats_;
|
2016-09-15 23:33:01 -07:00
|
|
|
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2016-02-10 10:53:12 +01:00
|
|
|
#endif // WEBRTC_API_PEERCONNECTION_H_
|