Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

i used a sample code as follows:

ISOURCEUTIL_SourceFromAStream(pMe->psu,(IAStream*)pMe->pIFile,&pMe->pISource);

md.clsData= MMD_ISOURCE;// pDatais ISource
md.pData= (void *)pMe->pISource;
md.dwSize= 0;
md.dwStructSize= sizeof(md); // Size of AEEMediaDataExstructure
md.dwCaps= 0; // What capabilities to enable. 0 means all.
md.bRaw= FALSE; // Is this Raw data? Set it to no (FALSE)
md.dwBufferSize= 0; // Internal buffer size. 0 means use default.
md.pSpec= NULL; // Valid only for raw data
md.dwSpecSize= 0; // Valid only for raw data

nErr = IMEDIA_SetMediaDataEx(pMe->pIMedia, &md,1); // Set the media source
if (SUCCESS != nErr)
return FALSE;

nErr = IMEDIA_Play(pMe->pIMedia);
if (SUCCESS != nErr)
return FALSE;

pIFile is a opened wav file

This sample code use IFile associated with a ISource to streaming

But in my simulate,i found if the wave file >32M bytes,the simulator can not play the whole file,the simulator seems can only trigger one isource_read and it reads no more than 32M bytes.

The API reference said can use ifile to streaming with imedia,but i my test,the simulator do not support it.does any one know about it?

Cound anyone please help me?
I am using SDK 3.1.5.
I see a lot of thread in this forum, it seems can using isource+imedia to streaming audio.

Cound anyone please help me?
I am using SDK 3.1.5.
I see a lot of thread in this forum, it seems can using isource+imedia to streaming audio.

To support PCM data streaming,
AEEMediaWaveSpec spec;
ZEROAT(&spec);
spec.wSize = sizeof(AEEMediaWaveSpec);
spec.clsMedia = AEECLSID_MEDIAPCM;
.... And you have fill up necessary parameters for spec
Now
AEEMediaDataEx md;
ZEROAT(&md);
md.clsData = MMD_ISOURCE;
md.dwStructSize = sizeof(AEEMediaDataEx);
md.pSpec = &spec;
md.dwSpecSize = spec.wSize;
If it is RAW data then
md.bRaw = TRUE; otherwise set to FALSE.
And then call IMEDIA_SetMediaDataEx, IMEDIA_RegisterNotify and then start playing. IMedia is highly asynchronous, be sure to check the return status.

To support PCM data streaming,
AEEMediaWaveSpec spec;
ZEROAT(&spec);
spec.wSize = sizeof(AEEMediaWaveSpec);
spec.clsMedia = AEECLSID_MEDIAPCM;
.... And you have fill up necessary parameters for spec
Now
AEEMediaDataEx md;
ZEROAT(&md);
md.clsData = MMD_ISOURCE;
md.dwStructSize = sizeof(AEEMediaDataEx);
md.pSpec = &spec;
md.dwSpecSize = spec.wSize;
If it is RAW data then
md.bRaw = TRUE; otherwise set to FALSE.
And then call IMEDIA_SetMediaDataEx, IMEDIA_RegisterNotify and then start playing. IMedia is highly asynchronous, be sure to check the return status.

