Revert "Move clients of WebRtcSession to use PeerConnection"

This reverts commit 3dc4d4a21f80cdf44c508412d784b254957696eb.

Reason for revert: breaks internal project

Original change's description:
> Move clients of WebRtcSession to use PeerConnection
> 
> This change is part of the work to merge WebRtcSession into
> PeerConnection. To make that work easier, this moves all clients
> of WebRtcSession to use shims added to PeerConnection. That way
> when the classes are merged they won't need to be modified.
> 
> Bug: webrtc:8183
> Change-Id: I43de7acf7e38c9fcf2dbf55d50eb05e73767c251
> Reviewed-on: https://webrtc-review.googlesource.com/4320
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Steve Anton <steveanton@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20030}

TBR=steveanton@webrtc.org,deadbeef@webrtc.org

Change-Id: I13f335b24c26753429cd08a4ca3e295eed5660ff
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8183
Reviewed-on: https://webrtc-review.googlesource.com/4700
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20035}
This commit is contained in:
Alex Loiko 2017-09-29 10:44:31 +00:00 committed by Commit Bot
parent 57fb3154b5
commit bf66794c06
7 changed files with 102 additions and 149 deletions

View File

@ -421,16 +421,12 @@ PeerConnection::~PeerConnection() {
// Now destroy session_ before destroying other members,
// because its destruction fires signals (such as VoiceChannelDestroyed)
// which will trigger some final actions in PeerConnection...
if (borrowed_session_) {
session_.release();
} else {
session_.reset(nullptr);
}
session_.reset(nullptr);
// port_allocator_ lives on the network thread and should be destroyed there.
network_thread()->Invoke<void>(RTC_FROM_HERE,
[this] { port_allocator_.reset(); });
// call_ and event_log_ must be destroyed on the worker thread.
worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
call_.reset();
event_log_.reset();
});
@ -471,9 +467,12 @@ bool PeerConnection::Initialize(
return false;
}
session_.reset(new WebRtcSession(
call_.get(), factory_->channel_manager(), configuration.media_config,
event_log_.get(), network_thread(), worker_thread(), signaling_thread(),
event_log_.get(),
factory_->network_thread(),
factory_->worker_thread(), factory_->signaling_thread(),
port_allocator_.get(),
std::unique_ptr<cricket::TransportController>(
factory_->CreateTransportController(
@ -481,7 +480,7 @@ bool PeerConnection::Initialize(
configuration.redetermine_role_on_ice_restart)),
#ifdef HAVE_SCTP
std::unique_ptr<cricket::SctpTransportInternalFactory>(
new cricket::SctpTransportFactory(network_thread()))
new cricket::SctpTransportFactory(factory_->network_thread()))
#else
nullptr
#endif
@ -1241,8 +1240,9 @@ void PeerConnection::RegisterUMAObserver(UMAObserver* observer) {
}
RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) {
if (!worker_thread()->IsCurrent()) {
return worker_thread()->Invoke<RTCError>(
rtc::Thread* worker_thread = factory_->worker_thread();
if (!worker_thread->IsCurrent()) {
return worker_thread->Invoke<RTCError>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::SetBitrate, this, bitrate));
}
@ -1289,13 +1289,13 @@ RTCError PeerConnection::SetBitrate(const BitrateParameters& bitrate) {
bool PeerConnection::StartRtcEventLog(rtc::PlatformFile file,
int64_t max_size_bytes) {
return worker_thread()->Invoke<bool>(
return factory_->worker_thread()->Invoke<bool>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::StartRtcEventLog_w, this, file,
max_size_bytes));
}
void PeerConnection::StopRtcEventLog() {
worker_thread()->Invoke<void>(
factory_->worker_thread()->Invoke<void>(
RTC_FROM_HERE, rtc::Bind(&PeerConnection::StopRtcEventLog_w, this));
}
@ -1339,7 +1339,7 @@ void PeerConnection::Close() {
rtc::Bind(&cricket::PortAllocator::DiscardCandidatePool,
port_allocator_.get()));
worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
factory_->worker_thread()->Invoke<void>(RTC_FROM_HERE, [this] {
call_.reset();
// The event log must outlive call (and any other object that uses it).
event_log_.reset();
@ -1437,7 +1437,7 @@ void PeerConnection::CreateVideoReceiver(MediaStreamInterface* stream,
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
receiver = RtpReceiverProxyWithInternal<RtpReceiverInternal>::Create(
signaling_thread(),
new VideoRtpReceiver(track_id, worker_thread(), ssrc,
new VideoRtpReceiver(track_id, factory_->worker_thread(), ssrc,
session_->video_channel()));
stream->AddTrack(
static_cast<VideoTrackInterface*>(receiver->internal()->track().get()));

View File

@ -65,6 +65,8 @@ class PeerConnection : public PeerConnectionInterface,
std::vector<MediaStreamInterface*> streams) override;
bool RemoveTrack(RtpSenderInterface* sender) override;
virtual WebRtcSession* session() { return session_.get(); }
rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
AudioTrackInterface* track) override;
@ -144,65 +146,6 @@ class PeerConnection : public PeerConnectionInterface,
return sctp_data_channels_;
}
// TODO(steveanton): These methods are temporarily added to facilitate work
// towards merging WebRtcSession into PeerConnection. To make this easier, we
// want only PeerConnection to interact with WebRtcSession so they can be
// merged easily. A few outside classes still access WebRtcSession methods
// directly, so these have been added to PeerConnection to remove the
// dependency from WebRtcSession.
rtc::Thread* network_thread() const { return factory_->network_thread(); }
rtc::Thread* worker_thread() const { return factory_->worker_thread(); }
rtc::Thread* signaling_thread() const { return factory_->signaling_thread(); }
virtual const std::string& session_id() const { return session_->id(); }
virtual bool session_created() const { return session_ != nullptr; }
virtual bool initial_offerer() const { return session_->initial_offerer(); }
virtual std::unique_ptr<SessionStats> GetSessionStats_s() {
return session_->GetStats_s();
}
virtual std::unique_ptr<SessionStats> GetSessionStats(
const ChannelNamePairs& channel_name_pairs) {
return session_->GetStats(channel_name_pairs);
}
virtual bool GetLocalCertificate(
const std::string& transport_name,
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
return session_->GetLocalCertificate(transport_name, certificate);
}
virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
const std::string& transport_name) {
return session_->GetRemoteSSLCertificate(transport_name);
}
virtual Call::Stats GetCallStats() { return session_->GetCallStats(); }
virtual cricket::VoiceChannel* voice_channel() {
return session_->voice_channel();
}
virtual cricket::VideoChannel* video_channel() {
return session_->video_channel();
}
virtual cricket::RtpDataChannel* rtp_data_channel() {
return session_->rtp_data_channel();
}
virtual rtc::Optional<std::string> sctp_content_name() const {
return session_->sctp_content_name();
}
virtual rtc::Optional<std::string> sctp_transport_name() const {
return session_->sctp_transport_name();
}
virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
return session_->GetLocalTrackIdBySsrc(ssrc, track_id);
}
virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) {
return session_->GetRemoteTrackIdBySsrc(ssrc, track_id);
}
// This is needed for stats tests to inject a MockWebRtcSession. Once
// WebRtcSession has been merged in, this will no longer be needed.
void set_session_for_testing(WebRtcSession* session) {
session_.reset(session);
borrowed_session_ = true;
}
protected:
~PeerConnection() override;
@ -267,6 +210,12 @@ class PeerConnection : public PeerConnectionInterface,
void OnVideoTrackRemoved(VideoTrackInterface* track,
MediaStreamInterface* stream);
rtc::Thread* signaling_thread() const {
return factory_->signaling_thread();
}
rtc::Thread* network_thread() const { return factory_->network_thread(); }
void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
const std::string& error);
void PostCreateSessionDescriptionFailure(
@ -485,9 +434,6 @@ class PeerConnection : public PeerConnectionInterface,
std::unique_ptr<Call> call_;
std::unique_ptr<WebRtcSession> session_;
// TODO(steveanton): Some tests need to inject a mock WebRtcSession. This
// indicates that we should not delete the WebRtcSession ourself.
bool borrowed_session_ = false;
std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;

View File

@ -588,9 +588,9 @@ rtc::scoped_refptr<RTCStatsCollector> RTCStatsCollector::Create(
RTCStatsCollector::RTCStatsCollector(PeerConnection* pc,
int64_t cache_lifetime_us)
: pc_(pc),
signaling_thread_(pc->signaling_thread()),
worker_thread_(pc->worker_thread()),
network_thread_(pc->network_thread()),
signaling_thread_(pc->session()->signaling_thread()),
worker_thread_(pc->session()->worker_thread()),
network_thread_(pc->session()->network_thread()),
num_pending_partial_reports_(0),
partial_report_timestamp_us_(0),
cache_timestamp_us_(0),
@ -636,25 +636,26 @@ void RTCStatsCollector::GetStatsReport(
// Prepare |channel_name_pairs_| for use in
// |ProducePartialResultsOnNetworkThread|.
channel_name_pairs_.reset(new ChannelNamePairs());
if (pc_->voice_channel()) {
if (pc_->session()->voice_channel()) {
channel_name_pairs_->voice = rtc::Optional<ChannelNamePair>(
ChannelNamePair(pc_->voice_channel()->content_name(),
pc_->voice_channel()->transport_name()));
ChannelNamePair(pc_->session()->voice_channel()->content_name(),
pc_->session()->voice_channel()->transport_name()));
}
if (pc_->video_channel()) {
if (pc_->session()->video_channel()) {
channel_name_pairs_->video = rtc::Optional<ChannelNamePair>(
ChannelNamePair(pc_->video_channel()->content_name(),
pc_->video_channel()->transport_name()));
ChannelNamePair(pc_->session()->video_channel()->content_name(),
pc_->session()->video_channel()->transport_name()));
}
if (pc_->rtp_data_channel()) {
channel_name_pairs_->data = rtc::Optional<ChannelNamePair>(
ChannelNamePair(pc_->rtp_data_channel()->content_name(),
pc_->rtp_data_channel()->transport_name()));
}
if (pc_->sctp_content_name()) {
if (pc_->session()->rtp_data_channel()) {
channel_name_pairs_->data =
rtc::Optional<ChannelNamePair>(ChannelNamePair(
*pc_->sctp_content_name(), *pc_->sctp_transport_name()));
pc_->session()->rtp_data_channel()->content_name(),
pc_->session()->rtp_data_channel()->transport_name()));
}
if (pc_->session()->sctp_content_name()) {
channel_name_pairs_->data = rtc::Optional<ChannelNamePair>(
ChannelNamePair(*pc_->session()->sctp_content_name(),
*pc_->session()->sctp_transport_name()));
}
// Prepare |track_media_info_map_| for use in
// |ProducePartialResultsOnNetworkThread| and
@ -669,7 +670,7 @@ void RTCStatsCollector::GetStatsReport(
// thread.
// TODO(holmer): To avoid the hop we could move BWE and BWE stats to the
// network thread, where it more naturally belongs.
call_stats_ = pc_->GetCallStats();
call_stats_ = pc_->session()->GetCallStats();
invoker_.AsyncInvoke<void>(
RTC_FROM_HERE, network_thread_,
@ -715,7 +716,7 @@ void RTCStatsCollector::ProducePartialResultsOnNetworkThread(
timestamp_us);
std::unique_ptr<SessionStats> session_stats =
pc_->GetSessionStats(*channel_name_pairs_);
pc_->session()->GetStats(*channel_name_pairs_);
if (session_stats) {
std::map<std::string, CertificateStatsPair> transport_cert_stats =
PrepareTransportCertificateStats_n(*session_stats);
@ -975,7 +976,7 @@ void RTCStatsCollector::ProduceRTPStreamStats_n(
// Audio
if (track_media_info_map.voice_media_info()) {
std::string transport_id = RTCTransportStatsIDFromBaseChannel(
session_stats.proxy_to_transport, *pc_->voice_channel());
session_stats.proxy_to_transport, *pc_->session()->voice_channel());
RTC_DCHECK(!transport_id.empty());
// Inbound
for (const cricket::VoiceReceiverInfo& voice_receiver_info :
@ -1037,7 +1038,7 @@ void RTCStatsCollector::ProduceRTPStreamStats_n(
// Video
if (track_media_info_map.video_media_info()) {
std::string transport_id = RTCTransportStatsIDFromBaseChannel(
session_stats.proxy_to_transport, *pc_->video_channel());
session_stats.proxy_to_transport, *pc_->session()->video_channel());
RTC_DCHECK(!transport_id.empty());
// Inbound
for (const cricket::VideoReceiverInfo& video_receiver_info :
@ -1172,13 +1173,14 @@ RTCStatsCollector::PrepareTransportCertificateStats_n(
for (const auto& transport_stats : session_stats.transport_stats) {
CertificateStatsPair certificate_stats_pair;
rtc::scoped_refptr<rtc::RTCCertificate> local_certificate;
if (pc_->GetLocalCertificate(transport_stats.second.transport_name,
&local_certificate)) {
if (pc_->session()->GetLocalCertificate(
transport_stats.second.transport_name, &local_certificate)) {
certificate_stats_pair.local =
local_certificate->ssl_certificate().GetStats();
}
std::unique_ptr<rtc::SSLCertificate> remote_certificate =
pc_->GetRemoteSSLCertificate(transport_stats.second.transport_name);
pc_->session()->GetRemoteSSLCertificate(
transport_stats.second.transport_name);
if (remote_certificate) {
certificate_stats_pair.remote = remote_certificate->GetStats();
}
@ -1193,16 +1195,16 @@ std::unique_ptr<TrackMediaInfoMap>
RTCStatsCollector::PrepareTrackMediaInfoMap_s() const {
RTC_DCHECK(signaling_thread_->IsCurrent());
std::unique_ptr<cricket::VoiceMediaInfo> voice_media_info;
if (pc_->voice_channel()) {
if (pc_->session()->voice_channel()) {
voice_media_info.reset(new cricket::VoiceMediaInfo());
if (!pc_->voice_channel()->GetStats(voice_media_info.get())) {
if (!pc_->session()->voice_channel()->GetStats(voice_media_info.get())) {
voice_media_info.reset();
}
}
std::unique_ptr<cricket::VideoMediaInfo> video_media_info;
if (pc_->video_channel()) {
if (pc_->session()->video_channel()) {
video_media_info.reset(new cricket::VideoMediaInfo());
if (!pc_->video_channel()->GetStats(video_media_info.get())) {
if (!pc_->session()->video_channel()->GetStats(video_media_info.get())) {
video_media_info.reset();
}
}

View File

@ -286,10 +286,10 @@ class RTCStatsCollectorTestHelper : public SetSessionDescriptionObserver {
network_thread_)),
session_(channel_manager_.get(), cricket::MediaConfig()),
pc_() {
pc_.set_session_for_testing(&session_);
// Default return values for mocks.
EXPECT_CALL(pc_, local_streams()).WillRepeatedly(Return(nullptr));
EXPECT_CALL(pc_, remote_streams()).WillRepeatedly(Return(nullptr));
EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
EXPECT_CALL(pc_, GetSenders()).WillRepeatedly(Return(
std::vector<rtc::scoped_refptr<RtpSenderInterface>>()));
EXPECT_CALL(pc_, GetReceivers()).WillRepeatedly(Return(
@ -561,11 +561,14 @@ class FakeRTCStatsCollector : public RTCStatsCollector,
}
protected:
FakeRTCStatsCollector(PeerConnection* pc, int64_t cache_lifetime)
FakeRTCStatsCollector(
PeerConnection* pc,
int64_t cache_lifetime)
: RTCStatsCollector(pc, cache_lifetime),
signaling_thread_(pc->signaling_thread()),
worker_thread_(pc->worker_thread()),
network_thread_(pc->network_thread()) {}
signaling_thread_(pc->session()->signaling_thread()),
worker_thread_(pc->session()->worker_thread()),
network_thread_(pc->session()->network_thread()) {
}
void ProducePartialResultsOnSignalingThread(int64_t timestamp_us) override {
EXPECT_TRUE(signaling_thread_->IsCurrent());

View File

@ -447,7 +447,7 @@ StatsCollector::StatsCollector(PeerConnection* pc)
}
StatsCollector::~StatsCollector() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
}
// Wallclock time in ms.
@ -459,7 +459,7 @@ double StatsCollector::GetTimeNow() {
// Adds a MediaStream with tracks that can be used as a |selector| in a call
// to GetStats.
void StatsCollector::AddStream(MediaStreamInterface* stream) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(stream != NULL);
CreateTrackReports<AudioTrackVector>(stream->GetAudioTracks(),
@ -470,7 +470,7 @@ void StatsCollector::AddStream(MediaStreamInterface* stream) {
void StatsCollector::AddLocalAudioTrack(AudioTrackInterface* audio_track,
uint32_t ssrc) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(audio_track != NULL);
#if RTC_DCHECK_IS_ON
for (const auto& track : local_audio_tracks_)
@ -504,7 +504,7 @@ void StatsCollector::RemoveLocalAudioTrack(AudioTrackInterface* audio_track,
void StatsCollector::GetStats(MediaStreamTrackInterface* track,
StatsReports* reports) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(reports != NULL);
RTC_DCHECK(reports->empty());
@ -518,7 +518,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
}
StatsReport* report = reports_.Find(StatsReport::NewTypedId(
StatsReport::kStatsReportTypeSession, pc_->session_id()));
StatsReport::kStatsReportTypeSession, pc_->session()->id()));
if (report)
reports->push_back(report);
@ -544,7 +544,7 @@ void StatsCollector::GetStats(MediaStreamTrackInterface* track,
void
StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
double time_now = GetTimeNow();
// Calls to UpdateStats() that occur less than kMinGatherStatsPeriod number of
// ms apart will be ignored.
@ -557,7 +557,7 @@ StatsCollector::UpdateStats(PeerConnectionInterface::StatsOutputLevel level) {
// TODO(pthatcher): Merge PeerConnection and WebRtcSession so there is no
// pc_->session().
if (pc_->session_created()) {
if (pc_->session()) {
// TODO(tommi): All of these hop over to the worker thread to fetch
// information. We could use an AsyncInvoker to run all of these and post
// the information back to the signaling thread where we can create and
@ -579,7 +579,7 @@ StatsReport* StatsCollector::PrepareReport(
uint32_t ssrc,
const StatsReport::Id& transport_id,
StatsReport::Direction direction) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
StatsReport::Id id(StatsReport::NewIdWithDirection(
local ? StatsReport::kStatsReportTypeSsrc
: StatsReport::kStatsReportTypeRemoteSsrc,
@ -623,7 +623,7 @@ bool StatsCollector::IsValidTrack(const std::string& track_id) {
StatsReport* StatsCollector::AddCertificateReports(
const rtc::SSLCertificate* cert) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(cert != NULL);
std::unique_ptr<rtc::SSLCertificateStats> first_stats = cert->GetStats();
@ -734,17 +734,17 @@ StatsReport* StatsCollector::AddCandidateReport(
}
void StatsCollector::ExtractSessionInfo() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
// Extract information from the base session.
StatsReport::Id id(StatsReport::NewTypedId(
StatsReport::kStatsReportTypeSession, pc_->session_id()));
StatsReport::kStatsReportTypeSession, pc_->session()->id()));
StatsReport* report = reports_.ReplaceOrAddNew(id);
report->set_timestamp(stats_gathering_started_);
report->AddBoolean(StatsReport::kStatsValueNameInitiator,
pc_->initial_offerer());
pc_->session()->initial_offerer());
std::unique_ptr<SessionStats> stats = pc_->GetSessionStats_s();
std::unique_ptr<SessionStats> stats = pc_->session()->GetStats_s();
if (!stats) {
return;
}
@ -764,15 +764,16 @@ void StatsCollector::ExtractSessionInfo() {
//
StatsReport::Id local_cert_report_id, remote_cert_report_id;
rtc::scoped_refptr<rtc::RTCCertificate> certificate;
if (pc_->GetLocalCertificate(transport_iter.second.transport_name,
&certificate)) {
if (pc_->session()->GetLocalCertificate(
transport_iter.second.transport_name, &certificate)) {
StatsReport* r = AddCertificateReports(&(certificate->ssl_certificate()));
if (r)
local_cert_report_id = r->id();
}
std::unique_ptr<rtc::SSLCertificate> cert =
pc_->GetRemoteSSLCertificate(transport_iter.second.transport_name);
pc_->session()->GetRemoteSSLCertificate(
transport_iter.second.transport_name);
if (cert) {
StatsReport* r = AddCertificateReports(cert.get());
if (r)
@ -827,20 +828,20 @@ void StatsCollector::ExtractSessionInfo() {
}
void StatsCollector::ExtractBweInfo() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
if (pc_->signaling_state() == PeerConnectionInterface::kClosed)
if (pc_->session()->state() == WebRtcSession::State::STATE_CLOSED)
return;
webrtc::Call::Stats call_stats = pc_->GetCallStats();
webrtc::Call::Stats call_stats = pc_->session()->GetCallStats();
cricket::BandwidthEstimationInfo bwe_info;
bwe_info.available_send_bandwidth = call_stats.send_bandwidth_bps;
bwe_info.available_recv_bandwidth = call_stats.recv_bandwidth_bps;
bwe_info.bucket_delay = call_stats.pacer_delay_ms;
// Fill in target encoder bitrate, actual encoder bitrate, rtx bitrate, etc.
// TODO(holmer): Also fill this in for audio.
if (pc_->video_channel()) {
pc_->video_channel()->FillBitrateInfo(&bwe_info);
if (pc_->session()->video_channel()) {
pc_->session()->video_channel()->FillBitrateInfo(&bwe_info);
}
StatsReport::Id report_id(StatsReport::NewBandwidthEstimationId());
StatsReport* report = reports_.FindOrAddNew(report_id);
@ -848,13 +849,13 @@ void StatsCollector::ExtractBweInfo() {
}
void StatsCollector::ExtractVoiceInfo() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
if (!pc_->voice_channel()) {
if (!pc_->session()->voice_channel()) {
return;
}
cricket::VoiceMediaInfo voice_info;
if (!pc_->voice_channel()->GetStats(&voice_info)) {
if (!pc_->session()->voice_channel()->GetStats(&voice_info)) {
LOG(LS_ERROR) << "Failed to get voice channel stats.";
return;
}
@ -864,10 +865,10 @@ void StatsCollector::ExtractVoiceInfo() {
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
StatsReport::Id transport_id(GetTransportIdFromProxy(
proxy_to_transport_, pc_->voice_channel()->content_name()));
proxy_to_transport_, pc_->session()->voice_channel()->content_name()));
if (!transport_id.get()) {
LOG(LS_ERROR) << "Failed to get transport name for proxy "
<< pc_->voice_channel()->content_name();
<< pc_->session()->voice_channel()->content_name();
return;
}
@ -881,13 +882,13 @@ void StatsCollector::ExtractVoiceInfo() {
void StatsCollector::ExtractVideoInfo(
PeerConnectionInterface::StatsOutputLevel level) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
if (!pc_->video_channel())
if (!pc_->session()->video_channel())
return;
cricket::VideoMediaInfo video_info;
if (!pc_->video_channel()->GetStats(&video_info)) {
if (!pc_->session()->video_channel()->GetStats(&video_info)) {
LOG(LS_ERROR) << "Failed to get video channel stats.";
return;
}
@ -897,10 +898,10 @@ void StatsCollector::ExtractVideoInfo(
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
StatsReport::Id transport_id(GetTransportIdFromProxy(
proxy_to_transport_, pc_->video_channel()->content_name()));
proxy_to_transport_, pc_->session()->video_channel()->content_name()));
if (!transport_id.get()) {
LOG(LS_ERROR) << "Failed to get transport name for proxy "
<< pc_->video_channel()->content_name();
<< pc_->session()->video_channel()->content_name();
return;
}
ExtractStatsFromList(video_info.receivers, transport_id, this,
@ -910,7 +911,7 @@ void StatsCollector::ExtractVideoInfo(
}
void StatsCollector::ExtractSenderInfo() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
for (const auto& sender : pc_->GetSenders()) {
// TODO(nisse): SSRC == 0 currently means none. Delete check when
@ -943,7 +944,7 @@ void StatsCollector::ExtractSenderInfo() {
}
void StatsCollector::ExtractDataInfo() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;
@ -966,14 +967,14 @@ void StatsCollector::ExtractDataInfo() {
StatsReport* StatsCollector::GetReport(const StatsReport::StatsType& type,
const std::string& id,
StatsReport::Direction direction) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(type == StatsReport::kStatsReportTypeSsrc ||
type == StatsReport::kStatsReportTypeRemoteSsrc);
return reports_.Find(StatsReport::NewIdWithDirection(type, id, direction));
}
void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
// Loop through the existing local audio tracks.
for (const auto& it : local_audio_tracks_) {
AudioTrackInterface* track = it.first;
@ -1001,7 +1002,7 @@ void StatsCollector::UpdateStatsFromExistingLocalAudioTracks() {
void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
StatsReport* report) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
RTC_DCHECK(track != NULL);
// Don't overwrite report values if they're not available.
@ -1032,16 +1033,16 @@ void StatsCollector::UpdateReportFromAudioTrack(AudioTrackInterface* track,
bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
std::string* track_id,
StatsReport::Direction direction) {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
if (direction == StatsReport::kSend) {
if (!pc_->GetLocalTrackIdBySsrc(ssrc, track_id)) {
if (!pc_->session()->GetLocalTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a sending track";
return false;
}
} else {
RTC_DCHECK(direction == StatsReport::kReceive);
if (!pc_->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
if (!pc_->session()->GetRemoteTrackIdBySsrc(ssrc, track_id)) {
LOG(LS_WARNING) << "The SSRC " << ssrc
<< " is not associated with a receiving track";
return false;
@ -1052,7 +1053,7 @@ bool StatsCollector::GetTrackIdBySsrc(uint32_t ssrc,
}
void StatsCollector::UpdateTrackReports() {
RTC_DCHECK(pc_->signaling_thread()->IsCurrent());
RTC_DCHECK(pc_->session()->signaling_thread()->IsCurrent());
rtc::Thread::ScopedDisallowBlockingCalls no_blocking_calls;

View File

@ -573,12 +573,12 @@ class StatsCollectorTest : public testing::Test {
network_thread_)),
session_(channel_manager_.get(), cricket::MediaConfig()) {
pc_.set_session_for_testing(&session_);
// By default, we ignore session GetStats calls.
EXPECT_CALL(session_, GetStats(_)).WillRepeatedly(ReturnNull());
// Add default returns for mock classes.
EXPECT_CALL(session_, video_channel()).WillRepeatedly(ReturnNull());
EXPECT_CALL(session_, voice_channel()).WillRepeatedly(ReturnNull());
EXPECT_CALL(pc_, session()).WillRepeatedly(Return(&session_));
EXPECT_CALL(pc_, sctp_data_channels())
.WillRepeatedly(ReturnRef(data_channels_));
EXPECT_CALL(pc_, GetSenders()).WillRepeatedly(Return(

View File

@ -47,6 +47,7 @@ class MockPeerConnection
rtc::scoped_refptr<StreamCollectionInterface>());
MOCK_METHOD0(remote_streams,
rtc::scoped_refptr<StreamCollectionInterface>());
MOCK_METHOD0(session, WebRtcSession*());
MOCK_CONST_METHOD0(GetSenders,
std::vector<rtc::scoped_refptr<RtpSenderInterface>>());
MOCK_CONST_METHOD0(GetReceivers,