aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXerxes Rånby <[email protected]>2013-05-08 19:05:19 +0200
committerXerxes Rånby <[email protected]>2013-05-10 09:39:50 +0200
commitdf6e7dbf623d7559c0b26cbad82d9a8bfda9d9db (patch)
tree359e466d08833507039f3d97e3e71e7199ae6c3f
parent170826d2e202a9938595017b9621a25a6f36a50b (diff)
FFMPEGMediaPlayer: Add updateSound callback for passing decoded jni audio frames to java.
Signed-off-by: Xerxes Rånby <[email protected]>
-rw-r--r--src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java3
-rw-r--r--src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c14
2 files changed, 16 insertions, 1 deletions
diff --git a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
index 7f17e6234..a954c9878 100644
--- a/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
+++ b/src/jogl/classes/jogamp/opengl/util/av/impl/FFMPEGMediaPlayer.java
@@ -213,6 +213,9 @@ public class FFMPEGMediaPlayer extends EGLMediaPlayerImpl {
throw new InternalError("Unknown ProcAddressTable: "+pt.getClass().getName()+" of "+ctx.getClass().getName());
}
}
+ private void updateSound() {
+ System.out.println("jA");
+ }
private void updateAttributes2(int pixFmt, int planes, int bitsPerPixel, int bytesPerPixelPerPlane,
int lSz0, int lSz1, int lSz2,
int tWd0, int tWd1, int tWd2) {
diff --git a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
index a90036fdb..8e5f4124c 100644
--- a/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
+++ b/src/jogl/native/libav/jogamp_opengl_util_av_impl_FFMPEGMediaPlayer.c
@@ -38,6 +38,7 @@ typedef void (APIENTRYP PFNGLTEXSUBIMAGE2DPROC) (GLenum target, GLint level, GLi
static const char * const ClazzNameFFMPEGMediaPlayer = "jogamp/opengl/util/av/impl/FFMPEGMediaPlayer";
static jclass ffmpegMediaPlayerClazz = NULL;
+static jmethodID jni_mid_updateSound = NULL;
static jmethodID jni_mid_updateAttributes1 = NULL;
static jmethodID jni_mid_updateAttributes2 = NULL;
@@ -191,6 +192,13 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGDynamicLibraryB
return JNI_TRUE;
}
+static void _updateSound(JNIEnv *env, jobject instance, char *data, int32_t data_size, int32_t sample_rate) {
+ if(NULL!=env) {
+ fprintf(stderr, "nA");
+ (*env)->CallVoidMethod(env, instance, jni_mid_updateSound);
+ }
+}
+
static void _updateJavaAttributes(JNIEnv *env, jobject instance, FFMPEGToolBasicAV_t* pAV)
{
// int shallBeDetached = 0;
@@ -334,10 +342,12 @@ JNIEXPORT jboolean JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_ini
JoglCommon_FatalError(env, "JOGL FFMPEG: can't use %s", ClazzNameFFMPEGMediaPlayer);
}
+ jni_mid_updateSound = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateSound", "()V");
jni_mid_updateAttributes1 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes", "(IIIIIFIILjava/lang/String;Ljava/lang/String;)V");
jni_mid_updateAttributes2 = (*env)->GetMethodID(env, ffmpegMediaPlayerClazz, "updateAttributes2", "(IIIIIIIIII)V");
- if(jni_mid_updateAttributes1 == NULL ||
+ if(jni_mid_updateSound == NULL ||
+ jni_mid_updateAttributes1 == NULL ||
jni_mid_updateAttributes2 == NULL) {
return JNI_FALSE;
}
@@ -644,6 +654,8 @@ JNIEXPORT jint JNICALL Java_jogamp_opengl_util_av_impl_FFMPEGMediaPlayer_readNex
// TODO: Wrap audio buffer data in a com.jogamp.openal.sound3d.Buffer or similar
// and hand it over to the user using a suitable API.
// TODO: OR send the audio buffer data down to sound card directly using JOAL.
+ _updateSound(env, instance, pAV->pAFrame->data[0], data_size, pAV->aSampleRate);
+
res = 1;
}
} else if(packet.stream_index==pAV->vid) {