我的系统包括数字视频记录器(DVR)和两个摄像机,它们与DVR连接的。硬盘录像机可以作为服务器也(连接到LAN)。在体系中包含一个Android应用程序,在这里我把信息有关服务器,端口,用户名和密码(我可以添加使用服务器软件帐户)。该应用程序从相机传输视频。我还可以与DVR通过HTTP(仅适用于IE浏览器)连接,然后将其显示ActiveX应用程序。
My system consists of a digital video recorder (dvr) and two cameras, which are connected with dvr. The dvr works as server also (connected to LAN). To the system was included an android application, where I put info about server, port, user name and password (I can add accounts using server software). The application streams video from cameras. I can also connect with dvr via http (only IE), then it show activeX application.
什么我做的是写的类似的应用程序,但我还是坚持了一个问题 - 我怎么能获取来自DVR的视频流?我与Java方面的专家,并试图跟硬盘录像机,没有成功。
What I'm to do is write similar application, but I stuck into a problem - how can I fetch the video stream from dvr? I'm no expert with Java and tried connect with dvr, unsuccessfully.
下面是我的code:
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(), true);
s_in = new BufferedReader(new InputStreamReader(s.getInputStream()));
//bufferedInputStream = new BufferedInputStream(s.getInputStream());
}
catch(UnknownHostException e)
{
e.printStackTrace();
System.exit(1);
}
catch(Exception e)
{
e.printStackTrace();
System.exit(1);
}
byte[] b = new byte[BUFFER_SIZE];
//bufferedInputStream.read(b);
int bytesRead = 0;
System.out.println("Reading... \n");
while((bytesRead = s_in.read()) > 0)
{
System.out.println(s_in.readLine());
}
System.out.println("Done");
}
我尝试了不同的端口(TCP和包括Android应用程序)。套接字与服务器连接,但它挂起当我尝试使用read()方法(甚至退出while循环)。验证器不工作了。
I tried different port (TCP and for included android app). The socket connect with the server, but it "hangs" when I try to use read() method (even out of while loop). Authenticator don't work too.
有关DVR一些信息:
支持的协议:TCP / IP,UDP,SMTP,NTP,DHCP,DDNS 视频融为一体pression:H.264 操作系统:Linux我会非常非常的AP preciate任何建议。
I will much appreciate any advices.
正如其他人在评论中指出,该意见是知道如何对现有的Android应用程序的工作。
As others noted in the comments, the advice is to know how the existing Android application works.
这可能是值得尝试检查数据包和回复(与像的关于Android客户端和DVR之间的通信鲨鱼的Droid的)。
It may be worth trying to inspect packets and replies (captured with a sniffer like Shark for Droid) concerning the communications between the Android client and the DVR.
上一篇:如何以编程方式适用于Android的低音效果适用于、低音、效果、方式
下一篇:navigator.geolocation.getCurrentPosition总是得到一个错误code 3:超时过期错误、geolocation、navigator、code