diff mbox

[FFmpeg-devel,v2,1/4] avcodec/mediacodec_wrapper: add helper to fetch SDK_INT

Message ID 20180503022500.76182-1-ffmpeg@tmm1.net
State Accepted
Commit fe0a6bcbda0f51d0613dbbd42a7635c22530ce95
Headers show

Commit Message

Aman Gupta May 3, 2018, 2:24 a.m. UTC
From: Aman Gupta <aman@tmm1.net>

---
 libavcodec/mediacodec_wrapper.c | 15 +++++++++++++++
 libavcodec/mediacodec_wrapper.h |  2 ++
 2 files changed, 17 insertions(+)
diff mbox

Patch

diff --git a/libavcodec/mediacodec_wrapper.c b/libavcodec/mediacodec_wrapper.c
index 9bf96e9383..c47c2c9a41 100644
--- a/libavcodec/mediacodec_wrapper.c
+++ b/libavcodec/mediacodec_wrapper.c
@@ -1687,3 +1687,18 @@  int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec *codec)
 fail:
     return ret;
 }
+
+int ff_Build_SDK_INT(AVCodecContext *avctx)
+{
+    int ret = -1;
+    JNIEnv *env = NULL;
+    jclass versionClass;
+    jfieldID sdkIntFieldID;
+    JNI_GET_ENV_OR_RETURN(env, avctx, -1);
+
+    versionClass = (*env)->FindClass(env, "android/os/Build$VERSION");
+    sdkIntFieldID = (*env)->GetStaticFieldID(env, versionClass, "SDK_INT", "I");
+    ret = (*env)->GetStaticIntField(env, versionClass, sdkIntFieldID);
+    (*env)->DeleteLocalRef(env, versionClass);
+    return ret;
+}
diff --git a/libavcodec/mediacodec_wrapper.h b/libavcodec/mediacodec_wrapper.h
index 1b4f3a9492..f0de16d669 100644
--- a/libavcodec/mediacodec_wrapper.h
+++ b/libavcodec/mediacodec_wrapper.h
@@ -124,4 +124,6 @@  int ff_AMediaCodec_getConfigureFlagEncode(FFAMediaCodec *codec);
 
 int ff_AMediaCodec_cleanOutputBuffers(FFAMediaCodec *codec);
 
+int ff_Build_SDK_INT(AVCodecContext *avctx);
+
 #endif /* AVCODEC_MEDIACODEC_WRAPPER_H */