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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 371 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
372 } | 372 } |
373 // Register new active modules. | 373 // Register new active modules. |
374 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { | 374 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { |
375 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); | 375 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); |
376 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], sender_); | 376 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], sender_); |
377 } | 377 } |
378 return 0; | 378 return 0; |
379 } | 379 } |
380 | 380 |
381 void ViEChannel::SetRTCPMode(const RtcpMode rtcp_mode) { | |
382 RTC_DCHECK(sender_); | |
383 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
384 rtp_rtcp->SetRTCPStatus(rtcp_mode); | |
385 } | |
386 | |
387 void ViEChannel::SetProtectionMode(bool enable_nack, | 381 void ViEChannel::SetProtectionMode(bool enable_nack, |
388 bool enable_fec, | 382 bool enable_fec, |
389 int payload_type_red, | 383 int payload_type_red, |
390 int payload_type_fec) { | 384 int payload_type_fec) { |
391 // Validate payload types. If either RED or FEC payload types are set then | 385 // Validate payload types. If either RED or FEC payload types are set then |
392 // both should be. If FEC is enabled then they both have to be set. | 386 // both should be. If FEC is enabled then they both have to be set. |
393 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { | 387 if (enable_fec || payload_type_red != -1 || payload_type_fec != -1) { |
394 RTC_DCHECK_GE(payload_type_red, 0); | 388 RTC_DCHECK_GE(payload_type_red, 0); |
395 RTC_DCHECK_GE(payload_type_fec, 0); | 389 RTC_DCHECK_GE(payload_type_fec, 0); |
396 RTC_DCHECK_LE(payload_type_red, 127); | 390 RTC_DCHECK_LE(payload_type_red, 127); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 440 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
447 rtp_rtcp->SetStorePacketsStatus(false, 0); | 441 rtp_rtcp->SetStorePacketsStatus(false, 0); |
448 // When NACK is off, allow decoding with errors. Otherwise, the video | 442 // When NACK is off, allow decoding with errors. Otherwise, the video |
449 // will freeze, and will only recover with a complete key frame. | 443 // will freeze, and will only recover with a complete key frame. |
450 vcm_->SetDecodeErrorMode(kWithErrors); | 444 vcm_->SetDecodeErrorMode(kWithErrors); |
451 } | 445 } |
452 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); | 446 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); |
453 } | 447 } |
454 } | 448 } |
455 | 449 |
456 bool ViEChannel::IsSendingFecEnabled() { | |
457 bool fec_enabled = false; | |
458 uint8_t pltype_red = 0; | |
459 uint8_t pltype_fec = 0; | |
460 | |
461 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
462 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); | |
463 if (fec_enabled) | |
464 return true; | |
465 } | |
466 return false; | |
467 } | |
468 | |
469 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) { | 450 int ViEChannel::GetRequiredNackListSize(int target_delay_ms) { |
470 // The max size of the nack list should be large enough to accommodate the | 451 // The max size of the nack list should be large enough to accommodate the |
471 // the number of packets (frames) resulting from the increased delay. | 452 // the number of packets (frames) resulting from the increased delay. |
472 // Roughly estimating for ~40 packets per frame @ 30fps. | 453 // Roughly estimating for ~40 packets per frame @ 30fps. |
473 return target_delay_ms * 40 * 30 / 1000; | 454 return target_delay_ms * 40 * 30 / 1000; |
474 } | 455 } |
475 | 456 |
476 int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { | 457 int ViEChannel::SetSendTimestampOffsetStatus(bool enable, int id) { |
477 // Disable any previous registrations of this extension to avoid errors. | 458 // Disable any previous registrations of this extension to avoid errors. |
478 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 459 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 return 0; | 512 return 0; |
532 // Enable the extension. | 513 // Enable the extension. |
533 int error = 0; | 514 int error = 0; |
534 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 515 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
535 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( | 516 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( |
536 kRtpExtensionTransportSequenceNumber, id); | 517 kRtpExtensionTransportSequenceNumber, id); |
537 } | 518 } |
538 return error; | 519 return error; |
539 } | 520 } |
540 | 521 |
541 int32_t ViEChannel::SetSSRC(const uint32_t SSRC, | |
542 const StreamType usage, | |
543 const uint8_t simulcast_idx) { | |
544 RTC_DCHECK(sender_); | |
545 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[simulcast_idx]; | |
546 if (usage == kViEStreamTypeRtx) { | |
547 rtp_rtcp->SetRtxSsrc(SSRC); | |
548 } else { | |
549 rtp_rtcp->SetSSRC(SSRC); | |
550 } | |
551 return 0; | |
552 } | |
553 | |
554 int32_t ViEChannel::GetLocalSSRC(uint8_t idx, unsigned int* ssrc) { | |
555 RTC_DCHECK_LE(idx, rtp_rtcp_modules_.size()); | |
556 *ssrc = rtp_rtcp_modules_[idx]->SSRC(); | |
557 return 0; | |
558 } | |
559 | |
560 int ViEChannel::SetRtxSendPayloadType(int payload_type, | |
561 int associated_payload_type) { | |
562 RTC_DCHECK(sender_); | |
563 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
564 rtp_rtcp->SetRtxSendPayloadType(payload_type, associated_payload_type); | |
565 SetRtxSendStatus(true); | |
566 return 0; | |
567 } | |
568 | |
569 void ViEChannel::SetRtxSendStatus(bool enable) { | |
570 int rtx_settings = | |
571 enable ? kRtxRetransmitted | kRtxRedundantPayloads : kRtxOff; | |
572 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
573 rtp_rtcp->SetRtxSendStatus(rtx_settings); | |
574 } | |
575 | |
576 void ViEChannel::SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state) { | |
577 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | |
578 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
579 if (rtp_rtcp->SetRtpStateForSsrc(ssrc, rtp_state)) | |
580 return; | |
581 } | |
582 } | |
583 | |
584 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { | 522 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { |
585 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | 523 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); |
586 RtpState rtp_state; | 524 RtpState rtp_state; |
587 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 525 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
588 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_state)) | 526 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_state)) |
589 return rtp_state; | 527 return rtp_state; |
590 } | 528 } |
591 LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc; | 529 LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc; |
592 return rtp_state; | 530 return rtp_state; |
593 } | 531 } |
594 | 532 |
595 // TODO(pbos): Set CNAME on all modules. | |
596 int32_t ViEChannel::SetRTCPCName(const char* rtcp_cname) { | |
597 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | |
598 return rtp_rtcp_modules_[0]->SetCNAME(rtcp_cname); | |
599 } | |
600 | |
601 int32_t ViEChannel::GetRemoteRTCPCName(char rtcp_cname[]) { | |
602 uint32_t remoteSSRC = vie_receiver_.GetRemoteSsrc(); | |
603 return rtp_rtcp_modules_[0]->RemoteCNAME(remoteSSRC, rtcp_cname); | |
604 } | |
605 | |
606 void ViEChannel::RegisterSendChannelRtcpStatisticsCallback( | |
607 RtcpStatisticsCallback* callback) { | |
608 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
609 rtp_rtcp->RegisterRtcpStatisticsCallback(callback); | |
610 } | |
611 | |
612 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( | 533 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( |
613 RtcpPacketTypeCounterObserver* observer) { | 534 RtcpPacketTypeCounterObserver* observer) { |
614 rtcp_packet_type_counter_observer_.Set(observer); | 535 rtcp_packet_type_counter_observer_.Set(observer); |
615 } | 536 } |
616 | 537 |
617 void ViEChannel::GetSendStreamDataCounters( | 538 void ViEChannel::GetSendStreamDataCounters( |
618 StreamDataCounters* rtp_counters, | 539 StreamDataCounters* rtp_counters, |
619 StreamDataCounters* rtx_counters) const { | 540 StreamDataCounters* rtx_counters) const { |
620 *rtp_counters = StreamDataCounters(); | 541 *rtp_counters = StreamDataCounters(); |
621 *rtx_counters = StreamDataCounters(); | 542 *rtx_counters = StreamDataCounters(); |
(...skipping 17 matching lines...) Expand all Loading... |
639 uint32_t rtx_ssrc = 0; | 560 uint32_t rtx_ssrc = 0; |
640 if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) { | 561 if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) { |
641 StreamStatistician* statistician = | 562 StreamStatistician* statistician = |
642 vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc); | 563 vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc); |
643 if (statistician) { | 564 if (statistician) { |
644 statistician->GetReceiveStreamDataCounters(rtx_counters); | 565 statistician->GetReceiveStreamDataCounters(rtx_counters); |
645 } | 566 } |
646 } | 567 } |
647 } | 568 } |
648 | 569 |
649 void ViEChannel::RegisterSendChannelRtpStatisticsCallback( | |
650 StreamDataCountersCallback* callback) { | |
651 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
652 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(callback); | |
653 } | |
654 | |
655 void ViEChannel::GetSendRtcpPacketTypeCounter( | 570 void ViEChannel::GetSendRtcpPacketTypeCounter( |
656 RtcpPacketTypeCounter* packet_counter) const { | 571 RtcpPacketTypeCounter* packet_counter) const { |
657 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = | 572 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = |
658 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); | 573 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); |
659 | 574 |
660 RtcpPacketTypeCounter counter; | 575 RtcpPacketTypeCounter counter; |
661 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 576 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
662 counter.Add(counter_map[rtp_rtcp->SSRC()]); | 577 counter.Add(counter_map[rtp_rtcp->SSRC()]); |
663 *packet_counter = counter; | 578 *packet_counter = counter; |
664 } | 579 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 if (!rtp_rtcp_modules_[0]->Sending()) { | 625 if (!rtp_rtcp_modules_[0]->Sending()) { |
711 return -1; | 626 return -1; |
712 } | 627 } |
713 | 628 |
714 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 629 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
715 rtp_rtcp->SetSendingStatus(false); | 630 rtp_rtcp->SetSendingStatus(false); |
716 } | 631 } |
717 return 0; | 632 return 0; |
718 } | 633 } |
719 | 634 |
720 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 635 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { |
721 RTC_DCHECK(sender_); | 636 return rtp_rtcp_modules_; |
722 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
723 rtp_rtcp->SetMaxTransferUnit(mtu); | |
724 return 0; | |
725 } | |
726 | |
727 RtpRtcp* ViEChannel::rtp_rtcp() { | |
728 return rtp_rtcp_modules_[0]; | |
729 } | 637 } |
730 | 638 |
731 ViEReceiver* ViEChannel::vie_receiver() { | 639 ViEReceiver* ViEChannel::vie_receiver() { |
732 return &vie_receiver_; | 640 return &vie_receiver_; |
733 } | 641 } |
734 | 642 |
735 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { | 643 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { |
736 return vcm_protection_callback_.get(); | 644 return vcm_protection_callback_.get(); |
737 } | 645 } |
738 | 646 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
938 rtc::CritScope lock(&crit_); | 846 rtc::CritScope lock(&crit_); |
939 receive_stats_callback_ = receive_statistics_proxy; | 847 receive_stats_callback_ = receive_statistics_proxy; |
940 } | 848 } |
941 | 849 |
942 void ViEChannel::SetIncomingVideoStream( | 850 void ViEChannel::SetIncomingVideoStream( |
943 IncomingVideoStream* incoming_video_stream) { | 851 IncomingVideoStream* incoming_video_stream) { |
944 rtc::CritScope lock(&crit_); | 852 rtc::CritScope lock(&crit_); |
945 incoming_video_stream_ = incoming_video_stream; | 853 incoming_video_stream_ = incoming_video_stream; |
946 } | 854 } |
947 } // namespace webrtc | 855 } // namespace webrtc |
OLD | NEW |