OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 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 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 ALOGE << "Encoder got stuck. Reset."; | 663 ALOGE << "Encoder got stuck. Reset."; |
664 ResetCodecOnCodecThread(); | 664 ResetCodecOnCodecThread(); |
665 return WEBRTC_VIDEO_CODEC_ERROR; | 665 return WEBRTC_VIDEO_CODEC_ERROR; |
666 } | 666 } |
667 frames_dropped_media_encoder_++; | 667 frames_dropped_media_encoder_++; |
668 OnDroppedFrameOnCodecThread(); | 668 OnDroppedFrameOnCodecThread(); |
669 return WEBRTC_VIDEO_CODEC_OK; | 669 return WEBRTC_VIDEO_CODEC_OK; |
670 } | 670 } |
671 consecutive_full_queue_frame_drops_ = 0; | 671 consecutive_full_queue_frame_drops_ = 0; |
672 | 672 |
673 rtc::scoped_refptr<webrtc::VideoFrameBuffer> input_buffer( | 673 VideoFrame input_frame = frame; |
674 frame.video_frame_buffer()); | |
675 if (scale_) { | 674 if (scale_) { |
676 // Check framerate before spatial resolution change. | 675 // Check framerate before spatial resolution change. |
677 quality_scaler_.OnEncodeFrame(frame.width(), frame.height()); | 676 quality_scaler_.OnEncodeFrame(frame.width(), frame.height()); |
678 const webrtc::QualityScaler::Resolution scaled_resolution = | 677 const webrtc::QualityScaler::Resolution scaled_resolution = |
679 quality_scaler_.GetScaledResolution(); | 678 quality_scaler_.GetScaledResolution(); |
680 if (scaled_resolution.width != frame.width() || | 679 if (scaled_resolution.width != frame.width() || |
681 scaled_resolution.height != frame.height()) { | 680 scaled_resolution.height != frame.height()) { |
682 if (input_buffer->native_handle() != nullptr) { | 681 if (frame.video_frame_buffer()->native_handle() != nullptr) { |
683 input_buffer = static_cast<AndroidTextureBuffer*>(input_buffer.get()) | 682 rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer( |
684 ->CropScaleAndRotate(frame.width(), frame.height(), | 683 static_cast<AndroidTextureBuffer*>( |
685 0, 0, | 684 frame.video_frame_buffer().get())->CropScaleAndRotate( |
686 scaled_resolution.width, | 685 frame.width(), frame.height(), 0, 0, |
687 scaled_resolution.height, | 686 scaled_resolution.width, scaled_resolution.height, |
688 webrtc::kVideoRotation_0); | 687 webrtc::kVideoRotation_0)); |
| 688 input_frame.set_video_frame_buffer(scaled_buffer); |
689 } else { | 689 } else { |
690 input_buffer = quality_scaler_.GetScaledBuffer(input_buffer); | 690 input_frame.set_video_frame_buffer( |
| 691 quality_scaler_.GetScaledBuffer(frame.video_frame_buffer())); |
691 } | 692 } |
692 } | 693 } |
693 } | 694 } |
694 | 695 |
695 VideoFrame input_frame(input_buffer, frame.timestamp(), | |
696 frame.render_time_ms(), frame.rotation()); | |
697 | |
698 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { | 696 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { |
699 ALOGE << "Failed to reconfigure encoder."; | 697 ALOGE << "Failed to reconfigure encoder."; |
700 return WEBRTC_VIDEO_CODEC_ERROR; | 698 return WEBRTC_VIDEO_CODEC_ERROR; |
701 } | 699 } |
702 | 700 |
703 const int64_t time_before_calling_encode = rtc::TimeMillis(); | 701 const int64_t time_before_calling_encode = rtc::TimeMillis(); |
704 const bool key_frame = | 702 const bool key_frame = |
705 frame_types->front() != webrtc::kVideoFrameDelta || send_key_frame; | 703 frame_types->front() != webrtc::kVideoFrameDelta || send_key_frame; |
706 bool encode_status = true; | 704 bool encode_status = true; |
707 if (!input_frame.video_frame_buffer()->native_handle()) { | 705 if (!input_frame.video_frame_buffer()->native_handle()) { |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1279 return supported_codecs_; | 1277 return supported_codecs_; |
1280 } | 1278 } |
1281 | 1279 |
1282 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1280 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1283 webrtc::VideoEncoder* encoder) { | 1281 webrtc::VideoEncoder* encoder) { |
1284 ALOGD << "Destroy video encoder."; | 1282 ALOGD << "Destroy video encoder."; |
1285 delete encoder; | 1283 delete encoder; |
1286 } | 1284 } |
1287 | 1285 |
1288 } // namespace webrtc_jni | 1286 } // namespace webrtc_jni |
OLD | NEW |