Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Thu, Mar 03, 2016 at 01:56:16PM +0100, Matthieu Bouron wrote: [...] > > New patch attached with the following differences: > * added myself as a maintainer of jni* and ffjni* > Pushed. [...] ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Wed, Mar 02, 2016 at 03:24:06PM +0100, Matthieu Bouron wrote: > On Tue, Mar 01, 2016 at 09:06:35PM +0100, wm4 wrote: > > On Tue, 1 Mar 2016 20:57:12 +0100 > > Matthieu Bouronwrote: > > > > > On Tue, Mar 01, 2016 at 08:55:23PM +0100, Matthieu Bouron wrote: > > > > On Tue, Mar 01, 2016 at 08:38:04PM +0100, wm4 wrote: > > > > > On Tue, 1 Mar 2016 20:33:14 +0100 > > > > > Matthieu Bouron wrote: > > > > > > > > > > > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > > > > > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > > > > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron > > > > > > > > > > > wrote: > > > > > > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu > > > > > > > > > > > > > Bouron wrote: > > > > > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > > > * fix of switch/case code style > > > > > > > > > > > > > * removal of a miss declaration of FFJNIField enum > > > > > > > > > > > > > as a global variable > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > > * fixes a few typo in comments > > > > > > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > * fixes a few typo in comments and message logs > > > > > > > > > > > * add missing .so at end of library names when trying > > > > > > > > > > > to find > > > > > > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > > > > > > * reintroduce public functions that allow the user to > > > > > > > > > > > set the Java > > > > > > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the > > > > > > > > > > > private C++ > > > > > > > > > > > JniInvocation wrapper is not available on all devices > > > > > > > > > > > (android >= 4.4) > > > > > > > > > > > > > > > > > > > > I'm wondering if the VM should be stored per > > > > > > > > > > AVCodecContext. (Since it > > > > > > > > > > has to be set explicitly again by the user.) > > > > > > > > > > > > > > > > > > I think it is fine to store one VM for all the AVCodecContext > > > > > > > > > as it will > > > > > > > > > be the same during all the lifetime of the application. I > > > > > > > > > should also > > > > > > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > > > > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in > > > > > > > > > jni.c and not in > > > > > > > > > ffjni.c and it is retrieved in jni.c using > > > > > > > > > av_jni_get_java_vm. I've done > > > > > > > > > it that way because if at some point we are to include > > > > > > > > > ffjni.c from > > > > > > > > > libavformat it won't work (it will only set the java vm in > > > > > > > > > the libavcodec > > > > > > > > > memory space). > > > > > > > > > > > > > > > > The problem is that this is not library-safe. What if two libs > > > > > > > > within > > > > > > > > the process (which both are using libavcodec) are setting a > > > > > > > > different > > > > > > > > VM? > > > > > > > > > > > > > > In the Android application context, you only have, AFAIK, one VM > > > > > > > running > > > > > > > during the lifetime of the application. The code does handle the > > > > > > > general > > > > > > > > > > > > does *not* (sorry) > > > > > > > > > > > > > JNI case (even outside Android) but do we really want to do that > > > > > > > anyway ? > > > > > > > > > > If there's guaranteed to be exactly one, I don't get why we can't get > > > > > it into existence ourselves? > > > > > > > > > > Where exactly would an application get the VM handle from? > > > > > > > > You get the Java VM pointer when JNI_onLoad(JavaVM *vm, void *reserved) > > > > is > > > > executed at library load. This is where you can pass the pointer to > > > > lavc. > > >
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 09:06:35PM +0100, wm4 wrote: > On Tue, 1 Mar 2016 20:57:12 +0100 > Matthieu Bouronwrote: > > > On Tue, Mar 01, 2016 at 08:55:23PM +0100, Matthieu Bouron wrote: > > > On Tue, Mar 01, 2016 at 08:38:04PM +0100, wm4 wrote: > > > > On Tue, 1 Mar 2016 20:33:14 +0100 > > > > Matthieu Bouron wrote: > > > > > > > > > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > > > > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > > > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron > > > > > > > > > > wrote: > > > > > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu > > > > > > > > > > > > Bouron wrote: > > > > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > > * fix of switch/case code style > > > > > > > > > > > > * removal of a miss declaration of FFJNIField enum as > > > > > > > > > > > > a global variable > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > * fixes a few typo in comments > > > > > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > * fixes a few typo in comments and message logs > > > > > > > > > > * add missing .so at end of library names when trying to > > > > > > > > > > find > > > > > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > > > > > * reintroduce public functions that allow the user to set > > > > > > > > > > the Java > > > > > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private > > > > > > > > > > C++ > > > > > > > > > > JniInvocation wrapper is not available on all devices > > > > > > > > > > (android >= 4.4) > > > > > > > > > > > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. > > > > > > > > > (Since it > > > > > > > > > has to be set explicitly again by the user.) > > > > > > > > > > > > > > > > I think it is fine to store one VM for all the AVCodecContext > > > > > > > > as it will > > > > > > > > be the same during all the lifetime of the application. I > > > > > > > > should also > > > > > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c > > > > > > > > and not in > > > > > > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. > > > > > > > > I've done > > > > > > > > it that way because if at some point we are to include ffjni.c > > > > > > > > from > > > > > > > > libavformat it won't work (it will only set the java vm in the > > > > > > > > libavcodec > > > > > > > > memory space). > > > > > > > > > > > > > > The problem is that this is not library-safe. What if two libs > > > > > > > within > > > > > > > the process (which both are using libavcodec) are setting a > > > > > > > different > > > > > > > VM? > > > > > > > > > > > > In the Android application context, you only have, AFAIK, one VM > > > > > > running > > > > > > during the lifetime of the application. The code does handle the > > > > > > general > > > > > > > > > > does *not* (sorry) > > > > > > > > > > > JNI case (even outside Android) but do we really want to do that > > > > > > anyway ? > > > > > > > > If there's guaranteed to be exactly one, I don't get why we can't get > > > > it into existence ourselves? > > > > > > > > Where exactly would an application get the VM handle from? > > > > > > You get the Java VM pointer when JNI_onLoad(JavaVM *vm, void *reserved) is > > > executed at library load. This is where you can pass the pointer to lavc. > > > > > > IMHO, av_jni_set_java_vm should set the VM once and then warn (or return > > > an error) > > > if the user is providing a different Java VM pointer. > > > > > > In theory, on some version of Android, you can spawn your own VM using > > > their > > > private C++ JniInvocation wrapper. > > > On a
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, 1 Mar 2016 20:57:12 +0100 Matthieu Bouronwrote: > On Tue, Mar 01, 2016 at 08:55:23PM +0100, Matthieu Bouron wrote: > > On Tue, Mar 01, 2016 at 08:38:04PM +0100, wm4 wrote: > > > On Tue, 1 Mar 2016 20:33:14 +0100 > > > Matthieu Bouron wrote: > > > > > > > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > > > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron > > > > > > > > > wrote: > > > > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron > > > > > > > > > > > wrote: > > > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > > * fix of switch/case code style > > > > > > > > > > > * removal of a miss declaration of FFJNIField enum as a > > > > > > > > > > > global variable > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > * fixes a few typo in comments > > > > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > * fixes a few typo in comments and message logs > > > > > > > > > * add missing .so at end of library names when trying to > > > > > > > > > find > > > > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > > > > * reintroduce public functions that allow the user to set > > > > > > > > > the Java > > > > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private > > > > > > > > > C++ > > > > > > > > > JniInvocation wrapper is not available on all devices > > > > > > > > > (android >= 4.4) > > > > > > > > > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. > > > > > > > > (Since it > > > > > > > > has to be set explicitly again by the user.) > > > > > > > > > > > > > > I think it is fine to store one VM for all the AVCodecContext as > > > > > > > it will > > > > > > > be the same during all the lifetime of the application. I should > > > > > > > also > > > > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c > > > > > > > and not in > > > > > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. > > > > > > > I've done > > > > > > > it that way because if at some point we are to include ffjni.c > > > > > > > from > > > > > > > libavformat it won't work (it will only set the java vm in the > > > > > > > libavcodec > > > > > > > memory space). > > > > > > > > > > > > The problem is that this is not library-safe. What if two libs > > > > > > within > > > > > > the process (which both are using libavcodec) are setting a > > > > > > different > > > > > > VM? > > > > > > > > > > In the Android application context, you only have, AFAIK, one VM > > > > > running > > > > > during the lifetime of the application. The code does handle the > > > > > general > > > > > > > > does *not* (sorry) > > > > > > > > > JNI case (even outside Android) but do we really want to do that > > > > > anyway ? > > > > > > If there's guaranteed to be exactly one, I don't get why we can't get > > > it into existence ourselves? > > > > > > Where exactly would an application get the VM handle from? > > > > You get the Java VM pointer when JNI_onLoad(JavaVM *vm, void *reserved) is > > executed at library load. This is where you can pass the pointer to lavc. > > > > IMHO, av_jni_set_java_vm should set the VM once and then warn (or return an > > error) > > if the user is providing a different Java VM pointer. > > > > In theory, on some version of Android, you can spawn your own VM using their > > private C++ JniInvocation wrapper. > > On a regular desktop, you can create Java VMs (using JNI_createJavaVM). > > Also note that the JniInvocation wrapper is still used if the user hasn't > provided a JavaVM using av_jni_set_java_vm but that will only work on > android >= 4.4.2 I still don't quite understand the
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 08:55:23PM +0100, Matthieu Bouron wrote: > On Tue, Mar 01, 2016 at 08:38:04PM +0100, wm4 wrote: > > On Tue, 1 Mar 2016 20:33:14 +0100 > > Matthieu Bouronwrote: > > > > > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > > > Matthieu Bouron wrote: > > > > > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron > > > > > > > > wrote: > > > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron > > > > > > > > > > wrote: > > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > > * fix of switch/case code style > > > > > > > > > > * removal of a miss declaration of FFJNIField enum as a > > > > > > > > > > global variable > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > * fixes a few typo in comments > > > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > * fixes a few typo in comments and message logs > > > > > > > > * add missing .so at end of library names when trying to find > > > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > > > * reintroduce public functions that allow the user to set the > > > > > > > > Java > > > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > > > > > > JniInvocation wrapper is not available on all devices > > > > > > > > (android >= 4.4) > > > > > > > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. > > > > > > > (Since it > > > > > > > has to be set explicitly again by the user.) > > > > > > > > > > > > I think it is fine to store one VM for all the AVCodecContext as it > > > > > > will > > > > > > be the same during all the lifetime of the application. I should > > > > > > also > > > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and > > > > > > not in > > > > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've > > > > > > done > > > > > > it that way because if at some point we are to include ffjni.c from > > > > > > libavformat it won't work (it will only set the java vm in the > > > > > > libavcodec > > > > > > memory space). > > > > > > > > > > The problem is that this is not library-safe. What if two libs within > > > > > the process (which both are using libavcodec) are setting a different > > > > > VM? > > > > > > > > In the Android application context, you only have, AFAIK, one VM running > > > > during the lifetime of the application. The code does handle the > > > > general > > > > > > does *not* (sorry) > > > > > > > JNI case (even outside Android) but do we really want to do that anyway > > > > ? > > > > If there's guaranteed to be exactly one, I don't get why we can't get > > it into existence ourselves? > > > > Where exactly would an application get the VM handle from? > > You get the Java VM pointer when JNI_onLoad(JavaVM *vm, void *reserved) is > executed at library load. This is where you can pass the pointer to lavc. > > IMHO, av_jni_set_java_vm should set the VM once and then warn (or return an > error) > if the user is providing a different Java VM pointer. > > In theory, on some version of Android, you can spawn your own VM using their > private C++ JniInvocation wrapper. > On a regular desktop, you can create Java VMs (using JNI_createJavaVM). Also note that the JniInvocation wrapper is still used if the user hasn't provided a JavaVM using av_jni_set_java_vm but that will only work on android >= 4.4.2 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 08:38:04PM +0100, wm4 wrote: > On Tue, 1 Mar 2016 20:33:14 +0100 > Matthieu Bouronwrote: > > > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > > Matthieu Bouron wrote: > > > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > > Matthieu Bouron wrote: > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > > > > > > > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron > > > > > > > > > wrote: > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > > * fix of switch/case code style > > > > > > > > > * removal of a miss declaration of FFJNIField enum as a > > > > > > > > > global variable > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > * fixes a few typo in comments > > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > * fixes a few typo in comments and message logs > > > > > > > * add missing .so at end of library names when trying to find > > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > > * reintroduce public functions that allow the user to set the > > > > > > > Java > > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > > > > > JniInvocation wrapper is not available on all devices (android > > > > > > > >= 4.4) > > > > > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. (Since > > > > > > it > > > > > > has to be set explicitly again by the user.) > > > > > > > > > > I think it is fine to store one VM for all the AVCodecContext as it > > > > > will > > > > > be the same during all the lifetime of the application. I should also > > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and > > > > > not in > > > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've > > > > > done > > > > > it that way because if at some point we are to include ffjni.c from > > > > > libavformat it won't work (it will only set the java vm in the > > > > > libavcodec > > > > > memory space). > > > > > > > > The problem is that this is not library-safe. What if two libs within > > > > the process (which both are using libavcodec) are setting a different > > > > VM? > > > > > > In the Android application context, you only have, AFAIK, one VM running > > > during the lifetime of the application. The code does handle the general > > > > does *not* (sorry) > > > > > JNI case (even outside Android) but do we really want to do that anyway ? > > > > > If there's guaranteed to be exactly one, I don't get why we can't get > it into existence ourselves? > > Where exactly would an application get the VM handle from? You get the Java VM pointer when JNI_onLoad(JavaVM *vm, void *reserved) is executed at library load. This is where you can pass the pointer to lavc. IMHO, av_jni_set_java_vm should set the VM once and then warn (or return an error) if the user is providing a different Java VM pointer. In theory, on some version of Android, you can spawn your own VM using their private C++ JniInvocation wrapper. On a regular desktop, you can create Java VMs (using JNI_createJavaVM). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, 1 Mar 2016 20:33:14 +0100 Matthieu Bouronwrote: > On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > > On Tue, 1 Mar 2016 20:10:50 +0100 > > > Matthieu Bouron wrote: > > > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > > Matthieu Bouron wrote: > > > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > > > wrote: > > > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron > > > > > > > > wrote: > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > > * fix of switch/case code style > > > > > > > > * removal of a miss declaration of FFJNIField enum as a > > > > > > > > global variable > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > * fixes a few typo in comments > > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > > > Patch updated with the following differences: > > > > > > * fixes a few typo in comments and message logs > > > > > > * add missing .so at end of library names when trying to find > > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > > * reintroduce public functions that allow the user to set the Java > > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > > > > JniInvocation wrapper is not available on all devices (android >= > > > > > > 4.4) > > > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. (Since it > > > > > has to be set explicitly again by the user.) > > > > > > > > I think it is fine to store one VM for all the AVCodecContext as it will > > > > be the same during all the lifetime of the application. I should also > > > > enforce that the VM cannot be changed afterwards. > > > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and not > > > > in > > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've done > > > > it that way because if at some point we are to include ffjni.c from > > > > libavformat it won't work (it will only set the java vm in the > > > > libavcodec > > > > memory space). > > > > > > The problem is that this is not library-safe. What if two libs within > > > the process (which both are using libavcodec) are setting a different > > > VM? > > > > In the Android application context, you only have, AFAIK, one VM running > > during the lifetime of the application. The code does handle the general > > does *not* (sorry) > > > JNI case (even outside Android) but do we really want to do that anyway ? If there's guaranteed to be exactly one, I don't get why we can't get it into existence ourselves? Where exactly would an application get the VM handle from? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 08:24:27PM +0100, Matthieu Bouron wrote: > On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > > On Tue, 1 Mar 2016 20:10:50 +0100 > > Matthieu Bouronwrote: > > > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > > Matthieu Bouron wrote: > > > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > > > wrote: > > > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > > > > > > > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > > * fix of switch/case code style > > > > > > > * removal of a miss declaration of FFJNIField enum as a global > > > > > > > variable > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > * fixes a few typo in comments > > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > > > Patch updated with the following differences: > > > > > * fixes a few typo in comments and message logs > > > > > * add missing .so at end of library names when trying to find > > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > > * reintroduce public functions that allow the user to set the Java > > > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > > > JniInvocation wrapper is not available on all devices (android >= > > > > > 4.4) > > > > > > > > I'm wondering if the VM should be stored per AVCodecContext. (Since it > > > > has to be set explicitly again by the user.) > > > > > > I think it is fine to store one VM for all the AVCodecContext as it will > > > be the same during all the lifetime of the application. I should also > > > enforce that the VM cannot be changed afterwards. > > > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and not in > > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've done > > > it that way because if at some point we are to include ffjni.c from > > > libavformat it won't work (it will only set the java vm in the libavcodec > > > memory space). > > > > The problem is that this is not library-safe. What if two libs within > > the process (which both are using libavcodec) are setting a different > > VM? > > In the Android application context, you only have, AFAIK, one VM running > during the lifetime of the application. The code does handle the general does *not* (sorry) > JNI case (even outside Android) but do we really want to do that anyway ? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 08:13:48PM +0100, wm4 wrote: > On Tue, 1 Mar 2016 20:10:50 +0100 > Matthieu Bouronwrote: > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > > On Tue, 1 Mar 2016 19:52:08 +0100 > > > Matthieu Bouron wrote: > > > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > > > wrote: > > > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > > * fix of switch/case code style > > > > > > * removal of a miss declaration of FFJNIField enum as a global > > > > > > variable > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > * fixes a few typo in comments > > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > > > Patch updated with the following differences: > > > > * fixes a few typo in comments and message logs > > > > * add missing .so at end of library names when trying to find > > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > > * reintroduce public functions that allow the user to set the Java > > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > > JniInvocation wrapper is not available on all devices (android >= > > > > 4.4) > > > > > > I'm wondering if the VM should be stored per AVCodecContext. (Since it > > > has to be set explicitly again by the user.) > > > > I think it is fine to store one VM for all the AVCodecContext as it will > > be the same during all the lifetime of the application. I should also > > enforce that the VM cannot be changed afterwards. > > > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and not in > > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've done > > it that way because if at some point we are to include ffjni.c from > > libavformat it won't work (it will only set the java vm in the libavcodec > > memory space). > > The problem is that this is not library-safe. What if two libs within > the process (which both are using libavcodec) are setting a different > VM? In the Android application context, you only have, AFAIK, one VM running during the lifetime of the application. The code does handle the general JNI case (even outside Android) but do we really want to do that anyway ? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, 1 Mar 2016 20:10:50 +0100 Matthieu Bouronwrote: > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > > On Tue, 1 Mar 2016 19:52:08 +0100 > > Matthieu Bouron wrote: > > > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > > > wrote: > > > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > > > > > Patch updated with the following differences: > > > > > * fix of switch/case code style > > > > > * removal of a miss declaration of FFJNIField enum as a global > > > > > variable > > > > > > > > > > > > > > Patch updated with the following differences: > > > > * fixes a few typo in comments > > > > * fixes a if statement in ff_jni_init_jfields > > > > > > Patch updated with the following differences: > > > * fixes a few typo in comments and message logs > > > * add missing .so at end of library names when trying to find > > > JNI_GetCreatedVMs symbol (also add libart.so) > > > * reintroduce public functions that allow the user to set the Java > > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > > JniInvocation wrapper is not available on all devices (android >= 4.4) > > > > I'm wondering if the VM should be stored per AVCodecContext. (Since it > > has to be set explicitly again by the user.) > > I think it is fine to store one VM for all the AVCodecContext as it will > be the same during all the lifetime of the application. I should also > enforce that the VM cannot be changed afterwards. > > av_jni_set_java_vm stores the Java VM pointer locally in jni.c and not in > ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've done > it that way because if at some point we are to include ffjni.c from > libavformat it won't work (it will only set the java vm in the libavcodec > memory space). The problem is that this is not library-safe. What if two libs within the process (which both are using libavcodec) are setting a different VM? ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote: > On Tue, 1 Mar 2016 19:52:08 +0100 > Matthieu Bouronwrote: > > > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > > > > > wrote: > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > > > From: Matthieu Bouron > > > > > > > > > > > > > > > [...] > > > > > > > > > > > > > > Patch updated with the following differences: > > > > * fix of switch/case code style > > > > * removal of a miss declaration of FFJNIField enum as a global > > > > variable > > > > > > > > > > > Patch updated with the following differences: > > > * fixes a few typo in comments > > > * fixes a if statement in ff_jni_init_jfields > > > > Patch updated with the following differences: > > * fixes a few typo in comments and message logs > > * add missing .so at end of library names when trying to find > > JNI_GetCreatedVMs symbol (also add libart.so) > > * reintroduce public functions that allow the user to set the Java > > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > > JniInvocation wrapper is not available on all devices (android >= 4.4) > > I'm wondering if the VM should be stored per AVCodecContext. (Since it > has to be set explicitly again by the user.) I think it is fine to store one VM for all the AVCodecContext as it will be the same during all the lifetime of the application. I should also enforce that the VM cannot be changed afterwards. av_jni_set_java_vm stores the Java VM pointer locally in jni.c and not in ffjni.c and it is retrieved in jni.c using av_jni_get_java_vm. I've done it that way because if at some point we are to include ffjni.c from libavformat it won't work (it will only set the java vm in the libavcodec memory space). ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Tue, 1 Mar 2016 19:52:08 +0100 Matthieu Bouronwrote: > On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron > > wrote: > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > > From: Matthieu Bouron > > > > > > > > > > > [...] > > > > > > > > > > Patch updated with the following differences: > > > * fix of switch/case code style > > > * removal of a miss declaration of FFJNIField enum as a global variable > > > > > > > > Patch updated with the following differences: > > * fixes a few typo in comments > > * fixes a if statement in ff_jni_init_jfields > > Patch updated with the following differences: > * fixes a few typo in comments and message logs > * add missing .so at end of library names when trying to find > JNI_GetCreatedVMs symbol (also add libart.so) > * reintroduce public functions that allow the user to set the Java > virtual machine (av_jni_(set,get)_java_vm) as the private C++ > JniInvocation wrapper is not available on all devices (android >= 4.4) I'm wondering if the VM should be stored per AVCodecContext. (Since it has to be set explicitly again by the user.) ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Fri, Feb 26, 2016 at 05:36:40PM +0100, Matthieu Bouron wrote: > On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouron> wrote: > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > > From: Matthieu Bouron > > > > > > > [...] > > > > > > Patch updated with the following differences: > > * fix of switch/case code style > > * removal of a miss declaration of FFJNIField enum as a global variable > > > > > Patch updated with the following differences: > * fixes a few typo in comments > * fixes a if statement in ff_jni_init_jfields Patch updated with the following differences: * fixes a few typo in comments and message logs * add missing .so at end of library names when trying to find JNI_GetCreatedVMs symbol (also add libart.so) * reintroduce public functions that allow the user to set the Java virtual machine (av_jni_(set,get)_java_vm) as the private C++ JniInvocation wrapper is not available on all devices (android >= 4.4) >From 653f6f02efad5dd3bf3aeb328fd5ee2af1c7e5c6 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Mon, 28 Sep 2015 15:18:56 +0200 Subject: [PATCH 1/2] lavc: add JNI support --- configure | 5 + libavcodec/Makefile | 4 + libavcodec/ffjni.c | 483 libavcodec/ffjni.h | 148 libavcodec/jni.c| 65 +++ libavcodec/jni.h| 42 + 6 files changed, 747 insertions(+) create mode 100644 libavcodec/ffjni.c create mode 100644 libavcodec/ffjni.h create mode 100644 libavcodec/jni.c create mode 100644 libavcodec/jni.h diff --git a/configure b/configure index 8491fa1..fe94f84 100755 --- a/configure +++ b/configure @@ -208,6 +208,7 @@ External library support: --enable-gnutls enable gnutls, needed for https support if openssl is not used [no] --disable-iconv disable iconv [autodetect] + --enable-jni enable JNI support [no] --enable-ladspa enable LADSPA audio filtering [no] --enable-libass enable libass subtitles rendering, needed for subtitles and ass filter [no] @@ -1436,6 +1437,7 @@ EXTERNAL_LIBRARY_LIST=" gmp gnutls iconv +jni ladspa libass libbluray @@ -5544,6 +5546,8 @@ enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLin enabled frei0r&& { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled gmp && require2 gmp gmp.h mpz_export -lgmp enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init +enabled jni && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads && + check_lib2 "dlfcn.h" dlopen -ldl; } enabled ladspa&& { check_header ladspa.h || die "ERROR: ladspa.h header not found"; } enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libass&& require_pkg_config libass ass/ass.h ass_library_init @@ -6312,6 +6316,7 @@ echo "threading support ${thread_type-no}" echo "safe bitstream reader ${safe_bitstream_reader-no}" echo "SDL support ${sdl-no}" echo "opencl enabled${opencl-no}" +echo "JNI support ${jni-no}" echo "texi2html enabled ${texi2html-no}" echo "perl enabled ${perl-no}" echo "pod2man enabled ${pod2man-no}" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 667e257..c7a0ede 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -9,6 +9,7 @@ HEADERS = avcodec.h \ d3d11va.h \ dirac.h \ dxva2.h \ + jni.h \ qsv.h \ vaapi.h \ vda.h \ @@ -30,6 +31,7 @@ OBJS = allcodecs.o \ dirac.o \ dv_profile.o \ imgconvert.o \ + jni.o\ mathtables.o \ options.o\ parser.o
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Fri, Feb 26, 2016 at 4:41 PM, Matthieu Bouronwrote: > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > > From: Matthieu Bouron > > > [...] > > Patch updated with the following differences: > * fix of switch/case code style > * removal of a miss declaration of FFJNIField enum as a global variable > > Patch updated with the following differences: * fixes a few typo in comments * fixes a if statement in ff_jni_init_jfields From 098b528c0cf9ce18d9144a94a16a607ed3769827 Mon Sep 17 00:00:00 2001 From: Matthieu Bouron Date: Mon, 28 Sep 2015 15:18:56 +0200 Subject: [PATCH 1/2] lavc: add JNI support --- configure | 5 + libavcodec/Makefile | 2 + libavcodec/ffjni.c | 480 libavcodec/ffjni.h | 148 4 files changed, 635 insertions(+) create mode 100644 libavcodec/ffjni.c create mode 100644 libavcodec/ffjni.h diff --git a/configure b/configure index 37c4277..3ee9376 100755 --- a/configure +++ b/configure @@ -207,6 +207,7 @@ External library support: --enable-gnutls enable gnutls, needed for https support if openssl is not used [no] --disable-iconv disable iconv [autodetect] + --enable-jni enable JNI support [no] --enable-ladspa enable LADSPA audio filtering [no] --enable-libass enable libass subtitles rendering, needed for subtitles and ass filter [no] @@ -1434,6 +1435,7 @@ EXTERNAL_LIBRARY_LIST=" gmp gnutls iconv +jni ladspa libass libbluray @@ -5467,6 +5469,8 @@ enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLin enabled frei0r&& { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled gmp && require2 gmp gmp.h mpz_export -lgmp enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init +enabled jni && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads && + check_lib2 "dlfcn.h" dlopen -ldl; } enabled ladspa&& { check_header ladspa.h || die "ERROR: ladspa.h header not found"; } enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libass&& require_pkg_config libass ass/ass.h ass_library_init @@ -6234,6 +6238,7 @@ echo "threading support ${thread_type-no}" echo "safe bitstream reader ${safe_bitstream_reader-no}" echo "SDL support ${sdl-no}" echo "opencl enabled${opencl-no}" +echo "JNI support ${jni-no}" echo "texi2html enabled ${texi2html-no}" echo "perl enabled ${perl-no}" echo "pod2man enabled ${pod2man-no}" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f78d27b..519210a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -78,6 +78,7 @@ OBJS-$(CONFIG_IIRFILTER) += iirfilter.o OBJS-$(CONFIG_IMDCT15) += imdct15.o OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o +OBJS-$(CONFIG_JNI) += ffjni.o OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o @@ -934,6 +935,7 @@ SKIPHEADERS+= %_tablegen.h \ SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h +SKIPHEADERS-$(CONFIG_JNI) += ffjni.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c new file mode 100644 index 000..49f782a --- /dev/null +++ b/libavcodec/ffjni.c @@ -0,0 +1,480 @@ +/* + * Copyright (c) 2015-2016 Matthieu Bouron + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor,
Re: [FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote: > From: Matthieu Bouron> > --- > configure | 5 + > libavcodec/Makefile | 2 + > libavcodec/ffjni.c | 480 > > libavcodec/ffjni.h | 147 > 4 files changed, 634 insertions(+) > create mode 100644 libavcodec/ffjni.c > create mode 100644 libavcodec/ffjni.h > > diff --git a/configure b/configure > index 2148f11..b107a38 100755 > --- a/configure > +++ b/configure > @@ -206,6 +206,7 @@ External library support: >--enable-gnutls enable gnutls, needed for https support > if openssl is not used [no] >--disable-iconv disable iconv [autodetect] > + --enable-jni enable JNI support [no] >--enable-ladspa enable LADSPA audio filtering [no] >--enable-libass enable libass subtitles rendering, > needed for subtitles and ass filter [no] > @@ -1432,6 +1433,7 @@ EXTERNAL_LIBRARY_LIST=" > gmp > gnutls > iconv > +jni > ladspa > libass > libbluray > @@ -5455,6 +5457,8 @@ enabled decklink && { check_header > DeckLinkAPI.h || die "ERROR: DeckLin > enabled frei0r&& { check_header frei0r.h || die "ERROR: frei0r.h > header not found"; } > enabled gmp && require2 gmp gmp.h mpz_export -lgmp > enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h > gnutls_global_init > +enabled jni && { [ $target_os = "android" ] && check_header > jni.h && enabled pthreads && > + check_lib2 "dlfcn.h" dlopen -ldl; } > enabled ladspa&& { check_header ladspa.h || die "ERROR: ladspa.h > header not found"; } > enabled libiec61883 && require libiec61883 libiec61883/iec61883.h > iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 > enabled libass&& require_pkg_config libass ass/ass.h > ass_library_init > @@ -6222,6 +6226,7 @@ echo "threading support ${thread_type-no}" > echo "safe bitstream reader ${safe_bitstream_reader-no}" > echo "SDL support ${sdl-no}" > echo "opencl enabled${opencl-no}" > +echo "JNI support ${jni-no}" > echo "texi2html enabled ${texi2html-no}" > echo "perl enabled ${perl-no}" > echo "pod2man enabled ${pod2man-no}" > diff --git a/libavcodec/Makefile b/libavcodec/Makefile > index f6a4fbb..ced700a 100644 > --- a/libavcodec/Makefile > +++ b/libavcodec/Makefile > @@ -78,6 +78,7 @@ OBJS-$(CONFIG_IIRFILTER) += iirfilter.o > OBJS-$(CONFIG_IMDCT15) += imdct15.o > OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o > OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o > +OBJS-$(CONFIG_JNI) += ffjni.o > OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o > OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o > OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o > @@ -939,6 +940,7 @@ SKIPHEADERS+= %_tablegen.h > \ > > SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h > SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h > +SKIPHEADERS-$(CONFIG_JNI) += ffjni.h > SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h > SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h > SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h > diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c > new file mode 100644 > index 000..e73d6e0 > --- /dev/null > +++ b/libavcodec/ffjni.c > @@ -0,0 +1,480 @@ > +/* > + * Copyright (c) 2015-2016 Matthieu Bouron > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 > USA > + */ > + > +#include > +#include > +#include > +#include > + > +#include "libavutil/bprint.h" > +#include "libavutil/log.h" > + > +#include "config.h" > +#include "ffjni.h" > + > +static JavaVM *java_vm = NULL; > +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; > + > +/** > + * Check if JniInvocation has been initialized. > + * > + * @param log_ctx
[FFmpeg-devel] [PATCH 1/2] lavc: add JNI support
From: Matthieu Bouron--- configure | 5 + libavcodec/Makefile | 2 + libavcodec/ffjni.c | 480 libavcodec/ffjni.h | 147 4 files changed, 634 insertions(+) create mode 100644 libavcodec/ffjni.c create mode 100644 libavcodec/ffjni.h diff --git a/configure b/configure index 2148f11..b107a38 100755 --- a/configure +++ b/configure @@ -206,6 +206,7 @@ External library support: --enable-gnutls enable gnutls, needed for https support if openssl is not used [no] --disable-iconv disable iconv [autodetect] + --enable-jni enable JNI support [no] --enable-ladspa enable LADSPA audio filtering [no] --enable-libass enable libass subtitles rendering, needed for subtitles and ass filter [no] @@ -1432,6 +1433,7 @@ EXTERNAL_LIBRARY_LIST=" gmp gnutls iconv +jni ladspa libass libbluray @@ -5455,6 +5457,8 @@ enabled decklink && { check_header DeckLinkAPI.h || die "ERROR: DeckLin enabled frei0r&& { check_header frei0r.h || die "ERROR: frei0r.h header not found"; } enabled gmp && require2 gmp gmp.h mpz_export -lgmp enabled gnutls&& require_pkg_config gnutls gnutls/gnutls.h gnutls_global_init +enabled jni && { [ $target_os = "android" ] && check_header jni.h && enabled pthreads && + check_lib2 "dlfcn.h" dlopen -ldl; } enabled ladspa&& { check_header ladspa.h || die "ERROR: ladspa.h header not found"; } enabled libiec61883 && require libiec61883 libiec61883/iec61883.h iec61883_cmp_connect -lraw1394 -lavc1394 -lrom1394 -liec61883 enabled libass&& require_pkg_config libass ass/ass.h ass_library_init @@ -6222,6 +6226,7 @@ echo "threading support ${thread_type-no}" echo "safe bitstream reader ${safe_bitstream_reader-no}" echo "SDL support ${sdl-no}" echo "opencl enabled${opencl-no}" +echo "JNI support ${jni-no}" echo "texi2html enabled ${texi2html-no}" echo "perl enabled ${perl-no}" echo "pod2man enabled ${pod2man-no}" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index f6a4fbb..ced700a 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -78,6 +78,7 @@ OBJS-$(CONFIG_IIRFILTER) += iirfilter.o OBJS-$(CONFIG_IMDCT15) += imdct15.o OBJS-$(CONFIG_INTRAX8) += intrax8.o intrax8dsp.o OBJS-$(CONFIG_IVIDSP) += ivi_dsp.o +OBJS-$(CONFIG_JNI) += ffjni.o OBJS-$(CONFIG_JPEGTABLES) += jpegtables.o OBJS-$(CONFIG_LIBXVID) += libxvid_rc.o OBJS-$(CONFIG_LLAUDDSP)+= lossless_audiodsp.o @@ -939,6 +940,7 @@ SKIPHEADERS+= %_tablegen.h \ SKIPHEADERS-$(CONFIG_D3D11VA) += d3d11va.h dxva2_internal.h SKIPHEADERS-$(CONFIG_DXVA2)+= dxva2.h dxva2_internal.h +SKIPHEADERS-$(CONFIG_JNI) += ffjni.h SKIPHEADERS-$(CONFIG_LIBSCHROEDINGER) += libschroedinger.h SKIPHEADERS-$(CONFIG_LIBUTVIDEO) += libutvideo.h SKIPHEADERS-$(CONFIG_LIBVPX) += libvpx.h diff --git a/libavcodec/ffjni.c b/libavcodec/ffjni.c new file mode 100644 index 000..e73d6e0 --- /dev/null +++ b/libavcodec/ffjni.c @@ -0,0 +1,480 @@ +/* + * Copyright (c) 2015-2016 Matthieu Bouron + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include +#include +#include +#include + +#include "libavutil/bprint.h" +#include "libavutil/log.h" + +#include "config.h" +#include "ffjni.h" + +static JavaVM *java_vm = NULL; +static pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER; + +/** + * Check if JniInvocation has been initialized. + * + * @param log_ctx context used for logging, can be NULL + * @return 0 on success, < 0 otherwise + */ +static int check_jni_invocation(void *log_ctx) +{ +int ret = AVERROR_EXTERNAL; +void *handle = NULL; +void **jni_invocation = NULL; + +handle = dlopen(NULL, RTLD_LOCAL); +if (!handle) { +goto done; +