An abstract base class for simplifying working with Media Foundation Transforms You need to override the method that actually creates and configures the transform.
More...
|
| MediaFoundationTransform (IWaveProvider sourceProvider, WaveFormat outputFormat) |
| Constructs a new MediaFoundationTransform wrapper Will read one second at a time.
|
|
void | Dispose () |
| Disposes this Media Foundation Transform.
|
|
int | Read (byte[] buffer, int offset, int count) |
| Reads data from the input buffer and processes it using the transform, returning the number of bytes written to the output buffer.
|
|
void | Reposition () |
| Repositions the object for streaming if it is initialized for streaming, by ending the stream and draining, clearing the output buffer, and reinitializing the transform for streaming.
|
|
|
IMFTransform | CreateTransform () |
| Creates and returns a new IMFTransform object.
|
|
virtual void | Dispose (bool disposing) |
| Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
|
|
|
static long | BytesToNsPosition (int bytes, WaveFormat waveFormat) |
| Converts the given number of bytes to the corresponding position in nanoseconds based on the provided WaveFormat.
|
|
An abstract base class for simplifying working with Media Foundation Transforms You need to override the method that actually creates and configures the transform.
◆ MediaFoundationTransform()
NAudio.MediaFoundation.MediaFoundationTransform.MediaFoundationTransform |
( |
IWaveProvider | sourceProvider, |
|
|
WaveFormat | outputFormat ) |
|
inline |
Constructs a new MediaFoundationTransform wrapper Will read one second at a time.
- Parameters
-
sourceProvider | The source provider for input data to the transform |
outputFormat | The desired output format |
◆ ~MediaFoundationTransform()
NAudio.MediaFoundation.MediaFoundationTransform.~MediaFoundationTransform |
( |
| ) |
|
|
inlineprivate |
◆ BytesToNsPosition()
static long NAudio.MediaFoundation.MediaFoundationTransform.BytesToNsPosition |
( |
int | bytes, |
|
|
WaveFormat | waveFormat ) |
|
inlinestaticprivate |
Converts the given number of bytes to the corresponding position in nanoseconds based on the provided WaveFormat.
- Parameters
-
bytes | The number of bytes to be converted. |
waveFormat | The WaveFormat used to calculate the position. |
- Returns
- The position in nanoseconds corresponding to the given number of bytes based on the provided WaveFormat.
◆ ClearOutputBuffer()
void NAudio.MediaFoundation.MediaFoundationTransform.ClearOutputBuffer |
( |
| ) |
|
|
inlineprivate |
Clears the output buffer by resetting the count and offset to zero.
◆ CreateTransform()
IMFTransform NAudio.MediaFoundation.MediaFoundationTransform.CreateTransform |
( |
| ) |
|
|
abstractprotected |
Creates and returns a new IMFTransform object.
This method is an abstract method that must be implemented by derived classes. It is used to create and return a new IMFTransform object, which represents a Media Foundation transform (MFT). An MFT is a COM object that performs media processing operations, such as decoding, encoding, or processing audio and video data.
◆ Dispose() [1/2]
void NAudio.MediaFoundation.MediaFoundationTransform.Dispose |
( |
| ) |
|
|
inline |
Disposes this Media Foundation Transform.
◆ Dispose() [2/2]
virtual void NAudio.MediaFoundation.MediaFoundationTransform.Dispose |
( |
bool | disposing | ) |
|
|
inlineprotectedvirtual |
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
This method is called by the public Dispose method and the Finalize method. Dispose(bool disposing) executes in two distinct scenarios. If disposing equals true, the method has been called directly or indirectly by a user's code. Managed and unmanaged resources can be disposed. If disposing equals false, the method has been called by the runtime from inside the finalizer and you should not reference other objects. Only unmanaged resources can be disposed.
Reimplemented in NAudio.Wave.MediaFoundationResampler.
◆ EndStreamAndDrain()
void NAudio.MediaFoundation.MediaFoundationTransform.EndStreamAndDrain |
( |
| ) |
|
|
inlineprivate |
Ends the stream and drains the transform.
This method sends a message to the transform to notify the end of the stream and then drains the transform by sending a command message. It then reads from the transform until no more data is available, resetting the input and output positions as well as notifying the end of streaming.
◆ InitializeTransformForStreaming()
void NAudio.MediaFoundation.MediaFoundationTransform.InitializeTransformForStreaming |
( |
| ) |
|
|
inlineprivate |
Initializes the transform for streaming by processing specific messages and setting the initializedForStreaming flag to true.
This method processes the MFT_MESSAGE_COMMAND_FLUSH, MFT_MESSAGE_NOTIFY_BEGIN_STREAMING, and MFT_MESSAGE_NOTIFY_START_OF_STREAM messages using the transform object. After processing the messages, it sets the initializedForStreaming flag to true, indicating that the transform is initialized for streaming.
◆ Read()
int NAudio.MediaFoundation.MediaFoundationTransform.Read |
( |
byte[] | buffer, |
|
|
int | offset, |
|
|
int | count ) |
|
inline |
Reads data from the input buffer and processes it using the transform, returning the number of bytes written to the output buffer.
- Parameters
-
buffer | The input buffer containing the data to be processed. |
offset | The zero-based byte offset in buffer at which to begin reading. |
count | The maximum number of bytes to read from buffer . |
- Returns
- The total number of bytes written to the output buffer.
This method reads data from the input buffer and processes it using the transform. It ensures that the transform is initialized for streaming and then continuously reads data from the source, processes it using the transform, and writes the processed data to the output buffer until the specified count is reached. If there are any leftover bytes from the previous read, they are first written to the output buffer. If the end of the input is reached, the method ends the stream, drains any remaining data from the transform, and clears the output buffer. The method then returns the total number of bytes written to the output buffer.
Implements NAudio.Wave.IWaveProvider.
◆ ReadFromOutputBuffer()
int NAudio.MediaFoundation.MediaFoundationTransform.ReadFromOutputBuffer |
( |
byte[] | buffer, |
|
|
int | offset, |
|
|
int | needed ) |
|
inlineprivate |
Reads bytes from the output buffer into the provided buffer and returns the number of bytes read.
- Parameters
-
buffer | The buffer to which the bytes will be copied. |
offset | The zero-based byte offset in buffer at which to begin copying bytes. |
needed | The maximum number of bytes to read from the output buffer. |
- Returns
- The actual number of bytes read from the output buffer and copied into buffer .
This method reads a maximum of needed bytes from the output buffer into the provided buffer . If the output buffer contains fewer bytes than needed, it reads all available bytes. The method then updates the output buffer offset and count accordingly.
◆ ReadFromSource()
IMFSample NAudio.MediaFoundation.MediaFoundationTransform.ReadFromSource |
( |
| ) |
|
|
inlineprivate |
Reads data from the source provider and creates an IMFSample object.
- Returns
- An IMFSample object containing the data read from the source provider.
This method reads a full second of data from the source provider and creates an IMFSample object. It locks the media buffer, copies the source data into it, unlocks the media buffer, and sets its current length. Then it creates a sample, adds the media buffer to it, sets the sample time and duration, and returns the sample.
◆ ReadFromTransform()
int NAudio.MediaFoundation.MediaFoundationTransform.ReadFromTransform |
( |
| ) |
|
|
inlineprivate |
Reads data from the transform and returns the length of the output buffer.
- Returns
- The length of the output buffer.
This method reads data from the transform and returns the length of the output buffer. It creates a sample and memory buffer using MediaFoundationApi, processes the output, and handles exceptions accordingly.
◆ Reposition()
void NAudio.MediaFoundation.MediaFoundationTransform.Reposition |
( |
| ) |
|
|
inline |
Repositions the object for streaming if it is initialized for streaming, by ending the stream and draining, clearing the output buffer, and reinitializing the transform for streaming.
This method checks if the object is initialized for streaming. If it is, it ends the stream and drains any remaining data, clears the output buffer, and reinitializes the transform for streaming.
◆ disposed
bool NAudio.MediaFoundation.MediaFoundationTransform.disposed |
|
private |
◆ initializedForStreaming
bool NAudio.MediaFoundation.MediaFoundationTransform.initializedForStreaming |
|
private |
◆ inputPosition
long NAudio.MediaFoundation.MediaFoundationTransform.inputPosition |
|
private |
◆ outputBuffer
byte [] NAudio.MediaFoundation.MediaFoundationTransform.outputBuffer |
|
private |
◆ outputBufferCount
int NAudio.MediaFoundation.MediaFoundationTransform.outputBufferCount |
|
private |
◆ outputBufferOffset
int NAudio.MediaFoundation.MediaFoundationTransform.outputBufferOffset |
|
private |
◆ outputPosition
long NAudio.MediaFoundation.MediaFoundationTransform.outputPosition |
|
private |
◆ outputWaveFormat
readonly WaveFormat NAudio.MediaFoundation.MediaFoundationTransform.outputWaveFormat |
|
protected |
◆ sourceBuffer
readonly byte [] NAudio.MediaFoundation.MediaFoundationTransform.sourceBuffer |
|
private |
◆ sourceProvider
readonly IWaveProvider NAudio.MediaFoundation.MediaFoundationTransform.sourceProvider |
|
protected |
◆ transform
IMFTransform NAudio.MediaFoundation.MediaFoundationTransform.transform |
|
private |
◆ WaveFormat
WaveFormat NAudio.MediaFoundation.MediaFoundationTransform.WaveFormat |
|
get |
The documentation for this class was generated from the following file: