Reads media data out of a stream at the current position. Only entire media samples are read. Media samples are also called frames for audio and video data.
DWORD mmReadStream ( MMSTREAM *pMMStream, unsigned sampleCount, BYTE *pBuffer, unsigned bufferSize, unsigned *pByteCount)
|
Argument |
Description |
|
pMMStream |
Returns a pointer to the object that controls the stream. |
|
sampleCount |
The number of samples to read. Specify SAMPLE_COUNT_MAX to read as many entire samples as the buffer can contain. |
|
pBuffer |
A pointer to the recipient buffer where the media data is copied. |
|
bufferSize |
The maximum size of the recipient buffer, in bytes. |
|
pByteCount |
A pointer to the actual number of bytes copied. The Video Messaging Server Interface returns this value after the end of stream is reached (return value MMERR_END_OF_STREAM). |
|
Return value |
Description |
|
SUCCESS |
|
|
MMERR_BUFFER_TOO_SMALL |
Recipient buffer is too small to receive the entire media sample. |
|
MMERR_END_OF_STREAM |
End of stream reached. Check the pByteCount value. |
|
MMERR_FILE_FORMAT |
Error in file format. |
|
MMERR_FILE_READ_FAILURE |
File read failure. |
|
MMERR_INCOMP_ACCESS_MODE |
Stream was not opened for read operation. |
|
MMERR_INVALID_POINTER |
Either pBuffer or pByteCount is null. |
|
MMERR_INVALID_STREAM |
pMMStream is invalid. |
DWORD ret;
unsigned char *pBuffer;
unsigned byteCount;
pBuffer = (unsigned char *)malloc(bufferSize);
ret = mmReadStream(&mmStream, SAMPLE_COUNT_MAX, pBuffer,
bufferSize, &byteCount);
if ((ret != SUCCESS) && (ret != MMERR_END_OF_STREAM))
{
printf("\nERROR: failed to read the stream from file. ret (%d)\n", ret);
}