| 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 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 } else { | 209 } else { |
| 210 return false; | 210 return false; |
| 211 } | 211 } |
| 212 } else { | 212 } else { |
| 213 receiving_tsn_enabled_ = false; | 213 receiving_tsn_enabled_ = false; |
| 214 return rtp_header_parser_->DeregisterRtpHeaderExtension( | 214 return rtp_header_parser_->DeregisterRtpHeaderExtension( |
| 215 kRtpExtensionTransportSequenceNumber); | 215 kRtpExtensionTransportSequenceNumber); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 | 218 |
| 219 int ViEReceiver::ReceivedRTPPacket(const void* rtp_packet, | |
| 220 size_t rtp_packet_length, | |
| 221 const PacketTime& packet_time) { | |
| 222 return InsertRTPPacket(static_cast<const uint8_t*>(rtp_packet), | |
| 223 rtp_packet_length, packet_time); | |
| 224 } | |
| 225 | |
| 226 int ViEReceiver::ReceivedRTCPPacket(const void* rtcp_packet, | |
| 227 size_t rtcp_packet_length) { | |
| 228 return InsertRTCPPacket(static_cast<const uint8_t*>(rtcp_packet), | |
| 229 rtcp_packet_length); | |
| 230 } | |
| 231 | |
| 232 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, | 219 int32_t ViEReceiver::OnReceivedPayloadData(const uint8_t* payload_data, |
| 233 const size_t payload_size, | 220 const size_t payload_size, |
| 234 const WebRtcRTPHeader* rtp_header) { | 221 const WebRtcRTPHeader* rtp_header) { |
| 235 RTC_DCHECK(vcm_); | 222 RTC_DCHECK(vcm_); |
| 236 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; | 223 WebRtcRTPHeader rtp_header_with_ntp = *rtp_header; |
| 237 rtp_header_with_ntp.ntp_time_ms = | 224 rtp_header_with_ntp.ntp_time_ms = |
| 238 ntp_estimator_->Estimate(rtp_header->header.timestamp); | 225 ntp_estimator_->Estimate(rtp_header->header.timestamp); |
| 239 if (vcm_->IncomingPacket(payload_data, | 226 if (vcm_->IncomingPacket(payload_data, |
| 240 payload_size, | 227 payload_size, |
| 241 rtp_header_with_ntp) != 0) { | 228 rtp_header_with_ntp) != 0) { |
| 242 // Check this... | 229 // Check this... |
| 243 return -1; | 230 return -1; |
| 244 } | 231 } |
| 245 return 0; | 232 return 0; |
| 246 } | 233 } |
| 247 | 234 |
| 248 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, | 235 bool ViEReceiver::OnRecoveredPacket(const uint8_t* rtp_packet, |
| 249 size_t rtp_packet_length) { | 236 size_t rtp_packet_length) { |
| 250 RTPHeader header; | 237 RTPHeader header; |
| 251 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { | 238 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, &header)) { |
| 252 return false; | 239 return false; |
| 253 } | 240 } |
| 254 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 241 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
| 255 bool in_order = IsPacketInOrder(header); | 242 bool in_order = IsPacketInOrder(header); |
| 256 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); | 243 return ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); |
| 257 } | 244 } |
| 258 | 245 |
| 259 int ViEReceiver::InsertRTPPacket(const uint8_t* rtp_packet, | 246 bool ViEReceiver::DeliverRtp(const uint8_t* rtp_packet, |
| 260 size_t rtp_packet_length, | 247 size_t rtp_packet_length, |
| 261 const PacketTime& packet_time) { | 248 const PacketTime& packet_time) { |
| 262 { | 249 { |
| 263 rtc::CritScope lock(&receive_cs_); | 250 rtc::CritScope lock(&receive_cs_); |
| 264 if (!receiving_) { | 251 if (!receiving_) { |
| 265 return -1; | 252 return false; |
| 266 } | 253 } |
| 267 } | 254 } |
| 268 | 255 |
| 269 RTPHeader header; | 256 RTPHeader header; |
| 270 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, | 257 if (!rtp_header_parser_->Parse(rtp_packet, rtp_packet_length, |
| 271 &header)) { | 258 &header)) { |
| 272 return -1; | 259 return false; |
| 273 } | 260 } |
| 274 size_t payload_length = rtp_packet_length - header.headerLength; | 261 size_t payload_length = rtp_packet_length - header.headerLength; |
| 275 int64_t arrival_time_ms; | 262 int64_t arrival_time_ms; |
| 276 int64_t now_ms = clock_->TimeInMilliseconds(); | 263 int64_t now_ms = clock_->TimeInMilliseconds(); |
| 277 if (packet_time.timestamp != -1) | 264 if (packet_time.timestamp != -1) |
| 278 arrival_time_ms = (packet_time.timestamp + 500) / 1000; | 265 arrival_time_ms = (packet_time.timestamp + 500) / 1000; |
| 279 else | 266 else |
| 280 arrival_time_ms = now_ms; | 267 arrival_time_ms = now_ms; |
| 281 | 268 |
| 282 { | 269 { |
| (...skipping 13 matching lines...) Expand all Loading... |
| 296 last_packet_log_ms_ = now_ms; | 283 last_packet_log_ms_ = now_ms; |
| 297 } | 284 } |
| 298 } | 285 } |
| 299 | 286 |
| 300 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_length, | 287 remote_bitrate_estimator_->IncomingPacket(arrival_time_ms, payload_length, |
| 301 header, true); | 288 header, true); |
| 302 header.payload_type_frequency = kVideoPayloadTypeFrequency; | 289 header.payload_type_frequency = kVideoPayloadTypeFrequency; |
| 303 | 290 |
| 304 bool in_order = IsPacketInOrder(header); | 291 bool in_order = IsPacketInOrder(header); |
| 305 rtp_payload_registry_->SetIncomingPayloadType(header); | 292 rtp_payload_registry_->SetIncomingPayloadType(header); |
| 306 int ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order) | 293 bool ret = ReceivePacket(rtp_packet, rtp_packet_length, header, in_order); |
| 307 ? 0 | |
| 308 : -1; | |
| 309 // Update receive statistics after ReceivePacket. | 294 // Update receive statistics after ReceivePacket. |
| 310 // Receive statistics will be reset if the payload type changes (make sure | 295 // Receive statistics will be reset if the payload type changes (make sure |
| 311 // that the first packet is included in the stats). | 296 // that the first packet is included in the stats). |
| 312 rtp_receive_statistics_->IncomingPacket( | 297 rtp_receive_statistics_->IncomingPacket( |
| 313 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); | 298 header, rtp_packet_length, IsPacketRetransmitted(header, in_order)); |
| 314 return ret; | 299 return ret; |
| 315 } | 300 } |
| 316 | 301 |
| 317 bool ViEReceiver::ReceivePacket(const uint8_t* packet, | 302 bool ViEReceiver::ReceivePacket(const uint8_t* packet, |
| 318 size_t packet_length, | 303 size_t packet_length, |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 400 } | 385 } |
| 401 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType; | 386 rtp_header.type.Video.codec = payload_specific.Video.videoCodecType; |
| 402 rtp_header.type.Video.rotation = kVideoRotation_0; | 387 rtp_header.type.Video.rotation = kVideoRotation_0; |
| 403 if (header.extension.hasVideoRotation) { | 388 if (header.extension.hasVideoRotation) { |
| 404 rtp_header.type.Video.rotation = | 389 rtp_header.type.Video.rotation = |
| 405 ConvertCVOByteToVideoRotation(header.extension.videoRotation); | 390 ConvertCVOByteToVideoRotation(header.extension.videoRotation); |
| 406 } | 391 } |
| 407 OnReceivedPayloadData(NULL, 0, &rtp_header); | 392 OnReceivedPayloadData(NULL, 0, &rtp_header); |
| 408 } | 393 } |
| 409 | 394 |
| 410 int ViEReceiver::InsertRTCPPacket(const uint8_t* rtcp_packet, | 395 bool ViEReceiver::DeliverRtcp(const uint8_t* rtcp_packet, |
| 411 size_t rtcp_packet_length) { | 396 size_t rtcp_packet_length) { |
| 412 { | 397 { |
| 413 rtc::CritScope lock(&receive_cs_); | 398 rtc::CritScope lock(&receive_cs_); |
| 414 if (!receiving_) { | 399 if (!receiving_) { |
| 415 return -1; | 400 return false; |
| 416 } | 401 } |
| 417 | 402 |
| 418 for (RtpRtcp* rtp_rtcp : rtp_rtcp_simulcast_) | 403 for (RtpRtcp* rtp_rtcp : rtp_rtcp_simulcast_) |
| 419 rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); | 404 rtp_rtcp->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); |
| 420 } | 405 } |
| 421 assert(rtp_rtcp_); // Should be set by owner at construction time. | 406 assert(rtp_rtcp_); // Should be set by owner at construction time. |
| 422 int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); | 407 int ret = rtp_rtcp_->IncomingRtcpPacket(rtcp_packet, rtcp_packet_length); |
| 423 if (ret != 0) { | 408 if (ret != 0) { |
| 424 return ret; | 409 return false; |
| 425 } | 410 } |
| 426 | 411 |
| 427 int64_t rtt = 0; | 412 int64_t rtt = 0; |
| 428 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL); | 413 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), &rtt, NULL, NULL, NULL); |
| 429 if (rtt == 0) { | 414 if (rtt == 0) { |
| 430 // Waiting for valid rtt. | 415 // Waiting for valid rtt. |
| 431 return 0; | 416 return true; |
| 432 } | 417 } |
| 433 uint32_t ntp_secs = 0; | 418 uint32_t ntp_secs = 0; |
| 434 uint32_t ntp_frac = 0; | 419 uint32_t ntp_frac = 0; |
| 435 uint32_t rtp_timestamp = 0; | 420 uint32_t rtp_timestamp = 0; |
| 436 if (0 != rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, | 421 if (0 != rtp_rtcp_->RemoteNTP(&ntp_secs, &ntp_frac, NULL, NULL, |
| 437 &rtp_timestamp)) { | 422 &rtp_timestamp)) { |
| 438 // Waiting for RTCP. | 423 // Waiting for RTCP. |
| 439 return 0; | 424 return true; |
| 440 } | 425 } |
| 441 ntp_estimator_->UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); | 426 ntp_estimator_->UpdateRtcpTimestamp(rtt, ntp_secs, ntp_frac, rtp_timestamp); |
| 442 | 427 |
| 443 return 0; | 428 return true; |
| 444 } | 429 } |
| 445 | 430 |
| 446 void ViEReceiver::StartReceive() { | 431 void ViEReceiver::StartReceive() { |
| 447 rtc::CritScope lock(&receive_cs_); | 432 rtc::CritScope lock(&receive_cs_); |
| 448 receiving_ = true; | 433 receiving_ = true; |
| 449 } | 434 } |
| 450 | 435 |
| 451 void ViEReceiver::StopReceive() { | 436 void ViEReceiver::StopReceive() { |
| 452 rtc::CritScope lock(&receive_cs_); | 437 rtc::CritScope lock(&receive_cs_); |
| 453 receiving_ = false; | 438 receiving_ = false; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 474 rtp_receive_statistics_->GetStatistician(header.ssrc); | 459 rtp_receive_statistics_->GetStatistician(header.ssrc); |
| 475 if (!statistician) | 460 if (!statistician) |
| 476 return false; | 461 return false; |
| 477 // Check if this is a retransmission. | 462 // Check if this is a retransmission. |
| 478 int64_t min_rtt = 0; | 463 int64_t min_rtt = 0; |
| 479 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); | 464 rtp_rtcp_->RTT(rtp_receiver_->SSRC(), NULL, NULL, &min_rtt, NULL); |
| 480 return !in_order && | 465 return !in_order && |
| 481 statistician->IsRetransmitOfOldPacket(header, min_rtt); | 466 statistician->IsRetransmitOfOldPacket(header, min_rtt); |
| 482 } | 467 } |
| 483 } // namespace webrtc | 468 } // namespace webrtc |
| OLD | NEW |