简体   繁体   中英

How to authenticate with IP Camera?

I encountered the problem when working with IP Camera Panasonic (BL-C111CE).

I want to get motion jpeg stream from this camera. So i did the following steps:

1. Open socket on HTTP port: 

 mySocket = connect("192.168.1.253" /*ip*/, "80" /*port*/);

2. Send the following string command to camera:

 "GET /nphMotionJpeg?&Resolution=640x480&Quality=Motion&Framerate=30 HTTP/1.1\r\n\r\n"

This command work fine when I enabled the privilege view video for general user in camera's settings. But when I disable this privilege, the above command is failed.

I have searched, and I knew I need send admin's username and password in order to authenticate to Camera.

But I don't know the syntax for sending my username and password. And which step must I send it?

Many thanks,

Phong Le

I think you might need to use some sort of HTTP Authentication, either Basic or Digest . I'd try with Basic Authentication first, so send an additional header in your Request like

GET /nphMotionJpeg?&Resolution=640x480&Quality=Motion&Framerate=30 HTTP/1.1
Authorization: Basic <AuthString>

For AuthString you construct a string 'username:password' and encode it using BASE64.

Have a look at the linked Wikipedia articles for more information about HTTP Authentication.

i resolved the part about authorization by

request.setHeader("Authorization","Basic " + Base64.encodeToString ("user:password".getBytes(), Base64.NO_WRAP));

where request is a HttpGet instance;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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