public static CodecToken TakePossession(Win32.AVICOMPRESSOPTIONS comprOptions) { CodecToken ret = new CodecToken(); ret.allocated = true; ret.comprOptions = comprOptions; ret.codec = Win32.decode_mmioFOURCC(comprOptions.fccHandler); return(ret); }
private static CodecToken DeSerializeFromByteArray(byte[] data) { var m = new MemoryStream(data, false); var b = new BinaryReader(m); Win32.AVICOMPRESSOPTIONS comprOptions = new Win32.AVICOMPRESSOPTIONS(); byte[] Format; byte[] Parms; try { comprOptions.fccType = b.ReadInt32(); comprOptions.fccHandler = b.ReadInt32(); comprOptions.dwKeyFrameEvery = b.ReadInt32(); comprOptions.dwQuality = b.ReadInt32(); comprOptions.dwBytesPerSecond = b.ReadInt32(); comprOptions.dwFlags = b.ReadInt32(); //comprOptions.lpFormat = b.ReadInt32(); comprOptions.cbFormat = b.ReadInt32(); //comprOptions.lpParms = b.ReadInt32(); comprOptions.cbParms = b.ReadInt32(); comprOptions.dwInterleaveEvery = b.ReadInt32(); Format = b.ReadBytes(comprOptions.cbFormat); Parms = b.ReadBytes(comprOptions.cbParms); } catch (IOException) { // ran off end of array most likely return(null); } finally { b.Close(); } var ret = new CodecToken { comprOptions = comprOptions, Format = Format, Parms = Parms, codec = Win32.decode_mmioFOURCC(comprOptions.fccHandler) }; return(ret); }
public static CodecToken CreateFromAVICOMPRESSOPTIONS(ref Win32.AVICOMPRESSOPTIONS opts) { CodecToken ret = new CodecToken(); ret.comprOptions = opts; ret.codec = Win32.decode_mmioFOURCC(opts.fccHandler); ret.Format = new byte[opts.cbFormat]; ret.Parms = new byte[opts.cbParms]; if (opts.lpFormat != IntPtr.Zero) { Marshal.Copy(opts.lpFormat, ret.Format, 0, opts.cbFormat); } if (opts.lpParms != IntPtr.Zero) { Marshal.Copy(opts.lpParms, ret.Parms, 0, opts.cbParms); } return(ret); }
static CodecToken DeSerializeFromByteArray(byte[] data) { var m = new MemoryStream(data, false); var b = new BinaryReader(m); Win32.AVICOMPRESSOPTIONS comprOptions = new Win32.AVICOMPRESSOPTIONS(); byte[] Format; byte[] Params; try { comprOptions.fccType = b.ReadInt32(); comprOptions.fccHandler = b.ReadInt32(); comprOptions.dwKeyFrameEvery = b.ReadInt32(); comprOptions.dwQuality = b.ReadInt32(); comprOptions.dwBytesPerSecond = b.ReadInt32(); comprOptions.dwFlags = b.ReadInt32(); //comprOptions.lpFormat = b.ReadInt32(); comprOptions.cbFormat = b.ReadInt32(); //comprOptions.lpParms = b.ReadInt32(); comprOptions.cbParms = b.ReadInt32(); comprOptions.dwInterleaveEvery = b.ReadInt32(); Format = b.ReadBytes(comprOptions.cbFormat); Params = b.ReadBytes(comprOptions.cbParms); } catch (IOException) { // ran off end of array most likely return(null); } finally { b.Close(); } // create unmanaged copies of Format, Params if (comprOptions.cbFormat != 0) { IntPtr lpFormat = Marshal.AllocHGlobal(comprOptions.cbFormat); Marshal.Copy(Format, 0, lpFormat, comprOptions.cbFormat); comprOptions.lpFormat = (int)lpFormat; } else { comprOptions.lpFormat = (int)IntPtr.Zero; } if (comprOptions.cbParms != 0) { IntPtr lpParms = Marshal.AllocHGlobal(comprOptions.cbParms); Marshal.Copy(Params, 0, lpParms, comprOptions.cbParms); comprOptions.lpParms = (int)lpParms; } else { comprOptions.lpParms = (int)IntPtr.Zero; } CodecToken ret = new CodecToken(); ret.marshaled = true; ret.comprOptions = comprOptions; ret.codec = Win32.decode_mmioFOURCC(comprOptions.fccHandler); return(ret); }