/** Map a library interface to the current process, providing * the explicit interface class. * Native libraries loaded via this method may be found in * <a href="NativeLibrary.html#library_search_paths">several locations</a>. * @param <T> Type of expected wrapper * @param interfaceClass The implementation wrapper interface * @return an instance of the requested interface, mapped to the current * process. * @throws UnsatisfiedLinkError if the library cannot be found or * dependent libraries are missing. */ public static <T extends Library> T load(Class<T> interfaceClass) { return load(null, interfaceClass); }
/** Map a library interface to the current process, providing * the explicit interface class. Any options provided for the library are * cached and associated with the library and any of its defined * structures and/or functions. * Native libraries loaded via this method may be found in * <a href="NativeLibrary.html#library_search_paths">several locations</a>. * @param <T> Type of expected wrapper * @param interfaceClass The implementation wrapper interface * @param options Map of library options * @return an instance of the requested interface, mapped to the current * process. * @throws UnsatisfiedLinkError if the library cannot be found or * dependent libraries are missing. * @see #load(String, Class, Map) */ public static <T extends Library> T load(Class<T> interfaceClass, Map<String, ?> options) { return load(null, interfaceClass, options); }
/** Map a library interface to the given shared library, providing * the explicit interface class. * If <code>name</code> is null, attempts to map onto the current process. * Native libraries loaded via this method may be found in * <a href="NativeLibrary.html#library_search_paths">several locations</a>. * @param <T> Type of expected wrapper * @param name Library base name * @param interfaceClass The implementation wrapper interface * @return an instance of the requested interface, mapped to the indicated * native library. * @throws UnsatisfiedLinkError if the library cannot be found or * dependent libraries are missing. * @see #load(String, Class, Map) */ public static <T extends Library> T load(String name, Class<T> interfaceClass) { return load(name, interfaceClass, Collections.<String, Object>emptyMap()); }
/** * Run native discovery, if set, and attempt to load the native library. * * @param discovery native discovery used to find the native library, may be <code>null</code> * @return native library */ private LibVlc discoverNativeLibrary(NativeDiscovery discovery) { if (discovery != null) { // The discover method return value is not currently used, since we try and load the native library whether // discovery worked or not discovery.discover(); } LibVlc nativeLibrary = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); checkVersion(nativeLibrary); // A synchronised library is required since there are multiple asynchronous task queues in use that could // potentially call into LibVLC concurrently return (LibVlc) Native.synchronizedLibrary(nativeLibrary); }
/** * Attempt to load the native library. * <p> * This is done immediately after discovery so that any error condition can be handled as early as possible. */ private boolean tryLoadingLibrary() { try { LibVlc libvlc = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); libvlc_instance_t instance = libvlc.libvlc_new(0, new String[0]); if (instance != null) { libvlc.libvlc_release(instance); LibVlcVersion version = new LibVlcVersion(libvlc); if (version.isSupported()) { return true; } } } catch (UnsatisfiedLinkError e) { } return false; }
/** * Execute the test. * <p> * This will throw a RuntimeException if the libvlc native library version is too old. * * @param args command-line arguments */ public static void main(String[] args) { LibVlc libvlc = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); String version = libvlc.libvlc_get_version(); test("2.1.0", version); }
public static void main(String[] args) throws Exception { LibVlc libvlc = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); libvlc_instance_t instance = libvlc.libvlc_new(0, new String[] {}); libvlc_media_t media = libvlc.libvlc_media_new_path(instance, args[0]); libvlc.libvlc_media_parse_with_options(media, 0, 0); // <--- FATAL VM CRASH IF RUNNING on 32-bit Ubuntu and Java7 Thread.sleep(1000); libvlc.libvlc_media_release(media); libvlc.libvlc_release(instance); System.exit(0); } }
public static void main(String[] args) { NativeDiscovery discovery = new NativeDiscovery() { @Override protected void onFound(String path, NativeDiscoveryStrategy strategy) { System.out.println("Found"); System.out.println(path); System.out.println(strategy); } @Override protected void onNotFound() { System.out.println("Not found"); } }; boolean found = discovery.discover(); System.out.println(found); LibVlc nativeLibrary = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); System.out.println("Loaded library " + nativeLibrary); libvlc_instance_t instance = nativeLibrary.libvlc_new(0, new String[0]); System.out.println("instance " + instance); if (instance != null) { nativeLibrary.libvlc_release(instance); } System.out.println(new LibVlcVersion(nativeLibrary).getVersion()); }
public static void main(String[] args) throws Exception { LibVlc libvlc = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class); libvlc_instance_t instance = libvlc.libvlc_new(0, new String[] {}); libvlc_media_player_t mediaPlayer = libvlc.libvlc_media_player_new(instance); libvlc_media_t media = libvlc.libvlc_media_new_path(instance, args[0]); libvlc.libvlc_media_player_set_media(mediaPlayer, media); libvlc.libvlc_media_player_play(mediaPlayer); Thread.sleep(10000); libvlc.libvlc_media_player_stop(mediaPlayer); libvlc.libvlc_media_release(media); libvlc.libvlc_media_player_release(mediaPlayer); libvlc.libvlc_release(instance); System.exit(0); } }
public BareBonesEmbeddedTest() { libvlc = Native.load(RuntimeUtil.getLibVlcLibraryName(), LibVlc.class);