Search code examples
c++ip-camera

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


Solution

  • 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.