Java 在FMJ中未找到捕获设备
以前我使用的是JMF,但需要安装JMF,但我不想增加这种开销。这就是为什么我想搬到FMJ。FMJ是开源的。:) 这里给出了一些FMJ源的示例。还有一个FMJStudio,我可以在这里运行和传输从麦克风捕获的RTP音频 但是当我想使用下面的源传输RTP时,它找不到任何捕获设备 完整来源可在以下网址找到:fmj-20070928-0938_2.zipin 并且该源类的类名为SimpleVoiceTransmiterJava 在FMJ中未找到捕获设备,java,jmf,fmj,Java,Jmf,Fmj,以前我使用的是JMF,但需要安装JMF,但我不想增加这种开销。这就是为什么我想搬到FMJ。FMJ是开源的。:) 这里给出了一些FMJ源的示例。还有一个FMJStudio,我可以在这里运行和传输从麦克风捕获的RTP音频 但是当我想使用下面的源传输RTP时,它找不到任何捕获设备 完整来源可在以下网址找到:fmj-20070928-0938_2.zipin 并且该源类的类名为SimpleVoiceTransmiter //final String urlStr = URLUtils.creat
//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);
}
}
//最终字符串urlStr=URLUtils.createUrlStr(新文件(“samplemedia/gulp2.wav”)//"file://samplemedia/gulp2.wav";
格式;
格式=新的音频格式(AudioFormat.ULAW_RTP,8000,8,1);
//格式=新的音频格式(AudioFormat.ULAW_RTP,8000.0,8,1,AudioFormat.LITTLE_ENDIAN,AudioFormat.SIGNED);
//格式=新的音频格式(BonusAudioFormatEncodings.ALAW_RTP,8000,8,1);
//格式=新的音频格式(BonusAudioFormatEncodings.SPEEX_RTP,8000,8,1,-1,AudioFormat.SIGNED);
//格式=新的音频格式(BonusAudioFormatEncodings.ILBC_RTP,8000.0,16,1,AudioFormat.LITTLE_ENDIAN,AudioFormat.SIGNED);
CaptureDeviceInfo di=null;
//如果要从捕获设备(如麦克风)传输音频,请将设置为true。
如果(真)
{
//首先找到一个可以捕获线性音频的捕获设备
//8位8Khz的数据
AudioFormat captureFormat=新的AudioFormat(AudioFormat.LINEAR,8000,8,1);
向量设备=CaptureDeviceManager.getDeviceList(captureFormat);
如果(devices.size()>0)
{
di=(CaptureDeviceInfo)设备。elementAt(0);
}否则
{
System.err.println(“无捕获设备”);
//如果找不到相关的capturedevice,请退出。
系统退出(-1);
}
}
//为此capturedevice创建处理器&如果需要,请退出
//无法创建它
处理器=空;
尝试
{
//processor=Manager.createProcessor(新的MediaLocator(urlStr));
processor=Manager.createProcessor(di.getLocator());
}捕获(IOE异常)
{
e、 printStackTrace();
系统退出(-1);
}捕获(NoProcessorException e)
{
e、 printStackTrace();
系统退出(-1);
}
//配置处理器
processor.configure();
while(processor.getState()!=processor.Configured)
{
尝试
{
睡眠(10);
}捕捉(中断异常e)
{
//TODO自动生成的捕捉块
e、 printStackTrace();
}
}
processor.setContentDescriptor(新的ContentDescriptor(ContentDescriptor.RAW_RTP));
TrackControl track[]=处理器。getTrackControls();
布尔编码OK=false;
//浏览这些曲目,并尝试将其中一个编程为
//输出g.711数据。
对于(int i=0;i
运行此源时,输出为:无捕获设备
有什么问题吗-(
< >编辑:我从系统中卸载了<强> JMF <强>。< / P> < P> OK,经过两天半,我就陷入了无处,我自己指出了这个问题。< /P> 问题是,当我卸载JMF时,它没有从CLASSPATH用户变量中删除。出现了如下情况:
"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;"
当我删除它们并重新启动我的计算机时。然后是宾果。代码运行时没有任何问题。:)