| 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 658 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 // Check framerate before spatial resolution change. | 669 // Check framerate before spatial resolution change. |
| 670 quality_scaler_.OnEncodeFrame(frame); | 670 quality_scaler_.OnEncodeFrame(frame); |
| 671 const webrtc::QualityScaler::Resolution scaled_resolution = | 671 const webrtc::QualityScaler::Resolution scaled_resolution = |
| 672 quality_scaler_.GetScaledResolution(); | 672 quality_scaler_.GetScaledResolution(); |
| 673 if (scaled_resolution.width != frame.width() || | 673 if (scaled_resolution.width != frame.width() || |
| 674 scaled_resolution.height != frame.height()) { | 674 scaled_resolution.height != frame.height()) { |
| 675 if (frame.video_frame_buffer()->native_handle() != nullptr) { | 675 if (frame.video_frame_buffer()->native_handle() != nullptr) { |
| 676 rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer( | 676 rtc::scoped_refptr<webrtc::VideoFrameBuffer> scaled_buffer( |
| 677 static_cast<AndroidTextureBuffer*>( | 677 static_cast<AndroidTextureBuffer*>( |
| 678 frame.video_frame_buffer().get())->CropScaleAndRotate( | 678 frame.video_frame_buffer().get())->CropScaleAndRotate( |
| 679 frame.width(), frame.height(), | 679 frame.width(), frame.height(), 0, 0, |
| 680 scaled_resolution.width, scaled_resolution.height, | 680 scaled_resolution.width, scaled_resolution.height, |
| 681 webrtc::kVideoRotation_0)); | 681 webrtc::kVideoRotation_0)); |
| 682 input_frame.set_video_frame_buffer(scaled_buffer); | 682 input_frame.set_video_frame_buffer(scaled_buffer); |
| 683 } else { | 683 } else { |
| 684 input_frame = quality_scaler_.GetScaledFrame(frame); | 684 input_frame = quality_scaler_.GetScaledFrame(frame); |
| 685 } | 685 } |
| 686 } | 686 } |
| 687 } | 687 } |
| 688 | 688 |
| 689 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { | 689 if (!MaybeReconfigureEncoderOnCodecThread(input_frame)) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 CHECK_EXCEPTION(jni); | 805 CHECK_EXCEPTION(jni); |
| 806 return encode_status; | 806 return encode_status; |
| 807 } | 807 } |
| 808 | 808 |
| 809 bool MediaCodecVideoEncoder::EncodeTextureOnCodecThread(JNIEnv* jni, | 809 bool MediaCodecVideoEncoder::EncodeTextureOnCodecThread(JNIEnv* jni, |
| 810 bool key_frame, const webrtc::VideoFrame& frame) { | 810 bool key_frame, const webrtc::VideoFrame& frame) { |
| 811 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread()); | 811 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread()); |
| 812 RTC_CHECK(use_surface_); | 812 RTC_CHECK(use_surface_); |
| 813 NativeHandleImpl* handle = static_cast<NativeHandleImpl*>( | 813 NativeHandleImpl* handle = static_cast<NativeHandleImpl*>( |
| 814 frame.video_frame_buffer()->native_handle()); | 814 frame.video_frame_buffer()->native_handle()); |
| 815 jfloatArray sampling_matrix = jni->NewFloatArray(16); | 815 jfloatArray sampling_matrix = handle->sampling_matrix.ToJava(jni); |
| 816 jni->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); | |
| 817 | |
| 818 bool encode_status = jni->CallBooleanMethod(*j_media_codec_video_encoder_, | 816 bool encode_status = jni->CallBooleanMethod(*j_media_codec_video_encoder_, |
| 819 j_encode_texture_method_, | 817 j_encode_texture_method_, |
| 820 key_frame, | 818 key_frame, |
| 821 handle->oes_texture_id, | 819 handle->oes_texture_id, |
| 822 sampling_matrix, | 820 sampling_matrix, |
| 823 current_timestamp_us_); | 821 current_timestamp_us_); |
| 824 CHECK_EXCEPTION(jni); | 822 CHECK_EXCEPTION(jni); |
| 825 return encode_status; | 823 return encode_status; |
| 826 } | 824 } |
| 827 | 825 |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 return supported_codecs_; | 1262 return supported_codecs_; |
| 1265 } | 1263 } |
| 1266 | 1264 |
| 1267 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1265 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
| 1268 webrtc::VideoEncoder* encoder) { | 1266 webrtc::VideoEncoder* encoder) { |
| 1269 ALOGD << "Destroy video encoder."; | 1267 ALOGD << "Destroy video encoder."; |
| 1270 delete encoder; | 1268 delete encoder; |
| 1271 } | 1269 } |
| 1272 | 1270 |
| 1273 } // namespace webrtc_jni | 1271 } // namespace webrtc_jni |
| OLD | NEW |