2018-04-18 14:29:07 +02:00
|
|
|
/*
|
2020-02-04 11:25:54 +01:00
|
|
|
* (C) Copyright 2017-2020 OpenVidu (https://openvidu.io)
|
2018-04-18 14:29:07 +02:00
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2019-01-18 20:59:27 +01:00
|
|
|
import { RecordingProperties } from './RecordingProperties';
|
2018-04-23 11:06:16 +02:00
|
|
|
import { RecordingLayout } from './RecordingLayout';
|
2018-04-20 12:04:56 +02:00
|
|
|
|
2018-07-22 22:13:45 +02:00
|
|
|
/**
|
|
|
|
* See [[OpenVidu.startRecording]]
|
|
|
|
*/
|
2018-04-18 10:39:39 +02:00
|
|
|
export class Recording {
|
2018-03-14 18:48:29 +01:00
|
|
|
|
2018-04-24 15:42:23 +02:00
|
|
|
/**
|
|
|
|
* Recording unique identifier
|
|
|
|
*/
|
|
|
|
id: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Session associated to the recording
|
|
|
|
*/
|
|
|
|
sessionId: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Time when the recording started in UTC milliseconds
|
|
|
|
*/
|
|
|
|
createdAt: number;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Size of the recording in bytes (0 until the recording is stopped)
|
|
|
|
*/
|
|
|
|
size = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Duration of the recording in seconds (0 until the recording is stopped)
|
|
|
|
*/
|
|
|
|
duration = 0;
|
|
|
|
|
|
|
|
/**
|
2020-04-17 18:45:46 +02:00
|
|
|
* URL of the recording. You can access the file from there. It is `null` until recording reaches "ready" or "failed" status. If OpenVidu Server configuration property `OPENVIDU_RECORDING_PUBLIC_ACCESS` is false, this path will be secured with OpenVidu credentials
|
2018-04-24 15:42:23 +02:00
|
|
|
*/
|
|
|
|
url: string;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Status of the recording
|
|
|
|
*/
|
|
|
|
status: Recording.Status;
|
|
|
|
|
|
|
|
/**
|
2019-01-18 20:59:27 +01:00
|
|
|
* Technical properties of the recorded file
|
2018-04-24 15:42:23 +02:00
|
|
|
*/
|
2019-01-18 20:59:27 +01:00
|
|
|
properties: RecordingProperties;
|
2018-04-24 15:42:23 +02:00
|
|
|
|
2018-03-14 18:48:29 +01:00
|
|
|
|
2018-04-23 11:06:16 +02:00
|
|
|
/* tslint:disable:no-string-literal */
|
2018-07-22 22:13:45 +02:00
|
|
|
/**
|
|
|
|
* @hidden
|
|
|
|
*/
|
2018-03-14 18:48:29 +01:00
|
|
|
constructor(json: JSON) {
|
|
|
|
this.id = json['id'];
|
|
|
|
this.sessionId = json['sessionId'];
|
|
|
|
this.createdAt = json['createdAt'];
|
|
|
|
this.size = json['size'];
|
|
|
|
this.duration = json['duration'];
|
|
|
|
this.url = json['url'];
|
|
|
|
this.status = json['status'];
|
2019-01-18 20:59:27 +01:00
|
|
|
this.properties = {
|
2021-04-09 17:32:33 +02:00
|
|
|
name: (json['name'] != null) ? json['name'] : this.id,
|
|
|
|
hasAudio: (json['hasAudio'] != null) ? !!json['hasAudio'] : Recording.DefaultRecordingPropertiesValues.hasAudio,
|
|
|
|
hasVideo: (json['hasVideo'] != null) ? !!json['hasVideo'] : Recording.DefaultRecordingPropertiesValues.hasVideo,
|
|
|
|
outputMode: (json['outputMode'] != null) ? json['outputMode'] : Recording.DefaultRecordingPropertiesValues.outputMode,
|
|
|
|
mediaNode: json['mediaNode']
|
2019-01-18 20:59:27 +01:00
|
|
|
};
|
2021-04-09 17:32:33 +02:00
|
|
|
if ((this.properties.outputMode.toString() === Recording.OutputMode[Recording.OutputMode.COMPOSED]
|
|
|
|
|| this.properties.outputMode.toString() === Recording.OutputMode[Recording.OutputMode.COMPOSED_QUICK_START])
|
|
|
|
&& this.properties.hasVideo) {
|
|
|
|
this.properties.recordingLayout = (json['recordingLayout'] != null) ? json['recordingLayout'] : Recording.DefaultRecordingPropertiesValues.recordingLayout;
|
|
|
|
this.properties.resolution = (json['resolution'] != null) ? json['resolution'] : Recording.DefaultRecordingPropertiesValues.resolution;
|
|
|
|
this.properties.frameRate = (json['frameRate'] != null) ? Number(json['frameRate']) : Recording.DefaultRecordingPropertiesValues.frameRate;
|
|
|
|
this.properties.shmSize = (json['shmSize'] != null) ? Number(json['shmSize']) : Recording.DefaultRecordingPropertiesValues.shmSize;
|
2019-01-18 20:59:27 +01:00
|
|
|
if (this.properties.recordingLayout.toString() === RecordingLayout[RecordingLayout.CUSTOM]) {
|
2021-04-09 17:32:33 +02:00
|
|
|
this.properties.customLayout = (json['customLayout'] != null) ? json['customLayout'] : '';
|
2019-01-18 20:59:27 +01:00
|
|
|
}
|
|
|
|
}
|
2021-05-11 13:00:08 +02:00
|
|
|
if (this.properties.outputMode.toString() === Recording.OutputMode[Recording.OutputMode.INDIVIDUAL]) {
|
|
|
|
this.properties.ignoreFailedStreams = (json['ignoreFailedStreams'] != null) ? !!json['ignoreFailedStreams'] : Recording.DefaultRecordingPropertiesValues.ignoreFailedStreams;
|
|
|
|
}
|
2018-03-14 18:48:29 +01:00
|
|
|
}
|
2018-04-23 11:06:16 +02:00
|
|
|
/* tslint:enable:no-string-literal */
|
2018-03-14 18:48:29 +01:00
|
|
|
}
|
|
|
|
|
2018-04-18 10:39:39 +02:00
|
|
|
export namespace Recording {
|
2018-07-22 22:13:45 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See [[Recording.status]]
|
|
|
|
*/
|
2018-03-14 18:48:29 +01:00
|
|
|
export enum Status {
|
2018-04-25 11:03:30 +02:00
|
|
|
|
|
|
|
/**
|
2019-06-27 14:04:02 +02:00
|
|
|
* The recording is starting (cannot be stopped). Some recording may not go
|
2020-10-02 16:40:03 +02:00
|
|
|
* through this status and directly reach "started" status
|
2018-04-25 11:03:30 +02:00
|
|
|
*/
|
2019-01-20 18:13:34 +01:00
|
|
|
starting = 'starting',
|
2018-04-25 11:03:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The recording has started and is going on
|
|
|
|
*/
|
2019-01-20 18:13:34 +01:00
|
|
|
started = 'started',
|
2018-04-25 11:03:30 +02:00
|
|
|
|
|
|
|
/**
|
2020-10-02 16:40:03 +02:00
|
|
|
* The recording has stopped and is being processed. At some point it will reach
|
|
|
|
* "ready" status
|
|
|
|
*/
|
2019-06-27 14:04:02 +02:00
|
|
|
stopped = 'stopped',
|
2019-06-19 17:45:54 +02:00
|
|
|
|
2018-04-25 11:03:30 +02:00
|
|
|
/**
|
2020-10-02 16:40:03 +02:00
|
|
|
* The recording has finished being processed and is available for download through
|
|
|
|
* property [[Recording.url]]
|
2018-04-25 11:03:30 +02:00
|
|
|
*/
|
2019-06-27 14:04:02 +02:00
|
|
|
ready = 'ready',
|
2018-04-25 11:03:30 +02:00
|
|
|
|
|
|
|
/**
|
2019-06-27 14:04:02 +02:00
|
|
|
* The recording has failed. This status may be reached from "starting",
|
2020-10-02 16:40:03 +02:00
|
|
|
* "started" and "stopped" status
|
2018-04-25 11:03:30 +02:00
|
|
|
*/
|
2019-01-20 18:13:34 +01:00
|
|
|
failed = 'failed'
|
2018-03-14 18:48:29 +01:00
|
|
|
}
|
2019-01-18 20:59:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* See [[RecordingProperties.outputMode]]
|
|
|
|
*/
|
|
|
|
export enum OutputMode {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Record all streams in a grid layout in a single archive
|
|
|
|
*/
|
2019-01-20 18:13:34 +01:00
|
|
|
COMPOSED = 'COMPOSED',
|
2020-10-02 16:40:03 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Works the same way as COMPOSED mode, but the necessary recorder
|
|
|
|
* service module will start some time in advance and won't be terminated
|
|
|
|
* once a specific session recording has ended. This module will remain
|
|
|
|
* up and running as long as the session remains active.
|
|
|
|
*
|
|
|
|
* - **Pros vs COMPOSED**: the process of starting the recording will be noticeably
|
|
|
|
* faster. This can be very useful in use cases where a session needs to be
|
|
|
|
* recorded multiple times over time, when a better response time is usually
|
|
|
|
* desirable.
|
|
|
|
|
|
|
|
* - **Cons vs COMPOSED**: for every session initialized with COMPOSED_QUICK_START
|
|
|
|
* recording output mode, extra CPU power will be required in OpenVidu Server.
|
|
|
|
* The recording module will be continuously rendering all of the streams being
|
|
|
|
* published to the session even when the session is not being recorded. And that
|
|
|
|
* is for every session configured with COMPOSED_QUICK_START.
|
|
|
|
*/
|
2020-07-01 14:02:32 +02:00
|
|
|
COMPOSED_QUICK_START = 'COMPOSED_QUICK_START',
|
2019-01-18 20:59:27 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Record each stream individually
|
|
|
|
*/
|
2019-01-20 18:13:34 +01:00
|
|
|
INDIVIDUAL = 'INDIVIDUAL'
|
2019-01-18 20:59:27 +01:00
|
|
|
}
|
2021-04-09 17:32:33 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @hidden
|
|
|
|
*/
|
|
|
|
export class DefaultRecordingPropertiesValues {
|
|
|
|
static readonly hasAudio: boolean = true;
|
|
|
|
static readonly hasVideo: boolean = true;
|
|
|
|
static readonly outputMode: Recording.OutputMode = Recording.OutputMode.COMPOSED;
|
|
|
|
static readonly recordingLayout: RecordingLayout = RecordingLayout.BEST_FIT;
|
|
|
|
static readonly resolution: string = "1280x720";
|
|
|
|
static readonly frameRate: number = 25;
|
|
|
|
static readonly shmSize: number = 536870912;
|
2021-05-11 13:00:08 +02:00
|
|
|
static readonly ignoreFailedStreams: boolean = false;
|
2021-04-09 17:32:33 +02:00
|
|
|
}
|
|
|
|
|
2018-03-14 18:48:29 +01:00
|
|
|
}
|