Preview
Used to preview videos previously stored on camera's file system. Preview engine will send interleaved JPG and AAC audio streaming packets via port specified by client and by using streaming via TCP.
In it's POST request to camera client will request port (which should fall inside allowed range) and will start listening on that port. If port is valid and available, camera will connect to it and start sending the video stream. If port is not valid or not available, camera will respond with error status code. Also, if streaming is already active request to start new streaming will be rejected with 409 status code as described below. It's up to the client to manage proper stream start/stop.
Once connection is established, camera will start streaming interleaved video and audio packets in the following format:
Above packets have following meaning:
Packet | Description |
VH | Video header. Contains metadata about following video packet. |
JPEG | JPEG image payload. |
AH | Audio header. Contains metadata about following audio packet. |
AAC frame | AAC encoded frame payload. |
SOS | Start of Stream header. User to mark start of the video and doesn't have payload which follows it. |
EOS | End of Stream header. Used to mark end of the video and doesn't have payload which follows it. |
Furthermore, video header (VH) has following structure:
Data | Data type | Length (bytes) | Description |
version | integer | 4 | Version of the header. |
type | integer | 4 | Type of the header (0 for video). |
size | integer | 4 | Size of the JPEG image which follows this header. |
pts | integer | 4 | PTS (presentation time stamp) for the following frame. PTSs are delivered in 1/90000 time base and represents media time at which following content should be presented. |
status | integer | 4 | Bit addressable value containing various flags. Currently not used. |
Audio header (AH) field has following structure:
Data | Data type | Length (bytes) | Description |
version | integer | 4 | Version of the header. |
type | integer | 4 | Type of the header (1 for audio). |
size | integer | 4 | Size of the AAC frame which following this header. |
pts | integer | 4 | PTS (presentation time stamp) for the following frame. PTSs are delivered in 1/90000 time base and represents media time at which following content should be presented. |
status | integer | 4 | Bit addressable value containing various flags. Currently not used. |
Start of stream (SOS) header has following structure:
Data | Data type | Length (bytes) | Description |
version | integer | 4 | Version of the header. |
type | integer | 4 | Type of the header (127 for End Of Stream). |
reserved | N/A | 12 | Reserved space currently used for padding to make this header the same size as video and audio. |
End of stream (EOS) header has following structure:
Data | Data type | Length (bytes) | Description |
version | integer | 4 | Version of the header. |
type | integer | 4 | Type of the header (128 for End Of Stream). |
reserved | N/A | 12 | Reserved space currently used for padding to make this header the same size as video and audio. |
POST /api/<versionNumber>/preview
Format:
http://<baseURL>/api/<versionNumber>/preview
Example:
http://192.168.1.101/api/2/preview
Parameters
Parameter | Description | Req'd? | Type / Values |
---|---|---|---|
baseURL | Fixed address, Bandit acts like an access point with this addres. TomTom Bandit's WiFi has to be turned on. | Yes | 192.168.1.101 |
versionNumber | Service version number. The current value is 2. | Yes | 2 |
JSON Parameters:
Parameters in request body are defined in JSON object containing following fields:
Parameter | Description | Req'd? | Type |
id | Unique id of a video file which preview is requested. | Yes | string, max. 49 characters |
preview_active | Starts (true) or stops (false) preview streaming. Example value: true |
Yes | boolean |
preview_port | Specifies requested video streaming port. Allowed range is between 4010 and 4999, inclusive. Example value: 4015 |
Yes | integer |
[offset_secs] | Seconds from beginning of a video from which streaming should start. If omitted, it's assumed that preview starts from beginning of a video (offset_secs = 0). Example value: 4.5 |
No | float |
[length_secs] | Specifies length (in seconds) of requested streaming. If omitted, it's assumed that preview lasts until the end of a video. Example value: 10.2 |
No | float |
Description:
Connects to server socket opened by client and starts streaming interleaved video and audio packets. JPG images are delivered at 30fps and AAC audio packets are sent in between JPG frames as they are being recorded. Streaming starts at the point in video marked with 'offset_secs' and for 'length_secs'. Currently, JPG resolution will be set to 480p and frame rate to 30fps.
Response codes:
Code | Description |
200 | OK |
400 | Bad Request (wrong parameters: offset_secs+length_secs points to the data outside of a video, request port is out of range) |
404 | Not Found (file with requested id not found) |
409 | Conflict (streaming start request came in while streaming is already in progress) |
500 | Server Error (request can't be processed) |
Example request:
POST http://<span class="nolink"><span class="nolink"><span class="nolink"><span class="nolink"><span class="nolink">192.168.1.101</span></span></span></span></span>/api/2/preview
{ "id":"1236a33a-5375-4549-836b-d4ed00289586-100-000-001-0001", "preview_active":true, "preview_port":4015, "offset_secs":4.5, "length_secs":10.2 }