/**
* STB object declaration and documentation.
* JSDoc specification ({@link http://usejsdoc.org/}).
* An introduction to JSDoc ({@link http://www.2ality.com/2011/08/jsdoc-intro.html}).
*
* @fileOverview Provides API for channel recording manager (PVR).
*/
'use strict';
/* jshint unused:false */
//noinspection JSUnusedGlobalSymbols
/**
* This object provides API for channel recording manager (PVR).
*
* Recording manager allows to schedule a task, which will record specified channel(stream) into local storage during the specified time range.
*
* pvrManager object does not need any additional initialization. It is always accessible from JavaScript context.
*
* It is allowed to record only channels that contain mpeg-ts stream. It can be multicast stream or stream from HTTP server.
*
* <br>
*
* Error codes table:
*
* Value | Description
* -------|-------------
* 0 | Operation successful.
* -1 | Bad argument.
* -2 | Not enough memory.
* -3 | Wrong recording range (start or end time). e.i. recording duration must be less or equal than 24 hours.
* -4 | Task with specified ID was not found.
* -5 | Wrong file name. Folder where you want to save recording must exist and begin with `/media/USB-...` or `/ram/media/USB-...`.
* -6 | Duplicate tasks. Recording with that file name already exists.
* -7 | Error opening stream URL.
* -8 | Error opening output file.
* -9 | Maximum number of simultaneous recording is exceeded. It does not mean task number but number of simultaneous recording. See also {@link pvrManager.SetMaxRecordingCnt}.
* -10 | Manager got end of stream and recording has finished earlier keeping the recorded file.
* -11 | Error writing output file. E.i. disk is full or has been disconnected during recording.
*
* <br>
*
* Task states table:
*
* Value | Description
* -------|-------------
* 1 | Waiting for a start of actual recording.
* 2 | Recording.
* 3 | Error occurred. Recording is stopped.
* 4 | Recording completed.
*
* @namespace
*/
var pvrManager = {
/**
* Information about specified task in **JSON** format.
*
* @typedef {string} pvrManager.TaskInfo
*
* @property {number} id unique task identifier
* @property {number} state current task state (see task state table)
* @property {number} errorCode error code (see error codes table)
* @property {string} fileName requested recording file name
* @property {string} url recorded stream address
* @property {string} startTime recording start time
* @property {string} endTime recording end time
*
* @example
* // parsed JSON data
* {
* "id": 1,
* "state": 0,
* "errorCode": 0,
* "filename": "/media/USB-1/1.ts",
* "url": "http://192.168.1.1/mpegts",
* "startTime": "3452344145",
* "endTime": "3452345345"
* }
*/
/**
* Change recording end time.
*
* @param {number} id task identifier
* @param {string} endTime new recording end time
*
* UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)
*
* @return {number} see error codes table
*/
ChangeEndTime:
function ( id, endTime ) { return 0; },
/**
* Schedule channel recording task.
*
* @param {string} url address of the stream that will be recorded (`http://...`, `rtp://...`, `udp://...`)
* @param {string} fileName full file name of recording (`/media/USB-...` or `/ram/media/USB-...`)
* @param {string} startTime recording start time
*
* UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)
*
* @param {string} endTime recording end time
*
* UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)
*
* @return {string} unique task identifier if operation was successful, otherwise return value is a string representing error code (<0) from error codes table
*
* @example
* // number of seconds since Epoch can be obtained via Date object
* var date = new Date();
* var startTime = date.getTime()/1000;
*/
CreateTask:
function ( url, fileName, startTime, endTime ) { return ''; },
/**
* Get the list of all tasks.
*
* See {@link pvrManager.TaskInfo}, {@link pvrManager.CreateTask}.
*
* @return {Array.<pvrManager.TaskInfo>} list of all recording tasks in **JSON** format
*/
GetAllTasks:
function () { return '[]'; },
/**
* Get task list by identifier list.
*
* See {@link pvrManager.TaskInfo}, {@link pvrManager.CreateTask}, {@link pvrManager.GetTaskByID}.
*
* @param {string} idList list of task identifiers in **JSON** format
*
* *signature:* `number[]`
*
* @return {Array.<pvrManager.TaskInfo>} list of all matched recording tasks in **JSON** format
*
* @example
* gSTB.GetTasksByIDs('[1,2]');
*/
GetTasksByIDs:
function ( idList ) { return ''; },
/**
* Get recording task by its identifier.
*
* See {@link pvrManager.GetTasksByIDs}.
*
* @param {string} id task identifier
*
* @return {pvrManager.TaskInfo} task data
*/
GetTaskByID:
function ( id ) { return ''; },
/**
* Remove recording task by its identifier.
*
* @param {string} id task identifier
* @param {number} removeType possible values:
*
* Value | Description
* -------|-------------
* 0 | do not remove any files
* 1 | if temporary file exists, rename it into resulting file
* 2 | remove only temporary file, if it exists
* 3 | remove both temporary and resulting files
*/
RemoveTask:
function ( id, removeType ) {},
/**
* Set maximum number of simultaneous recording.
*
* @param {number} maxCnt maximum number of simultaneous recording
*/
SetMaxRecordingCnt:
function ( maxCnt ) {}
};