Results 1 to 2 of 2
- 10-25-2009, 02:12 PM #1
Member
- Join Date
- Oct 2009
- Posts
- 5
- Rep Power
- 0
java.lang.Error: Error opening DSound for capture
hi all.
when i excuete the code , i got the error msg "java.lang.Error: Error opening DSound for capture" , how to solve the problem ?
Java Code:import javax.media.CaptureDeviceManager; import javax.media.CaptureDeviceInfo; import javax.media.DataSink; import javax.media.Manager; import javax.media.MediaLocator; import javax.media.NoProcessorException; import javax.media.NotRealizedError; import javax.media.Processor; import javax.media.format.AudioFormat; import javax.media.rtp.*; import javax.media.protocol.ContentDescriptor; import javax.media.protocol.DataSource; import javax.media.control.FormatControl; import javax.media.control.TrackControl; import java.util.Vector; import java.io.*; public class sendMedia extends Thread { CaptureDeviceInfo di = null; float fFrameRate = 44100.0F; Processor p = null; DataSink d; public sendMedia(String url) { //Get the CaptureDeviceInfo for the live audio capture device Vector deviceList = CaptureDeviceManager.getDeviceList(new AudioFormat("linear", 44100, 16, 2)); if (deviceList.size() > 0) di = (CaptureDeviceInfo)deviceList.firstElement(); else { System.exit(-1); } try { p = Manager.createProcessor(di.getLocator()); } catch (IOException e) { System.exit(-1); } catch (NoProcessorException e) { System.exit(-1); } int ProcessStatus; p.configure(); while(p.getState() == 140) {} p.setContentDescriptor(new ContentDescriptor(ContentDescriptor.RAW)); TrackControl track[] = p.getTrackControls(); boolean encodingOk = false; //Go through the tracks and try to program one of them to //output gsm data. for (int i = 0; i < track.length; i++) { if (!encodingOk && track[i] instanceof FormatControl) { if (((FormatControl)track[i]).setFormat( new AudioFormat(AudioFormat.GSM_RTP, 8000, 8, 1)) == null) { track[i].setEnabled(false); } else { encodingOk = true; } } else { //we could not set this track to gsm, so disable it track[i].setEnabled(false); } } //At this point, we have determined where we can send out //gsm data or not. //realize the processor if (encodingOk) { p.realize(); while(p.getState() ==200) {} //get the output datasource of the processor and exit //if we fail DataSource ds = null; try { ds = p.getDataOutput(); } catch (NotRealizedError e) { System.exit(-1); } //hand this datasource to manager for creating an RTP //datasink our RTP datasimnk will multicast the audio try { String srcFile = "/C:/tmp/test.wav"; // MediaLocator m = new MediaLocator(url); MediaLocator m = new MediaLocator("file:" + srcFile); d = Manager.createDataSink(ds, m); } catch (Exception e) { System.exit(-1); } } } public void run() { try { p.start(); d.open(); d.start(); } catch (Exception e) { System.exit(-1); } } public static void main(String args[]) { // sendMedia send = new sendMedia(args[0]); //ex:rtp://192.168.1.2:3000/audio/1 String str = "rtp://192.168.1.2:3000/audio/"; sendMedia send = new sendMedia(str); //ex:rtp://192.168.1.2:3000/audio/1 Thread startSend = new Thread(send); startSend.start(); } }
Any help will be appreciated!
- 10-26-2009, 04:38 PM #2
Member
- Join Date
- Oct 2009
- Posts
- 25
- Rep Power
- 0
Similar Threads
-
java.lang.NullPointerException Error
By Manfizy in forum NetBeansReplies: 3Last Post: 02-24-2011, 06:27 AM -
Error opening socket: java.net.ConnectException: Connection refused: connect
By somersst in forum Java ServletReplies: 3Last Post: 01-26-2009, 05:30 PM -
How to over come java.lang.out of memory error
By Chaitra_gm in forum New To JavaReplies: 5Last Post: 09-28-2008, 10:33 AM -
Error: cannot resolve symbol' on Person (java.lang.String, java.lang.String)
By baltimore in forum New To JavaReplies: 2Last Post: 09-18-2008, 07:30 AM -
Error: java.lang.ArrayIndexOutOfBoundsException
By fernando in forum Java 2DReplies: 1Last Post: 07-31-2007, 11:47 PM


LinkBack URL
About LinkBacks

Bookmarks