Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(540)

Side by Side Diff: webrtc/video/vie_channel.cc

Issue 1912133002: Move receive RtpRtcp ownership from ViEChannel to ViEReceiver. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Added RtpRtcp member to ViEChannel. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include "webrtc/video/vie_channel.h" 11 #include "webrtc/video/vie_channel.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <map> 14 #include <map>
15 #include <vector> 15 #include <vector>
16 16
17 #include "webrtc/base/checks.h" 17 #include "webrtc/base/checks.h"
18 #include "webrtc/base/logging.h" 18 #include "webrtc/base/logging.h"
19 #include "webrtc/base/platform_thread.h" 19 #include "webrtc/base/platform_thread.h"
20 #include "webrtc/common_video/include/frame_callback.h" 20 #include "webrtc/common_video/include/frame_callback.h"
21 #include "webrtc/common_video/include/incoming_video_stream.h" 21 #include "webrtc/common_video/include/incoming_video_stream.h"
22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 22 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
23 #include "webrtc/modules/pacing/paced_sender.h"
24 #include "webrtc/modules/pacing/packet_router.h"
25 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h" 23 #include "webrtc/modules/rtp_rtcp/include/rtp_receiver.h"
26 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h" 24 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp.h"
27 #include "webrtc/modules/utility/include/process_thread.h" 25 #include "webrtc/modules/utility/include/process_thread.h"
28 #include "webrtc/modules/video_coding/include/video_coding.h" 26 #include "webrtc/modules/video_coding/include/video_coding.h"
29 #include "webrtc/modules/video_processing/include/video_processing.h" 27 #include "webrtc/modules/video_processing/include/video_processing.h"
30 #include "webrtc/modules/video_render/video_render_defines.h" 28 #include "webrtc/modules/video_render/video_render_defines.h"
31 #include "webrtc/system_wrappers/include/metrics.h" 29 #include "webrtc/system_wrappers/include/metrics.h"
32 #include "webrtc/video/call_stats.h" 30 #include "webrtc/video/call_stats.h"
33 #include "webrtc/video/payload_router.h" 31 #include "webrtc/video/payload_router.h"
34 #include "webrtc/video/receive_statistics_proxy.h" 32 #include "webrtc/video/receive_statistics_proxy.h"
35 33
36 namespace webrtc { 34 namespace webrtc {
37 35
38 static const int kMaxPacketAgeToNack = 450; 36 static const int kMaxPacketAgeToNack = 450;
39 static const int kMaxNackListSize = 250; 37 static const int kMaxNackListSize = 250;
40 38
41 namespace {
42
43 std::unique_ptr<RtpRtcp> CreateRtpRtcpModule(
44 ReceiveStatistics* receive_statistics,
45 Transport* outgoing_transport,
46 RtcpRttStats* rtt_stats,
47 RtcpPacketTypeCounterObserver* rtcp_packet_type_counter_observer,
48 RemoteBitrateEstimator* remote_bitrate_estimator,
49 RtpPacketSender* paced_sender,
50 TransportSequenceNumberAllocator* transport_sequence_number_allocator) {
51 RtpRtcp::Configuration configuration;
52 configuration.audio = false;
53 configuration.receiver_only = true;
54 configuration.receive_statistics = receive_statistics;
55 configuration.outgoing_transport = outgoing_transport;
56 configuration.intra_frame_callback = nullptr;
57 configuration.rtt_stats = rtt_stats;
58 configuration.rtcp_packet_type_counter_observer =
59 rtcp_packet_type_counter_observer;
60 configuration.paced_sender = paced_sender;
61 configuration.transport_sequence_number_allocator =
62 transport_sequence_number_allocator;
63 configuration.send_bitrate_observer = nullptr;
64 configuration.send_frame_count_observer = nullptr;
65 configuration.send_side_delay_observer = nullptr;
66 configuration.bandwidth_callback = nullptr;
67 configuration.transport_feedback_callback = nullptr;
68
69 std::unique_ptr<RtpRtcp> rtp_rtcp(RtpRtcp::CreateRtpRtcp(configuration));
70 rtp_rtcp->SetSendingStatus(false);
71 rtp_rtcp->SetSendingMediaStatus(false);
72 rtp_rtcp->SetRTCPStatus(RtcpMode::kCompound);
73
74 return rtp_rtcp;
75 }
76
77 } // namespace
78
79 // Helper class receiving statistics callbacks. 39 // Helper class receiving statistics callbacks.
80 class ChannelStatsObserver : public CallStatsObserver { 40 class ChannelStatsObserver : public CallStatsObserver {
81 public: 41 public:
82 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {} 42 explicit ChannelStatsObserver(ViEChannel* owner) : owner_(owner) {}
83 virtual ~ChannelStatsObserver() {} 43 virtual ~ChannelStatsObserver() {}
84 44
85 // Implements StatsObserver. 45 // Implements StatsObserver.
86 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) { 46 virtual void OnRttUpdate(int64_t avg_rtt_ms, int64_t max_rtt_ms) {
87 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms); 47 owner_->OnRttUpdate(avg_rtt_ms, max_rtt_ms);
88 } 48 }
89 49
90 private: 50 private:
91 ViEChannel* const owner_; 51 ViEChannel* const owner_;
92 }; 52 };
93 53
94 ViEChannel::ViEChannel(Transport* transport, 54 ViEChannel::ViEChannel(Transport* transport,
95 ProcessThread* module_process_thread, 55 ProcessThread* module_process_thread,
96 VideoCodingModule* vcm, 56 VideoCodingModule* vcm,
97 RemoteBitrateEstimator* remote_bitrate_estimator, 57 RemoteBitrateEstimator* remote_bitrate_estimator,
98 RtcpRttStats* rtt_stats, 58 RtcpRttStats* rtt_stats,
99 PacedSender* paced_sender, 59 PacedSender* paced_sender,
100 PacketRouter* packet_router) 60 PacketRouter* packet_router)
101 : module_process_thread_(module_process_thread), 61 : module_process_thread_(module_process_thread),
102 vcm_(vcm), 62 vcm_(vcm),
103 vie_receiver_(vcm_, remote_bitrate_estimator, this), 63 vie_receiver_(vcm_, remote_bitrate_estimator, this, transport, rtt_stats,
64 paced_sender, packet_router),
65 rtp_rtcp_(vie_receiver_.rtp_rtcp()),
104 stats_observer_(new ChannelStatsObserver(this)), 66 stats_observer_(new ChannelStatsObserver(this)),
105 receive_stats_callback_(nullptr), 67 receive_stats_callback_(nullptr),
106 incoming_video_stream_(nullptr), 68 incoming_video_stream_(nullptr),
107 rtt_stats_(rtt_stats),
108 paced_sender_(paced_sender),
109 packet_router_(packet_router),
110 max_nack_reordering_threshold_(kMaxPacketAgeToNack), 69 max_nack_reordering_threshold_(kMaxPacketAgeToNack),
111 pre_render_callback_(nullptr), 70 pre_render_callback_(nullptr),
112 last_rtt_ms_(0), 71 last_rtt_ms_(0) {
113 rtp_rtcp_(CreateRtpRtcpModule(vie_receiver_.GetReceiveStatistics(),
114 transport,
115 rtt_stats_,
116 &rtcp_packet_type_counter_observer_,
117 remote_bitrate_estimator,
118 paced_sender_,
119 packet_router_)) {
120 vie_receiver_.Init(rtp_rtcp_.get());
121 RTC_DCHECK(vcm_); 72 RTC_DCHECK(vcm_);
122 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0); 73 vcm_->SetNackSettings(kMaxNackListSize, max_nack_reordering_threshold_, 0);
123 } 74 }
124 75
125 int32_t ViEChannel::Init() { 76 int32_t ViEChannel::Init() {
126 static const int kDefaultRenderDelayMs = 10; 77 static const int kDefaultRenderDelayMs = 10;
127 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics()); 78 module_process_thread_->RegisterModule(vie_receiver_.GetReceiveStatistics());
79 module_process_thread_->RegisterModule(rtp_rtcp_);
pbos-webrtc 2016/04/22 15:16:58 As a follow-up maybe both of these should be done
mflodman 2016/04/25 07:03:22 Or rather when creating this in VideoReceiveStream
128 80
129 // RTP/RTCP initialization.
130 module_process_thread_->RegisterModule(rtp_rtcp_.get());
131 packet_router_->AddRtpModule(rtp_rtcp_.get());
132
133 rtp_rtcp_->SetKeyFrameRequestMethod(kKeyFrameReqPliRtcp);
134 if (vcm_->RegisterReceiveCallback(this) != 0) { 81 if (vcm_->RegisterReceiveCallback(this) != 0) {
135 return -1; 82 return -1;
136 } 83 }
137 vcm_->RegisterFrameTypeCallback(this); 84 vcm_->RegisterFrameTypeCallback(this);
138 vcm_->RegisterReceiveStatisticsCallback(this); 85 vcm_->RegisterReceiveStatisticsCallback(this);
139 vcm_->RegisterDecoderTimingCallback(this); 86 vcm_->RegisterDecoderTimingCallback(this);
140 vcm_->SetRenderDelay(kDefaultRenderDelayMs); 87 vcm_->SetRenderDelay(kDefaultRenderDelayMs);
141 88
142 return 0; 89 return 0;
143 } 90 }
144 91
145 ViEChannel::~ViEChannel() { 92 ViEChannel::~ViEChannel() {
146 // Make sure we don't get more callbacks from the RTP module. 93 // Make sure we don't get more callbacks from the RTP module.
147 module_process_thread_->DeRegisterModule( 94 module_process_thread_->DeRegisterModule(
148 vie_receiver_.GetReceiveStatistics()); 95 vie_receiver_.GetReceiveStatistics());
149 96
150 packet_router_->RemoveRtpModule(rtp_rtcp_.get()); 97 module_process_thread_->DeRegisterModule(rtp_rtcp_);
151 module_process_thread_->DeRegisterModule(rtp_rtcp_.get());
152 } 98 }
153 99
154 void ViEChannel::SetProtectionMode(bool enable_nack, 100 void ViEChannel::SetProtectionMode(bool enable_nack,
155 bool enable_fec, 101 bool enable_fec,
156 int payload_type_red, 102 int payload_type_red,
157 int payload_type_fec) { 103 int payload_type_fec) {
158 // Validate payload types. If either RED or FEC payload types are set then 104 // Validate payload types. If either RED or FEC payload types are set then
159 // both should be. If FEC is enabled then they both have to be set. 105 // both should be. If FEC is enabled then they both have to be set.
160 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { 106 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) {
161 RTC_DCHECK_GE(payload_type_red, 0); 107 RTC_DCHECK_GE(payload_type_red, 0);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 } 162 }
217 163
218 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { 164 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const {
219 RTC_DCHECK(!rtp_rtcp_->Sending()); 165 RTC_DCHECK(!rtp_rtcp_->Sending());
220 RTC_DCHECK_EQ(ssrc, rtp_rtcp_->SSRC()); 166 RTC_DCHECK_EQ(ssrc, rtp_rtcp_->SSRC());
221 return rtp_rtcp_->GetRtpState(); 167 return rtp_rtcp_->GetRtpState();
222 } 168 }
223 169
224 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( 170 void ViEChannel::RegisterRtcpPacketTypeCounterObserver(
225 RtcpPacketTypeCounterObserver* observer) { 171 RtcpPacketTypeCounterObserver* observer) {
226 rtcp_packet_type_counter_observer_.Set(observer); 172 vie_receiver_.RegisterRtcpPacketTypeCounterObserver(observer);
227 }
228
229 RtpRtcp* ViEChannel::rtp_rtcp() const {
230 return rtp_rtcp_.get();
231 } 173 }
232 174
233 ViEReceiver* ViEChannel::vie_receiver() { 175 ViEReceiver* ViEChannel::vie_receiver() {
234 return &vie_receiver_; 176 return &vie_receiver_;
235 } 177 }
236 178
237 CallStatsObserver* ViEChannel::GetStatsObserver() { 179 CallStatsObserver* ViEChannel::GetStatsObserver() {
238 return stats_observer_.get(); 180 return stats_observer_.get();
239 } 181 }
240 182
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 rtc::CritScope lock(&crit_); 297 rtc::CritScope lock(&crit_);
356 receive_stats_callback_ = receive_statistics_proxy; 298 receive_stats_callback_ = receive_statistics_proxy;
357 } 299 }
358 300
359 void ViEChannel::SetIncomingVideoStream( 301 void ViEChannel::SetIncomingVideoStream(
360 IncomingVideoStream* incoming_video_stream) { 302 IncomingVideoStream* incoming_video_stream) {
361 rtc::CritScope lock(&crit_); 303 rtc::CritScope lock(&crit_);
362 incoming_video_stream_ = incoming_video_stream; 304 incoming_video_stream_ = incoming_video_stream;
363 } 305 }
364 } // namespace webrtc 306 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698