Skip to content

Commit b80497f

Browse files
committed
Linux Changes
1 parent 422f85b commit b80497f

File tree

23 files changed

+74
-175
lines changed

23 files changed

+74
-175
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ and chat. There is also an `installer` module that provides a simple way to inst
3737
`jda` module that integrates with the [Java Discord API](https://github.com/discord-jda/JDA), and a `http` module that
3838
integrates with [Javalin](https://github.com/javalin/javalin) to provide a simple way to stream videos over HTTP.
3939

40-
The `sandbox` module only supports Paper and forks of it! However, any other aspect of the library can be used in any
40+
The `sandbox` plugin only supports Paper and forks of it! However, any other aspect of the library can be used in any
4141
Java context.
42+
4243
---
4344

4445
### Licensing

TODO

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
Development Milestones
22
- Build QEMU Statically for All Platforms
3-
- Fix Linux Library Issues
4-
53
- Add Interaction Support for Virtual Machine
64
- Add Interaction Support for Browser
75
- Add Images and GIF Support into Plugin

build.gradle.kts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ subprojects {
2222
apply(plugin = "com.github.node-gradle.node")
2323
apply(plugin = "com.diffplug.spotless")
2424

25+
val targetJavaVersion = 21
2526
java {
26-
sourceCompatibility = JavaVersion.VERSION_11
27-
targetCompatibility = JavaVersion.VERSION_11
28-
toolchain.languageVersion.set(JavaLanguageVersion.of(11))
27+
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
28+
val language = JavaLanguageVersion.of(targetJavaVersion)
29+
sourceCompatibility = javaVersion
30+
targetCompatibility = javaVersion
31+
toolchain.languageVersion.set(language)
2932
}
3033

3134
tasks {
@@ -43,6 +46,7 @@ subprojects {
4346

4447
withType<JavaCompile>().configureEach {
4548
val set = setOf("-parameters")
49+
options.release.set(targetJavaVersion)
4650
options.compilerArgs.addAll(set)
4751
options.encoding = "UTF-8"
4852
options.isFork = true

docs/_toc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ parts:
1818
- file: image.md
1919
- file: ffmpeg.md
2020
- file: examples.md
21-
- caption: MCAV Minecraft Module 🧱
21+
- caption: MCAV Bukkit Module 🧱
2222
chapters:
2323
- file: minecraft.md
2424
- file: resourcepack.md

docs/minecraft.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
## Minecraft Platform Module
1+
## Bukkit Platform Module
22

3-
The Minecraft platform module is an external module that provides Minecraft-specific playback for
3+
The Bukkit platform module is an external module that provides Minecraft-specific playback for
44
players. There are several useful utilities to output video to maps, entities, scoreboards, and chat in this module.
55

6+
```{note}
7+
The Bukkit module only supports the latest version of Minecraft.
8+
```
9+
610
If you would like access to the Bukkit platform module, add the following dependency to the project instead of the
711
`mcav-common` dependency:
812

docs/started.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
MCAV is a Java library that can be used in any project. To get started, you need to add the MCAV dependency to your
66
project. For more information about other modules, see the Minecraft or Installer documentation.
77

8+
```{note}
9+
All of MCAV's modules require at least Java 21 in order to run.
10+
```
11+
812
```kts
913
repositories {
1014
maven("https://repo.brandonli.me/snapshots")

mcav-bukkit/build.gradle.kts

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,8 @@ dependencies {
2323
testImplementation(project(":mcav-common"))
2424
}
2525

26-
val targetJavaVersion = 21
27-
java {
28-
val javaVersion = JavaVersion.toVersion(targetJavaVersion)
29-
val language = JavaLanguageVersion.of(targetJavaVersion)
30-
sourceCompatibility = javaVersion
31-
targetCompatibility = javaVersion
32-
toolchain.languageVersion.set(language)
33-
}
34-
3526
tasks {
3627

37-
withType<JavaCompile>().configureEach {
38-
options.release.set(targetJavaVersion)
39-
}
40-
4128
java {
4229
withSourcesJar()
4330
withJavadocJar()
Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,13 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18-
package me.brandonli.mcav.capability.installer.vlc.github;
18+
package me.brandonli.mcav;
1919

20-
public final class ReleasePackage {
20+
import com.sun.jna.Library;
21+
import com.sun.jna.Native;
2122

22-
private final String url;
23-
private final String hash;
23+
public interface CLibrary extends Library {
24+
CLibrary INSTANCE = Native.load("c", CLibrary.class);
2425

25-
ReleasePackage(final String url, final String hash) {
26-
this.url = url;
27-
this.hash = hash;
28-
}
29-
30-
public String getUrl() {
31-
return this.url;
32-
}
33-
34-
public String getHash() {
35-
return this.hash;
36-
}
26+
int setenv(String name, String value, int overwrite);
3727
}

mcav-common/src/main/java/me/brandonli/mcav/LibraryInjector.java

Lines changed: 0 additions & 84 deletions
This file was deleted.

mcav-common/src/main/java/me/brandonli/mcav/MCAV.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,12 @@
2929
import me.brandonli.mcav.media.player.driver.ChromeDriverServiceProvider;
3030
import me.brandonli.mcav.media.player.multimedia.vlc.MediaPlayerFactoryProvider;
3131
import me.brandonli.mcav.media.player.pipeline.filter.video.dither.palette.Palette;
32+
import me.brandonli.mcav.utils.os.OS;
33+
import me.brandonli.mcav.utils.os.OSUtils;
3234
import org.bytedeco.ffmpeg.ffmpeg;
3335
import org.bytedeco.javacpp.Loader;
3436
import org.bytedeco.javacv.FFmpegLogCallback;
37+
import org.bytedeco.opencv.global.*;
3538
import org.bytedeco.opencv.opencv_java;
3639
import org.slf4j.Logger;
3740
import org.slf4j.LoggerFactory;
@@ -123,16 +126,34 @@ private void loadMapCache() {
123126
private void loadModules() {
124127
final long start = System.currentTimeMillis();
125128
LOGGER.info("Loading JavaCV modules...");
126-
final LibraryInjector injector = new LibraryInjector();
127-
injector.load();
128129
FFmpegLogCallback.set();
129130
Loader.load(Loader.class);
130-
Loader.load(opencv_java.class);
131+
this.loadOpenCVModules();
131132
Loader.load(ffmpeg.class);
132133
final long end = System.currentTimeMillis();
133134
LOGGER.info("JavaCV modules loaded in {} ms", end - start);
134135
}
135136

137+
private void loadOpenCVModules() {
138+
final OS os = OSUtils.getOS();
139+
if (os == OS.LINUX) {
140+
// avoid loading headless libraries
141+
System.setProperty("org.bytedeco.javacpp.loadlibraries", "false");
142+
Loader.load(opencv_core.class);
143+
Loader.load(opencv_imgproc.class);
144+
Loader.load(opencv_imgcodecs.class);
145+
Loader.load(opencv_videoio.class);
146+
Loader.load(opencv_video.class);
147+
Loader.load(opencv_calib3d.class);
148+
Loader.load(opencv_features2d.class);
149+
Loader.load(opencv_objdetect.class);
150+
Loader.load(opencv_photo.class);
151+
Loader.load(opencv_dnn.class);
152+
} else {
153+
Loader.load(opencv_java.class);
154+
}
155+
}
156+
136157
private void installQemu() {
137158
try {
138159
final QemuInstaller installer = QemuInstaller.create();
Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18-
package me.brandonli.mcav.capability.installer.vlc.github;
18+
package me.brandonli.mcav.capability.installer.vlc;
1919

2020
import static java.util.Objects.requireNonNull;
2121

@@ -67,25 +67,22 @@ public static Download[] readVLCDownloadsFromJsonResource(final String resourceP
6767
}
6868

6969
private static Download[] getDownloads() {
70-
final ReleasePackage releasePackage = download(true);
71-
final ReleasePackage other = download(false);
70+
final String releasePackage = download(true);
71+
final String other = download(false);
7272
if (releasePackage == null || other == null) {
7373
return new Download[0];
7474
}
75-
final Download linux64 = new Download(
76-
Platform.ofPlatform(OS.LINUX, Arch.X86, Bits.BITS_64),
77-
releasePackage.getUrl(),
78-
releasePackage.getHash()
79-
);
80-
final Download linux32 = new Download(Platform.ofPlatform(OS.LINUX, Arch.X86, Bits.BITS_32), other.getUrl(), other.getHash());
75+
final Download linux64 = new Download(Platform.ofPlatform(OS.LINUX, Arch.X86, Bits.BITS_64), releasePackage, null);
76+
final Download linux32 = new Download(Platform.ofPlatform(OS.LINUX, Arch.X86, Bits.BITS_32), other, null);
8177
return new Download[] { linux64, linux32 };
8278
}
8379

84-
private static @Nullable ReleasePackage download(final boolean continuous) {
80+
private static @Nullable String download(final boolean continuous) {
8581
final JsonArray assets = getJsonAssets(continuous);
8682
if (assets == null) {
8783
return null;
8884
}
85+
8986
String downloadUrl = "";
9087
final int size = assets.size();
9188
for (int i = 0; i < size; i++) {
@@ -103,14 +100,12 @@ private static Download[] getDownloads() {
103100
return null;
104101
}
105102

106-
final String hash = IOUtils.getSHA256Hash(downloadUrl);
107-
return new ReleasePackage(downloadUrl, hash);
103+
return downloadUrl;
108104
}
109105

110106
private static JsonArray getJsonAssets(final boolean continuous) {
111-
try {
107+
try (final HttpClient client = HttpClient.newHttpClient()) {
112108
final String apiUrl = continuous ? RELEASE_X86_64_URL : RELEASE_X86_32_URL;
113-
final HttpClient client = HttpClient.newHttpClient();
114109
final URI uri = URI.create(apiUrl);
115110
final HttpRequest request = HttpRequest.newBuilder().uri(uri).GET().build();
116111
final HttpResponse.BodyHandler<String> bodyHandler = HttpResponse.BodyHandlers.ofString();

mcav-common/src/main/java/me/brandonli/mcav/capability/installer/vlc/VLCInstaller.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import java.util.Optional;
2323
import me.brandonli.mcav.capability.installer.AbstractInstaller;
2424
import me.brandonli.mcav.capability.installer.Download;
25-
import me.brandonli.mcav.capability.installer.vlc.github.ReleasePackageManager;
2625
import me.brandonli.mcav.capability.installer.vlc.installation.InstallationStrategy;
2726
import me.brandonli.mcav.capability.installer.vlc.installation.LinuxInstallationStrategy;
2827
import me.brandonli.mcav.capability.installer.vlc.installation.OSXInstallationStrategy;

mcav-common/src/main/java/me/brandonli/mcav/media/player/multimedia/cv/AbstractVideoPlayerCV.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
import me.brandonli.mcav.media.player.pipeline.step.VideoPipelineStep;
3838
import me.brandonli.mcav.media.source.FFmpegDirectSource;
3939
import me.brandonli.mcav.media.source.Source;
40-
import me.brandonli.mcav.utils.ByteUtils;
4140
import me.brandonli.mcav.utils.ExecutorUtils;
41+
import me.brandonli.mcav.utils.natives.ByteUtils;
4242
import org.bytedeco.javacv.Frame;
4343
import org.bytedeco.javacv.FrameGrabber;
4444
import org.checkerframework.checker.nullness.qual.Nullable;

mcav-common/src/main/java/me/brandonli/mcav/media/player/multimedia/vlc/VLCPlayer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import me.brandonli.mcav.media.player.pipeline.step.AudioPipelineStep;
3030
import me.brandonli.mcav.media.player.pipeline.step.VideoPipelineStep;
3131
import me.brandonli.mcav.media.source.Source;
32-
import me.brandonli.mcav.utils.ByteUtils;
3332
import me.brandonli.mcav.utils.MetadataUtils;
33+
import me.brandonli.mcav.utils.natives.ByteUtils;
3434
import me.brandonli.mcav.utils.os.OSUtils;
3535
import org.checkerframework.checker.initialization.qual.UnderInitialization;
3636
import uk.co.caprica.vlcj.factory.MediaPlayerApi;

mcav-common/src/main/java/me/brandonli/mcav/media/player/pipeline/filter/video/dither/algorithm/error/FilterLiteDither.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import me.brandonli.mcav.media.image.StaticImage;
2323
import me.brandonli.mcav.media.player.pipeline.filter.video.dither.DitherUtils;
2424
import me.brandonli.mcav.media.player.pipeline.filter.video.dither.palette.Palette;
25-
import me.brandonli.mcav.utils.NativeUtils;
25+
import me.brandonli.mcav.utils.natives.NativeUtils;
2626
import me.brandonli.mcav.utils.os.Arch;
2727
import me.brandonli.mcav.utils.os.Bits;
2828
import me.brandonli.mcav.utils.os.OS;

mcav-common/src/main/java/me/brandonli/mcav/utils/ByteUtils.java renamed to mcav-common/src/main/java/me/brandonli/mcav/utils/natives/ByteUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18-
package me.brandonli.mcav.utils;
18+
package me.brandonli.mcav.utils.natives;
1919

2020
import java.nio.ByteBuffer;
2121
import java.nio.ByteOrder;

mcav-common/src/main/java/me/brandonli/mcav/utils/NativeLoadingException.java renamed to mcav-common/src/main/java/me/brandonli/mcav/utils/natives/NativeLoadingException.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18-
package me.brandonli.mcav.utils;
18+
package me.brandonli.mcav.utils.natives;
1919

2020
import org.checkerframework.checker.nullness.qual.Nullable;
2121

@@ -35,7 +35,7 @@ public class NativeLoadingException extends AssertionError {
3535
super(msg);
3636
}
3737

38-
NativeLoadingException(final @Nullable String msg, final @Nullable Throwable cause) {
38+
public NativeLoadingException(final @Nullable String msg, final @Nullable Throwable cause) {
3939
super(msg, cause);
4040
}
4141
}

0 commit comments

Comments
 (0)