I used the code in the API reference
//Set the streaming media source as "sample.wav" file saved in an application directory.
//Setup an ISource referring to "sample.wav" and set the media data using
//IMEDIA_SetMediaDataEx().
//
static void CApp_SetupSource(CMediaOAT * pme)
{
AEEMediaDataEx md;
IFileMgr * pfm;
ISourceUtil * psu;
int nErr;
// STEP #1: Create IMedia PCM object. It will be in IDLE state.
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_MEDIAPCM, (void **)&pme->m_pIMedia);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
//
// STEP #2: Create the concrete ISource object.
// Create an ISource object that is actually an IAStream object,
// which is the IFile object referring to "sample.wav".
//
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pfm))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
pme->m_pFile = IFILEMGR_OpenFile(pfm, "sample.wav", _OFM_READ);
if (!pme->m_pFile)
{
// Handle error condition
return;
}
IFILEMGR_Release(pfm);
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_SOURCEUTIL, (void**)&psu))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
nErr = ISOURCEUTIL_SourceFromAStream(psu, (IAStream *)pme->m_pFile, &pme->m_pISource);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
ISOURCEUTIL_Release(psu);
// STEP #3: Initialize ISource object in AEEMediaDataEx
md.clsData = MMD_ISOURCE; // pData is ISource
md.pData = (void *)pme->m_pISource; // ISource object
md.dwSize = 0;
md.dwStructSize = sizeof(md); // Size of AEEMediaDataEx structure
md.dwCaps = 0; // What capabilities to enable. 0 means all.
md.bRaw = FALSE; // Is this Raw data? Set it to no (FALSE)
md.dwBufferSize = 0; // Internal buffer size. 0 means use default.
md.pSpec = NULL; // Valid only for raw data
md.dwSpecSize = 0; // Valid only for raw data
// STEP #4: Set the media data. IMedia object transitions to READY state.
nErr = IMEDIA_SetMediaDataEx(pme->m_pIMedia, &md, 1);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}

but can not do imedia streaming
Your code is similar to code below:
//Set the streaming media source as "sample.raw" file saved in the application directory.
//The encoding specifications are: Linear PCM, 16kHz, 16-bit, Unsigned, Stereo.
//Setup an ISource referring to "sample.raw" and set the media data using
//IMEDIA_SetMediaDataEx().
//
static void CApp_SetupSource(CMediaOAT * pme)
{
AEEMediaWaveSpec ws;
AEEMediaDataEx md;
IFileMgr * pfm;
ISourceUtil * psu;
// STEP #1: Create IMedia PCM object. It will be in IDLE state.
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_MEDIAPCM, (void **)&pme->m_pIMedia);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
// STEP #2: Create the concrete ISource object.
// Create an ISource object that is actually an IAStream object,
// which is the IFile object referring to "sample.wav".
//
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pfm))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
pme->m_pFile = IFILEMGR_OpenFile(pfm, "sample.wav", _OFM_READ);
if (!pme->m_pFile)
{
// Handle error condition
return;
}
IFILEMGR_Release(pfm);
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_SOURCEUTIL, (void**)&psu))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
nErr = ISOURCEUTIL_SourceFromAStream(psu, (IAStream *)pme->m_pFile, &pme->m_pISource);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
ISOURCEUTIL_Release(psu);
// STEP #3: Specify the encoding information of the raw data based on the media.
// For raw PCM, use AEEMediaWaveSpec defined in AEEMediaFormats.h
MEMSET(&ws, (int)0, sizeof(ws));
ws.wSize= sizeof(ws);
ws.clsMedia= AEECLSID_MEDIAPCM;
ws.wChannels= 2;
ws.dwSamplesPerSec= 16000;
ws.wBitsPerSample= 16;
ws.bUnsigned= TRUE;
// STEP #4: Initialize ISource object in AEEMediaDataEx
// Set the encoding specifications of the raw media data.
md.clsData = MMD_ISOURCE; // pData is ISource
md.pData = (void *)pme->m_pISource; // ISource object
md.dwSize = 0;
md.dwStructSize = sizeof(md); // Size of AEEMediaDataEx structure
md.dwCaps = 0; // What capabilities to enable. 0 means all.
md.bRaw = TRUE; // Is this Raw data? Set it to yes (TRUE)
md.dwBufferSize = 0; // Internal buffer size. 0 means use default.
md.pSpec = &ws; // Raw media data encoding specifications
md.dwSpecSize = sizeof(ws); // Size, in bytes, of the specifications
// STEP #5: Set the media data. IMedia object transitions to READY state.
nErr = IMEDIA_SetMediaDataEx(pme->m_pIMedia, &md, 1);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}

But Still can not do imedia streaming in My simulator
My SDK is 3.1.5
Do u test it in your simulator?

