java rtcp_如何使用Java Media Framework(JMF)发送rtcp bye消息?

我正在使用Java应用程序使用JAIN SIP Java API与精益语音服务器建立SIP会话。然后,我通过发送一些MRCP命令(如GET_PARAMS,SET-PARAMS,Define Grammar&识别使用mrcp4j API。

然后我使用JMF API来设置一个rtp& rtcp会话与语音服务器发送音频进行识别。服务器已收到音频,但在收到RTCP再见之前它不会识别。

但问题是我无法使用rtcp bye结束rtp会话,因为我无法找到JMF文档中的方法。

如果有人能指导我,那将会非常有帮助。我附上了RTP会话的代码。

JMF api文档的链接是here

// send Audio data

// create the RTP Manager

RTPManager rtpManager = RTPManager.newInstance();

// create the local endpoint for the local interface on any 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 the RTPManager

rtpManager.initialize(localAddress);

//rtpManager.initialize(rtpConnector);

// specify the remote endpoint of this unicast session

InetAddress ipAddress = InetAddress.getByName("hydhtc227033d");

SessionAddress remoteAddress = new SessionAddress(ipAddress, port, ipAddress, port + 1);

//System.out.println(remoteAddress);

// open the 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 the 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 the tracks and try to program one of them to

// output ulaw data.

for (int i = 0; i < 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

{

// we could not set this track to ulaw, so disable it

track[i].setEnabled(false);

}

}

// At this point, we have determined where we can send out ulaw data or not.

// realize the processor

if (encodingOk) {

processor.realize();

// block until realized.

while (processor.getState() != processor.Realized) {

}

// get the output datasource of the processor and exit if we fail

DataSource dataOutput = processor.getDataOutput();

// create a send stream for the output data source of a processor and start it

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 was started and audio was sent to server");

Wait(2000); // waiting so that audio could be given to the server

// close the connection if no longer needed.

rtpManager.removeTarget(remoteAddress, "Client disconnected.");

// call dispose at the end of the life-cycle of this RTPManager so

// it is prepared to be garbage-collected.

rtpManager.dispose();

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值