public static int IMOS_XP_OpenInputStream(int port, byte[] header, uint bufPoolSize = 2 * 1024 * 1024) { int size = 0; IntPtr ptr = IntPtr.Zero; if (header != null) { size = header.Length; ptr = Marshal.AllocHGlobal(size); Marshal.Copy(header, 0, ptr, size); } int ret = 0; if (_isX64) { ret = Native64.IMOS_XP_OpenInputStream((uint)port, ptr, (uint)size, bufPoolSize); } else { ret = Native32.IMOS_XP_OpenInputStream((uint)port, ptr, (uint)size, bufPoolSize); } if (ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } return(ret); }
public static int IMOS_XP_InputMediaData(int port, byte[] data) { int size = 0; IntPtr ptr = IntPtr.Zero; if (data != null) { size = data.Length; ptr = Marshal.AllocHGlobal(size); Marshal.Copy(data, 0, ptr, size); } int ret = 0; if (_isX64) { ret = Native64.IMOS_XP_InputMediaData((uint)port, ptr, (uint)size); } else { ret = Native32.IMOS_XP_InputMediaData((uint)port, ptr, (uint)size); } if (ptr != IntPtr.Zero) { Marshal.FreeHGlobal(ptr); } return(ret); }
public static int IMOS_XP_SetDecodeVideoMediaDataCB(int port, DecodeVideoDataCallback onDecodeVideoData, bool bContinue) { _decVideoCallbacks[port] = onDecodeVideoData; if (onDecodeVideoData != null) { IntPtr userParam = Marshal.GetFunctionPointerForDelegate(onDecodeVideoData); if (_isX64) { return(Native64.IMOS_XP_SetDecodeVideoMediaDataCB((uint)port, _onDecVideoData, bContinue, userParam)); } else { return(Native32.IMOS_XP_SetDecodeVideoMediaDataCB((uint)port, _onDecVideoData, bContinue, userParam)); } } else { if (_isX64) { return(Native64.IMOS_XP_SetDecodeVideoMediaDataCB((uint)port, null, bContinue, IntPtr.Zero)); } else { return(Native32.IMOS_XP_SetDecodeVideoMediaDataCB((uint)port, null, bContinue, IntPtr.Zero)); } } }
public static int Decompress(byte[] inbuf, uint inlen, byte[] outbuf, ref uint outlen) { if (_Is64Bit == true) { return(Native64.NativeDecompress(inbuf, inlen, outbuf, ref outlen)); } return(Native32.NativeDecompress(inbuf, inlen, outbuf, ref outlen)); }
public static int IMOS_XP_SetDecoderTag(int port, string decoderTag) { if (_isX64) { return(Native64.IMOS_XP_SetDecoderTag((uint)port, decoderTag)); } else { return(Native32.IMOS_XP_SetDecoderTag((uint)port, decoderTag)); } }
public static int IMOS_XP_CloseInputStream(int port) { if (_isX64) { return(Native64.IMOS_XP_CloseInputStream((uint)port)); } else { return(Native32.IMOS_XP_CloseInputStream((uint)port)); } }
public static void IMOS_XP_Cleanup() { if (_isX64) { Native64.IMOS_XP_Cleanup(); } else { Native32.IMOS_XP_Cleanup(); } }
public static int IMOS_XP_Init() { if (_isX64) { return(Native64.IMOS_XP_Init()); } else { return(Native32.IMOS_XP_Init()); } }
public static int IMOS_XP_StopPlay(int port) { if (_isX64) { return(Native64.IMOS_XP_StopPlay((uint)port)); } else { return(Native32.IMOS_XP_StopPlay((uint)port)); } }
public static int IMOS_XP_SetPlayWnd(int port, IntPtr handle) { if (_isX64) { return(Native64.IMOS_XP_SetPlayWnd((uint)port, handle)); } else { return(Native32.IMOS_XP_SetPlayWnd((uint)port, handle)); } }
private static void CallDecompressImage(byte[] rgba, int width, int height, byte[] blocks, int flags) { if (Is64Bit() == true) { Native64.DecompressImage(rgba, width, height, blocks, flags); } else { Native32.DecompressImage(rgba, width, height, blocks, flags); } }
public static int Compress(byte[] inbuf, uint inlen, byte[] outbuf, ref uint outlen) { lock (CompressWork) { if (_Is64Bit == true) { return(Native64.NativeCompress(inbuf, inlen, outbuf, ref outlen, CompressWork)); } return(Native32.NativeCompress(inbuf, inlen, outbuf, ref outlen, CompressWork)); } }
public static ErrorCode Compress( byte[] dest, ref uint destLen, byte[] src, uint srcLen, byte[] outProps, ref uint outPropsSize, int level, uint dictSize, int lc, int lp, int pb, int fb, int numThreads) { if (Is64Bit == true) { return((ErrorCode)Native64.CompressInternal( dest, ref destLen, src, srcLen, outProps, ref outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads)); } return((ErrorCode)Native32.CompressInternal( dest, ref destLen, src, srcLen, outProps, ref outPropsSize, level, dictSize, lc, lp, pb, fb, numThreads)); }
public static ErrorCode Decompress( byte[] dest, ref uint destLen, byte[] src, ref uint srcLen, byte[] props, uint propsSize) { if (Is64Bit == true) { return((ErrorCode)Native64.DecompressInternal( dest, ref destLen, src, ref srcLen, props, propsSize)); } return((ErrorCode)Native32.DecompressInternal( dest, ref destLen, src, ref srcLen, props, propsSize)); }
public static ErrorCode Compress(byte[] inputBytes, int inputOffset, int inputCount, byte[] outputBytes, int outputOffset, ref int outputCount) { if (inputBytes == null) { throw new ArgumentNullException("inputBytes"); } if (inputOffset < 0 || inputOffset > inputBytes.Length) { throw new ArgumentOutOfRangeException("inputOffset"); } if (inputCount <= 0 || inputOffset + inputCount > inputBytes.Length) { throw new ArgumentOutOfRangeException("inputCount"); } if (outputBytes == null) { throw new ArgumentNullException("outputBytes"); } if (outputOffset < 0 || outputOffset > outputBytes.Length) { throw new ArgumentOutOfRangeException("outputOffset"); } if (outputCount <= 0 || outputOffset + outputCount > outputBytes.Length) { throw new ArgumentOutOfRangeException("outputCount"); } var outputHandle = GCHandle.Alloc(outputBytes, GCHandleType.Pinned); var inputHandle = GCHandle.Alloc(inputBytes, GCHandleType.Pinned); ErrorCode result; lock (_CompressWork) { if (_Is64Bit == true) { result = Native64.NativeCompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref outputCount, _CompressWork); } else { result = Native32.NativeCompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref outputCount, _CompressWork); } } return(result); }
public static ErrorCode Decompress(byte[] inputBytes, int inputOffset, int inputCount, byte[] outputBytes, int outputOffset, ref int outputCount) { if (inputBytes == null) { throw new ArgumentNullException("inputBytes"); } if (inputOffset < 0 || inputOffset >= inputBytes.Length) { throw new ArgumentOutOfRangeException("inputOffset"); } if (inputCount <= 0 || inputOffset + inputCount > inputBytes.Length) { throw new ArgumentOutOfRangeException("inputCount"); } if (outputBytes == null) { throw new ArgumentNullException("outputBytes"); } if (outputOffset < 0 || outputOffset >= outputBytes.Length) { throw new ArgumentOutOfRangeException("outputOffset"); } if (outputCount <= 0 || outputOffset + outputCount > outputBytes.Length) { throw new ArgumentOutOfRangeException("outputCount"); } var outputHandle = GCHandle.Alloc(outputBytes, GCHandleType.Pinned); var inputHandle = GCHandle.Alloc(inputBytes, GCHandleType.Pinned); ErrorCode result; if (_Is64Bit == true) { long dummy = outputCount; result = (ErrorCode)Native64.NativeDecompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref dummy); if (dummy < 0 || dummy > outputCount) { throw new InvalidOperationException("strange output count"); } outputCount = (int)dummy; } else { result = (ErrorCode)Native32.NativeDecompress(inputHandle.AddrOfPinnedObject() + inputOffset, inputCount, outputHandle.AddrOfPinnedObject() + outputOffset, ref outputCount); } inputHandle.Free(); outputHandle.Free(); return(result); }