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 EncodedImageCallback::Result PayloadRouter::OnEncodedImage( | 140 int32_t PayloadRouter::Encoded(const EncodedImage& encoded_image, |
141 const EncodedImage& encoded_image, | 141 const CodecSpecificInfo* codec_specific_info, |
142 const CodecSpecificInfo* codec_specific_info, | 142 const RTPFragmentationHeader* fragmentation) { |
143 const RTPFragmentationHeader* fragmentation) { | |
144 rtc::CritScope lock(&crit_); | 143 rtc::CritScope lock(&crit_); |
145 RTC_DCHECK(!rtp_modules_.empty()); | 144 RTC_DCHECK(!rtp_modules_.empty()); |
146 if (!active_ || num_sending_modules_ == 0) | 145 if (!active_ || num_sending_modules_ == 0) |
147 return Result(Result::ERROR_SEND_FAILED); | 146 return -1; |
148 | 147 |
149 int stream_index = 0; | 148 int stream_idx = 0; |
150 | 149 |
151 RTPVideoHeader rtp_video_header; | 150 RTPVideoHeader rtp_video_header; |
152 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader)); | 151 memset(&rtp_video_header, 0, sizeof(RTPVideoHeader)); |
153 if (codec_specific_info) | 152 if (codec_specific_info) |
154 CopyCodecSpecific(codec_specific_info, &rtp_video_header); | 153 CopyCodecSpecific(codec_specific_info, &rtp_video_header); |
155 rtp_video_header.rotation = encoded_image.rotation_; | 154 rtp_video_header.rotation = encoded_image.rotation_; |
156 rtp_video_header.playout_delay = encoded_image.playout_delay_; | 155 rtp_video_header.playout_delay = encoded_image.playout_delay_; |
157 | 156 |
158 RTC_DCHECK_LT(rtp_video_header.simulcastIdx, rtp_modules_.size()); | 157 RTC_DCHECK_LT(rtp_video_header.simulcastIdx, rtp_modules_.size()); |
159 // The simulcast index might actually be larger than the number of modules | 158 // The simulcast index might actually be larger than the number of modules |
160 // in case the encoder was processing a frame during a codec reconfig. | 159 // in case the encoder was processing a frame during a codec reconfig. |
161 if (rtp_video_header.simulcastIdx >= num_sending_modules_) | 160 if (rtp_video_header.simulcastIdx >= num_sending_modules_) |
162 return Result(Result::ERROR_SEND_FAILED); | 161 return -1; |
163 stream_index = rtp_video_header.simulcastIdx; | 162 stream_idx = rtp_video_header.simulcastIdx; |
164 | 163 |
165 uint32_t frame_id; | 164 return rtp_modules_[stream_idx]->SendOutgoingData( |
166 int send_result = rtp_modules_[stream_index]->SendOutgoingData( | |
167 encoded_image._frameType, payload_type_, encoded_image._timeStamp, | 165 encoded_image._frameType, payload_type_, encoded_image._timeStamp, |
168 encoded_image.capture_time_ms_, encoded_image._buffer, | 166 encoded_image.capture_time_ms_, encoded_image._buffer, |
169 encoded_image._length, fragmentation, &rtp_video_header, &frame_id); | 167 encoded_image._length, fragmentation, &rtp_video_header); |
170 | |
171 if (send_result < 0) | |
172 return Result(Result::ERROR_SEND_FAILED); | |
173 | |
174 return Result(Result::OK, frame_id); | |
175 } | 168 } |
176 | 169 |
177 size_t PayloadRouter::MaxPayloadLength() const { | 170 size_t PayloadRouter::MaxPayloadLength() const { |
178 size_t min_payload_length = DefaultMaxPayloadLength(); | 171 size_t min_payload_length = DefaultMaxPayloadLength(); |
179 rtc::CritScope lock(&crit_); | 172 rtc::CritScope lock(&crit_); |
180 for (size_t i = 0; i < num_sending_modules_; ++i) { | 173 for (size_t i = 0; i < num_sending_modules_; ++i) { |
181 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); | 174 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); |
182 if (module_payload_length < min_payload_length) | 175 if (module_payload_length < min_payload_length) |
183 min_payload_length = module_payload_length; | 176 min_payload_length = module_payload_length; |
184 } | 177 } |
185 return min_payload_length; | 178 return min_payload_length; |
186 } | 179 } |
187 | 180 |
188 } // namespace webrtc | 181 } // namespace webrtc |
OLD | NEW |