From 5911b729b69b7fb327e441b33f22eb1ef31a03df Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Mon, 2 Apr 2012 08:36:38 +0200 Subject: Initial commit for AudioVideo (com.jogamp.opengl.av) rework, introducing Android API 14 MediaPlayer impl of GLMediaPlayer. Android API 14 MediaPlayer allows usage of OMX AL direct decode to texture via libstagefright (OMX AL usage included). Status: Untested, not working - Need to fix native OMX IL (stream detect and split) and/or GStreamer implementation. --- .../native/openmax/com_sun_openmax_OMXInstance.c | 255 --------------------- .../openmax/jogamp.opengl.omx.OMXGLMediaPlayer.c | 252 ++++++++++++++++++++ src/jogl/native/openmax/omx_tool.c | 6 +- src/jogl/native/openmax/omx_tool.h | 2 +- 4 files changed, 256 insertions(+), 259 deletions(-) delete mode 100644 src/jogl/native/openmax/com_sun_openmax_OMXInstance.c create mode 100644 src/jogl/native/openmax/jogamp.opengl.omx.OMXGLMediaPlayer.c (limited to 'src/jogl/native/openmax') diff --git a/src/jogl/native/openmax/com_sun_openmax_OMXInstance.c b/src/jogl/native/openmax/com_sun_openmax_OMXInstance.c deleted file mode 100644 index 5317c2abc..000000000 --- a/src/jogl/native/openmax/com_sun_openmax_OMXInstance.c +++ /dev/null @@ -1,255 +0,0 @@ -/* - * media_video_Movie.c - * JFXFramework - * - * Created by sun on 17/02/08. - * Copyright 2007 __MyCompanyName__. All rights reserved. - * - */ - -// http://developer.apple.com/technotes/tn2005/tn2140.html -// http://developer.apple.com/qa/qa2005/qa1443.html -// http://developer.apple.com/documentation/QuickTime/Conceptual/QT7UpdateGuide/Chapter03/chapter_3_section_1.html#//apple_ref/doc/c_ref/NewMovieFromProperties -// http://developer.apple.com/qa/qa2001/qa1149.html -// http://developer.apple.com/qa/qa2001/qa1262.html - -#include "com_jogamp_openmax_OMXInstance.h" -#include "omx_tool.h" -#include - -static const char * const ClazzNameRuntimeException = - "java/lang/RuntimeException"; -static jclass runtimeExceptionClz=NULL; -#ifdef _WIN32_WCE - #define STDOUT_FILE "\\Storage Card\\demos\\stdout.txt" - #define STDERR_FILE "\\Storage Card\\demos\\stderr.txt" -#endif - -static void _initStatics(JNIEnv *env) -{ - jclass c; -#ifdef _WIN32_WCE - _wfreopen(TEXT(STDOUT_FILE),L"w",stdout); - _wfreopen(TEXT(STDERR_FILE),L"w",stderr); -#endif - fprintf(stdout, "_initstatics ..\n"); fflush(stdout); // JAU - if (runtimeExceptionClz != NULL) { - return; - } - - c = (*env)->FindClass(env, ClazzNameRuntimeException); - if(NULL==c) { - fprintf(stdout, "FatalError: can't find %s\n", ClazzNameRuntimeException); - (*env)->FatalError(env, ClazzNameRuntimeException); - } - runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); - if(NULL==runtimeExceptionClz) { - fprintf(stdout, "FatalError: can't use %s\n", ClazzNameRuntimeException); - (*env)->FatalError(env, ClazzNameRuntimeException); - } -} - -void java_throwNewRuntimeException(intptr_t jni_env, const char* format, ...) -{ - va_list ap; - char buffer[255]; - va_start(ap, format); - #ifdef _WIN32 - _vsnprintf(buffer, sizeof(buffer)-1, format, ap); - #else - vsnprintf(buffer, sizeof(buffer)-1, format, ap); - #endif - va_end(ap); - buffer[sizeof(buffer)-1]=0; - fprintf(stderr, "RuntimeException: %s\n", buffer); fflush(stderr); - if(jni_env!=0) { - (*((JNIEnv *)jni_env))->ThrowNew((JNIEnv *)jni_env, runtimeExceptionClz, buffer); - } -} - -void OMXInstance_SaveJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback) -{ - if(NULL==pOMXAV || 0==pOMXAV->jni_env || 0==pOMXAV->jni_instance) { - fprintf(stderr, "OMXInstance_SaveJavaAttributes failed"); - return; - } else if(issueJavaCallback==KD_TRUE) { - JNIEnv * env = (JNIEnv *)pOMXAV->jni_env; - jobject instance = (jobject)pOMXAV->jni_instance; - (*env)->CallVoidMethod(env, instance, (jmethodID)pOMXAV->jni_mid_saveAttributes); - } -} - -void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback) -{ - if(NULL==pOMXAV || 0==pOMXAV->jni_env || 0==pOMXAV->jni_instance) { - fprintf(stderr, "OMXInstance_UpdateJavaAttributes failed"); - return; - } else { - JNIEnv * env = (JNIEnv *)pOMXAV->jni_env; - jobject instance = (jobject)pOMXAV->jni_instance; - (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_width, (jint)pOMXAV->width); - (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_height, (jint)pOMXAV->height); - (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_fps, (jint)pOMXAV->framerate); - (*env)->SetLongField(env, instance, (jfieldID)pOMXAV->jni_fid_bps, (jlong)pOMXAV->bitrate); - (*env)->SetLongField(env, instance, (jfieldID)pOMXAV->jni_fid_totalFrames, (jlong)(pOMXAV->length*pOMXAV->framerate)); - if(issueJavaCallback==KD_TRUE) { - (*env)->CallVoidMethod(env, instance, (jmethodID)pOMXAV->jni_mid_attributesUpdated); - } else { - if(strlen(pOMXAV->videoCodec)>0) { - (*env)->SetObjectField(env, instance, (jfieldID)pOMXAV->jni_fid_vcodec, (*env)->NewStringUTF(env, pOMXAV->videoCodec)); - } - if(strlen(pOMXAV->audioCodec)>0) { - (*env)->SetObjectField(env, instance, (jfieldID)pOMXAV->jni_fid_acodec, (*env)->NewStringUTF(env, pOMXAV->audioCodec)); - } - } - } -} - -JNIEXPORT jlong JNICALL Java_com_jogamp_openmax_OMXInstance__1createInstance - (JNIEnv *env, jobject instance) -{ - OMXToolBasicAV_t * pOMXAV; - - _initStatics(env); - - pOMXAV->jni_env=(intptr_t)env; - pOMXAV->jni_instance=(intptr_t)instance; - - pOMXAV = OMXToolBasicAV_CreateInstance((intptr_t)env, (intptr_t)instance); - if(NULL!=pOMXAV) { - jclass cls = (*env)->GetObjectClass(env, instance); - pOMXAV->jni_mid_saveAttributes = (intptr_t) (*env)->GetMethodID(env, cls, "saveAttributes", "()V"); - pOMXAV->jni_mid_attributesUpdated = (intptr_t) (*env)->GetMethodID(env, cls, "attributesUpdated", "()V"); - pOMXAV->jni_fid_width = (intptr_t) (*env)->GetFieldID(env, cls, "width", "I"); - pOMXAV->jni_fid_height = (intptr_t) (*env)->GetFieldID(env, cls, "height", "I"); - pOMXAV->jni_fid_fps = (intptr_t) (*env)->GetFieldID(env, cls, "fps", "I"); - pOMXAV->jni_fid_bps = (intptr_t) (*env)->GetFieldID(env, cls, "bps", "J"); - pOMXAV->jni_fid_totalFrames = (intptr_t) (*env)->GetFieldID(env, cls, "totalFrames", "J"); - pOMXAV->jni_fid_acodec = (intptr_t) (*env)->GetFieldID(env, cls, "acodec", "Ljava/lang/String;"); - pOMXAV->jni_fid_vcodec = (intptr_t) (*env)->GetFieldID(env, cls, "vcodec", "Ljava/lang/String;"); - } - - return (jlong) (intptr_t) (void *)pOMXAV; -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1setStream - (JNIEnv *env, jobject instance, jlong ptr, jint vBufferNum, jstring jpath) -{ - jboolean iscopy; - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - - fprintf(stdout, "setStream 1 ..\n"); fflush(stdout); // JAU - if (pOMXAV != NULL) { - const char *filePath = (*env)->GetStringUTFChars(env, jpath, &iscopy); - fprintf(stdout, "setStream 2 %s..\n", filePath); fflush(stdout); // JAU - pOMXAV->jni_env=(intptr_t)env; - pOMXAV->jni_instance=(intptr_t)instance; - OMXToolBasicAV_SetStream(pOMXAV, vBufferNum, filePath); - (*env)->ReleaseStringChars(env, jpath, (const jchar *)filePath); - } - fprintf(stdout, "setStream 3 ..\n"); fflush(stdout); // JAU -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1setStreamEGLImageTexture2D - (JNIEnv *env, jobject instance, jlong ptr, jint i, jint tex, jlong image, jlong sync) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - if (pOMXAV != NULL) { - OMXToolBasicAV_SetStreamEGLImageTexture2D( pOMXAV, i, (GLuint) tex, - (EGLImageKHR)(intptr_t)image, - (EGLSyncKHR)(intptr_t)sync); - } -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1activateStream - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - - if (pOMXAV != NULL) { - OMXToolBasicAV_ActivateStream(pOMXAV); - } -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1attachVideoRenderer - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_AttachVideoRenderer(pOMXAV); -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1detachVideoRenderer - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_DetachVideoRenderer(pOMXAV); -} - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1setPlaySpeed - (JNIEnv *env, jobject instance, jlong ptr, jfloat scale) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_SetPlaySpeed(pOMXAV, scale); -} - -JNIEXPORT jfloat JNICALL Java_com_jogamp_openmax_OMXInstance__1play - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_PlayStart(pOMXAV); - return OMXToolBasicAV_GetCurrentPosition(pOMXAV); -} - -JNIEXPORT jfloat JNICALL Java_com_jogamp_openmax_OMXInstance__1pause - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_PlayPause(pOMXAV); - return OMXToolBasicAV_GetCurrentPosition(pOMXAV); -} - -JNIEXPORT jfloat JNICALL Java_com_jogamp_openmax_OMXInstance__1stop - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_PlayStop(pOMXAV); - return OMXToolBasicAV_GetCurrentPosition(pOMXAV); -} - -JNIEXPORT jfloat JNICALL Java_com_jogamp_openmax_OMXInstance__1seek - (JNIEnv *env, jobject instance, jlong ptr, jfloat pos) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - OMXToolBasicAV_PlaySeek(pOMXAV, pos); - return OMXToolBasicAV_GetCurrentPosition(pOMXAV); -} - -JNIEXPORT jint JNICALL Java_com_jogamp_openmax_OMXInstance__1getNextTextureID - (JNIEnv *env, jobject instance, jlong ptr) -{ - jint textureID = 0xffffffff; - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - if (pOMXAV != NULL) { - textureID = OMXToolBasicAV_GetNextTextureID(pOMXAV); - } - return textureID; -} - -JNIEXPORT jfloat JNICALL Java_com_jogamp_openmax_OMXInstance__1getCurrentPosition - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - return OMXToolBasicAV_GetCurrentPosition(pOMXAV); -} - - -JNIEXPORT void JNICALL Java_com_jogamp_openmax_OMXInstance__1destroyInstance - (JNIEnv *env, jobject instance, jlong ptr) -{ - OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); - if (pOMXAV != NULL) { - OMXToolBasicAV_DestroyInstance(pOMXAV); - } -} - - diff --git a/src/jogl/native/openmax/jogamp.opengl.omx.OMXGLMediaPlayer.c b/src/jogl/native/openmax/jogamp.opengl.omx.OMXGLMediaPlayer.c new file mode 100644 index 000000000..00c0ca562 --- /dev/null +++ b/src/jogl/native/openmax/jogamp.opengl.omx.OMXGLMediaPlayer.c @@ -0,0 +1,252 @@ +/* + * media_video_Movie.c + * JFXFramework + * + * Created by sun on 17/02/08. + * Copyright 2007 __MyCompanyName__. All rights reserved. + * + */ + +// http://developer.apple.com/technotes/tn2005/tn2140.html +// http://developer.apple.com/qa/qa2005/qa1443.html +// http://developer.apple.com/documentation/QuickTime/Conceptual/QT7UpdateGuide/Chapter03/chapter_3_section_1.html#//apple_ref/doc/c_ref/NewMovieFromProperties +// http://developer.apple.com/qa/qa2001/qa1149.html +// http://developer.apple.com/qa/qa2001/qa1262.html + +#include "jogamp_opengl_omx_OMXGLMediaPlayer.h" +#include "omx_tool.h" +#include + +static const char * const ClazzNameRuntimeException = + "java/lang/RuntimeException"; +static jclass runtimeExceptionClz=NULL; +#ifdef _WIN32_WCE + #define STDOUT_FILE "\\Storage Card\\demos\\stdout.txt" + #define STDERR_FILE "\\Storage Card\\demos\\stderr.txt" +#endif + +static void _initStatics(JNIEnv *env) +{ + jclass c; +#ifdef _WIN32_WCE + _wfreopen(TEXT(STDOUT_FILE),L"w",stdout); + _wfreopen(TEXT(STDERR_FILE),L"w",stderr); +#endif + fprintf(stdout, "_initstatics ..\n"); fflush(stdout); // JAU + if (runtimeExceptionClz != NULL) { + return; + } + + c = (*env)->FindClass(env, ClazzNameRuntimeException); + if(NULL==c) { + fprintf(stdout, "FatalError: can't find %s\n", ClazzNameRuntimeException); + (*env)->FatalError(env, ClazzNameRuntimeException); + } + runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); + if(NULL==runtimeExceptionClz) { + fprintf(stdout, "FatalError: can't use %s\n", ClazzNameRuntimeException); + (*env)->FatalError(env, ClazzNameRuntimeException); + } +} + +void java_throwNewRuntimeException(intptr_t jni_env, const char* format, ...) +{ + va_list ap; + char buffer[255]; + va_start(ap, format); + #ifdef _WIN32 + _vsnprintf(buffer, sizeof(buffer)-1, format, ap); + #else + vsnprintf(buffer, sizeof(buffer)-1, format, ap); + #endif + va_end(ap); + buffer[sizeof(buffer)-1]=0; + fprintf(stderr, "RuntimeException: %s\n", buffer); fflush(stderr); + if(jni_env!=0) { + (*((JNIEnv *)jni_env))->ThrowNew((JNIEnv *)jni_env, runtimeExceptionClz, buffer); + } +} + +void OMXInstance_SaveJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback) +{ + if(NULL==pOMXAV || 0==pOMXAV->jni_env || 0==pOMXAV->jni_instance) { + fprintf(stderr, "OMXInstance_SaveJavaAttributes failed"); + return; + } else if(issueJavaCallback==KD_TRUE) { + JNIEnv * env = (JNIEnv *)pOMXAV->jni_env; + jobject instance = (jobject)pOMXAV->jni_instance; + (*env)->CallVoidMethod(env, instance, (jmethodID)pOMXAV->jni_mid_saveAttributes); + } +} + +void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback) +{ + if(NULL==pOMXAV || 0==pOMXAV->jni_env || 0==pOMXAV->jni_instance) { + fprintf(stderr, "OMXInstance_UpdateJavaAttributes failed"); + return; + } else { + JNIEnv * env = (JNIEnv *)pOMXAV->jni_env; + jobject instance = (jobject)pOMXAV->jni_instance; + (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_width, (jint)pOMXAV->width); + (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_height, (jint)pOMXAV->height); + (*env)->SetIntField(env, instance, (jfieldID)pOMXAV->jni_fid_fps, (jint)pOMXAV->framerate); + (*env)->SetLongField(env, instance, (jfieldID)pOMXAV->jni_fid_bps, (jlong)pOMXAV->bitrate); + (*env)->SetLongField(env, instance, (jfieldID)pOMXAV->jni_fid_totalFrames, (jlong)(pOMXAV->length*pOMXAV->framerate)); + if(issueJavaCallback==KD_TRUE) { + (*env)->CallVoidMethod(env, instance, (jmethodID)pOMXAV->jni_mid_attributesUpdated); + } else { + if(strlen(pOMXAV->videoCodec)>0) { + (*env)->SetObjectField(env, instance, (jfieldID)pOMXAV->jni_fid_vcodec, (*env)->NewStringUTF(env, pOMXAV->videoCodec)); + } + if(strlen(pOMXAV->audioCodec)>0) { + (*env)->SetObjectField(env, instance, (jfieldID)pOMXAV->jni_fid_acodec, (*env)->NewStringUTF(env, pOMXAV->audioCodec)); + } + } + } +} + +JNIEXPORT jlong JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1createInstance + (JNIEnv *env, jobject instance) +{ + OMXToolBasicAV_t * pOMXAV; + + _initStatics(env); + + pOMXAV->jni_env=(intptr_t)env; + pOMXAV->jni_instance=(intptr_t)instance; + + pOMXAV = OMXToolBasicAV_CreateInstance((intptr_t)env, (intptr_t)instance); + if(NULL!=pOMXAV) { + jclass cls = (*env)->GetObjectClass(env, instance); + pOMXAV->jni_mid_saveAttributes = (intptr_t) (*env)->GetMethodID(env, cls, "saveAttributes", "()V"); + pOMXAV->jni_mid_attributesUpdated = (intptr_t) (*env)->GetMethodID(env, cls, "attributesUpdated", "()V"); + pOMXAV->jni_fid_width = (intptr_t) (*env)->GetFieldID(env, cls, "width", "I"); + pOMXAV->jni_fid_height = (intptr_t) (*env)->GetFieldID(env, cls, "height", "I"); + pOMXAV->jni_fid_fps = (intptr_t) (*env)->GetFieldID(env, cls, "fps", "I"); + pOMXAV->jni_fid_bps = (intptr_t) (*env)->GetFieldID(env, cls, "bps", "J"); + pOMXAV->jni_fid_totalFrames = (intptr_t) (*env)->GetFieldID(env, cls, "totalFrames", "J"); + pOMXAV->jni_fid_acodec = (intptr_t) (*env)->GetFieldID(env, cls, "acodec", "Ljava/lang/String;"); + pOMXAV->jni_fid_vcodec = (intptr_t) (*env)->GetFieldID(env, cls, "vcodec", "Ljava/lang/String;"); + } + + return (jlong) (intptr_t) (void *)pOMXAV; +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1setStream + (JNIEnv *env, jobject instance, jlong ptr, jint vBufferNum, jstring jpath) +{ + jboolean iscopy; + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + + fprintf(stdout, "setStream 1 ..\n"); fflush(stdout); // JAU + if (pOMXAV != NULL) { + const char *filePath = (*env)->GetStringUTFChars(env, jpath, &iscopy); + fprintf(stdout, "setStream 2 %s..\n", filePath); fflush(stdout); // JAU + pOMXAV->jni_env=(intptr_t)env; + pOMXAV->jni_instance=(intptr_t)instance; + OMXToolBasicAV_SetStream(pOMXAV, vBufferNum, filePath); + (*env)->ReleaseStringChars(env, jpath, (const jchar *)filePath); + } + fprintf(stdout, "setStream 3 ..\n"); fflush(stdout); // JAU +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1setStreamEGLImageTexture2D + (JNIEnv *env, jobject instance, jlong ptr, jint i, jint tex, jlong image, jlong sync) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + if (pOMXAV != NULL) { + OMXToolBasicAV_SetStreamEGLImageTexture2D( pOMXAV, i, (GLuint) tex, + (EGLImageKHR)(intptr_t)image, + (EGLSyncKHR)(intptr_t)sync); + } +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1activateStream + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + + if (pOMXAV != NULL) { + OMXToolBasicAV_ActivateStream(pOMXAV); + } +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1attachVideoRenderer + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_AttachVideoRenderer(pOMXAV); +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1detachVideoRenderer + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_DetachVideoRenderer(pOMXAV); +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1setPlaySpeed + (JNIEnv *env, jobject instance, jlong ptr, jfloat scale) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_SetPlaySpeed(pOMXAV, scale); +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1play + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_PlayStart(pOMXAV); +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1pause + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_PlayPause(pOMXAV); +} + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1stop + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_PlayStop(pOMXAV); +} + +JNIEXPORT jint JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1seek + (JNIEnv *env, jobject instance, jlong ptr, jfloat pos) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + OMXToolBasicAV_PlaySeek(pOMXAV, pos); + return OMXToolBasicAV_GetCurrentPosition(pOMXAV); +} + +JNIEXPORT jint JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1getNextTextureID + (JNIEnv *env, jobject instance, jlong ptr) +{ + jint textureID = 0xffffffff; + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + if (pOMXAV != NULL) { + textureID = OMXToolBasicAV_GetNextTextureID(pOMXAV); + } + return textureID; +} + +JNIEXPORT jint JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1getCurrentPosition + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + return OMXToolBasicAV_GetCurrentPosition(pOMXAV); +} + + +JNIEXPORT void JNICALL Java_jogamp_opengl_omx_OMXGLMediaPlayer__1destroyInstance + (JNIEnv *env, jobject instance, jlong ptr) +{ + OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); + if (pOMXAV != NULL) { + OMXToolBasicAV_DestroyInstance(pOMXAV); + } +} + + diff --git a/src/jogl/native/openmax/omx_tool.c b/src/jogl/native/openmax/omx_tool.c index 57fa8ad21..1f2ce7da7 100644 --- a/src/jogl/native/openmax/omx_tool.c +++ b/src/jogl/native/openmax/omx_tool.c @@ -627,14 +627,14 @@ static int StartClock(OMXToolBasicAV_t * pOMXAV, KDboolean start, KDfloat32 time return (OMX_ErrorNotReady == eError)?-1:0; } -static KDfloat32 GetClockPosition(OMXToolBasicAV_t * pOMXAV) +static KDint GetClockPosition(OMXToolBasicAV_t * pOMXAV) { OMX_TIME_CONFIG_TIMESTAMPTYPE stamp; INIT_PARAM(stamp); stamp.nPortIndex = 0; OMX_GetConfig(pOMXAV->comp[OMXAV_H_CLOCK], OMX_IndexConfigTimeCurrentMediaTime, &stamp); - return (KDfloat32) (stamp.nTimestamp * (1.0f/(1000.0f*1000.0f))); + return (int) ( stamp.nTimestamp / 1000 ); } static KDfloat32 GetClockScale(OMXToolBasicAV_t * pOMXAV) @@ -1474,7 +1474,7 @@ GLuint OMXToolBasicAV_GetNextTextureID(OMXToolBasicAV_t * pOMXAV) { return texID; } -KDfloat32 OMXToolBasicAV_GetCurrentPosition(OMXToolBasicAV_t * pOMXAV) { +KDint OMXToolBasicAV_GetCurrentPosition(OMXToolBasicAV_t * pOMXAV) { KDfloat32 res = -1.0f; if(NULL==pOMXAV) { java_throwNewRuntimeException(0, "OMX instance null\n"); diff --git a/src/jogl/native/openmax/omx_tool.h b/src/jogl/native/openmax/omx_tool.h index d566507c1..cb0f125ec 100644 --- a/src/jogl/native/openmax/omx_tool.h +++ b/src/jogl/native/openmax/omx_tool.h @@ -141,7 +141,7 @@ void OMXToolBasicAV_PlayStop(OMXToolBasicAV_t * pOMXAV); void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDfloat32 time); GLuint OMXToolBasicAV_GetNextTextureID(OMXToolBasicAV_t * pOMXAV); -KDfloat32 OMXToolBasicAV_GetCurrentPosition(OMXToolBasicAV_t * pOMXAV); +KDint OMXToolBasicAV_GetCurrentPosition(OMXToolBasicAV_t * pOMXAV); void OMXToolBasicAV_DestroyInstance(OMXToolBasicAV_t * pOMXAV); -- cgit v1.2.3