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.
Inherited Members
Namespace: FFmpeg.IO
Assembly: FFmpeg.dll
Syntax
public class IOStreamContext : IOContext, IDisposable, IAVPointer<_AVIOContext>
Constructors
View SourceIOStreamContext(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 |
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 |
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 |
Properties
View SourceCanSeek
Gets a value indicating whether this I/O context supports seeking.
Declaration
public override bool CanSeek { get; }
Property Value
| Type | Description |
|---|---|
| bool |
Overrides
Remarks
If this property returns false, FFmpeg treats the stream as non-seekable.
Methods
View SourceDispose(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
View SourceFlush()
Flushes any buffered output data to the underlying destination.
Declaration
public override void Flush()
Overrides
Remarks
This method has an effect only for writable I/O contexts. For read-only contexts, calling this method typically has no effect.
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. |
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. |
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
View SourceSeek(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
View SourceWritePacket(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. |