Show / Hide Table of Contents

Class IOStreamContext

Represents an I/O context for interacting with a .NET Stream object. This class supports reading from, writing to, and seeking within the stream.

Inheritance
object
AVIOContext
IOContext
IOStreamContext
Implements
IDisposable
IAVPointer<_AVIOContext>
Inherited Members
IOContext.InitContext(FormatContext, IOOptions, int)
IOContext.FormatContext
IOContext.Seekable
AVIOContext.SetContext(_AVIOContext**)
AVIOContext.Dispose()
AVIOContext.EOF
AVIOContext.ErrorCode
object.GetType()
object.MemberwiseClone()
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
Namespace: FFmpeg.IO
Assembly: FFmpeg.dll
Syntax
public class IOStreamContext : IOContext, IDisposable, IAVPointer<_AVIOContext>

Constructors

View Source

IOStreamContext(FormatContext, Stream, IOOptions, int)

Initializes a new instance of the IOStreamContext class.

Declaration
public IOStreamContext(FormatContext context, Stream stream, IOOptions options, int bufferSize = 32768)
Parameters
Type Name Description
FormatContext context

The FormatContext to associate with this I/O context.

Stream stream

The .NET Stream to use for I/O operations.

IOOptions options

The I/O operations to support (reading, writing, seeking).

int bufferSize

The size of the buffer to allocate for I/O operations. Defaults to 32,768 bytes.

Exceptions
Type Condition
ArgumentNullException

Thrown when the stream is null.

View Source

IOStreamContext(Stream)

Initializes a new instance of the IOStreamContext class using the specified stream.

Declaration
public IOStreamContext(Stream stream)
Parameters
Type Name Description
Stream stream

The .NET Stream to use for I/O operations.

Remarks

The underlying stream is disposed when this IOStreamContext is disposed.

Exceptions
Type Condition
ArgumentNullException

Thrown when stream is null.

View Source

IOStreamContext(Stream, bool)

Initializes a new instance of the IOStreamContext class using the specified stream.

Declaration
public IOStreamContext(Stream stream, bool closeStreamOnDispose)
Parameters
Type Name Description
Stream stream

The .NET Stream to use for I/O operations.

bool closeStreamOnDispose

true to dispose the underlying stream when this IOStreamContext is disposed; otherwise, false.

Exceptions
Type Condition
ArgumentNullException

Thrown when stream is null.

Properties

View Source

CanSeek

Gets a value indicating whether this I/O context supports seeking.

Declaration
public override bool CanSeek { get; }
Property Value
Type Description
bool
Overrides
IOContext.CanSeek
Remarks

If this property returns false, FFmpeg treats the stream as non-seekable.

Methods

View Source

Dispose(bool)

Releases the resources used by this instance of IOStreamContext.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

Indicates whether to release both managed and unmanaged resources.

Overrides
IOContext.Dispose(bool)
View Source

Flush()

Flushes any buffered output data to the underlying destination.

Declaration
public override void Flush()
Overrides
AVIOContext.Flush()
Remarks

This method has an effect only for writable I/O contexts. For read-only contexts, calling this method typically has no effect.

View Source

OpenRead(FormatContext, Stream, int)

Creates an IOStreamContext for reading from the specified stream.

Declaration
public static IOStreamContext OpenRead(FormatContext context, Stream stream, int bufferSize = 32768)
Parameters
Type Name Description
FormatContext context

The FormatContext to associate with this I/O context.

Stream stream

The stream to read from.

int bufferSize

The size of the buffer to allocate for I/O operations. Defaults to 32,768 bytes.

Returns
Type Description
IOStreamContext

A new IOStreamContext instance configured for reading.

View Source

OpenWrite(FormatContext, Stream, int)

Creates an IOStreamContext for writing to the specified stream.

Declaration
public static IOStreamContext OpenWrite(FormatContext context, Stream stream, int bufferSize = 32768)
Parameters
Type Name Description
FormatContext context

The FormatContext to associate with this I/O context.

Stream stream

The stream to write to.

int bufferSize

The size of the buffer to allocate for I/O operations. Defaults to 32,768 bytes.

Returns
Type Description
IOStreamContext

A new IOStreamContext instance configured for writing.

View Source

ReadPacket(Span<byte>)

Reads data from the stream into the provided buffer.

Declaration
protected override AVResult32 ReadPacket(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer

The buffer to read data into.

Returns
Type Description
AVResult32

The number of bytes read. Returns a non-negative value on success.

Overrides
IOContext.ReadPacket(Span<byte>)
View Source

Seek(long, AVSeek)

Seeks to the specified offset in the stream.

Declaration
protected override AVResult64 Seek(long offset, AVSeek whence)
Parameters
Type Name Description
long offset

The offset to seek to.

AVSeek whence

The seek mode (e.g., from the start, current position, etc.).

Returns
Type Description
AVResult64

The new position within the stream. Returns a non-negative value on success.

Overrides
IOContext.Seek(long, AVSeek)
View Source

WritePacket(Span<byte>)

Writes data from the provided buffer into the stream.

Declaration
protected override AVResult32 WritePacket(Span<byte> buffer)
Parameters
Type Name Description
Span<byte> buffer

The buffer containing the data to write.

Returns
Type Description
AVResult32

The number of bytes written. Returns a non-negative value on success.

Overrides
IOContext.WritePacket(Span<byte>)

Implements

IDisposable
IAVPointer<T>
  • View Source
In this article
Back to top Generated by DocFX