我正在尝试构建一个Libjitsi音频会议组件,以便集成到更大的applet中,从org.jitsi.examples.AVReceive2和* .AVTransmit2开始作为模板。我在一台计算机上正常运行这些示例,但在我尝试过的每台其他计算机上,我在初始化MediaDevices时不断收到错误消息。以下是AVReceive2的相关代码段:
private final int localPortBase;
private MediaStream[] mediaStreams;
private final InetAddress remoteAddr;
private final int remotePortBase;
public AudioTranceiver(int localPortBase, String remoteHost, int remotePortBase) {
this.localPortBase = localPortBase;
this.remoteAddr = InetAddress.getByName(remoteHost);
this.remotePortBase = remotePortBase;
}
public String start() {
MediaType mediaType = MediaType.AUDIO;
MediaService mediaService = LibJitsi.getMediaService();
int localPort = localPortBase;
int remotePort = remotePortBase;
mediaStreams = new MediaStream[1];
for(MediaDevice audio : mediaService.getDevices(mediaType, MediaUseCase.ANY)) {
System.out.println(audio.toString() + "\n");
}
try {
MediaDevice device
= mediaService.getDefaultDevice(mediaType, MediaUseCase.CALL);
MediaStream mediaStream = mediaService.createMediaStream(device);
mediaStream.setDirection(MediaDirection.RECVONLY);
......
......
此代码生成一个巨大的日志。我已经逐步完成了这项工作"工作"和"非工作"系统,并没有找到任何显着的日志差异,除了在最后。在一台计算机上,代码正常工作的计算机,初始化结束如下:
Oct 29, 2015 3:08:53 PM org.jitsi.util.Logger info
INFO: Initializing audio devices
Oct 29, 2015 3:08:53 PM org.jitsi.util.Logger info
INFO: Initializing video devices
Oct 29, 2015 3:08:54 PM org.jitsi.util.Logger info
INFO: Support for the formats of camera 'Lenovo EasyCamera': [AVFRAME, class org.jitsi.impl.neomedia.codec.video.AVFrame, pixFmt 1, deviceSystemPixFmt 0x32595559]
Oct 29, 2015 3:08:54 PM org.jitsi.util.Logger info
INFO: Looking for configured audio devices.
Oct 29, 2015 3:08:54 PM org.jitsi.util.Logger info
INFO: Scanning for configured Video Devices.
Oct 29, 2015 3:08:54 PM org.jitsi.util.Logger info
INFO: Found Lenovo EasyCamera as a AVFRAME, class org.jitsi.impl.neomedia.codec.video.AVFrame video capture device.
Oct 29, 2015 3:08:56 PM org.jitsi.util.Logger info
INFO: GatherEntropy got: 88200 bytes
此时,计算机将成功接收传入的RTP音频流。在我的其他设备上,我收到错误,它崩溃如下:
Oct 29, 2015 2:58:12 PM org.jitsi.util.Logger info
INFO: Initializing audio devices
Oct 29, 2015 2:58:12 PM org.jitsi.util.Logger info
INFO: Initializing video devices
Oct 29, 2015 2:58:12 PM org.jitsi.util.Logger info
INFO: Looking for configured audio devices.
Oct 29, 2015 2:58:12 PM org.jitsi.util.Logger info
INFO: Scanning for configured Video Devices.
Oct 29, 2015 2:58:12 PM org.jitsi.util.Logger info
INFO: Found Desktop Streaming 0 as a AVFRAME, class org.jitsi.impl.neomedia.codec.video.AVFrame video capture device.
java.lang.IllegalArgumentException: direction
at org.jitsi.service.neomedia.AbstractMediaStream.assertDirection(AbstractMediaStream.java:101)
at org.jitsi.impl.neomedia.MediaStreamImpl.setDirection(MediaStreamImpl.java:2496)
at org.jitsi.examples.AVReceive2.initialize(AVReceive2.java:131)
at org.jitsi.examples.AVReceive2.main(AVReceive2.java:349)
at com.sun.deploy.uitoolkit.impl.awt.AWTAppletAdapter.init(Unknown Source)
at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
我已确定mediaStream.setDirection(MediaDirection.RECVONLY)调用引发了错误,并尝试围绕该元素进行调试。
四点:
麦克风(Realtek高清晰度音频):wasapi:{0.0.1.00000000}。{8941227a-5fac-4416-b31b-728eb2665a82 LINEAR,48000.0 Hz,16位,Mono,LittleEndian,签名
LINEAR,48000.0 Hz,16位,立体声,LittleEndian,签名
LINEAR,48000.0 Hz,8位,单声道,签名
LINEAR,48000.0 Hz,8位,立体声,已签名
LINEAR,22050.0 Hz,16位,Mono,LittleEndian,签名
LINEAR,16000.0 Hz,16位,Mono,LittleEndian,签名
LINEAR,11025.0 Hz,16位,Mono,LittleEndian,签名
LINEAR,8000.0 Hz,16位,Mono,LittleEndian,签名
在非工作设备上,我只是得到一个通用的toString(),如:
Org.jits.impl.neomedia.device.AudioMediaDeviceImpl@131d2bf
我猜这意味着MediaService没有正确定位或实例化我的设备。我已经使用MediaService.getDevice(MediaType.AUDIO,MediaUseCase.ANY)扩展了搜索,以查看是否有其他设备,并且该服务只是获取了一个错误的默认设备,但Impl类是唯一检测到的设备。
我已经在这几天了,试图找到解决方案或者看看是否有其他人遇到过这个问题,但没有运气。任何有Libjitsi经验的人都知道可能导致这种情况的原因吗?
非常感谢,
大卫