I used the code in the API reference
//Set the streaming media source as "sample.wav" file saved in an application directory.
//Setup an ISource referring to "sample.wav" and set the media data using
//IMEDIA_SetMediaDataEx().
//
static void CApp_SetupSource(CMediaOAT * pme)
{
AEEMediaDataEx md;
IFileMgr * pfm;
ISourceUtil * psu;
int nErr;
// STEP #1: Create IMedia PCM object. It will be in IDLE state.
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_MEDIAPCM, (void **)&pme->m_pIMedia);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
//
// STEP #2: Create the concrete ISource object.
// Create an ISource object that is actually an IAStream object,
// which is the IFile object referring to "sample.wav".
//
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pfm))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
pme->m_pFile = IFILEMGR_OpenFile(pfm, "sample.wav", _OFM_READ);
if (!pme->m_pFile)
{
// Handle error condition
return;
}
IFILEMGR_Release(pfm);
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_SOURCEUTIL, (void**)&psu))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
nErr = ISOURCEUTIL_SourceFromAStream(psu, (IAStream *)pme->m_pFile, &pme->m_pISource);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
ISOURCEUTIL_Release(psu);
// STEP #3: Initialize ISource object in AEEMediaDataEx
md.clsData = MMD_ISOURCE; // pData is ISource
md.pData = (void *)pme->m_pISource; // ISource object
md.dwSize = 0;
md.dwStructSize = sizeof(md); // Size of AEEMediaDataEx structure
md.dwCaps = 0; // What capabilities to enable. 0 means all.
md.bRaw = FALSE; // Is this Raw data? Set it to no (FALSE)
md.dwBufferSize = 0; // Internal buffer size. 0 means use default.
md.pSpec = NULL; // Valid only for raw data
md.dwSpecSize = 0; // Valid only for raw data
// STEP #4: Set the media data. IMedia object transitions to READY state.
nErr = IMEDIA_SetMediaDataEx(pme->m_pIMedia, &md, 1);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}

but can not do imedia streaming
Your code is similar to code below:
//Set the streaming media source as "sample.raw" file saved in the application directory.
//The encoding specifications are: Linear PCM, 16kHz, 16-bit, Unsigned, Stereo.
//Setup an ISource referring to "sample.raw" and set the media data using
//IMEDIA_SetMediaDataEx().
//
static void CApp_SetupSource(CMediaOAT * pme)
{
AEEMediaWaveSpec ws;
AEEMediaDataEx md;
IFileMgr * pfm;
ISourceUtil * psu;
// STEP #1: Create IMedia PCM object. It will be in IDLE state.
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_MEDIAPCM, (void **)&pme->m_pIMedia);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
// STEP #2: Create the concrete ISource object.
// Create an ISource object that is actually an IAStream object,
// which is the IFile object referring to "sample.wav".
//
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_FILEMGR, (void**)&pfm))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
pme->m_pFile = IFILEMGR_OpenFile(pfm, "sample.wav", _OFM_READ);
if (!pme->m_pFile)
{
// Handle error condition
return;
}
IFILEMGR_Release(pfm);
nErr = ISHELL_CreateInstance(pme->a.m_pIShell, AEECLSID_SOURCEUTIL, (void**)&psu))
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
nErr = ISOURCEUTIL_SourceFromAStream(psu, (IAStream *)pme->m_pFile, &pme->m_pISource);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}
ISOURCEUTIL_Release(psu);
// STEP #3: Specify the encoding information of the raw data based on the media.
// For raw PCM, use AEEMediaWaveSpec defined in AEEMediaFormats.h
MEMSET(&ws, (int)0, sizeof(ws));
ws.wSize= sizeof(ws);
ws.clsMedia= AEECLSID_MEDIAPCM;
ws.wChannels= 2;
ws.dwSamplesPerSec= 16000;
ws.wBitsPerSample= 16;
ws.bUnsigned= TRUE;
// STEP #4: Initialize ISource object in AEEMediaDataEx
// Set the encoding specifications of the raw media data.
md.clsData = MMD_ISOURCE; // pData is ISource
md.pData = (void *)pme->m_pISource; // ISource object
md.dwSize = 0;
md.dwStructSize = sizeof(md); // Size of AEEMediaDataEx structure
md.dwCaps = 0; // What capabilities to enable. 0 means all.
md.bRaw = TRUE; // Is this Raw data? Set it to yes (TRUE)
md.dwBufferSize = 0; // Internal buffer size. 0 means use default.
md.pSpec = &ws; // Raw media data encoding specifications
md.dwSpecSize = sizeof(ws); // Size, in bytes, of the specifications
// STEP #5: Set the media data. IMedia object transitions to READY state.
nErr = IMEDIA_SetMediaDataEx(pme->m_pIMedia, &md, 1);
if (SUCCESS != nErr)
{
// Handle error condition
return;
}

