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/media_codec_bridge.h" | 5 #include "media/base/android/media_codec_bridge.h" |
6 | 6 |
7 #include <jni.h> | 7 #include <jni.h> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/android/build_info.h" | 10 #include "base/android/build_info.h" |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
629 const gfx::Size& size, | 629 const gfx::Size& size, |
630 jobject surface, | 630 jobject surface, |
631 jobject media_crypto) { | 631 jobject media_crypto) { |
632 JNIEnv* env = AttachCurrentThread(); | 632 JNIEnv* env = AttachCurrentThread(); |
633 const std::string mime = VideoCodecToAndroidMimeType(codec); | 633 const std::string mime = VideoCodecToAndroidMimeType(codec); |
634 if (mime.empty()) | 634 if (mime.empty()) |
635 return NULL; | 635 return NULL; |
636 | 636 |
637 scoped_ptr<VideoCodecBridge> bridge( | 637 scoped_ptr<VideoCodecBridge> bridge( |
638 new VideoCodecBridge(mime, is_secure, MEDIA_CODEC_DECODER)); | 638 new VideoCodecBridge(mime, is_secure, MEDIA_CODEC_DECODER)); |
639 if (!bridge->media_codec()) | |
640 return NULL; | |
xhwang
2013/12/19 07:29:05
Shall we have a Create function that could return
qinmin
2013/12/19 18:26:25
The java side MediaCodecBridge.Create() function a
| |
639 | 641 |
640 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); | 642 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
641 ScopedJavaLocalRef<jobject> j_format( | 643 ScopedJavaLocalRef<jobject> j_format( |
642 Java_MediaCodecBridge_createVideoDecoderFormat( | 644 Java_MediaCodecBridge_createVideoDecoderFormat( |
643 env, j_mime.obj(), size.width(), size.height())); | 645 env, j_mime.obj(), size.width(), size.height())); |
644 DCHECK(!j_format.is_null()); | 646 DCHECK(!j_format.is_null()); |
645 if (!Java_MediaCodecBridge_configureVideo(env, | 647 if (!Java_MediaCodecBridge_configureVideo(env, |
646 bridge->media_codec(), | 648 bridge->media_codec(), |
647 j_format.obj(), | 649 j_format.obj(), |
648 surface, | 650 surface, |
(...skipping 11 matching lines...) Expand all Loading... | |
660 int frame_rate, | 662 int frame_rate, |
661 int i_frame_interval, | 663 int i_frame_interval, |
662 int color_format) { | 664 int color_format) { |
663 JNIEnv* env = AttachCurrentThread(); | 665 JNIEnv* env = AttachCurrentThread(); |
664 const std::string mime = VideoCodecToAndroidMimeType(codec); | 666 const std::string mime = VideoCodecToAndroidMimeType(codec); |
665 if (mime.empty()) | 667 if (mime.empty()) |
666 return NULL; | 668 return NULL; |
667 | 669 |
668 scoped_ptr<VideoCodecBridge> bridge( | 670 scoped_ptr<VideoCodecBridge> bridge( |
669 new VideoCodecBridge(mime, false, MEDIA_CODEC_ENCODER)); | 671 new VideoCodecBridge(mime, false, MEDIA_CODEC_ENCODER)); |
672 if (!bridge->media_codec()) | |
673 return NULL; | |
670 | 674 |
671 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); | 675 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
672 ScopedJavaLocalRef<jobject> j_format( | 676 ScopedJavaLocalRef<jobject> j_format( |
673 Java_MediaCodecBridge_createVideoEncoderFormat(env, | 677 Java_MediaCodecBridge_createVideoEncoderFormat(env, |
674 j_mime.obj(), | 678 j_mime.obj(), |
675 size.width(), | 679 size.width(), |
676 size.height(), | 680 size.height(), |
677 bit_rate, | 681 bit_rate, |
678 frame_rate, | 682 frame_rate, |
679 i_frame_interval, | 683 i_frame_interval, |
(...skipping 24 matching lines...) Expand all Loading... | |
704 void VideoCodecBridge::RequestKeyFrameSoon() { | 708 void VideoCodecBridge::RequestKeyFrameSoon() { |
705 JNIEnv* env = AttachCurrentThread(); | 709 JNIEnv* env = AttachCurrentThread(); |
706 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec()); | 710 Java_MediaCodecBridge_requestKeyFrameSoon(env, media_codec()); |
707 } | 711 } |
708 | 712 |
709 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 713 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
710 return RegisterNativesImpl(env); | 714 return RegisterNativesImpl(env); |
711 } | 715 } |
712 | 716 |
713 } // namespace media | 717 } // namespace media |
OLD | NEW |