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

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

Issue 1671893002: Remove ViEChannel calls for VideoReceiveStream. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove extra include + forward declare ProcessThread Created 4 years, 10 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
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 vcm_.get(), 167 vcm_.get(),
168 nullptr, 168 nullptr,
169 nullptr, 169 nullptr,
170 nullptr, 170 nullptr,
171 congestion_controller_->GetRemoteBitrateEstimator( 171 congestion_controller_->GetRemoteBitrateEstimator(
172 UseSendSideBwe(config_)), 172 UseSendSideBwe(config_)),
173 call_stats_->rtcp_rtt_stats(), 173 call_stats_->rtcp_rtt_stats(),
174 congestion_controller_->pacer(), 174 congestion_controller_->pacer(),
175 congestion_controller_->packet_router(), 175 congestion_controller_->packet_router(),
176 1, 176 1,
177 false) { 177 false),
178 vie_receiver_(vie_channel_.vie_receiver()),
179 rtp_rtcp_(vie_channel_.rtp_rtcp()) {
178 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString(); 180 LOG(LS_INFO) << "VideoReceiveStream: " << config_.ToString();
179 181
180 RTC_CHECK(vie_channel_.Init() == 0); 182 RTC_CHECK(vie_channel_.Init() == 0);
181 183
182 // Register the channel to receive stats updates. 184 // Register the channel to receive stats updates.
183 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver()); 185 call_stats_->RegisterStatsObserver(vie_channel_.GetStatsObserver());
184 186
185 // TODO(pbos): This is not fine grained enough... 187 // TODO(pbos): This is not fine grained enough...
186 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, 188 vie_channel_.SetProtectionMode(config_.rtp.nack.rtp_history_ms > 0, false, -1,
187 -1, -1); 189 -1);
188 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff) 190 RTC_DCHECK(config_.rtp.rtcp_mode != RtcpMode::kOff)
189 << "A stream should not be configured with RTCP disabled. This value is " 191 << "A stream should not be configured with RTCP disabled. This value is "
190 "reserved for internal usage."; 192 "reserved for internal usage.";
191 vie_channel_.SetRTCPMode(config_.rtp.rtcp_mode); 193 rtp_rtcp_->SetRTCPStatus(config_.rtp.rtcp_mode);
192 194
193 RTC_DCHECK(config_.rtp.remote_ssrc != 0); 195 RTC_DCHECK(config_.rtp.remote_ssrc != 0);
194 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams? 196 // TODO(pbos): What's an appropriate local_ssrc for receive-only streams?
195 RTC_DCHECK(config_.rtp.local_ssrc != 0); 197 RTC_DCHECK(config_.rtp.local_ssrc != 0);
196 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc); 198 RTC_DCHECK(config_.rtp.remote_ssrc != config_.rtp.local_ssrc);
199 rtp_rtcp_->SetSSRC(config_.rtp.local_ssrc);
197 200
198 vie_channel_.SetSSRC(config_.rtp.local_ssrc, kViEStreamTypeNormal, 0);
199 // TODO(pbos): Support multiple RTX, per video payload. 201 // TODO(pbos): Support multiple RTX, per video payload.
200 Config::Rtp::RtxMap::const_iterator it = config_.rtp.rtx.begin(); 202 for (const auto& kv : config_.rtp.rtx) {
201 for (; it != config_.rtp.rtx.end(); ++it) { 203 RTC_DCHECK(kv.second.ssrc != 0);
202 RTC_DCHECK(it->second.ssrc != 0); 204 RTC_DCHECK(kv.second.payload_type != 0);
203 RTC_DCHECK(it->second.payload_type != 0);
204 205
205 vie_channel_.SetRemoteSSRCType(kViEStreamTypeRtx, it->second.ssrc); 206 vie_receiver_->SetRtxSsrc(kv.second.ssrc);
206 vie_channel_.SetRtxReceivePayloadType(it->second.payload_type, it->first); 207 vie_channel_.SetRtxReceivePayloadType(kv.second.payload_type, kv.first);
207 } 208 }
208 // TODO(holmer): When Chrome no longer depends on this being false by default, 209 // TODO(holmer): When Chrome no longer depends on this being false by default,
209 // always use the mapping and remove this whole codepath. 210 // always use the mapping and remove this whole codepath.
210 vie_channel_.SetUseRtxPayloadMappingOnRestore( 211 vie_channel_.SetUseRtxPayloadMappingOnRestore(
211 config_.rtp.use_rtx_payload_mapping_on_restore); 212 config_.rtp.use_rtx_payload_mapping_on_restore);
212 213
213 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb, 214 congestion_controller_->SetChannelRembStatus(false, config_.rtp.remb,
214 vie_channel_.rtp_rtcp()); 215 rtp_rtcp_);
215 216
216 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) { 217 for (size_t i = 0; i < config_.rtp.extensions.size(); ++i) {
217 const std::string& extension = config_.rtp.extensions[i].name; 218 const std::string& extension = config_.rtp.extensions[i].name;
218 int id = config_.rtp.extensions[i].id; 219 int id = config_.rtp.extensions[i].id;
219 // One-byte-extension local identifiers are in the range 1-14 inclusive. 220 // One-byte-extension local identifiers are in the range 1-14 inclusive.
220 RTC_DCHECK_GE(id, 1); 221 RTC_DCHECK_GE(id, 1);
221 RTC_DCHECK_LE(id, 14); 222 RTC_DCHECK_LE(id, 14);
222 if (extension == RtpExtension::kTOffset) { 223 if (extension == RtpExtension::kTOffset) {
223 RTC_CHECK_EQ(0, vie_channel_.SetReceiveTimestampOffsetStatus(true, id)); 224 RTC_CHECK(vie_receiver_->SetReceiveTimestampOffsetStatus(true, id));
224 } else if (extension == RtpExtension::kAbsSendTime) { 225 } else if (extension == RtpExtension::kAbsSendTime) {
225 RTC_CHECK_EQ(0, vie_channel_.SetReceiveAbsoluteSendTimeStatus(true, id)); 226 RTC_CHECK(vie_receiver_->SetReceiveAbsoluteSendTimeStatus(true, id));
226 } else if (extension == RtpExtension::kVideoRotation) { 227 } else if (extension == RtpExtension::kVideoRotation) {
227 RTC_CHECK_EQ(0, vie_channel_.SetReceiveVideoRotationStatus(true, id)); 228 RTC_CHECK(vie_receiver_->SetReceiveVideoRotationStatus(true, id));
228 } else if (extension == RtpExtension::kTransportSequenceNumber) { 229 } else if (extension == RtpExtension::kTransportSequenceNumber) {
229 RTC_CHECK_EQ(0, 230 RTC_CHECK(vie_receiver_->SetReceiveTransportSequenceNumber(true, id));
230 vie_channel_.SetReceiveTransportSequenceNumber(true, id));
231 } else { 231 } else {
232 RTC_NOTREACHED() << "Unsupported RTP extension."; 232 RTC_NOTREACHED() << "Unsupported RTP extension.";
233 } 233 }
234 } 234 }
235 235
236 if (config_.rtp.fec.ulpfec_payload_type != -1) { 236 if (config_.rtp.fec.ulpfec_payload_type != -1) {
237 // ULPFEC without RED doesn't make sense. 237 // ULPFEC without RED doesn't make sense.
238 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1); 238 RTC_DCHECK(config_.rtp.fec.red_payload_type != -1);
239 VideoCodec codec; 239 VideoCodec codec;
240 memset(&codec, 0, sizeof(codec)); 240 memset(&codec, 0, sizeof(codec));
(...skipping 10 matching lines...) Expand all
251 codec.plType = config_.rtp.fec.red_payload_type; 251 codec.plType = config_.rtp.fec.red_payload_type;
252 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec)); 252 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec));
253 if (config_.rtp.fec.red_rtx_payload_type != -1) { 253 if (config_.rtp.fec.red_rtx_payload_type != -1) {
254 vie_channel_.SetRtxReceivePayloadType( 254 vie_channel_.SetRtxReceivePayloadType(
255 config_.rtp.fec.red_rtx_payload_type, 255 config_.rtp.fec.red_rtx_payload_type,
256 config_.rtp.fec.red_payload_type); 256 config_.rtp.fec.red_payload_type);
257 } 257 }
258 } 258 }
259 259
260 if (config.rtp.rtcp_xr.receiver_reference_time_report) 260 if (config.rtp.rtcp_xr.receiver_reference_time_report)
261 vie_channel_.SetRtcpXrRrtrStatus(true); 261 rtp_rtcp_->SetRtcpXrRrtrStatus(true);
262 262
263 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_); 263 vie_channel_.RegisterReceiveStatisticsProxy(&stats_proxy_);
264 vie_channel_.RegisterReceiveChannelRtcpStatisticsCallback(&stats_proxy_); 264 vie_channel_.RegisterReceiveChannelRtcpStatisticsCallback(&stats_proxy_);
265 vie_channel_.RegisterReceiveChannelRtpStatisticsCallback(&stats_proxy_); 265 vie_channel_.RegisterReceiveChannelRtpStatisticsCallback(&stats_proxy_);
266 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_); 266 vie_channel_.RegisterRtcpPacketTypeCounterObserver(&stats_proxy_);
267 267
268 RTC_DCHECK(!config_.decoders.empty()); 268 RTC_DCHECK(!config_.decoders.empty());
269 std::set<int> decoder_payload_types; 269 std::set<int> decoder_payload_types;
270 for (size_t i = 0; i < config_.decoders.size(); ++i) { 270 for (size_t i = 0; i < config_.decoders.size(); ++i) {
271 const Decoder& decoder = config_.decoders[i]; 271 const Decoder& decoder = config_.decoders[i];
272 RTC_CHECK(decoder.decoder); 272 RTC_CHECK(decoder.decoder);
273 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) == 273 RTC_CHECK(decoder_payload_types.find(decoder.payload_type) ==
274 decoder_payload_types.end()) 274 decoder_payload_types.end())
275 << "Duplicate payload type (" << decoder.payload_type 275 << "Duplicate payload type (" << decoder.payload_type
276 << ") for different decoders."; 276 << ") for different decoders.";
277 decoder_payload_types.insert(decoder.payload_type); 277 decoder_payload_types.insert(decoder.payload_type);
278 vie_channel_.RegisterExternalDecoder(decoder.payload_type, 278 vcm_->RegisterExternalDecoder(decoder.decoder, decoder.payload_type);
279 decoder.decoder);
280 279
281 VideoCodec codec = CreateDecoderVideoCodec(decoder); 280 VideoCodec codec = CreateDecoderVideoCodec(decoder);
282 281
283 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec)); 282 RTC_CHECK_EQ(0, vie_channel_.SetReceiveCodec(codec));
284 } 283 }
285 284
285 vcm_->SetRenderDelay(config.render_delay_ms);
286 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms); 286 incoming_video_stream_.SetExpectedRenderDelay(config.render_delay_ms);
287 vie_channel_.SetExpectedRenderDelay(config.render_delay_ms); 287 vcm_->RegisterPreDecodeImageCallback(this);
288 incoming_video_stream_.SetExternalCallback(this); 288 incoming_video_stream_.SetExternalCallback(this);
289 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_); 289 vie_channel_.SetIncomingVideoStream(&incoming_video_stream_);
290
291 vie_channel_.RegisterPreDecodeImageCallback(this);
292 vie_channel_.RegisterPreRenderCallback(this); 290 vie_channel_.RegisterPreRenderCallback(this);
293 291
294 process_thread_->RegisterModule(vcm_.get()); 292 process_thread_->RegisterModule(vcm_.get());
295 } 293 }
296 294
297 VideoReceiveStream::~VideoReceiveStream() { 295 VideoReceiveStream::~VideoReceiveStream() {
298 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString(); 296 LOG(LS_INFO) << "~VideoReceiveStream: " << config_.ToString();
299 incoming_video_stream_.Stop(); 297 incoming_video_stream_.Stop();
300 process_thread_->DeRegisterModule(vcm_.get()); 298 process_thread_->DeRegisterModule(vcm_.get());
301 vie_channel_.RegisterPreRenderCallback(nullptr); 299 vie_channel_.RegisterPreRenderCallback(nullptr);
302 vie_channel_.RegisterPreDecodeImageCallback(nullptr); 300 vcm_->RegisterPreDecodeImageCallback(nullptr);
303 301
304 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver()); 302 call_stats_->DeregisterStatsObserver(vie_channel_.GetStatsObserver());
305 congestion_controller_->SetChannelRembStatus(false, false, 303 congestion_controller_->SetChannelRembStatus(false, false, rtp_rtcp_);
306 vie_channel_.rtp_rtcp());
307 304
308 uint32_t remote_ssrc = vie_channel_.GetRemoteSSRC();
309 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_)) 305 congestion_controller_->GetRemoteBitrateEstimator(UseSendSideBwe(config_))
310 ->RemoveStream(remote_ssrc); 306 ->RemoveStream(vie_receiver_->GetRemoteSsrc());
311 } 307 }
312 308
313 void VideoReceiveStream::Start() { 309 void VideoReceiveStream::Start() {
314 transport_adapter_.Enable(); 310 transport_adapter_.Enable();
315 incoming_video_stream_.Start(); 311 incoming_video_stream_.Start();
316 vie_channel_.StartReceive(); 312 vie_channel_.StartReceive();
317 } 313 }
318 314
319 void VideoReceiveStream::Stop() { 315 void VideoReceiveStream::Stop() {
320 incoming_video_stream_.Stop(); 316 incoming_video_stream_.Stop();
(...skipping 10 matching lines...) Expand all
331 } else { 327 } else {
332 vie_channel_.SetVoiceChannel(-1, nullptr); 328 vie_channel_.SetVoiceChannel(-1, nullptr);
333 } 329 }
334 } 330 }
335 331
336 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const { 332 VideoReceiveStream::Stats VideoReceiveStream::GetStats() const {
337 return stats_proxy_.GetStats(); 333 return stats_proxy_.GetStats();
338 } 334 }
339 335
340 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) { 336 bool VideoReceiveStream::DeliverRtcp(const uint8_t* packet, size_t length) {
341 return vie_channel_.ReceivedRTCPPacket(packet, length) == 0; 337 return vie_receiver_->DeliverRtcp(packet, length);
342 } 338 }
343 339
344 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet, 340 bool VideoReceiveStream::DeliverRtp(const uint8_t* packet,
345 size_t length, 341 size_t length,
346 const PacketTime& packet_time) { 342 const PacketTime& packet_time) {
347 return vie_channel_.ReceivedRTPPacket(packet, length, packet_time) == 0; 343 return vie_receiver_->DeliverRtp(packet, length, packet_time);
348 } 344 }
349 345
350 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) { 346 void VideoReceiveStream::FrameCallback(VideoFrame* video_frame) {
351 stats_proxy_.OnDecodedFrame(); 347 stats_proxy_.OnDecodedFrame();
352 348
353 // Post processing is not supported if the frame is backed by a texture. 349 // Post processing is not supported if the frame is backed by a texture.
354 if (video_frame->native_handle() == NULL) { 350 if (video_frame->native_handle() == NULL) {
355 if (config_.pre_render_callback) 351 if (config_.pre_render_callback)
356 config_.pre_render_callback->FrameCallback(video_frame); 352 config_.pre_render_callback->FrameCallback(video_frame);
357 } 353 }
(...skipping 24 matching lines...) Expand all
382 stats_proxy_.OnPreDecode(encoded_image, codec_specific_info); 378 stats_proxy_.OnPreDecode(encoded_image, codec_specific_info);
383 if (config_.pre_decode_callback) { 379 if (config_.pre_decode_callback) {
384 // TODO(asapersson): Remove EncodedFrameCallbackAdapter. 380 // TODO(asapersson): Remove EncodedFrameCallbackAdapter.
385 encoded_frame_proxy_.Encoded( 381 encoded_frame_proxy_.Encoded(
386 encoded_image, codec_specific_info, fragmentation); 382 encoded_image, codec_specific_info, fragmentation);
387 } 383 }
388 return 0; 384 return 0;
389 } 385 }
390 386
391 void VideoReceiveStream::SignalNetworkState(NetworkState state) { 387 void VideoReceiveStream::SignalNetworkState(NetworkState state) {
392 vie_channel_.SetRTCPMode(state == kNetworkUp ? config_.rtp.rtcp_mode 388 rtp_rtcp_->SetRTCPStatus(state == kNetworkUp ? config_.rtp.rtcp_mode
393 : RtcpMode::kOff); 389 : RtcpMode::kOff);
394 } 390 }
395 391
396 } // namespace internal 392 } // namespace internal
397 } // namespace webrtc 393 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698