Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(477)

Side by Side Diff: webrtc/modules/rtp_rtcp/source/rtcp_sender.cc

Issue 2254703003: Remove TMMBRSet class (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Feedback Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 last_rtp_timestamp_(0), 165 last_rtp_timestamp_(0),
166 last_frame_capture_time_ms_(-1), 166 last_frame_capture_time_ms_(-1),
167 ssrc_(0), 167 ssrc_(0),
168 remote_ssrc_(0), 168 remote_ssrc_(0),
169 receive_statistics_(receive_statistics), 169 receive_statistics_(receive_statistics),
170 170
171 sequence_number_fir_(0), 171 sequence_number_fir_(0),
172 172
173 remb_bitrate_(0), 173 remb_bitrate_(0),
174 174
175 tmmbr_send_(0), 175 tmmbr_send_bps_(0),
176 packet_oh_send_(0), 176 packet_oh_send_(0),
177 max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default. 177 max_payload_length_(IP_PACKET_SIZE - 28), // IPv4 + UDP by default.
178 178
179 app_sub_type_(0), 179 app_sub_type_(0),
180 app_name_(0), 180 app_name_(0),
181 app_data_(nullptr), 181 app_data_(nullptr),
182 app_length_(0), 182 app_length_(0),
183 183
184 xr_send_receiver_reference_time_enabled_(false), 184 xr_send_receiver_reference_time_enabled_(false),
185 packet_type_counter_observer_(packet_type_counter_observer) { 185 packet_type_counter_observer_(packet_type_counter_observer) {
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
570 remb->WithBitrateBps(remb_bitrate_); 570 remb->WithBitrateBps(remb_bitrate_);
571 571
572 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"), 572 TRACE_EVENT_INSTANT0(TRACE_DISABLED_BY_DEFAULT("webrtc_rtp"),
573 "RTCPSender::REMB"); 573 "RTCPSender::REMB");
574 574
575 return std::unique_ptr<rtcp::RtcpPacket>(remb); 575 return std::unique_ptr<rtcp::RtcpPacket>(remb);
576 } 576 }
577 577
578 void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) { 578 void RTCPSender::SetTargetBitrate(unsigned int target_bitrate) {
579 rtc::CritScope lock(&critical_section_rtcp_sender_); 579 rtc::CritScope lock(&critical_section_rtcp_sender_);
580 tmmbr_send_ = target_bitrate / 1000; 580 tmmbr_send_bps_ = target_bitrate;
581 } 581 }
582 582
583 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR( 583 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBR(
584 const RtcpContext& ctx) { 584 const RtcpContext& ctx) {
585 if (ctx.feedback_state_.module == nullptr) 585 if (ctx.feedback_state_.module == nullptr)
586 return nullptr; 586 return nullptr;
587 // Before sending the TMMBR check the received TMMBN, only an owner is 587 // Before sending the TMMBR check the received TMMBN, only an owner is
588 // allowed to raise the bitrate: 588 // allowed to raise the bitrate:
589 // * If the sender is an owner of the TMMBN -> send TMMBR 589 // * If the sender is an owner of the TMMBN -> send TMMBR
590 // * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR 590 // * If not an owner but the TMMBR would enter the TMMBN -> send TMMBR
591 591
592 // get current bounding set from RTCP receiver 592 // get current bounding set from RTCP receiver
593 bool tmmbrOwner = false; 593 bool tmmbr_owner = false;
594 TMMBRSet candidates;
595 594
596 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which 595 // holding critical_section_rtcp_sender_ while calling RTCPreceiver which
597 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but 596 // will accuire criticalSectionRTCPReceiver_ is a potental deadlock but
598 // since RTCPreceiver is not doing the reverse we should be fine 597 // since RTCPreceiver is not doing the reverse we should be fine
599 int32_t lengthOfBoundingSet = 598 std::vector<rtcp::TmmbItem> candidates =
600 ctx.feedback_state_.module->BoundingSet(&tmmbrOwner, &candidates); 599 ctx.feedback_state_.module->BoundingSet(&tmmbr_owner);
601 600
602 if (lengthOfBoundingSet > 0) { 601 if (!candidates.empty()) {
603 for (int32_t i = 0; i < lengthOfBoundingSet; i++) { 602 for (const auto& candidate : candidates) {
604 if (candidates.Tmmbr(i) == tmmbr_send_ && 603 if (candidate.bitrate_bps() == tmmbr_send_bps_ &&
605 candidates.PacketOH(i) == packet_oh_send_) { 604 candidate.packet_overhead() == packet_oh_send_) {
606 // Do not send the same tuple. 605 // Do not send the same tuple.
607 return nullptr; 606 return nullptr;
608 } 607 }
609 } 608 }
610 if (!tmmbrOwner) { 609 if (!tmmbr_owner) {
611 // use received bounding set as candidate set 610 // Use received bounding set as candidate set.
612 // add current tuple 611 // Add current tuple.
613 candidates.SetEntry(lengthOfBoundingSet, tmmbr_send_, packet_oh_send_, 612 candidates.emplace_back(ssrc_, tmmbr_send_bps_, packet_oh_send_);
614 ssrc_);
615 613
616 // find bounding set 614 // Find bounding set.
617 std::vector<rtcp::TmmbItem> bounding = 615 std::vector<rtcp::TmmbItem> bounding =
618 TMMBRHelp::FindBoundingSet(std::move(candidates)); 616 TMMBRHelp::FindBoundingSet(std::move(candidates));
619 tmmbrOwner = TMMBRHelp::IsOwner(bounding, ssrc_); 617 tmmbr_owner = TMMBRHelp::IsOwner(bounding, ssrc_);
620 if (!tmmbrOwner) { 618 if (!tmmbr_owner) {
621 // Did not enter bounding set, no meaning to send this request. 619 // Did not enter bounding set, no meaning to send this request.
622 return nullptr; 620 return nullptr;
623 } 621 }
624 } 622 }
625 } 623 }
626 624
627 if (!tmmbr_send_) 625 if (!tmmbr_send_bps_)
628 return nullptr; 626 return nullptr;
629 627
630 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr(); 628 rtcp::Tmmbr* tmmbr = new rtcp::Tmmbr();
631 tmmbr->From(ssrc_); 629 tmmbr->From(ssrc_);
632 rtcp::TmmbItem request; 630 rtcp::TmmbItem request;
633 request.set_ssrc(remote_ssrc_); 631 request.set_ssrc(remote_ssrc_);
634 request.set_bitrate_bps(tmmbr_send_ * 1000); 632 request.set_bitrate_bps(tmmbr_send_bps_);
635 request.set_packet_overhead(packet_oh_send_); 633 request.set_packet_overhead(packet_oh_send_);
636 tmmbr->WithTmmbr(request); 634 tmmbr->WithTmmbr(request);
637 635
638 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr); 636 return std::unique_ptr<rtcp::RtcpPacket>(tmmbr);
639 } 637 }
640 638
641 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN( 639 std::unique_ptr<rtcp::RtcpPacket> RTCPSender::BuildTMMBN(
642 const RtcpContext& ctx) { 640 const RtcpContext& ctx) {
643 rtcp::Tmmbn* tmmbn = new rtcp::Tmmbn(); 641 rtcp::Tmmbn* tmmbn = new rtcp::Tmmbn();
644 tmmbn->From(ssrc_); 642 tmmbn->From(ssrc_);
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 // but we can't because of an incorrect warning (C4822) in MVS 2013. 1049 // but we can't because of an incorrect warning (C4822) in MVS 2013.
1052 } sender(transport_, event_log_); 1050 } sender(transport_, event_log_);
1053 1051
1054 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE)); 1052 RTC_DCHECK_LE(max_payload_length_, static_cast<size_t>(IP_PACKET_SIZE));
1055 uint8_t buffer[IP_PACKET_SIZE]; 1053 uint8_t buffer[IP_PACKET_SIZE];
1056 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) && 1054 return packet.BuildExternalBuffer(buffer, max_payload_length_, &sender) &&
1057 !sender.send_failure_; 1055 !sender.send_failure_;
1058 } 1056 }
1059 1057
1060 } // namespace webrtc 1058 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/rtp_rtcp/source/rtcp_sender.h ('k') | webrtc/modules/rtp_rtcp/source/rtp_rtcp_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698