Commit b44cd580 authored by Dele Olajide's avatar Dele Olajide

Jitsi Videobridge: Video recording re-write. Now using libwebm. Only working...

Jitsi Videobridge: Video recording re-write. Now using libwebm. Only working in Windows for now. TODO - generate linux binaries
parent 5fc6ca89
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
* Common parts of the codec that are shared by
* the encoder and decoder.
*/
public class LibVpxCom {
static {
System.loadLibrary("vpx");
System.loadLibrary("vpxJNI");
}
protected long vpxCodecIface;
protected native String vpxCodecVersionStr();
protected native String vpxCodecVersionExtraStr();
protected native String vpxCodecBuildConfig();
protected native boolean vpxCodecIsError(long ctx);
protected native String vpxCodecErrToString(int err);
protected native String vpxCodecError(long ctx);
protected native String vpxCodecErrorDetail(long ctx);
protected native long vpxCodecAllocCodec();
protected native void vpxCodecFreeCodec(long cfg);
protected native void vpxCodecDestroy(long ctx);
public String versionString() {
return vpxCodecVersionStr();
}
public String versionExtraString() {
return vpxCodecVersionExtraStr();
}
public String buildConfigString() {
return vpxCodecBuildConfig();
}
public String errToString(int err) {
return vpxCodecErrToString(err);
}
public String errorString() {
return vpxCodecError(vpxCodecIface);
}
public String errorDetailString() {
return vpxCodecErrorDetail(vpxCodecIface);
}
}
\ No newline at end of file
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
* libvpx JNI wrapper for decoding functions.
*/
public class LibVpxDec extends LibVpxCom {
private long decCfgObj;
private native long vpxCodecDecAllocCfg();
private native void vpxCodecDecFreeCfg(long cfg);
private native void vpxCodecDecSetThreads(long cfg, int value);
private native void vpxCodecDecSetWidth(long cfg, int value);
private native void vpxCodecDecSetHeight(long cfg, int value);
private native int vpxCodecDecGetThreads(long cfg);
private native int vpxCodecDecGetWidth(long cfg);
private native int vpxCodecDecGetHeight(long cfg);
private native boolean vpxCodecDecInit(long decoder, long cfg,
boolean postproc, boolean ecEnabled);
private native int vpxCodecDecDecode(long decoder, byte[] buf, int bufSize);
private native byte[] vpxCodecDecGetFrame(long decoder);
public LibVpxDec(int width, int height,
int threads,
boolean postProcEnabled,
boolean errorConcealmentEnabled) throws LibVpxException {
decCfgObj = vpxCodecDecAllocCfg();
vpxCodecIface = vpxCodecAllocCodec();
if (width > 0) {
vpxCodecDecSetWidth(decCfgObj, width);
}
if (height > 0) {
vpxCodecDecSetHeight(decCfgObj, height);
}
if (threads > 0) {
vpxCodecDecSetThreads(decCfgObj, threads);
}
if (!vpxCodecDecInit(vpxCodecIface, decCfgObj,
postProcEnabled, errorConcealmentEnabled)) {
throw new LibVpxException(vpxCodecError(vpxCodecIface));
}
}
public LibVpxDec(boolean postProcEnabled,
boolean errorConcealmentEnabled) throws LibVpxException {
this(0, 0, 0, postProcEnabled, errorConcealmentEnabled);
}
public LibVpxDec() throws LibVpxException {
this(0, 0, 0, false, false);
}
public byte[] decodeFrameToBuffer(byte[] rawFrame) throws LibVpxException {
if (vpxCodecDecDecode(vpxCodecIface, rawFrame, rawFrame.length) != 0) {
throw new LibVpxException(vpxCodecErrorDetail(vpxCodecIface));
}
return vpxCodecDecGetFrame(vpxCodecIface);
}
public void close() {
vpxCodecDestroy(vpxCodecIface);
vpxCodecDecFreeCfg(decCfgObj);
vpxCodecFreeCodec(vpxCodecIface);
}
}
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
import java.util.ArrayList;
/**
* libvpx JNI wrapper for encoding functions.
*/
public class LibVpxEnc extends LibVpxCom {
// Enums from libyuv.
public static final long FOURCC_I420 = 0x30323449;
public static final long FOURCC_I422 = 0x32323449;
public static final long FOURCC_NV21 = 0x3132564E;
public static final long FOURCC_NV12 = 0x3231564E;
public static final long FOURCC_YUY2 = 0x32595559;
public static final long FOURCC_UYVY = 0x56595559;
public static final long FOURCC_ARGB = 0x42475241;
public static final long FOURCC_BGRA = 0x41524742;
public static final long FOURCC_ABGR = 0x52474241;
public static final long FOURCC_24BG = 0x47423432; // rgb888
public static final long FOURCC_RGBA = 0x41424752;
public static final long FOURCC_RGBP = 0x50424752; // bgr565.
public static final long FOURCC_RGBO = 0x4F424752; // abgr1555.
public static final long FOURCC_R444 = 0x34343452; // argb4444.
public static final long FOURCC_YV12 = 0x32315659;
public static final long FOURCC_YV16 = 0x36315659;
// Enums from libvpx.
public static final int VPX_IMG_FMT_YV12 = 0x301;
public static final int VPX_IMG_FMT_I420 = 0x102;
private native void vpxCodecEncInit(long encoder, long cfg);
private native int vpxCodecEncCtlSetCpuUsed(long ctx, int value);
private native int vpxCodecEncCtlSetEnableAutoAltRef(long ctx, int value);
private native int vpxCodecEncCtlSetNoiseSensitivity(long ctx, int value);
private native int vpxCodecEncCtlSetSharpness(long ctx, int value);
private native int vpxCodecEncCtlSetStaticThreshold(long ctx, int value);
private native int vpxCodecEncCtlSetTokenPartitions(long ctx, int value);
private native int vpxCodecEncCtlSetARNRMaxFrames(long ctx, int value);
private native int vpxCodecEncCtlSetARNRStrength(long ctx, int value);
private native int vpxCodecEncCtlSetARNRType(long ctx, int value);
private native int vpxCodecEncCtlSetTuning(long ctx, int value);
private native int vpxCodecEncCtlSetCQLevel(long ctx, int value);
private native int vpxCodecEncCtlSetMaxIntraBitratePct(long ctx, int value);
private native boolean vpxCodecEncode(long ctx, byte[] frame,
int fmt, long pts, long duration,
long flags, long deadline);
private native boolean vpxCodecConvertByteEncode(long ctx, byte[] frame,
long pts, long duration,
long flags, long deadline,
long fourcc, int size);
private native boolean vpxCodecConvertIntEncode(long ctx, int[] frame,
long pts, long duration,
long flags, long deadline,
long fourcc, int size);
private static native boolean vpxCodecHaveLibyuv();
private native ArrayList<VpxCodecCxPkt> vpxCodecEncGetCxData(long ctx);
public LibVpxEnc(LibVpxEncConfig cfg) throws LibVpxException {
vpxCodecIface = vpxCodecAllocCodec();
if (vpxCodecIface == 0) {
throw new LibVpxException("Can not allocate JNI codec object");
}
vpxCodecEncInit(vpxCodecIface, cfg.handle());
if (isError()) {
String errorMsg = vpxCodecErrorDetail(vpxCodecIface);
vpxCodecFreeCodec(vpxCodecIface);
throw new LibVpxException(errorMsg);
}
}
public boolean isError() {
return vpxCodecIsError(vpxCodecIface);
}
private void throwOnError() throws LibVpxException {
if (vpxCodecIsError(vpxCodecIface)) {
throw new LibVpxException(vpxCodecErrorDetail(vpxCodecIface));
}
}
public ArrayList<VpxCodecCxPkt> encodeFrame(byte[] frame, int fmt, long frameStart, long frameDuration)
throws LibVpxException {
if (!vpxCodecEncode(vpxCodecIface, frame, fmt, frameStart, frameDuration, 0L, 0L)) {
throw new LibVpxException("Unable to encode frame");
}
throwOnError();
return vpxCodecEncGetCxData(vpxCodecIface);
}
public ArrayList<VpxCodecCxPkt> convertByteEncodeFrame(
byte[] frame, long frameStart, long frameDuration, long fourcc) throws LibVpxException {
if (!vpxCodecConvertByteEncode(vpxCodecIface,
frame, frameStart, frameDuration, 0L, 0L, fourcc, frame.length)) {
throw new LibVpxException("Unable to convert and encode frame");
}
throwOnError();
return vpxCodecEncGetCxData(vpxCodecIface);
}
public ArrayList<VpxCodecCxPkt> convertIntEncodeFrame(
int[] frame, long frameStart, long frameDuration, long fourcc) throws LibVpxException {
if (!vpxCodecConvertIntEncode(vpxCodecIface,
frame, frameStart, frameDuration, 0L, 0L, fourcc, frame.length)) {
throw new LibVpxException("Unable to convert and encode frame");
}
throwOnError();
return vpxCodecEncGetCxData(vpxCodecIface);
}
public static boolean haveLibyuv() {
return vpxCodecHaveLibyuv();
}
public void close() {
vpxCodecDestroy(vpxCodecIface);
vpxCodecFreeCodec(vpxCodecIface);
}
public void setCpuUsed(int value) throws LibVpxException {
// TODO(frkoenig) : Investigate anonymous interface class to reduce duplication
if (vpxCodecEncCtlSetCpuUsed(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set CpuUsed");
}
throwOnError();
}
public void setEnableAutoAltRef(int value) throws LibVpxException {
if (vpxCodecEncCtlSetEnableAutoAltRef(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to Enable Auto Alt Ref");
}
throwOnError();
}
public void setNoiseSensitivity(int value) throws LibVpxException {
if (vpxCodecEncCtlSetNoiseSensitivity(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Noise Sensitivity");
}
throwOnError();
}
public void setSharpness(int value) throws LibVpxException {
if (vpxCodecEncCtlSetSharpness(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Sharpness");
}
throwOnError();
}
public void setStaticThreshold(int value) throws LibVpxException {
if (vpxCodecEncCtlSetStaticThreshold(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Static Threshold");
}
throwOnError();
}
public void setTokenPartitions(int value) throws LibVpxException {
if (vpxCodecEncCtlSetTokenPartitions(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Token Partitions");
}
throwOnError();
}
public void setARNRMaxFrames(int value) throws LibVpxException {
if (vpxCodecEncCtlSetARNRMaxFrames(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set ARNR Max Frames");
}
throwOnError();
}
public void setARNRStrength(int value) throws LibVpxException {
if (vpxCodecEncCtlSetARNRStrength(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set ARNR Strength");
}
throwOnError();
}
public void setARNRType(int value) throws LibVpxException {
if (vpxCodecEncCtlSetARNRType(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set ARNRType");
}
throwOnError();
}
public void setTuning(int value) throws LibVpxException {
if (vpxCodecEncCtlSetTuning(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Tuning");
}
throwOnError();
}
public void setCQLevel(int value) throws LibVpxException {
if (vpxCodecEncCtlSetCQLevel(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set CQLevel");
}
throwOnError();
}
public void setMaxIntraBitratePct(int value) throws LibVpxException {
if (vpxCodecEncCtlSetMaxIntraBitratePct(vpxCodecIface, value) != 0) {
throw new LibVpxException("Unable to set Max Intra Bitrate Pct");
}
throwOnError();
}
}
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
* JNI interface to C struct used for configuring
* the libvpx encoder.
*/
public class LibVpxEncConfig extends LibVpxCom {
private long encCfgObj;
private native long vpxCodecEncAllocCfg();
private native void vpxCodecEncFreeCfg(long cfg);
private native int vpxCodecEncConfigDefault(long cfg, int argUsage);
private native void vpxCodecEncSetUsage(long cfg, int value);
private native void vpxCodecEncSetThreads(long cfg, int value);
private native void vpxCodecEncSetProfile(long cfg, int value);
private native void vpxCodecEncSetWidth(long cfg, int value);
private native void vpxCodecEncSetHeight(long cfg, int value);
private native void vpxCodecEncSetTimebase(long cfg, int num, int den);
private native void vpxCodecEncSetErrorResilient(long cfg, int value);
private native void vpxCodecEncSetPass(long cfg, int value);
private native void vpxCodecEncSetLagInFrames(long cfg, int value);
private native void vpxCodecEncSetRCDropframeThresh(long cfg, int value);
private native void vpxCodecEncSetRCResizeAllowed(long cfg, int value);
private native void vpxCodecEncSetRCResizeUpThresh(long cfg, int value);
private native void vpxCodecEncSetRCResizeDownThresh(long cfg, int value);
private native void vpxCodecEncSetRCEndUsage(long cfg, int value);
private native void vpxCodecEncSetRCTargetBitrate(long cfg, int value);
private native void vpxCodecEncSetRCMinQuantizer(long cfg, int value);
private native void vpxCodecEncSetRCMaxQuantizer(long cfg, int value);
private native void vpxCodecEncSetRCUndershootPct(long cfg, int value);
private native void vpxCodecEncSetRCOvershootPct(long cfg, int value);
private native void vpxCodecEncSetRCBufSz(long cfg, int value);
private native void vpxCodecEncSetRCBufInitialSz(long cfg, int value);
private native void vpxCodecEncSetRCBufOptimalSz(long cfg, int value);
private native void vpxCodecEncSetRC2PassVBRBiasPct(long cfg, int value);
private native void vpxCodecEncSetRC2PassVBRMinsectionPct(long cfg, int value);
private native void vpxCodecEncSetRC2PassVBRMaxsectioniasPct(long cfg, int value);
private native void vpxCodecEncSetKFMode(long cfg, int value);
private native void vpxCodecEncSetKFMinDist(long cfg, int value);
private native void vpxCodecEncSetKFMaxDist(long cfg, int value);
private native int vpxCodecEncGetUsage(long cfg);
private native int vpxCodecEncGetThreads(long cfg);
private native int vpxCodecEncGetProfile(long cfg);
private native int vpxCodecEncGetWidth(long cfg);
private native int vpxCodecEncGetHeight(long cfg);
private native Rational vpxCodecEncGetTimebase(long cfg);
private native int vpxCodecEncGetErrorResilient(long cfg);
private native int vpxCodecEncGetPass(long cfg);
private native int vpxCodecEncGetLagInFrames(long cfg);
private native int vpxCodecEncGetRCDropframeThresh(long cfg);
private native int vpxCodecEncGetRCResizeAllowed(long cfg);
private native int vpxCodecEncGetRCResizeUpThresh(long cfg);
private native int vpxCodecEncGetRCResizeDownThresh(long cfg);
private native int vpxCodecEncGetRCEndUsage(long cfg);
private native int vpxCodecEncGetRCTargetBitrate(long cfg);
private native int vpxCodecEncGetRCMinQuantizer(long cfg);
private native int vpxCodecEncGetRCMaxQuantizer(long cfg);
private native int vpxCodecEncGetRCUndershootPct(long cfg);
private native int vpxCodecEncGetRCOvershootPct(long cfg);
private native int vpxCodecEncGetRCBufSz(long cfg);
private native int vpxCodecEncGetRCBufInitialSz(long cfg);
private native int vpxCodecEncGetRCBufOptimalSz(long cfg);
private native int vpxCodecEncGetRC2PassVBRBiasPct(long cfg);
private native int vpxCodecEncGetRC2PassVBRMinsectionPct(long cfg);
private native int vpxCodecEncGetRC2PassVBRMaxsectioniasPct(long cfg);
private native int vpxCodecEncGetKFMode(long cfg);
private native int vpxCodecEncGetKFMinDist(long cfg);
private native int vpxCodecEncGetKFMaxDist(long cfg);
private native int vpxCodecEncGetFourcc();
public LibVpxEncConfig(int width, int height) throws LibVpxException {
encCfgObj = vpxCodecEncAllocCfg();
if (encCfgObj == 0) {
throw new LibVpxException("Can not allocate JNI encoder configure object");
}
int res = vpxCodecEncConfigDefault(encCfgObj, 0);
if (res != 0) {
vpxCodecEncFreeCfg(encCfgObj);
throw new LibVpxException(errToString(res));
}
setWidth(width);
setHeight(height);
/* Change the default timebase to a high enough value so that the encoder
* will always create strictly increasing timestamps.
*/
setTimebase(1, 1000);
}
public void close() {
vpxCodecEncFreeCfg(encCfgObj);
}
public long handle() {
return encCfgObj;
}
public void setThreads(int value) {
vpxCodecEncSetThreads(encCfgObj, value);
}
public void setProfile(int value) {
vpxCodecEncSetProfile(encCfgObj, value);
}
public void setWidth(int value) {
vpxCodecEncSetWidth(encCfgObj, value);
}
public void setHeight(int value) {
vpxCodecEncSetHeight(encCfgObj, value);
}
public void setTimebase(int num, int den) {
vpxCodecEncSetTimebase(encCfgObj, num, den);
}
public void setErrorResilient(int value) {
vpxCodecEncSetErrorResilient(encCfgObj, value);
}
public void setPass(int value) {
vpxCodecEncSetPass(encCfgObj, value);
}
public void setLagInFrames(int value) {
vpxCodecEncSetLagInFrames(encCfgObj, value);
}
public void setRCDropframeThresh(int value) {
vpxCodecEncSetRCDropframeThresh(encCfgObj, value);
}
public void setRCResizeAllowed(int value) {
vpxCodecEncSetRCResizeAllowed(encCfgObj, value);
}
public void setRCResizeUpThresh(int value) {
vpxCodecEncSetRCResizeUpThresh(encCfgObj, value);
}
public void setRCResizeDownThresh(int value) {
vpxCodecEncSetRCResizeDownThresh(encCfgObj, value);
}
public void setRCEndUsage(int value) {
vpxCodecEncSetRCEndUsage(encCfgObj, value);
}
public void setRCTargetBitrate(int value) {
vpxCodecEncSetRCTargetBitrate(encCfgObj, value);
}
public void setRCMinQuantizer(int value) {
vpxCodecEncSetRCMinQuantizer(encCfgObj, value);
}
public void setRCMaxQuantizer(int value) {
vpxCodecEncSetRCMaxQuantizer(encCfgObj, value);
}
public void setRCUndershootPct(int value) {
vpxCodecEncSetRCUndershootPct(encCfgObj, value);
}
public void setRCOvershootPct(int value) {
vpxCodecEncSetRCOvershootPct(encCfgObj, value);
}
public void setRCBufSz(int value) {
vpxCodecEncSetRCBufSz(encCfgObj, value);
}
public void setRCBufInitialSz(int value) {
vpxCodecEncSetRCBufInitialSz(encCfgObj, value);
}
public void setRCBufOptimalSz(int value) {
vpxCodecEncSetRCBufOptimalSz(encCfgObj, value);
}
public void setKFMinDist(int value) {
vpxCodecEncSetKFMinDist(encCfgObj, value);
}
public void setKFMaxDist(int value) {
vpxCodecEncSetKFMaxDist(encCfgObj, value);
}
public int getThreads() {
return vpxCodecEncGetThreads(encCfgObj);
}
public int getProfile() {
return vpxCodecEncGetProfile(encCfgObj);
}
public int getWidth() {
return vpxCodecEncGetWidth(encCfgObj);
}
public int getHeight() {
return vpxCodecEncGetHeight(encCfgObj);
}
public Rational getTimebase() {
return vpxCodecEncGetTimebase(encCfgObj);
}
public int getErrorResilient() {
return vpxCodecEncGetErrorResilient(encCfgObj);
}
public int getPass() {
return vpxCodecEncGetPass(encCfgObj);
}
public int getLagInFrames() {
return vpxCodecEncGetLagInFrames(encCfgObj);
}
public int getRCDropframeThresh() {
return vpxCodecEncGetRCDropframeThresh(encCfgObj);
}
public int getRCResizeAllowed() {
return vpxCodecEncGetRCResizeAllowed(encCfgObj);
}
public int getRCResizeUpThresh() {
return vpxCodecEncGetRCResizeUpThresh(encCfgObj);
}
public int getRCResizeDownThresh() {
return vpxCodecEncGetRCResizeDownThresh(encCfgObj);
}
public int getRCEndUsage() {
return vpxCodecEncGetRCEndUsage(encCfgObj);
}
public int getRCTargetBitrate() {
return vpxCodecEncGetRCTargetBitrate(encCfgObj);
}
public int getRCMinQuantizer() {
return vpxCodecEncGetRCMinQuantizer(encCfgObj);
}
public int getRCMaxQuantizer() {
return vpxCodecEncGetRCMaxQuantizer(encCfgObj);
}
public int getRCUndershootPct() {
return vpxCodecEncGetRCUndershootPct(encCfgObj);
}
public int getRCOvershootPct() {
return vpxCodecEncGetRCOvershootPct(encCfgObj);
}
public int getRCBufSz() {
return vpxCodecEncGetRCBufSz(encCfgObj);
}
public int getRCBufInitialSz() {
return vpxCodecEncGetRCBufInitialSz(encCfgObj);
}
public int getRCBufOptimalSz() {
return vpxCodecEncGetRCBufOptimalSz(encCfgObj);
}
public int getFourcc() {
return vpxCodecEncGetFourcc();
}
}
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
*
*/
public class LibVpxException extends Exception {
private static final long serialVersionUID = 1L;
public LibVpxException(String msg) {
super(msg);
}
}
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
* Holds a rational number
*
*/
public class Rational {
private final long num;
private final long den;
public Rational() {
num = 0;
den = 1;
}
public Rational(long num, long den) {
this.num = num;
this.den = den;
}
public Rational(String num, String den) {
this.num = Integer.parseInt(num);
this.den = Integer.parseInt(den);
}
public Rational multiply(Rational b) {
return new Rational(num * b.num(), den * b.den());
}
public Rational multiply(int b) {
return new Rational(num * b, den);
}
public Rational reciprocal() {
return new Rational(den, num);
}
public float toFloat() {
return (float) num / (float) den;
}
public long toLong() {
// TODO(frkoenig) : consider adding rounding to the divide.
return num / den;
}
public long num() {
return num;
}
public long den() {
return den;
}
@Override
public String toString() {
if (den == 1) {
return new String(num + "");
} else {
return new String(num + "/" + den);
}
}
public String toColonSeparatedString() {
return new String(num + ":" + den);
}
}
// Copyright 2012 Google Inc. All Rights Reserved.
// Author: frkoenig@google.com (Fritz Koenig)
package com.google.libvpx;
/**
* Packet of data return from encoder.
*/
public class VpxCodecCxPkt {
public byte[] buffer; // compressed data buffer
public long sz; // length of compressed data
public long pts; // time stamp to show frame (in timebase units)
long duration; // duration to show frame (in timebase units)
public int flags; // flags for this frame
int partitionId; // the partition id
// defines the decoding order
// of the partitions. Only
// applicable when "output partition"
// mode is enabled. First partition
// has id 0
public VpxCodecCxPkt(long sz) {
this.sz = sz;
buffer = new byte[(int) this.sz];
}
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm;
public abstract class Common {
static {
System.loadLibrary("webm");
}
protected long nativePointer;
protected boolean ownMemory;
public long getNativePointer() {
return nativePointer;
}
protected Common() {
nativePointer = 0;
ownMemory = true;
}
protected Common(long nativePointer) {
this.nativePointer = nativePointer;
ownMemory = false;
}
protected abstract void deleteObject();
@Override
protected void finalize() {
if (ownMemory) {
deleteObject();
}
nativePointer = 0;
ownMemory = false;
}
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
public class AudioTrack extends Track {
public AudioTrack(int seed) {
nativePointer = newAudioTrack(seed);
}
public long bitDepth() {
return bitDepth(nativePointer);
}
public long channels() {
return channels(nativePointer);
}
@Override
public long payloadSize() {
return PayloadSize(nativePointer);
}
public double sampleRate() {
return sampleRate(nativePointer);
}
public void setBitDepth(long bitDepth) {
setBitDepth(nativePointer, bitDepth);
}
public void setChannels(long channels) {
setChannels(nativePointer, channels);
}
public void setSampleRate(double sampleRate) {
setSampleRate(nativePointer, sampleRate);
}
@Override
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected AudioTrack(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteAudioTrack(nativePointer);
}
private static native long bitDepth(long jAudioTrack);
private static native long channels(long jAudioTrack);
private static native void deleteAudioTrack(long jAudioTrack);
private static native long newAudioTrack(int jSeed);
private static native long PayloadSize(long jAudioTrack);
private static native double sampleRate(long jAudioTrack);
private static native void setBitDepth(long jAudioTrack, long bit_depth);
private static native void setChannels(long jAudioTrack, long channels);
private static native void setSampleRate(long jAudioTrack, double sample_rate);
private static native boolean Write(long jAudioTrack, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Chapter extends Common {
public boolean addString(String title, String language, String country) {
return addString(nativePointer, title, language, country);
}
public boolean setId(String id) {
return setId(nativePointer, id);
}
public void setTime(Segment segment, long startTimeNs, long endTimeNs) {
setTime(nativePointer, segment.getNativePointer(), startTimeNs, endTimeNs);
}
protected Chapter(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native boolean addString(long jChapter, String jTitle, String jLanguage,
String jCountry);
private static native boolean setId(long jChapter, String jId);
private static native void setTime(long jChapter, long jSegment, long start_time_ns,
long end_time_ns);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Chapters extends Common {
public Chapters() {
nativePointer = newChapters();
}
public Chapter addChapter(int seed) {
long pointer = AddChapter(nativePointer, seed);
return new Chapter(pointer);
}
public int count() {
return Count(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected Chapters(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteChapters(nativePointer);
}
private static native long AddChapter(long jChapters, int jSeed);
private static native int Count(long jChapters);
private static native void deleteChapters(long jChapters);
private static native long newChapters();
private static native boolean Write(long jChapters, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Cluster extends Common {
public Cluster(long timecode, long cuesPos) {
nativePointer = newCluster(timecode, cuesPos);
}
public boolean addFrame(byte[] frame, long trackNumber, long timecode, boolean isKey) {
return AddFrame(nativePointer, frame, frame.length, trackNumber, timecode, isKey);
}
public boolean addMetadata(byte[] frame, long trackNumber, long timecode, long duration) {
return AddMetadata(nativePointer, frame, frame.length, trackNumber, timecode, duration);
}
public void addPayloadSize(long size) {
AddPayloadSize(nativePointer, size);
}
public int blocksAdded() {
return blocksAdded(nativePointer);
}
public boolean finalizeCluster() {
return Finalize(nativePointer);
}
public boolean init(IMkvWriter writer) {
return Init(nativePointer, writer.getNativePointer());
}
public long payloadSize() {
return payloadSize(nativePointer);
}
public long positionForCues() {
return positionForCues(nativePointer);
}
public long size() {
return Size(nativePointer);
}
public long timecode() {
return timecode(nativePointer);
}
protected Cluster(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteCluster(nativePointer);
}
private static native boolean AddFrame(long jCluster, byte[] jFrame, long length,
long track_number, long timecode, boolean is_key);
private static native boolean AddMetadata(long jCluster, byte[] jFrame, long length,
long track_number, long timecode, long duration);
private static native void AddPayloadSize(long jCluster, long size);
private static native int blocksAdded(long jCluster);
private static native void deleteCluster(long jCluster);
private static native boolean Finalize(long jCluster);
private static native boolean Init(long jCluster, long jWriter);
private static native long newCluster(long timecode, long cues_pos);
private static native long payloadSize(long jCluster);
private static native long positionForCues(long jCluster);
private static native long Size(long jCluster);
private static native long timecode(long jCluster);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class ContentEncAesSettings extends Common {
public ContentEncAesSettings() {
nativePointer = newContentEncAesSettings();
}
public long cipherMode() {
return cipherMode(nativePointer);
}
public long size() {
return Size(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected ContentEncAesSettings(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentEncAesSettings(nativePointer);
}
private static native long cipherMode(long jContentEncAesSettings);
private static native void deleteContentEncAesSettings(long jContentEncAesSettings);
private static native long newContentEncAesSettings();
private static native long Size(long jContentEncAesSettings);
private static native boolean Write(long jContentEncAesSettings, long jWriter);
public enum CipherMode {None, kCTR};
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class ContentEncoding extends Common {
public ContentEncoding() {
nativePointer = newContentEncoding();
}
public ContentEncAesSettings encAesSettings() {
long pointer = encAesSettings(nativePointer);
return new ContentEncAesSettings(pointer);
}
public long encAlgo() {
return encAlgo(nativePointer);
}
public long encodingOrder() {
return encodingOrder(nativePointer);
}
public long encodingScope() {
return encodingScope(nativePointer);
}
public long encodingType() {
return encodingType(nativePointer);
}
public boolean setEncryptionId(byte[] id) {
return SetEncryptionID(nativePointer, id, id.length);
}
public long size() {
return Size(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected ContentEncoding(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentEncoding(nativePointer);
}
private static native void deleteContentEncoding(long jContentEncoding);
private static native long encAesSettings(long jContentEncoding);
private static native long encAlgo(long jContentEncoding);
private static native long encodingOrder(long jContentEncoding);
private static native long encodingScope(long jContentEncoding);
private static native long encodingType(long jContentEncoding);
private static native long newContentEncoding();
private static native boolean SetEncryptionID(long jContentEncoding, byte[] jId, long length);
private static native long Size(long jContentEncoding);
private static native boolean Write(long jContentEncoding, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class CuePoint extends Common {
public CuePoint() {
nativePointer = newCuePoint();
}
public long blockNumber() {
return blockNumber(nativePointer);
}
public long clusterPos() {
return clusterPos(nativePointer);
}
public boolean outputBlockNumber() {
return outputBlockNumber(nativePointer);
}
public void setBlockNumber(long blockNumber) {
setBlockNumber(nativePointer, blockNumber);
}
public void setClusterPos(long clusterPos) {
setClusterPos(nativePointer, clusterPos);
}
public void setOutputBlockNumber(boolean outputBlockNumber) {
setOutputBlockNumber(nativePointer, outputBlockNumber);
}
public void setTime(long time) {
setTime(nativePointer, time);
}
public void setTrack(long track) {
setTrack(nativePointer, track);
}
public long size() {
return Size(nativePointer);
}
public long time() {
return time(nativePointer);
}
public long track() {
return track(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected CuePoint(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteCuePoint(nativePointer);
}
private static native long blockNumber(long jCuePoint);
private static native long clusterPos(long jCuePoint);
private static native void deleteCuePoint(long jCuePoint);
private static native long newCuePoint();
private static native boolean outputBlockNumber(long jCuePoint);
private static native void setBlockNumber(long jCuePoint, long block_number);
private static native void setClusterPos(long jCuePoint, long cluster_pos);
private static native void setOutputBlockNumber(long jCuePoint, boolean output_block_number);
private static native void setTime(long jCuePoint, long time);
private static native void setTrack(long jCuePoint, long track);
private static native long Size(long jCuePoint);
private static native long time(long jCuePoint);
private static native long track(long jCuePoint);
private static native boolean Write(long jCuePoint, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Cues extends Common {
public Cues() {
nativePointer = newCues();
}
public boolean addCue(CuePoint cue) {
return AddCue(nativePointer, cue.getNativePointer());
}
public int cueEntriesSize() {
return cueEntriesSize(nativePointer);
}
public CuePoint getCueByIndex(int index) {
long pointer = GetCueByIndex(nativePointer, index);
return new CuePoint(pointer);
}
public boolean outputBlockNumber() {
return outputBlockNumber(nativePointer);
}
public void setOutputBlockNumber(boolean outputBlockNumber) {
setOutputBlockNumber(nativePointer, outputBlockNumber);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected Cues(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteCues(nativePointer);
}
private static native boolean AddCue(long jCues, long jCue);
private static native int cueEntriesSize(long jCues);
private static native long GetCueByIndex(long jCues, int index);
private static native void deleteCues(long jCuePoint);
private static native long newCues();
private static native boolean outputBlockNumber(long jCues);
private static native void setOutputBlockNumber(long jCues, boolean output_block_number);
private static native boolean Write(long jCues, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Frame extends Common {
public Frame() {
nativePointer = newFrame();
}
public byte[] frame() {
return frame(nativePointer);
}
public boolean init(byte[] frame) {
return Init(nativePointer, frame, frame.length);
}
public boolean isKey() {
return isKey(nativePointer);
}
public long length() {
return length(nativePointer);
}
public void setIsKey(boolean key) {
setIsKey(nativePointer, key);
}
public void setTimestamp(long timestamp) {
setTimestamp(nativePointer, timestamp);
}
public void setTrackNumber(long trackNumber) {
setTrackNumber(nativePointer, trackNumber);
}
public long timestamp() {
return timestamp(nativePointer);
}
public long trackNumber() {
return trackNumber(nativePointer);
}
protected Frame(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteFrame(nativePointer);
}
private static native void deleteFrame(long jFrame);
private static native byte[] frame(long jFrame);
private static native boolean Init(long jFrame, byte[] jFrameBuffer, long length);
private static native boolean isKey(long jFrame);
private static native long length(long jFrame);
private static native long newFrame();
private static native void setIsKey(long jFrame, boolean key);
private static native void setTimestamp(long jFrame, long timestamp);
private static native void setTrackNumber(long jFrame, long track_number);
private static native long timestamp(long jFrame);
private static native long trackNumber(long jFrame);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public abstract class IMkvWriter extends Common {
public static IMkvWriter newMkvWriter(long nativePointer) {
IMkvWriter mkvWriter = null;
int type = getType(nativePointer);
if (type == 1) {
mkvWriter = new MkvWriter(nativePointer);
}
return mkvWriter;
}
public abstract void elementStartNotify(long elementId, long position);
public abstract long position();
public abstract int position(long position);
public abstract boolean seekable();
public abstract int write(byte[] buffer);
protected IMkvWriter() {
super();
}
protected IMkvWriter(long nativePointer) {
super(nativePointer);
}
private static native int getType(long jMkvReader);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public abstract class MkvMuxer extends Common {
public final long kEbmlUnknownValue = 0x01ffffffffffffffL;
public static long ebmlElementSize(long type, long value) {
return EbmlElementSizeLong(type, value);
}
public static long ebmlElementSize(long type, float value) {
return EbmlElementSizeFloat(type, value);
}
public static long ebmlElementSize(long type, byte[] value) {
return EbmlElementSizeBuffer(type, value, value.length);
}
public static long ebmlElementSize(long type, String value) {
return EbmlElementSizeString(type, value);
}
public static long ebmlMasterElementSize(long type, long value) {
return EbmlMasterElementSize(type, value);
}
public static void getVersion(int[] major, int[] minor, int[] build, int[] revision) {
GetVersion(major, minor, build, revision);
}
public static long makeUid(int seed) {
return MakeUID(seed);
}
public static int serializeInt(IMkvWriter writer, long value, int size) {
return SerializeInt(writer.getNativePointer(), value, size);
}
public static boolean writeEbmlElement(IMkvWriter writer, long type, long value) {
return WriteEbmlElementLong(writer.getNativePointer(), type, value);
}
public static boolean writeEbmlElement(IMkvWriter writer, long type, float value) {
return WriteEbmlElementFloat(writer.getNativePointer(), type, value);
}
public static boolean writeEbmlElement(IMkvWriter writer, long type, byte[] value) {
return WriteEbmlElementBuffer(writer.getNativePointer(), type, value, value.length);
}
public static boolean writeEbmlElement(IMkvWriter writer, long type, String value) {
return WriteEbmlElementString(writer.getNativePointer(), type, value);
}
public static boolean writeEbmlHeader(IMkvWriter writer) {
return WriteEbmlHeader(writer.getNativePointer());
}
public static boolean writeEbmlMasterElement(IMkvWriter writer, long value, long size) {
return WriteEbmlMasterElement(writer.getNativePointer(), value, size);
}
public static int writeId(IMkvWriter writer, long type) {
return WriteID(writer.getNativePointer(), type);
}
public static long writeMetadataBlock(IMkvWriter writer, byte[] data, long trackNumber,
long timeCode, long durationTimeCode) {
return WriteMetadataBlock(writer.getNativePointer(), data, data.length, trackNumber, timeCode,
durationTimeCode);
}
public static long writeSimpleBlock(IMkvWriter writer, byte[] data, long trackNumber,
long timeCode, long isKey) {
return WriteSimpleBlock(writer.getNativePointer(), data, data.length, trackNumber, timeCode,
isKey);
}
public static int writeUint(IMkvWriter writer, long value) {
return WriteUInt(writer.getNativePointer(), value);
}
public static int writeUintSize(IMkvWriter writer, long value, int size) {
return WriteUIntSize(writer.getNativePointer(), value, size);
}
public static long writeVoidElement(IMkvWriter writer, long size) {
return WriteVoidElement(writer.getNativePointer(), size);
}
private static native long EbmlElementSizeBuffer(long type, byte[] jValue, long size);
private static native long EbmlElementSizeFloat(long type, float value);
private static native long EbmlElementSizeLong(long type, long jValue);
private static native long EbmlElementSizeString(long type, String jValue);
private static native long EbmlMasterElementSize(long type, long value);
private static native void GetVersion(int[] jMajor, int[] jMinor, int[] jBuild, int[] jRevision);
private static native long MakeUID(int jSeed);
private static native int SerializeInt(long jWriter, long value, int size);
private static native boolean WriteEbmlElementBuffer(long jWriter, long type, byte[] jValue,
long size);
private static native boolean WriteEbmlElementFloat(long jWriter, long type, float value);
private static native boolean WriteEbmlElementLong(long jWriter, long type, long jValue);
private static native boolean WriteEbmlElementString(long jWriter, long type, String jValue);
private static native boolean WriteEbmlHeader(long jWriter);
private static native boolean WriteEbmlMasterElement(long jWriter, long value, long size);
private static native int WriteID(long jWriter, long type);
private static native long WriteMetadataBlock(long jWriter, byte[] jData, long length,
long track_number, long timecode, long duration_timecode);
private static native long WriteSimpleBlock(long jWriter, byte[] jData, long length,
long track_number, long timecode, long is_key);
private static native int WriteUInt(long jWriter, long value);
private static native int WriteUIntSize(long jWriter, long value, int size);
private static native long WriteVoidElement(long jWriter, long size);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
public class MkvWriter extends IMkvWriter {
public MkvWriter() {
nativePointer = newMkvWriter();
}
public void close() {
Close(nativePointer);
}
@Override
public void elementStartNotify(long elementId, long position) {
ElementStartNotify(nativePointer, elementId, position);
}
public boolean open(String fileName) {
return Open(nativePointer, fileName);
}
@Override
public long position() {
return GetPosition(nativePointer);
}
@Override
public int position(long position) {
return SetPosition(nativePointer, position);
}
@Override
public boolean seekable() {
return Seekable(nativePointer);
}
@Override
public int write(byte[] buffer) {
return Write(nativePointer, buffer, buffer.length);
}
protected MkvWriter(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteMkvWriter(nativePointer);
}
private static native void Close(long jMkvWriter);
private static native void deleteMkvWriter(long jMkvWriter);
private static native void ElementStartNotify(long jMkvWriter, long element_id, long position);
private static native long GetPosition(long jMkvWriter);
private static native long newMkvWriter();
private static native boolean Open(long jMkvWriter, String jFilename);
private static native boolean Seekable(long jMkvWriter);
private static native int SetPosition(long jMkvWriter, long position);
private static native int Write(long jMkvWriter, byte[] jBuffer, int length);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class SeekHead extends Common {
public SeekHead() {
nativePointer = newSeekHead();
}
public boolean addSeekEntry(int id, long pos) {
return AddSeekEntry(nativePointer, id, pos);
}
public boolean finalizeSeekHead(IMkvWriter writer) {
return Finalize(nativePointer, writer.getNativePointer());
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected SeekHead(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSeekHead(nativePointer);
}
private static native boolean AddSeekEntry(long jSeekHead, int id, long pos);
private static native void deleteSeekHead(long jSeekHead);
private static native boolean Finalize(long jSeekHead, long jWriter);
private static native long newSeekHead();
private static native boolean Write(long jSeekHead, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Segment extends Common {
public enum Mode {
None,
kLive,
kFile
};
public static final long kDefaultMaxClusterDuration = 30000000000L;
public Segment() {
nativePointer = newSegment();
}
public long addAudioTrack(int sampleRate, int channels, int number) {
return AddAudioTrack(nativePointer, sampleRate, channels, number);
}
public Chapter addChapter() {
long pointer = AddChapter(nativePointer);
return new Chapter(pointer);
}
public boolean addCuePoint(long timestamp, long track) {
return AddCuePoint(nativePointer, timestamp, track);
}
public boolean addFrame(byte[] frame, long trackNumber, long timestampNs, boolean isKey) {
return AddFrame(nativePointer, frame, frame.length, trackNumber, timestampNs, isKey);
}
public boolean addMetadata(byte[] frame, long trackNumber, long timestampNs, long durationNs) {
return AddMetadata(nativePointer, frame, frame.length, trackNumber, timestampNs, durationNs);
}
public Track addTrack(int number) {
long pointer = AddTrack(nativePointer, number);
return Track.newTrack(pointer);
}
public long addVideoTrack(int width, int height, int number) {
return AddVideoTrack(nativePointer, width, height, number);
}
public boolean chunking() {
return chunking(nativePointer);
}
public long cuesTrack() {
return getCuesTrack(nativePointer);
}
public boolean cuesTrack(long trackNumber) {
return setCuesTrack(nativePointer, trackNumber);
}
public boolean finalizeSegment() {
return Finalize(nativePointer);
}
public void forceNewClusterOnNextFrame() {
ForceNewClusterOnNextFrame(nativePointer);
}
public Cues getCues() {
long pointer = GetCues(nativePointer);
return new Cues(pointer);
}
public SegmentInfo getSegmentInfo() {
long pointer = GetSegmentInfo(nativePointer);
return new SegmentInfo(pointer);
}
public Track getTrackByNumber(long trackNumber) {
long pointer = GetTrackByNumber(nativePointer, trackNumber);
return Track.newTrack(pointer);
}
public boolean init(IMkvWriter writer) {
return Init(nativePointer, writer.getNativePointer());
}
public long maxClusterDuration() {
return maxClusterDuration(nativePointer);
}
public long maxClusterSize() {
return maxClusterSize(nativePointer);
}
public Mode mode() {
int ordinal = mode(nativePointer);
return Mode.values()[ordinal];
}
public boolean outputCues() {
return outputCues(nativePointer);
}
public void outputCues(boolean outputCues) {
OutputCues(nativePointer, outputCues);
}
public SegmentInfo segmentInfo() {
long pointer = segmentInfo(nativePointer);
return new SegmentInfo(pointer);
}
public void setMaxClusterDuration(long maxClusterDuration) {
setMaxClusterDuration(nativePointer, maxClusterDuration);
}
public void setMaxClusterSize(long maxClusterSize) {
setMaxClusterSize(nativePointer, maxClusterSize);
}
public void setMode(Mode mode) {
setMode(nativePointer, mode.ordinal());
}
public boolean setChunking(boolean chunking, String filename) {
return SetChunking(nativePointer, chunking, filename);
}
protected Segment(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSegment(nativePointer);
}
private static native long AddAudioTrack(long jSegment, int sample_rate, int channels,
int number);
private static native long AddChapter(long jSegment);
private static native boolean AddCuePoint(long jSegment, long timestamp, long track);
private static native boolean AddFrame(long jSegment, byte[] jFrame, long length,
long track_number, long timestamp_ns, boolean is_key);
private static native boolean AddMetadata(long jSegment, byte[] jFrame, long length,
long track_number, long timestamp_ns, long duration_ns);
private static native long AddTrack(long jSegment, int number);
private static native long AddVideoTrack(long jSegment, int width, int height, int number);
private static native boolean chunking(long jSegment);
private static native void deleteSegment(long jSegment);
private static native boolean Finalize(long jSegment);
private static native void ForceNewClusterOnNextFrame(long jSegment);
private static native long GetCues(long jSegment);
private static native long getCuesTrack(long jSegment);
private static native long GetSegmentInfo(long jSegment);
private static native long GetTrackByNumber(long jSegment, long track_number);
private static native boolean Init(long jSegment, long jWriter);
private static native long maxClusterDuration(long jSegment);
private static native long maxClusterSize(long jSegment);
private static native int mode(long jSegment);
private static native long newSegment();
private static native boolean outputCues(long jSegment);
private static native void OutputCues(long jSegment, boolean output_cues);
private static native long segmentInfo(long jSegment);
private static native boolean setCuesTrack(long jSegment, long track_number);
private static native void setMaxClusterDuration(long jSegment, long max_cluster_duration);
private static native void setMaxClusterSize(long jSegment, long max_cluster_size);
private static native void setMode(long jSegment, int mode);
private static native boolean SetChunking(long jSegment, boolean chunking, String jFilename);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class SegmentInfo extends Common {
public SegmentInfo() {
nativePointer = newSegmentInfo();
}
public double duration() {
return duration(nativePointer);
}
public boolean finalizeSegmentInfo(IMkvWriter writer) {
return Finalize(nativePointer, writer.getNativePointer());
}
public boolean init() {
return Init(nativePointer);
}
public String muxingApp() {
return muxingApp(nativePointer);
}
public void setDuration(double duration) {
setDuration(nativePointer, duration);
}
public void setMuxingApp(String app) {
setMuxingApp(nativePointer, app);
}
public void setTimecodeScale(long scale) {
setTimecodeScale(nativePointer, scale);
}
public void setWritingApp(String app) {
setWritingApp(nativePointer, app);
}
public long timecodeScale() {
return timecodeScale(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
public String writingApp() {
return writingApp(nativePointer);
}
protected SegmentInfo(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSegmentInfo(nativePointer);
}
private static native void deleteSegmentInfo(long jSegmentInfo);
private static native double duration(long jSegmentInfo);
private static native boolean Finalize(long jSegmentInfo, long jWriter);
private static native boolean Init(long jSegmentInfo);
private static native String muxingApp(long jSegmentInfo);
private static native long newSegmentInfo();
private static native void setDuration(long jSegmentInfo, double duration);
private static native void setMuxingApp(long jSegmentInfo, String jApp);
private static native void setTimecodeScale(long jSegmentInfo, long scale);
private static native void setWritingApp(long jSegmentInfo, String jApp);
private static native long timecodeScale(long jSegmentInfo);
private static native boolean Write(long jSegmentInfo, long jWriter);
private static native String writingApp(long jSegmentInfo);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Track extends Common {
public static Track newTrack(long nativePointer) {
Track track = null;
int type = getClassType(nativePointer);
if (type == 1) {
track = new AudioTrack(nativePointer);
} else if (type == 2) {
track = new Track(nativePointer);
} else if (type == 3) {
track = new VideoTrack(nativePointer);
}
return track;
}
public Track(int seed) {
nativePointer = newTrack(seed);
}
public boolean addContentEncoding() {
return AddContentEncoding(nativePointer);
}
public String codecId() {
return codecId(nativePointer);
}
public byte[] codecPrivate() {
return codecPrivate(nativePointer);
}
public long codecPrivateLength() {
return codecPrivateLength(nativePointer);
}
public int contentEncodingEntriesSize() {
return contentEncodingEntriesSize(nativePointer);
}
public ContentEncoding getContentEncodingByIndex(int index) {
long pointer = GetContentEncodingByIndex(nativePointer, index);
return new ContentEncoding(pointer);
}
public String language() {
return language(nativePointer);
}
public String name() {
return name(nativePointer);
}
public long number() {
return number(nativePointer);
}
public long payloadSize() {
return PayloadSize(nativePointer);
}
public void setCodecId(String codecId) {
setCodecId(nativePointer, codecId);
}
public boolean setCodecPrivate(byte[] codecPrivate) {
return SetCodecPrivate(nativePointer, codecPrivate, codecPrivate.length);
}
public void setLanguage(String language) {
setLanguage(nativePointer, language);
}
public void setName(String name) {
setName(nativePointer, name);
}
public void setNumber(long number) {
setNumber(nativePointer, number);
}
public void setType(long type) {
setType(nativePointer, type);
}
public long size() {
return Size(nativePointer);
}
public long type() {
return type(nativePointer);
}
public long uid() {
return uid(nativePointer);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected Track() {
}
protected Track(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteTrack(nativePointer);
}
private static native boolean AddContentEncoding(long jTrack);
private static native int contentEncodingEntriesSize(long jTrack);
private static native String codecId(long jTrack);
private static native byte[] codecPrivate(long jTrack);
private static native long codecPrivateLength(long jTrack);
private static native void deleteTrack(long jTrack);
private static native int getClassType(long jTrack);
private static native long GetContentEncodingByIndex(long jTrack, int index);
private static native String language(long jTrack);
private static native String name(long jTrack);
private static native long newTrack(int jSeed);
private static native long number(long jTrack);
private static native long PayloadSize(long jTrack);
private static native void setCodecId(long jTrack, String jCodecId);
private static native void setLanguage(long jTrack, String jLanguage);
private static native void setName(long jTrack, String jName);
private static native void setNumber(long jTrack, long number);
private static native void setType(long jTrack, long type);
private static native boolean SetCodecPrivate(long jTrack, byte[] jCodecPrivate, long length);
private static native long Size(long jTrack);
private static native long type(long jTrack);
private static native long uid(long jTrack);
private static native boolean Write(long jTrack, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import com.google.libwebm.Common;
public class Tracks extends Common {
public enum Type {
None,
kVideo,
kAudio
};
public static final String kVorbisCodecId = "A_VORBIS";
public static final String kVp8CodecId = "V_VP8";
public Tracks() {
nativePointer = newTracks();
}
public boolean addTrack(Track track, int number) {
return AddTrack(nativePointer, track.getNativePointer(), number);
}
public Track getTrackByIndex(int index) {
long pointer = GetTrackByIndex(nativePointer, index);
return Track.newTrack(pointer);
}
public Track getTrackByNumber(long trackNumber) {
long pointer = GetTrackByNumber(nativePointer, trackNumber);
return Track.newTrack(pointer);
}
public int trackEntriesSize() {
return trackEntriesSize(nativePointer);
}
public boolean trackIsAudio(long trackNumber) {
return TrackIsAudio(nativePointer, trackNumber);
}
public boolean trackIsVideo(long trackNumber) {
return TrackIsVideo(nativePointer, trackNumber);
}
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected Tracks(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteTracks(nativePointer);
}
private static native boolean AddTrack(long jTracks, long jTrack, int number);
private static native void deleteTracks(long jTracks);
private static native long GetTrackByIndex(long jTracks, int idx);
private static native long GetTrackByNumber(long jTracks, long track_number);
private static native long newTracks();
private static native int trackEntriesSize(long jTracks);
private static native boolean TrackIsAudio(long jTracks, long track_number);
private static native boolean TrackIsVideo(long jTracks, long track_number);
private static native boolean Write(long jTracks, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvmuxer;
import java.util.HashMap;
import java.util.Map;
public class VideoTrack extends Track {
public enum StereoMode {
kMono(0),
kSideBySideLeftIsFirst(1),
kTopBottomRightIsFirst(2),
kTopBottomLeftIsFirst(3),
kSideBySideRightIsFirst(11);
private static final Map<Integer, StereoMode> stereoModes = new HashMap<Integer, StereoMode>();
static {
for (StereoMode mode : StereoMode.values()) {
stereoModes.put(mode.toInt(), mode);
}
}
private final int value;
public static StereoMode toStereoMode(int value) {
return stereoModes.get(value);
}
public int toInt() {
return value;
}
private StereoMode(int value) {
this.value = value;
}
}
public VideoTrack(int seed) {
nativePointer = newVideoTrack(seed);
}
public long displayHeight() {
return displayHeight(nativePointer);
}
public long displayWidth() {
return displayWidth(nativePointer);
}
public double frameRate() {
return frameRate(nativePointer);
}
public long height() {
return height(nativePointer);
}
@Override
public long payloadSize() {
return PayloadSize(nativePointer);
}
public void setDisplayHeight(long height) {
setDisplayHeight(nativePointer, height);
}
public void setDisplayWidth(long width) {
setDisplayWidth(nativePointer, width);
}
public void setFrameRate(double frameRate) {
setFrameRate(nativePointer, frameRate);
}
public void setHeight(long height) {
setHeight(nativePointer, height);
}
public void setStereoMode(StereoMode stereoMode) {
SetStereoMode(nativePointer, stereoMode.toInt());
}
public void setWidth(long width) {
setWidth(nativePointer, width);
}
public StereoMode stereoMode() {
return StereoMode.toStereoMode((int) stereoMode(nativePointer));
}
public long width() {
return width(nativePointer);
}
@Override
public boolean write(IMkvWriter writer) {
return Write(nativePointer, writer.getNativePointer());
}
protected VideoTrack(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteVideoTrack(nativePointer);
}
private static native void deleteVideoTrack(long jVideoTrack);
private static native long displayHeight(long jVideoTrack);
private static native long displayWidth(long jVideoTrack);
private static native double frameRate(long jVideoTrack);
private static native long height(long jVideoTrack);
private static native long newVideoTrack(int jSeed);
private static native long PayloadSize(long jVideoTrack);
private static native void setDisplayHeight(long jVideoTrack, long height);
private static native void setDisplayWidth(long jVideoTrack, long width);
private static native void setFrameRate(long jVideoTrack, double frame_rate);
private static native void setHeight(long jVideoTrack, long height);
private static native void setWidth(long jVideoTrack, long width);
private static native void SetStereoMode(long jVideoTrack, long stereo_mode);
private static native long stereoMode(long jVideoTrack);
private static native long width(long jVideoTrack);
private static native boolean Write(long jVideoTrack, long jWriter);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
import com.google.libwebm.mkvmuxer.Chapters;
public class Atom extends Common {
public Display getDisplay(int index) {
long pointer = GetDisplay(nativePointer, index);
return new Display(pointer);
}
public int getDisplayCount() {
return GetDisplayCount(nativePointer);
}
public long getStartTime(Chapters chapters) {
return GetStartTime(nativePointer, chapters.getNativePointer());
}
public long getStartTimecode() {
return GetStartTimecode(nativePointer);
}
public long getStopTime(Chapters chapters) {
return GetStopTime(nativePointer, chapters.getNativePointer());
}
public long getStopTimecode() {
return GetStopTimecode(nativePointer);
}
public String getStringUid() {
return GetStringUID(nativePointer);
}
public long getUid() {
return GetUID(nativePointer);
}
protected Atom(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native long GetDisplay(long jAtom, int index);
private static native int GetDisplayCount(long jAtom);
private static native long GetStartTime(long jAtom, long jChapters);
private static native long GetStartTimecode(long jAtom);
private static native long GetStopTime(long jAtom, long jChapters);
private static native long GetStopTimecode(long jAtom);
private static native String GetStringUID(long jAtom);
private static native long GetUID(long jAtom);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
public class AudioTrack extends Track {
public static long parse(Segment segment, Info info, long element_start, long element_size,
AudioTrack[] audioTrack) {
long[] jAudioTrack = {0};
long result = Parse(segment.getNativePointer(), info.getNativePointer(), element_start,
element_size, jAudioTrack);
audioTrack[0] = new AudioTrack(jAudioTrack[0]);
return result;
}
public long getBitDepth() {
return GetBitDepth(nativePointer);
}
public long getChannels() {
return GetChannels(nativePointer);
}
public double getSamplingRate() {
return GetSamplingRate(nativePointer);
}
@Override
public long seek(long time_ns, BlockEntry[] result) {
long[] jResult = {0};
long output = Seek(nativePointer, time_ns, jResult);
result[0] = BlockEntry.newBlockEntry(jResult[0]);
return output;
}
protected AudioTrack(long nativePointer) {
super(nativePointer);
}
private static native long GetBitDepth(long jAudioTrack);
private static native long GetChannels(long jAudioTrack);
private static native double GetSamplingRate(long jAudioTrack);
private static native long Parse(long jSegment, long jInfo, long element_start, long element_size,
long[] jAudioTrack);
private static native long Seek(long jAudioTrack, long time_ns, long[] jResult);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Block extends Common {
public enum Lacing {
kLacingNone,
kLacingXiph,
kLacingFixed,
kLacingEbml
};
public Block() {
nativePointer = newBlock();
}
public Frame getFrame(int frameIndex) {
long pointer = GetFrame(nativePointer, frameIndex);
return new Frame(pointer);
}
public int getFrameCount() {
return GetFrameCount(nativePointer);
}
public Lacing getLacing() {
int ordinal = GetLacing(nativePointer);
return Lacing.values()[ordinal];
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public long getTime(Cluster cluster) {
return GetTime(nativePointer, cluster.getNativePointer());
}
public long getTimeCode(Cluster cluster) {
return GetTimeCode(nativePointer, cluster.getNativePointer());
}
public long getTrackNumber() {
return GetTrackNumber(nativePointer);
}
public boolean isInvisible() {
return IsInvisible(nativePointer);
}
public boolean isKey() {
return IsKey(nativePointer);
}
public long parse(Cluster cluster) {
return Parse(nativePointer, cluster.getNativePointer());
}
public void setKey(boolean key) {
SetKey(nativePointer, key);
}
protected Block(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteBlock(nativePointer);
}
private static native void deleteBlock(long jBlock);
private static native long GetFrame(long jBlock, int frameIndex);
private static native int GetFrameCount(long jBlock);
private static native int GetLacing(long jBlock);
private static native long getSize(long jBlock);
private static native long getStart(long jBlock);
private static native long GetTime(long jBlock, long jCluster);
private static native long GetTimeCode(long jBlock, long jCluster);
private static native long GetTrackNumber(long jBlock);
private static native boolean IsInvisible(long jBlock);
private static native boolean IsKey(long jBlock);
private static native long newBlock();
private static native long Parse(long jBlock, long jCluster);
private static native void SetKey(long jBlock, boolean key);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public abstract class BlockEntry extends Common {
public enum Kind {
kBlockEOS,
kBlockSimple,
kBlockGroup
};
public static BlockEntry newBlockEntry(long nativePointer) {
BlockEntry blockEntry = null;
int type = getClassType(nativePointer);
if (type == 1) {
blockEntry = new BlockGroup(nativePointer);
} else if (type == 2) {
blockEntry = new SimpleBlock(nativePointer);
}
return blockEntry;
}
public boolean eos() {
return EOS(nativePointer);
}
public abstract Block getBlock();
public Cluster getCluster() {
long pointer = GetCluster(nativePointer);
return new Cluster(pointer);
}
public long getIndex() {
return GetIndex(nativePointer);
}
public abstract Kind getKind();
protected BlockEntry() {
super();
}
protected BlockEntry(long nativePointer) {
super(nativePointer);
}
private static native boolean EOS(long jBlockEntry);
private static native int getClassType(long jBlockEntry);
private static native long GetCluster(long jBlockEntry);
private static native long GetIndex(long jBlockEntry);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
public class BlockGroup extends BlockEntry {
public BlockGroup(Cluster cluster, long index, long blockStart, long blockSize, long previous,
long next, long duration) {
nativePointer = newBlockGroup(cluster.getNativePointer(), index, blockStart, blockSize,
previous, next, duration);
}
@Override
public Block getBlock() {
long pointer = GetBlock(nativePointer);
return new Block(pointer);
}
public long getDurationTimeCode() {
return GetDurationTimeCode(nativePointer);
}
@Override
public Kind getKind() {
int ordinal = GetKind(nativePointer);
return Kind.values()[ordinal];
}
public long getNextTimeCode() {
return GetNextTimeCode(nativePointer);
}
public long getPrevTimeCode() {
return GetPrevTimeCode(nativePointer);
}
public long Parse() {
return Parse(nativePointer);
}
protected BlockGroup(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteBlockGroup(nativePointer);
}
private static native void deleteBlockGroup(long jBlockGroup);
private static native long GetBlock(long jBlockGroup);
private static native long GetDurationTimeCode(long jBlockGroup);
private static native int GetKind(long jBlockGroup);
private static native long GetNextTimeCode(long jBlockGroup);
private static native long GetPrevTimeCode(long jBlockGroup);
private static native long newBlockGroup(long jCluster, long index, long blockStart,
long blockSize, long previous, long next, long duration);
private static native long Parse(long jBlockGroup);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Chapters extends Common {
public Chapters(Segment segment, long payloadStart, long payloadSize, long elementStart,
long elementSize) {
nativePointer = newChapters(segment.getNativePointer(), payloadStart, payloadSize, elementStart,
elementSize);
}
public Edition getEdition(int index) {
long pointer = GetEdition(nativePointer, index);
return new Edition(pointer);
}
public int getEditionCount() {
return GetEditionCount(nativePointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public long parse() {
return Parse(nativePointer);
}
protected Chapters(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteChapters(nativePointer);
}
private static native void deleteChapters(long jChapters);
private static native long GetEdition(long jChapters, int index);
private static native int GetEditionCount(long jChapters);
private static native long getElementSize(long jChapters);
private static native long getElementStart(long jChapters);
private static native long getSegment(long jChapters);
private static native long getSize(long jChapters);
private static native long getStart(long jChapters);
private static native long newChapters(long jSegment, long payload_start, long payload_size,
long element_start, long element_size);
private static native long Parse(long jChapters);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Cluster extends Common {
public static Cluster create(Segment segment, long index, long offset) {
long pointer = Create(segment.getNativePointer(), index, offset);
return new Cluster(pointer);
}
public static long hasBlockEntries(Segment segment, long offset, long[] position, long[] size) {
return HasBlockEntries(segment.getNativePointer(), offset, position, size);
}
public Cluster() {
nativePointer = newCluster();
}
public boolean eos() {
return EOS(nativePointer);
}
public long getElementSize() {
return GetElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public long getEntryCount() {
return GetEntryCount(nativePointer);
}
public long getEntry(long index, BlockEntry[] blockEntry) {
long[] jBlockEntry = {0};
long result = GetEntryIndex(nativePointer, index, jBlockEntry);
blockEntry[0] = BlockEntry.newBlockEntry(jBlockEntry[0]);
return result;
}
public BlockEntry getEntry(CuePoint cuePoint, TrackPosition trackPosition) {
long pointer = GetEntryCuePoint(nativePointer, cuePoint.getNativePointer(),
trackPosition.getNativePointer());
return BlockEntry.newBlockEntry(pointer);
}
public BlockEntry getEntry(Track track, long ns) {
long pointer = GetEntryTrack(nativePointer, track.getNativePointer(), ns);
return BlockEntry.newBlockEntry(pointer);
}
public long getFirst(BlockEntry[] blockEntry) {
long[] jBlockEntry = {0};
long result = GetFirst(nativePointer, jBlockEntry);
blockEntry[0] = BlockEntry.newBlockEntry(jBlockEntry[0]);
return result;
}
public long getFirstTime() {
return GetFirstTime(nativePointer);
}
public long getLast(BlockEntry[] blockEntry) {
long[] jBlockEntry = {0};
long result = GetLast(nativePointer, jBlockEntry);
blockEntry[0] = BlockEntry.newBlockEntry(jBlockEntry[0]);
return result;
}
public long getLastTime() {
return GetLastTime(nativePointer);
}
public long getNext(BlockEntry current, BlockEntry[] next) {
long[] jNext = {0};
long result = GetNext(nativePointer, current.getNativePointer(), jNext);
next[0] = BlockEntry.newBlockEntry(jNext[0]);
return result;
}
public long getPosition() {
return GetPosition(nativePointer);
}
public long getSegment() {
return getSegment(nativePointer);
}
public long getTime() {
return GetTime(nativePointer);
}
public long getTimeCode() {
return GetTimeCode(nativePointer);
}
public long load(long[] position, long[] size) {
return Load(nativePointer, position, size);
}
public long parse(long[] position, long[] size) {
return Parse(nativePointer, position, size);
}
protected Cluster(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteCluster(nativePointer);
}
private static native long Create(long jSegment, long index, long offset);
private static native void deleteCluster(long jCluster);
private static native boolean EOS(long jCluster);
private static native long GetElementSize(long jCluster);
private static native long getElementStart(long jCluster);
private static native long GetEntryCount(long jCluster);
private static native long GetEntryCuePoint(long jCluster, long jCuePoint, long jTrackPosition);
private static native long GetEntryIndex(long jCluster, long index, long[] jBlockEntry);
private static native long GetEntryTrack(long jCluster, long jTrack, long ns);
private static native long GetFirst(long jCluster, long[] jBlockEntry);
private static native long GetFirstTime(long jCluster);
private static native long GetIndex(long jCluster);
private static native long GetLast(long jCluster, long[] jBlockEntry);
private static native long GetLastTime(long jCluster);
private static native long GetNext(long jCluster, long jCurrent, long[] jNext);
private static native long GetPosition(long jCluster);
private static native long getSegment(long jCluster);
private static native long GetTime(long jCluster);
private static native long GetTimeCode(long jCluster);
private static native long HasBlockEntries(long jSegment, long offset, long[] jPosition,
long[] jSize);
private static native long Load(long jCluster, long[] jPosition, long[] jSize);
private static native long newCluster();
private static native long Parse(long jCluster, long[] jPosition, long[] jSize);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class ContentCompression extends Common {
public ContentCompression() {
nativePointer = newContentCompression();
}
public long getAlgo() {
return getAlgo(nativePointer);
}
public void setAlgo(long algo) {
setAlgo(nativePointer, algo);
}
protected ContentCompression(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentCompression(nativePointer);
}
private static native void deleteContentCompression(long jContentCompression);
private static native long getAlgo(long jContentCompression);
private static native long newContentCompression();
private static native void setAlgo(long jContentCompression, long algo);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class ContentEncAesSettings extends Common {
public ContentEncAesSettings() {
nativePointer = newContentEncAesSettings();
}
public ContentEncoding.CipherMode getCipherMode() {
int ordinal = (int) getCipherMode(nativePointer);
return ContentEncoding.CipherMode.values()[ordinal];
}
public void setCipherMode(ContentEncoding.CipherMode cipherMode) {
setCipherMode(nativePointer, cipherMode.ordinal());
}
protected ContentEncAesSettings(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentEncAesSettings(nativePointer);
}
private static native void deleteContentEncAesSettings(long jContentEncAesSettings);
private static native long getCipherMode(long jContentEncAesSettings);
private static native long newContentEncAesSettings();
private static native void setCipherMode(long jContentEncAesSettings, long cipherMode);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class ContentEncoding extends Common {
public enum CipherMode {
None,
kCTR
};
public ContentEncoding() {
nativePointer = newContentEncoding();
}
public long encodingOrder() {
return encodingOrder(nativePointer);
}
public long encodingScope() {
return encodingScope(nativePointer);
}
public long encodingType() {
return encodingType(nativePointer);
}
public ContentCompression getCompressionByIndex(long index) {
long pointer = GetCompressionByIndex(nativePointer, index);
return new ContentCompression(pointer);
}
public long getCompressionCount() {
return GetCompressionCount(nativePointer);
}
public ContentEncryption getEncryptionByIndex(long index) {
long pointer = GetEncryptionByIndex(nativePointer, index);
return new ContentEncryption(pointer);
}
public long getEncryptionCount() {
return GetEncryptionCount(nativePointer);
}
public long parseContentEncAesSettingsEntry(long start, long size, IMkvReader mkvReader,
ContentEncAesSettings contentEncAesSettings) {
return ParseContentEncAESSettingsEntry(nativePointer, start, size, mkvReader.getNativePointer(),
contentEncAesSettings.getNativePointer());
}
public long parseContentEncodingEntry(long start, long size, IMkvReader mkvReader) {
return ParseContentEncodingEntry(nativePointer, start, size, mkvReader.getNativePointer());
}
public long parseEncryptionEntry(long start, long size, IMkvReader mkvReader,
ContentEncryption contentEncryption) {
return ParseEncryptionEntry(nativePointer, start, size, mkvReader.getNativePointer(),
contentEncryption.getNativePointer());
}
protected ContentEncoding(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentEncoding(nativePointer);
}
private static native void deleteContentEncoding(long jContentEncoding);
private static native long encodingOrder(long jContentEncoding);
private static native long encodingScope(long jContentEncoding);
private static native long encodingType(long jContentEncoding);
private static native long GetCompressionByIndex(long jContentEncoding, long idx);
private static native long GetCompressionCount(long jContentEncoding);
private static native long GetEncryptionByIndex(long jContentEncoding, long idx);
private static native long GetEncryptionCount(long jContentEncoding);
private static native long newContentEncoding();
private static native long ParseContentEncAESSettingsEntry(long jContentEncoding, long start,
long size, long jMkvReader, long jContentEncAesSettings);
private static native long ParseContentEncodingEntry(long jContentEncoding, long start, long size,
long jMkvReader);
private static native long ParseEncryptionEntry(long jContentEncoding, long start, long size,
long jMkvReader, long jContentEncryption);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class ContentEncryption extends Common {
public ContentEncryption() {
nativePointer = newContentEncrytpion();
}
public ContentEncAesSettings getAesSettings() {
long pointer = getAesSettings(nativePointer);
return new ContentEncAesSettings(pointer);
}
public long getAlgo() {
return getAlgo(nativePointer);
}
public byte[] getKeyId() {
return getKeyId(nativePointer);
}
public long getSigAlgo() {
return getSigAlgo(nativePointer);
}
public long getSigHashAlgo() {
return getSigHashAlgo(nativePointer);
}
public byte[] getSigKeyId() {
return getSigKeyId(nativePointer);
}
public byte[] getSignature() {
return getSignature(nativePointer);
}
public void setAesSettings(ContentEncAesSettings aesSettings) {
setAesSettings(nativePointer, aesSettings.getNativePointer());
}
public void setAlgo(long algo) {
setAlgo(nativePointer, algo);
}
public void setKeyId(byte[] keyId) {
setKeyId(nativePointer, keyId);
}
public void setSigAlgo(long sigAlgo) {
setSigAlgo(nativePointer, sigAlgo);
}
public void setSigHashAlgo(long sigHashAlgo) {
setSigHashAlgo(nativePointer, sigHashAlgo);
}
public void setSigKeyId(byte[] sigKeyId) {
setSigKeyId(nativePointer, sigKeyId);
}
public void setSignature(byte[] signature) {
setSignature(nativePointer, signature);
}
protected ContentEncryption(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteContentEncrytpion(nativePointer);
}
private static native void deleteContentEncrytpion(long jContentEncrytpion);
private static native long getAesSettings(long jContentEncrytpion);
private static native long getAlgo(long jContentEncrytpion);
private static native byte[] getKeyId(long jContentEncrytpion);
private static native long getSigAlgo(long jContentEncrytpion);
private static native long getSigHashAlgo(long jContentEncrytpion);
private static native byte[] getSigKeyId(long jContentEncrytpion);
private static native byte[] getSignature(long jContentEncrytpion);
private static native long newContentEncrytpion();
private static native void setAesSettings(long jContentEncrytpion, long aesSettings);
private static native void setAlgo(long jContentEncrytpion, long algo);
private static native void setKeyId(long jContentEncrytpion, byte[] jKeyId);
private static native void setSigAlgo(long jContentEncrytpion, long sigAlgo);
private static native void setSigHashAlgo(long jContentEncrytpion, long sigHashAlgo);
private static native void setSigKeyId(long jContentEncrytpion, byte[] jSigKeyId);
private static native void setSignature(long jContentEncrytpion, byte[] jSignature);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class CuePoint extends Common {
public TrackPosition find(Track track) {
long pointer = Find(nativePointer, track.getNativePointer());
return new TrackPosition(pointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public long getTime(Segment segment) {
return GetTime(nativePointer, segment.getNativePointer());
}
public long getTimeCode() {
return GetTimeCode(nativePointer);
}
public void load(IMkvReader mkvReader) {
Load(nativePointer, mkvReader.getNativePointer());
}
public void setElementSize(long elementSize) {
setElementSize(nativePointer, elementSize);
}
public void setElementStart(long elementStart) {
setElementStart(nativePointer, elementStart);
}
protected CuePoint(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native long Find(long jCuePoint, long jTrack);
private static native long getElementSize(long jCuePoint);
private static native long getElementStart(long jCuePoint);
private static native long GetTime(long jCuePoint, long jSegment);
private static native long GetTimeCode(long jCuePoint);
private static native void Load(long jCuePoint, long jMkvReader);
private static native void setElementSize(long jCuePoint, long element_size);
private static native void setElementStart(long jCuePoint, long element_start);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Cues extends Common {
public boolean doneParsing() {
return DoneParsing(nativePointer);
}
public boolean find(long timeNs, Track track, CuePoint[] cuePoint,
TrackPosition[] trackPosition) {
long[] jCuePoint = {0};
long[] jTrackPosition = {0};
boolean result =
Find(nativePointer, timeNs, track.getNativePointer(), jCuePoint, jTrackPosition);
cuePoint[0] = new CuePoint(jCuePoint[0]);
trackPosition[0] = new TrackPosition(jTrackPosition[0]);
return result;
}
public BlockEntry getBlock(CuePoint cp, TrackPosition tp) {
long pointer = GetBlock(nativePointer, cp.getNativePointer(), tp.getNativePointer());
return BlockEntry.newBlockEntry(pointer);
}
public long getCount() {
return GetCount(nativePointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public CuePoint getFirst() {
long pointer = GetFirst(nativePointer);
return new CuePoint(pointer);
}
public CuePoint getLast() {
long pointer = GetLast(nativePointer);
return new CuePoint(pointer);
}
public CuePoint getNext(CuePoint current) {
long pointer = GetNext(nativePointer, current.getNativePointer());
return new CuePoint(pointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public boolean loadCuePoint() {
return LoadCuePoint(nativePointer);
}
protected Cues(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native boolean DoneParsing(long jCues);
private static native boolean Find(long jCues, long time_ns, long jTrack, long[] jCuePoint,
long[] jTrackPosition);
private static native long GetBlock(long jCues, long jcp, long jtp);
private static native long GetCount(long jCues);
private static native long getElementSize(long jCues);
private static native long getElementStart(long jCues);
private static native long GetFirst(long jCues);
private static native long GetLast(long jCues);
private static native long GetNext(long jCues, long jCurrent);
private static native long getSegment(long jCues);
private static native long getSize(long jCues);
private static native long getStart(long jCues);
private static native boolean LoadCuePoint(long jCues);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Display extends Common {
public String getCountry() {
return GetCountry(nativePointer);
}
public String getLanguage() {
return GetLanguage(nativePointer);
}
public String getString() {
return GetString(nativePointer);
}
protected Display(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native String GetCountry(long jDisplay);
private static native String GetLanguage(long jDisplay);
private static native String GetString(long jDisplay);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class EbmlHeader extends Common {
public EbmlHeader() {
nativePointer = newEBMLHeader();
}
public String getDocType() {
return getDocType(nativePointer);
}
public long getDocTypeReadVersion() {
return getDocTypeReadVersion(nativePointer);
}
public long getDocTypeVersion() {
return getDocTypeVersion(nativePointer);
}
public long getMaxIdLength() {
return getMaxIdLength(nativePointer);
}
public long getMaxSizeLength() {
return getMaxSizeLength(nativePointer);
}
public long getReadVersion() {
return getReadVersion(nativePointer);
}
public long getVersion() {
return getVersion(nativePointer);
}
public void init() {
Init(nativePointer);
}
public long parse(IMkvReader mkvReader, long[] position) {
return Parse(nativePointer, mkvReader.getNativePointer(), position);
}
public void setDocType(String docType) {
setDocType(nativePointer, docType);
}
public void setDocTypeReadVersion(long docTypeReadVersion) {
setDocTypeReadVersion(nativePointer, docTypeReadVersion);
}
public void setDocTypeVersion(long docTypeVersion) {
setDocTypeVersion(nativePointer, docTypeVersion);
}
public void setMaxIdLength(long maxIdLength) {
setMaxIdLength(nativePointer, maxIdLength);
}
public void setMaxSizeLength(long maxSizeLength) {
setMaxSizeLength(nativePointer, maxSizeLength);
}
public void setReadVersion(long readVersion) {
setReadVersion(nativePointer, readVersion);
}
public void setVersion(long version) {
setVersion(nativePointer, version);
}
protected EbmlHeader(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteEBMLHeader(nativePointer);
}
private static native void deleteEBMLHeader(long jEbmlHeader);
private static native String getDocType(long jEbmlHeader);
private static native long getDocTypeReadVersion(long jEbmlHeader);
private static native long getDocTypeVersion(long jEbmlHeader);
private static native long getMaxIdLength(long jEbmlHeader);
private static native long getMaxSizeLength(long jEbmlHeader);
private static native long getReadVersion(long jEbmlHeader);
private static native long getVersion(long jEbmlHeader);
private static native void Init(long jEbmlHeader);
private static native long newEBMLHeader();
private static native long Parse(long jEbmlHeader, long jMkvReader, long[] jPosition);
private static native void setDocType(long jEbmlHeader, String jDocType);
private static native void setDocTypeReadVersion(long jEbmlHeader, long docTypeReadVersion);
private static native void setDocTypeVersion(long jEbmlHeader, long docTypeVersion);
private static native void setMaxIdLength(long jEbmlHeader, long maxIdLength);
private static native void setMaxSizeLength(long jEbmlHeader, long maxSizeLength);
private static native void setReadVersion(long jEbmlHeader, long readVersion);
private static native void setVersion(long jEbmlHeader, long version);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Edition extends Common {
public Atom getAtom(int index) {
long pointer = GetAtom(nativePointer, index);
return new Atom(pointer);
}
public int getAtomCount() {
return GetAtomCount(nativePointer);
}
protected Edition(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
}
private static native long GetAtom(long jEdition, int index);
private static native int GetAtomCount(long jEdition);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Entry extends Common {
public Entry() {
nativePointer = newEntry();
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public long getId() {
return getId(nativePointer);
}
public long getPos() {
return getPos(nativePointer);
}
public void setElementSize(long elementSize) {
setElementSize(nativePointer, elementSize);
}
public void setElementStart(long elementStart) {
setElementStart(nativePointer, elementStart);
}
public void setId(long id) {
setId(nativePointer, id);
}
public void setPos(long pos) {
setPos(nativePointer, pos);
}
protected Entry(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteEntry(nativePointer);
}
private static native void deleteEntry(long jEntry);
private static native long getElementSize(long jEntry);
private static native long getElementStart(long jEntry);
private static native long getId(long jEntry);
private static native long getPos(long jEntry);
private static native long newEntry();
private static native void setElementSize(long jEntry, long element_size);
private static native void setElementStart(long jEntry, long element_start);
private static native void setId(long jEntry, long id);
private static native void setPos(long jEntry, long pos);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Frame extends Common {
public Frame() {
nativePointer = newFrame();
}
public long getLen() {
return getLen(nativePointer);
}
public long getPos() {
return getPos(nativePointer);
}
public long read(IMkvReader mkvReader, byte[][] buffer) {
return Read(nativePointer, mkvReader.getNativePointer(), buffer);
}
public void setLen(long len) {
setLen(nativePointer, len);
}
public void setPos(long pos) {
setPos(nativePointer, pos);
}
protected Frame(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteFrame(nativePointer);
}
private static native void deleteFrame(long jFrame);
private static native long getLen(long jFrame);
private static native long getPos(long jFrame);
private static native long newFrame();
private static native long Read(long jFrame, long jMkvReader, byte[][] jBuffer);
private static native void setLen(long jFrame, long len);
private static native void setPos(long jFrame, long pos);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public abstract class IMkvReader extends Common {
public static IMkvReader newMkvReader(long nativePointer) {
IMkvReader mkvReader = null;
int type = getClassType(nativePointer);
if (type == 1) {
mkvReader = new MkvReader(nativePointer);
}
return mkvReader;
}
public abstract int length(long[] total, long[] available);
public abstract int read(long position, long length, byte[][] buffer);
protected IMkvReader() {
super();
}
protected IMkvReader(long nativePointer) {
super(nativePointer);
}
private static native int getClassType(long jMkvReader);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Info extends Common {
public Info() {
nativePointer = newInfo();
}
public void clear() {
Clear(nativePointer);
}
public int copy(Info destination) {
return Copy(nativePointer, destination.getNativePointer());
}
public String getCodecId() {
return getCodecId(nativePointer);
}
public String getCodecNameAsUtf8() {
return getCodecNameAsUTF8(nativePointer);
}
public byte[] getCodecPrivate() {
return getCodecPrivate(nativePointer);
}
public boolean getLacing() {
return getLacing(nativePointer);
}
public String getNameAsUtf8() {
return getNameAsUTF8(nativePointer);
}
public long getNumber() {
return getNumber(nativePointer);
}
public Settings getSettings() {
long pointer = getSettings(nativePointer);
return new Settings(pointer);
}
public long getType() {
return getType(nativePointer);
}
public void setCodecId(String codecId) {
setCodecId(nativePointer, codecId);
}
public void setCodecNameAsUtf8(String codecNameAsUtf8) {
setCodecNameAsUTF8(nativePointer, codecNameAsUtf8);
}
public void setCodecPrivate(String codecPrivate) {
setCodecPrivate(nativePointer, codecPrivate);
}
public void setLacing(boolean lacing) {
setLacing(nativePointer, lacing);
}
public void setNameAsUtf8(String nameAsUtf8) {
setNameAsUTF8(nativePointer, nameAsUtf8);
}
public void setNumber(long number) {
setNumber(nativePointer, number);
}
public void setSettings(Settings settings) {
setSettings(nativePointer, settings.getNativePointer());
}
public void setType(long type) {
setType(nativePointer, type);
}
public void setUid(long uid) {
setUid(nativePointer, uid);
}
protected Info(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteInfo(nativePointer);
}
private static native void Clear(long jInfo);
private static native int Copy(long jInfo, long jDestination);
private static native void deleteInfo(long jInfo);
private static native String getCodecId(long jInfo);
private static native String getCodecNameAsUTF8(long jInfo);
private static native byte[] getCodecPrivate(long jInfo);
private static native boolean getLacing(long jInfo);
private static native String getNameAsUTF8(long jInfo);
private static native long getNumber(long jInfo);
private static native long getSettings(long jInfo);
private static native long getType(long jInfo);
private static native long newInfo();
private static native void setCodecId(long jInfo, String jCodecId);
private static native void setCodecNameAsUTF8(long jInfo, String jCodecNameAsUtf8);
private static native void setCodecPrivate(long jInfo, String jCodecPrivate);
private static native void setLacing(long jInfo, boolean lacing);
private static native void setNameAsUTF8(long jInfo, String jNameAsUtf8);
private static native void setNumber(long jInfo, long number);
private static native void setSettings(long jInfo, long jSettings);
private static native void setType(long jInfo, long type);
private static native void setUid(long jInfo, long uid);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public abstract class MkvParser extends Common {
public static final int E_BUFFER_NOT_FULL = -3;
public static final int E_FILE_FORMAT_INVALID = -2;
public static long getUintLength(IMkvReader mkvReader, long position, long[] length) {
return GetUIntLength(mkvReader.getNativePointer(), position, length);
}
public static void getVersion(int[] major, int[] minor, int[] build, int[] revision) {
GetVersion(major, minor, build, revision);
}
public static boolean match(IMkvReader mkvReader, long[] position, long id, long[] value) {
return MatchValue(mkvReader.getNativePointer(), position, id, value);
}
public static boolean match(IMkvReader mkvReader, long[] position, long id, byte[][] buffer) {
long[] bufferLength = {0};
return MatchBuffer(mkvReader.getNativePointer(), position, id, buffer, bufferLength);
}
public static long parseElementHeader(IMkvReader mkvReader, long[] position, long stop, long[] id,
long[] size) {
return ParseElementHeader(mkvReader.getNativePointer(), position, stop, id, size);
}
public static long readUint(IMkvReader mkvReader, long position, long[] length) {
return ReadUInt(mkvReader.getNativePointer(), position, length);
}
public static long unserializeFloat(IMkvReader mkvReader, long position, long size,
double[] result) {
return UnserializeFloat(mkvReader.getNativePointer(), position, size, result);
}
public static long unserializeInt(IMkvReader mkvReader, long position, long length,
long[] result) {
return UnserializeInt(mkvReader.getNativePointer(), position, length, result);
}
public static long unserializeString(IMkvReader mkvReader, long position, long size,
String[] str) {
return UnserializeString(mkvReader.getNativePointer(), position, size, str);
}
public static long unserializeUint(IMkvReader mkvReader, long position, long size) {
return UnserializeUInt(mkvReader.getNativePointer(), position, size);
}
private static native long GetUIntLength(long jMkvReader, long position, long[] jLength);
private static native void GetVersion(int[] jMajor, int[] jMinor, int[] jBuild, int[] jRevision);
private static native boolean MatchBuffer(long jMkvReader, long[] jPosition, long id,
byte[][] jBuffer, long[] jBufferLength);
private static native boolean MatchValue(long jMkvReader, long[] jPosition, long id,
long[] jValue);
private static native long ParseElementHeader(long jMkvReader, long[] jPosition, long stop,
long[] jId, long[] jSize);
private static native long ReadUInt(long jMkvReader, long position, long[] jLength);
private static native long UnserializeFloat(long jMkvReader, long position, long size,
double[] jResult);
private static native long UnserializeInt(long jMkvReader, long position, long length,
long[] jResult);
private static native long UnserializeString(long jMkvReader, long position, long size,
String[] jStr);
private static native long UnserializeUInt(long jMkvReader, long position, long size);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
public class MkvReader extends IMkvReader {
public MkvReader() {
nativePointer = newMkvReader();
}
public void close() {
Close(nativePointer);
}
@Override
public int length(long[] total, long[] available) {
return Length(nativePointer, total, available);
}
public int open(String fileName) {
return Open(nativePointer, fileName);
}
@Override
public int read(long position, long length, byte[][] buffer) {
return Read(nativePointer, position, length, buffer);
}
protected MkvReader(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteMkvReader(nativePointer);
}
private static native void Close(long jMkvReader);
private static native void deleteMkvReader(long jMkvReader);
private static native int Length(long jMkvReader, long[] jTotal, long[] jAvailable);
private static native long newMkvReader();
private static native int Open(long jMkvReader, String jFileName);
private static native int Read(long jMkvReader, long position, long length, byte[][] jBuffer);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class SeekHead extends Common {
public SeekHead(Segment segment, long start, long size, long elementStart, long elementSize) {
nativePointer = newSeekHead(segment.getNativePointer(), start, size, elementStart, elementSize);
}
public int getCount() {
return GetCount(nativePointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public Entry getEntry(int index) {
long pointer = GetEntry(nativePointer, index);
return new Entry(pointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public VoidElement getVoidElement(int index) {
long pointer = GetVoidElement(nativePointer, index);
return new VoidElement(pointer);
}
public int getVoidElementCount() {
return GetVoidElementCount(nativePointer);
}
public long parse() {
return Parse(nativePointer);
}
protected SeekHead(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSeekHead(nativePointer);
}
private static native void deleteSeekHead(long jSeekHead);
private static native int GetCount(long jSeekHead);
private static native long getElementSize(long jSeekHead);
private static native long getElementStart(long jSeekHead);
private static native long GetEntry(long jSeekHead, int idx);
private static native long getSegment(long jSeekHead);
private static native long getSize(long jSeekHead);
private static native long getStart(long jSeekHead);
private static native long GetVoidElement(long jSeekHead, int idx);
private static native int GetVoidElementCount(long jSeekHead);
private static native long newSeekHead(long jSegment, long start, long size, long element_start,
long element_size);
private static native long Parse(long jSeekHead);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Segment extends Common {
public static long createInstance(IMkvReader mkvReader, long position, Segment[] segment) {
long[] jSegment = {0};
long result = CreateInstance(mkvReader.getNativePointer(), position, jSegment);
segment[0] = new Segment(jSegment[0]);
return result;
}
public boolean doneParsing() {
return DoneParsing(nativePointer);
}
public Cluster findCluster(long timeNanoseconds) {
long pointer = FindCluster(nativePointer, timeNanoseconds);
return new Cluster(pointer);
}
public Cluster findOrPreloadCluster(long position) {
long pointer = FindOrPreloadCluster(nativePointer, position);
return new Cluster(pointer);
}
public Chapters getChapters() {
long pointer = GetChapters(nativePointer);
return new Chapters(pointer);
}
public long getCount() {
return GetCount(nativePointer);
}
public Cues getCues() {
long pointer = GetCues(nativePointer);
return new Cues(pointer);
}
public long getDuration() {
return GetDuration(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public Cluster getEos() {
long pointer = getEos(nativePointer);
return new Cluster(pointer);
}
public Cluster getFirst() {
long pointer = GetFirst(nativePointer);
return new Cluster(pointer);
}
public SegmentInfo getInfo() {
long pointer = GetInfo(nativePointer);
return new SegmentInfo(pointer);
}
public Cluster getLast() {
long pointer = GetLast(nativePointer);
return new Cluster(pointer);
}
public Cluster getNext(Cluster current) {
long pointer = GetNext(nativePointer, current.getNativePointer());
return new Cluster(pointer);
}
public IMkvReader getReader() {
long pointer = getReader(nativePointer);
return IMkvReader.newMkvReader(pointer);
}
public SeekHead getSeekHead() {
long pointer = GetSeekHead(nativePointer);
return new SeekHead(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public Tracks getTracks() {
long pointer = GetTracks(nativePointer);
return new Tracks(pointer);
}
public long load() {
return Load(nativePointer);
}
public long loadCluster() {
return LoadClusterWithoutPosition(nativePointer);
}
public long loadCluster(long[] position, long[] size) {
return LoadClusterAndPosition(nativePointer, position, size);
}
public long parseCues(long cuesOffset, long[] position, long[] length) {
return ParseCues(nativePointer, cuesOffset, position, length);
}
public long parseHeaders() {
return ParseHeaders(nativePointer);
}
public long parseNext(Cluster current, Cluster[] next, long[] position, long[] size) {
long[] jNext = {0};
long result = ParseNext(nativePointer, current.getNativePointer(), jNext, position, size);
next[0] = new Cluster(jNext[0]);
return result;
}
public void setEos(Cluster eos) {
setEos(nativePointer, eos.getNativePointer());
}
protected Segment(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSegment(nativePointer);
}
private static native long CreateInstance(long jMkvReader, long position, long[] jSegment);
private static native void deleteSegment(long jSegment);
private static native boolean DoneParsing(long jSegment);
private static native long FindCluster(long jSegment, long time_nanoseconds);
private static native long FindOrPreloadCluster(long jSegment, long position);
private static native long GetChapters(long jSegment);
private static native long GetCount(long jSegment);
private static native long GetCues(long jSegment);
private static native long GetDuration(long jSegment);
private static native long getElementStart(long jSegment);
private static native long getEos(long jSegment);
private static native long GetFirst(long jSegment);
private static native long GetInfo(long jSegment);
private static native long GetLast(long jSegment);
private static native long GetNext(long jSegment, long jCurrent);
private static native long getReader(long jSegment);
private static native long GetSeekHead(long jSegment);
private static native long getSize(long jSegment);
private static native long getStart(long jSegment);
private static native long GetTracks(long jSegment);
private static native long Load(long jSegment);
private static native long LoadClusterAndPosition(long jSegment, long[] jPosition, long[] jSize);
private static native long LoadClusterWithoutPosition(long jSegment);
private static native long ParseCues(long jSegment, long cues_off, long[] jPosition,
long[] jLength);
private static native long ParseHeaders(long jSegment);
private static native long ParseNext(long jSegment, long jCurrent, long[] jNext, long[] jPosition,
long[] jSize);
private static native void setEos(long jSegment, long jEos);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class SegmentInfo extends Common {
public SegmentInfo(Segment segment, long start, long size, long elementStart, long elementSize) {
nativePointer =
newSegmentInfo(segment.getNativePointer(), start, size, elementStart, elementSize);
}
public long getDuration() {
return GetDuration(nativePointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public String getMuxingAppAsUtf8() {
return GetMuxingAppAsUTF8(nativePointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public long getTimeCodeScale() {
return GetTimeCodeScale(nativePointer);
}
public String getTitleAsUtf8() {
return GetTitleAsUTF8(nativePointer);
}
public String getWritingAppAsUtf8() {
return GetWritingAppAsUTF8(nativePointer);
}
public long Parse() {
return Parse(nativePointer);
}
protected SegmentInfo(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSegmentInfo(nativePointer);
}
private static native void deleteSegmentInfo(long jSegmentInfo);
private static native long GetDuration(long jSegmentInfo);
private static native long getElementSize(long jSegmentInfo);
private static native long getElementStart(long jSegmentInfo);
private static native String GetMuxingAppAsUTF8(long jSegmentInfo);
private static native long getSegment(long jSegmentInfo);
private static native long getSize(long jSegmentInfo);
private static native long getStart(long jSegmentInfo);
private static native long GetTimeCodeScale(long jSegmentInfo);
private static native String GetTitleAsUTF8(long jSegmentInfo);
private static native String GetWritingAppAsUTF8(long jSegmentInfo);
private static native long newSegmentInfo(long jSegment, long start, long size,
long element_start, long element_size);
private static native long Parse(long jSegmentInfo);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Settings extends Common {
public Settings() {
nativePointer = newSettings();
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public void setSize(long size) {
setSize(nativePointer, size);
}
public void setStart(long start) {
setStart(nativePointer, start);
}
protected Settings(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSettings(nativePointer);
}
private static native void deleteSettings(long jSettings);
private static native long getSize(long jSettings);
private static native long getStart(long jSettings);
private static native long newSettings();
private static native void setSize(long jSettings, long size);
private static native void setStart(long jSettings, long start);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
public class SimpleBlock extends BlockEntry {
public SimpleBlock(Cluster cluster, long index, long start, long size) {
nativePointer = newSimpleBlock(cluster.getNativePointer(), index, start, size);
}
@Override
public Block getBlock() {
long pointer = GetBlock(nativePointer);
return new Block(pointer);
}
@Override
public Kind getKind() {
int ordinal = GetKind(nativePointer);
return Kind.values()[ordinal];
}
public long Parse() {
return Parse(nativePointer);
}
protected SimpleBlock(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteSimpleBlock(nativePointer);
}
private static native void deleteSimpleBlock(long jSimpleBlock);
private static native long GetBlock(long jSimpleBlock);
private static native int GetKind(long jSimpleBlock);
private static native long newSimpleBlock(long jCluster, long index, long start, long size);
private static native long Parse(long jSimpleBlock);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Track extends Common {
public enum Type {
None,
kVideo,
kAudio
};
public static long create(Segment segment, Info info, long element_start, long element_size,
Track[] track) {
long[] jTrack = {0};
long result = Create(segment.getNativePointer(), info.getNativePointer(), element_start,
element_size, jTrack);
track[0] = Track.newTrack(jTrack[0]);
return result;
}
public static Track newTrack(long nativePointer) {
Track track = null;
int type = getClassType(nativePointer);
if (type == 1) {
track = new AudioTrack(nativePointer);
} else if (type == 2) {
track = new Track(nativePointer);
} else if (type == 3) {
track = new VideoTrack(nativePointer);
}
return track;
}
public String getCodecId() {
return GetCodecId(nativePointer);
}
public String getCodecNameAsUtf8() {
return GetCodecNameAsUTF8(nativePointer);
}
public byte[] getCodecPrivate(long[] size) {
return GetCodecPrivate(nativePointer, size);
}
public ContentEncoding getContentEncodingByIndex(long idx) {
long pointer = GetContentEncodingByIndex(nativePointer, idx);
return new ContentEncoding(pointer);
}
public long getContentEncodingCount() {
return GetContentEncodingCount(nativePointer);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public BlockEntry getEos() {
long pointer = GetEOS(nativePointer);
return BlockEntry.newBlockEntry(pointer);
}
public long getFirst(BlockEntry[] blockEntry) {
long[] jBlockEntry = {0};
long result = GetFirst(nativePointer, jBlockEntry);
blockEntry[0] = BlockEntry.newBlockEntry(jBlockEntry[0]);
return result;
}
public boolean getLacing() {
return GetLacing(nativePointer);
}
public String getNameAsUtf8() {
return GetNameAsUTF8(nativePointer);
}
public long getNext(BlockEntry current, BlockEntry[] next) {
long[] jNext = {0};
long result = GetNext(nativePointer, current.getNativePointer(), jNext);
next[0] = BlockEntry.newBlockEntry(jNext[0]);
return result;
}
public long getNumber() {
return GetNumber(nativePointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public Type getType() {
int ordinal = (int) GetType(nativePointer);
return Type.values()[ordinal];
}
public long getUid() {
return GetUid(nativePointer);
}
public long parseContentEncodingsEntry(long start, long size) {
return ParseContentEncodingsEntry(nativePointer, start, size);
}
public long seek(long time_ns, BlockEntry[] result) {
long[] jResult = {0};
long output = Seek(nativePointer, time_ns, jResult);
result[0] = BlockEntry.newBlockEntry(jResult[0]);
return output;
}
public boolean vetEntry(BlockEntry blockEntry) {
return VetEntry(nativePointer, blockEntry.getNativePointer());
}
protected Track(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteTrack(nativePointer);
}
private static native long Create(long jSegment, long jInfo, long element_start,
long element_size, long[] jTrack);
private static native void deleteTrack(long jTrack);
private static native int getClassType(long jTrack);
private static native String GetCodecId(long jTrack);
private static native String GetCodecNameAsUTF8(long jTrack);
private static native byte[] GetCodecPrivate(long jTrack, long[] jSize);
private static native long GetContentEncodingByIndex(long jTrack, long idx);
private static native long GetContentEncodingCount(long jTrack);
private static native long getElementSize(long jTrack);
private static native long getElementStart(long jTrack);
private static native long GetEOS(long jTrack);
private static native long GetFirst(long jTrack, long[] jBlockEntry);
private static native boolean GetLacing(long jTrack);
private static native String GetNameAsUTF8(long jTrack);
private static native long GetNext(long jTrack, long jCurrent, long[] jNext);
private static native long GetNumber(long jTrack);
private static native long getSegment(long jTrack);
private static native long GetType(long jTrack);
private static native long GetUid(long jTrack);
private static native long ParseContentEncodingsEntry(long jTrack, long start, long size);
private static native long Seek(long jTrack, long time_ns, long[] jResult);
private static native boolean VetEntry(long jTrack, long jBlockEntry);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class TrackPosition extends Common {
public TrackPosition() {
nativePointer = newTrackPosition();
}
public long getBlock() {
return getBlock(nativePointer);
}
public long getPos() {
return getPos(nativePointer);
}
public long getTrack() {
return getTrack(nativePointer);
}
public void parse(IMkvReader mkvReader, long start, long size) {
Parse(nativePointer, mkvReader.getNativePointer(), start, size);
}
public void setBlock(long block) {
setBlock(nativePointer, block);
}
public void setPos(long pos) {
setPos(nativePointer, pos);
}
public void setTrack(long track) {
setTrack(nativePointer, track);
}
protected TrackPosition(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteTrackPosition(nativePointer);
}
private static native void deleteTrackPosition(long jTrackPosition);
private static native long getBlock(long jTrackPosition);
private static native long getPos(long jTrackPosition);
private static native long getTrack(long jTrackPosition);
private static native long newTrackPosition();
private static native void Parse(long jTrackPosition, long jMkvReader, long start, long size);
private static native void setBlock(long jTrackPosition, long block);
private static native void setPos(long jTrackPosition, long pos);
private static native void setTrack(long jTrackPosition, long track);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class Tracks extends Common {
public Tracks(Segment segment, long start, long size, long element_start, long element_size) {
nativePointer = newTracks(segment.getNativePointer(), start, size, element_start, element_size);
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public Segment getSegment() {
long pointer = getSegment(nativePointer);
return new Segment(pointer);
}
public long getSize() {
return getSize(nativePointer);
}
public long getStart() {
return getStart(nativePointer);
}
public Track getTrackByIndex(long idx) {
long pointer = GetTrackByIndex(nativePointer, idx);
return Track.newTrack(pointer);
}
public Track getTrackByNumber(long tn) {
long pointer = GetTrackByNumber(nativePointer, tn);
return Track.newTrack(pointer);
}
public long getTracksCount() {
return GetTracksCount(nativePointer);
}
public long Parse() {
return Parse(nativePointer);
}
protected Tracks(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteTracks(nativePointer);
}
private static native void deleteTracks(long jTracks);
private static native long getElementSize(long jTracks);
private static native long getElementStart(long jTracks);
private static native long getSegment(long jTracks);
private static native long getSize(long jTracks);
private static native long getStart(long jTracks);
private static native long GetTrackByIndex(long jTracks, long idx);
private static native long GetTrackByNumber(long jTracks, long tn);
private static native long GetTracksCount(long jTracks);
private static native long newTracks(long jSegment, long start, long size, long element_start,
long element_size);
private static native long Parse(long jTracks);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
public class VideoTrack extends Track {
public static long parse(Segment segment, Info info, long element_start, long element_size,
VideoTrack[] videoTrack) {
long[] jVideoTrack = {0};
long result = Parse(segment.getNativePointer(), info.getNativePointer(), element_start,
element_size, jVideoTrack);
videoTrack[0] = new VideoTrack(jVideoTrack[0]);
return result;
}
public double getFrameRate() {
return GetFrameRate(nativePointer);
}
public long getHeight() {
return GetHeight(nativePointer);
}
public long getWidth() {
return GetWidth(nativePointer);
}
@Override
public long seek(long time_ns, BlockEntry[] result) {
long[] jResult = {0};
long output = Seek(nativePointer, time_ns, jResult);
result[0] = BlockEntry.newBlockEntry(jResult[0]);
return output;
}
@Override
public boolean vetEntry(BlockEntry blockEntry) {
return VetEntry(nativePointer, blockEntry.getNativePointer());
}
protected VideoTrack(long nativePointer) {
super(nativePointer);
}
private static native double GetFrameRate(long jVideoTrack);
private static native long GetHeight(long jVideoTrack);
private static native long GetWidth(long jVideoTrack);
private static native long Parse(long jSegment, long jInfo, long element_start, long element_size,
long[] jVideoTrack);
private static native long Seek(long jVideoTrack, long time_ns, long[] jResult);
private static native boolean VetEntry(long jVideoTrack, long jBlockEntry);
}
// Author: mszal@google.com (Michael Szal)
package com.google.libwebm.mkvparser;
import com.google.libwebm.Common;
public class VoidElement extends Common {
public VoidElement() {
nativePointer = newVoidElement();
}
public long getElementSize() {
return getElementSize(nativePointer);
}
public long getElementStart() {
return getElementStart(nativePointer);
}
public void setElementSize(long elementSize) {
setElementSize(nativePointer, elementSize);
}
public void setElementStart(long elementStart) {
setElementStart(nativePointer, elementStart);
}
protected VoidElement(long nativePointer) {
super(nativePointer);
}
@Override
protected void deleteObject() {
deleteVoidElement(nativePointer);
}
private static native void deleteVoidElement(long jVoidElement);
private static native long getElementSize(long jVoidElement);
private static native long getElementStart(long jVoidElement);
private static native long newVoidElement();
private static native void setElementSize(long jVoidElement, long element_size);
private static native void setElementStart(long jVoidElement, long element_start);
}
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Element.java
*
*
*/
package org.ebml;
/**
* Defines the basic EBML element. Subclasses may provide child element
* access.
* Created on November 19, 2002, 9:11 PM
* @author John Cannon
*/
public class BinaryElement extends Element {
/*private byte[] type = {
0x00};*/
private static int MIN_SIZE_LENGTH = 4;
//private long size = 0;
//protected byte[] data;
/*
* Creates a new instance of Element
@param type The type ID of this element
*/
public BinaryElement(byte[] type) {
super(type);
}
/** Getter for property data.
* @return Value of property data.
*
*/
public byte[] getData() {
return this.data;
}
/** Setter for property data.
* @param data New value of property data.
*
*/
public void setData(byte[] data) {
this.data = data;
this.size = data.length;
}
/** Getter for property size.
* @return Value of property size.
*
*/
public long getSize() {
return size;
}
/** Setter for property size.
* @param size New value of property size.
*
*/
public void setSize(long size) {
this.size = size;
}
/** Getter for property type.
* @return Value of property type.
*
*/
public byte[] getType() {
return type;
}
/** Setter for property type.
* @param type New value of property type.
*
*/
public void setType(byte[] type) {
this.type = type;
}
public byte[] toByteArray() {
byte[] head = makeEbmlCode(type, size);
byte[] ret = new byte[head.length + data.length];
org.ebml.util.ArrayCopy.arraycopy(head, 0, ret, 0, head.length);
org.ebml.util.ArrayCopy.arraycopy(data, 0, ret, head.length, data.length);
return ret;
}
public static void setMinSizeLength(int minSize) {
MIN_SIZE_LENGTH = minSize;
}
public static int getMinSizeLength() {
return MIN_SIZE_LENGTH;
}
}
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import java.util.*;
public class DateElement extends SignedIntegerElement {
//const uint64 EbmlDate::UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
public static long UnixEpochDelay = 978307200; // 2001/01/01 00:00:00 UTC
private static int MIN_SIZE_LENGTH = 8;
public DateElement(byte[] type) {
super(type);
}
/**
* Set the Date of this element
* @param value Date to set
*/
public void setDate(Date value) {
long val = (value.getTime() - UnixEpochDelay) * 1000000000;
setData(packInt(val, MIN_SIZE_LENGTH));
}
/**
* Get the Date value of this element
* @return Date of this element
*/
public Date getDate() {
/*
Date begin = new Date(0);
Date start = new Date(1970, 1, 1, 0, 0, 0);
Date end = new Date(2001, 1, 1, 0, 0, 0);
long diff0 = begin.getTime();
long diff1 = start.getTime();
long diff2 = end.getTime();
long diff3 = Date.UTC(2001, 1, 1, 0, 0, 0) - Date.UTC(1970, 1, 1, 0, 0, 0);
*/
long val = getValue();;
val = val / 1000000000 + UnixEpochDelay;
return new Date(val);
}
/**
* It's not recommended to use this method.
* Use the setDate(Date) method instead.
*/
public void setValue(long value)
{
setData(packInt(value, MIN_SIZE_LENGTH));
}
}
\ No newline at end of file
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
public interface DocType {
public ElementType getElements();
public Element createElement(ElementType type);
public Element createElement(byte [] type);
}
\ No newline at end of file
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import org.ebml.io.*;
/**
* Summary description for EBMLWriter.
*/
public class EBMLWriter
{
protected DataWriter writer;
/** Creates a new <code>EBMLReader</code> reading from the <code>DataSource
* source</code>. The <code>DocType doc</code> is used to validate the
* document.
*
* @param source DataSource to read from
* @param doc DocType to use to validate the docment
*/
public EBMLWriter(DataWriter writer)
{
this.writer = writer;
}
public long writeElement(Element elem)
{
return elem.writeHeaderData(writer) + elem.writeData(writer);
}
}
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import java.util.*;
public class ElementType {
public static short UNKNOWN_ELEMENT = 0;
public static short MASTER_ELEMENT = 1;
public static short BINARY_ELEMENT = 2;
public static short SINTEGER_ELEMENT = 3;
public static short UINTEGER_ELEMENT = 4;
public static short FLOAT_ELEMENT = 5;
public static short STRING_ELEMENT = 6;
public static short ASCII_STRING_ELEMENT = 7;
public static short DATE_ELEMENT = 8;
public static short LAST_ELEMENT_TYPE = 100;
public String name;
public short level;
public byte [] id;
public short type;
//public HashMap child;
public ArrayList<ElementType> children;
public ElementType() {
}
public ElementType(String name, short level, byte [] id, short type, ArrayList<ElementType> children) {
this.name = name;
this.level = level;
this.id = id;
this.type = type;
this.children = children;
}
public ElementType findElement(byte [] id) {
if (this.isElement(id))
return this;
if (children != null) {
for (int i = 0; i < children.size(); i++) {
ElementType entry = (ElementType)children.get(i);
if (entry.isElement(id))
return entry;
entry = entry.findElement(id);
if (entry != null)
return entry;
}
}
return null;
}
public boolean isElement(byte [] id) {
return ElementType.compareIDs(this.id, id);
}
public static boolean compareIDs(byte[] id1, byte[] id2) {
if ((id1 == null)
|| (id2 == null)
|| (id1.length != id2.length))
return false;
for (int i = 0; i < id1.length; i++) {
if (id1[i] != id2[i])
return false;
}
return true;
}
public Element createElement() {
Element elem;
if (this.type == ElementType.MASTER_ELEMENT) {
elem = new MasterElement(this.id);
} else if (this.type == ElementType.BINARY_ELEMENT) {
elem = new BinaryElement(this.id);
} else if (this.type == ElementType.STRING_ELEMENT) {
elem = new StringElement(this.id);
} else if (this.type == ElementType.ASCII_STRING_ELEMENT) {
elem = new StringElement(this.id, "US-ASCII");
} else if (this.type == ElementType.SINTEGER_ELEMENT) {
elem = new SignedIntegerElement(this.id);
} else if (this.type == ElementType.UINTEGER_ELEMENT) {
elem = new UnsignedIntegerElement(this.id);
} else if (this.type == ElementType.FLOAT_ELEMENT) {
elem = new FloatElement(this.id);
} else if (this.type == ElementType.DATE_ELEMENT) {
elem = new DateElement(this.id);
} else if (this.type == ElementType.UNKNOWN_ELEMENT) {
elem = new BinaryElement(this.id);
} else {
return null;
}
elem.setElementType(this);
return elem;
}
}
\ No newline at end of file
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import java.io.*;
public class FloatElement extends BinaryElement {
public FloatElement(byte[] type) {
super(type);
}
/**
* Set the float value of this element
* @param value Float value to set
* @throws ArithmeticException if the float value is larger than Double.MAX_VALUE
*/
public void setValue(double value) {
try {
if (value < Float.MAX_VALUE) {
ByteArrayOutputStream bIO = new ByteArrayOutputStream(4);
DataOutputStream dIO = new DataOutputStream(bIO);
dIO.writeFloat((float)value);
setData(bIO.toByteArray());
} else if (value < Double.MAX_VALUE) {
ByteArrayOutputStream bIO = new ByteArrayOutputStream(8);
DataOutputStream dIO = new DataOutputStream(bIO);
dIO.writeDouble(value);
setData(bIO.toByteArray());
} else {
throw new ArithmeticException(
"80-bit floats are not supported, BTW How did you create such a large float in Java?");
}
} catch (IOException ex) {
return;
}
}
/**
* Get the float value of this element
* @return Float value of this element
* @throws ArithmeticException for 80-bit or 10-byte floats. AFAIK Java doesn't support them
*/
public double getValue() {
try {
if (size == 4) {
float value = 0;
ByteArrayInputStream bIS = new ByteArrayInputStream(data);
DataInputStream dIS = new DataInputStream(bIS);
value = dIS.readFloat();
return value;
} else if (size == 8) {
double value = 0;
ByteArrayInputStream bIS = new ByteArrayInputStream(data);
DataInputStream dIS = new DataInputStream(bIS);
value = dIS.readDouble();
return value;
} else {
throw new ArithmeticException(
"80-bit floats are not supported");
}
} catch (IOException ex) {
return 0;
}
}
}
\ No newline at end of file
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import org.ebml.io.*;
import java.util.*;
public class MasterElement extends Element {
protected long usedSize;
protected ArrayList<Element> children = new ArrayList<Element>();
public MasterElement(byte[] type) {
super(type);
usedSize = 0;
}
public Element readNextChild(EBMLReader reader) {
if (usedSize >= this.getSize())
return null;
Element elem = reader.readNextElement();
if (elem == null)
return null;
elem.setParent(this);
usedSize += elem.getTotalSize();
return elem;
}
/* Skip the element data */
public void skipData(DataSource source) {
// Skip the child elements
source.skip(size-usedSize);
}
public long writeData(DataWriter writer)
{
long len = 0;
for (int i = 0; i < children.size(); i++)
{
Element elem = (Element)children.get(i);
len += elem.writeElement(writer);
}
return len;
}
public void addChildElement(Element elem)
{
children.add(elem);
size += elem.getTotalSize();
}
}
\ No newline at end of file
/**
* JEBML - Java library to read/write EBML/Matroska elements.
* Copyright (C) 2004 Jory Stone <jebml@jory.info>
* Based on Javatroska (C) 2002 John Cannon <spyder@matroska.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package org.ebml;
import java.util.*;
public class UnknownElementType extends ElementType {
public UnknownElementType(byte [] id) {
super("Unknown", (short)0, id, ElementType.UNKNOWN_ELEMENT, (ArrayList<ElementType>)null);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment