| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 payload_type_(payload_type) { | 94 payload_type_(payload_type) { |
| 95 } | 95 } |
| 96 | 96 |
| 97 PayloadRouter::~PayloadRouter() {} | 97 PayloadRouter::~PayloadRouter() {} |
| 98 | 98 |
| 99 size_t PayloadRouter::DefaultMaxPayloadLength() { | 99 size_t PayloadRouter::DefaultMaxPayloadLength() { |
| 100 const size_t kIpUdpSrtpLength = 44; | 100 const size_t kIpUdpSrtpLength = 44; |
| 101 return IP_PACKET_SIZE - kIpUdpSrtpLength; | 101 return IP_PACKET_SIZE - kIpUdpSrtpLength; |
| 102 } | 102 } |
| 103 | 103 |
| 104 void PayloadRouter::set_active(bool active) { | 104 void PayloadRouter::SetActive(bool active) { |
| 105 rtc::CritScope lock(&crit_); | 105 rtc::CritScope lock(&crit_); |
| 106 if (active_ == active) | 106 if (active_ == active) |
| 107 return; | 107 return; |
| 108 active_ = active; | 108 active_ = active; |
| 109 | 109 |
| 110 for (auto& module : rtp_modules_) { | 110 for (auto& module : rtp_modules_) { |
| 111 module->SetSendingStatus(active_); | 111 module->SetSendingStatus(active_); |
| 112 module->SetSendingMediaStatus(active_); | 112 module->SetSendingMediaStatus(active_); |
| 113 } | 113 } |
| 114 } | 114 } |
| 115 | 115 |
| 116 bool PayloadRouter::active() { | 116 bool PayloadRouter::IsActive() { |
| 117 rtc::CritScope lock(&crit_); | 117 rtc::CritScope lock(&crit_); |
| 118 return active_ && !rtp_modules_.empty(); | 118 return active_ && !rtp_modules_.empty(); |
| 119 } | 119 } |
| 120 | 120 |
| 121 EncodedImageCallback::Result PayloadRouter::OnEncodedImage( | 121 EncodedImageCallback::Result PayloadRouter::OnEncodedImage( |
| 122 const EncodedImage& encoded_image, | 122 const EncodedImage& encoded_image, |
| 123 const CodecSpecificInfo* codec_specific_info, | 123 const CodecSpecificInfo* codec_specific_info, |
| 124 const RTPFragmentationHeader* fragmentation) { | 124 const RTPFragmentationHeader* fragmentation) { |
| 125 rtc::CritScope lock(&crit_); | 125 rtc::CritScope lock(&crit_); |
| 126 RTC_DCHECK(!rtp_modules_.empty()); | 126 RTC_DCHECK(!rtp_modules_.empty()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 151 size_t min_payload_length = DefaultMaxPayloadLength(); | 151 size_t min_payload_length = DefaultMaxPayloadLength(); |
| 152 rtc::CritScope lock(&crit_); | 152 rtc::CritScope lock(&crit_); |
| 153 for (size_t i = 0; i < rtp_modules_.size(); ++i) { | 153 for (size_t i = 0; i < rtp_modules_.size(); ++i) { |
| 154 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | 154 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); |
| 155 if (module_payload_length < min_payload_length) | 155 if (module_payload_length < min_payload_length) |
| 156 min_payload_length = module_payload_length; | 156 min_payload_length = module_payload_length; |
| 157 } | 157 } |
| 158 return min_payload_length; | 158 return min_payload_length; |
| 159 } | 159 } |
| 160 | 160 |
| 161 void PayloadRouter::OnBitrateAllocationUpdated( |
| 162 const BitrateAllocation& bitrate) { |
| 163 rtc::CritScope lock(&crit_); |
| 164 if (IsActive()) { |
| 165 if (rtp_modules_.size() == 1) { |
| 166 // If spatial scalability is enabled, it is covered by a single stream. |
| 167 rtp_modules_[0]->SetVideoBitrateAllocation(bitrate); |
| 168 } else { |
| 169 // Simulcast is in use, split the BitrateAllocation into one struct per |
| 170 // rtp stream, moving over the temporal layer allocation. |
| 171 for (size_t si = 0; si < rtp_modules_.size(); ++si) { |
| 172 BitrateAllocation layer_bitrate; |
| 173 for (int tl = 0; tl < kMaxTemporalStreams; ++tl) |
| 174 layer_bitrate.SetBitrate(0, tl, bitrate.GetBitrate(si, tl)); |
| 175 rtp_modules_[si]->SetVideoBitrateAllocation(layer_bitrate); |
| 176 } |
| 177 } |
| 178 } |
| 179 } |
| 180 |
| 161 } // namespace webrtc | 181 } // namespace webrtc |
| OLD | NEW |