summaryrefslogtreecommitdiffstats
path: root/media/jni
diff options
context:
space:
mode:
authorAndreas Huber <andih@google.com>2012-11-30 14:28:14 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2012-11-30 14:28:14 -0800
commit1adc5975fa293afc484cc3095f74a7b4964f6306 (patch)
tree1b68b188fb9d04bd109f560cb1829bcab00240a4 /media/jni
parentcc95712ea2eb07913d8a9964cd8266245f8c1fd6 (diff)
parent800c8ab68d695f1b6c5332c80a32316cdca69954 (diff)
downloadframeworks_base-1adc5975fa293afc484cc3095f74a7b4964f6306.zip
frameworks_base-1adc5975fa293afc484cc3095f74a7b4964f6306.tar.gz
frameworks_base-1adc5975fa293afc484cc3095f74a7b4964f6306.tar.bz2
am 800c8ab6: am 2644494a: Merge changes I8462f040,Ie471f40f
* commit '800c8ab68d695f1b6c5332c80a32316cdca69954': MediaCodec: Allow getting the codec info directly MediaCodec: Allow getting the chosen component name
Diffstat (limited to 'media/jni')
-rw-r--r--media/jni/android_media_MediaCodec.cpp40
-rw-r--r--media/jni/android_media_MediaCodec.h2
-rw-r--r--media/jni/android_media_MediaCodecList.cpp22
3 files changed, 64 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaCodec.cpp b/media/jni/android_media_MediaCodec.cpp
index f91c9a0..dab2de1 100644
--- a/media/jni/android_media_MediaCodec.cpp
+++ b/media/jni/android_media_MediaCodec.cpp
@@ -264,6 +264,20 @@ status_t JMediaCodec::getBuffers(
return OK;
}
+status_t JMediaCodec::getName(JNIEnv *env, jstring *nameStr) const {
+ AString name;
+
+ status_t err = mCodec->getName(&name);
+
+ if (err != OK) {
+ return err;
+ }
+
+ *nameStr = env->NewStringUTF(name.c_str());
+
+ return OK;
+}
+
void JMediaCodec::setVideoScalingMode(int mode) {
if (mSurfaceTextureClient != NULL) {
native_window_set_scaling_mode(mSurfaceTextureClient.get(), mode);
@@ -706,6 +720,29 @@ static jobjectArray android_media_MediaCodec_getBuffers(
return NULL;
}
+static jobject android_media_MediaCodec_getName(
+ JNIEnv *env, jobject thiz) {
+ ALOGV("android_media_MediaCodec_getName");
+
+ sp<JMediaCodec> codec = getMediaCodec(env, thiz);
+
+ if (codec == NULL) {
+ jniThrowException(env, "java/lang/IllegalStateException", NULL);
+ return NULL;
+ }
+
+ jstring name;
+ status_t err = codec->getName(env, &name);
+
+ if (err == OK) {
+ return name;
+ }
+
+ throwExceptionAsNecessary(env, err);
+
+ return NULL;
+}
+
static void android_media_MediaCodec_setVideoScalingMode(
JNIEnv *env, jobject thiz, jint mode) {
sp<JMediaCodec> codec = getMediaCodec(env, thiz);
@@ -826,6 +863,9 @@ static JNINativeMethod gMethods[] = {
{ "getBuffers", "(Z)[Ljava/nio/ByteBuffer;",
(void *)android_media_MediaCodec_getBuffers },
+ { "getName", "()Ljava/lang/String;",
+ (void *)android_media_MediaCodec_getName },
+
{ "setVideoScalingMode", "(I)V",
(void *)android_media_MediaCodec_setVideoScalingMode },
diff --git a/media/jni/android_media_MediaCodec.h b/media/jni/android_media_MediaCodec.h
index 4936b53..bc9ad50 100644
--- a/media/jni/android_media_MediaCodec.h
+++ b/media/jni/android_media_MediaCodec.h
@@ -81,6 +81,8 @@ struct JMediaCodec : public RefBase {
status_t getBuffers(
JNIEnv *env, bool input, jobjectArray *bufArray) const;
+ status_t getName(JNIEnv *env, jstring *name) const;
+
void setVideoScalingMode(int mode);
protected:
diff --git a/media/jni/android_media_MediaCodecList.cpp b/media/jni/android_media_MediaCodecList.cpp
index 0638b4a..04430ec 100644
--- a/media/jni/android_media_MediaCodecList.cpp
+++ b/media/jni/android_media_MediaCodecList.cpp
@@ -44,6 +44,25 @@ static jstring android_media_MediaCodecList_getCodecName(
return env->NewStringUTF(name);
}
+static jint android_media_MediaCodecList_findCodecByName(
+ JNIEnv *env, jobject thiz, jstring name) {
+ if (name == NULL) {
+ jniThrowException(env, "java/lang/IllegalArgumentException", NULL);
+ return -ENOENT;
+ }
+
+ const char *nameStr = env->GetStringUTFChars(name, NULL);
+
+ if (nameStr == NULL) {
+ // Out of memory exception already pending.
+ return -ENOENT;
+ }
+
+ jint ret = MediaCodecList::getInstance()->findCodecByName(nameStr);
+ env->ReleaseStringUTFChars(name, nameStr);
+ return ret;
+}
+
static jboolean android_media_MediaCodecList_isEncoder(
JNIEnv *env, jobject thiz, jint index) {
return MediaCodecList::getInstance()->isEncoder(index);
@@ -180,6 +199,9 @@ static JNINativeMethod gMethods[] = {
"(ILjava/lang/String;)Landroid/media/MediaCodecInfo$CodecCapabilities;",
(void *)android_media_MediaCodecList_getCodecCapabilities },
+ { "findCodecByName", "(Ljava/lang/String;)I",
+ (void *)android_media_MediaCodecList_findCodecByName },
+
{ "native_init", "()V", (void *)android_media_MediaCodecList_native_init },
};