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

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

Issue 1419803002: Rename ChannelGroup to CongestionController and move to webrtc/call/. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase Created 5 years, 2 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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/video_send_stream.h" 11 #include "webrtc/video/video_send_stream.h"
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <sstream> 14 #include <sstream>
15 #include <string> 15 #include <string>
16 #include <vector> 16 #include <vector>
17 17
18 #include "webrtc/base/checks.h" 18 #include "webrtc/base/checks.h"
19 #include "webrtc/base/trace_event.h" 19 #include "webrtc/base/trace_event.h"
20 #include "webrtc/call/congestion_controller.h"
20 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h" 21 #include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
21 #include "webrtc/modules/pacing/include/packet_router.h" 22 #include "webrtc/modules/pacing/include/packet_router.h"
22 #include "webrtc/system_wrappers/interface/logging.h" 23 #include "webrtc/system_wrappers/interface/logging.h"
23 #include "webrtc/video/video_capture_input.h" 24 #include "webrtc/video/video_capture_input.h"
24 #include "webrtc/video_engine/call_stats.h" 25 #include "webrtc/video_engine/call_stats.h"
25 #include "webrtc/video_engine/encoder_state_feedback.h" 26 #include "webrtc/video_engine/encoder_state_feedback.h"
26 #include "webrtc/video_engine/payload_router.h" 27 #include "webrtc/video_engine/payload_router.h"
27 #include "webrtc/video_engine/vie_channel.h" 28 #include "webrtc/video_engine/vie_channel.h"
28 #include "webrtc/video_engine/vie_channel_group.h"
29 #include "webrtc/video_engine/vie_defines.h" 29 #include "webrtc/video_engine/vie_defines.h"
30 #include "webrtc/video_engine/vie_encoder.h" 30 #include "webrtc/video_engine/vie_encoder.h"
31 #include "webrtc/video_send_stream.h" 31 #include "webrtc/video_send_stream.h"
32 32
33 namespace webrtc { 33 namespace webrtc {
34 34
35 class BitrateAllocator; 35 class BitrateAllocator;
36 class PacedSender; 36 class PacedSender;
37 class RtcpIntraFrameObserver; 37 class RtcpIntraFrameObserver;
38 class TransportFeedbackObserver; 38 class TransportFeedbackObserver;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 : "off"); 106 : "off");
107 ss << '}'; 107 ss << '}';
108 return ss.str(); 108 return ss.str();
109 } 109 }
110 110
111 namespace internal { 111 namespace internal {
112 VideoSendStream::VideoSendStream( 112 VideoSendStream::VideoSendStream(
113 int num_cpu_cores, 113 int num_cpu_cores,
114 ProcessThread* module_process_thread, 114 ProcessThread* module_process_thread,
115 CallStats* call_stats, 115 CallStats* call_stats,
116 ChannelGroup* channel_group, 116 CongestionController* congestion_controller,
117 const VideoSendStream::Config& config, 117 const VideoSendStream::Config& config,
118 const VideoEncoderConfig& encoder_config, 118 const VideoEncoderConfig& encoder_config,
119 const std::map<uint32_t, RtpState>& suspended_ssrcs) 119 const std::map<uint32_t, RtpState>& suspended_ssrcs)
120 : transport_adapter_(config.send_transport), 120 : transport_adapter_(config.send_transport),
121 encoded_frame_proxy_(config.post_encode_callback), 121 encoded_frame_proxy_(config.post_encode_callback),
122 config_(config), 122 config_(config),
123 suspended_ssrcs_(suspended_ssrcs), 123 suspended_ssrcs_(suspended_ssrcs),
124 module_process_thread_(module_process_thread), 124 module_process_thread_(module_process_thread),
125 call_stats_(call_stats), 125 call_stats_(call_stats),
126 channel_group_(channel_group), 126 congestion_controller_(congestion_controller),
127 encoder_feedback_(new EncoderStateFeedback()), 127 encoder_feedback_(new EncoderStateFeedback()),
128 use_config_bitrate_(true), 128 use_config_bitrate_(true),
129 stats_proxy_(Clock::GetRealTimeClock(), config) { 129 stats_proxy_(Clock::GetRealTimeClock(), config) {
130 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString(); 130 LOG(LS_INFO) << "VideoSendStream: " << config_.ToString();
131 RTC_DCHECK(!config_.rtp.ssrcs.empty()); 131 RTC_DCHECK(!config_.rtp.ssrcs.empty());
132 132
133 // Set up Call-wide sequence numbers, if configured for this send stream. 133 // Set up Call-wide sequence numbers, if configured for this send stream.
134 TransportFeedbackObserver* transport_feedback_observer = nullptr; 134 TransportFeedbackObserver* transport_feedback_observer = nullptr;
135 for (const RtpExtension& extension : config.rtp.extensions) { 135 for (const RtpExtension& extension : config.rtp.extensions) {
136 if (extension.name == RtpExtension::kTransportSequenceNumber) { 136 if (extension.name == RtpExtension::kTransportSequenceNumber) {
137 transport_feedback_observer = 137 transport_feedback_observer =
138 channel_group_->GetTransportFeedbackObserver(); 138 congestion_controller_->GetTransportFeedbackObserver();
139 break; 139 break;
140 } 140 }
141 } 141 }
142 142
143 const std::vector<uint32_t>& ssrcs = config.rtp.ssrcs; 143 const std::vector<uint32_t>& ssrcs = config.rtp.ssrcs;
144 144
145 vie_encoder_.reset(new ViEEncoder( 145 vie_encoder_.reset(new ViEEncoder(
146 num_cpu_cores, module_process_thread_, &stats_proxy_, 146 num_cpu_cores, module_process_thread_, &stats_proxy_,
147 config.pre_encode_callback, channel_group_->pacer(), 147 config.pre_encode_callback, congestion_controller_->pacer(),
148 channel_group_->bitrate_allocator())); 148 congestion_controller_->bitrate_allocator()));
149 RTC_CHECK(vie_encoder_->Init()); 149 RTC_CHECK(vie_encoder_->Init());
150 150
151 vie_channel_.reset(new ViEChannel( 151 vie_channel_.reset(new ViEChannel(
152 num_cpu_cores, config.send_transport, module_process_thread_, 152 num_cpu_cores, config.send_transport, module_process_thread_,
153 encoder_feedback_->GetRtcpIntraFrameObserver(), 153 encoder_feedback_->GetRtcpIntraFrameObserver(),
154 channel_group_->GetBitrateController()->CreateRtcpBandwidthObserver(), 154 congestion_controller_->GetBitrateController()->
155 CreateRtcpBandwidthObserver(),
155 transport_feedback_observer, 156 transport_feedback_observer,
156 channel_group_->GetRemoteBitrateEstimator(false), 157 congestion_controller_->GetRemoteBitrateEstimator(false),
157 call_stats_->rtcp_rtt_stats(), channel_group_->pacer(), 158 call_stats_->rtcp_rtt_stats(), congestion_controller_->pacer(),
158 channel_group_->packet_router(), ssrcs.size(), true)); 159 congestion_controller_->packet_router(), ssrcs.size(), true));
159 RTC_CHECK(vie_channel_->Init() == 0); 160 RTC_CHECK(vie_channel_->Init() == 0);
160 161
161 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); 162 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver());
162 163
163 vie_encoder_->StartThreadsAndSetSharedMembers( 164 vie_encoder_->StartThreadsAndSetSharedMembers(
164 vie_channel_->send_payload_router(), 165 vie_channel_->send_payload_router(),
165 vie_channel_->vcm_protection_callback()); 166 vie_channel_->vcm_protection_callback());
166 167
167 std::vector<uint32_t> first_ssrc(1, ssrcs[0]); 168 std::vector<uint32_t> first_ssrc(1, ssrcs[0]);
168 vie_encoder_->SetSsrcs(first_ssrc); 169 vie_encoder_->SetSsrcs(first_ssrc);
(...skipping 10 matching lines...) Expand all
179 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id)); 180 RTC_CHECK_EQ(0, vie_channel_->SetSendAbsoluteSendTimeStatus(true, id));
180 } else if (extension == RtpExtension::kVideoRotation) { 181 } else if (extension == RtpExtension::kVideoRotation) {
181 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id)); 182 RTC_CHECK_EQ(0, vie_channel_->SetSendVideoRotationStatus(true, id));
182 } else if (extension == RtpExtension::kTransportSequenceNumber) { 183 } else if (extension == RtpExtension::kTransportSequenceNumber) {
183 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id)); 184 RTC_CHECK_EQ(0, vie_channel_->SetSendTransportSequenceNumber(true, id));
184 } else { 185 } else {
185 RTC_NOTREACHED() << "Registering unsupported RTP extension."; 186 RTC_NOTREACHED() << "Registering unsupported RTP extension.";
186 } 187 }
187 } 188 }
188 189
189 channel_group_->SetChannelRembStatus(true, false, vie_channel_->rtp_rtcp()); 190 congestion_controller_->SetChannelRembStatus(true, false,
191 vie_channel_->rtp_rtcp());
190 192
191 // Enable NACK, FEC or both. 193 // Enable NACK, FEC or both.
192 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0; 194 const bool enable_protection_nack = config_.rtp.nack.rtp_history_ms > 0;
193 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1; 195 const bool enable_protection_fec = config_.rtp.fec.red_payload_type != -1;
194 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future. 196 // TODO(changbin): Should set RTX for RED mapping in RTP sender in future.
195 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec, 197 vie_channel_->SetProtectionMode(enable_protection_nack, enable_protection_fec,
196 config_.rtp.fec.red_payload_type, 198 config_.rtp.fec.red_payload_type,
197 config_.rtp.fec.ulpfec_payload_type); 199 config_.rtp.fec.ulpfec_payload_type);
198 vie_encoder_->UpdateProtectionMethod(enable_protection_nack, 200 vie_encoder_->UpdateProtectionMethod(enable_protection_nack,
199 enable_protection_fec); 201 enable_protection_fec);
(...skipping 21 matching lines...) Expand all
221 RTC_CHECK(ReconfigureVideoEncoder(encoder_config)); 223 RTC_CHECK(ReconfigureVideoEncoder(encoder_config));
222 224
223 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_); 225 vie_channel_->RegisterSendSideDelayObserver(&stats_proxy_);
224 226
225 if (config_.post_encode_callback) 227 if (config_.post_encode_callback)
226 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_); 228 vie_encoder_->RegisterPostEncodeImageCallback(&encoded_frame_proxy_);
227 229
228 if (config_.suspend_below_min_bitrate) 230 if (config_.suspend_below_min_bitrate)
229 vie_encoder_->SuspendBelowMinBitrate(); 231 vie_encoder_->SuspendBelowMinBitrate();
230 232
231 channel_group_->AddEncoder(vie_encoder_.get()); 233 congestion_controller_->AddEncoder(vie_encoder_.get());
232 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get()); 234 encoder_feedback_->AddEncoder(ssrcs, vie_encoder_.get());
233 235
234 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_); 236 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(&stats_proxy_);
235 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_); 237 vie_channel_->RegisterSendChannelRtpStatisticsCallback(&stats_proxy_);
236 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); 238 vie_channel_->RegisterRtcpPacketTypeCounterObserver(&stats_proxy_);
237 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_); 239 vie_channel_->RegisterSendBitrateObserver(&stats_proxy_);
238 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_); 240 vie_channel_->RegisterSendFrameCountObserver(&stats_proxy_);
239 } 241 }
240 242
241 VideoSendStream::~VideoSendStream() { 243 VideoSendStream::~VideoSendStream() {
242 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString(); 244 LOG(LS_INFO) << "~VideoSendStream: " << config_.ToString();
243 vie_channel_->RegisterSendFrameCountObserver(nullptr); 245 vie_channel_->RegisterSendFrameCountObserver(nullptr);
244 vie_channel_->RegisterSendBitrateObserver(nullptr); 246 vie_channel_->RegisterSendBitrateObserver(nullptr);
245 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr); 247 vie_channel_->RegisterRtcpPacketTypeCounterObserver(nullptr);
246 vie_channel_->RegisterSendChannelRtpStatisticsCallback(nullptr); 248 vie_channel_->RegisterSendChannelRtpStatisticsCallback(nullptr);
247 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr); 249 vie_channel_->RegisterSendChannelRtcpStatisticsCallback(nullptr);
248 250
249 // Remove capture input (thread) so that it's not running after the current 251 // Remove capture input (thread) so that it's not running after the current
250 // channel is deleted. 252 // channel is deleted.
251 input_.reset(); 253 input_.reset();
252 254
253 vie_encoder_->DeRegisterExternalEncoder( 255 vie_encoder_->DeRegisterExternalEncoder(
254 config_.encoder_settings.payload_type); 256 config_.encoder_settings.payload_type);
255 257
256 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); 258 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver());
257 channel_group_->SetChannelRembStatus(false, false, vie_channel_->rtp_rtcp()); 259 congestion_controller_->SetChannelRembStatus(false, false,
260 vie_channel_->rtp_rtcp());
258 261
259 // Remove the feedback, stop all encoding threads and processing. This must be 262 // Remove the feedback, stop all encoding threads and processing. This must be
260 // done before deleting the channel. 263 // done before deleting the channel.
261 channel_group_->RemoveEncoder(vie_encoder_.get()); 264 congestion_controller_->RemoveEncoder(vie_encoder_.get());
262 encoder_feedback_->RemoveEncoder(vie_encoder_.get()); 265 encoder_feedback_->RemoveEncoder(vie_encoder_.get());
263 vie_encoder_->StopThreadsAndRemoveSharedMembers(); 266 vie_encoder_->StopThreadsAndRemoveSharedMembers();
264 267
265 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); 268 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC();
266 channel_group_->GetRemoteBitrateEstimator(false)->RemoveStream(remote_ssrc); 269 congestion_controller_->GetRemoteBitrateEstimator(false)->RemoveStream(
270 remote_ssrc);
267 } 271 }
268 272
269 VideoCaptureInput* VideoSendStream::Input() { 273 VideoCaptureInput* VideoSendStream::Input() {
270 return input_.get(); 274 return input_.get();
271 } 275 }
272 276
273 void VideoSendStream::Start() { 277 void VideoSendStream::Start() {
274 transport_adapter_.Enable(); 278 transport_adapter_.Enable();
275 vie_encoder_->Pause(); 279 vie_encoder_->Pause();
276 if (vie_channel_->StartSend() == 0) { 280 if (vie_channel_->StartSend() == 0) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 vie_channel_->IsSendingFecEnabled()); 556 vie_channel_->IsSendingFecEnabled());
553 557
554 // Restart the media flow 558 // Restart the media flow
555 vie_encoder_->Restart(); 559 vie_encoder_->Restart();
556 560
557 return true; 561 return true;
558 } 562 }
559 563
560 } // namespace internal 564 } // namespace internal
561 } // namespace webrtc 565 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698