OLD | NEW |
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 |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
135 Call::Config::kDefaultStartBitrateBps / 1000; | 135 Call::Config::kDefaultStartBitrateBps / 1000; |
136 | 136 |
137 return codec; | 137 return codec; |
138 } | 138 } |
139 } // namespace | 139 } // namespace |
140 | 140 |
141 VideoReceiveStream::VideoReceiveStream(int num_cpu_cores, | 141 VideoReceiveStream::VideoReceiveStream(int num_cpu_cores, |
142 ChannelGroup* channel_group, | 142 ChannelGroup* channel_group, |
143 const VideoReceiveStream::Config& config, | 143 const VideoReceiveStream::Config& config, |
144 webrtc::VoiceEngine* voice_engine, | 144 webrtc::VoiceEngine* voice_engine, |
145 ProcessThread* process_thread) | 145 ProcessThread* process_thread, |
| 146 CallStats* call_stats) |
146 : transport_adapter_(config.rtcp_send_transport), | 147 : transport_adapter_(config.rtcp_send_transport), |
147 encoded_frame_proxy_(config.pre_decode_callback), | 148 encoded_frame_proxy_(config.pre_decode_callback), |
148 config_(config), | 149 config_(config), |
149 clock_(Clock::GetRealTimeClock()), | 150 clock_(Clock::GetRealTimeClock()), |
150 channel_group_(channel_group) { | 151 channel_group_(channel_group), |
| 152 call_stats_(call_stats) { |
151 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); | 153 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); |
152 | 154 |
153 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 155 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
154 | 156 |
155 RemoteBitrateEstimator* bitrate_estimator = | 157 RemoteBitrateEstimator* bitrate_estimator = |
156 channel_group_->GetRemoteBitrateEstimator(send_side_bwe); | 158 channel_group_->GetRemoteBitrateEstimator(send_side_bwe); |
157 | 159 |
158 vie_channel_.reset(new ViEChannel( | 160 vie_channel_.reset(new ViEChannel( |
159 num_cpu_cores, &transport_adapter_, process_thread, | 161 num_cpu_cores, &transport_adapter_, process_thread, nullptr, |
160 channel_group_->GetRtcpIntraFrameObserver(), | |
161 channel_group_->GetBitrateController()->CreateRtcpBandwidthObserver(), | 162 channel_group_->GetBitrateController()->CreateRtcpBandwidthObserver(), |
162 nullptr, bitrate_estimator, | 163 nullptr, bitrate_estimator, call_stats_->rtcp_rtt_stats(), |
163 channel_group_->GetCallStats()->rtcp_rtt_stats(), channel_group_->pacer(), | 164 channel_group_->pacer(), channel_group_->packet_router(), 1, false)); |
164 channel_group_->packet_router(), 1, false)); | |
165 | 165 |
166 RTC_CHECK(vie_channel_->Init() == 0); | 166 RTC_CHECK(vie_channel_->Init() == 0); |
167 | 167 |
168 // Register the channel to receive stats updates. | 168 // Register the channel to receive stats updates. |
169 channel_group_->GetCallStats()->RegisterStatsObserver( | 169 call_stats_->RegisterStatsObserver(vie_channel_->GetStatsObserver()); |
170 vie_channel_->GetStatsObserver()); | |
171 | 170 |
172 // TODO(pbos): This is not fine grained enough... | 171 // TODO(pbos): This is not fine grained enough... |
173 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, | 172 vie_channel_->SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, |
174 -1, -1); | 173 -1, -1); |
175 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) | 174 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) |
176 << "A stream should not be configured with RTCP disabled. This value is " | 175 << "A stream should not be configured with RTCP disabled. This value is " |
177 "reserved for internal usage."; | 176 "reserved for internal usage."; |
178 vie_channel_->SetRTCPMode(config_.rtp.rtcp_mode); | 177 vie_channel_->SetRTCPMode(config_.rtp.rtcp_mode); |
179 | 178 |
180 RTC_DCHECK(config_.rtp.remote_ssrc != 0); | 179 RTC_DCHECK(config_.rtp.remote_ssrc != 0); |
181 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? | 180 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? |
182 RTC_DCHECK(config_.rtp.local_ssrc != 0); | 181 RTC_DCHECK(config_.rtp.local_ssrc != 0); |
183 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); | 182 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); |
184 | 183 |
185 vie_channel_->SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0); | 184 vie_channel_->SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0); |
186 // TODO(pbos): Support multiple RTX, per video payload. | 185 // TODO(pbos): Support multiple RTX, per video payload. |
187 Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin(); | 186 Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin(); |
188 for (; it != config_.rtp.rtx.end(); ++it) { | 187 for (; it != config_.rtp.rtx.end(); ++it) { |
189 RTC_DCHECK(it->second.ssrc != 0); | 188 RTC_DCHECK(it->second.ssrc != 0); |
190 RTC_DCHECK(it->second.payload_type != 0); | 189 RTC_DCHECK(it->second.payload_type != 0); |
191 | 190 |
192 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); | 191 vie_channel_->SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); |
193 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); | 192 vie_channel_->SetRtxReceivePayloadType(it->second.payload_type, it->first); |
194 } | 193 } |
195 // TODO(holmer): When Chrome no longer depends on this being false by default, | 194 // TODO(holmer): When Chrome no longer depends on this being false by default, |
196 // always use the mapping and remove this whole codepath. | 195 // always use the mapping and remove this whole codepath. |
197 vie_channel_->SetUseRtxPayloadMappingOnRestore( | 196 vie_channel_->SetUseRtxPayloadMappingOnRestore( |
198 config_.rtp.use_rtx_payload_mapping_on_restore); | 197 config_.rtp.use_rtx_payload_mapping_on_restore); |
199 | 198 |
200 // TODO(pbos): Remove channel_group_ usage from VideoReceiveStream. This | |
201 // should be configured in call.cc. | |
202 channel_group_->SetChannelRembStatus(false, config_.rtp.remb, | 199 channel_group_->SetChannelRembStatus(false, config_.rtp.remb, |
203 vie_channel_.get()); | 200 vie_channel_->rtp_rtcp()); |
204 | 201 |
205 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { | 202 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { |
206 const std::string& extension = config_.rtp.extensions[i].name; | 203 const std::string& extension = config_.rtp.extensions[i].name; |
207 int id = config_.rtp.extensions[i].id; | 204 int id = config_.rtp.extensions[i].id; |
208 // One-byte-extension local identifiers are in the range 1-14 inclusive. | 205 // One-byte-extension local identifiers are in the range 1-14 inclusive. |
209 RTC_DCHECK_GE(id, 1); | 206 RTC_DCHECK_GE(id, 1); |
210 RTC_DCHECK_LE(id, 14); | 207 RTC_DCHECK_LE(id, 14); |
211 if (extension == RtpExtension::kTOffset) { | 208 if (extension == RtpExtension::kTOffset) { |
212 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); | 209 RTC_CHECK_EQ(0, vie_channel_->SetReceiveTimestampOffsetStatus(true, id)); |
213 } else if (extension == RtpExtension::kAbsSendTime) { | 210 } else if (extension == RtpExtension::kAbsSendTime) { |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 | 281 |
285 VideoReceiveStream::~VideoReceiveStream() { | 282 VideoReceiveStream::~VideoReceiveStream() { |
286 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); | 283 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); |
287 incoming_video_stream_->Stop(); | 284 incoming_video_stream_->Stop(); |
288 vie_channel_->RegisterPreRenderCallback(nullptr); | 285 vie_channel_->RegisterPreRenderCallback(nullptr); |
289 vie_channel_->RegisterPreDecodeImageCallback(nullptr); | 286 vie_channel_->RegisterPreDecodeImageCallback(nullptr); |
290 | 287 |
291 for (size_t i = 0; i < config_.decoders.size(); ++i) | 288 for (size_t i = 0; i < config_.decoders.size(); ++i) |
292 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); | 289 vie_channel_->DeRegisterExternalDecoder(config_.decoders[i].payload_type); |
293 | 290 |
294 channel_group_->GetCallStats()->DeregisterStatsObserver( | 291 call_stats_->DeregisterStatsObserver(vie_channel_->GetStatsObserver()); |
295 vie_channel_->GetStatsObserver()); | 292 channel_group_->SetChannelRembStatus(false, false, vie_channel_->rtp_rtcp()); |
296 channel_group_->SetChannelRembStatus(false, false, vie_channel_.get()); | |
297 | 293 |
298 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); | 294 uint32_t remote_ssrc = vie_channel_->GetRemoteSSRC(); |
299 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); | 295 bool send_side_bwe = UseSendSideBwe(config_.rtp.extensions); |
300 channel_group_->GetRemoteBitrateEstimator(send_side_bwe)->RemoveStream( | 296 channel_group_->GetRemoteBitrateEstimator(send_side_bwe)->RemoveStream( |
301 remote_ssrc); | 297 remote_ssrc); |
302 } | 298 } |
303 | 299 |
304 void VideoReceiveStream::Start() { | 300 void VideoReceiveStream::Start() { |
305 transport_adapter_.Enable(); | 301 transport_adapter_.Enable(); |
306 incoming_video_stream_->Start(); | 302 incoming_video_stream_->Start(); |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 return 0; | 360 return 0; |
365 } | 361 } |
366 | 362 |
367 void VideoReceiveStream::SignalNetworkState(NetworkState state) { | 363 void VideoReceiveStream::SignalNetworkState(NetworkState state) { |
368 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode | 364 vie_channel_->SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode |
369 : RtcpMode::kOff); | 365 : RtcpMode::kOff); |
370 } | 366 } |
371 | 367 |
372 } // namespace internal | 368 } // namespace internal |
373 } // namespace webrtc | 369 } // namespace webrtc |
OLD | NEW |