import java.util.*;
import java.util.zip.*;
import java.util.List;
import java.util.regex.*;
import java.util.concurrent.*;
import java.util.concurrent.atomic.*;
import java.util.concurrent.locks.*;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.text.*;
import javax.swing.table.*;
import java.io.*;
import java.net.*;
import java.lang.reflect.*;
import java.lang.ref.*;
import java.lang.management.*;
import java.security.*;
import java.security.spec.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
import javax.imageio.*;
import java.math.*;
// https://stackoverflow.com/a/48214101
// sudo apt install vlc-plugin-access-extra !!!
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.nio.charset.Charset;
import static x30_pkg.x30_util.DynamicObject;
import java.text.*;
import java.util.TimeZone;
import uk.co.caprica.vlcj.player.*;
import uk.co.caprica.vlcj.player.direct.*;
import uk.co.caprica.vlcj.player.direct.format.*;
class main {
// vlcj player (stable version for VLCJ 3)
// vlcj 3
// jna
static String megaLibID = "#1400525";
static BufferedImage image;
static MediaPlayerFactory factory;
static DirectMediaPlayer mediaPlayer;
static int width, height;
static FPSCounter fps;
public static void main(final String[] args) throws Exception {
pnl(pairToList(addMegaLibrary(myClassLoader(), megaLibID)));
fixContextClassLoader();
width = screenWidth();
height = screenHeight();
print(width + "/" + height);
image = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration().createCompatibleImage(width, height);
image.setAccelerationPriority(1.0f);
String mrl = "screen://";
String[] options = {
":screen-fps=30",
":live-caching=0",
":screen-width=" + width,
":screen-height=" + height,
":screen-left=0",
":screen-top=0"
};
pnl(options);
factory = new MediaPlayerFactory();
mediaPlayer = factory.newDirectMediaPlayer(new TestBufferFormatCallback(), new TestRenderCallback());
mediaPlayer.playMedia(mrl, options);
}
// Callbacks are required.
static class TestRenderCallback extends RenderCallbackAdapter {
public TestRenderCallback() {
super(((DataBufferInt) image.getRaster().getDataBuffer()).getData());
}
@Override
public void onDisplay(DirectMediaPlayer mediaPlayer, int[] data) {
if (fps == null) fps = new FPSCounter();
fps.inc();
print("Got image data (" + n2(l(data)) + ") - " + fps.get() + " fps");
// The image data could be manipulated here...
/* RGB to GRAYScale conversion example */
// for(int i=0; i < data.length; i++){
// int argb = data[i];
// int b = (argb & 0xFF);
// int g = ((argb >> 8 ) & 0xFF);
// int r = ((argb >> 16 ) & 0xFF);
// int grey = (r + g + b + g) >> 2 ; //performance optimized - not real grey!
// data[i] = (grey << 16) + (grey << 8) + grey;
// }
// imagePane.repaint();
}
}
static class TestBufferFormatCallback implements BufferFormatCallback {
@Override
public BufferFormat getBufferFormat(int sourceWidth, int sourceHeight) {
return new RV32BufferFormat(width, height);
}
}
static A pnl(A l) { return pnl("", l); }
static A pnl(String prefix, A l) {
printNumberedLines(prefix, l);
return l;
}
static A[] pnl(A[] l) { return pnl("", l); }
static A[] pnl(String prefix, A[] l) {
printNumberedLines(prefix, l);
return l;
}
static A pnl(A map) {
printNumberedLines(map);
return map;
}
static A pnl(String prefix, A map) {
printNumberedLines(prefix, map);
return map;
}
static String pnl(String s) {
printNumberedLines(lines(s));
return s;
}
static MultiMap pnl(MultiMap mm) {
pnl(mm == null ? null : mm.asMap());
return mm;
}
static List pairToList(Pair p) {
return p == null ? null : ll(p.a, p.b);
}
static Pair, List> addMegaLibrary(ClassLoader cl, String snippetID) {
var jars = allJarFiles(unpackZipLibrary(snippetID));
List added = new ArrayList();
List alreadyThere = new ArrayList();
for (var jar : jars)
(addByteCodePathToClassLoader(cl, jar) ? added : alreadyThere).add(jar);
return pair(added, alreadyThere);
}
static ClassLoader myClassLoader() {
return _getClass(mc()).getClassLoader();
}
/* binary break!
static ClassLoader fixContextClassLoader() {
var cl = myClassLoader();
Thread.currentThread().setContextClassLoader(cl);
ret cl;
}*/
static void fixContextClassLoader() {
Thread.currentThread().setContextClassLoader(myClassLoader());
}
static int screenWidth() {
return getScreenWidth();
}
static int screenHeight() {
return getScreenHeight();
}
static volatile StringBuffer local_log = new StringBuffer(); // not redirected
static volatile Appendable print_log = local_log; // might be redirected, e.g. to main bot
// in bytes - will cut to half that
static volatile int print_log_max = 1024*1024;
static volatile int local_log_max = 100*1024;
static boolean print_silent = false; // total mute if set
static Object print_byThread_lock = new Object();
static volatile ThreadLocal