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 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); | 402 packet_router_->RemoveRtpModule(rtp_rtcp_modules_[i], sender_); |
403 } | 403 } |
404 // Register new active modules. | 404 // Register new active modules. |
405 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { | 405 for (size_t i = num_prev_active_modules; i < num_active_modules; ++i) { |
406 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); | 406 module_process_thread_->RegisterModule(rtp_rtcp_modules_[i]); |
407 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], sender_); | 407 packet_router_->AddRtpModule(rtp_rtcp_modules_[i], sender_); |
408 } | 408 } |
409 return 0; | 409 return 0; |
410 } | 410 } |
411 | 411 |
412 void ViEChannel::SetRTCPMode(const RtcpMode rtcp_mode) { | |
413 RTC_DCHECK(sender_); | |
414 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
415 rtp_rtcp->SetRTCPStatus(rtcp_mode); | |
416 } | |
417 | |
418 void ViEChannel::SetProtectionMode(bool enable_nack, | 412 void ViEChannel::SetProtectionMode(bool enable_nack, |
419 bool enable_fec, | 413 bool enable_fec, |
420 int payload_type_red, | 414 int payload_type_red, |
421 int payload_type_fec) { | 415 int payload_type_fec) { |
422 // Validate payload types. | 416 // Validate payload types. |
423 if (enable_fec) { | 417 if (enable_fec) { |
424 RTC_DCHECK_GE(payload_type_red, 0); | 418 RTC_DCHECK_GE(payload_type_red, 0); |
425 RTC_DCHECK_GE(payload_type_fec, 0); | 419 RTC_DCHECK_GE(payload_type_fec, 0); |
426 RTC_DCHECK_LE(payload_type_red, 127); | 420 RTC_DCHECK_LE(payload_type_red, 127); |
427 RTC_DCHECK_LE(payload_type_fec, 127); | 421 RTC_DCHECK_LE(payload_type_fec, 127); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
475 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 469 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
476 rtp_rtcp->SetStorePacketsStatus(false, 0); | 470 rtp_rtcp->SetStorePacketsStatus(false, 0); |
477 // When NACK is off, allow decoding with errors. Otherwise, the video | 471 // When NACK is off, allow decoding with errors. Otherwise, the video |
478 // will freeze, and will only recover with a complete key frame. | 472 // will freeze, and will only recover with a complete key frame. |
479 vcm_->SetDecodeErrorMode(kWithErrors); | 473 vcm_->SetDecodeErrorMode(kWithErrors); |
480 } | 474 } |
481 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); | 475 vie_receiver_.SetNackStatus(false, max_nack_reordering_threshold_); |
482 } | 476 } |
483 } | 477 } |
484 | 478 |
485 bool ViEChannel::IsSendingFecEnabled() { | |
486 bool fec_enabled = false; | |
487 uint8_t pltype_red = 0; | |
488 uint8_t pltype_fec = 0; | |
489 | |
490 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
491 rtp_rtcp->GenericFECStatus(&fec_enabled, &pltype_red, &pltype_fec); | |
492 if (fec_enabled) | |
493 return true; | |
494 } | |
495 return false; | |
496 } | |
497 | |
498 int ViEChannel::SetSenderBufferingMode(int target_delay_ms) { | 479 int ViEChannel::SetSenderBufferingMode(int target_delay_ms) { |
499 if ((target_delay_ms < 0) || (target_delay_ms > kMaxTargetDelayMs)) { | 480 if ((target_delay_ms < 0) || (target_delay_ms > kMaxTargetDelayMs)) { |
500 LOG(LS_ERROR) << "Invalid send buffer value."; | 481 LOG(LS_ERROR) << "Invalid send buffer value."; |
501 return -1; | 482 return -1; |
502 } | 483 } |
503 if (target_delay_ms == 0) { | 484 if (target_delay_ms == 0) { |
504 // Real-time mode. | 485 // Real-time mode. |
505 nack_history_size_sender_ = kMinSendSidePacketHistorySize; | 486 nack_history_size_sender_ = kMinSendSidePacketHistorySize; |
506 } else { | 487 } else { |
507 nack_history_size_sender_ = GetRequiredNackListSize(target_delay_ms); | 488 nack_history_size_sender_ = GetRequiredNackListSize(target_delay_ms); |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 return 0; | 561 return 0; |
581 // Enable the extension. | 562 // Enable the extension. |
582 int error = 0; | 563 int error = 0; |
583 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 564 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
584 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( | 565 error |= rtp_rtcp->RegisterSendRtpHeaderExtension( |
585 kRtpExtensionTransportSequenceNumber, id); | 566 kRtpExtensionTransportSequenceNumber, id); |
586 } | 567 } |
587 return error; | 568 return error; |
588 } | 569 } |
589 | 570 |
590 int32_t ViEChannel::SetSSRC(const uint32_t SSRC, | |
591 const StreamType usage, | |
592 const uint8_t simulcast_idx) { | |
593 RTC_DCHECK(sender_); | |
594 RtpRtcp* rtp_rtcp = rtp_rtcp_modules_[simulcast_idx]; | |
595 if (usage == kViEStreamTypeRtx) { | |
596 rtp_rtcp->SetRtxSsrc(SSRC); | |
597 } else { | |
598 rtp_rtcp->SetSSRC(SSRC); | |
599 } | |
600 return 0; | |
601 } | |
602 | |
603 int32_t ViEChannel::GetLocalSSRC(uint8_t idx, unsigned int* ssrc) { | |
604 RTC_DCHECK_LE(idx, rtp_rtcp_modules_.size()); | |
605 *ssrc = rtp_rtcp_modules_[idx]->SSRC(); | |
606 return 0; | |
607 } | |
608 | |
609 int ViEChannel::SetRtxSendPayloadType(int payload_type, | |
610 int associated_payload_type) { | |
611 RTC_DCHECK(sender_); | |
612 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
613 rtp_rtcp->SetRtxSendPayloadType(payload_type, associated_payload_type); | |
614 SetRtxSendStatus(true); | |
615 return 0; | |
616 } | |
617 | |
618 void ViEChannel::SetRtxSendStatus(bool enable) { | |
619 int rtx_settings = | |
620 enable ? kRtxRetransmitted | kRtxRedundantPayloads : kRtxOff; | |
621 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
622 rtp_rtcp->SetRtxSendStatus(rtx_settings); | |
623 } | |
624 | |
625 void ViEChannel::SetRtpStateForSsrc(uint32_t ssrc, const RtpState& rtp_state) { | |
626 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | |
627 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | |
628 if (rtp_rtcp->SetRtpStateForSsrc(ssrc, rtp_state)) | |
629 return; | |
630 } | |
631 } | |
632 | |
633 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { | 571 RtpState ViEChannel::GetRtpStateForSsrc(uint32_t ssrc) const { |
634 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | 572 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); |
635 RtpState rtp_state; | 573 RtpState rtp_state; |
636 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 574 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
637 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_state)) | 575 if (rtp_rtcp->GetRtpStateForSsrc(ssrc, &rtp_state)) |
638 return rtp_state; | 576 return rtp_state; |
639 } | 577 } |
640 LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc; | 578 LOG(LS_ERROR) << "Couldn't get RTP state for ssrc: " << ssrc; |
641 return rtp_state; | 579 return rtp_state; |
642 } | 580 } |
643 | 581 |
644 // TODO(pbos): Set CNAME on all modules. | |
645 int32_t ViEChannel::SetRTCPCName(const char* rtcp_cname) { | |
646 RTC_DCHECK(!rtp_rtcp_modules_[0]->Sending()); | |
647 return rtp_rtcp_modules_[0]->SetCNAME(rtcp_cname); | |
648 } | |
649 | |
650 int32_t ViEChannel::GetRemoteRTCPCName(char rtcp_cname[]) { | |
651 uint32_t remoteSSRC = vie_receiver_.GetRemoteSsrc(); | |
652 return rtp_rtcp_modules_[0]->RemoteCNAME(remoteSSRC, rtcp_cname); | |
653 } | |
654 | |
655 int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, | 582 int32_t ViEChannel::GetSendRtcpStatistics(uint16_t* fraction_lost, |
656 uint32_t* cumulative_lost, | 583 uint32_t* cumulative_lost, |
657 uint32_t* extended_max, | 584 uint32_t* extended_max, |
658 uint32_t* jitter_samples, | 585 uint32_t* jitter_samples, |
659 int64_t* rtt_ms) const { | 586 int64_t* rtt_ms) const { |
660 // Aggregate the report blocks associated with streams sent on this channel. | 587 // Aggregate the report blocks associated with streams sent on this channel. |
661 std::vector<RTCPReportBlock> report_blocks; | 588 std::vector<RTCPReportBlock> report_blocks; |
662 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 589 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
663 rtp_rtcp->RemoteRTCPStat(&report_blocks); | 590 rtp_rtcp->RemoteRTCPStat(&report_blocks); |
664 | 591 |
(...skipping 27 matching lines...) Expand all Loading... |
692 int64_t dummy; | 619 int64_t dummy; |
693 int64_t rtt = 0; | 620 int64_t rtt = 0; |
694 if (rtp_rtcp_modules_[0]->RTT(remote_ssrc, &rtt, &dummy, &dummy, &dummy) != | 621 if (rtp_rtcp_modules_[0]->RTT(remote_ssrc, &rtt, &dummy, &dummy, &dummy) != |
695 0) { | 622 0) { |
696 return -1; | 623 return -1; |
697 } | 624 } |
698 *rtt_ms = rtt; | 625 *rtt_ms = rtt; |
699 return 0; | 626 return 0; |
700 } | 627 } |
701 | 628 |
702 void ViEChannel::RegisterSendChannelRtcpStatisticsCallback( | |
703 RtcpStatisticsCallback* callback) { | |
704 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
705 rtp_rtcp->RegisterRtcpStatisticsCallback(callback); | |
706 } | |
707 | |
708 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( | 629 void ViEChannel::RegisterRtcpPacketTypeCounterObserver( |
709 RtcpPacketTypeCounterObserver* observer) { | 630 RtcpPacketTypeCounterObserver* observer) { |
710 rtcp_packet_type_counter_observer_.Set(observer); | 631 rtcp_packet_type_counter_observer_.Set(observer); |
711 } | 632 } |
712 | 633 |
713 void ViEChannel::GetSendStreamDataCounters( | 634 void ViEChannel::GetSendStreamDataCounters( |
714 StreamDataCounters* rtp_counters, | 635 StreamDataCounters* rtp_counters, |
715 StreamDataCounters* rtx_counters) const { | 636 StreamDataCounters* rtx_counters) const { |
716 *rtp_counters = StreamDataCounters(); | 637 *rtp_counters = StreamDataCounters(); |
717 *rtx_counters = StreamDataCounters(); | 638 *rtx_counters = StreamDataCounters(); |
(...skipping 17 matching lines...) Expand all Loading... |
735 uint32_t rtx_ssrc = 0; | 656 uint32_t rtx_ssrc = 0; |
736 if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) { | 657 if (vie_receiver_.GetRtxSsrc(&rtx_ssrc)) { |
737 StreamStatistician* statistician = | 658 StreamStatistician* statistician = |
738 vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc); | 659 vie_receiver_.GetReceiveStatistics()->GetStatistician(rtx_ssrc); |
739 if (statistician) { | 660 if (statistician) { |
740 statistician->GetReceiveStreamDataCounters(rtx_counters); | 661 statistician->GetReceiveStreamDataCounters(rtx_counters); |
741 } | 662 } |
742 } | 663 } |
743 } | 664 } |
744 | 665 |
745 void ViEChannel::RegisterSendChannelRtpStatisticsCallback( | |
746 StreamDataCountersCallback* callback) { | |
747 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
748 rtp_rtcp->RegisterSendChannelRtpStatisticsCallback(callback); | |
749 } | |
750 | |
751 void ViEChannel::GetSendRtcpPacketTypeCounter( | 666 void ViEChannel::GetSendRtcpPacketTypeCounter( |
752 RtcpPacketTypeCounter* packet_counter) const { | 667 RtcpPacketTypeCounter* packet_counter) const { |
753 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = | 668 std::map<uint32_t, RtcpPacketTypeCounter> counter_map = |
754 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); | 669 rtcp_packet_type_counter_observer_.GetPacketTypeCounterMap(); |
755 | 670 |
756 RtcpPacketTypeCounter counter; | 671 RtcpPacketTypeCounter counter; |
757 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | 672 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) |
758 counter.Add(counter_map[rtp_rtcp->SSRC()]); | 673 counter.Add(counter_map[rtp_rtcp->SSRC()]); |
759 *packet_counter = counter; | 674 *packet_counter = counter; |
760 } | 675 } |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
806 if (!rtp_rtcp_modules_[0]->Sending()) { | 721 if (!rtp_rtcp_modules_[0]->Sending()) { |
807 return -1; | 722 return -1; |
808 } | 723 } |
809 | 724 |
810 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { | 725 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) { |
811 rtp_rtcp->SetSendingStatus(false); | 726 rtp_rtcp->SetSendingStatus(false); |
812 } | 727 } |
813 return 0; | 728 return 0; |
814 } | 729 } |
815 | 730 |
816 int32_t ViEChannel::SetMTU(uint16_t mtu) { | 731 const std::vector<RtpRtcp*>& ViEChannel::rtp_rtcp() const { |
817 RTC_DCHECK(sender_); | 732 return rtp_rtcp_modules_; |
818 for (RtpRtcp* rtp_rtcp : rtp_rtcp_modules_) | |
819 rtp_rtcp->SetMaxTransferUnit(mtu); | |
820 return 0; | |
821 } | |
822 | |
823 RtpRtcp* ViEChannel::rtp_rtcp() { | |
824 return rtp_rtcp_modules_[0]; | |
825 } | 733 } |
826 | 734 |
827 ViEReceiver* ViEChannel::vie_receiver() { | 735 ViEReceiver* ViEChannel::vie_receiver() { |
828 return &vie_receiver_; | 736 return &vie_receiver_; |
829 } | 737 } |
830 | 738 |
831 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { | 739 VCMProtectionCallback* ViEChannel::vcm_protection_callback() { |
832 return vcm_protection_callback_.get(); | 740 return vcm_protection_callback_.get(); |
833 } | 741 } |
834 | 742 |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1051 rtc::CritScope lock(&crit_); | 959 rtc::CritScope lock(&crit_); |
1052 receive_stats_callback_ = receive_statistics_proxy; | 960 receive_stats_callback_ = receive_statistics_proxy; |
1053 } | 961 } |
1054 | 962 |
1055 void ViEChannel::SetIncomingVideoStream( | 963 void ViEChannel::SetIncomingVideoStream( |
1056 IncomingVideoStream* incoming_video_stream) { | 964 IncomingVideoStream* incoming_video_stream) { |
1057 rtc::CritScope lock(&crit_); | 965 rtc::CritScope lock(&crit_); |
1058 incoming_video_stream_ = incoming_video_stream; | 966 incoming_video_stream_ = incoming_video_stream; |
1059 } | 967 } |
1060 } // namespace webrtc | 968 } // namespace webrtc |
OLD | NEW |