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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 | 91 |
92 PayloadRouter::PayloadRouter(const std::vector<RtpRtcp*>& rtp_modules, | 92 PayloadRouter::PayloadRouter(const std::vector<RtpRtcp*>& rtp_modules, |
93 int payload_type) | 93 int payload_type) |
94 : active_(false), | 94 : active_(false), |
95 rtp_modules_(rtp_modules), | 95 rtp_modules_(rtp_modules), |
96 payload_type_(payload_type) { | 96 payload_type_(payload_type) { |
97 } | 97 } |
98 | 98 |
99 PayloadRouter::~PayloadRouter() {} | 99 PayloadRouter::~PayloadRouter() {} |
100 | 100 |
101 size_t PayloadRouter::DefaultMaxPayloadLength() { | |
102 const size_t kIpUdpSrtpLength = 44; | |
103 return IP_PACKET_SIZE - kIpUdpSrtpLength; | |
104 } | |
105 | |
106 void PayloadRouter::SetActive(bool active) { | 101 void PayloadRouter::SetActive(bool active) { |
107 rtc::CritScope lock(&crit_); | 102 rtc::CritScope lock(&crit_); |
108 if (active_ == active) | 103 if (active_ == active) |
109 return; | 104 return; |
110 active_ = active; | 105 active_ = active; |
111 | 106 |
112 for (auto& module : rtp_modules_) { | 107 for (auto& module : rtp_modules_) { |
113 module->SetSendingStatus(active_); | 108 module->SetSendingStatus(active_); |
114 module->SetSendingMediaStatus(active_); | 109 module->SetSendingMediaStatus(active_); |
115 } | 110 } |
(...skipping 26 matching lines...) Expand all Loading... |
142 bool send_result = rtp_modules_[stream_index]->SendOutgoingData( | 137 bool send_result = rtp_modules_[stream_index]->SendOutgoingData( |
143 encoded_image._frameType, payload_type_, encoded_image._timeStamp, | 138 encoded_image._frameType, payload_type_, encoded_image._timeStamp, |
144 encoded_image.capture_time_ms_, encoded_image._buffer, | 139 encoded_image.capture_time_ms_, encoded_image._buffer, |
145 encoded_image._length, fragmentation, &rtp_video_header, &frame_id); | 140 encoded_image._length, fragmentation, &rtp_video_header, &frame_id); |
146 if (!send_result) | 141 if (!send_result) |
147 return Result(Result::ERROR_SEND_FAILED); | 142 return Result(Result::ERROR_SEND_FAILED); |
148 | 143 |
149 return Result(Result::OK, frame_id); | 144 return Result(Result::OK, frame_id); |
150 } | 145 } |
151 | 146 |
152 size_t PayloadRouter::MaxPayloadLength() const { | |
153 size_t min_payload_length = DefaultMaxPayloadLength(); | |
154 rtc::CritScope lock(&crit_); | |
155 for (size_t i = 0; i < rtp_modules_.size(); ++i) { | |
156 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | |
157 if (module_payload_length < min_payload_length) | |
158 min_payload_length = module_payload_length; | |
159 } | |
160 return min_payload_length; | |
161 } | |
162 | |
163 void PayloadRouter::OnBitrateAllocationUpdated( | 147 void PayloadRouter::OnBitrateAllocationUpdated( |
164 const BitrateAllocation& bitrate) { | 148 const BitrateAllocation& bitrate) { |
165 rtc::CritScope lock(&crit_); | 149 rtc::CritScope lock(&crit_); |
166 if (IsActive()) { | 150 if (IsActive()) { |
167 if (rtp_modules_.size() == 1) { | 151 if (rtp_modules_.size() == 1) { |
168 // If spatial scalability is enabled, it is covered by a single stream. | 152 // If spatial scalability is enabled, it is covered by a single stream. |
169 rtp_modules_[0]->SetVideoBitrateAllocation(bitrate); | 153 rtp_modules_[0]->SetVideoBitrateAllocation(bitrate); |
170 } else { | 154 } else { |
171 // Simulcast is in use, split the BitrateAllocation into one struct per | 155 // Simulcast is in use, split the BitrateAllocation into one struct per |
172 // rtp stream, moving over the temporal layer allocation. | 156 // rtp stream, moving over the temporal layer allocation. |
173 for (size_t si = 0; si < rtp_modules_.size(); ++si) { | 157 for (size_t si = 0; si < rtp_modules_.size(); ++si) { |
174 BitrateAllocation layer_bitrate; | 158 BitrateAllocation layer_bitrate; |
175 for (int tl = 0; tl < kMaxTemporalStreams; ++tl) | 159 for (int tl = 0; tl < kMaxTemporalStreams; ++tl) |
176 layer_bitrate.SetBitrate(0, tl, bitrate.GetBitrate(si, tl)); | 160 layer_bitrate.SetBitrate(0, tl, bitrate.GetBitrate(si, tl)); |
177 rtp_modules_[si]->SetVideoBitrateAllocation(layer_bitrate); | 161 rtp_modules_[si]->SetVideoBitrateAllocation(layer_bitrate); |
178 } | 162 } |
179 } | 163 } |
180 } | 164 } |
181 } | 165 } |
182 | 166 |
183 } // namespace webrtc | 167 } // namespace webrtc |
OLD | NEW |