OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
282 streaminfos_[stream_idx].key_frame_request = false; | 282 streaminfos_[stream_idx].key_frame_request = false; |
283 } else { | 283 } else { |
284 stream_frame_types.push_back(kVideoFrameDelta); | 284 stream_frame_types.push_back(kVideoFrameDelta); |
285 } | 285 } |
286 | 286 |
287 int dst_width = streaminfos_[stream_idx].width; | 287 int dst_width = streaminfos_[stream_idx].width; |
288 int dst_height = streaminfos_[stream_idx].height; | 288 int dst_height = streaminfos_[stream_idx].height; |
289 // If scaling isn't required, because the input resolution | 289 // If scaling isn't required, because the input resolution |
290 // matches the destination or the input image is empty (e.g. | 290 // matches the destination or the input image is empty (e.g. |
291 // a keyframe request for encoders with internal camera | 291 // a keyframe request for encoders with internal camera |
292 // sources), pass the image on directly. Otherwise, we'll | 292 // sources) or the source image has a native handle, pass the image on |
293 // scale it to match what the encoder expects (below). | 293 // directly. Otherwise, we'll scale it to match what the encoder expects |
294 // (below). | |
295 // For texture frames, the underlying encoder is expected to be able to | |
296 // correctly sample/scale the source texture. | |
294 if ((dst_width == src_width && dst_height == src_height) || | 297 if ((dst_width == src_width && dst_height == src_height) || |
295 input_image.IsZeroSize()) { | 298 input_image.IsZeroSize() || |
299 input_image.video_frame_buffer()->native_handle()) { | |
perkj_webrtc
2016/06/27 08:02:01
The encoder does not know the size is should scale
noahric
2016/06/30 17:17:39
Added a TODO here with a reference for webrtc:5683
| |
296 int ret = streaminfos_[stream_idx].encoder->Encode( | 300 int ret = streaminfos_[stream_idx].encoder->Encode( |
297 input_image, codec_specific_info, &stream_frame_types); | 301 input_image, codec_specific_info, &stream_frame_types); |
298 if (ret != WEBRTC_VIDEO_CODEC_OK) { | 302 if (ret != WEBRTC_VIDEO_CODEC_OK) { |
299 return ret; | 303 return ret; |
300 } | 304 } |
301 } else { | 305 } else { |
302 VideoFrame dst_frame; | 306 VideoFrame dst_frame; |
perkj_webrtc
2016/06/28 14:09:00
So apparently no one use simulcast with native tex
pbos-webrtc
2016/06/29 15:48:27
I think quality scaling should apply outside and j
| |
303 // Making sure that destination frame is of sufficient size. | 307 // Making sure that destination frame is of sufficient size. |
304 // Aligning stride values based on width. | 308 // Aligning stride values based on width. |
305 dst_frame.CreateEmptyFrame(dst_width, dst_height, dst_width, | 309 dst_frame.CreateEmptyFrame(dst_width, dst_height, dst_width, |
306 (dst_width + 1) / 2, (dst_width + 1) / 2); | 310 (dst_width + 1) / 2, (dst_width + 1) / 2); |
307 libyuv::I420Scale(input_image.video_frame_buffer()->DataY(), | 311 libyuv::I420Scale(input_image.video_frame_buffer()->DataY(), |
308 input_image.video_frame_buffer()->StrideY(), | 312 input_image.video_frame_buffer()->StrideY(), |
309 input_image.video_frame_buffer()->DataU(), | 313 input_image.video_frame_buffer()->DataU(), |
310 input_image.video_frame_buffer()->StrideU(), | 314 input_image.video_frame_buffer()->StrideU(), |
311 input_image.video_frame_buffer()->DataV(), | 315 input_image.video_frame_buffer()->DataV(), |
312 input_image.video_frame_buffer()->StrideV(), | 316 input_image.video_frame_buffer()->StrideV(), |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
503 return !streaminfos_.empty(); | 507 return !streaminfos_.empty(); |
504 } | 508 } |
505 | 509 |
506 void SimulcastEncoderAdapter::OnDroppedFrame() { | 510 void SimulcastEncoderAdapter::OnDroppedFrame() { |
507 streaminfos_[0].encoder->OnDroppedFrame(); | 511 streaminfos_[0].encoder->OnDroppedFrame(); |
508 } | 512 } |
509 | 513 |
510 bool SimulcastEncoderAdapter::SupportsNativeHandle() const { | 514 bool SimulcastEncoderAdapter::SupportsNativeHandle() const { |
511 // We should not be calling this method before streaminfos_ are configured. | 515 // We should not be calling this method before streaminfos_ are configured. |
512 RTC_DCHECK(!streaminfos_.empty()); | 516 RTC_DCHECK(!streaminfos_.empty()); |
513 // TODO(pbos): Support textures when using more than one encoder. | 517 for (const auto& streaminfo : streaminfos_) { |
514 if (streaminfos_.size() != 1) | 518 if (!streaminfo.encoder->SupportsNativeHandle()) { |
515 return false; | 519 return false; |
pbos-webrtc
2016/06/29 15:48:27
remove {}s, you're not in Kansas anymore, cowboy.
noahric
2016/06/30 17:17:39
Done :)
| |
516 return streaminfos_[0].encoder->SupportsNativeHandle(); | 520 } |
521 } | |
522 return true; | |
517 } | 523 } |
518 | 524 |
519 const char* SimulcastEncoderAdapter::ImplementationName() const { | 525 const char* SimulcastEncoderAdapter::ImplementationName() const { |
520 return implementation_name_.c_str(); | 526 return implementation_name_.c_str(); |
521 } | 527 } |
522 | 528 |
523 } // namespace webrtc | 529 } // namespace webrtc |
OLD | NEW |