그래서, 나는 혀를 보내는 마이크 데이터를 찾고 있었지만 아무 것도 찾지 못했습니다. 그래서 저는 Oracles이 라인 열기에 관해서 tut을 읽었고 오디오를 ByteArrayOutputStream에 녹음 할 수 있었지만 지금은 두 가지 문제가 있습니다!UDP를 통해 오디오를 보내십시오
처음 : 녹음 된 오디오를 재생하는 방법.
두 번째 : 내가 BAOS에 어떻게 녹음하면 동적으로 보내겠습니까? 데이터 배열을 보내 겠지만 프로세서를 수신 할 때마다 BAOS에 쓰는 것이 너무 프로세서가 많을까요? 아니면 다르게 할 수 있습니까?
현재 코드 : 주어진 어떤 도움
import java.io.ByteArrayOutputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.TargetDataLine;
public class MicrophoneRecorder {
static boolean stopped = false;
public static void main(String[] args) {
AudioFormat format = new AudioFormat(8000.0f, 16, 1, true, true);
TargetDataLine line = null;
DataLine.Info info = new DataLine.Info(TargetDataLine.class, format);
if (!AudioSystem.isLineSupported(info)) {
System.out.println("Not supported!");
}
try {
line = (TargetDataLine) AudioSystem.getLine(info);
line.open(format);
} catch (LineUnavailableException ex) {
ex.printStackTrace();
}
ByteArrayOutputStream out = new ByteArrayOutputStream();
int numBytesRead = 0;
byte[] data = new byte[line.getBufferSize()/5];
line.start();
new Thread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
stopped = true;
}
}).start();
while (!stopped) {
numBytesRead = line.read(data, 0, data.length);
out.write(data, 0, numBytesRead);
}
}
}
감사합니다. 감사합니다. Roberto Anić Banić
P. 이 경우 작동하지 않습니다. http://javasolution.blogspot.com/2007/04/voice-chat-using-java.html P.P.S. UDP는 좋은 선택이며 RTSP를 사용해야합니까?
왜 그 일을하지 않습니다? 당신은 아마 그것을하고 싶다 ... –
코드가 망가져있다 –
오히려 바퀴를 재발 명하는 것 같다 : [RTSP] (http://www.ietf.org/rfc/rfc2326.txt) – marko