Chromium Code Reviews| 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 130 rtp_modules_[i]->SetSendingStatus(active_); | 130 rtp_modules_[i]->SetSendingStatus(active_); |
| 131 rtp_modules_[i]->SetSendingMediaStatus(active_); | 131 rtp_modules_[i]->SetSendingMediaStatus(active_); |
| 132 } | 132 } |
| 133 // Disable inactive modules. | 133 // Disable inactive modules. |
| 134 for (size_t i = num_sending_modules_; i < rtp_modules_.size(); ++i) { | 134 for (size_t i = num_sending_modules_; i < rtp_modules_.size(); ++i) { |
| 135 rtp_modules_[i]->SetSendingStatus(false); | 135 rtp_modules_[i]->SetSendingStatus(false); |
| 136 rtp_modules_[i]->SetSendingMediaStatus(false); | 136 rtp_modules_[i]->SetSendingMediaStatus(false); |
| 137 } | 137 } |
| 138 } | 138 } |
| 139 | 139 |
| 140 int32_t PayloadRouter::Encoded(const EncodedImage& encoded_image, | 140 EncodedImageCallback::Result PayloadRouter::OnEncodedImage( |
| 141 const CodecSpecificInfo* codec_specific_info, | 141 const EncodedImage& encoded_image, |
| 142 const RTPFragmentationHeader* fragmentation) { | 142 const CodecSpecificInfo* codec_specific_info, |
| 143 const RTPFragmentationHeader* fragmentation) { | |
| 143 rtc::CritScope lock(&crit_); | 144 rtc::CritScope lock(&crit_); |
| 144 RTC_DCHECK(!rtp_modules_.empty()); | 145 RTC_DCHECK(!rtp_modules_.empty()); |
| 145 if (!active_ || num_sending_modules_ == 0) | 146 if (!active_ || num_sending_modules_ == 0) |
| 146 return -1; | 147 return Result(Result::ERROR_SEND_FAILED); |
| 147 | 148 |
| 148 int stream_idx = 0; | 149 int stream_index = 0; |
| 149 | 150 |
| 150 RTPVideoHeader rtp_video_header; | 151 RTPVideoHeader rtp_video_header; |
| 151 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader)); | 152 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader)); |
| 152 if (codec_specific_info) | 153 if (codec_specific_info) |
| 153 CopyCodecSpecific(codec_specific_info, &rtp_video_header); | 154 CopyCodecSpecific(codec_specific_info, &rtp_video_header); |
| 154 rtp_video_header.rotation = encoded_image.rotation_; | 155 rtp_video_header.rotation = encoded_image.rotation_; |
| 155 rtp_video_header.playout_delay = encoded_image.playout_delay_; | 156 rtp_video_header.playout_delay = encoded_image.playout_delay_; |
| 156 | 157 |
| 157 RTC_DCHECK_LT(rtp_video_header.simulcastIdx, rtp_modules_.size()); | 158 RTC_DCHECK_LT(rtp_video_header.simulcastIdx, rtp_modules_.size()); |
| 158 // The simulcast index might actually be larger than the number of modules | 159 // The simulcast index might actually be larger than the number of modules |
| 159 // in case the encoder was processing a frame during a codec reconfig. | 160 // in case the encoder was processing a frame during a codec reconfig. |
| 160 if (rtp_video_header.simulcastIdx >= num_sending_modules_) | 161 if (rtp_video_header.simulcastIdx >= num_sending_modules_) |
| 161 return -1; | 162 return Result(Result::ERROR_SEND_FAILED); |
| 162 stream_idx = rtp_video_header.simulcastIdx; | 163 stream_index = rtp_video_header.simulcastIdx; |
| 163 | 164 |
| 164 return rtp_modules_[stream_idx]->SendOutgoingData( | 165 int send_result = rtp_modules_[stream_index]->SendOutgoingData( |
| 165 encoded_image._frameType, payload_type_, encoded_image._timeStamp, | 166 encoded_image._frameType, payload_type_, encoded_image._timeStamp, |
| 166 encoded_image.capture_time_ms_, encoded_image._buffer, | 167 encoded_image.capture_time_ms_, encoded_image._buffer, |
| 167 encoded_image._length, fragmentation, &rtp_video_header); | 168 encoded_image._length, fragmentation, &rtp_video_header); |
| 169 | |
| 170 if (send_result < 0) | |
| 171 return Result(Result::ERROR_SEND_FAILED); | |
| 172 | |
| 173 uint32_t frame_id = | |
| 174 rtp_modules_[stream_index]->StartTimestamp() + encoded_image._timeStamp; | |
|
stefan-webrtc
2016/07/18 16:51:27
Would it make sense to instead have SendOutgoingDa
Sergey Ulanov
2016/07/21 00:09:39
Yes, but RtpRtcp::SendOutgoingData() is used in bu
stefan-webrtc
2016/07/25 15:19:33
Missed this comment, sorry.
I would prefer to add
Sergey Ulanov
2016/07/26 19:19:53
Done
| |
| 175 return Result(Result::OK, frame_id); | |
| 168 } | 176 } |
| 169 | 177 |
| 170 void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) { | 178 void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) { |
| 171 rtc::CritScope lock(&crit_); | 179 rtc::CritScope lock(&crit_); |
| 172 RTC_DCHECK_LE(streams_.size(), rtp_modules_.size()); | 180 RTC_DCHECK_LE(streams_.size(), rtp_modules_.size()); |
| 173 | 181 |
| 174 // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of | 182 // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of |
| 175 // this. | 183 // this. |
| 176 int bitrate_remainder = bitrate_bps; | 184 int bitrate_remainder = bitrate_bps; |
| 177 for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) { | 185 for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 191 rtc::CritScope lock(&crit_); | 199 rtc::CritScope lock(&crit_); |
| 192 for (size_t i = 0; i < num_sending_modules_; ++i) { | 200 for (size_t i = 0; i < num_sending_modules_; ++i) { |
| 193 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | 201 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); |
| 194 if (module_payload_length < min_payload_length) | 202 if (module_payload_length < min_payload_length) |
| 195 min_payload_length = module_payload_length; | 203 min_payload_length = module_payload_length; |
| 196 } | 204 } |
| 197 return min_payload_length; | 205 return min_payload_length; |
| 198 } | 206 } |
| 199 | 207 |
| 200 } // namespace webrtc | 208 } // namespace webrtc |
| OLD | NEW |