Xeno-rat
Loading...
Searching...
No Matches
NAudio.MediaFoundation.MediaFoundationTransform Class Referenceabstract

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...

Inheritance diagram for NAudio.MediaFoundation.MediaFoundationTransform:
Collaboration diagram for NAudio.MediaFoundation.MediaFoundationTransform:

Public Member Functions

 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.
 

Protected Member Functions

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.
 

Protected Attributes

readonly IWaveProvider sourceProvider
 The Source Provider.
 
readonly WaveFormat outputWaveFormat
 The Output WaveFormat.
 

Properties

WaveFormat WaveFormat [get]
 The output WaveFormat of this Media Foundation Transform.
 
- Properties inherited from NAudio.Wave.IWaveProvider

Private Member Functions

void InitializeTransformForStreaming ()
 Initializes the transform for streaming by processing specific messages and setting the initializedForStreaming flag to true.
 
 ~MediaFoundationTransform ()
 Destructor.
 
void EndStreamAndDrain ()
 Ends the stream and drains the transform.
 
void ClearOutputBuffer ()
 Clears the output buffer by resetting the count and offset to zero.
 
int ReadFromTransform ()
 Reads data from the transform and returns the length of the output buffer.
 
IMFSample ReadFromSource ()
 Reads data from the source provider and creates an IMFSample object.
 
int ReadFromOutputBuffer (byte[] buffer, int offset, int needed)
 Reads bytes from the output buffer into the provided buffer and returns the number of bytes read.
 

Static Private Member Functions

static long BytesToNsPosition (int bytes, WaveFormat waveFormat)
 Converts the given number of bytes to the corresponding position in nanoseconds based on the provided WaveFormat.
 

Private Attributes

readonly byte[] sourceBuffer
 
byte[] outputBuffer
 
int outputBufferOffset
 
int outputBufferCount
 
IMFTransform transform
 
bool disposed
 
long inputPosition
 
long outputPosition
 
bool initializedForStreaming
 

Detailed Description

An abstract base class for simplifying working with Media Foundation Transforms You need to override the method that actually creates and configures the transform.

Constructor & Destructor Documentation

◆ MediaFoundationTransform()

NAudio.MediaFoundation.MediaFoundationTransform.MediaFoundationTransform ( IWaveProvider sourceProvider,
WaveFormat outputFormat )
inline

Constructs a new MediaFoundationTransform wrapper Will read one second at a time.

Parameters
sourceProviderThe source provider for input data to the transform
outputFormatThe desired output format

◆ ~MediaFoundationTransform()

NAudio.MediaFoundation.MediaFoundationTransform.~MediaFoundationTransform ( )
inlineprivate

Destructor.

Here is the call graph for this function:

Member Function Documentation

◆ 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
bytesThe number of bytes to be converted.
waveFormatThe WaveFormat used to calculate the position.
Returns
The position in nanoseconds corresponding to the given number of bytes based on the provided WaveFormat.
Here is the caller graph for this function:

◆ ClearOutputBuffer()

void NAudio.MediaFoundation.MediaFoundationTransform.ClearOutputBuffer ( )
inlineprivate

Clears the output buffer by resetting the count and offset to zero.

Here is the caller graph for this function:

◆ 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.

Here is the caller graph for this function:

◆ Dispose() [1/2]

void NAudio.MediaFoundation.MediaFoundationTransform.Dispose ( )
inline

Disposes this Media Foundation Transform.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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
bufferThe input buffer containing the data to be processed.
offsetThe zero-based byte offset in buffer at which to begin reading.
countThe 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.

Here is the call graph for this function:

◆ 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
bufferThe buffer to which the bytes will be copied.
offsetThe zero-based byte offset in buffer at which to begin copying bytes.
neededThe 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.

Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Here is the call graph for this function:

Member Data Documentation

◆ 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

The Output WaveFormat.

◆ sourceBuffer

readonly byte [] NAudio.MediaFoundation.MediaFoundationTransform.sourceBuffer
private

◆ sourceProvider

readonly IWaveProvider NAudio.MediaFoundation.MediaFoundationTransform.sourceProvider
protected

The Source Provider.

◆ transform

IMFTransform NAudio.MediaFoundation.MediaFoundationTransform.transform
private

Property Documentation

◆ WaveFormat

WaveFormat NAudio.MediaFoundation.MediaFoundationTransform.WaveFormat
get

The output WaveFormat of this Media Foundation Transform.

Implements NAudio.Wave.IWaveProvider.


The documentation for this class was generated from the following file: