简体   繁体   English

在Android上通过身份验证访问IP摄像机的实时流(Dlink 930l)

[英]Accessing the live stream of an IP camera (Dlink 930l) with authentication on Android

I have an IPCamera (Dlink DCS930l) connected to a network which requires authentication to access the stream. 我有一个IPCamera(Dlink DCS930l)连接到网络,该网络需要身份验证才能访问流。

Are there any Android libraries or frameworks that have the functionality to access an authenticated network stream? 是否有具有访问经过身份验证的网络流的功能的Android库或框架?

I was able to do something similar with a GoPro via Wifi connection. 我可以通过Wifi连接对GoPro进行类似操作。

Method 1: This can be achieved using OpenCV. 方法1:这可以使用OpenCV实现。 Based on the type of authentication used, you will need to specify the corresponding protocol, username and password when you provide the IP to access the camera. 根据使用的身份验证类型,在提供用于访问摄像机的IP时,需要指定相应的协议,用户名和密码。 The syntax required to open the camera stream using OpenCV is provided here (1). 此处提供了使用OpenCV打开摄像机流所需的语法(1)。

You will need to use OpenCV for Android and JNI bindings to the native C++ OpenCV API. 您将需要使用Android的OpenCV和与本机C ++ OpenCV API的JNI绑定。 Some sample applications here demonstrate how to make calls to the native API in an Android project. 这里的一些示例应用程序演示了如何在Android项目中调用本地API。

xuchong has developed a sample Android application demonstrating how to read an mp4 file natively via OpenCV on Android. xuchong开发了一个示例Android应用程序,演示了如何通过Android上的OpenCV本地读取mp4文件。 Update the video path in the MainActivity.java OnCreate() method to the IP camera feed with the syntax from (1) to read from a camera requiring authentication. 使用(1)的语法将MainActivity.java OnCreate()方法中的视频路径更新为IP摄像机源,以从需要身份验证的摄像机中读取。

Method 2: An example application demonstrating an alternative method that does not use OpenCV but instead uses the mjpeg library can be found here. 方法2:在此处可以找到一个示例应用程序,应用程序演示了一种不使用OpenCV而是使用mjpeg库的替代方法。

Method 3: Using just VideoView , assuming you have a http stream using Basic Auth for authentication, you can set headers when you provide the URI link in the following way: 方法3:仅使用VideoView ,假设您具有使用基本身份验证进行身份验证的http流,则可以通过以下方式在提供URI链接时设置标头:

Map<String, String> params = new HashMap<String, String>(1);
byte[] toEncrypt = (username + ":" + password).getBytes();
String encoded = Base64.encodeToString(toEncrypt, Base64.DEFAULT);
final String auth = "Basic " + encoded;
params.put("Authorization", auth);
Log.e(TAG, "Params Encode: " + params);
myVideoView.setVideoURI(vidAddress, params);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM