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