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 int NativeOpenCallbacks(byte[] datasource, [In, Out] NativeOggVorbisFile vf, IntPtr initial, int ibytes, NativeCallbacks callbacks);
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 int NativeOpenCallbacks(byte[] datasource, [In, Out] NativeOggVorbisFile vf, IntPtr initial, int ibytes, NativeCallbacks callbacks);