Loading media/java/android/media/DecoderCapabilities.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media; import java.util.List; import java.util.ArrayList; /** * {@hide} * * The DecoderCapabilities class is used to retrieve the types of the * video and audio decoder(s) supported on a specific Android platform. */ public class DecoderCapabilities { /** * The VideoDecoder class represents the type of a video decoder * */ public enum VideoDecoder { VIDEO_DECODER_WMV, }; /** * The AudioDecoder class represents the type of an audio decoder */ public enum AudioDecoder { AUDIO_DECODER_WMA, }; static { System.loadLibrary("media_jni"); native_init(); } /** * Returns the list of video decoder types * @see android.media.DecoderCapabilities.VideoDecoder */ public static List<VideoDecoder> getVideoDecoders() { List<VideoDecoder> decoderList = new ArrayList<VideoDecoder>(); int nDecoders = native_get_num_video_decoders(); for (int i = 0; i < nDecoders; ++i) { decoderList.add(VideoDecoder.values()[native_get_video_decoder_type(i)]); } return decoderList; } /** * Returns the list of audio decoder types * @see android.media.DecoderCapabilities.AudioDecoder */ public static List<AudioDecoder> getAudioDecoders() { List<AudioDecoder> decoderList = new ArrayList<AudioDecoder>(); int nDecoders = native_get_num_audio_decoders(); for (int i = 0; i < nDecoders; ++i) { decoderList.add(AudioDecoder.values()[native_get_audio_decoder_type(i)]); } return decoderList; } private DecoderCapabilities() {} // Don't call me // Implemented by JNI private static native final void native_init(); private static native final int native_get_num_video_decoders(); private static native final int native_get_video_decoder_type(int index); private static native final int native_get_num_audio_decoders(); private static native final int native_get_audio_decoder_type(int index); } media/jni/android_media_MediaProfiles.cpp +63 −8 Original line number Diff line number Diff line Loading @@ -44,14 +44,14 @@ android_media_MediaProfiles_native_init(JNIEnv *env) } } static int static jint android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) { LOGV("native_get_num_file_formats"); return sProfiles->getOutputFileFormats().size(); } static int static jint android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_file_format: %d", index); Loading @@ -61,11 +61,10 @@ android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, ji jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } int format = static_cast<int>(formats[index]); return format; return static_cast<jint>(formats[index]); } static int static jint android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_video_encoders"); Loading Loading @@ -116,7 +115,7 @@ android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject th return cap; } static int static jint android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_audio_encoders"); Loading Loading @@ -209,6 +208,48 @@ android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject th audioChannels); } static jint android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_video_decoders"); return sProfiles->getVideoDecoders().size(); } static jint android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_video_decoder_type: %d", index); Vector<video_decoder> decoders = sProfiles->getVideoDecoders(); int nSize = decoders.size(); if (index < 0 || index >= nSize) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } return static_cast<jint>(decoders[index]); } static jint android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_audio_decoders"); return sProfiles->getAudioDecoders().size(); } static jint android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_audio_decoder_type: %d", index); Vector<audio_decoder> decoders = sProfiles->getAudioDecoders(); int nSize = decoders.size(); if (index < 0 || index >= nSize) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } return static_cast<jint>(decoders[index]); } static JNINativeMethod gMethodsForEncoderCapabilitiesClass[] = { {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, {"native_get_num_file_formats", "()I", (void *)android_media_MediaProfiles_native_get_num_file_formats}, Loading @@ -229,7 +270,16 @@ static JNINativeMethod gMethodsForCamcorderProfileClass[] = { (void *)android_media_MediaProfiles_native_get_camcorder_profile}, }; static JNINativeMethod gMethodsForDecoderCapabilitiesClass[] = { {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, {"native_get_num_video_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_video_decoders}, {"native_get_num_audio_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_audio_decoders}, {"native_get_video_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_video_decoder_type}, {"native_get_audio_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_audio_decoder_type}, }; static const char* const kEncoderCapabilitiesClassPathName = "android/media/EncoderCapabilities"; static const char* const kDecoderCapabilitiesClassPathName = "android/media/DecoderCapabilities"; static const char* const kCamcorderProfileClassPathName = "android/media/CamcorderProfile"; // This function only registers the native methods, and is called from Loading @@ -246,6 +296,11 @@ int register_android_media_MediaProfiles(JNIEnv *env) gMethodsForCamcorderProfileClass, NELEM(gMethodsForCamcorderProfileClass)); // Success if ret1 == 0 && ret2 == 0 return (ret1 || ret2); int ret3 = AndroidRuntime::registerNativeMethods(env, kDecoderCapabilitiesClassPathName, gMethodsForDecoderCapabilitiesClass, NELEM(gMethodsForDecoderCapabilitiesClass)); // Success if ret1 == 0 && ret2 == 0 && ret3 == 0 return (ret1 || ret2 || ret3); } Loading
media/java/android/media/DecoderCapabilities.java 0 → 100644 +84 −0 Original line number Diff line number Diff line /* * Copyright (C) 2010 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.media; import java.util.List; import java.util.ArrayList; /** * {@hide} * * The DecoderCapabilities class is used to retrieve the types of the * video and audio decoder(s) supported on a specific Android platform. */ public class DecoderCapabilities { /** * The VideoDecoder class represents the type of a video decoder * */ public enum VideoDecoder { VIDEO_DECODER_WMV, }; /** * The AudioDecoder class represents the type of an audio decoder */ public enum AudioDecoder { AUDIO_DECODER_WMA, }; static { System.loadLibrary("media_jni"); native_init(); } /** * Returns the list of video decoder types * @see android.media.DecoderCapabilities.VideoDecoder */ public static List<VideoDecoder> getVideoDecoders() { List<VideoDecoder> decoderList = new ArrayList<VideoDecoder>(); int nDecoders = native_get_num_video_decoders(); for (int i = 0; i < nDecoders; ++i) { decoderList.add(VideoDecoder.values()[native_get_video_decoder_type(i)]); } return decoderList; } /** * Returns the list of audio decoder types * @see android.media.DecoderCapabilities.AudioDecoder */ public static List<AudioDecoder> getAudioDecoders() { List<AudioDecoder> decoderList = new ArrayList<AudioDecoder>(); int nDecoders = native_get_num_audio_decoders(); for (int i = 0; i < nDecoders; ++i) { decoderList.add(AudioDecoder.values()[native_get_audio_decoder_type(i)]); } return decoderList; } private DecoderCapabilities() {} // Don't call me // Implemented by JNI private static native final void native_init(); private static native final int native_get_num_video_decoders(); private static native final int native_get_video_decoder_type(int index); private static native final int native_get_num_audio_decoders(); private static native final int native_get_audio_decoder_type(int index); }
media/jni/android_media_MediaProfiles.cpp +63 −8 Original line number Diff line number Diff line Loading @@ -44,14 +44,14 @@ android_media_MediaProfiles_native_init(JNIEnv *env) } } static int static jint android_media_MediaProfiles_native_get_num_file_formats(JNIEnv *env, jobject thiz) { LOGV("native_get_num_file_formats"); return sProfiles->getOutputFileFormats().size(); } static int static jint android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_file_format: %d", index); Loading @@ -61,11 +61,10 @@ android_media_MediaProfiles_native_get_file_format(JNIEnv *env, jobject thiz, ji jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } int format = static_cast<int>(formats[index]); return format; return static_cast<jint>(formats[index]); } static int static jint android_media_MediaProfiles_native_get_num_video_encoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_video_encoders"); Loading Loading @@ -116,7 +115,7 @@ android_media_MediaProfiles_native_get_video_encoder_cap(JNIEnv *env, jobject th return cap; } static int static jint android_media_MediaProfiles_native_get_num_audio_encoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_audio_encoders"); Loading Loading @@ -209,6 +208,48 @@ android_media_MediaProfiles_native_get_camcorder_profile(JNIEnv *env, jobject th audioChannels); } static jint android_media_MediaProfiles_native_get_num_video_decoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_video_decoders"); return sProfiles->getVideoDecoders().size(); } static jint android_media_MediaProfiles_native_get_video_decoder_type(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_video_decoder_type: %d", index); Vector<video_decoder> decoders = sProfiles->getVideoDecoders(); int nSize = decoders.size(); if (index < 0 || index >= nSize) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } return static_cast<jint>(decoders[index]); } static jint android_media_MediaProfiles_native_get_num_audio_decoders(JNIEnv *env, jobject thiz) { LOGV("native_get_num_audio_decoders"); return sProfiles->getAudioDecoders().size(); } static jint android_media_MediaProfiles_native_get_audio_decoder_type(JNIEnv *env, jobject thiz, jint index) { LOGV("native_get_audio_decoder_type: %d", index); Vector<audio_decoder> decoders = sProfiles->getAudioDecoders(); int nSize = decoders.size(); if (index < 0 || index >= nSize) { jniThrowException(env, "java/lang/IllegalArgumentException", "out of array boundary"); return -1; } return static_cast<jint>(decoders[index]); } static JNINativeMethod gMethodsForEncoderCapabilitiesClass[] = { {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, {"native_get_num_file_formats", "()I", (void *)android_media_MediaProfiles_native_get_num_file_formats}, Loading @@ -229,7 +270,16 @@ static JNINativeMethod gMethodsForCamcorderProfileClass[] = { (void *)android_media_MediaProfiles_native_get_camcorder_profile}, }; static JNINativeMethod gMethodsForDecoderCapabilitiesClass[] = { {"native_init", "()V", (void *)android_media_MediaProfiles_native_init}, {"native_get_num_video_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_video_decoders}, {"native_get_num_audio_decoders", "()I", (void *)android_media_MediaProfiles_native_get_num_audio_decoders}, {"native_get_video_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_video_decoder_type}, {"native_get_audio_decoder_type", "(I)I", (void *)android_media_MediaProfiles_native_get_audio_decoder_type}, }; static const char* const kEncoderCapabilitiesClassPathName = "android/media/EncoderCapabilities"; static const char* const kDecoderCapabilitiesClassPathName = "android/media/DecoderCapabilities"; static const char* const kCamcorderProfileClassPathName = "android/media/CamcorderProfile"; // This function only registers the native methods, and is called from Loading @@ -246,6 +296,11 @@ int register_android_media_MediaProfiles(JNIEnv *env) gMethodsForCamcorderProfileClass, NELEM(gMethodsForCamcorderProfileClass)); // Success if ret1 == 0 && ret2 == 0 return (ret1 || ret2); int ret3 = AndroidRuntime::registerNativeMethods(env, kDecoderCapabilitiesClassPathName, gMethodsForDecoderCapabilitiesClass, NELEM(gMethodsForDecoderCapabilitiesClass)); // Success if ret1 == 0 && ret2 == 0 && ret3 == 0 return (ret1 || ret2 || ret3); }