libZPlay documentation (Win32)
ZPlay::OpenStream Method

Open memory stream.

virtual __stdcall int OpenStream(int fBuffered, int fDynamic, const void * sMemStream, unsigned int nStreamSize, TStreamFormat nFormat) = 0;
int fBuffered 
Specifies if stream is buffered stream. Value 1 specifies buffered stream. Value 0 specifies non bufferd stream. 
int fDynamic 
Specifies if stream is dynamic or static. Value 1 specifies dynamic stream. Value 0 specifies static stream. 
const void * sMemStream 
Points to a memory block with stream data. 
unsigned int nStreamSize 
Size of memory block, in bytes. 
TStreamFormat nFormat 
Stream format. This value can't be sfAutodetect. You must specify valid stream format. 
Return Values 
All OK. 
Error. To get error message read here

First block of data needs to be large enough and must contain all data to identify specified stream type. 

For sfMp3 stream format, this block of data needs to contain at least one valid mp3 frame. 

For sfOgg streamformat, this block must contain enough data to identify ogg type. 

For sfWave, this block must contain valid RIFF header. 

If this function fails, call this function again with larger block of data or with another block of data. 

For sfMp3 stream, 128 kbps at 44100 Hz you need at least 426 bytes without ID3v2 data at stream start. If input block is too small, function will fail. Then you need to send larger block. 

Buffered stream allocates internal memory for input data and class makes copy of input data. User can destroy input data because there is copy of this data in internal buffer. Class will manage this internal memory. 

If stream is not buffered, function takes only pointer to stream data. User is responsible for this data. So, user must keep this data in memory until function is done with this data. See IsStreamDataFree

If you specify dynamic stream, you can add new data into this stream with PushDataToStream function. Use OpenStream with small chunk of input data and add rest of data with PushDataToStream function later. Use SetCallbackFunc and callback mechanism to determine when class needs more data. You can't seek or use reverse mode on dynamic stream. If dynamic stream runs out of data, it waits for new data, playing is paused, wave output is still active and class is ready to continue playing when you push new data to stream with PushDataToStream

If stream is not dynamic, you can't add new data into stream. Class will use only data provided by sMemStream parameter. But this type of stream has no limitation in seek and reverse mode. When this stream runs out of data, playing is stopped.

Open memory stream of 10000 bytes as dynamic, buffered, mp3 stream. 

ZPlay C++ Class interface  

instance->OpenStream(1, 1, memory_ptr, 10000, sfMp3);


C Style interface

zplay_OpenStream(instance, 1, 1, memory_ptr, 10000, sfMp3);
Copyright (c) 2010. Zoran Cindori - All rights reserved.