pvrManager

pvrManager

Tutorials:

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.


Error codes table:

Value Description
0 Operation successful.
-1 Bad argument.
-2 Not enough memory.
-3 Recording range setting error (start or end time, state). 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 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.

Task states table:

Value Description
1 Waiting for a start of actual recording.
2 Recording.
3 Error occurred. Recording is stopped.
4 Recording completed.

Methods

(static) ChangeEndTime(id, endTime) → {number}

Change recording end time.

Affects only tasks with waiting and recording statuses, otherwise gives -3 error code.

Parameters:
Name Type Description
id number

task identifier

endTime string

new recording end time

UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)

Returns:

see error codes table

Type
number

(static) CreateTask(url, fileName, startTime, endTime) → {string}

Schedule channel recording task.

Example
// number of seconds since Epoch can be obtained via Date object
var date = new Date();
var startTime = date.getTime()/1000;
Parameters:
Name Type Description
url string

address of the stream that will be recorded (http://..., rtp://..., udp://...)

fileName string

full file name of recording (/media/USB-... or /ram/media/USB-...)

startTime string

recording start time

UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)

endTime string

recording end time

UTC time in "YYYYMMDDThhmmss" format or number of seconds since Epoch (1970/01/01 UTC)

Returns:

unique task identifier if operation was successful, otherwise return value is a string representing error code (<0) from error codes table

Type
string

(static) GetAllTasks() → {Array.<pvrManager.TaskInfo>}

Get the list of all tasks.

See pvrManager.TaskInfo, pvrManager.CreateTask.

Returns:

list of all recording tasks in JSON format

Type
Array.<pvrManager.TaskInfo>

(static) GetTasksByIDs(idList) → {Array.<pvrManager.TaskInfo>}

Get task list by identifier list.

See pvrManager.TaskInfo, pvrManager.CreateTask, pvrManager.GetTaskByID.

Example
gSTB.GetTasksByIDs('[1,2]');
Parameters:
Name Type Description
idList string

list of task identifiers in JSON format

signature: number[]

Returns:

list of all matched recording tasks in JSON format

Type
Array.<pvrManager.TaskInfo>

(static) GetTaskByID(id) → {pvrManager.TaskInfo}

Get recording task by its identifier.

See pvrManager.GetTasksByIDs.

Parameters:
Name Type Description
id number

task identifier

Returns:

task data

Type
pvrManager.TaskInfo

(static) RemoveTask(id, removeType)

Remove recording task by its identifier.

Parameters:
Name Type Description
id number

task identifier

removeType number

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

(static) SetMaxRecordingCnt(maxCnt)

Set maximum number of simultaneous recording.

Parameters:
Name Type Description
maxCnt number

maximum number of simultaneous recording

Type Definitions

TaskInfo

Properties:
Name Type Description
id number

unique task identifier

state number

current task state (see task state table)

errorCode number

error code (see error codes table)

fileName string

requested recording file name

url string

recorded stream address

startTime string

recording start time (number of seconds since Epoch (1970/01/01 UTC))

endTime string

recording end time (number of seconds since Epoch (1970/01/01 UTC))

Information about specified task in JSON format.

Type:
  • string
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"
}