Camera Management Server

From MiOS
(Difference between revisions)
Jump to: navigation, search
(archive_image: Tells the cs to archive an image from the camera)
(list_archives: The cs returns a list of archived images and video)
Line 97: Line 97:
  
  
==list_archives: The cs returns a list of archived images and video  ==
+
==fetch_archive: The cs returns an archived image or video  ==
  
 
https://cr1.mios.com/fetch_archive?id=a&user=b&pass=c
 
https://cr1.mios.com/fetch_archive?id=a&user=b&pass=c

Revision as of 02:12, 1 August 2011

Certain cameras come with custom firmware so that they automatically connect to the MiOS camera management server (cms), creating a tunnel the cms can use to send commands to the camera and to act as a relay so users can view and control the camera when outside the home without having to change their firewall.

Mios operates a camera server ("cs") which is available at crX.mios.com (ie cr1.mios.com, cr2.mios.com, etc.). Cameras which are shipped with this custom firmware will automatically connect to the cs and report their Mac Address and IP address. Cs stores this in a database along with the external IP that the connection came in on.

Contents

Locating the camera

To get the list of all cameras and MiOS systems on your current home network, read this URL: http://sta1.mios.com/locator_json2.php which returns the list in JSON format. To add to the list all cameras that are off the home network but which can be access remotely with a given username, add a ?username=x to the URL, such as http://sta1.mios.com/locator_json2.php?username=johndoe

A camera will look like this:

     {
           "serialNumber": "554",
           "Alive": 0,
           "name": "Good camera",
           "mfr": "Mios",
           "ipAddress": "192.168.2.27",
           "category": "2",
           "subcategory": "1",
           "users": "16782,3",
           "ImageUrl_LR": "img/snapshot.cgi?size=320x240&quality=4",
           "MJpegUrl_LR": "img/video.mjpeg",
           "MP4Url_LR": "img/video.asf",
           "ImageUrl_HR": "img/snapshot.cgi?size=640x480&quality=2",
           "MJpegUrl_HR": "img/video.mjpeg",
           "MP4Url_HR": "img/video.asf",
           "CanRelay": "1",
           "Port": "80",
           "local_remote": "1",
           "relay_remote": "1",
           "active_server": "cr1.mios.com"
       }

Local vs remote access

In the Json data above, "active_server" tells you which Cs the camera connects to. So to view or control this camera connect to cr1.mios.com. If the camera is on the same network as the client, then ipAddress will have an ip. Otherwise there is no ipAddress. If the ipAddress is specified, then you can access the camera on the local network, without going through the relay server, by using ImageUrl, MJpegUrl and MP4Url tags to fetch a JPEG Image, MJPEG stream, or MP4 stream. _LR are low res verseions, _HR are high res. If CanRelay is 1, then this camera connects to the cs and you can also view the camera remotely using the Cs.

request_video: Request video from a camera

To view the video from the camera, open this URL:

https://cr1.mios.com/request_video?cam=a&format=b&res=c&user=d&pass=e

where a is the serial number of the camera, 554 in the above example, b is "mp4" or "mjpeg", c is the resolution and can be "low" or "med" or "high", d and e are the username/password of the MiOS account the camera is paired with.

This will return another URL. If the viewer is on the same home network as the camera the URL will point directly to the camera. Otherwise it will be a Url, for example http://209.160.41.93:80/relay_viewer?cam=554&pass=2024848122, which points to the Cs with a use-once token. In this case the URL can only be used one time, and must be used within 1 minute of making the request.

request_image: Request image from a camera

To fetch a JPEG that is the current image from the camera, open this URL:

https://cr1.mios.com/request_image?cam=a&res=b&user=c&pass=d

where a is the serial number of the camera, 554 in the above example, b is "low" or "med" or "high" to indicate the resolution, c and d are the username/password of the MiOS account the camera is paired with. Calling this with "low" is the right way to get at thumbnail. This URL returns the JPEG image directly.

archive_video: Tells the cs to archive video from the camera

This command causes the cs to capture video from the camera and add it to the video archive for the user. The camera must be linked to a mios.com account.

https://cr1.mios.com/archive_video?cam=a&preroll=b&duration=c&format=d&res=e&user=f&pass=g

where a is the serial number of the camera, 554 in the above example, b is 0 or 1 where 1 means to also capture whatever pre-roll is available from the camera, c is how long in seconds to capture the video, d is "mp4" or "mjpeg", e is "low" or "med" or "high" to indicate the resolution, f and g are the username/password of the MiOS account the camera is paired with.

The pre-roll is a given number of seconds at a given resolution as specified in the "config" command.

archive_image: Tells the cs to archive an image from the camera

This is like archive_video except it stores a single image. If retimg=1 then the image being archived will also be returned by the Url, just like request_image.

https://cr1.mios.com/archive_image?cam=a&res=b&user=c&pass=d&retimg=e

list_archives: The cs returns a list of archived images and video

https://cr1.mios.com/list_archives?cam=a&count=b&start=c&before=d&after=e&user=f&pass=g&rs=h

This returns a list of archives in JSON format as follows:

 {
   "rs": 1,
   "count": 2,
   "records": [
       {
           "id": 4,
           "date": "2011-07-31 22:43:33",
           "format": "mp4",
           "duration": 30
       },
       {
           "id": 5,
           "date": "2011-07-31 22:43:33",
           "format": "jpeg"
       }
   ]
 }

"rs" is a number indicating the recordset. "count" is the total number of rows. The "id" of a record is passed to fetch_archive


fetch_archive: The cs returns an archived image or video

https://cr1.mios.com/fetch_archive?id=a&user=b&pass=c

move_camera: Tells the cs to move the camera

https://cr1.mios.com/move_camera?cam=a&dir=b&user=c&pass=d

Where dir can be "up", "down", "left", "right", "in" or "out" (for zoom).

config: Sets a configuration setting on the camera

https://cr1.mios.com/config?cam=a&setting=b&value=c&user=d&pass=e

This sets the setting (b) to the value (c). The possible setting/values are:

brightness: 0-100 for brightness control
contract: 0-100 for contrast
Personal tools