# null

[Open topic with navigation](../../../../../CANoeDEFamily.htm#Topics/CAPLFunctions/Media/EventProcedures/CAPLfunctionOnMediaRead.md)

## CAPL Functions » Media API » OnMediaRead

### OnMediaRead

[Valid for](../../../Shared/FeatureAvailability.md): CANoe DE • CANoe4SW DE

### Function Syntax

```c
void OnMediaRead(dword sourceReaderHandle, long result, dword streamIndex, dword streamFlags, int64 timestamp, byte buffer[], dword length);
void OnMediaRead(dword sourceReaderHandle, long result, dword streamIndex, dword streamFlags, int64 timestamp, int buffer[], dword length);
void OnMediaRead(dword sourceReaderHandle, long result, dword streamIndex, dword streamFlags, int64 timestamp, long buffer[], dword length);
```

### Description

This callback is dispatched when an asynchronous read operation on a source reader completes.

### Parameters

* **sourceReaderHandle**: The source reader handle.
* **result**: The specific result code of the operation. If the operation completed successfully the value is zero. Otherwise the value is non-zero.
* **streamIndex**: The zero-based index of the stream that delivered the sample.
* **streamFlags**:
  * **SOURCE\_READERF\_ERROR (0x00000001)**: An error occurred. If you receive this flag, do not make any further calls to [SourceReader](../CAPLfunctionsMediaSouceReader.md) methods.
  * **SOURCE\_READERF\_ENDOFSTREAM (0x00000002)**: The source reader reached the end of the stream.
  * **SOURCE\_READERF\_NEWSTREAM (0x00000004)**: One or more new streams were created. Respond to this flag by doing at least one of the following:
    * Set the output types on the new streams.
    * Update the stream selection by selecting or deselecting streams.
  * **SOURCE\_READERF\_NATIVEMEDIATYPECHANGED (0x00000010)**: The native format has changed for one or more streams. The native format is the format delivered by the media source before any decoders are inserted.
  * **SOURCE\_READERF\_CURRENTMEDIATYPECHANGED (0x00000020)**: The current media has type changed for one or more streams. To get the current media type, call the source reader’s [GetMediaType](../Functions/CAPLfunctionMediaGetMediaType.md) method.
  * **MF\_SOURCE\_READERF\_STREAMTICK (0x00000100)**: There is a gap in the stream.
  * **SOURCE\_READERF\_ALLEFFECTSREMOVED (0x00000200)**: All transforms inserted by the application have been removed for a particular stream. This could be due to a dynamic format change from a source or decoder that prevents custom transforms from being used because they cannot handle the new media type.
* **buffer**: The buffer into which the data was stored.
* **length**: The length of the received data.

### Return Values

—

### Example

—

[See Also](javascript:void\(0\);)
