使用Mjsip作为我的softphone项目的sip堆栈。有类RtpSender.java有Method
public RtpSender(OutputStream output_stream, boolean do_sync, SIPCodec sipCodec, DatagramSocket src_socket, String dest_addr, int dest_port )
{
init( output_stream, do_sync, sipCodec, src_socket, dest_addr, dest_port );
}
在另一个文件AudioSender.java(这是一个纯java音频流发送者)我使用RtpSender方法如下...
sender=new RtpSender(audio_input_stream,true,**SIPCodec**,null,daddr,dport);
我的问题是SIPCodec,我有一个为编解码器命名的接口,我应该传递什么值?我应该怎样通过?我正在调用codecids,但显示方法对此不合适。这是编解码器接口......
public interface SIPCodec {
// Codec constants
public static String MEDIA_TYPE_AUDIO = "audio";
public static String MEDIA_TYPE_VIDEO = "video";
public static String ATTRIBUTE_PTIME = "ptime";
public static String ATTRIBUTE_RTPMAP = "rtpmap";
public static String ATTRIBUTE_FMTP = "fmtp";
public static String ATTRIBUTE_AS = "AS";
public static int DEFAULT_PACKETIZATION = 20;
public void encodeInit( int defaultEncodePacketization );
public void decodeInit( int defaultDecodePacketization );
...
这是codecs.java类,我将其称为单个编解码器。
public SIPCodec getSIPAudioCodec( int codecId ) {
SIPCodec sipCodec;
switch ( codecId ) {
case audioCodecPCMU:
sipCodec = new SIPCodecPCMU();
break;
case audioCodecPCMA:
sipCodec = new SIPCodecPCMA();
break;
case audioCodecG729:
sipCodec = new SIPCodecG729();
break;
case audioCodeciLBC:
sipCodec = new SIPCodeciLBC();
break;
default:
sipCodec = null;
}