Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 87 VieRemb* remb, | 87 VieRemb* remb, |
| 88 const VideoReceiveStream::Config* config, | 88 const VideoReceiveStream::Config* config, |
| 89 ReceiveStatisticsProxy* receive_stats_proxy, | 89 ReceiveStatisticsProxy* receive_stats_proxy, |
| 90 ProcessThread* process_thread, | 90 ProcessThread* process_thread, |
| 91 NackSender* nack_sender, | 91 NackSender* nack_sender, |
| 92 KeyFrameRequestSender* keyframe_request_sender, | 92 KeyFrameRequestSender* keyframe_request_sender, |
| 93 video_coding::OnCompleteFrameCallback* complete_frame_callback, | 93 video_coding::OnCompleteFrameCallback* complete_frame_callback, |
| 94 VCMTiming* timing) | 94 VCMTiming* timing) |
| 95 : clock_(Clock::GetRealTimeClock()), | 95 : clock_(Clock::GetRealTimeClock()), |
| 96 config_(*config), | 96 config_(*config), |
| 97 rtp_config_(config->rtp.extensions, config->rtp.transport_cc), | |
| 97 video_receiver_(video_receiver), | 98 video_receiver_(video_receiver), |
| 98 packet_router_(packet_router), | 99 packet_router_(packet_router), |
| 99 remb_(remb), | 100 remb_(remb), |
| 100 process_thread_(process_thread), | 101 process_thread_(process_thread), |
| 101 ntp_estimator_(clock_), | 102 ntp_estimator_(clock_), |
| 102 rtp_header_parser_(RtpHeaderParser::Create()), | 103 rtp_header_parser_(RtpHeaderParser::Create()), |
| 103 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, | 104 rtp_receiver_(RtpReceiver::CreateVideoReceiver(clock_, |
| 104 this, | 105 this, |
| 105 this, | 106 this, |
| 106 &rtp_payload_registry_)), | 107 &rtp_payload_registry_)), |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 } | 236 } |
| 236 | 237 |
| 237 int RtpStreamReceiver::GetCsrcs(uint32_t* csrcs) const { | 238 int RtpStreamReceiver::GetCsrcs(uint32_t* csrcs) const { |
| 238 return rtp_receiver_->CSRCs(csrcs); | 239 return rtp_receiver_->CSRCs(csrcs); |
| 239 } | 240 } |
| 240 | 241 |
| 241 RtpReceiver* RtpStreamReceiver::GetRtpReceiver() const { | 242 RtpReceiver* RtpStreamReceiver::GetRtpReceiver() const { |
| 242 return rtp_receiver_.get(); | 243 return rtp_receiver_.get(); |
| 243 } | 244 } |
| 244 | 245 |
| 246 bool RtpStreamReceiver::OnRtpPacket(const RtpPacketReceived& packet) { | |
| 247 { | |
| 248 rtc::CritScope lock(&receive_cs_); | |
| 249 if (!receiving_) { | |
| 250 return false; | |
| 251 } | |
| 252 } | |
| 253 | |
| 254 RTPHeader header; | |
| 255 packet.GetHeader(&header); | |
| 256 | |
| 257 int64_t now_ms = clock_->TimeInMilliseconds(); | |
| 258 | |
| 259 { | |
| 260 // Periodically log the RTP header of incoming packets. | |
| 261 rtc::CritScope lock(&receive_cs_); | |
| 262 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { | |
| 263 std::stringstream ss; | |
| 264 ss << "Packet received on SSRC: " << header.ssrc << " with payload type: " | |
| 265 << static_cast<int>(header.payloadType) << ", timestamp: " | |
| 266 << header.timestamp << ", sequence number: " << header.sequenceNumber | |
| 267 << ", arrival time: " << packet.arrival_time_ms(); | |
| 268 if (header.extension.hasTransmissionTimeOffset) | |
| 269 ss << ", toffset: " << header.extension.transmissionTimeOffset; | |
| 270 if (header.extension.hasAbsoluteSendTime) | |
| 271 ss << ", abs send time: " << header.extension.absoluteSendTime; | |
| 272 LOG(LS_INFO) << ss.str(); | |
| 273 last_packet_log_ms_ = now_ms; | |
| 274 } | |
| 275 } | |
| 276 | |
| 277 header.payload_type_frequency = kVideoPayloadTypeFrequency; | |
| 278 | |
| 279 bool in_order = IsPacketInOrder(header); | |
| 280 rtp_payload_registry_.SetIncomingPayloadType(header); | |
| 281 // TODO(nisse): Is .data() and .size() right? Strip headers or not? | |
|
stefan-webrtc
2017/02/09 13:40:06
Yes, this looks correct, as the full packet is nee
| |
| 282 bool ret = ReceivePacket(packet.data(), packet.size(), header, in_order); | |
| 283 // Update receive statistics after ReceivePacket. | |
| 284 // Receive statistics will be reset if the payload type changes (make sure | |
| 285 // that the first packet is included in the stats). | |
| 286 rtp_receive_statistics_->IncomingPacket( | |
| 287 header, packet.size(), IsPacketRetransmitted(header, in_order)); | |
| 288 return ret; | |
| 289 } | |
| 290 | |
| 291 const RtpPacketReceiver::RtpConfig& RtpStreamReceiver::rtp_config() const { | |
| 292 return rtp_config_; | |
| 293 } | |
| 294 | |
| 295 | |
| 245 int32_t RtpStreamReceiver::OnReceivedPayloadData( | 296 int32_t RtpStreamReceiver::OnReceivedPayloadData( |
| 246 const uint8_t* payload_data, | 297 const uint8_t* payload_data, |
| 247 size_t payload_size, | 298 size_t payload_size, |
| 248 const WebRtcRTPHeader* rtp_header) { | 299 const WebRtcRTPHeader* rtp_header) { |
| 249 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 300 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
| 250 rtp_header_with_ntp.ntp_time_ms = | 301 rtp_header_with_ntp.ntp_time_ms = |
| 251 ntp_estimator_.Estimate(rtp_header->header.timestamp); | 302 ntp_estimator_.Estimate(rtp_header->header.timestamp); |
| 252 if (jitter_buffer_experiment_) { | 303 if (jitter_buffer_experiment_) { |
| 253 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); | 304 VCMPacket packet(payload_data, payload_size, rtp_header_with_ntp); |
| 254 packet.timesNacked = nack_module_->OnReceivedPacket(packet); | 305 packet.timesNacked = nack_module_->OnReceivedPacket(packet); |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 309 const size_t channels, | 360 const size_t channels, |
| 310 const uint32_t rate) { | 361 const uint32_t rate) { |
| 311 RTC_NOTREACHED(); | 362 RTC_NOTREACHED(); |
| 312 return 0; | 363 return 0; |
| 313 } | 364 } |
| 314 | 365 |
| 315 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { | 366 void RtpStreamReceiver::OnIncomingSSRCChanged(const uint32_t ssrc) { |
| 316 rtp_rtcp_->SetRemoteSSRC(ssrc); | 367 rtp_rtcp_->SetRemoteSSRC(ssrc); |
| 317 } | 368 } |
| 318 | 369 |
| 319 bool RtpStreamReceiver::DeliverRtp(const uint8_t* rtp_packet, | |
| 320 size_t rtp_packet_length, | |
| 321 const PacketTime& packet_time) { | |
| 322 { | |
| 323 rtc::CritScope lock(&receive_cs_); | |
| 324 if (!receiving_) { | |
| 325 return false; | |
| 326 } | |
| 327 } | |
| 328 | |
| 329 RTPHeader header; | |
| 330 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, | |
| 331 &header)) { | |
| 332 return false; | |
| 333 } | |
| 334 int64_t arrival_time_ms; | |
| 335 int64_t now_ms = clock_->TimeInMilliseconds(); | |
| 336 if (packet_time.timestamp != -1) | |
| 337 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | |
| 338 else | |
| 339 arrival_time_ms = now_ms; | |
| 340 | |
| 341 { | |
| 342 // Periodically log the RTP header of incoming packets. | |
| 343 rtc::CritScope lock(&receive_cs_); | |
| 344 if (now_ms - last_packet_log_ms_ > kPacketLogIntervalMs) { | |
| 345 std::stringstream ss; | |
| 346 ss << "Packet received on SSRC: " << header.ssrc << " with payload type: " | |
| 347 << static_cast<int>(header.payloadType) << ", timestamp: " | |
| 348 << header.timestamp << ", sequence number: " << header.sequenceNumber | |
| 349 << ", arrival time: " << arrival_time_ms; | |
| 350 if (header.extension.hasTransmissionTimeOffset) | |
| 351 ss << ", toffset: " << header.extension.transmissionTimeOffset; | |
| 352 if (header.extension.hasAbsoluteSendTime) | |
| 353 ss << ", abs send time: " << header.extension.absoluteSendTime; | |
| 354 LOG(LS_INFO) << ss.str(); | |
| 355 last_packet_log_ms_ = now_ms; | |
| 356 } | |
| 357 } | |
| 358 | |
| 359 header.payload_type_frequency = kVideoPayloadTypeFrequency; | |
| 360 | |
| 361 bool in_order = IsPacketInOrder(header); | |
| 362 rtp_payload_registry_.SetIncomingPayloadType(header); | |
| 363 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | |
| 364 // Update receive statistics after ReceivePacket. | |
| 365 // Receive statistics will be reset if the payload type changes (make sure | |
| 366 // that the first packet is included in the stats). | |
| 367 rtp_receive_statistics_->IncomingPacket( | |
| 368 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); | |
| 369 return ret; | |
| 370 } | |
| 371 | |
| 372 int32_t RtpStreamReceiver::RequestKeyFrame() { | 370 int32_t RtpStreamReceiver::RequestKeyFrame() { |
| 373 return rtp_rtcp_->RequestKeyFrame(); | 371 return rtp_rtcp_->RequestKeyFrame(); |
| 374 } | 372 } |
| 375 | 373 |
| 376 int32_t RtpStreamReceiver::SliceLossIndicationRequest( | 374 int32_t RtpStreamReceiver::SliceLossIndicationRequest( |
| 377 const uint64_t picture_id) { | 375 const uint64_t picture_id) { |
| 378 return rtp_rtcp_->SendRTCPSliceLossIndication( | 376 return rtp_rtcp_->SendRTCPSliceLossIndication( |
| 379 static_cast<uint8_t>(picture_id)); | 377 static_cast<uint8_t>(picture_id)); |
| 380 } | 378 } |
| 381 | 379 |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 668 return; | 666 return; |
| 669 | 667 |
| 670 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) | 668 if (!sprop_decoder.DecodeSprop(sprop_base64_it->second.c_str())) |
| 671 return; | 669 return; |
| 672 | 670 |
| 673 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), | 671 tracker_.InsertSpsPpsNalus(sprop_decoder.sps_nalu(), |
| 674 sprop_decoder.pps_nalu()); | 672 sprop_decoder.pps_nalu()); |
| 675 } | 673 } |
| 676 | 674 |
| 677 } // namespace webrtc | 675 } // namespace webrtc |
| OLD | NEW |