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