But Still can not do imedia streaming in My simulator
My SDK is 3.1.5
Do u test it in your simulator?

Just so that we are clear, are you looking for MM_STATUS_SYNC event for sound synchronization or just want to play streaming sound with no synchronization

Just so that we are clear, are you looking for MM_STATUS_SYNC event for sound synchronization or just want to play streaming sound with no synchronization

I just want to test streaming audio function
I want the media to smoothly playback the wave file in isource streaming mode
Right now,I only received MM_STATUS_DONE and MM_STATUS_TICK_UPDATE
What do you mean by syncrization?i only have audio steam

I just want to test streaming audio function
I want the media to smoothly playback the wave file in isource streaming mode
Right now,I only received MM_STATUS_DONE and MM_STATUS_TICK_UPDATE
What do you mean by syncrization?i only have audio steam

It looks like I"m having the same problem, but instead in my case the MM_CMD_PLAY status goes from MM_STATUS_MEDIA_SPEC to MM_STATUS_ABORT without even going to MM_STATUS_TICK_UPDATE.
R

It looks like I"m having the same problem, but instead in my case the MM_CMD_PLAY status goes from MM_STATUS_MEDIA_SPEC to MM_STATUS_ABORT without even going to MM_STATUS_TICK_UPDATE.
R

hanyunfeng wrote:
This sample code use IFile associated with a ISource to streaming
But in my simulate,i found if the wave file >32M bytes,the simulator can not play the whole file,the simulator seems can only trigger one isource_read and it reads no more than 32M bytes.
The API reference said can use ifile to streaming with imedia,but i my test,the simulator do not support it.does any one know about it?
HI,hanyunfeng
I think I have the same problem as you, i'm using an ISource object to get audio data from a streaming buffer, and i implenments this ISource interface myself, when i call IMEDIA_SetMediaDataEx, it will call ISource_Read() as i know, and the parameters passed to it are a buffer point, and a buffer size which is exactly 0x02000000, that is 32M. After that, the IMedia will do nothing with my ISource interface, that means it never calls ISource_Read() again or ISource_Readable() at all. so i guess IMedia requires the ISource to buffer 32M at one time, that's why it can not play a wav file >32M.
i do not know if i have explain that clearly, if there is something wrong pls let me konw, i'll really appreciate it .

hanyunfeng wrote:
This sample code use IFile associated with a ISource to streaming
But in my simulate,i found if the wave file >32M bytes,the simulator can not play the whole file,the simulator seems can only trigger one isource_read and it reads no more than 32M bytes.
The API reference said can use ifile to streaming with imedia,but i my test,the simulator do not support it.does any one know about it?
HI,hanyunfeng
I think I have the same problem as you, i'm using an ISource object to get audio data from a streaming buffer, and i implenments this ISource interface myself, when i call IMEDIA_SetMediaDataEx, it will call ISource_Read() as i know, and the parameters passed to it are a buffer point, and a buffer size which is exactly 0x02000000, that is 32M. After that, the IMedia will do nothing with my ISource interface, that means it never calls ISource_Read() again or ISource_Readable() at all. so i guess IMedia requires the ISource to buffer 32M at one time, that's why it can not play a wav file >32M.
i do not know if i have explain that clearly, if there is something wrong pls let me konw, i'll really appreciate it .