我的系统由一台数字视频录像机(dvr)和两台与dvr连接的摄像机组成.dvr也作为服务器工作(连接到LAN).系统包括一个Android应用程序,我在其中放置有关服务器,端口,用户名和密码的信息(我可以使用服务器软件添加帐户).该应用程序从摄像机传输视频.我也可以通过http(只有IE)与dvr连接,然后显示activeX应用程序.
我要做的是编写类似的应用程序,但我遇到了一个问题 - 如何从dvr获取视频流?我不是Java专家,尝试连接dvr,但没有成功.
这是我的代码:
import java.net.*;
import java.io.*;
public class VideoStream
{
final static int BUFFER_SIZE = 1024000;
public static void main(String[] args) throws Exception
{
Authenticator.setDefault(new Authenticator()
{
protected PasswordAuthentication getPasswordAuthentication()
{
System.out.println("Authenticatting...");
PasswordAuthentication p=new PasswordAuthentication("login", "password".toCharArray());
return p;
}
});
Socket s = new Socket();
String host = "192.168.80.107"; //192.168.80.107
PrintWriter s_out = null;
BufferedReader s_in = null;
BufferedInputStream bufferedInputStream = null;
try
{
s.connect(new InetSocketAddress(host, 34599));
System.out.println("Is connected? : " + s.isConnected());
s_out = new PrintWriter(s.getOutputStream(), …Run Code Online (Sandbox Code Playgroud)