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 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 CHECK_EXCEPTION(jni); | 802 CHECK_EXCEPTION(jni); |
803 return encode_status; | 803 return encode_status; |
804 } | 804 } |
805 | 805 |
806 bool MediaCodecVideoEncoder::EncodeTextureOnCodecThread(JNIEnv* jni, | 806 bool MediaCodecVideoEncoder::EncodeTextureOnCodecThread(JNIEnv* jni, |
807 bool key_frame, const webrtc::VideoFrame& frame) { | 807 bool key_frame, const webrtc::VideoFrame& frame) { |
808 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread()); | 808 RTC_DCHECK(codec_thread_checker_.CalledOnValidThread()); |
809 RTC_CHECK(use_surface_); | 809 RTC_CHECK(use_surface_); |
810 NativeHandleImpl* handle = static_cast<NativeHandleImpl*>( | 810 NativeHandleImpl* handle = static_cast<NativeHandleImpl*>( |
811 frame.video_frame_buffer()->native_handle()); | 811 frame.video_frame_buffer()->native_handle()); |
812 jfloatArray sampling_matrix = jni->NewFloatArray(16); | 812 jfloatArray sampling_matrix = handle->sampling_matrix.ToJava(jni); |
813 jni->SetFloatArrayRegion(sampling_matrix, 0, 16, handle->sampling_matrix); | |
814 | |
815 bool encode_status = jni->CallBooleanMethod(*j_media_codec_video_encoder_, | 813 bool encode_status = jni->CallBooleanMethod(*j_media_codec_video_encoder_, |
816 j_encode_texture_method_, | 814 j_encode_texture_method_, |
817 key_frame, | 815 key_frame, |
818 handle->oes_texture_id, | 816 handle->oes_texture_id, |
819 sampling_matrix, | 817 sampling_matrix, |
820 current_timestamp_us_); | 818 current_timestamp_us_); |
821 CHECK_EXCEPTION(jni); | 819 CHECK_EXCEPTION(jni); |
822 return encode_status; | 820 return encode_status; |
823 } | 821 } |
824 | 822 |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1261 return supported_codecs_; | 1259 return supported_codecs_; |
1262 } | 1260 } |
1263 | 1261 |
1264 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( | 1262 void MediaCodecVideoEncoderFactory::DestroyVideoEncoder( |
1265 webrtc::VideoEncoder* encoder) { | 1263 webrtc::VideoEncoder* encoder) { |
1266 ALOGD << "Destroy video encoder."; | 1264 ALOGD << "Destroy video encoder."; |
1267 delete encoder; | 1265 delete encoder; |
1268 } | 1266 } |
1269 | 1267 |
1270 } // namespace webrtc_jni | 1268 } // namespace webrtc_jni |
OLD | NEW |