public OggVorbisEncodedStream(byte[] buffer) { //this.buffer = buffer; rawStream = new MemoryStream(buffer); //Open file = new NativeOggVorbisFile(); NativeCallbacks callbacks = new NativeCallbacks(); callbacks.ReadFunction = new ReadFunctionDelegate(this.RawStreamRead); callbacks.TellFunction = new TellFunctionDelegate(this.RawStreamTell); callbacks.SeekFunction = new SeekFunctionDelegate(this.RawStreamSeek); int result = 0; if ((result = OggVorbisFile.NativeOpenCallbacks(buffer, file, IntPtr.Zero, 0, callbacks)) != 0) { throw new OggVorbisException(String.Format("Error {0} during open", result)); } //Get info info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1)); //Get lengths of the stream pcmLength = OggVorbisFile.NativeGetLength(file, -1); // -1 to entire bitstream rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream duration = OggVorbisFile.NativeGetDuration(file, -1); // -1 to entire bitstream //Update info info.Duration = duration; }
public OggVorbisFileStream(string filename) { //Open File file = new NativeOggVorbisFile(); //if (ov_open(stream.SafeFileHandle, ref vf, IntPtr.Zero,0) == 0) // fopen for Win32! if (OggVorbisFile.NativeFOpen(filename, file) != 0) { throw new OggVorbisException("Error during fopen"); } //Get info info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1)); //Get lengths of the stream pcmLength = OggVorbisFile.NativeGetLength(file, -1); // -1 to entire bitstream rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream duration = OggVorbisFile.NativeGetDuration(file, -1); // -1 to entire bitstream //Update info info.Duration = duration; }
internal static extern double NativeGetDuration([In, Out] NativeOggVorbisFile vf, int i);
internal static extern double NativeGetTime([In, Out] NativeOggVorbisFile vf);
internal static extern long NativeGetPosition([In, Out] NativeOggVorbisFile vf);
internal static extern int NativeSeekTime([In, Out] NativeOggVorbisFile vf, double pos);
internal static extern int NativeSeek([In, Out] NativeOggVorbisFile vf, long pos);
internal static extern long NativeGetRawLength([In, Out] NativeOggVorbisFile vf, int i);
internal static extern int NativeFOpen([In] string path, [In, Out] NativeOggVorbisFile vf);
internal static extern int NativeOpenCallbacks(byte[] datasource, [In, Out] NativeOggVorbisFile vf, IntPtr initial, int ibytes, NativeCallbacks callbacks);
internal static extern int NativeIsSeekable([In, Out] NativeOggVorbisFile vf);
internal static extern int NativeClear([In, Out] NativeOggVorbisFile vf);
public OggVorbisEncodedStream(byte[] buffer) { //this.buffer = buffer; rawStream = new MemoryStream(buffer); //Open file = new NativeOggVorbisFile(); NativeCallbacks callbacks = new NativeCallbacks(); callbacks.ReadFunction = new ReadFunctionDelegate(this.RawStreamRead); callbacks.TellFunction = new TellFunctionDelegate(this.RawStreamTell); callbacks.SeekFunction = new SeekFunctionDelegate(this.RawStreamSeek); int result = 0; if ((result = OggVorbisFile.NativeOpenCallbacks(buffer, file, IntPtr.Zero, 0, callbacks)) != 0) { throw new OggVorbisException(String.Format("Error {0} during open",result)); } //Get info info = new VorbisInfo(OggVorbisFile.NativeGetInfo(file, -1)); //Get lengths of the stream pcmLength = OggVorbisFile.NativeGetLength(file, -1); // -1 to entire bitstream rawLength = OggVorbisFile.NativeGetRawLength(file, -1); // -1 to entire bitstream duration = OggVorbisFile.NativeGetDuration(file, -1); // -1 to entire bitstream //Update info info.Duration = duration; }
internal static extern long NativeCrosslap([In, Out] NativeOggVorbisFile old_vf, [In, Out] NativeOggVorbisFile new_vf);
internal static unsafe extern int NativeRead([In, Out] NativeOggVorbisFile vf, byte *buffer, int length, int bigendianp, int word, int sgned, IntPtr bitstream);
internal static extern IntPtr NativeGetComment([In, Out] NativeOggVorbisFile vf, int link);