Namespace: pvrManager

pvrManager

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 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 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

ChangeEndTime

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

Change recording end time.

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:
Type Description

number

see error codes table

CreateTask

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

Schedule channel recording task.

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:
Type Description

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;

GetAllTasks

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

Get the list of all tasks.

See pvrManager.TaskInfo, pvrManager.CreateTask.

Returns:
Type Description

Array.<pvrManager.TaskInfo>

list of all recording tasks in JSON format

GetTaskByID

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

Get recording task by its identifier.

See pvrManager.GetTasksByIDs.

Parameters:
Name Type Description

id

string

task identifier

Returns:
Type Description

pvrManager.TaskInfo

task data

GetTasksByIDs

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

Get task list by identifier list.

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

Parameters:
Name Type Description

idList

string

list of task identifiers in JSON format

signature: number[]

Returns:
Type Description

Array.<pvrManager.TaskInfo>

list of all matched recording tasks in JSON format

Example

gSTB.GetTasksByIDs('[1,2]');

RemoveTask

<static> RemoveTask ( id, removeType )

Remove recording task by its identifier.

Parameters:
Name Type Description

id

string

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

SetMaxRecordingCnt

<static> SetMaxRecordingCnt ( maxCnt )

Set maximum number of simultaneous recording.

Parameters:
Name Type Description

maxCnt

number

maximum number of simultaneous recording

Type Definitions

TaskInfo

TaskInfo

Information about specified task in JSON format.

Type:
  • string

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

endTime

string

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"
}