(Page 28 of 41 in this chapter) Version
vceRead
Description
- Reads data at the current position in the current message.
Prototype
- DWORD vceRead ( CTAHD ctahd,
BYTE *buffer,
unsigned bytes,
unsigned *bytesread)
- ctahd Handle returned by ctaCreateContext.
- buffer Pointer to a buffer to receive data.
- bytes Amount of data to read.
- bytesread Pointer to the returned number of bytes read.
Return Values
Events
Details
- This function copies the specified number of bytes of data at the current location in the current message in the context specified by ctahd to a specified buffer. It returns the number of bytes read in bytesread, unless bytesread is NULL.
- The number of bytes read will always be an integral multiple of the framesize of the current message. If you specify a buffer size that is not a multiple of the framesize, the number of bytes read will be smaller than the requested size.
- You cannot read while play or record is active.
- If you attempt to read beyond the end of the current message, SUCCESS will be returned and the current position will be set to the end of the current message.
- The current position will be advanced by the amount read in millisecond units.
- To convert between bytes and milliseconds, use vceGetContextInfo
to get the frame size and frame time, then use the following formulas:
milliseconds = (bytes / framesize) * frametime
bytes = (milliseconds / frametime) * framesize
See Also
- vceGetContextInfo
, vceWrite
Example
/* Read a message into memory */
void myLoadMessage (CTAHD ctahd, VCEHD vh, unsigned message,
BYTE **returned_address, unsigned *returned_msec,
unsigned *returned_bytes)
{
VCE_CONTEXT_INFO contextinfo;
unsigned msec;
unsigned bytes;
unsigned bytesread;
BYTE *buffer;
*returned_address = NULL;
*returned_msec = 0;
vceSetCurrentMessage (vh, message) ;
vceGetCurrentSize (ctahd, &msec) ;
if (msec == 0)
return ;
/* Convert the size from milliseconds to bytes */
vceGetContextInfo (ctahd, &contextinfo, sizeof contextinfo);
bytes = msec / contextinfo.frametime * contextinfo.framesize;
buffer = malloc(bytes) ;
vceRead (ctahd, buffer, bytes, &bytesread);
*returned_address = buffer;
*returned_msec = msec;
*returned_bytes = bytes;
return;
}
(Page 28 of 41 in this chapter) Version
Want to send us feedback on our documentation? Email: Tech_Pubs@nmss.com
Copyright © 2001, Natural MicroSystems, Inc. All rights
reserved.