/** * gstInitPlayer() * * Initializes a native player. Each media view in JavaFX is tied to a media player. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstInitPlayer (JNIEnv *env, jobject obj, jlong ref_media) { LOWLEVELPERF_EXECTIMESTART("gstInitPlayer()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; CJavaPlayerEventDispatcher* pEventDispatcher = new(nothrow) CJavaPlayerEventDispatcher(); if (NULL == pEventDispatcher) return ERROR_MEMORY_ALLOCATION; pEventDispatcher->Init(env, obj, pMedia); pPipeline->SetEventDispatcher(pEventDispatcher); jint iRet = (jint)pPipeline->Init(); LOWLEVELPERF_EXECTIMESTOP("gstInitPlayer()"); return iRet; }
/* * Class: com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer * Method: gstGetAudioEqualizer * Signature: (J)J */ JNIEXPORT jlong JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetAudioEqualizer (JNIEnv *env, jobject playerObject, jlong nativeRef) { CMedia* pMedia = (CMedia*)jlong_to_ptr(nativeRef); if (NULL == pMedia) { return 0; } CAudioEqualizer *eq = pMedia->GetPipeline()->GetAudioEqualizer(); return ptr_to_jlong(eq); }
/** * gstSetBalance() * * Makes an asynchronous call to set the audio balance. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstSetBalance (JNIEnv *env, jobject obj, jlong ref_media, jfloat balance) { LOWLEVELPERF_EXECTIMESTART("gstSetBalance()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; jint iRet = (jint)pPipeline->SetBalance((float)balance); LOWLEVELPERF_EXECTIMESTOP("gstSetBalance()"); return iRet; }
/** * gstFinish() * * Makes an asynchronous call to finish the media playback. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstFinish (JNIEnv *env, jobject obj, jlong ref_media) { LOWLEVELPERF_EXECTIMESTART("gstFinishToSendToJavaPlayerStateEventFinished"); LOWLEVELPERF_EXECTIMESTART("gstFinish()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; jint iRet = (jint)pPipeline->Finish(); LOWLEVELPERF_EXECTIMESTOP("gstFinish()"); return iRet; }
/** * gstGetAudioSyncDelay() * * Gets the audio sync delay for the media. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetAudioSyncDelay (JNIEnv *env, jobject obj, jlong ref_media, jlongArray jrglAudioSyncDelay) { LOWLEVELPERF_EXECTIMESTART("gstGetAudioSyncDelay()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; long lAudioSyncDelay; uint32_t uErrCode = pPipeline->GetAudioSyncDelay(&lAudioSyncDelay); if (ERROR_NONE != uErrCode) return (jint)uErrCode; jlong jlAudioSyncDelay = (jlong)lAudioSyncDelay; env->SetLongArrayRegion(jrglAudioSyncDelay, 0, 1, &jlAudioSyncDelay); LOWLEVELPERF_EXECTIMESTOP("gstGetAudioSyncDelay()"); return ERROR_NONE; }
/** * gstGetDuration() * * Makes a synchronous call to get the duration of the media. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetDuration (JNIEnv *env, jobject obj, jlong ref_media, jdoubleArray jrgdDuration) { LOWLEVELPERF_EXECTIMESTART("gstGetDuration()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; double dDuration; uint32_t uErrCode = pPipeline->GetDuration(&dDuration); if (ERROR_NONE != uErrCode) return uErrCode; jdouble jdDuration = (jdouble)dDuration; env->SetDoubleArrayRegion (jrgdDuration, 0, 1, &jdDuration); LOWLEVELPERF_EXECTIMESTOP("gstGetDuration()"); return ERROR_NONE; }
/** * gstGetBalance() * * Makes a synchronous call to get the audio balance. */ JNIEXPORT jint JNICALL Java_com_sun_media_jfxmediaimpl_platform_gstreamer_GSTMediaPlayer_gstGetBalance (JNIEnv *env, jobject obj, jlong ref_media, jfloatArray jrgfBalance) { LOWLEVELPERF_EXECTIMESTART("gstGetBalance()"); CMedia* pMedia = (CMedia*)jlong_to_ptr(ref_media); if (NULL == pMedia) return ERROR_MEDIA_NULL; CPipeline* pPipeline = (CPipeline*)pMedia->GetPipeline(); if (NULL == pPipeline) return ERROR_PIPELINE_NULL; float fBalance; uint32_t uErrCode = pPipeline->GetBalance(&fBalance); if (ERROR_NONE != uErrCode) return uErrCode; jfloat jfBalance = (jfloat)fBalance; env->SetFloatArrayRegion (jrgfBalance, 0, 1, &jfBalance); LOWLEVELPERF_EXECTIMESTOP("gstGetBalance()"); return ERROR_NONE; }