diff options
author | Sven Gothel <[email protected]> | 2012-04-16 21:18:03 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-04-16 21:18:03 +0200 |
commit | 35beeabffed61e1597aaffc0c5926ab5ef86d32e (patch) | |
tree | 6a7e91c07e7d61613b03f35a17486faf01b211fc /src/jogl/native | |
parent | 2f0583aad39f93a934629c21beac66a758373249 (diff) |
TextureSequence Shader Support; GLMediaPlayer uses 'int' where possible; General enhancments.
For details about TextureSequence/GLMediaPlayer shader collaboration w/ your own shader source,
see TextureSequence and TexCubeES2 / MovieSimple demo.
TextureSequence allows implementations to provide their own texture lookup function
which may provide color space conversion (YUV) .. or other runtime hw-accel features.
Have a look at the next commit, which provides an Libav/FFMpeg implementation w/ YUV/RGB shader conversion.
MovieCube adds keyboard control (Android: firm touch on display to launch keyboard, don't break it though :)
Diffstat (limited to 'src/jogl/native')
-rw-r--r-- | src/jogl/native/JoglCommon.c | 56 | ||||
-rw-r--r-- | src/jogl/native/JoglCommon.h | 3 | ||||
-rw-r--r-- | src/jogl/native/openmax/jogamp_opengl_util_av_impl_OMXGLMediaPlayer.c | 124 | ||||
-rw-r--r-- | src/jogl/native/openmax/omx_tool.c | 123 | ||||
-rw-r--r-- | src/jogl/native/openmax/omx_tool.h | 20 |
5 files changed, 135 insertions, 191 deletions
diff --git a/src/jogl/native/JoglCommon.c b/src/jogl/native/JoglCommon.c index 719e0df56..d9f5edd49 100644 --- a/src/jogl/native/JoglCommon.c +++ b/src/jogl/native/JoglCommon.c @@ -11,48 +11,63 @@ static jclass runtimeExceptionClz=NULL; static JavaVM *_jvmHandle = NULL; static int _jvmVersion = 0; +void JoglCommon_init(JNIEnv *env) { + if(NULL==runtimeExceptionClz) { + jclass c = (*env)->FindClass(env, ClazzNameRuntimeException); + if(NULL==c) { + JoglCommon_FatalError(env, "JOGL: can't find %s", ClazzNameRuntimeException); + } + runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); + (*env)->DeleteLocalRef(env, c); + if(NULL==runtimeExceptionClz) { + JoglCommon_FatalError(env, "JOGL: can't use %s", ClazzNameRuntimeException); + } + } + if(0 != (*env)->GetJavaVM(env, &_jvmHandle)) { + JoglCommon_FatalError(env, "JOGL: can't fetch JavaVM handle"); + } else { + _jvmVersion = (*env)->GetVersion(env); + } +} void JoglCommon_FatalError(JNIEnv *env, const char* msg, ...) { char buffer[512]; va_list ap; + int shallBeDetached = 0; + + if(NULL == env) { + env = JoglCommon_GetJNIEnv (&shallBeDetached); + } va_start(ap, msg); vsnprintf(buffer, sizeof(buffer), msg, ap); va_end(ap); fprintf(stderr, "%s\n", buffer); - (*env)->FatalError(env, buffer); + if(NULL != env) { + (*env)->FatalError(env, buffer); + JoglCommon_ReleaseJNIEnv (shallBeDetached); + } } void JoglCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...) { char buffer[512]; va_list ap; + int shallBeDetached = 0; + + if(NULL == env) { + env = JoglCommon_GetJNIEnv (&shallBeDetached); + } va_start(ap, msg); vsnprintf(buffer, sizeof(buffer), msg, ap); va_end(ap); - (*env)->ThrowNew(env, runtimeExceptionClz, buffer); -} - -void JoglCommon_init(JNIEnv *env) { - if(NULL==runtimeExceptionClz) { - jclass c = (*env)->FindClass(env, ClazzNameRuntimeException); - if(NULL==c) { - JoglCommon_FatalError(env, "JOGL: can't find %s", ClazzNameRuntimeException); - } - runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); - (*env)->DeleteLocalRef(env, c); - if(NULL==runtimeExceptionClz) { - JoglCommon_FatalError(env, "JOGL: can't use %s", ClazzNameRuntimeException); - } - } - if(0 != (*env)->GetJavaVM(env, &_jvmHandle)) { - JoglCommon_FatalError(env, "JOGL: can't fetch JavaVM handle"); - } else { - _jvmVersion = (*env)->GetVersion(env); + if(NULL != env) { + (*env)->ThrowNew(env, runtimeExceptionClz, buffer); + JoglCommon_ReleaseJNIEnv (shallBeDetached); } } @@ -110,7 +125,6 @@ JNIEnv* JoglCommon_GetJNIEnv (int * shallBeDetached) void JoglCommon_ReleaseJNIEnv (int shallBeDetached) { if(NULL == _jvmHandle) { fprintf(stderr, "JOGL: No JavaVM handle registered, call JoglCommon_init(..) 1st"); - return NULL; } if(shallBeDetached) { diff --git a/src/jogl/native/JoglCommon.h b/src/jogl/native/JoglCommon.h index b988336fa..023b4be03 100644 --- a/src/jogl/native/JoglCommon.h +++ b/src/jogl/native/JoglCommon.h @@ -15,7 +15,10 @@ int JoglCommon_GetJVMVersion(); jchar* JoglCommon_GetNullTerminatedStringChars(JNIEnv* env, jstring str); +/** env may be NULL, in which case JoglCommon_GetJNIEnv() is being used. */ void JoglCommon_FatalError(JNIEnv *env, const char* msg, ...); + +/** env may be NULL, in which case JoglCommon_GetJNIEnv() is being used. */ void JoglCommon_throwNewRuntimeException(JNIEnv *env, const char* msg, ...); /** diff --git a/src/jogl/native/openmax/jogamp_opengl_util_av_impl_OMXGLMediaPlayer.c b/src/jogl/native/openmax/jogamp_opengl_util_av_impl_OMXGLMediaPlayer.c index 60e436678..964ac64a7 100644 --- a/src/jogl/native/openmax/jogamp_opengl_util_av_impl_OMXGLMediaPlayer.c +++ b/src/jogl/native/openmax/jogamp_opengl_util_av_impl_OMXGLMediaPlayer.c @@ -14,94 +14,68 @@ // http://developer.apple.com/qa/qa2001/qa1262.html #include "jogamp_opengl_util_av_impl_OMXGLMediaPlayer.h" +#include "JoglCommon.h" #include "omx_tool.h" #include <stdarg.h> -static const char * const ClazzNameRuntimeException = - "java/lang/RuntimeException"; -static jclass runtimeExceptionClz=NULL; +static const char * const ClazzNameOMXGLMediaPlayer = "jogamp/opengl/util/av/impl/OMXGLMediaPlayer"; + +static jclass omxGLMediaPlayerClazz = NULL; +static jmethodID jni_mid_updateAttributes = 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) +JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer_initIDs0 + (JNIEnv *env, jclass clazz) { - 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) { + JoglCommon_init(env); + + jclass c; + if (omxGLMediaPlayerClazz != NULL) { return; } - c = (*env)->FindClass(env, ClazzNameRuntimeException); + c = (*env)->FindClass(env, ClazzNameOMXGLMediaPlayer); if(NULL==c) { - fprintf(stdout, "FatalError: can't find %s\n", ClazzNameRuntimeException); - (*env)->FatalError(env, ClazzNameRuntimeException); + JoglCommon_FatalError(env, "JOGL OMX: can't find %s", ClazzNameOMXGLMediaPlayer); } - runtimeExceptionClz = (jclass)(*env)->NewGlobalRef(env, c); - if(NULL==runtimeExceptionClz) { - fprintf(stdout, "FatalError: can't use %s\n", ClazzNameRuntimeException); - (*env)->FatalError(env, ClazzNameRuntimeException); + omxGLMediaPlayerClazz = (jclass)(*env)->NewGlobalRef(env, c); + (*env)->DeleteLocalRef(env, c); + if(NULL==omxGLMediaPlayerClazz) { + JoglCommon_FatalError(env, "JOGL OMX: can't use %s", ClazzNameOMXGLMediaPlayer); } -} -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); - } -} + jni_mid_updateAttributes = (*env)->GetMethodID(env, omxGLMediaPlayerClazz, "updateAttributes", "(IIIIIFIILjava/lang/String;Ljava/lang/String;)V"); -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); + if(jni_mid_updateAttributes == NULL) { + return JNI_FALSE; } + return JNI_TRUE; } -void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback) +void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pAV) { - if(NULL==pOMXAV || 0==pOMXAV->jni_env || 0==pOMXAV->jni_instance) { + if(NULL==pAV || 0==pAV->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)); - } - } + } + int shallBeDetached = 0; + JNIEnv * env = JoglCommon_GetJNIEnv (&shallBeDetached); + if(NULL!=env) { + (*env)->CallVoidMethod(env, (jobject)pAV->jni_instance, jni_mid_updateAttributes, + pAV->width, pAV->height, + pAV->bitrate, 0, 0, + pAV->framerate, (uint32_t)(pAV->length*pAV->framerate), pAV->length, + (*env)->NewStringUTF(env, pAV->videoCodec), + (*env)->NewStringUTF(env, pAV->audioCodec) ); + JoglCommon_ReleaseJNIEnv (shallBeDetached); } } @@ -110,26 +84,9 @@ JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1creat { OMXToolBasicAV_t * pOMXAV; - _initStatics(env); - - pOMXAV->jni_env=(intptr_t)env; - pOMXAV->jni_instance=(intptr_t)instance; - pOMXAV = OMXToolBasicAV_CreateInstance((EGLDisplay)(intptr_t)env); - 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; + pOMXAV->jni_instance=(intptr_t)instance; + return (jlong) (intptr_t) pOMXAV; } JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1setStream @@ -142,7 +99,6 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1setStr 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); @@ -213,8 +169,8 @@ JNIEXPORT void JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1stop OMXToolBasicAV_PlayStop(pOMXAV); } -JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1seek - (JNIEnv *env, jobject instance, jlong ptr, jlong pos) +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1seek + (JNIEnv *env, jobject instance, jlong ptr, jint pos) { OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); OMXToolBasicAV_PlaySeek(pOMXAV, pos); @@ -232,7 +188,7 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1getNex return textureID; } -JNIEXPORT jlong JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1getCurrentPosition +JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_OMXGLMediaPlayer__1getCurrentPosition (JNIEnv *env, jobject instance, jlong ptr) { OMXToolBasicAV_t *pOMXAV = (OMXToolBasicAV_t *)((void *)((intptr_t)ptr)); diff --git a/src/jogl/native/openmax/omx_tool.c b/src/jogl/native/openmax/omx_tool.c index 5e168ad02..16c43f6a8 100644 --- a/src/jogl/native/openmax/omx_tool.c +++ b/src/jogl/native/openmax/omx_tool.c @@ -28,35 +28,15 @@ #define NOTSET_U32 ((OMX_U32)0xDEDEDEDE) #define INIT_PARAM(_X_) (memset(&(_X_), NOTSET_U8, sizeof(_X_)), ((_X_).nSize = sizeof (_X_)), (_X_).nVersion = vOMX) -void OMXInstance_SaveJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback); -void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pOMXAV, KDboolean issueJavaCallback); +void OMXInstance_UpdateJavaAttributes(OMXToolBasicAV_t *pOMXAV); -#if !defined(SELF_TEST) -void java_throwNewRuntimeException(intptr_t jni_env, const char* format, ...); -#else -#include <stdarg.h> -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; - DBG_PRINT( "RuntimeException: %s\n", buffer); - exit(1); -} -#endif static void DestroyInstanceUnlock(OMXToolBasicAV_t * pOMXAV); #define OMXSAFEVOID(x) \ do { \ OMX_ERRORTYPE err = (x); \ if (err != OMX_ErrorNone) { \ - java_throwNewRuntimeException((NULL!=pOMXAV)?pOMXAV->jni_env:0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ + JoglCommon_throwNewRuntimeException(0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ if(NULL!=pOMXAV) { \ DestroyInstanceUnlock(pOMXAV); \ } \ @@ -68,7 +48,7 @@ do { \ do { \ OMX_ERRORTYPE err = (x); \ if (err != OMX_ErrorNone) { \ - java_throwNewRuntimeException((NULL!=pOMXAV)?pOMXAV->jni_env:0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ + JoglCommon_throwNewRuntimeException(0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ if(NULL!=pOMXAV) { \ DestroyInstanceUnlock(pOMXAV); \ } \ @@ -80,7 +60,7 @@ do { \ do { \ OMX_ERRORTYPE err = (x); \ if (err != OMX_ErrorNone) { \ - java_throwNewRuntimeException((NULL!=pOMXAV)?pOMXAV->jni_env:0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ + JoglCommon_throwNewRuntimeException(0, "FAILED at %s:%d, Error: 0x%x\n", __FILE__, __LINE__, err); \ if(NULL!=pOMXAV) { \ DestroyInstanceUnlock(pOMXAV); \ } \ @@ -466,7 +446,7 @@ static void DestroyInstanceUnlock(OMXToolBasicAV_t * pOMXAV) DBG_PRINT( "Destroy p2\n"); if(0!=(res1=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateIdle, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Destroy - Wait for Idle Failed (%d)", res1); + JoglCommon_throwNewRuntimeException(0, "Destroy - Wait for Idle Failed (%d)", res1); } DBG_PRINT( "Destroy p3\n"); @@ -479,7 +459,7 @@ static void DestroyInstanceUnlock(OMXToolBasicAV_t * pOMXAV) if(0!=(res2=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateLoaded, KD_TRUE))) { if(!res1) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Destroy - Wait for Loaded Failed (%d)", res2); + JoglCommon_throwNewRuntimeException(0, "Destroy - Wait for Loaded Failed (%d)", res2); } } @@ -726,19 +706,20 @@ static OMX_ERRORTYPE UpdateStreamInfo(OMXToolBasicAV_t * pOMXAV, KDboolean issue } DBG_PRINT( "Update StreamInfo p1\n" ); - OMXInstance_SaveJavaAttributes(pOMXAV, issueCallback); pOMXAV->width = oPortDef.format.video.nFrameWidth; pOMXAV->height = oPortDef.format.video.nFrameHeight; /* pOMXAV->stride = oPortDef.format.video.nStride; pOMXAV->sliceHeight = oPortDef.format.video.nSliceHeight; */ - pOMXAV->framerate = oPortDef.format.video.xFramerate; + pOMXAV->framerate = (float) oPortDef.format.video.xFramerate; pOMXAV->bitrate = oPortDef.format.video.nBitrate; - DBG_PRINT( "Update StreamInfo p2 %dx%d, fps %d, bps %d\n", pOMXAV->width, pOMXAV->height, pOMXAV->framerate, pOMXAV->bitrate ); + DBG_PRINT( "Update StreamInfo p2 %dx%d, fps %f, bps %d\n", pOMXAV->width, pOMXAV->height, pOMXAV->framerate, pOMXAV->bitrate ); pOMXAV->length = GetMediaLength(pOMXAV); pOMXAV->speed = GetClockScale(pOMXAV); - OMXInstance_UpdateJavaAttributes(pOMXAV, issueCallback); + if(issueCallback) { + OMXInstance_UpdateJavaAttributes(pOMXAV); + } return err; } @@ -755,7 +736,7 @@ static int AttachAudioRenderer(OMXToolBasicAV_t * pOMXAV) // FIXME: proper audio buffering .. OMXSAFE(OMX_GetHandle(&pOMXAV->comp[OMXAV_H_ABUFFERING], "OMX.Nvidia.audio.visualization", pOMXAV, &pOMXAV->callbacks)); if(0!=(res=SyncOnState(pOMXAV->comp[OMXAV_H_ABUFFERING], OMX_StateLoaded))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Loading AudioBuffering Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Loading AudioBuffering Failed (%d)", res); return res; } /** @@ -777,7 +758,7 @@ static int AttachAudioRenderer(OMXToolBasicAV_t * pOMXAV) // mandatory before SetupTunnel if(0!=(res=SyncOnState(pOMXAV->comp[OMXAV_H_ARENDERER], OMX_StateLoaded))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Loading AudioRenderer Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Loading AudioRenderer Failed (%d)", res); return res; } @@ -828,7 +809,7 @@ static int AttachVideoRenderer(OMXToolBasicAV_t * pOMXAV) { int i, res=0; if(KD_NULL!=pOMXAV->comp[OMXAV_H_VSCHEDULER]) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Detach Video first"); + JoglCommon_throwNewRuntimeException(0, "Detach Video first"); return -1; } OMXSAFE(OMX_GetHandle(&pOMXAV->comp[OMXAV_H_VSCHEDULER], "OMX.Nvidia.video.scheduler", pOMXAV, &pOMXAV->callbacks)); @@ -836,7 +817,7 @@ static int AttachVideoRenderer(OMXToolBasicAV_t * pOMXAV) // mandatory before SetupTunnel if(0!=(res=SyncOnState(pOMXAV->comp[OMXAV_H_VSCHEDULER], OMX_StateLoaded))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Loading VideoScheduler Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Loading VideoScheduler Failed (%d)", res); return res; } // mandatory before EGLUseImage @@ -861,7 +842,7 @@ static int AttachVideoRenderer(OMXToolBasicAV_t * pOMXAV) DBG_PRINT( "UseEGLImg %p #%d t:%d i:%p s:%p p1\n", pOMXAV, i, pBuf->tex, pBuf->image, pBuf->sync); if(NULL==pBuf->image) { - java_throwNewRuntimeException(pOMXAV->jni_env, "AttachVideoRenderer: User didn't set buffer %d/%d\n", i, pOMXAV->vBufferNum); + JoglCommon_throwNewRuntimeException(0, "AttachVideoRenderer: User didn't set buffer %d/%d\n", i, pOMXAV->vBufferNum); return -1; } else { // tell decoder output port that it will be using EGLImage @@ -886,7 +867,7 @@ static int DetachVideoRenderer(OMXToolBasicAV_t * pOMXAV) if(NULL==pOMXAV) return -1; if(KD_NULL==pOMXAV->comp[OMXAV_H_VSCHEDULER]) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Attach Video first"); + JoglCommon_throwNewRuntimeException(0, "Attach Video first"); return -1; } DBG_PRINT( "DetachVideoRenderer p0\n"); @@ -968,11 +949,11 @@ void OMXToolBasicAV_SetStream(OMXToolBasicAV_t * pOMXAV, int vBufferNum, const K // FIXME: verify player state .. ie stop ! if(pOMXAV->status!=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Player instance in use\n"); + JoglCommon_throwNewRuntimeException(0, "Player instance in use\n"); return; } if(vBufferNum>EGLIMAGE_MAX_BUFFERS) { - java_throwNewRuntimeException(pOMXAV->jni_env, "buffer number %d > MAX(%d)\n", vBufferNum, EGLIMAGE_MAX_BUFFERS); + JoglCommon_throwNewRuntimeException(0, "buffer number %d > MAX(%d)\n", vBufferNum, EGLIMAGE_MAX_BUFFERS); return; } @@ -987,7 +968,7 @@ void OMXToolBasicAV_SetStream(OMXToolBasicAV_t * pOMXAV, int vBufferNum, const K eError = AddFile(pOMXAV, stream); if(eError!=OMX_ErrorNone) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Couldn't open or handle stream: %s\n", stream); + JoglCommon_throwNewRuntimeException(0, "Couldn't open or handle stream: %s\n", stream); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1040,7 +1021,7 @@ void OMXToolBasicAV_SetStream(OMXToolBasicAV_t * pOMXAV, int vBufferNum, const K if (pOMXAV->audioPort == -1 && pOMXAV->videoPort == -1) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Neither audioport or videoport could be played back!\n"); + JoglCommon_throwNewRuntimeException(0, "Neither audioport or videoport could be played back!\n"); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1071,12 +1052,12 @@ void OMXToolBasicAV_SetStream(OMXToolBasicAV_t * pOMXAV, int vBufferNum, const K void OMXToolBasicAV_SetStreamEGLImageTexture2D(OMXToolBasicAV_t * pOMXAV, KDint i, GLuint tex, EGLImageKHR image, EGLSyncKHR sync) { if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } DBG_PRINT( "SetStreamEGLImg %p #%d/%d t:%d i:%p s:%p..\n", pOMXAV, i, pOMXAV->vBufferNum, tex, image, sync); if(i<0||i>=pOMXAV->vBufferNum) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Buffer index out of range: %d\n", i); + JoglCommon_throwNewRuntimeException(0, "Buffer index out of range: %d\n", i); return; } @@ -1094,7 +1075,7 @@ void OMXToolBasicAV_SetStreamEGLImageTexture2D(OMXToolBasicAV_t * pOMXAV, KDint void OMXToolBasicAV_ActivateStream(OMXToolBasicAV_t * pOMXAV) { int res; if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } DBG_PRINT( "ActivateStream 1\n"); @@ -1115,7 +1096,7 @@ void OMXToolBasicAV_ActivateStream(OMXToolBasicAV_t * pOMXAV) { // mandatory: before SetupTunnel (->Activate), wait until all devices are ready .. // arender/vrender must wait as well .. if(0!=(res=OMXToolBasicAV_WaitForState(pOMXAV, OMX_StateLoaded))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Loaded Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Loaded Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1161,7 +1142,7 @@ void OMXToolBasicAV_ActivateStream(OMXToolBasicAV_t * pOMXAV) { // if(0!=(res=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateIdle, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Wait for Idle Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Wait for Idle Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1172,11 +1153,11 @@ void OMXToolBasicAV_ActivateStream(OMXToolBasicAV_t * pOMXAV) { void OMXToolBasicAV_DetachVideoRenderer(OMXToolBasicAV_t * pOMXAV) { if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } kdThreadMutexLock(pOMXAV->mutex); @@ -1188,11 +1169,11 @@ void OMXToolBasicAV_DetachVideoRenderer(OMXToolBasicAV_t * pOMXAV) { void OMXToolBasicAV_AttachVideoRenderer(OMXToolBasicAV_t * pOMXAV) { if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } kdThreadMutexLock(pOMXAV->mutex); @@ -1205,11 +1186,11 @@ void OMXToolBasicAV_AttachVideoRenderer(OMXToolBasicAV_t * pOMXAV) { void OMXToolBasicAV_SetPlaySpeed(OMXToolBasicAV_t * pOMXAV, KDfloat32 scale) { if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } kdThreadMutexLock(pOMXAV->mutex); @@ -1226,11 +1207,11 @@ void OMXToolBasicAV_PlayStart(OMXToolBasicAV_t * pOMXAV) { int res; if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } if(pOMXAV->status==OMXAV_PLAYING) { @@ -1244,14 +1225,14 @@ void OMXToolBasicAV_PlayStart(OMXToolBasicAV_t * pOMXAV) DBG_PRINT( "Play 3.1\n"); if(0!=(res=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateExecuting, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Play Execute Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Play Execute Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return; } if(pOMXAV->status==OMXAV_STOPPED || pOMXAV->status==OMXAV_FIN) { DBG_PRINT( "Play 3.2\n"); if(StartClock(pOMXAV, KD_TRUE, 0.0)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Play StartClock Failed"); + JoglCommon_throwNewRuntimeException(0, "Play StartClock Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1275,13 +1256,13 @@ static int PlayStop(OMXToolBasicAV_t * pOMXAV) if(OMXToolBasicAV_CheckState(pOMXAV, OMX_StateLoaded)) { if(StartClock(pOMXAV, KD_FALSE, 0.0)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Stop StopClock Failed"); + JoglCommon_throwNewRuntimeException(0, "Stop StopClock Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return -1; } if(OMXToolBasicAV_CheckState(pOMXAV, OMX_StateIdle)) { if(0!=(res=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateIdle, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Stop Idle Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Stop Idle Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return res; } @@ -1294,11 +1275,11 @@ static int PlayStop(OMXToolBasicAV_t * pOMXAV) void OMXToolBasicAV_PlayStop(OMXToolBasicAV_t * pOMXAV) { if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } kdThreadMutexLock(pOMXAV->mutex); @@ -1312,11 +1293,11 @@ void OMXToolBasicAV_PlayPause(OMXToolBasicAV_t * pOMXAV) { int res; if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } if(pOMXAV->status==OMXAV_PAUSED || pOMXAV->status!=OMXAV_PLAYING) { @@ -1339,11 +1320,11 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) int res; if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return; } kdThreadMutexLock(pOMXAV->mutex); @@ -1359,7 +1340,7 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) // state transition to OMX_StatePause. if(pOMXAV->status!=OMXAV_PAUSED) { if(0!=(res=OMXToolBasicAV_RequestState(pOMXAV, OMX_StatePause, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek Pause Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Seek Pause Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1369,7 +1350,7 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) // on OMX_TIME_CONFIG_CLOCKSTATETYPE requesting a transition to // OMX_TIME_ClockStateStopped. if(StartClock(pOMXAV, KD_FALSE, 0.0)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek StopClock Failed"); + JoglCommon_throwNewRuntimeException(0, "Seek StopClock Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1377,14 +1358,14 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) // 3. Seek to the desired location through the use of OMX_SetConfig on // OMX_IndexConfigTimePosition requesting the desired timestamp. if(SetMediaPosition(pOMXAV, time)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek position Failed"); + JoglCommon_throwNewRuntimeException(0, "Seek position Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return; } // 4. Flush all components. if(SendCommand(pOMXAV, OMX_CommandFlush, OMX_ALL, 0)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek Flush Failed"); + JoglCommon_throwNewRuntimeException(0, "Seek Flush Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1394,7 +1375,7 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) // OMX_TIME_ClockStateRunning or // OMX_TIME_ClockStateWaitingForStartTime. if(StartClock(pOMXAV, KD_TRUE, time)) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek StartClock Failed"); + JoglCommon_throwNewRuntimeException(0, "Seek StartClock Failed"); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1403,7 +1384,7 @@ void OMXToolBasicAV_PlaySeek(OMXToolBasicAV_t * pOMXAV, KDint64 time) // state transition to OMX_StateExecuting. if(pOMXAV->status==OMXAV_PLAYING) { if(0!=(res=OMXToolBasicAV_RequestState(pOMXAV, OMX_StateExecuting, KD_TRUE))) { - java_throwNewRuntimeException(pOMXAV->jni_env, "Seek Execute Failed (%d)", res); + JoglCommon_throwNewRuntimeException(0, "Seek Execute Failed (%d)", res); kdThreadMutexUnlock(pOMXAV->mutex); return; } @@ -1478,11 +1459,11 @@ GLuint OMXToolBasicAV_GetNextTextureID(OMXToolBasicAV_t * pOMXAV, int blocking) KDint64 OMXToolBasicAV_GetCurrentPosition(OMXToolBasicAV_t * pOMXAV) { KDint64 res = 0L; if(NULL==pOMXAV) { - java_throwNewRuntimeException(0, "OMX instance null\n"); + JoglCommon_throwNewRuntimeException(0, "OMX instance null\n"); return res; } if(pOMXAV->status<=OMXAV_INIT) { - java_throwNewRuntimeException(pOMXAV->jni_env, "OMX invalid status: %d <= INIT\n", pOMXAV->status); + JoglCommon_throwNewRuntimeException(0, "OMX invalid status: %d <= INIT\n", pOMXAV->status); return res; } kdThreadMutexLock(pOMXAV->mutex); diff --git a/src/jogl/native/openmax/omx_tool.h b/src/jogl/native/openmax/omx_tool.h index 1ade60e4f..414befca0 100644 --- a/src/jogl/native/openmax/omx_tool.h +++ b/src/jogl/native/openmax/omx_tool.h @@ -73,16 +73,16 @@ typedef struct { OMX_HANDLETYPE endComponent; OMX_CALLBACKTYPE callbacks; - KDchar audioCodec[256]; - KDchar audioCodecComponent[256]; - KDchar videoCodec[256]; - KDchar videoCodecComponent[256]; + KDchar audioCodec[64]; + KDchar audioCodecComponent[64]; + KDchar videoCodec[64]; + KDchar videoCodecComponent[64]; int audioPort; int videoPort; KDuint32 width; KDuint32 height; KDuint32 bitrate; // per seconds - KDuint32 framerate; // per seconds + KDfloat32 framerate; // per seconds KDfloat32 length; // seconds KDfloat32 speed; // current clock scale KDfloat32 play_speed; // current play clock scale @@ -99,17 +99,7 @@ typedef struct { int status; - intptr_t jni_env; intptr_t jni_instance; - intptr_t jni_mid_saveAttributes; - intptr_t jni_mid_attributesUpdated; - intptr_t jni_fid_width; - intptr_t jni_fid_height; - intptr_t jni_fid_fps; - intptr_t jni_fid_bps; - intptr_t jni_fid_totalFrames; - intptr_t jni_fid_acodec; - intptr_t jni_fid_vcodec; } OMXToolBasicAV_t ; // |