OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/base/android/sdk_media_codec_bridge.h" | 5 #include "media/base/android/sdk_media_codec_bridge.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
(...skipping 615 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
626 | 626 |
627 std::unique_ptr<VideoCodecBridge> bridge( | 627 std::unique_ptr<VideoCodecBridge> bridge( |
628 new VideoCodecBridge(mime, false, MEDIA_CODEC_ENCODER, false)); | 628 new VideoCodecBridge(mime, false, MEDIA_CODEC_ENCODER, false)); |
629 if (!bridge->media_codec()) | 629 if (!bridge->media_codec()) |
630 return nullptr; | 630 return nullptr; |
631 | 631 |
632 JNIEnv* env = AttachCurrentThread(); | 632 JNIEnv* env = AttachCurrentThread(); |
633 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); | 633 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
634 ScopedJavaLocalRef<jobject> j_format( | 634 ScopedJavaLocalRef<jobject> j_format( |
635 Java_MediaCodecBridge_createVideoEncoderFormat( | 635 Java_MediaCodecBridge_createVideoEncoderFormat( |
636 env, j_mime, size.width(), size.height(), bit_rate, frame_rate, | 636 env, bridge->media_codec(), j_mime, size.width(), size.height(), |
637 i_frame_interval, color_format)); | 637 bit_rate, frame_rate, i_frame_interval, color_format)); |
638 DCHECK(!j_format.is_null()); | 638 DCHECK(!j_format.is_null()); |
639 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(), | 639 if (!Java_MediaCodecBridge_configureVideo(env, bridge->media_codec(), |
640 j_format, nullptr, nullptr, | 640 j_format, nullptr, nullptr, |
641 kConfigureFlagEncode, true)) { | 641 kConfigureFlagEncode, true)) { |
642 return nullptr; | 642 return nullptr; |
643 } | 643 } |
644 | 644 |
645 return bridge->Start() ? bridge.release() : nullptr; | 645 return bridge->Start() ? bridge.release() : nullptr; |
646 } | 646 } |
647 | 647 |
648 VideoCodecBridge::VideoCodecBridge(const std::string& mime, | 648 VideoCodecBridge::VideoCodecBridge(const std::string& mime, |
649 bool is_secure, | 649 bool is_secure, |
650 MediaCodecDirection direction, | 650 MediaCodecDirection direction, |
651 bool require_software_codec) | 651 bool require_software_codec) |
652 : SdkMediaCodecBridge(mime, is_secure, direction, require_software_codec), | 652 : SdkMediaCodecBridge(mime, is_secure, direction, require_software_codec), |
653 adaptive_playback_supported_for_testing_(-1) {} | 653 adaptive_playback_supported_for_testing_(-1) {} |
654 | 654 |
655 void VideoCodecBridge::SetVideoBitrate(int bps) { | 655 void VideoCodecBridge::SetVideoBitrate(int bps, int frame_rate) { |
656 JNIEnv* env = AttachCurrentThread(); | 656 JNIEnv* env = AttachCurrentThread(); |
657 Java_MediaCodecBridge_setVideoBitrate(env, media_codec(), bps); | 657 Java_MediaCodecBridge_setVideoBitrate(env, media_codec(), bps, frame_rate); |
658 } | 658 } |
659 | 659 |
660 void VideoCodecBridge::RequestKeyFrameSoon() { | 660 void VideoCodecBridge::RequestKeyFrameSoon() { |
661 JNIEnv* env = AttachCurrentThread(); | 661 JNIEnv* env = AttachCurrentThread(); |
662 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec()); | 662 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec()); |
663 } | 663 } |
664 | 664 |
665 bool VideoCodecBridge::IsAdaptivePlaybackSupported(int width, int height) { | 665 bool VideoCodecBridge::IsAdaptivePlaybackSupported(int width, int height) { |
666 if (adaptive_playback_supported_for_testing_ == 0) | 666 if (adaptive_playback_supported_for_testing_ == 0) |
667 return false; | 667 return false; |
668 else if (adaptive_playback_supported_for_testing_ > 0) | 668 else if (adaptive_playback_supported_for_testing_ > 0) |
669 return true; | 669 return true; |
670 JNIEnv* env = AttachCurrentThread(); | 670 JNIEnv* env = AttachCurrentThread(); |
671 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), | 671 return Java_MediaCodecBridge_isAdaptivePlaybackSupported(env, media_codec(), |
672 width, height); | 672 width, height); |
673 } | 673 } |
674 | 674 |
675 } // namespace media | 675 } // namespace media |
OLD | NEW |