pj_status_t stream_to_call(pjsua_call_id call_id)
{
pj_caching_pool cp;
pjmedia_endpt *med_endpt;
pj_pool_t *pool;
pjmedia_port *file_port;
pjmedia_snd_port *snd_port;
char tmp[10];
pj_status_t status;
pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);
status = pjmedia_endpt_create(&cp.factory, NULL, 1, &med_endpt);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
Sleep(100);
/* Create memory pool for our file player */
pool = pj_pool_create( &cp.factory, /* pool factory */
"wav", /* pool name. */
4000, /* init size */
4000, /* increment size */
NULL /* callback on error */
);
/* Create file media port from the WAV file */
status = pjmedia_wav_player_port_create( pool, /* memory pool */
"C:/waves/16bit/test55.wav", /* file to play */
20, /* ptime. WAS 20 */
0, /* flags */
0, /* default buffer */
&file_port/* returned port */
);
if (status != PJ_SUCCESS)
{
app_perror(THIS_FILE, "Unable to use WAV file", status);
return 1;
}
status = pjmedia_snd_port_create_player(
pool,
-1,
file_port->info.clock_rate, /* clock rate. */
file_port->info.channel_count, /* # of channels. */
file_port->info.samples_per_frame, /* samples per frame. */
file_port->info.bits_per_sample, /* bits per sample. */
0, /* options */
&snd_port /* returned port */
);
if (status != PJ_SUCCESS) {
app_perror(THIS_FILE, "Unable to open sound device", status);
return 1;
}
/* Connect file port to the sound player.
/* Stream playing will commence immediately.
*/
status = pjmedia_snd_port_connect( snd_port, file_port);
PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
}
|