Results 1 to 5 of 5
Thread: Voip
- 02-21-2013, 10:48 AM #1
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
Voip
hey,I want to ask about Java Sound API...using the code below, can I capture the audio coming from a microphone and send it using a Datagram packet?? if no, then please someone tell me what should I do...
private void captureAudio() {
try {
final AudioFormat format = getFormat();
DataLine.Info info = new DataLine.Info(
TargetDataLine.class, format);
final TargetDataLine line = (TargetDataLine)
AudioSystem.getLine(info);
line.open(format);
line.start();
Runnable runner = new Runnable() {
int bufferSize = (int)format.getSampleRate()
* format.getFrameSize();
byte buffer[] = new byte[bufferSize];
public void run() {
out = new ByteArrayOutputStream();
running = true;
try {
while (running) {
int count =
line.read(buffer, 0, buffer.length);
if (count > 0) {
out.write(buffer, 0, count);
buf=out.toByteArray();
sendPacket=new DatagramPacket ( buf,buf.length,address,portNumber);
socket.send(sendPacket);
}
}
out.close();
} catch (IOException e) {
System.err.println("I/O problems: " + e);
System.exit(-1);
}
}
};
Thread captureThread = new Thread(runner);
captureThread.start();
} catch (LineUnavailableException e) {
System.err.println("Line unavailable: " + e);
System.exit(-2);}
}
- 02-21-2013, 12:59 PM #2
Re: Voip
Why do they call it rush hour when nothing moves? - Robin Williams
- 02-21-2013, 04:22 PM #3
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
Re: Voip
thnx...
- 02-21-2013, 04:26 PM #4
Member
- Join Date
- Feb 2013
- Posts
- 3
- Rep Power
- 0
voip,capture audio, and send datagram packet
hey,I want to ask about Java Sound API...using the code below, can I capture the audio coming from a microphone and send it using a Datagram packet?? if no, then please someone tell me what should I do...
Java Code:private void captureAudio() { try { final AudioFormat format = getFormat(); DataLine.Info info = new DataLine.Info( TargetDataLine.class, format); final TargetDataLine line = (TargetDataLine) AudioSystem.getLine(info); line.open(format); line.start(); Runnable runner = new Runnable() { int bufferSize = (int)format.getSampleRate() * format.getFrameSize(); byte buffer[] = new byte[bufferSize]; public void run() { out = new ByteArrayOutputStream(); running = true; try { while (running) { int count = line.read(buffer, 0, buffer.length); if (count > 0) { out.write(buffer, 0, count); buf=out.toByteArray(); sendPacket=new DatagramPacket ( buf,buf.length,address,portNumber); socket.send(sendPacket); } } out.close(); } catch (IOException e) { System.err.println("I/O problems: " + e); System.exit(-1); } } }; Thread captureThread = new Thread(runner); captureThread.start(); } catch (LineUnavailableException e) { System.err.println("Line unavailable: " + e); System.exit(-2);} }
- 02-21-2013, 04:39 PM #5
Re: Voip
Please don't start a new thread with the same question. I've merged the two threads here.
Also, haven't you learned to format your code for readability? Code Conventions for the Java Programming Language: Contents
dbWhy do they call it rush hour when nothing moves? - Robin Williams
Similar Threads
-
JAVA and VOIP, how to?
By mr_anderson in forum Advanced JavaReplies: 1Last Post: 05-31-2011, 03:39 PM -
Voip review
By callsvoip in forum Reviews / AdvertisingReplies: 0Last Post: 02-22-2010, 02:16 PM -
Better Oppertunity To start Voip Buisness
By taiger786 in forum Reviews / AdvertisingReplies: 0Last Post: 02-16-2010, 09:00 AM -
VOIP Server Hardware Requirements
By asifsolkar in forum NetworkingReplies: 12Last Post: 05-21-2008, 04:23 AM -
Urgent Opening in C++/Java with SIP/VoIP
By Satish.kumar in forum Jobs OfferedReplies: 3Last Post: 03-30-2008, 09:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks