2013-05-16 12:08:03 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2013-08-05 16:22:53 +00:00
|
|
|
#include <string.h>
|
|
|
|
|
|
2016-06-09 17:21:19 +02:00
|
|
|
#include <algorithm>
|
2013-05-16 12:08:03 +00:00
|
|
|
#include <map>
|
2016-03-12 06:10:44 -08:00
|
|
|
#include <memory>
|
2013-05-16 12:08:03 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
2015-09-25 13:58:30 +02:00
|
|
|
#include "webrtc/audio/audio_receive_stream.h"
|
2015-10-16 14:35:07 -07:00
|
|
|
#include "webrtc/audio/audio_send_stream.h"
|
2015-11-06 15:34:49 -08:00
|
|
|
#include "webrtc/audio/audio_state.h"
|
|
|
|
|
#include "webrtc/audio/scoped_voe_interface.h"
|
2015-03-23 13:12:24 +00:00
|
|
|
#include "webrtc/base/checks.h"
|
2016-04-26 08:14:39 -07:00
|
|
|
#include "webrtc/base/constructormagic.h"
|
2015-12-04 16:13:05 +01:00
|
|
|
#include "webrtc/base/logging.h"
|
2014-09-24 06:05:00 +00:00
|
|
|
#include "webrtc/base/thread_annotations.h"
|
2015-10-19 03:39:20 -07:00
|
|
|
#include "webrtc/base/thread_checker.h"
|
2015-10-20 23:00:48 -07:00
|
|
|
#include "webrtc/base/trace_event.h"
|
2013-10-28 16:32:01 +00:00
|
|
|
#include "webrtc/call.h"
|
2015-11-12 21:02:42 -08:00
|
|
|
#include "webrtc/call/bitrate_allocator.h"
|
2015-09-25 13:58:30 +02:00
|
|
|
#include "webrtc/call/rtc_event_log.h"
|
2013-12-05 12:11:47 +00:00
|
|
|
#include "webrtc/config.h"
|
2015-11-12 21:02:42 -08:00
|
|
|
#include "webrtc/modules/bitrate_controller/include/bitrate_controller.h"
|
2016-02-23 13:30:42 +01:00
|
|
|
#include "webrtc/modules/congestion_controller/include/congestion_controller.h"
|
2015-11-16 11:12:24 +01:00
|
|
|
#include "webrtc/modules/pacing/paced_sender.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/rtp_rtcp/include/rtp_header_parser.h"
|
2015-01-28 12:37:36 +00:00
|
|
|
#include "webrtc/modules/rtp_rtcp/source/byte_io.h"
|
2015-11-04 08:31:52 +01:00
|
|
|
#include "webrtc/modules/utility/include/process_thread.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/cpu_info.h"
|
|
|
|
|
#include "webrtc/system_wrappers/include/critical_section_wrapper.h"
|
2015-11-11 10:13:02 -08:00
|
|
|
#include "webrtc/system_wrappers/include/metrics.h"
|
2015-10-28 18:17:40 +01:00
|
|
|
#include "webrtc/system_wrappers/include/rw_lock_wrapper.h"
|
|
|
|
|
#include "webrtc/system_wrappers/include/trace.h"
|
2015-12-09 12:13:30 +01:00
|
|
|
#include "webrtc/video/call_stats.h"
|
2016-05-02 23:44:01 -07:00
|
|
|
#include "webrtc/video/send_delay_stats.h"
|
2013-10-28 16:32:01 +00:00
|
|
|
#include "webrtc/video/video_receive_stream.h"
|
|
|
|
|
#include "webrtc/video/video_send_stream.h"
|
2016-02-08 14:31:30 +01:00
|
|
|
#include "webrtc/video/vie_remb.h"
|
2015-09-09 00:09:43 -07:00
|
|
|
#include "webrtc/voice_engine/include/voe_codec.h"
|
2013-05-16 12:08:03 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
2014-09-17 09:02:25 +00:00
|
|
|
|
2014-10-14 11:52:10 +00:00
|
|
|
const int Call::Config::kDefaultStartBitrateBps = 300000;
|
|
|
|
|
|
2013-10-28 16:32:01 +00:00
|
|
|
namespace internal {
|
2014-01-31 10:05:07 +00:00
|
|
|
|
2016-05-11 06:01:13 -07:00
|
|
|
class Call : public webrtc::Call,
|
|
|
|
|
public PacketReceiver,
|
2016-06-15 00:47:53 -07:00
|
|
|
public CongestionController::Observer,
|
|
|
|
|
public BitrateAllocator::LimitObserver {
|
2013-10-28 16:32:01 +00:00
|
|
|
public:
|
2015-05-08 13:54:38 +02:00
|
|
|
explicit Call(const Call::Config& config);
|
2013-10-28 16:32:01 +00:00
|
|
|
virtual ~Call();
|
|
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
PacketReceiver* Receiver() override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
webrtc::AudioSendStream* CreateAudioSendStream(
|
|
|
|
|
const webrtc::AudioSendStream::Config& config) override;
|
|
|
|
|
void DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) override;
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
webrtc::AudioReceiveStream* CreateAudioReceiveStream(
|
|
|
|
|
const webrtc::AudioReceiveStream::Config& config) override;
|
|
|
|
|
void DestroyAudioReceiveStream(
|
|
|
|
|
webrtc::AudioReceiveStream* receive_stream) override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
webrtc::VideoSendStream* CreateVideoSendStream(
|
|
|
|
|
const webrtc::VideoSendStream::Config& config,
|
|
|
|
|
const VideoEncoderConfig& encoder_config) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
void DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
webrtc::VideoReceiveStream* CreateVideoReceiveStream(
|
2016-06-10 17:58:01 +02:00
|
|
|
webrtc::VideoReceiveStream::Config configuration) override;
|
2015-03-04 12:58:35 +00:00
|
|
|
void DestroyVideoReceiveStream(
|
|
|
|
|
webrtc::VideoReceiveStream* receive_stream) override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
Stats GetStats() const override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-09-08 05:36:15 -07:00
|
|
|
DeliveryStatus DeliverPacket(MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketTime& packet_time) override;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-03-04 12:58:35 +00:00
|
|
|
void SetBitrateConfig(
|
|
|
|
|
const webrtc::Call::Config::BitrateConfig& bitrate_config) override;
|
2016-03-22 15:32:27 -07:00
|
|
|
|
|
|
|
|
void SignalChannelNetworkState(MediaType media, NetworkState state) override;
|
2014-09-03 16:17:12 +00:00
|
|
|
|
2016-04-19 15:41:36 -07:00
|
|
|
void OnNetworkRouteChanged(const std::string& transport_name,
|
|
|
|
|
const rtc::NetworkRoute& network_route) override;
|
|
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
void OnSentPacket(const rtc::SentPacket& sent_packet) override;
|
|
|
|
|
|
2015-11-12 21:02:42 -08:00
|
|
|
// Implements BitrateObserver.
|
|
|
|
|
void OnNetworkChanged(uint32_t bitrate_bps, uint8_t fraction_loss,
|
|
|
|
|
int64_t rtt_ms) override;
|
|
|
|
|
|
2016-06-15 00:47:53 -07:00
|
|
|
// Implements BitrateAllocator::LimitObserver.
|
|
|
|
|
void OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
|
|
|
|
|
uint32_t max_padding_bitrate_bps) override;
|
|
|
|
|
|
2013-10-28 16:32:01 +00:00
|
|
|
private:
|
2015-04-29 15:24:01 +02:00
|
|
|
DeliveryStatus DeliverRtcp(MediaType media_type, const uint8_t* packet,
|
|
|
|
|
size_t length);
|
2015-09-08 05:36:15 -07:00
|
|
|
DeliveryStatus DeliverRtp(MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketTime& packet_time);
|
2015-07-15 08:02:58 -07:00
|
|
|
void ConfigureSync(const std::string& sync_group)
|
|
|
|
|
EXCLUSIVE_LOCKS_REQUIRED(receive_crit_);
|
|
|
|
|
|
2015-11-06 15:34:49 -08:00
|
|
|
VoiceEngine* voice_engine() {
|
|
|
|
|
internal::AudioState* audio_state =
|
|
|
|
|
static_cast<internal::AudioState*>(config_.audio_state.get());
|
|
|
|
|
if (audio_state)
|
|
|
|
|
return audio_state->voice_engine();
|
|
|
|
|
else
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-26 15:36:48 +01:00
|
|
|
void UpdateSendHistograms() EXCLUSIVE_LOCKS_REQUIRED(&bitrate_crit_);
|
2015-11-17 06:24:56 -08:00
|
|
|
void UpdateReceiveHistograms();
|
2016-03-22 15:32:27 -07:00
|
|
|
void UpdateAggregateNetworkState();
|
2015-11-11 10:13:02 -08:00
|
|
|
|
2015-12-09 11:20:58 +01:00
|
|
|
Clock* const clock_;
|
2015-11-11 10:13:02 -08:00
|
|
|
|
2015-05-08 13:54:38 +02:00
|
|
|
const int num_cpu_cores_;
|
2016-03-12 06:10:44 -08:00
|
|
|
const std::unique_ptr<ProcessThread> module_process_thread_;
|
|
|
|
|
const std::unique_ptr<ProcessThread> pacer_thread_;
|
|
|
|
|
const std::unique_ptr<CallStats> call_stats_;
|
|
|
|
|
const std::unique_ptr<BitrateAllocator> bitrate_allocator_;
|
2013-10-28 16:32:01 +00:00
|
|
|
Call::Config config_;
|
2015-10-19 03:39:20 -07:00
|
|
|
rtc::ThreadChecker configuration_thread_checker_;
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2016-03-22 15:32:27 -07:00
|
|
|
NetworkState audio_network_state_;
|
|
|
|
|
NetworkState video_network_state_;
|
2014-09-03 16:17:12 +00:00
|
|
|
|
2016-03-12 06:10:44 -08:00
|
|
|
std::unique_ptr<RWLockWrapper> receive_crit_;
|
2015-10-16 14:35:07 -07:00
|
|
|
// Audio and Video receive streams are owned by the client that creates them.
|
2015-04-29 15:24:01 +02:00
|
|
|
std::map<uint32_t, AudioReceiveStream*> audio_receive_ssrcs_
|
|
|
|
|
GUARDED_BY(receive_crit_);
|
|
|
|
|
std::map<uint32_t, VideoReceiveStream*> video_receive_ssrcs_
|
|
|
|
|
GUARDED_BY(receive_crit_);
|
|
|
|
|
std::set<VideoReceiveStream*> video_receive_streams_
|
2014-09-03 16:17:12 +00:00
|
|
|
GUARDED_BY(receive_crit_);
|
2015-07-15 08:02:58 -07:00
|
|
|
std::map<std::string, AudioReceiveStream*> sync_stream_mapping_
|
|
|
|
|
GUARDED_BY(receive_crit_);
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2016-03-12 06:10:44 -08:00
|
|
|
std::unique_ptr<RWLockWrapper> send_crit_;
|
2015-10-16 14:35:07 -07:00
|
|
|
// Audio and Video send streams are owned by the client that creates them.
|
|
|
|
|
std::map<uint32_t, AudioSendStream*> audio_send_ssrcs_ GUARDED_BY(send_crit_);
|
2015-04-29 15:24:01 +02:00
|
|
|
std::map<uint32_t, VideoSendStream*> video_send_ssrcs_ GUARDED_BY(send_crit_);
|
|
|
|
|
std::set<VideoSendStream*> video_send_streams_ GUARDED_BY(send_crit_);
|
2013-10-28 16:32:01 +00:00
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
VideoSendStream::RtpStateMap suspended_video_send_ssrcs_;
|
2014-07-07 13:06:48 +00:00
|
|
|
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
RtcEventLog* event_log_ = nullptr;
|
2015-09-09 00:09:43 -07:00
|
|
|
|
2015-11-17 06:24:56 -08:00
|
|
|
// The following members are only accessed (exclusively) from one thread and
|
|
|
|
|
// from the destructor, and therefore doesn't need any explicit
|
|
|
|
|
// synchronization.
|
2015-11-26 15:36:48 +01:00
|
|
|
int64_t received_video_bytes_;
|
|
|
|
|
int64_t received_audio_bytes_;
|
|
|
|
|
int64_t received_rtcp_bytes_;
|
2015-11-11 10:13:02 -08:00
|
|
|
int64_t first_rtp_packet_received_ms_;
|
2015-11-26 15:36:48 +01:00
|
|
|
int64_t last_rtp_packet_received_ms_;
|
|
|
|
|
int64_t first_packet_sent_ms_;
|
2015-11-11 10:13:02 -08:00
|
|
|
|
2015-11-17 06:24:56 -08:00
|
|
|
// TODO(holmer): Remove this lock once BitrateController no longer calls
|
|
|
|
|
// OnNetworkChanged from multiple threads.
|
|
|
|
|
rtc::CriticalSection bitrate_crit_;
|
2015-11-26 15:36:48 +01:00
|
|
|
int64_t estimated_send_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
|
|
|
|
|
int64_t pacer_bitrate_sum_kbits_ GUARDED_BY(&bitrate_crit_);
|
2016-06-15 00:47:53 -07:00
|
|
|
uint32_t min_allocated_send_bitrate_bps_ GUARDED_BY(&bitrate_crit_);
|
2015-11-26 15:36:48 +01:00
|
|
|
int64_t num_bitrate_updates_ GUARDED_BY(&bitrate_crit_);
|
2015-11-17 06:24:56 -08:00
|
|
|
|
2016-04-19 15:41:36 -07:00
|
|
|
std::map<std::string, rtc::NetworkRoute> network_routes_;
|
|
|
|
|
|
2016-02-08 14:31:30 +01:00
|
|
|
VieRemb remb_;
|
2016-03-12 06:10:44 -08:00
|
|
|
const std::unique_ptr<CongestionController> congestion_controller_;
|
2016-05-02 23:44:01 -07:00
|
|
|
const std::unique_ptr<SendDelayStats> video_send_delay_stats_;
|
2015-11-12 21:02:42 -08:00
|
|
|
|
2015-09-16 05:37:44 -07:00
|
|
|
RTC_DISALLOW_COPY_AND_ASSIGN(Call);
|
2013-10-28 16:32:01 +00:00
|
|
|
};
|
2013-12-05 12:11:47 +00:00
|
|
|
} // namespace internal
|
2013-08-14 13:52:52 +00:00
|
|
|
|
2013-12-04 10:24:26 +00:00
|
|
|
Call* Call::Create(const Call::Config& config) {
|
2015-05-08 13:54:38 +02:00
|
|
|
return new internal::Call(config);
|
2013-08-14 13:52:52 +00:00
|
|
|
}
|
|
|
|
|
|
2013-05-16 12:08:03 +00:00
|
|
|
namespace internal {
|
|
|
|
|
|
2015-05-08 13:54:38 +02:00
|
|
|
Call::Call(const Call::Config& config)
|
2015-11-11 10:13:02 -08:00
|
|
|
: clock_(Clock::GetRealTimeClock()),
|
|
|
|
|
num_cpu_cores_(CpuInfo::DetectNumberOfCores()),
|
2016-04-26 08:18:04 -07:00
|
|
|
module_process_thread_(ProcessThread::Create("ModuleProcessThread")),
|
|
|
|
|
pacer_thread_(ProcessThread::Create("PacerThread")),
|
2015-12-09 11:20:58 +01:00
|
|
|
call_stats_(new CallStats(clock_)),
|
2016-06-15 00:47:53 -07:00
|
|
|
bitrate_allocator_(new BitrateAllocator(this)),
|
2015-05-08 13:54:38 +02:00
|
|
|
config_(config),
|
2016-03-22 15:32:27 -07:00
|
|
|
audio_network_state_(kNetworkUp),
|
|
|
|
|
video_network_state_(kNetworkUp),
|
2014-09-03 16:17:12 +00:00
|
|
|
receive_crit_(RWLockWrapper::CreateRWLock()),
|
2015-11-11 10:13:02 -08:00
|
|
|
send_crit_(RWLockWrapper::CreateRWLock()),
|
2015-11-26 15:36:48 +01:00
|
|
|
received_video_bytes_(0),
|
|
|
|
|
received_audio_bytes_(0),
|
|
|
|
|
received_rtcp_bytes_(0),
|
2015-11-12 21:02:42 -08:00
|
|
|
first_rtp_packet_received_ms_(-1),
|
2015-11-26 15:36:48 +01:00
|
|
|
last_rtp_packet_received_ms_(-1),
|
|
|
|
|
first_packet_sent_ms_(-1),
|
|
|
|
|
estimated_send_bitrate_sum_kbits_(0),
|
|
|
|
|
pacer_bitrate_sum_kbits_(0),
|
2016-06-15 00:47:53 -07:00
|
|
|
min_allocated_send_bitrate_bps_(0),
|
2015-11-26 15:36:48 +01:00
|
|
|
num_bitrate_updates_(0),
|
2016-02-08 14:31:30 +01:00
|
|
|
remb_(clock_),
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
congestion_controller_(new CongestionController(clock_, this, &remb_)),
|
2016-05-02 23:44:01 -07:00
|
|
|
video_send_delay_stats_(new SendDelayStats(clock_)) {
|
2015-11-12 08:24:41 -08:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_GE(config.bitrate_config.min_bitrate_bps, 0);
|
|
|
|
|
RTC_DCHECK_GE(config.bitrate_config.start_bitrate_bps,
|
|
|
|
|
config.bitrate_config.min_bitrate_bps);
|
2015-03-26 11:11:06 +01:00
|
|
|
if (config.bitrate_config.max_bitrate_bps != -1) {
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_GE(config.bitrate_config.max_bitrate_bps,
|
|
|
|
|
config.bitrate_config.start_bitrate_bps);
|
2014-11-25 14:03:34 +00:00
|
|
|
}
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
if (config.audio_state.get()) {
|
|
|
|
|
ScopedVoEInterface<VoECodec> voe_codec(voice_engine());
|
|
|
|
|
event_log_ = voe_codec->GetEventLog();
|
|
|
|
|
}
|
2014-11-25 14:03:34 +00:00
|
|
|
|
2015-05-08 13:54:38 +02:00
|
|
|
Trace::CreateTrace();
|
2016-02-17 15:52:17 +01:00
|
|
|
call_stats_->RegisterStatsObserver(congestion_controller_.get());
|
2015-05-08 13:54:38 +02:00
|
|
|
|
2015-10-21 15:52:16 +02:00
|
|
|
congestion_controller_->SetBweBitrates(
|
|
|
|
|
config_.bitrate_config.min_bitrate_bps,
|
|
|
|
|
config_.bitrate_config.start_bitrate_bps,
|
|
|
|
|
config_.bitrate_config.max_bitrate_bps);
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
congestion_controller_->GetBitrateController()->SetEventLog(event_log_);
|
2016-02-24 16:02:55 +01:00
|
|
|
|
|
|
|
|
module_process_thread_->Start();
|
|
|
|
|
module_process_thread_->RegisterModule(call_stats_.get());
|
|
|
|
|
module_process_thread_->RegisterModule(congestion_controller_.get());
|
|
|
|
|
pacer_thread_->RegisterModule(congestion_controller_->pacer());
|
|
|
|
|
pacer_thread_->RegisterModule(
|
|
|
|
|
congestion_controller_->GetRemoteBitrateEstimator(true));
|
|
|
|
|
pacer_thread_->Start();
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2013-09-09 15:04:25 +00:00
|
|
|
Call::~Call() {
|
2016-02-08 14:31:30 +01:00
|
|
|
RTC_DCHECK(!remb_.InUse());
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-11-17 06:24:56 -08:00
|
|
|
UpdateSendHistograms();
|
|
|
|
|
UpdateReceiveHistograms();
|
2015-10-16 14:35:07 -07:00
|
|
|
RTC_CHECK(audio_send_ssrcs_.empty());
|
|
|
|
|
RTC_CHECK(video_send_ssrcs_.empty());
|
|
|
|
|
RTC_CHECK(video_send_streams_.empty());
|
|
|
|
|
RTC_CHECK(audio_receive_ssrcs_.empty());
|
|
|
|
|
RTC_CHECK(video_receive_ssrcs_.empty());
|
|
|
|
|
RTC_CHECK(video_receive_streams_.empty());
|
2015-02-12 10:48:23 +00:00
|
|
|
|
2016-02-24 16:02:55 +01:00
|
|
|
pacer_thread_->Stop();
|
|
|
|
|
pacer_thread_->DeRegisterModule(congestion_controller_->pacer());
|
|
|
|
|
pacer_thread_->DeRegisterModule(
|
|
|
|
|
congestion_controller_->GetRemoteBitrateEstimator(true));
|
2016-02-17 15:52:17 +01:00
|
|
|
module_process_thread_->DeRegisterModule(congestion_controller_.get());
|
2015-10-21 13:24:28 +02:00
|
|
|
module_process_thread_->DeRegisterModule(call_stats_.get());
|
2015-05-08 13:54:38 +02:00
|
|
|
module_process_thread_->Stop();
|
2016-02-24 16:02:55 +01:00
|
|
|
call_stats_->DeregisterStatsObserver(congestion_controller_.get());
|
2015-05-08 13:54:38 +02:00
|
|
|
Trace::ReturnTrace();
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-17 06:24:56 -08:00
|
|
|
void Call::UpdateSendHistograms() {
|
2015-11-26 15:36:48 +01:00
|
|
|
if (num_bitrate_updates_ == 0 || first_packet_sent_ms_ == -1)
|
2015-11-17 06:24:56 -08:00
|
|
|
return;
|
|
|
|
|
int64_t elapsed_sec =
|
|
|
|
|
(clock_->TimeInMilliseconds() - first_packet_sent_ms_) / 1000;
|
|
|
|
|
if (elapsed_sec < metrics::kMinRunTimeInSeconds)
|
|
|
|
|
return;
|
2015-11-26 15:36:48 +01:00
|
|
|
int send_bitrate_kbps =
|
|
|
|
|
estimated_send_bitrate_sum_kbits_ / num_bitrate_updates_;
|
|
|
|
|
int pacer_bitrate_kbps = pacer_bitrate_sum_kbits_ / num_bitrate_updates_;
|
2015-11-17 06:24:56 -08:00
|
|
|
if (send_bitrate_kbps > 0) {
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.EstimatedSendBitrateInKbps",
|
|
|
|
|
send_bitrate_kbps);
|
2015-11-17 06:24:56 -08:00
|
|
|
}
|
|
|
|
|
if (pacer_bitrate_kbps > 0) {
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.PacerBitrateInKbps",
|
|
|
|
|
pacer_bitrate_kbps);
|
2015-11-17 06:24:56 -08:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Call::UpdateReceiveHistograms() {
|
2015-11-11 10:13:02 -08:00
|
|
|
if (first_rtp_packet_received_ms_ == -1)
|
|
|
|
|
return;
|
|
|
|
|
int64_t elapsed_sec =
|
2015-11-26 15:36:48 +01:00
|
|
|
(last_rtp_packet_received_ms_ - first_rtp_packet_received_ms_) / 1000;
|
2015-11-11 10:13:02 -08:00
|
|
|
if (elapsed_sec < metrics::kMinRunTimeInSeconds)
|
|
|
|
|
return;
|
2015-11-26 15:36:48 +01:00
|
|
|
int audio_bitrate_kbps = received_audio_bytes_ * 8 / elapsed_sec / 1000;
|
|
|
|
|
int video_bitrate_kbps = received_video_bytes_ * 8 / elapsed_sec / 1000;
|
|
|
|
|
int rtcp_bitrate_bps = received_rtcp_bytes_ * 8 / elapsed_sec;
|
2015-11-11 10:13:02 -08:00
|
|
|
if (video_bitrate_kbps > 0) {
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.VideoBitrateReceivedInKbps",
|
|
|
|
|
video_bitrate_kbps);
|
2015-11-11 10:13:02 -08:00
|
|
|
}
|
|
|
|
|
if (audio_bitrate_kbps > 0) {
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.AudioBitrateReceivedInKbps",
|
|
|
|
|
audio_bitrate_kbps);
|
2015-11-11 10:13:02 -08:00
|
|
|
}
|
|
|
|
|
if (rtcp_bitrate_bps > 0) {
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000("WebRTC.Call.RtcpBitrateReceivedInBps",
|
|
|
|
|
rtcp_bitrate_bps);
|
2015-11-11 10:13:02 -08:00
|
|
|
}
|
2016-03-29 02:15:06 -07:00
|
|
|
RTC_LOGGED_HISTOGRAM_COUNTS_100000(
|
2015-11-11 10:13:02 -08:00
|
|
|
"WebRTC.Call.BitrateReceivedInKbps",
|
|
|
|
|
audio_bitrate_kbps + video_bitrate_kbps + rtcp_bitrate_bps / 1000);
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-19 03:39:20 -07:00
|
|
|
PacketReceiver* Call::Receiver() {
|
|
|
|
|
// TODO(solenberg): Some test cases in EndToEndTest use this from a different
|
|
|
|
|
// thread. Re-enable once that is fixed.
|
|
|
|
|
// RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2015-06-08 13:04:56 +02:00
|
|
|
webrtc::AudioSendStream* Call::CreateAudioSendStream(
|
|
|
|
|
const webrtc::AudioSendStream::Config& config) {
|
2015-10-16 14:35:07 -07:00
|
|
|
TRACE_EVENT0("webrtc", "Call::CreateAudioSendStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-12-07 10:26:18 +01:00
|
|
|
AudioSendStream* send_stream = new AudioSendStream(
|
|
|
|
|
config, config_.audio_state, congestion_controller_.get());
|
2015-10-16 14:35:07 -07:00
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*send_crit_);
|
|
|
|
|
RTC_DCHECK(audio_send_ssrcs_.find(config.rtp.ssrc) ==
|
|
|
|
|
audio_send_ssrcs_.end());
|
|
|
|
|
audio_send_ssrcs_[config.rtp.ssrc] = send_stream;
|
|
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
send_stream->SignalNetworkState(audio_network_state_);
|
|
|
|
|
UpdateAggregateNetworkState();
|
2015-10-16 14:35:07 -07:00
|
|
|
return send_stream;
|
2015-06-08 13:04:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Call::DestroyAudioSendStream(webrtc::AudioSendStream* send_stream) {
|
2015-10-16 14:35:07 -07:00
|
|
|
TRACE_EVENT0("webrtc", "Call::DestroyAudioSendStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-10-16 14:35:07 -07:00
|
|
|
RTC_DCHECK(send_stream != nullptr);
|
|
|
|
|
|
|
|
|
|
send_stream->Stop();
|
|
|
|
|
|
|
|
|
|
webrtc::internal::AudioSendStream* audio_send_stream =
|
|
|
|
|
static_cast<webrtc::internal::AudioSendStream*>(send_stream);
|
|
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*send_crit_);
|
|
|
|
|
size_t num_deleted = audio_send_ssrcs_.erase(
|
|
|
|
|
audio_send_stream->config().rtp.ssrc);
|
|
|
|
|
RTC_DCHECK(num_deleted == 1);
|
|
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
UpdateAggregateNetworkState();
|
2015-10-16 14:35:07 -07:00
|
|
|
delete audio_send_stream;
|
2015-06-08 13:04:56 +02:00
|
|
|
}
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
webrtc::AudioReceiveStream* Call::CreateAudioReceiveStream(
|
|
|
|
|
const webrtc::AudioReceiveStream::Config& config) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "Call::CreateAudioReceiveStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
AudioReceiveStream* receive_stream = new AudioReceiveStream(
|
|
|
|
|
congestion_controller_.get(), config, config_.audio_state);
|
2015-04-29 15:24:01 +02:00
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*receive_crit_);
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(audio_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
|
|
|
|
|
audio_receive_ssrcs_.end());
|
2015-04-29 15:24:01 +02:00
|
|
|
audio_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
|
2015-07-15 08:02:58 -07:00
|
|
|
ConfigureSync(config.sync_group);
|
2015-04-29 15:24:01 +02:00
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
receive_stream->SignalNetworkState(audio_network_state_);
|
|
|
|
|
UpdateAggregateNetworkState();
|
2015-04-29 15:24:01 +02:00
|
|
|
return receive_stream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Call::DestroyAudioReceiveStream(
|
|
|
|
|
webrtc::AudioReceiveStream* receive_stream) {
|
|
|
|
|
TRACE_EVENT0("webrtc", "Call::DestroyAudioReceiveStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(receive_stream != nullptr);
|
2015-10-16 14:35:07 -07:00
|
|
|
webrtc::internal::AudioReceiveStream* audio_receive_stream =
|
|
|
|
|
static_cast<webrtc::internal::AudioReceiveStream*>(receive_stream);
|
2015-04-29 15:24:01 +02:00
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*receive_crit_);
|
|
|
|
|
size_t num_deleted = audio_receive_ssrcs_.erase(
|
|
|
|
|
audio_receive_stream->config().rtp.remote_ssrc);
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(num_deleted == 1);
|
2015-07-15 08:02:58 -07:00
|
|
|
const std::string& sync_group = audio_receive_stream->config().sync_group;
|
|
|
|
|
const auto it = sync_stream_mapping_.find(sync_group);
|
|
|
|
|
if (it != sync_stream_mapping_.end() &&
|
|
|
|
|
it->second == audio_receive_stream) {
|
|
|
|
|
sync_stream_mapping_.erase(it);
|
|
|
|
|
ConfigureSync(sync_group);
|
|
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
UpdateAggregateNetworkState();
|
2015-04-29 15:24:01 +02:00
|
|
|
delete audio_receive_stream;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
webrtc::VideoSendStream* Call::CreateVideoSendStream(
|
|
|
|
|
const webrtc::VideoSendStream::Config& config,
|
2014-09-19 12:30:25 +00:00
|
|
|
const VideoEncoderConfig& encoder_config) {
|
2015-01-29 12:33:07 +00:00
|
|
|
TRACE_EVENT0("webrtc", "Call::CreateVideoSendStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2013-06-10 13:48:26 +00:00
|
|
|
|
2016-05-02 23:44:01 -07:00
|
|
|
video_send_delay_stats_->AddSsrcs(config);
|
2014-06-16 08:57:39 +00:00
|
|
|
// TODO(mflodman): Base the start bitrate on a current bandwidth estimate, if
|
|
|
|
|
// the call has already started.
|
2015-10-21 15:52:16 +02:00
|
|
|
VideoSendStream* send_stream = new VideoSendStream(
|
|
|
|
|
num_cpu_cores_, module_process_thread_.get(), call_stats_.get(),
|
2016-05-02 23:44:01 -07:00
|
|
|
congestion_controller_.get(), bitrate_allocator_.get(),
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
video_send_delay_stats_.get(), &remb_, event_log_, config, encoder_config,
|
|
|
|
|
suspended_video_send_ssrcs_);
|
2016-03-22 15:32:27 -07:00
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*send_crit_);
|
|
|
|
|
for (uint32_t ssrc : config.rtp.ssrcs) {
|
|
|
|
|
RTC_DCHECK(video_send_ssrcs_.find(ssrc) == video_send_ssrcs_.end());
|
|
|
|
|
video_send_ssrcs_[ssrc] = send_stream;
|
|
|
|
|
}
|
|
|
|
|
video_send_streams_.insert(send_stream);
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
send_stream->SignalNetworkState(video_network_state_);
|
|
|
|
|
UpdateAggregateNetworkState();
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
if (event_log_)
|
|
|
|
|
event_log_->LogVideoSendStreamConfig(config);
|
2013-05-16 12:08:03 +00:00
|
|
|
return send_stream;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-21 13:49:43 +00:00
|
|
|
void Call::DestroyVideoSendStream(webrtc::VideoSendStream* send_stream) {
|
2015-01-29 12:33:07 +00:00
|
|
|
TRACE_EVENT0("webrtc", "Call::DestroyVideoSendStream");
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(send_stream != nullptr);
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2013-09-05 12:38:54 +00:00
|
|
|
|
2014-07-07 13:06:48 +00:00
|
|
|
send_stream->Stop();
|
|
|
|
|
|
2015-03-23 13:12:24 +00:00
|
|
|
VideoSendStream* send_stream_impl = nullptr;
|
2013-09-05 12:38:54 +00:00
|
|
|
{
|
2014-09-03 16:17:12 +00:00
|
|
|
WriteLockScoped write_lock(*send_crit_);
|
2015-04-29 15:24:01 +02:00
|
|
|
auto it = video_send_ssrcs_.begin();
|
|
|
|
|
while (it != video_send_ssrcs_.end()) {
|
2013-09-05 12:38:54 +00:00
|
|
|
if (it->second == static_cast<VideoSendStream*>(send_stream)) {
|
|
|
|
|
send_stream_impl = it->second;
|
2015-04-29 15:24:01 +02:00
|
|
|
video_send_ssrcs_.erase(it++);
|
2014-07-07 13:06:48 +00:00
|
|
|
} else {
|
|
|
|
|
++it;
|
2013-09-05 12:38:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
video_send_streams_.erase(send_stream_impl);
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_CHECK(send_stream_impl != nullptr);
|
2013-09-05 12:38:54 +00:00
|
|
|
|
2014-07-07 13:06:48 +00:00
|
|
|
VideoSendStream::RtpStateMap rtp_state = send_stream_impl->GetRtpStates();
|
|
|
|
|
|
|
|
|
|
for (VideoSendStream::RtpStateMap::iterator it = rtp_state.begin();
|
|
|
|
|
it != rtp_state.end();
|
|
|
|
|
++it) {
|
2015-04-29 15:24:01 +02:00
|
|
|
suspended_video_send_ssrcs_[it->first] = it->second;
|
2014-07-07 13:06:48 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:32:27 -07:00
|
|
|
UpdateAggregateNetworkState();
|
2013-09-05 12:38:54 +00:00
|
|
|
delete send_stream_impl;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
webrtc::VideoReceiveStream* Call::CreateVideoReceiveStream(
|
2016-06-10 17:58:01 +02:00
|
|
|
webrtc::VideoReceiveStream::Config configuration) {
|
2015-01-29 12:33:07 +00:00
|
|
|
TRACE_EVENT0("webrtc", "Call::CreateVideoReceiveStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-04-24 15:16:03 +02:00
|
|
|
VideoReceiveStream* receive_stream = new VideoReceiveStream(
|
2016-06-10 17:58:01 +02:00
|
|
|
num_cpu_cores_, congestion_controller_.get(), std::move(configuration),
|
|
|
|
|
voice_engine(), module_process_thread_.get(), call_stats_.get(), &remb_);
|
|
|
|
|
|
|
|
|
|
const webrtc::VideoReceiveStream::Config& config = receive_stream->config();
|
2016-03-22 15:32:27 -07:00
|
|
|
{
|
|
|
|
|
WriteLockScoped write_lock(*receive_crit_);
|
|
|
|
|
RTC_DCHECK(video_receive_ssrcs_.find(config.rtp.remote_ssrc) ==
|
|
|
|
|
video_receive_ssrcs_.end());
|
|
|
|
|
video_receive_ssrcs_[config.rtp.remote_ssrc] = receive_stream;
|
|
|
|
|
// TODO(pbos): Configure different RTX payloads per receive payload.
|
|
|
|
|
VideoReceiveStream::Config::Rtp::RtxMap::const_iterator it =
|
|
|
|
|
config.rtp.rtx.begin();
|
|
|
|
|
if (it != config.rtp.rtx.end())
|
|
|
|
|
video_receive_ssrcs_[it->second.ssrc] = receive_stream;
|
|
|
|
|
video_receive_streams_.insert(receive_stream);
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
|
2016-03-22 15:32:27 -07:00
|
|
|
ConfigureSync(config.sync_group);
|
|
|
|
|
}
|
|
|
|
|
receive_stream->SignalNetworkState(video_network_state_);
|
|
|
|
|
UpdateAggregateNetworkState();
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
if (event_log_)
|
|
|
|
|
event_log_->LogVideoReceiveStreamConfig(config);
|
2013-05-16 12:08:03 +00:00
|
|
|
return receive_stream;
|
|
|
|
|
}
|
|
|
|
|
|
2013-11-21 13:49:43 +00:00
|
|
|
void Call::DestroyVideoReceiveStream(
|
|
|
|
|
webrtc::VideoReceiveStream* receive_stream) {
|
2015-01-29 12:33:07 +00:00
|
|
|
TRACE_EVENT0("webrtc", "Call::DestroyVideoReceiveStream");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(receive_stream != nullptr);
|
2015-03-23 13:12:24 +00:00
|
|
|
VideoReceiveStream* receive_stream_impl = nullptr;
|
2013-09-05 12:38:54 +00:00
|
|
|
{
|
2014-09-03 16:17:12 +00:00
|
|
|
WriteLockScoped write_lock(*receive_crit_);
|
2014-01-24 09:30:53 +00:00
|
|
|
// Remove all ssrcs pointing to a receive stream. As RTX retransmits on a
|
|
|
|
|
// separate SSRC there can be either one or two.
|
2015-04-29 15:24:01 +02:00
|
|
|
auto it = video_receive_ssrcs_.begin();
|
|
|
|
|
while (it != video_receive_ssrcs_.end()) {
|
2013-09-05 12:38:54 +00:00
|
|
|
if (it->second == static_cast<VideoReceiveStream*>(receive_stream)) {
|
2015-03-23 13:12:24 +00:00
|
|
|
if (receive_stream_impl != nullptr)
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK(receive_stream_impl == it->second);
|
2013-09-05 12:38:54 +00:00
|
|
|
receive_stream_impl = it->second;
|
2015-04-29 15:24:01 +02:00
|
|
|
video_receive_ssrcs_.erase(it++);
|
2014-01-24 09:30:53 +00:00
|
|
|
} else {
|
|
|
|
|
++it;
|
2013-09-05 12:38:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
video_receive_streams_.erase(receive_stream_impl);
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_CHECK(receive_stream_impl != nullptr);
|
2015-07-15 08:02:58 -07:00
|
|
|
ConfigureSync(receive_stream_impl->config().sync_group);
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
2016-03-22 15:32:27 -07:00
|
|
|
UpdateAggregateNetworkState();
|
2013-09-05 12:38:54 +00:00
|
|
|
delete receive_stream_impl;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-05 14:05:29 +00:00
|
|
|
Call::Stats Call::GetStats() const {
|
2015-10-19 03:39:20 -07:00
|
|
|
// TODO(solenberg): Some test cases in EndToEndTest use this from a different
|
|
|
|
|
// thread. Re-enable once that is fixed.
|
|
|
|
|
// RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2014-11-05 14:05:29 +00:00
|
|
|
Stats stats;
|
2015-05-08 13:54:38 +02:00
|
|
|
// Fetch available send/receive bitrates.
|
2014-11-05 14:05:29 +00:00
|
|
|
uint32_t send_bandwidth = 0;
|
2015-10-21 15:52:16 +02:00
|
|
|
congestion_controller_->GetBitrateController()->AvailableBandwidth(
|
|
|
|
|
&send_bandwidth);
|
2015-05-08 13:54:38 +02:00
|
|
|
std::vector<unsigned int> ssrcs;
|
2014-11-05 14:05:29 +00:00
|
|
|
uint32_t recv_bandwidth = 0;
|
2015-10-21 15:52:16 +02:00
|
|
|
congestion_controller_->GetRemoteBitrateEstimator(false)->LatestEstimate(
|
2015-10-18 22:08:19 -07:00
|
|
|
&ssrcs, &recv_bandwidth);
|
2015-05-08 13:54:38 +02:00
|
|
|
stats.send_bandwidth_bps = send_bandwidth;
|
2014-11-05 14:05:29 +00:00
|
|
|
stats.recv_bandwidth_bps = recv_bandwidth;
|
2015-10-21 15:52:16 +02:00
|
|
|
stats.pacer_delay_ms = congestion_controller_->GetPacerQueuingDelayMs();
|
2016-02-19 09:03:26 -08:00
|
|
|
stats.rtt_ms = call_stats_->rtcp_rtt_stats()->LastProcessedRtt();
|
2014-11-05 14:05:29 +00:00
|
|
|
return stats;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2014-11-25 14:03:34 +00:00
|
|
|
void Call::SetBitrateConfig(
|
|
|
|
|
const webrtc::Call::Config::BitrateConfig& bitrate_config) {
|
2015-01-29 12:33:07 +00:00
|
|
|
TRACE_EVENT0("webrtc", "Call::SetBitrateConfig");
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_GE(bitrate_config.min_bitrate_bps, 0);
|
2015-03-23 13:12:24 +00:00
|
|
|
if (bitrate_config.max_bitrate_bps != -1)
|
2015-09-17 00:24:34 -07:00
|
|
|
RTC_DCHECK_GT(bitrate_config.max_bitrate_bps, 0);
|
2015-03-26 11:11:06 +01:00
|
|
|
if (config_.bitrate_config.min_bitrate_bps ==
|
2014-11-25 14:03:34 +00:00
|
|
|
bitrate_config.min_bitrate_bps &&
|
|
|
|
|
(bitrate_config.start_bitrate_bps <= 0 ||
|
2015-03-26 11:11:06 +01:00
|
|
|
config_.bitrate_config.start_bitrate_bps ==
|
2014-11-25 14:03:34 +00:00
|
|
|
bitrate_config.start_bitrate_bps) &&
|
2015-03-26 11:11:06 +01:00
|
|
|
config_.bitrate_config.max_bitrate_bps ==
|
2014-11-25 14:03:34 +00:00
|
|
|
bitrate_config.max_bitrate_bps) {
|
|
|
|
|
// Nothing new to set, early abort to avoid encoder reconfigurations.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2015-03-26 11:11:06 +01:00
|
|
|
config_.bitrate_config = bitrate_config;
|
2015-10-21 15:52:16 +02:00
|
|
|
congestion_controller_->SetBweBitrates(bitrate_config.min_bitrate_bps,
|
|
|
|
|
bitrate_config.start_bitrate_bps,
|
|
|
|
|
bitrate_config.max_bitrate_bps);
|
2014-11-25 14:03:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:32:27 -07:00
|
|
|
void Call::SignalChannelNetworkState(MediaType media, NetworkState state) {
|
2015-10-19 03:39:20 -07:00
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
2016-03-22 15:32:27 -07:00
|
|
|
switch (media) {
|
|
|
|
|
case MediaType::AUDIO:
|
|
|
|
|
audio_network_state_ = state;
|
|
|
|
|
break;
|
|
|
|
|
case MediaType::VIDEO:
|
|
|
|
|
video_network_state_ = state;
|
|
|
|
|
break;
|
|
|
|
|
case MediaType::ANY:
|
|
|
|
|
case MediaType::DATA:
|
|
|
|
|
RTC_NOTREACHED();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
UpdateAggregateNetworkState();
|
2014-09-03 16:17:12 +00:00
|
|
|
{
|
2016-03-22 15:32:27 -07:00
|
|
|
ReadLockScoped read_lock(*send_crit_);
|
2015-10-16 14:35:07 -07:00
|
|
|
for (auto& kv : audio_send_ssrcs_) {
|
2016-03-22 15:32:27 -07:00
|
|
|
kv.second->SignalNetworkState(audio_network_state_);
|
2015-10-16 14:35:07 -07:00
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
for (auto& kv : video_send_ssrcs_) {
|
2016-03-22 15:32:27 -07:00
|
|
|
kv.second->SignalNetworkState(video_network_state_);
|
2014-09-03 16:17:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
{
|
2016-03-22 15:32:27 -07:00
|
|
|
ReadLockScoped read_lock(*receive_crit_);
|
|
|
|
|
for (auto& kv : audio_receive_ssrcs_) {
|
|
|
|
|
kv.second->SignalNetworkState(audio_network_state_);
|
|
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
for (auto& kv : video_receive_ssrcs_) {
|
2016-03-22 15:32:27 -07:00
|
|
|
kv.second->SignalNetworkState(video_network_state_);
|
2014-09-03 16:17:12 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-19 15:41:36 -07:00
|
|
|
// TODO(honghaiz): Add tests for this method.
|
|
|
|
|
void Call::OnNetworkRouteChanged(const std::string& transport_name,
|
|
|
|
|
const rtc::NetworkRoute& network_route) {
|
|
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
|
|
|
|
// Check if the network route is connected.
|
|
|
|
|
if (!network_route.connected) {
|
|
|
|
|
LOG(LS_INFO) << "Transport " << transport_name << " is disconnected";
|
|
|
|
|
// TODO(honghaiz): Perhaps handle this in SignalChannelNetworkState and
|
|
|
|
|
// consider merging these two methods.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Check whether the network route has changed on each transport.
|
|
|
|
|
auto result =
|
|
|
|
|
network_routes_.insert(std::make_pair(transport_name, network_route));
|
|
|
|
|
auto kv = result.first;
|
|
|
|
|
bool inserted = result.second;
|
|
|
|
|
if (inserted) {
|
|
|
|
|
// No need to reset BWE if this is the first time the network connects.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
if (kv->second != network_route) {
|
|
|
|
|
kv->second = network_route;
|
|
|
|
|
LOG(LS_INFO) << "Network route changed on transport " << transport_name
|
|
|
|
|
<< ": new local network id " << network_route.local_network_id
|
2016-06-24 11:03:55 -07:00
|
|
|
<< " new remote network id " << network_route.remote_network_id
|
|
|
|
|
<< " Reset bitrate to "
|
|
|
|
|
<< config_.bitrate_config.start_bitrate_bps << "bps";
|
|
|
|
|
congestion_controller_->ResetBweAndBitrates(
|
|
|
|
|
config_.bitrate_config.start_bitrate_bps,
|
|
|
|
|
config_.bitrate_config.min_bitrate_bps,
|
|
|
|
|
config_.bitrate_config.max_bitrate_bps);
|
2016-04-19 15:41:36 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-22 15:32:27 -07:00
|
|
|
void Call::UpdateAggregateNetworkState() {
|
|
|
|
|
RTC_DCHECK(configuration_thread_checker_.CalledOnValidThread());
|
|
|
|
|
|
|
|
|
|
bool have_audio = false;
|
|
|
|
|
bool have_video = false;
|
|
|
|
|
{
|
|
|
|
|
ReadLockScoped read_lock(*send_crit_);
|
|
|
|
|
if (audio_send_ssrcs_.size() > 0)
|
|
|
|
|
have_audio = true;
|
|
|
|
|
if (video_send_ssrcs_.size() > 0)
|
|
|
|
|
have_video = true;
|
|
|
|
|
}
|
|
|
|
|
{
|
|
|
|
|
ReadLockScoped read_lock(*receive_crit_);
|
|
|
|
|
if (audio_receive_ssrcs_.size() > 0)
|
|
|
|
|
have_audio = true;
|
|
|
|
|
if (video_receive_ssrcs_.size() > 0)
|
|
|
|
|
have_video = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
NetworkState aggregate_state = kNetworkDown;
|
|
|
|
|
if ((have_video && video_network_state_ == kNetworkUp) ||
|
|
|
|
|
(have_audio && audio_network_state_ == kNetworkUp)) {
|
|
|
|
|
aggregate_state = kNetworkUp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
LOG(LS_INFO) << "UpdateAggregateNetworkState: aggregate_state="
|
|
|
|
|
<< (aggregate_state == kNetworkUp ? "up" : "down");
|
|
|
|
|
|
|
|
|
|
congestion_controller_->SignalNetworkState(aggregate_state);
|
|
|
|
|
}
|
|
|
|
|
|
2015-10-15 07:26:07 -07:00
|
|
|
void Call::OnSentPacket(const rtc::SentPacket& sent_packet) {
|
2015-11-17 06:24:56 -08:00
|
|
|
if (first_packet_sent_ms_ == -1)
|
|
|
|
|
first_packet_sent_ms_ = clock_->TimeInMilliseconds();
|
2016-05-02 23:44:01 -07:00
|
|
|
video_send_delay_stats_->OnSentPacket(sent_packet.packet_id,
|
|
|
|
|
clock_->TimeInMilliseconds());
|
2015-10-21 15:52:16 +02:00
|
|
|
congestion_controller_->OnSentPacket(sent_packet);
|
2015-10-15 07:26:07 -07:00
|
|
|
}
|
|
|
|
|
|
2015-11-12 21:02:42 -08:00
|
|
|
void Call::OnNetworkChanged(uint32_t target_bitrate_bps, uint8_t fraction_loss,
|
|
|
|
|
int64_t rtt_ms) {
|
2016-06-15 00:47:53 -07:00
|
|
|
bitrate_allocator_->OnNetworkChanged(target_bitrate_bps, fraction_loss,
|
|
|
|
|
rtt_ms);
|
2015-11-12 21:02:42 -08:00
|
|
|
|
2015-11-17 06:24:56 -08:00
|
|
|
{
|
|
|
|
|
rtc::CritScope lock(&bitrate_crit_);
|
2015-11-26 15:36:48 +01:00
|
|
|
// We only update these stats if we have send streams, and assume that
|
|
|
|
|
// OnNetworkChanged is called roughly with a fixed frequency.
|
|
|
|
|
estimated_send_bitrate_sum_kbits_ += target_bitrate_bps / 1000;
|
2016-06-15 00:47:53 -07:00
|
|
|
// Pacer bitrate might be higher than bitrate estimate if enforcing min
|
|
|
|
|
// bitrate.
|
|
|
|
|
uint32_t pacer_bitrate_bps =
|
|
|
|
|
std::max(target_bitrate_bps, min_allocated_send_bitrate_bps_);
|
2015-11-26 15:36:48 +01:00
|
|
|
pacer_bitrate_sum_kbits_ += pacer_bitrate_bps / 1000;
|
|
|
|
|
++num_bitrate_updates_;
|
2015-11-17 06:24:56 -08:00
|
|
|
}
|
2016-06-15 00:47:53 -07:00
|
|
|
}
|
2016-06-09 17:21:19 +02:00
|
|
|
|
2016-06-15 00:47:53 -07:00
|
|
|
void Call::OnAllocationLimitsChanged(uint32_t min_send_bitrate_bps,
|
|
|
|
|
uint32_t max_padding_bitrate_bps) {
|
|
|
|
|
congestion_controller_->SetAllocatedSendBitrateLimits(
|
|
|
|
|
min_send_bitrate_bps, max_padding_bitrate_bps);
|
|
|
|
|
rtc::CritScope lock(&bitrate_crit_);
|
|
|
|
|
min_allocated_send_bitrate_bps_ = min_send_bitrate_bps;
|
2015-11-12 21:02:42 -08:00
|
|
|
}
|
|
|
|
|
|
2015-07-15 08:02:58 -07:00
|
|
|
void Call::ConfigureSync(const std::string& sync_group) {
|
|
|
|
|
// Set sync only if there was no previous one.
|
2015-11-06 15:34:49 -08:00
|
|
|
if (voice_engine() == nullptr || sync_group.empty())
|
2015-07-15 08:02:58 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
AudioReceiveStream* sync_audio_stream = nullptr;
|
|
|
|
|
// Find existing audio stream.
|
|
|
|
|
const auto it = sync_stream_mapping_.find(sync_group);
|
|
|
|
|
if (it != sync_stream_mapping_.end()) {
|
|
|
|
|
sync_audio_stream = it->second;
|
|
|
|
|
} else {
|
|
|
|
|
// No configured audio stream, see if we can find one.
|
|
|
|
|
for (const auto& kv : audio_receive_ssrcs_) {
|
|
|
|
|
if (kv.second->config().sync_group == sync_group) {
|
|
|
|
|
if (sync_audio_stream != nullptr) {
|
|
|
|
|
LOG(LS_WARNING) << "Attempting to sync more than one audio stream "
|
|
|
|
|
"within the same sync group. This is not "
|
|
|
|
|
"supported in the current implementation.";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
sync_audio_stream = kv.second;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (sync_audio_stream)
|
|
|
|
|
sync_stream_mapping_[sync_group] = sync_audio_stream;
|
|
|
|
|
size_t num_synced_streams = 0;
|
|
|
|
|
for (VideoReceiveStream* video_stream : video_receive_streams_) {
|
|
|
|
|
if (video_stream->config().sync_group != sync_group)
|
|
|
|
|
continue;
|
|
|
|
|
++num_synced_streams;
|
|
|
|
|
if (num_synced_streams > 1) {
|
|
|
|
|
// TODO(pbos): Support synchronizing more than one A/V pair.
|
|
|
|
|
// https://code.google.com/p/webrtc/issues/detail?id=4762
|
|
|
|
|
LOG(LS_WARNING) << "Attempting to sync more than one audio/video pair "
|
|
|
|
|
"within the same sync group. This is not supported in "
|
|
|
|
|
"the current implementation.";
|
|
|
|
|
}
|
|
|
|
|
// Only sync the first A/V pair within this sync group.
|
|
|
|
|
if (sync_audio_stream != nullptr && num_synced_streams == 1) {
|
2015-11-06 15:34:49 -08:00
|
|
|
video_stream->SetSyncChannel(voice_engine(),
|
2015-07-15 08:02:58 -07:00
|
|
|
sync_audio_stream->config().voe_channel_id);
|
|
|
|
|
} else {
|
2015-11-06 15:34:49 -08:00
|
|
|
video_stream->SetSyncChannel(voice_engine(), -1);
|
2015-07-15 08:02:58 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
PacketReceiver::DeliveryStatus Call::DeliverRtcp(MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length) {
|
2015-12-07 23:17:15 +01:00
|
|
|
TRACE_EVENT0("webrtc", "Call::DeliverRtcp");
|
2016-04-29 00:57:13 -07:00
|
|
|
// TODO(pbos): Make sure it's a valid packet.
|
2014-05-14 13:57:12 +00:00
|
|
|
// Return DELIVERY_UNKNOWN_SSRC if it can be determined that
|
|
|
|
|
// there's no receiver of the packet.
|
2015-11-26 15:36:48 +01:00
|
|
|
received_rtcp_bytes_ += length;
|
2013-05-16 12:08:03 +00:00
|
|
|
bool rtcp_delivered = false;
|
2015-04-29 15:24:01 +02:00
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
|
2014-09-03 16:17:12 +00:00
|
|
|
ReadLockScoped read_lock(*receive_crit_);
|
2015-04-29 15:24:01 +02:00
|
|
|
for (VideoReceiveStream* stream : video_receive_streams_) {
|
2016-04-29 00:57:13 -07:00
|
|
|
if (stream->DeliverRtcp(packet, length))
|
|
|
|
|
rtcp_delivered = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
|
|
|
|
|
ReadLockScoped read_lock(*receive_crit_);
|
|
|
|
|
for (auto& kv : audio_receive_ssrcs_) {
|
|
|
|
|
if (kv.second->DeliverRtcp(packet, length))
|
2013-08-05 12:49:22 +00:00
|
|
|
rtcp_delivered = true;
|
2013-08-05 12:01:36 +00:00
|
|
|
}
|
|
|
|
|
}
|
2015-04-29 15:24:01 +02:00
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
|
2014-09-03 16:17:12 +00:00
|
|
|
ReadLockScoped read_lock(*send_crit_);
|
2015-04-29 15:24:01 +02:00
|
|
|
for (VideoSendStream* stream : video_send_streams_) {
|
2016-04-29 00:57:13 -07:00
|
|
|
if (stream->DeliverRtcp(packet, length))
|
2013-08-05 12:49:22 +00:00
|
|
|
rtcp_delivered = true;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
}
|
2016-04-29 00:57:13 -07:00
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
|
|
|
|
|
ReadLockScoped read_lock(*send_crit_);
|
|
|
|
|
for (auto& kv : audio_send_ssrcs_) {
|
|
|
|
|
if (kv.second->DeliverRtcp(packet, length))
|
|
|
|
|
rtcp_delivered = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (event_log_ && rtcp_delivered)
|
|
|
|
|
event_log_->LogRtcpPacket(kIncomingPacket, media_type, packet, length);
|
|
|
|
|
|
2014-05-14 13:57:12 +00:00
|
|
|
return rtcp_delivered ? DELIVERY_OK : DELIVERY_PACKET_ERROR;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-04-29 15:24:01 +02:00
|
|
|
PacketReceiver::DeliveryStatus Call::DeliverRtp(MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
2015-09-08 05:36:15 -07:00
|
|
|
size_t length,
|
|
|
|
|
const PacketTime& packet_time) {
|
2015-12-07 23:17:15 +01:00
|
|
|
TRACE_EVENT0("webrtc", "Call::DeliverRtp");
|
2014-07-08 07:38:12 +00:00
|
|
|
// Minimum RTP header size.
|
|
|
|
|
if (length < 12)
|
|
|
|
|
return DELIVERY_PACKET_ERROR;
|
|
|
|
|
|
2015-11-26 15:36:48 +01:00
|
|
|
last_rtp_packet_received_ms_ = clock_->TimeInMilliseconds();
|
2015-11-11 10:13:02 -08:00
|
|
|
if (first_rtp_packet_received_ms_ == -1)
|
2015-11-26 15:36:48 +01:00
|
|
|
first_rtp_packet_received_ms_ = last_rtp_packet_received_ms_;
|
2014-07-08 07:38:12 +00:00
|
|
|
|
2015-11-11 10:13:02 -08:00
|
|
|
uint32_t ssrc = ByteReader<uint32_t>::ReadBigEndian(&packet[8]);
|
2014-09-03 16:17:12 +00:00
|
|
|
ReadLockScoped read_lock(*receive_crit_);
|
2015-04-29 15:24:01 +02:00
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::AUDIO) {
|
|
|
|
|
auto it = audio_receive_ssrcs_.find(ssrc);
|
|
|
|
|
if (it != audio_receive_ssrcs_.end()) {
|
2015-11-26 15:36:48 +01:00
|
|
|
received_audio_bytes_ += length;
|
2015-09-09 00:09:43 -07:00
|
|
|
auto status = it->second->DeliverRtp(packet, length, packet_time)
|
|
|
|
|
? DELIVERY_OK
|
|
|
|
|
: DELIVERY_PACKET_ERROR;
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
if (status == DELIVERY_OK && event_log_)
|
2016-01-21 05:42:04 -08:00
|
|
|
event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
|
2015-09-09 00:09:43 -07:00
|
|
|
return status;
|
2015-04-29 15:24:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (media_type == MediaType::ANY || media_type == MediaType::VIDEO) {
|
|
|
|
|
auto it = video_receive_ssrcs_.find(ssrc);
|
|
|
|
|
if (it != video_receive_ssrcs_.end()) {
|
2015-11-26 15:36:48 +01:00
|
|
|
received_video_bytes_ += length;
|
2015-09-09 00:09:43 -07:00
|
|
|
auto status = it->second->DeliverRtp(packet, length, packet_time)
|
|
|
|
|
? DELIVERY_OK
|
|
|
|
|
: DELIVERY_PACKET_ERROR;
|
Revert of Move RtcEventLog object from inside VoiceEngine to Call. (patchset #16 id:420001 of https://codereview.webrtc.org/1748403002/ )
Reason for revert:
Reverting all CLs related to moving the eventlog, as they break Chromium tests.
Original issue's description:
> Move RtcEventLog object from inside VoiceEngine to Call.
>
> In addition to moving the logging object itself, this also moves the interface from PeerConnectionFactory to PeerConnection, which makes more sense for this functionality. An API parameter to set an upper limit to the size of the logfile is introduced.
> The old interface on PeerConnectionFactory is not removed in this CL, because it is called from Chrome, it will be removed after Chrome is updated to use the PeerConnection interface.
>
> BUG=webrtc:4741,webrtc:5603,chromium:609749
> R=solenberg@webrtc.org, stefan@webrtc.org, terelius@webrtc.org, tommi@webrtc.org
>
> Committed: https://crrev.com/1895526c6130e3d0e9b154f95079b8eda7567016
> Cr-Commit-Position: refs/heads/master@{#13321}
TBR=solenberg@webrtc.org,tommi@webrtc.org,stefan@webrtc.org,terelius@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=webrtc:4741,webrtc:5603,chromium:609749
Review-Url: https://codereview.webrtc.org/2111813002
Cr-Commit-Position: refs/heads/master@{#13340}
2016-06-30 00:59:43 -07:00
|
|
|
if (status == DELIVERY_OK && event_log_)
|
2016-01-21 05:42:04 -08:00
|
|
|
event_log_->LogRtpHeader(kIncomingPacket, media_type, packet, length);
|
2015-09-09 00:09:43 -07:00
|
|
|
return status;
|
2015-04-29 15:24:01 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return DELIVERY_UNKNOWN_SSRC;
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
2015-09-08 05:36:15 -07:00
|
|
|
PacketReceiver::DeliveryStatus Call::DeliverPacket(
|
|
|
|
|
MediaType media_type,
|
|
|
|
|
const uint8_t* packet,
|
|
|
|
|
size_t length,
|
|
|
|
|
const PacketTime& packet_time) {
|
2015-10-19 03:39:20 -07:00
|
|
|
// TODO(solenberg): Tests call this function on a network thread, libjingle
|
|
|
|
|
// calls on the worker thread. We should move towards always using a network
|
|
|
|
|
// thread. Then this check can be enabled.
|
|
|
|
|
// RTC_DCHECK(!configuration_thread_checker_.CalledOnValidThread());
|
2014-07-08 12:10:51 +00:00
|
|
|
if (RtpHeaderParser::IsRtcp(packet, length))
|
2015-04-29 15:24:01 +02:00
|
|
|
return DeliverRtcp(media_type, packet, length);
|
2013-05-16 12:08:03 +00:00
|
|
|
|
2015-09-08 05:36:15 -07:00
|
|
|
return DeliverRtp(media_type, packet, length, packet_time);
|
2013-05-16 12:08:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace internal
|
|
|
|
|
} // namespace webrtc
|