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

Side by Side Diff: webrtc/video/payload_router.cc

Issue 2089773002: Add EncodedImageCallback::OnEncodedImage(). (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 6 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) 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
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 EncodedImageCallback::Result::FrameDropped();
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 EncodedImageCallback::Result::FrameDropped();
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 EncodedImageCallback::Result result;
171 if (send_result < 0) {
172 result.dropped = true;
173 } else {
174 result.frame_id =
175 rtp_modules_[stream_index]->StartTimestamp() + encoded_image._timeStamp;
176 }
177 return result;
168 } 178 }
169 179
170 void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) { 180 void PayloadRouter::SetTargetSendBitrate(uint32_t bitrate_bps) {
171 rtc::CritScope lock(&crit_); 181 rtc::CritScope lock(&crit_);
172 RTC_DCHECK_LE(streams_.size(), rtp_modules_.size()); 182 RTC_DCHECK_LE(streams_.size(), rtp_modules_.size());
173 183
174 // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of 184 // TODO(sprang): Rebase https://codereview.webrtc.org/1913073002/ on top of
175 // this. 185 // this.
176 int bitrate_remainder = bitrate_bps; 186 int bitrate_remainder = bitrate_bps;
177 for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) { 187 for (size_t i = 0; i < streams_.size() && bitrate_remainder > 0; ++i) {
(...skipping 13 matching lines...) Expand all
191 rtc::CritScope lock(&crit_); 201 rtc::CritScope lock(&crit_);
192 for (size_t i = 0; i < num_sending_modules_; ++i) { 202 for (size_t i = 0; i < num_sending_modules_; ++i) {
193 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength(); 203 size_t module_payload_length = rtp_modules_[i]->MaxDataPayloadLength();
194 if (module_payload_length < min_payload_length) 204 if (module_payload_length < min_payload_length)
195 min_payload_length = module_payload_length; 205 min_payload_length = module_payload_length;
196 } 206 }
197 return min_payload_length; 207 return min_payload_length;
198 } 208 }
199 209
200 } // namespace webrtc 210 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698