Skip to content

Commit

Permalink
bumped videolan-natives to 4.8.5 + porting VLCJ
Browse files Browse the repository at this point in the history
  • Loading branch information
SrRapero720 committed May 29, 2024
1 parent e4996ea commit 9eb4592
Show file tree
Hide file tree
Showing 45 changed files with 184 additions and 300 deletions.
9 changes: 6 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,14 @@ configurations {
}

sourceSets {
test.compileClasspath += configurations.library
test.runtimeClasspath += configurations.library
// SHADOW
test.compileClasspath += configurations.shadow
test.runtimeClasspath += configurations.shadow

// LIBRARY
main.compileClasspath += configurations.library
test.compileClasspath += configurations.library
test.runtimeClasspath += configurations.library
}

dependencies {
Expand All @@ -60,7 +62,8 @@ dependencies {
}

// DEPENDENCIES
shadow "com.github.sealedtx:java-youtube-downloader:$jyd_version"
shadow "com.github.WaterMediaTeam:videolan-natives:$vlcj_natives_version"
shadow "com.github.WaterMediaTeam:ytdl-java:$jyd_version"
shadow "org.apache.commons:commons-compress:$commoncompress_version" // CARRIES 'CODEC', 'LANG3' AND 'COMMONS-IO'
shadow "org.tukaani:xz:$tukaani_version"
shadow project(":lib-vlcj")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ description=Library with an API using VLC for multimedia integration with Minecr
fabric_version=0.14.19
forge_version=unknown
jyd_version=3.2.3
vlcj_natives_version=4.8.4
vlcj_natives_version=4.8.5
commoncompress_version=1.26.1
commonslang3_version=3.12.0
commonsio_version=2.7
Expand Down
21 changes: 1 addition & 20 deletions lib-vlcj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,8 @@ repositories {
maven { url 'https://jitpack.io' }
}

configurations {
api
}

sourceSets {
main.compileClasspath += configurations.api
main.runtimeClasspath += configurations.api
}

dependencies {
api "com.github.WaterMediaTeam:videolan-natives:$vlcj_natives_version"
implementation "com.github.WaterMediaTeam:videolan-natives:$vlcj_natives_version"
compileOnly 'uk.co.caprica:vlcj-osx-stubs:1.0.0'
compileOnly 'net.java.dev.jna:jna:4.4.0'
compileOnly 'net.java.dev.jna:platform:3.4.0'
Expand All @@ -47,14 +38,4 @@ jar {
attributes "Implementation-Vendor": authors
attributes "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")
}

from {
configurations.api.collect {
it.isDirectory() ? it.matching {
exclude '*', 'META-INF/**'
} : zipTree(it).matching {
exclude '*', 'META-INF/**'
}
}
}
}
19 changes: 0 additions & 19 deletions lib-vlcj/src/main/java/uk/co/caprica/vlcj/VideoLan4J.java

This file was deleted.

10 changes: 5 additions & 5 deletions lib-vlcj/src/main/java/uk/co/caprica/vlcj/factory/AudioApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

package uk.co.caprica.vlcj.factory;

import uk.co.caprica.vlcj.VideoLan4J;
import uk.co.caprica.vlcj.binding.internal.libvlc_audio_output_device_t;
import uk.co.caprica.vlcj.binding.internal.libvlc_audio_output_t;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.strings.NativeString;
import uk.co.caprica.vlcj.player.base.AudioDevice;

