diff --git a/api/current.txt b/api/current.txt index de5486907589b..da304500b36bc 100644 --- a/api/current.txt +++ b/api/current.txt @@ -22448,6 +22448,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; + method public android.os.Bundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; diff --git a/api/system-current.txt b/api/system-current.txt index bdf06db863fc8..ec4f80bcddc86 100644 --- a/api/system-current.txt +++ b/api/system-current.txt @@ -24068,6 +24068,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; + method public android.os.Bundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; diff --git a/api/test-current.txt b/api/test-current.txt index 0f6502b6daeda..46e0da209e2bb 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -22540,6 +22540,7 @@ package android.media { ctor public MediaRecorder(); method public static final int getAudioSourceMax(); method public int getMaxAmplitude() throws java.lang.IllegalStateException; + method public android.os.Bundle getMetrics(); method public android.view.Surface getSurface(); method public void pause() throws java.lang.IllegalStateException; method public void prepare() throws java.io.IOException, java.lang.IllegalStateException; diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index 3e884509833b6..bb6fd6f6382f7 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -20,6 +20,7 @@ import android.annotation.NonNull; import android.annotation.SystemApi; import android.app.ActivityThread; import android.hardware.Camera; +import android.os.Bundle; import android.os.Handler; import android.os.Looper; import android.os.Message; @@ -1257,6 +1258,93 @@ public class MediaRecorder private native void setParameter(String nameValuePair); + /** + * Returns Metrics data about the current media container. + * + * @return the set of keys and values available for the media being + * handled by this instance of MediaExtractor. The keys, data types, + * and meaning are described in the following table. + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
KeyTypeDescription
{@code "ht"}IntegerHeight of the recorded video (pixels)
{@code "wid"}IntegerWidth of the recorded video (pixels)
{@code "frame-rate"}IntegerFramerate of captured Video (frames per second)
{@code "video-bitrate"}IntegerBit rate of encoded video (bits per second)
{@code "video-iframe-interval"}IntegerInterval between encoded IFrames (seconds)
{@code "video-timescale"}Integer
{@code "video-encoder-profile"}IntegerVideo Encoder Profile, as defined in OpenMAX IL
{@code "video-encoder-level"}IntegerVideo Encoder Level, as defined in OpenMAX IL
{@code "audio-bitrate"}IntegerBitrate of encoded audio (bits per second)
{@code "audio-samplerate"}Integer
{@code "audio-channels"}IntegerNumber of Audio Channels Captured
{@code "audio-timescale"}Integer
{@code "movie-timescale"}Integer
{@code "movie-timescale"}Integer
{@code "capture-fps"}Integer
{@code "rotation"}IntegerOrientation of the Video (degrees)
+ */ + + public native Bundle getMetrics(); + @Override protected void finalize() { native_finalize(); } } diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp index 7c509d297dbfc..77544eb736b56 100644 --- a/media/jni/android_media_MediaRecorder.cpp +++ b/media/jni/android_media_MediaRecorder.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -35,6 +36,7 @@ #include "jni.h" #include "JNIHelp.h" +#include "android_media_MediaMetricsJNI.h" #include "android_runtime/AndroidRuntime.h" #include @@ -625,6 +627,36 @@ void android_media_MediaRecorder_setInputSurface( "java/lang/IllegalArgumentException", "native_setInputSurface failed."); } +static jobject +android_media_MediaRecorder_getMetrics(JNIEnv *env, jobject thiz) +{ + ALOGV("android_media_MediaRecorder_getMetrics"); + + sp mr = getMediaRecorder(env, thiz); + if (mr == NULL) { + jniThrowException(env, "java/lang/IllegalStateException", NULL); + return NULL; + } + + // get what we have for the metrics from the codec + Parcel reply; + status_t err = mr->getMetrics(&reply); + if (err != OK) { + ALOGE("getMetrics failed"); + return (jobject) NULL; + } + + // build and return the Bundle + MediaAnalyticsItem *item = new MediaAnalyticsItem; + item->readFromParcel(reply); + jobject mybundle = MediaMetricsJNI::writeMetricsToBundle(env, item, NULL); + + // housekeeping + delete item; + item = NULL; + return mybundle; + +} // ---------------------------------------------------------------------------- static const JNINativeMethod gMethods[] = { @@ -655,6 +687,8 @@ static const JNINativeMethod gMethods[] = { (void *)android_media_MediaRecorder_native_setup}, {"native_finalize", "()V", (void *)android_media_MediaRecorder_native_finalize}, {"native_setInputSurface", "(Landroid/view/Surface;)V", (void *)android_media_MediaRecorder_setInputSurface }, + + {"getMetrics", "()Landroid/os/Bundle;", (void *)android_media_MediaRecorder_getMetrics}, }; // This function only registers the native methods, and is called from