[英]No capture devices found in FMJ
Previously I was working with JMF, but JMF need to be installed, but I don't want to add this overhead. 以前我正在使用JMF,但是需要安装JMF,但是我不想增加此开销。 That's why I want be moved to FMJ.
这就是为什么我要转到FMJ。 And FMJ is opensource.
FMJ是开源的。 :)
:)
There is some sample example given with FMJ source. FMJ源提供了一些示例示例。 And there is a FMJStudio, from where I can run and transmit RTP audio captured from microphone.
还有一个FMJStudio,从那里我可以运行和传输从麦克风捕获的RTP音频。
But when I want to Transmit RTP, using the source below, it couldn't find any capture device. 但是,当我想使用下面的源发送RTP时,找不到任何捕获设备。
The complete source can be found on: fmj-20070928-0938_2.zip in FMJ And the class name of this source class is SimpleVoiceTransmiter . 完整的源代码可以在FMJ中的 fmj-20070928-0938_2.zip中找到,该源类的类名称为SimpleVoiceTransmiter 。
//final String urlStr = URLUtils.createUrlStr(new File("samplemedia/gulp2.wav"));//"file://samplemedia/gulp2.wav";
Format format;
format = new AudioFormat(AudioFormat.ULAW_RTP, 8000, 8, 1);
//format = new AudioFormat(AudioFormat.ULAW_RTP, 8000.0, 8, 1, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED);
//format = new AudioFormat(BonusAudioFormatEncodings.ALAW_RTP, 8000, 8, 1);
//format = new AudioFormat(BonusAudioFormatEncodings.SPEEX_RTP, 8000, 8, 1, -1, AudioFormat.SIGNED);
//format = new AudioFormat(BonusAudioFormatEncodings.ILBC_RTP, 8000.0, 16, 1, AudioFormat.LITTLE_ENDIAN, AudioFormat.SIGNED);
CaptureDeviceInfo di = null;
//Set to true if you want to transmit audio from capture device, like microphone.
if (true)
{
// First find a capture device that will capture linear audio
// data at 8bit 8Khz
AudioFormat captureFormat = new AudioFormat(AudioFormat.LINEAR, 8000, 8, 1);
Vector devices = CaptureDeviceManager.getDeviceList(captureFormat);
if (devices.size() > 0)
{
di = (CaptureDeviceInfo) devices.elementAt(0);
} else
{
System.err.println("No capture devices");
// exit if we could not find the relevant capturedevice.
System.exit(-1);
}
}
// Create a processor for this capturedevice & exit if we
// cannot create it
Processor processor = null;
try
{
//processor = Manager.createProcessor(new MediaLocator(urlStr));
processor = Manager.createProcessor(di.getLocator());
} catch (IOException e)
{
e.printStackTrace();
System.exit(-1);
} catch (NoProcessorException e)
{
e.printStackTrace();
System.exit(-1);
}
// configure the processor
processor.configure();
while (processor.getState() != Processor.Configured)
{
try
{
Thread.sleep(10);
} catch (InterruptedException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
}
processor.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW_RTP));
TrackControl track[] = processor.getTrackControls();
boolean encodingOk = false;
// Go through the tracks and try to program one of them to
// output g.711 data.
for (int i = 0; i < track.length; i++)
{
if (!encodingOk && track[i] instanceof FormatControl)
{
if (((FormatControl) track[i]).setFormat(format) == null)
{
track[i].setEnabled(false);
} else
{
encodingOk = true;
}
} else
{
// we could not set this track to g.711, so disable it
track[i].setEnabled(false);
}
}
// At this point, we have determined where we can send out
// g.711 data or not.
// realize the processor
if (encodingOk)
{
if (!new net.sf.fmj.ejmf.toolkit.util.StateWaiter(processor).blockingRealize())
{
System.err.println("Failed to realize");
return;
}
// get the output datasource of the processor and exit
// if we fail
DataSource ds = null;
try
{
ds = processor.getDataOutput();
} catch (NotRealizedError e)
{
e.printStackTrace();
System.exit(-1);
}
// hand this datasource to manager for creating an RTP
// datasink our RTP datasink will multicast the audio
try
{
String url = "rtp://192.168.1.99:49150/audio/1";
MediaLocator m = new MediaLocator(url);
DataSink d = Manager.createDataSink(ds, m);
d.open();
d.start();
System.out.println("Starting processor");
processor.start();
Thread.sleep(30000);
} catch (Exception e)
{
e.printStackTrace();
System.exit(-1);
}
}
When I run this source, The output is: No capture devices 当我运行此源代码时,输出为: 没有捕获设备
What may be the problem? 可能是什么问题? :-(
:-(
Edit: I uninstalled the JMF from my system. 编辑:我从系统中卸载了JMF 。
Ok, after two and half days, stuck in the middle of nowhere, I pointed out the problem myself. 好了,两天半之后,我陷于茫茫荒野之中,我自己指出了问题所在。
The problem was, when I uninstalled JMF it wasn't removed from the CLASSPATH user variable. 问题是,当我卸载JMF时,它没有从CLASSPATH用户变量中删除。 There was somethinng like:
有类似的东西:
"C:\PROGRA~1\JMF21~1.1E\lib\sound.jar;C:\PROGRA~1\JMF21~1.1E\lib\jmf.jar;C:\PROGRA~1\JMF21~1.1E\lib;"
and when I removed them, and restarted my computer. 当我删除它们,然后重新启动计算机时。 Then bingo.
然后宾果游戏。 The code run without any problem.
该代码运行没有任何问题。 :)
:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.