public unsafe AvioContext( FfmpegCalls.AvioReadData readDataCallback, FfmpegCalls.AvioSeek seekCallback, FfmpegCalls.AvioWriteData writeDataCallback) { _readDataCallback = readDataCallback; _seekCallback = seekCallback; _writeDataCallback = writeDataCallback; //make sure that the buffer won't be disposed //the buffer may change. we always have to free _context->buffer _buffer = new AvioBuffer { SuppressAvFree = true }; _context = FfmpegCalls.AvioAllocContext(_buffer, _writeDataCallback != null, IntPtr.Zero, _readDataCallback, _writeDataCallback, _seekCallback); }
internal static unsafe AVIOContext *AvioAllocContext(AvioBuffer buffer, bool writeable, IntPtr userData, AvioReadData readData, AvioWriteData writeData, AvioSeek seek) { byte *bufferPtr = (byte *)buffer.Buffer; var avioContext = ffmpeg.avio_alloc_context( bufferPtr, buffer.BufferSize, writeable ? 1 : 0, (void *)userData, readData, writeData, seek); if (avioContext == null) { throw new FfmpegException("Could not allocate avio-context.", "avio_alloc_context"); } return(avioContext); }