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 | 8 |
9 #include "base/android/build_info.h" | 9 #include "base/android/build_info.h" |
10 #include "base/android/jni_android.h" | 10 #include "base/android/jni_android.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
65 // static | 65 // static |
66 const base::TimeDelta MediaCodecBridge::kTimeOutNoWait = | 66 const base::TimeDelta MediaCodecBridge::kTimeOutNoWait = |
67 base::TimeDelta::FromMicroseconds(0); | 67 base::TimeDelta::FromMicroseconds(0); |
68 | 68 |
69 // static | 69 // static |
70 bool MediaCodecBridge::IsAvailable() { | 70 bool MediaCodecBridge::IsAvailable() { |
71 // MediaCodec is only available on JB and greater. | 71 // MediaCodec is only available on JB and greater. |
72 return base::android::BuildInfo::GetInstance()->sdk_int() >= 16; | 72 return base::android::BuildInfo::GetInstance()->sdk_int() >= 16; |
73 } | 73 } |
74 | 74 |
| 75 // static |
| 76 bool MediaCodecBridge::CanPlayType(const char* mime, bool secure) { |
| 77 JNIEnv* env = AttachCurrentThread(); |
| 78 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
| 79 return !Java_MediaCodecBridge_create(env, j_mime.obj(), secure).is_null(); |
| 80 } |
| 81 |
| 82 // TODO(xhwang): Support creating secure MediaCodecBridge. |
75 MediaCodecBridge::MediaCodecBridge(const char* mime) { | 83 MediaCodecBridge::MediaCodecBridge(const char* mime) { |
76 JNIEnv* env = AttachCurrentThread(); | 84 JNIEnv* env = AttachCurrentThread(); |
77 CHECK(env); | 85 CHECK(env); |
78 DCHECK(mime); | 86 DCHECK(mime); |
79 | 87 |
80 ScopedJavaLocalRef<jstring> j_type = ConvertUTF8ToJavaString(env, mime); | 88 ScopedJavaLocalRef<jstring> j_mime = ConvertUTF8ToJavaString(env, mime); |
81 j_media_codec_.Reset(Java_MediaCodecBridge_create( | 89 j_media_codec_.Reset(Java_MediaCodecBridge_create(env, j_mime.obj(), false)); |
82 env, j_type.obj())); | |
83 } | 90 } |
84 | 91 |
85 MediaCodecBridge::~MediaCodecBridge() { | 92 MediaCodecBridge::~MediaCodecBridge() { |
86 JNIEnv* env = AttachCurrentThread(); | 93 JNIEnv* env = AttachCurrentThread(); |
87 CHECK(env); | 94 CHECK(env); |
88 if (j_media_codec_.obj()) | 95 if (j_media_codec_.obj()) |
89 Java_MediaCodecBridge_release(env, j_media_codec_.obj()); | 96 Java_MediaCodecBridge_release(env, j_media_codec_.obj()); |
90 } | 97 } |
91 | 98 |
92 void MediaCodecBridge::StartInternal() { | 99 void MediaCodecBridge::StartInternal() { |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 VideoCodecBridge* VideoCodecBridge::Create(const VideoCodec codec) { | 424 VideoCodecBridge* VideoCodecBridge::Create(const VideoCodec codec) { |
418 const char* mime = VideoCodecToMimeType(codec); | 425 const char* mime = VideoCodecToMimeType(codec); |
419 return mime ? new VideoCodecBridge(mime) : NULL; | 426 return mime ? new VideoCodecBridge(mime) : NULL; |
420 } | 427 } |
421 | 428 |
422 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { | 429 bool MediaCodecBridge::RegisterMediaCodecBridge(JNIEnv* env) { |
423 return RegisterNativesImpl(env); | 430 return RegisterNativesImpl(env); |
424 } | 431 } |
425 | 432 |
426 } // namespace media | 433 } // namespace media |
OLD | NEW |