How to manage media with PJMEDIA_CONF_NO_DEVICE and PJMEDIA_CONF_NO_MIC option?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am devloping an server like application, which is in demand of handling large number of calls.
I have read the performance suggestion in FAQ, it provides a solution to improving performance by managing the media ourselves.
But I cant get de media through(no voice) as following the suggestion.

To be declared, in my case, sound device and microphone is disabled,  I want to record
the up stream in buffer and put the down stream in buffer which will be played by pjsip periodicly.
so, at first I create a media conference with PJMEDIA_CONF_NO_DEVICE | PJMEDIA_CONF_NO_MIC option,
then, I create a recorder media port and a player media port, and attache them to master media port.
------------------------------------------------------------------------------------------------------------------------
void PhoneCallHandler::CallMediaInit(pjsua_call_id call_id)
{
pj_status_t status;
pj_pool_t *pool;
pool = pjsua_pool_create("mycall", 1000, 1000);
cd = PJ_POOL_ZALLOC_T(pool, struct call_data);
cd->pool = pool;

status = pjmedia_conf_create(pool, 
128, 
16000, //unsigned clock_rate,
1,     //unsigned channel_count,
16,    //unsigned samples_per_frame,
16,    //unsigned bits_per_sample,
PJMEDIA_CONF_NO_DEVICE | PJMEDIA_CONF_NO_MIC, 
&cd->conf);

//--- create player media port
status = pjmedia_mem_player_create(cd->pool, 
player_buf_, 
FRAME_SIZE,
16000, //unsigned clock_rate,
1,     //unsigned channel_count,
16,    //unsigned samples_per_frame,
16,    //unsigned bits_per_sample,
0,     //unsigned options,
&cd->dport);

status = pjmedia_mem_player_set_eof_cb(player_port, (void*)this, OnPlayerMediaEof);

//--- create recorder media port

status = pjmedia_mem_capture_create(cd->pool, 
recorder_buf_, 
FRAME_SIZE,
16000, //unsigned clock_rate,
1,     //unsigned channel_count,
16,    //unsigned samples_per_frame,
16,    //unsigned bits_per_sample,
0,     //unsigned options,
&cd->uport);

status = pjmedia_mem_capture_set_eof_cb(recorder_port, (void*)this, PhoneAccess::OnRecorderMediaEof);

status = pjmedia_master_port_create(pool, cd->uport, cd->dport, 0, &cd->m);
status = pjmedia_master_port_start(cd->m);
}

In callback of OnStreamCreated, I try to add the media port into media conference, but it failed obviously.
---------------------------------------------------------------------------------------------------------------------------------
int PhoneCallHandler::OnStreamCreated(pjmedia_stream *strm, unsigned stream_idx, pjmedia_port **p_port)
{ 
pj_status_t status;
pjmedia_conf_add_port(cd->conf, cd->pool, *p_port, NULL, &cd->conf_slot);
pjmedia_conf_add_port(cd->conf, cd->pool, cd->uport, NULL, &cd->up_slot);
pjmedia_conf_add_port(cd->conf, cd->pool, cd->dport, NULL, &cd->dn_slot);

status = pjmedia_conf_connect_port(cd->conf, cd->conf_slot, cd->up_slot, 0);

//status = pjmedia_conf_connect_port(cd->conf, cd->up_slot, cd->conf_slot, 0);

status = pjmedia_conf_connect_port(cd->conf, cd->dn_slot, cd->conf_slot, 0);

//status = pjmedia_conf_connect_port(cd->conf, cd->conf_slot, cd->dn_slot, 0);


return PJ_SUCCESS;
}

questions:
1) I cant understand "master media port" clearly, whether I must use the "master media port"?
2) master media port/memery media port/media port coming from OnStreamCreated para, what is the relationship of them?
3) How to connect these media port correctly?

Any help will be much appreciation.





ivgotcrazy at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20141014/a7f695fb/attachment.html>


[Index of Archives]     [Asterisk Users]     [Asterisk App Development]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [Linux API]
  Powered by Linux