import java.util.ArrayList;
Expand Down Expand Up @@ -51,8 +51,8 @@ public List<AudioOutput> audioOutputs() {
if (audioOutputs != null) {
libvlc_audio_output_t audioOutput = audioOutputs;
while (audioOutput != null) {
String name = NativeString.copyNativeString(audioOutput.psz_name);
String description = NativeString.copyNativeString(audioOutput.psz_description);
String name = VideoLan4J.copyNativeString(audioOutput.psz_name);
String description = VideoLan4J.copyNativeString(audioOutput.psz_description);
result.add(new AudioOutput(name, description, getAudioOutputDevices(name)));
audioOutput = audioOutput.p_next;
}
Expand All @@ -73,8 +73,8 @@ private List<AudioDevice> getAudioOutputDevices(String outputName) {
if (audioDevices != null) {
libvlc_audio_output_device_t audioDevice = audioDevices;
while(audioDevice != null) {
String device = NativeString.copyNativeString(audioDevice.psz_device);
String description = NativeString.copyNativeString(audioDevice.psz_description);
String device = VideoLan4J.copyNativeString(audioDevice.psz_device);
String description = VideoLan4J.copyNativeString(audioDevice.psz_description);
result.add(new AudioDevice(device, description));
audioDevice = audioDevice.p_next;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import uk.co.caprica.vlcj.binding.internal.libvlc_media_discoverer_description_t;
import uk.co.caprica.vlcj.binding.internal.libvlc_media_discoverer_t;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.types.size_t;
import uk.co.caprica.vlcj.binding.lib.types.size_t;
import uk.co.caprica.vlcj.media.discoverer.MediaDiscoverer;
import uk.co.caprica.vlcj.media.discoverer.MediaDiscovererCategory;
import uk.co.caprica.vlcj.media.discoverer.MediaDiscovererDescription;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import uk.co.caprica.vlcj.binding.internal.libvlc_rd_description_t;
import uk.co.caprica.vlcj.binding.internal.libvlc_renderer_discoverer_t;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.types.size_t;
import uk.co.caprica.vlcj.binding.lib.types.size_t;
import uk.co.caprica.vlcj.player.renderer.RendererDiscoverer;
import uk.co.caprica.vlcj.player.renderer.RendererDiscovererDescription;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@

import com.sun.jna.NativeLibrary;
import com.sun.jna.StringArray;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;
import uk.co.caprica.vlcj.VideoLan4J;
import uk.co.caprica.vlcj.binding.internal.libvlc_instance_t;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.factory.MediaPlayerFactory;
import uk.co.caprica.vlcj.factory.discovery.strategy.LinuxNativeDiscoveryStrategy;
import uk.co.caprica.vlcj.factory.discovery.strategy.NativeDiscoveryStrategy;
import uk.co.caprica.vlcj.factory.discovery.strategy.OsxNativeDiscoveryStrategy;
import uk.co.caprica.vlcj.factory.discovery.strategy.WindowsNativeDiscoveryStrategy;
import uk.co.caprica.vlcj.support.version.LibVlcVersion;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.Marker;
import org.apache.logging.log4j.MarkerManager;

import java.lang.ref.Reference;
import java.lang.reflect.Field;
Expand Down Expand Up @@ -119,7 +119,7 @@ public final boolean discover() {
String path = discoveryStrategy.discover();
if (path != null) {
if (discoveryStrategy.onFound(path)) {
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcLibraryName(), path);
NativeLibrary.addSearchPath(VideoLan4J.LIBVLC_NAME, path);
}
tryPluginPath(path, discoveryStrategy);
if (tryLoadingLibrary()) {
Expand Down Expand Up @@ -166,10 +166,10 @@ public boolean attemptFix() {

Map<String, Reference<NativeLibrary>> libs = (Map<String, Reference<NativeLibrary>>) libraries.get(null);
Map<String, List<String>> paths = (Map<String, List<String>>) searchPaths.get(null);
libs.remove(RuntimeUtil.getLibVlcCoreLibraryName());
paths.remove(RuntimeUtil.getLibVlcCoreLibraryName());
libs.remove(RuntimeUtil.getLibVlcLibraryName());
paths.remove(RuntimeUtil.getLibVlcLibraryName());
libs.remove(VideoLan4J.LIBVLCCORE_NAME);
paths.remove(VideoLan4J.LIBVLCCORE_NAME);
libs.remove(VideoLan4J.LIBVLC_NAME);
paths.remove(VideoLan4J.LIBVLC_NAME);
return true;
} catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException e) {
LOGGER.error(IT, "attemptFix failed", e);
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package uk.co.caprica.vlcj.factory.discovery.provider;

import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import com.sun.jna.Platform;

/**
* Implementation of a directory provider that returns a list of well-known directory locations to search on Linux.
Expand Down Expand Up @@ -51,6 +51,6 @@ public String[] directories() {

@Override
public boolean supported() {
return RuntimeUtil.isNix();
return Platform.isLinux();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

package uk.co.caprica.vlcj.factory.discovery.provider;

import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import com.sun.jna.Platform;

/**
* Implementation of a directory provider that returns a list of well-known directory locations to search on OSX.
Expand All @@ -38,7 +38,7 @@ public String[] directories() {

@Override
public boolean supported() {
return RuntimeUtil.isMac();
return Platform.isMac();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package uk.co.caprica.vlcj.factory.discovery.provider;

import com.sun.jna.Platform;
import com.sun.jna.platform.win32.Advapi32Util;
import com.sun.jna.platform.win32.WinReg;
import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.factory.discovery.NativeDiscovery;

import java.io.File;
Expand Down Expand Up @@ -64,7 +64,7 @@ public String[] directories() {

@Override
public boolean supported() {
return RuntimeUtil.isWindows();
return Platform.isWindows();
}

private String getVlcInstallDir() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package uk.co.caprica.vlcj.factory.discovery.strategy;

import com.sun.jna.Platform;
import uk.co.caprica.vlcj.binding.lib.LibC;
import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.factory.discovery.provider.DirectoryProviderDiscoveryStrategy;

/**
Expand All @@ -44,7 +44,7 @@ public LinuxNativeDiscoveryStrategy() {

@Override
public boolean supported() {
return RuntimeUtil.isNix();
return Platform.isLinux();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@
package uk.co.caprica.vlcj.factory.discovery.strategy;

import com.sun.jna.NativeLibrary;
import com.sun.jna.Platform;
import uk.co.caprica.vlcj.VideoLan4J;
import uk.co.caprica.vlcj.binding.lib.LibC;
import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.factory.discovery.provider.DirectoryProviderDiscoveryStrategy;

/**
Expand All @@ -47,7 +48,7 @@ public OsxNativeDiscoveryStrategy() {

@Override
public boolean supported() {
return RuntimeUtil.isMac();
return Platform.isMac();
}

@Override
Expand All @@ -63,8 +64,8 @@ public boolean onFound(String path) {
* @param path
*/
private void forceLoadLibVlcCore(String path) {
NativeLibrary.addSearchPath(RuntimeUtil.getLibVlcCoreLibraryName(), path);
NativeLibrary.getInstance(RuntimeUtil.getLibVlcCoreLibraryName());
NativeLibrary.addSearchPath(VideoLan4J.LIBVLC_NAME, path);
NativeLibrary.getInstance(VideoLan4J.LIBVLCCORE_NAME);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

package uk.co.caprica.vlcj.factory.discovery.strategy;

import com.sun.jna.Platform;
import uk.co.caprica.vlcj.binding.lib.LibC;
import uk.co.caprica.vlcj.binding.support.runtime.RuntimeUtil;
import uk.co.caprica.vlcj.factory.discovery.provider.DirectoryProviderDiscoveryStrategy;

/**
Expand All @@ -44,7 +44,7 @@ public WindowsNativeDiscoveryStrategy() {

@Override
public boolean supported() {
return RuntimeUtil.isWindows();
return Platform.isWindows();
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions lib-vlcj/src/main/java/uk/co/caprica/vlcj/log/NativeLog.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@
import com.sun.jna.Pointer;
import com.sun.jna.ptr.IntByReference;
import com.sun.jna.ptr.PointerByReference;
import uk.co.caprica.vlcj.VideoLan4J;
import uk.co.caprica.vlcj.binding.internal.libvlc_instance_t;
import uk.co.caprica.vlcj.binding.internal.libvlc_log_cb;
import uk.co.caprica.vlcj.binding.internal.libvlc_log_t;
import uk.co.caprica.vlcj.binding.lib.LibC;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.strings.NativeString;

import java.nio.ByteBuffer;
import java.util.List;
Expand Down Expand Up @@ -201,7 +201,7 @@ public void log(Pointer data, int level, libvlc_log_t ctx, String format, Pointe
private String getString(PointerByReference pointer) {
// The string is copied but not freed, the native string will be reclaimed when the native callback returns
Pointer value = pointer.getValue();
return value != null ? NativeString.copyNativeString(value) : null;
return value != null ? VideoLan4J.copyNativeString(value) : null;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib-vlcj/src/main/java/uk/co/caprica/vlcj/media/InfoApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@

package uk.co.caprica.vlcj.media;

import uk.co.caprica.vlcj.VideoLan4J;
import uk.co.caprica.vlcj.binding.internal.libvlc_media_stats_t;
import uk.co.caprica.vlcj.binding.lib.LibVlc;
import uk.co.caprica.vlcj.binding.support.strings.NativeString;
import uk.co.caprica.vlcj.player.base.State;

import java.util.List;
Expand All @@ -44,7 +44,7 @@ public final class InfoApi extends BaseApi {
* @return media resource locator
*/
public String mrl() {
return NativeString.copyAndFreeNativeString(LibVlc.libvlc_media_get_mrl(mediaInstance));
return VideoLan4J.copyAndFreeNativeString(LibVlc.libvlc_media_get_mrl(mediaInstance));
}

/**
Expand Down
Loading

0 comments on commit 9eb4592

Please sign in to comment.