Controls CGI

Version / Author / DateModify
1.0/David/2013-03-30First edition

ReeCam IP Camera CGI interface is provided to the user to use a set of HTTP CGI-based application development interface. The user can use this interface:

1. Customizable IP Camera Web UI interface
2. Using a browser or player IP Camera directly access and manipulate
3. Use of a computer programming language to access and manipulate IP Camera

CGI Call

There are three ways to call the CGI interface IP Camera:

Call the CGI interface directly in the browser and player, for example:

Directly in the browser address bar enter
You can also directly in the player open the following address
Call in a Web page. For example:
<html> <head> <script Src="get_status.cgi"> </script> </head> <body> ... </body> </html> Or:

location = 'set_params.cgi? alias = ipcam-demo'; - <Implemented in a computer programming language.

Note, when calling the CGI interface should ensure that send HTTP URL can not contain illegal characters, URI encoding parameters may contain illegal characters. For example:
Location = 'set_params.cgi? Alias ​​=' + alias_inp.value;
Should use location = 'set_params.cgi? Alias ​​=' + encodeURIComponent (alias_inp.value);

User Authentication

User invokes the CGI interface IP Camera, IP Camera username/password authentication must be carried out to the user to determine whether it can meet the user's permissions.
Permissions required by each CGI command, by definition, have the permissions on the IP Camera is divided into two categories: managers and visitors.
Managers have all the permissions function; while the visitors were awarded according to the set combination of the following privileges:
    1 video access: access to the video.
    2 pictures permissions: You can take pictures of operation.
    3 video permissions: remote video operation, ie video IP Camera SD card IP Camera set network shared directory.
    4 audio access: listening.
    Dialogue permission: dialogue with the IP Camera.
    6 control permissions: IP Camera PTZ control and camera parameters can be performed.
CGI interface to support user authentication, there are three:
    1 certification based on the way the HTTP Basic Authentication.
        For example, in the browser address bar directly input, the browser prompt username/password authentication window will pop up to alert the user,
        If the program is written in a programming language, you can increase the Authentication field in the HTTP request sent to the IP Camera to implement user authentication.
    Based on the parameters in the form of certification.
        Example, directly in the browser address bar enter = HTTP request additional user and pwd parameters to achieve the user authentication.
    Session-based authentication.
        Created before a Session, directly in the HTTP request additional session parameters to achieve user authentication.
        For example, you can be entered directly in the browser address bar, IP Camera No. 20,983,424 of the session will be created prior to grant the user rights of the Session Current users visit.
These three authentication methods, if used, the third highest priority, the first priority of the lowest.

CGI Returns

CGI interface to return to the four types of data:
    1 text message
    2.js text messages
    3.json/jsonp text messages
    4 files
CGI interface can be divided into three categories according to the return type:
    A class of CGI, the user will need to get a file or a series of streaming data.
    For example snapshot.cgi, backup.cgi, av.asf ... such as cgi such as the operation fails, then return to the failed text messages, and if successful, returns the corresponding file.
    A class operation and settings like CGI, such CGI users only care about the results of the operation and settings. For example set_params.cgi, ptz_control.cgi ...
json/jsonp type of data a kind of cgi settings when the call returns json/jsonp data, whether successful or not, are returned to indicate the result of the operation, such as:
{"Error": -2} json data
callback ({"error": 0}); jsonp data
b. json/jsonp data is returned, the operation is not set called failure will certainly return to the text message, for example,
Operation failed: invalid ip and mask. Representing the operation to fail, given the failure of the reasons is invalid ip and mask parameters
Operation failed: invalid user settings. Representatives operation failed, and given the failure due to invalid user parameter
While operation was successful based on whether the user when invoked set next_url parameters, if not set, returns the success of text information, for example:
Operation Succeed. Representative of the operation is successful
Otherwise, camera will return specified page next_url. For example:
If the operation is successful, IP Camera will return page of user.htm, Of course, if the operation failed, or will return to operation fails and causes the text information.
Note: The specified page must next_url IP Camera on the page and not the page on other sites.
the page specified next_url nor incidental parameters.
    A class CGI query classes CGI for such CGI, you not only need to know whether the operation was successful, and also need to know the specific value.
    For example: get_status.cgi, get_params.cgi
json/jsonp type of data a kind of cgi settings when the call returns json/jsonp data, whether successful or not, are returned to indicate the result of the operation, such as:
{"Error": 0, "time": 1363592625, "alarm": 0, "upnp": 0, "ntp": 1, "record": 0, "disk": 0, "ddns": 0, " skype ": 0," tutk ": 0} json data
callback ({"error": -2}); jsonp data
b such cgi called set the returned json/jsonp data returns if the operation fails friendly text information, but if the operation is successful, it will return js text messages.
For example, the user wants to query the IP address of the IP Camera: =
IP Camera will return:
var ip = '192 .168.0.188 ';
Some CGI returns may also be javascript array variable form. For example:
IP Camera will return:
var session_user = new Array ();
var session_ip = new Array ();
session_user [0] = 'admin';
session_ip [0] = '192 .168.0.16 ';
var number = 1;
Of which session_user and session_ip are an array of variables, and the number is the number of members of the array.
For some applications, the user may not want to use the name of the variables returned by the default IP Camera
Such as the first example, the user does not want to use the ip variable name, but the variable name want to use camera_ip, you can:
IP Camera will return:
var camera_ip = '192 .168.0.188 ';

How do I set cgi return json/jsonp type of data? The cgi parameters increase json parameter and jsonp_callback parameter which the json parameter specifies the type of data returned by the camera:

0 or no additional json parameters, return text information or js text
1: return json text
2: return jsonp text returned callback function name can be specified by jsonp_callback parameters, otherwise the default function name "callback" parameter is returned json object.

Camera returned json object, there will always be an error variable to specify the cgi call:


operation is successful


Operation failed: Authentication error


Operation failed: parameter error


Operation failed to achieve the maximum number of session


Operation failed: camera internal error


Operation failed: Timeout


Operation failed: error or is not supported by the operating request

When the error is not equal to 0, there is no follow returns.

Copyright:Shenzhen XRC Tech Co.,Ltd.