mirror of
https://github.com/mollyim/webrtc.git
synced 2025-05-16 23:30:48 +01:00
Move almost all references from WebRtcSession to PeerConnection
WebRtcSession is being merged into PeerConnection, and to make the code review easier this is the first step towards achieving that. Bug: webrtc:8323 Change-Id: I33778e46f20cb14089dff4328947868e207476bd Reviewed-on: https://webrtc-review.googlesource.com/8760 Commit-Queue: Steve Anton <steveanton@webrtc.org> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org> Cr-Commit-Position: refs/heads/master@{#20413}
This commit is contained in:
parent
c4faa9c4e1
commit
d5585ca956
9 changed files with 68 additions and 111 deletions
|
@ -487,10 +487,8 @@ bool PeerConnection::Initialize(
|
||||||
stats_collector_ = RTCStatsCollector::Create(this);
|
stats_collector_ = RTCStatsCollector::Create(this);
|
||||||
|
|
||||||
// Initialize the WebRtcSession. It creates transport channels etc.
|
// Initialize the WebRtcSession. It creates transport channels etc.
|
||||||
if (!session_->Initialize(factory_->options(), std::move(cert_generator),
|
session_->Initialize(factory_->options(), std::move(cert_generator),
|
||||||
configuration)) {
|
configuration, this);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Register PeerConnection as receiver of local ice candidates.
|
// Register PeerConnection as receiver of local ice candidates.
|
||||||
// All the callbacks will be posted to the application from PeerConnection.
|
// All the callbacks will be posted to the application from PeerConnection.
|
||||||
|
|
|
@ -209,6 +209,15 @@ class PeerConnection : public PeerConnectionInterface,
|
||||||
virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
|
virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
|
||||||
return session_->GetRemoteTrackIdBySsrc(ssrc, track_id);
|
return session_->GetRemoteTrackIdBySsrc(ssrc, track_id);
|
||||||
}
|
}
|
||||||
|
bool IceRestartPending(const std::string& content_name) const {
|
||||||
|
return session_->IceRestartPending(content_name);
|
||||||
|
}
|
||||||
|
bool NeedsIceRestart(const std::string& content_name) const {
|
||||||
|
return session_->NeedsIceRestart(content_name);
|
||||||
|
}
|
||||||
|
bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) {
|
||||||
|
return session_->GetSslRole(content_name, role);
|
||||||
|
}
|
||||||
|
|
||||||
// This is needed for stats tests to inject a MockWebRtcSession. Once
|
// This is needed for stats tests to inject a MockWebRtcSession. Once
|
||||||
// WebRtcSession has been merged in, this will no longer be needed.
|
// WebRtcSession has been merged in, this will no longer be needed.
|
||||||
|
|
|
@ -22,7 +22,6 @@
|
||||||
#include "p2p/base/p2pconstants.h"
|
#include "p2p/base/p2pconstants.h"
|
||||||
#include "p2p/base/port.h"
|
#include "p2p/base/port.h"
|
||||||
#include "pc/peerconnection.h"
|
#include "pc/peerconnection.h"
|
||||||
#include "pc/webrtcsession.h"
|
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/stringutils.h"
|
#include "rtc_base/stringutils.h"
|
||||||
#include "rtc_base/timeutils.h"
|
#include "rtc_base/timeutils.h"
|
||||||
|
@ -77,7 +76,7 @@ std::string RTCTransportStatsIDFromTransportChannel(
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string RTCTransportStatsIDFromBaseChannel(
|
std::string RTCTransportStatsIDFromBaseChannel(
|
||||||
const ProxyTransportMap& proxy_to_transport,
|
const std::map<std::string, std::string>& proxy_to_transport,
|
||||||
const cricket::BaseChannel& base_channel) {
|
const cricket::BaseChannel& base_channel) {
|
||||||
auto proxy_it = proxy_to_transport.find(base_channel.content_name());
|
auto proxy_it = proxy_to_transport.find(base_channel.content_name());
|
||||||
if (proxy_it == proxy_to_transport.cend())
|
if (proxy_it == proxy_to_transport.cend())
|
||||||
|
|
|
@ -50,7 +50,8 @@ typedef TypeForAdd<float> FloatForAdd;
|
||||||
typedef TypeForAdd<int64_t> Int64ForAdd;
|
typedef TypeForAdd<int64_t> Int64ForAdd;
|
||||||
typedef TypeForAdd<int> IntForAdd;
|
typedef TypeForAdd<int> IntForAdd;
|
||||||
|
|
||||||
StatsReport::Id GetTransportIdFromProxy(const ProxyTransportMap& map,
|
StatsReport::Id GetTransportIdFromProxy(
|
||||||
|
const std::map<std::string, std::string>& map,
|
||||||
const std::string& proxy) {
|
const std::string& proxy) {
|
||||||
RTC_DCHECK(!proxy.empty());
|
RTC_DCHECK(!proxy.empty());
|
||||||
auto found = map.find(proxy);
|
auto found = map.find(proxy);
|
||||||
|
|
|
@ -21,7 +21,6 @@
|
||||||
#include "api/mediastreaminterface.h"
|
#include "api/mediastreaminterface.h"
|
||||||
#include "api/peerconnectioninterface.h"
|
#include "api/peerconnectioninterface.h"
|
||||||
#include "api/statstypes.h"
|
#include "api/statstypes.h"
|
||||||
#include "pc/webrtcsession.h"
|
|
||||||
|
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
|
|
||||||
|
@ -139,7 +138,7 @@ class StatsCollector {
|
||||||
// Raw pointer to the peer connection the statistics are gathered from.
|
// Raw pointer to the peer connection the statistics are gathered from.
|
||||||
PeerConnection* const pc_;
|
PeerConnection* const pc_;
|
||||||
double stats_gathering_started_;
|
double stats_gathering_started_;
|
||||||
ProxyTransportMap proxy_to_transport_;
|
std::map<std::string, std::string> proxy_to_transport_;
|
||||||
|
|
||||||
// TODO(tommi): We appear to be holding on to raw pointers to reference
|
// TODO(tommi): We appear to be holding on to raw pointers to reference
|
||||||
// counted objects? We should be using scoped_refptr here.
|
// counted objects? We should be using scoped_refptr here.
|
||||||
|
|
|
@ -536,10 +536,11 @@ WebRtcSession::~WebRtcSession() {
|
||||||
LOG(LS_INFO) << "Session: " << id() << " is destroyed.";
|
LOG(LS_INFO) << "Session: " << id() << " is destroyed.";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WebRtcSession::Initialize(
|
void WebRtcSession::Initialize(
|
||||||
const PeerConnectionFactoryInterface::Options& options,
|
const PeerConnectionFactoryInterface::Options& options,
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
||||||
const PeerConnectionInterface::RTCConfiguration& rtc_configuration) {
|
const PeerConnectionInterface::RTCConfiguration& rtc_configuration,
|
||||||
|
PeerConnection* pc) {
|
||||||
bundle_policy_ = rtc_configuration.bundle_policy;
|
bundle_policy_ = rtc_configuration.bundle_policy;
|
||||||
rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
|
rtcp_mux_policy_ = rtc_configuration.rtcp_mux_policy;
|
||||||
transport_controller_->SetSslMaxProtocolVersion(options.ssl_max_version);
|
transport_controller_->SetSslMaxProtocolVersion(options.ssl_max_version);
|
||||||
|
@ -589,24 +590,20 @@ bool WebRtcSession::Initialize(
|
||||||
audio_options_.audio_jitter_buffer_fast_accelerate = rtc::Optional<bool>(
|
audio_options_.audio_jitter_buffer_fast_accelerate = rtc::Optional<bool>(
|
||||||
rtc_configuration.audio_jitter_buffer_fast_accelerate);
|
rtc_configuration.audio_jitter_buffer_fast_accelerate);
|
||||||
|
|
||||||
|
// Whether the certificate generator/certificate is null or not determines
|
||||||
|
// what WebRtcSessionDescriptionFactory will do, so make sure that we give it
|
||||||
|
// the right instructions by clearing the variables if needed.
|
||||||
if (!dtls_enabled_) {
|
if (!dtls_enabled_) {
|
||||||
// Construct with DTLS disabled.
|
cert_generator.reset();
|
||||||
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
|
certificate = nullptr;
|
||||||
signaling_thread(), channel_manager_, this, id(),
|
} else if (certificate) {
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface>()));
|
// Favor generated certificate over the certificate generator.
|
||||||
} else {
|
cert_generator.reset();
|
||||||
// Construct with DTLS enabled.
|
|
||||||
if (!certificate) {
|
|
||||||
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
|
|
||||||
signaling_thread(), channel_manager_, this, id(),
|
|
||||||
std::move(cert_generator)));
|
|
||||||
} else {
|
|
||||||
// Use the already generated certificate.
|
|
||||||
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
|
|
||||||
signaling_thread(), channel_manager_, this, id(), certificate));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
webrtc_session_desc_factory_.reset(new WebRtcSessionDescriptionFactory(
|
||||||
|
signaling_thread(), channel_manager_, pc, id(), std::move(cert_generator),
|
||||||
|
certificate));
|
||||||
webrtc_session_desc_factory_->SignalCertificateReady.connect(
|
webrtc_session_desc_factory_->SignalCertificateReady.connect(
|
||||||
this, &WebRtcSession::OnCertificateReady);
|
this, &WebRtcSession::OnCertificateReady);
|
||||||
|
|
||||||
|
@ -616,8 +613,6 @@ bool WebRtcSession::Initialize(
|
||||||
|
|
||||||
webrtc_session_desc_factory_->set_enable_encrypted_rtp_header_extensions(
|
webrtc_session_desc_factory_->set_enable_encrypted_rtp_header_extensions(
|
||||||
options.crypto_options.enable_encrypted_rtp_header_extensions);
|
options.crypto_options.enable_encrypted_rtp_header_extensions);
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void WebRtcSession::Close() {
|
void WebRtcSession::Close() {
|
||||||
|
|
|
@ -46,6 +46,7 @@ namespace webrtc {
|
||||||
class IceRestartAnswerLatch;
|
class IceRestartAnswerLatch;
|
||||||
class JsepIceCandidate;
|
class JsepIceCandidate;
|
||||||
class MediaStreamSignaling;
|
class MediaStreamSignaling;
|
||||||
|
class PeerConnection;
|
||||||
class RtcEventLog;
|
class RtcEventLog;
|
||||||
class WebRtcSessionDescriptionFactory;
|
class WebRtcSessionDescriptionFactory;
|
||||||
|
|
||||||
|
@ -99,14 +100,11 @@ class IceObserver {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Statistics for all the transports of the session.
|
// Statistics for all the transports of the session.
|
||||||
typedef std::map<std::string, cricket::TransportStats> TransportStatsMap;
|
|
||||||
typedef std::map<std::string, std::string> ProxyTransportMap;
|
|
||||||
|
|
||||||
// TODO(pthatcher): Think of a better name for this. We already have
|
// TODO(pthatcher): Think of a better name for this. We already have
|
||||||
// a TransportStats in transport.h. Perhaps TransportsStats?
|
// a TransportStats in transport.h. Perhaps TransportsStats?
|
||||||
struct SessionStats {
|
struct SessionStats {
|
||||||
ProxyTransportMap proxy_to_transport;
|
std::map<std::string, std::string> proxy_to_transport;
|
||||||
TransportStatsMap transport_stats;
|
std::map<std::string, cricket::TransportStats> transport_stats;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ChannelNamePair {
|
struct ChannelNamePair {
|
||||||
|
@ -172,10 +170,11 @@ class WebRtcSession :
|
||||||
// The ID of this session.
|
// The ID of this session.
|
||||||
const std::string& id() const { return sid_; }
|
const std::string& id() const { return sid_; }
|
||||||
|
|
||||||
bool Initialize(
|
void Initialize(
|
||||||
const PeerConnectionFactoryInterface::Options& options,
|
const PeerConnectionFactoryInterface::Options& options,
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
||||||
const PeerConnectionInterface::RTCConfiguration& rtc_configuration);
|
const PeerConnectionInterface::RTCConfiguration& rtc_configuration,
|
||||||
|
PeerConnection* pc);
|
||||||
// Deletes the voice, video and data channel and changes the session state
|
// Deletes the voice, video and data channel and changes the session state
|
||||||
// to STATE_CLOSED.
|
// to STATE_CLOSED.
|
||||||
void Close();
|
void Close();
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
#include "api/jsep.h"
|
#include "api/jsep.h"
|
||||||
#include "api/jsepsessiondescription.h"
|
#include "api/jsepsessiondescription.h"
|
||||||
#include "api/mediaconstraintsinterface.h"
|
#include "api/mediaconstraintsinterface.h"
|
||||||
#include "pc/webrtcsession.h"
|
#include "pc/peerconnection.h"
|
||||||
#include "rtc_base/checks.h"
|
#include "rtc_base/checks.h"
|
||||||
#include "rtc_base/sslidentity.h"
|
#include "rtc_base/sslidentity.h"
|
||||||
|
|
||||||
|
@ -118,7 +118,7 @@ void WebRtcSessionDescriptionFactory::CopyCandidatesFromSessionDescription(
|
||||||
WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
||||||
rtc::Thread* signaling_thread,
|
rtc::Thread* signaling_thread,
|
||||||
cricket::ChannelManager* channel_manager,
|
cricket::ChannelManager* channel_manager,
|
||||||
WebRtcSession* session,
|
PeerConnection* pc,
|
||||||
const std::string& session_id,
|
const std::string& session_id,
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
||||||
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
|
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
|
||||||
|
@ -130,10 +130,11 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
||||||
// |kInitSessionVersion|.
|
// |kInitSessionVersion|.
|
||||||
session_version_(kInitSessionVersion),
|
session_version_(kInitSessionVersion),
|
||||||
cert_generator_(std::move(cert_generator)),
|
cert_generator_(std::move(cert_generator)),
|
||||||
session_(session),
|
pc_(pc),
|
||||||
session_id_(session_id),
|
session_id_(session_id),
|
||||||
certificate_request_state_(CERTIFICATE_NOT_NEEDED) {
|
certificate_request_state_(CERTIFICATE_NOT_NEEDED) {
|
||||||
RTC_DCHECK(signaling_thread_);
|
RTC_DCHECK(signaling_thread_);
|
||||||
|
RTC_DCHECK(!(cert_generator_ && certificate));
|
||||||
bool dtls_enabled = cert_generator_ || certificate;
|
bool dtls_enabled = cert_generator_ || certificate;
|
||||||
// SRTP-SDES is disabled if DTLS is on.
|
// SRTP-SDES is disabled if DTLS is on.
|
||||||
SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED);
|
SetSdesPolicy(dtls_enabled ? cricket::SEC_DISABLED : cricket::SEC_REQUIRED);
|
||||||
|
@ -175,36 +176,6 @@ WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
|
||||||
rtc::Thread* signaling_thread,
|
|
||||||
cricket::ChannelManager* channel_manager,
|
|
||||||
WebRtcSession* session,
|
|
||||||
const std::string& session_id,
|
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator)
|
|
||||||
: WebRtcSessionDescriptionFactory(
|
|
||||||
signaling_thread,
|
|
||||||
channel_manager,
|
|
||||||
session,
|
|
||||||
session_id,
|
|
||||||
std::move(cert_generator),
|
|
||||||
nullptr) {
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtcSessionDescriptionFactory::WebRtcSessionDescriptionFactory(
|
|
||||||
rtc::Thread* signaling_thread,
|
|
||||||
cricket::ChannelManager* channel_manager,
|
|
||||||
WebRtcSession* session,
|
|
||||||
const std::string& session_id,
|
|
||||||
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate)
|
|
||||||
: WebRtcSessionDescriptionFactory(signaling_thread,
|
|
||||||
channel_manager,
|
|
||||||
session,
|
|
||||||
session_id,
|
|
||||||
nullptr,
|
|
||||||
certificate) {
|
|
||||||
RTC_DCHECK(certificate);
|
|
||||||
}
|
|
||||||
|
|
||||||
WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
|
WebRtcSessionDescriptionFactory::~WebRtcSessionDescriptionFactory() {
|
||||||
RTC_DCHECK(signaling_thread_->IsCurrent());
|
RTC_DCHECK(signaling_thread_->IsCurrent());
|
||||||
|
|
||||||
|
@ -270,14 +241,13 @@ void WebRtcSessionDescriptionFactory::CreateAnswer(
|
||||||
PostCreateSessionDescriptionFailed(observer, error);
|
PostCreateSessionDescriptionFailed(observer, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!session_->remote_description()) {
|
if (!pc_->remote_description()) {
|
||||||
error += " can't be called before SetRemoteDescription.";
|
error += " can't be called before SetRemoteDescription.";
|
||||||
LOG(LS_ERROR) << error;
|
LOG(LS_ERROR) << error;
|
||||||
PostCreateSessionDescriptionFailed(observer, error);
|
PostCreateSessionDescriptionFailed(observer, error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session_->remote_description()->type() !=
|
if (pc_->remote_description()->type() != JsepSessionDescription::kOffer) {
|
||||||
JsepSessionDescription::kOffer) {
|
|
||||||
error += " failed because remote_description is not an offer.";
|
error += " failed because remote_description is not an offer.";
|
||||||
LOG(LS_ERROR) << error;
|
LOG(LS_ERROR) << error;
|
||||||
PostCreateSessionDescriptionFailed(observer, error);
|
PostCreateSessionDescriptionFailed(observer, error);
|
||||||
|
@ -344,20 +314,20 @@ void WebRtcSessionDescriptionFactory::OnMessage(rtc::Message* msg) {
|
||||||
|
|
||||||
void WebRtcSessionDescriptionFactory::InternalCreateOffer(
|
void WebRtcSessionDescriptionFactory::InternalCreateOffer(
|
||||||
CreateSessionDescriptionRequest request) {
|
CreateSessionDescriptionRequest request) {
|
||||||
if (session_->local_description()) {
|
if (pc_->local_description()) {
|
||||||
// If the needs-ice-restart flag is set as described by JSEP, we should
|
// If the needs-ice-restart flag is set as described by JSEP, we should
|
||||||
// generate an offer with a new ufrag/password to trigger an ICE restart.
|
// generate an offer with a new ufrag/password to trigger an ICE restart.
|
||||||
for (cricket::MediaDescriptionOptions& options :
|
for (cricket::MediaDescriptionOptions& options :
|
||||||
request.options.media_description_options) {
|
request.options.media_description_options) {
|
||||||
if (session_->NeedsIceRestart(options.mid)) {
|
if (pc_->NeedsIceRestart(options.mid)) {
|
||||||
options.transport_options.ice_restart = true;
|
options.transport_options.ice_restart = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::SessionDescription* desc(session_desc_factory_.CreateOffer(
|
cricket::SessionDescription* desc(session_desc_factory_.CreateOffer(
|
||||||
request.options, session_->local_description()
|
request.options, pc_->local_description()
|
||||||
? session_->local_description()->description()
|
? pc_->local_description()->description()
|
||||||
: nullptr));
|
: nullptr));
|
||||||
// RFC 3264
|
// RFC 3264
|
||||||
// When issuing an offer that modifies the session,
|
// When issuing an offer that modifies the session,
|
||||||
|
@ -378,11 +348,11 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
|
||||||
"Failed to initialize the offer.");
|
"Failed to initialize the offer.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session_->local_description()) {
|
if (pc_->local_description()) {
|
||||||
for (const cricket::MediaDescriptionOptions& options :
|
for (const cricket::MediaDescriptionOptions& options :
|
||||||
request.options.media_description_options) {
|
request.options.media_description_options) {
|
||||||
if (!options.transport_options.ice_restart) {
|
if (!options.transport_options.ice_restart) {
|
||||||
CopyCandidatesFromSessionDescription(session_->local_description(),
|
CopyCandidatesFromSessionDescription(pc_->local_description(),
|
||||||
options.mid, offer);
|
options.mid, offer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -392,18 +362,18 @@ void WebRtcSessionDescriptionFactory::InternalCreateOffer(
|
||||||
|
|
||||||
void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
|
void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
|
||||||
CreateSessionDescriptionRequest request) {
|
CreateSessionDescriptionRequest request) {
|
||||||
if (session_->remote_description()) {
|
if (pc_->remote_description()) {
|
||||||
for (cricket::MediaDescriptionOptions& options :
|
for (cricket::MediaDescriptionOptions& options :
|
||||||
request.options.media_description_options) {
|
request.options.media_description_options) {
|
||||||
// According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1
|
// According to http://tools.ietf.org/html/rfc5245#section-9.2.1.1
|
||||||
// an answer should also contain new ICE ufrag and password if an offer
|
// an answer should also contain new ICE ufrag and password if an offer
|
||||||
// has been received with new ufrag and password.
|
// has been received with new ufrag and password.
|
||||||
options.transport_options.ice_restart =
|
options.transport_options.ice_restart =
|
||||||
session_->IceRestartPending(options.mid);
|
pc_->IceRestartPending(options.mid);
|
||||||
// We should pass the current SSL role to the transport description
|
// We should pass the current SSL role to the transport description
|
||||||
// factory, if there is already an existing ongoing session.
|
// factory, if there is already an existing ongoing session.
|
||||||
rtc::SSLRole ssl_role;
|
rtc::SSLRole ssl_role;
|
||||||
if (session_->GetSslRole(options.mid, &ssl_role)) {
|
if (pc_->GetSslRole(options.mid, &ssl_role)) {
|
||||||
options.transport_options.prefer_passive_role =
|
options.transport_options.prefer_passive_role =
|
||||||
(rtc::SSL_SERVER == ssl_role);
|
(rtc::SSL_SERVER == ssl_role);
|
||||||
}
|
}
|
||||||
|
@ -411,11 +381,10 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
|
||||||
}
|
}
|
||||||
|
|
||||||
cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer(
|
cricket::SessionDescription* desc(session_desc_factory_.CreateAnswer(
|
||||||
session_->remote_description()
|
pc_->remote_description() ? pc_->remote_description()->description()
|
||||||
? session_->remote_description()->description()
|
|
||||||
: nullptr,
|
: nullptr,
|
||||||
request.options, session_->local_description()
|
request.options,
|
||||||
? session_->local_description()->description()
|
pc_->local_description() ? pc_->local_description()->description()
|
||||||
: nullptr));
|
: nullptr));
|
||||||
// RFC 3264
|
// RFC 3264
|
||||||
// If the answer is different from the offer in any way (different IP
|
// If the answer is different from the offer in any way (different IP
|
||||||
|
@ -434,13 +403,13 @@ void WebRtcSessionDescriptionFactory::InternalCreateAnswer(
|
||||||
"Failed to initialize the answer.");
|
"Failed to initialize the answer.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (session_->local_description()) {
|
if (pc_->local_description()) {
|
||||||
// Include all local ICE candidates in the SessionDescription unless
|
// Include all local ICE candidates in the SessionDescription unless
|
||||||
// the remote peer has requested an ICE restart.
|
// the remote peer has requested an ICE restart.
|
||||||
for (const cricket::MediaDescriptionOptions& options :
|
for (const cricket::MediaDescriptionOptions& options :
|
||||||
request.options.media_description_options) {
|
request.options.media_description_options) {
|
||||||
if (!options.transport_options.ice_restart) {
|
if (!options.transport_options.ice_restart) {
|
||||||
CopyCandidatesFromSessionDescription(session_->local_description(),
|
CopyCandidatesFromSessionDescription(pc_->local_description(),
|
||||||
options.mid, answer);
|
options.mid, answer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@ class TransportDescriptionFactory;
|
||||||
namespace webrtc {
|
namespace webrtc {
|
||||||
class CreateSessionDescriptionObserver;
|
class CreateSessionDescriptionObserver;
|
||||||
class MediaConstraintsInterface;
|
class MediaConstraintsInterface;
|
||||||
|
class PeerConnection;
|
||||||
class SessionDescriptionInterface;
|
class SessionDescriptionInterface;
|
||||||
class WebRtcSession;
|
class WebRtcSession;
|
||||||
|
|
||||||
|
@ -74,20 +75,16 @@ struct CreateSessionDescriptionRequest {
|
||||||
class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
|
class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
|
||||||
public sigslot::has_slots<> {
|
public sigslot::has_slots<> {
|
||||||
public:
|
public:
|
||||||
// If |certificate_generator| is not null, DTLS is enabled and a default
|
// Can specify either a |cert_generator| or |certificate| to enable DTLS. If
|
||||||
// certificate is generated asynchronously; otherwise DTLS is disabled.
|
// a certificate generator is given, starts generating the certificate
|
||||||
|
// asynchronously. If a certificate is given, will use that for identifying
|
||||||
|
// over DTLS. If neither is specified, DTLS is disabled.
|
||||||
WebRtcSessionDescriptionFactory(
|
WebRtcSessionDescriptionFactory(
|
||||||
rtc::Thread* signaling_thread,
|
rtc::Thread* signaling_thread,
|
||||||
cricket::ChannelManager* channel_manager,
|
cricket::ChannelManager* channel_manager,
|
||||||
WebRtcSession* session,
|
PeerConnection* pc,
|
||||||
const std::string& session_id,
|
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator);
|
|
||||||
// Construct with DTLS enabled using the specified |certificate|.
|
|
||||||
WebRtcSessionDescriptionFactory(
|
|
||||||
rtc::Thread* signaling_thread,
|
|
||||||
cricket::ChannelManager* channel_manager,
|
|
||||||
WebRtcSession* session,
|
|
||||||
const std::string& session_id,
|
const std::string& session_id,
|
||||||
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
||||||
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
||||||
virtual ~WebRtcSessionDescriptionFactory();
|
virtual ~WebRtcSessionDescriptionFactory();
|
||||||
|
|
||||||
|
@ -126,16 +123,6 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
|
||||||
CERTIFICATE_FAILED,
|
CERTIFICATE_FAILED,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If |certificate_generator| or |certificate| is not null DTLS is enabled,
|
|
||||||
// otherwise DTLS is disabled.
|
|
||||||
WebRtcSessionDescriptionFactory(
|
|
||||||
rtc::Thread* signaling_thread,
|
|
||||||
cricket::ChannelManager* channel_manager,
|
|
||||||
WebRtcSession* session,
|
|
||||||
const std::string& session_id,
|
|
||||||
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
|
||||||
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
|
||||||
|
|
||||||
// MessageHandler implementation.
|
// MessageHandler implementation.
|
||||||
virtual void OnMessage(rtc::Message* msg);
|
virtual void OnMessage(rtc::Message* msg);
|
||||||
|
|
||||||
|
@ -161,8 +148,9 @@ class WebRtcSessionDescriptionFactory : public rtc::MessageHandler,
|
||||||
cricket::MediaSessionDescriptionFactory session_desc_factory_;
|
cricket::MediaSessionDescriptionFactory session_desc_factory_;
|
||||||
uint64_t session_version_;
|
uint64_t session_version_;
|
||||||
const std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator_;
|
const std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator_;
|
||||||
// TODO(jiayl): remove the dependency on session once bug 2264 is fixed.
|
// TODO(jiayl): remove the dependency on peer connection once bug 2264 is
|
||||||
WebRtcSession* const session_;
|
// fixed.
|
||||||
|
PeerConnection* const pc_;
|
||||||
const std::string session_id_;
|
const std::string session_id_;
|
||||||
CertificateRequestState certificate_request_state_;
|
CertificateRequestState certificate_request_state_;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue