Thursday, 15 September 2011

rtp - How to send rtcp bye message using Java Media Framework (JMF)? -



rtp - How to send rtcp bye message using Java Media Framework (JMF)? -

i using java application set sip session nuance speech server using jain sip java api. prepared scheme recognition setting sending mrcp commands get_params, set-params, define grammar & recognize using mrcp4j api.

then used jmf api set rtp & rtcp session speech server send sound recognition. server has received sound won't recognize until has received rtcp bye.

but problem not able end rtp session using rtcp bye not able figure out method in jmf documentation.

it helpful if guide me on that. have attached code rtp session.

link jmf api documentation here

// send sound info // create rtp manager rtpmanager rtpmanager = rtpmanager.newinstance(); // create local endpoint local interface on local port int port = integer.parseint(rtpport);; sessionaddress localaddress = new sessionaddress(); inetaddress ip = inetaddress.getbyname("hydhtc284704d"); localaddress.setcontrolhostaddress(ip); localaddress.setcontrolport(24501); localaddress.setdatahostaddress(ip); localaddress.setdataport(24500); // initialize rtpmanager rtpmanager.initialize(localaddress); //rtpmanager.initialize(rtpconnector); // specify remote endpoint of unicast session inetaddress ipaddress = inetaddress.getbyname("hydhtc227033d"); sessionaddress remoteaddress = new sessionaddress(ipaddress, port, ipaddress, port + 1); //system.out.println(remoteaddress); // open connection rtpmanager.addtarget(remoteaddress); rtpmanager.addsendstreamlistener(new sendstreamlistener() { @override public void update(sendstreamevent arg0) { //system.out.println("send stream event: " + arg0.getsource()); system.out.println("number of bytes transmitted: " + arg0.getsendstream().getsourcetransmissionstats().getbytestransmitted()); system.out.println("sender report: " + arg0.getsendstream().getsenderreport()); } }); rtpmanager.addreceivestreamlistener(new receivestreamlistener() { @override public void update(receivestreamevent arg0) { // todo auto-generated method stub } }); file audiofile = new file("c:\\users\\bhanu_verma\\desktop\\eclipse\\one.wav"); processor processor= manager.createprocessor(audiofile.touri().tourl()); processor.configure(); // block until processor has been configured while (processor.getstate() != processor.configured) { } processor.setcontentdescriptor(new contentdescriptor(contentdescriptor.raw_rtp)); trackcontrol track[] = processor.gettrackcontrols(); //contentdescriptor cd = new contentdescriptor(contentdescriptor.raw_rtp); //processor.setcontentdescriptor(cd); boolean encodingok = false; // go through tracks , seek programme 1 of them // output ulaw data. (int = 0; < track.length; i++) { if (!encodingok && track[i] instanceof formatcontrol) { if (((formatcontrol)track[i]).setformat(new audioformat(audioformat.ulaw_rtp,8000,8,1)) == null) { track[i].setenabled(false); } else { encodingok = true; } } else { // not set track ulaw, disable track[i].setenabled(false); } } // @ point, have determined can send out ulaw info or not. // realize processor if (encodingok) { processor.realize(); // block until realized. while (processor.getstate() != processor.realized) { } // output datasource of processor , exit if fail datasource dataoutput = processor.getdataoutput(); // create send stream output info source of processor , start sendstream sendstream = rtpmanager.createsendstream(dataoutput,0); sendstream.start(); system.out.println("starting processor" + "\n"); processor.start(); while(processor.getstate()== processor.started) { system.out.println("sending audio.."); } system.out.println("processor started , sound sent server"); wait(2000); // waiting sound given server // close connection if no longer needed. rtpmanager.removetarget(remoteaddress, "client disconnected."); // phone call dispose @ end of life-cycle of rtpmanager // prepared garbage-collected. rtpmanager.dispose();

well there no such explicit method sending rtcp bye using jmf. instead jmf internally sends rtcp bye when close sendstream.

please notice closing , stopping sendstream different. closing stream removes session whereas stopping sendstream stops info transmission. send rtcp bye stop processor , close sendstream when done sending media. send rtcp bye add together these 2 lines code.

processor.stop(); //processor needs stopped before closing sendstream sendstream.close();

java rtp jmf rtcp

No comments:

Post a Comment