Opens a stream in a multimedia file for read or write operations.
DWORD mmOpenStream ( MMFILE *pMMFile, DWORD streamID, WORD streamType, WORD codec, DATA_FORMAT_DESC *pDataFormatDesc, MMSTREAM *pMMStream, DATA_FORMAT_INFO *pDataFormatInfo)
| Argument | Description | ||||||
pMMFile |
A pointer to the object that controls the multimedia file. |
||||||
| streamID | The ID of the stream to open. For a:
|
||||||
| streamType | The type of stream to open. Valid values for streamType depend on the mode:
|
||||||
| codec | The codec of the stream to open. Valid values for codec depend on the mode.
|
||||||
| pDataFormatDesc | A pointer to the DATA_FORMAT_DESC structure that determines the format of the data, including whether it is raw or NMS packetized. A NULL value indicates that the default format (NMS_PACKETIZED) is used. The structure definition is: typedef struct For information about the fields in this structure, see DATA_FORMAT_DESC. |
||||||
| pMMStream | A pointer to the returned MMSTREAM data structure that is used to access the multimedia stream. The structure definition is: typedef struct mm_stream |
||||||
| pDataFormatInfo | An optional pointer to the DATA_FORMAT_INFO structure that provides size characteristics for the opened stream. The structure definition is: typedef struct For information about the fields in this structure, see DATA_FORMAT_INFO. |
Return value |
Description |
SUCCESS |
|
MMERR_FILE_FORMAT |
(Read mode only) Error in file format. |
MMERR_FILE_READ_FAILURE |
(Read mode only) File read failure. |
MMERR_FILE_WRITE_FAILURE |
(Write mode only) File write failure. |
MMERR_INTERNAL_RESOURCE |
Error on internal resource. |
MMERR_INVALID_FILE |
pMMFile is invalid. |
MMERR_INVALID_FORMAT_DESC |
Invalid field in format descriptor. |
MMERR_INVALID_POINTER |
pMMStream is NULL. |
MMERR_INVALID_STREAM |
Stream not found. The stream may already be opened, or may be incorrectly specified. |
MMERR_MAX_STREAM |
Maximum number of opened streams reached. |
MMERR_NO_LICENSE_AVAILABLE |
No license is available. |
None.
The mode that mmOpenStream uses to open a stream depends on how the file containing the stream was opened.
If you used mmOpenFile in read mode to open the file, then the stream is also opened in read mode.
If you used mmOpenFile in write mode to open the file, then the stream is also opened in write mode.
For a read operation, the stream can be selected by any combination of type, codec, or ID. Typically, an application selects a stream with the ID only or with the type and codec.
DWORD ret;
MMSTREAM mmStream;
DATA_FORMAT_INFO dataFormatInfo;
DATA_FORMAT_DESC dataFormatDesc;
streamID = 1;
streamType = STREAM_TYPE_VIDEO;
codec = S_CODEC_MPEG4;
dataFormatDesc. format = FORMAT_NMS_PACKETIZED;
dataFormatDesc. flags = FORMAT_FLAG_AMR_IF2;
dataFormatDesc. videoLevel = 0;
dataFormatDesc. videoProfile = 0;
ret = mmOpenStream(&mmFile, streamID, streamType, codec, &dataFormatDesc,
&mmStream, &dataFormatInfo);
if( ret != SUCCESS )
{
printf ("\nERROR in mmOpenStream for stream ID (%lu), ret=(%d)\n",
streamID, ret );
return -1;
}