[FFmpeg-devel] [PATCH 1/2] lavc: add JNI support

wm4 nfxjfg at googlemail.com
Tue Mar 1 20:38:04 CET 2016


On Tue, 1 Mar 2016 20:33:14 +0100
Matthieu Bouron <matthieu.bouron at gmail.com> 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 <matthieu.bouron at gmail.com> wrote:
> > >   
> > > > On Tue, Mar 01, 2016 at 07:56:30PM +0100, wm4 wrote:  
> > > > > On Tue, 1 Mar 2016 19:52:08 +0100
> > > > > Matthieu Bouron <matthieu.bouron at gmail.com> 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 <matthieu.bouron at gmail.com>
> > > > > > > wrote:
> > > > > > >       
> > > > > > > > On Mon, Feb 22, 2016 at 12:20:35PM +0100, Matthieu Bouron wrote:      
> > > > > > > > > From: Matthieu Bouron <matthieu.bouron at stupeflix.com>
> > > > > > > > >      
> > > > > > > >      
> > > > > > > 
> > > > > > > [...]
> > > > > > > 
> > > > > > >       
> > > > > > > >
> > > > > > > > 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?


More information about the ffmpeg-devel mailing list