API android.media.MediaExtractor.getMetrics()
adds the API getMetrics() to android.media.MediaExtractor includes plumbing through JNI to the underlying mediaextractor code in frameworks/av. Tested with some CTS modifications; a more formal set of CTS updates will be along later. Bug: 35094936 Test: modified CTS to invoke new API and output results Change-Id: Id8d56c9c3273b86bbd11e248bdf5004be90b91ef
This commit is contained in:
@@ -21992,6 +21992,7 @@ package android.media {
|
||||
method public boolean advance();
|
||||
method public long getCachedDuration();
|
||||
method public android.media.DrmInitData getDrmInitData();
|
||||
method public android.os.Bundle getMetrics();
|
||||
method public java.util.Map<java.util.UUID, byte[]> getPsshInfo();
|
||||
method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo);
|
||||
method public int getSampleFlags();
|
||||
|
||||
@@ -23603,6 +23603,7 @@ package android.media {
|
||||
method public boolean advance();
|
||||
method public long getCachedDuration();
|
||||
method public android.media.DrmInitData getDrmInitData();
|
||||
method public android.os.Bundle getMetrics();
|
||||
method public java.util.Map<java.util.UUID, byte[]> getPsshInfo();
|
||||
method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo);
|
||||
method public int getSampleFlags();
|
||||
|
||||
@@ -22084,6 +22084,7 @@ package android.media {
|
||||
method public boolean advance();
|
||||
method public long getCachedDuration();
|
||||
method public android.media.DrmInitData getDrmInitData();
|
||||
method public android.os.Bundle getMetrics();
|
||||
method public java.util.Map<java.util.UUID, byte[]> getPsshInfo();
|
||||
method public boolean getSampleCryptoInfo(android.media.MediaCodec.CryptoInfo);
|
||||
method public int getSampleFlags();
|
||||
|
||||
@@ -26,6 +26,7 @@ import android.media.MediaCodec;
|
||||
import android.media.MediaFormat;
|
||||
import android.media.MediaHTTPService;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
|
||||
import com.android.internal.util.Preconditions;
|
||||
@@ -598,6 +599,16 @@ final public class MediaExtractor {
|
||||
*/
|
||||
public native boolean hasCacheReachedEndOfStream();
|
||||
|
||||
/**
|
||||
* Returns Analytics/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
|
||||
*
|
||||
*/
|
||||
public native Bundle getMetrics();
|
||||
|
||||
|
||||
private static native final void native_init();
|
||||
private native final void native_setup();
|
||||
private native final void native_finalize();
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include "android_media_MediaExtractor.h"
|
||||
#include "android_media_MediaMetricsJNI.h"
|
||||
|
||||
#include "android_media_Utils.h"
|
||||
#include "android_runtime/AndroidRuntime.h"
|
||||
@@ -240,6 +241,13 @@ status_t JMediaExtractor::getSampleFlags(uint32_t *sampleFlags) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t JMediaExtractor::getMetrics(Parcel *reply) const {
|
||||
|
||||
status_t status = mImpl->getMetrics(reply);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
status_t JMediaExtractor::getSampleMeta(sp<MetaData> *sampleMeta) {
|
||||
return mImpl->getSampleMeta(sampleMeta);
|
||||
}
|
||||
@@ -767,6 +775,38 @@ static void android_media_MediaExtractor_native_finalize(
|
||||
android_media_MediaExtractor_release(env, thiz);
|
||||
}
|
||||
|
||||
static jobject
|
||||
android_media_MediaExtractor_getMetrics(JNIEnv * env, jobject thiz)
|
||||
{
|
||||
ALOGV("android_media_MediaExtractor_getMetrics");
|
||||
|
||||
sp<JMediaExtractor> extractor = getMediaExtractor(env, thiz);
|
||||
if (extractor == NULL ) {
|
||||
jniThrowException(env, "java/lang/IllegalStateException", NULL);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// get what we have for the metrics from the codec
|
||||
Parcel reply;
|
||||
status_t err = extractor->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[] = {
|
||||
{ "release", "()V", (void *)android_media_MediaExtractor_release },
|
||||
|
||||
@@ -826,6 +866,9 @@ static const JNINativeMethod gMethods[] = {
|
||||
|
||||
{ "hasCacheReachedEndOfStream", "()Z",
|
||||
(void *)android_media_MediaExtractor_hasCacheReachedEOS },
|
||||
|
||||
{"getMetrics", "()Landroid/os/Bundle;",
|
||||
(void *)android_media_MediaExtractor_getMetrics},
|
||||
};
|
||||
|
||||
int register_android_media_MediaExtractor(JNIEnv *env) {
|
||||
|
||||
@@ -60,6 +60,7 @@ struct JMediaExtractor : public RefBase {
|
||||
status_t getSampleTime(int64_t *sampleTimeUs);
|
||||
status_t getSampleFlags(uint32_t *sampleFlags);
|
||||
status_t getSampleMeta(sp<MetaData> *sampleMeta);
|
||||
status_t getMetrics(Parcel *reply) const;
|
||||
|
||||
bool getCachedDuration(int64_t *durationUs, bool *eos) const;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user