mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-07 16:36:10 +00:00
Add video decoder using OpenMax LI on Raspberry Pi
This commit is contained in:
17
src/com/limelight/binding/video/OmxDecoder.java
Normal file
17
src/com/limelight/binding/video/OmxDecoder.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.limelight.binding.video;
|
||||
|
||||
import com.limelight.binding.LibraryHelper;
|
||||
|
||||
public class OmxDecoder {
|
||||
static {
|
||||
LibraryHelper.loadNativeLibrary("nv_omx_dec");
|
||||
}
|
||||
|
||||
public static native int init();
|
||||
|
||||
public static native void stop();
|
||||
|
||||
public static native void destroy();
|
||||
|
||||
public static native int decode(byte[] indata, int inoff, int inlen, boolean last);
|
||||
}
|
||||
54
src/com/limelight/binding/video/OmxDecoderRenderer.java
Normal file
54
src/com/limelight/binding/video/OmxDecoderRenderer.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.limelight.binding.video;
|
||||
|
||||
import com.limelight.nvstream.av.ByteBufferDescriptor;
|
||||
import com.limelight.nvstream.av.DecodeUnit;
|
||||
import com.limelight.nvstream.av.video.VideoDecoderRenderer;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implementation of a video decoder and renderer.
|
||||
* @author Iwan Timmer
|
||||
*/
|
||||
public class OmxDecoderRenderer implements VideoDecoderRenderer {
|
||||
|
||||
@Override
|
||||
public void setup(int width, int height, int redrawRate, Object renderTarget, int drFlags) {
|
||||
int err = OmxDecoder.init();
|
||||
if (err != 0) {
|
||||
throw new IllegalStateException("AVC decoder initialization failure: "+err);
|
||||
}
|
||||
|
||||
System.out.println("Using omx decoding");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
System.out.println("Start omx rendering");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stop() {
|
||||
OmxDecoder.stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void release() {
|
||||
OmxDecoder.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean submitDecodeUnit(DecodeUnit decodeUnit) {
|
||||
boolean ok = true;
|
||||
List<ByteBufferDescriptor> units = decodeUnit.getBufferList();
|
||||
for (int i=0;i<units.size();i++) {
|
||||
ByteBufferDescriptor bbd = units.get(i);
|
||||
if (ok)
|
||||
ok = (OmxDecoder.decode(bbd.data, bbd.offset, bbd.length, i == (units.size()-1)) == 0);
|
||||
}
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user