我必须创建一个客户端/服务器系统来流式传输视频和音频.这很简单.喜欢youtube风格.服务器应首先参加提供媒体列表的客户端,并等待每个客户端的选择以开始流式传输媒体.直到创建一个套接字并显示一个简单的列表我就在它上面;)但我不知道我可以使用哪个类来传输.这个例子基本上是youtube风格.如何开始流式传输,客户端如何暂停再现,怎么样?
我知道如何流式传输文字,但视频呢?你知道任何教程页吗?
它与这个简单的服务器客户端示例有很大不同?
import java.io.*;
import java.io.*;
import java.net.*;
public class ThreadedEchoServer {
public static void main(String[] args) {
try {
int i = 1;
ServerSocket s = new ServerSocket(8189);
while(true) {
Runnable r = new ThreadedEchoHandler(incoming, i);
Thread t = new Thread(r);
t.start();
i++;
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
class ThreadedEchoHandler implements Runnable {
private Socket incoming;
private int counter;
public ThreadedEchoHandler(Socket i, int c) {
incoming = i;
counter = c;
}
public void run() {
try {
try {
InputStream inStream = incoming.getInputStream();
OutputStream outStream = incoming.getOutputStream();
Scanner in = new Scanner(inStream);
PrintWriter out = new PrintWriter(outStream);
out.println("BYE to exit");
boolean done = false;
while (!done && in.hasNextLine()) {
String line = in.nextLine()) {
out.println("Echo: " + line);
if (line.trim().equals("BYE"))
done = true;
out.println("BYE to exit");
}
} finally {
incoming.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
希望你能澄清我的想法.
亲切的问候.