From 7c9f8209d4ad69e77f346734a9cfca88882e4555 Mon Sep 17 00:00:00 2001 From: pabloFuente Date: Fri, 18 Jan 2019 20:59:27 +0100 Subject: [PATCH] openvidu-node-client: individual stream recording --- openvidu-node-client/src/OpenVidu.ts | 4 +- openvidu-node-client/src/Recording.ts | 53 +++++++++++-------- .../src/RecordingProperties.ts | 27 ++++++++-- 3 files changed, 57 insertions(+), 27 deletions(-) diff --git a/openvidu-node-client/src/OpenVidu.ts b/openvidu-node-client/src/OpenVidu.ts index ed091594..8178b653 100644 --- a/openvidu-node-client/src/OpenVidu.ts +++ b/openvidu-node-client/src/OpenVidu.ts @@ -124,7 +124,6 @@ export class OpenVidu { * * @param sessionId The `sessionId` of the [[Session]] you want to start recording * @param name The name you want to give to the video file. You can access this same value in your clients on recording events (`recordingStarted`, `recordingStopped`) - * **WARNING: this parameter follows an overwriting policy.** If you name two recordings the same, the newest MP4 file will overwrite the oldest one * * @returns A Promise that is resolved to the [[Recording]] if it successfully started (the recording can be stopped with guarantees) and rejected with an Error object if not. This Error object has as `message` property with the following values: * - `404`: no session exists for the passed `sessionId` @@ -143,6 +142,7 @@ export class OpenVidu { data = JSON.stringify({ session: sessionId, name: !!properties.name ? properties.name : '', + outputMode: !!properties.outputMode ? properties.outputMode : '', recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '', customLayout: !!properties.customLayout ? properties.customLayout : '' }); @@ -150,6 +150,7 @@ export class OpenVidu { data = JSON.stringify({ session: sessionId, name: param2, + outputMode: '', recordingLayout: '', customLayout: '' }); @@ -158,6 +159,7 @@ export class OpenVidu { data = JSON.stringify({ session: sessionId, name: '', + outputMode: '', recordingLayout: '', customLayout: '' }); diff --git a/openvidu-node-client/src/Recording.ts b/openvidu-node-client/src/Recording.ts index bb605348..6d938cef 100644 --- a/openvidu-node-client/src/Recording.ts +++ b/openvidu-node-client/src/Recording.ts @@ -15,6 +15,7 @@ * */ +import { RecordingProperties } from './RecordingProperties'; import { RecordingLayout } from './RecordingLayout'; /** @@ -52,32 +53,16 @@ export class Recording { */ url: string; - /** - * `true` if the recording has an audio track, `false` otherwise (currently fixed to true) - */ - hasAudio = true; - - /** - * `true` if the recording has a video track, `false` otherwise (currently fixed to true) - */ - hasVideo = true; - /** * Status of the recording */ status: Recording.Status; /** - * Name of the Recording. The video file will be named after this property. - * You can access this same value in your clients on recording events - * (`recordingStarted`, `recordingStopped`) + * Technical properties of the recorded file */ - name: string; + properties: RecordingProperties; - /** - * The layout used in this Recording - */ - recordingLayout: RecordingLayout; /* tslint:disable:no-string-literal */ /** @@ -90,11 +75,19 @@ export class Recording { this.size = json['size']; this.duration = json['duration']; this.url = json['url']; - this.hasAudio = json['hasAudio']; - this.hasVideo = json['hasVideo']; this.status = json['status']; - this.name = json['name']; - this.recordingLayout = json['recordingLayout']; + this.properties = { + name: !!(json['name']) ? json['name'] : this.id, + outputMode: !!(json['outputMode']) ? json['outputMode'] : Recording.OutputMode.COMPOSED, + hasAudio: !!(json['hasAudio']), + hasVideo: !!json['hasVideo'] + }; + if (this.properties.outputMode.toString() === Recording.OutputMode[Recording.OutputMode.COMPOSED]) { + this.properties.recordingLayout = !!(json['recordingLayout']) ? json['recordingLayout'] : RecordingLayout.BEST_FIT; + if (this.properties.recordingLayout.toString() === RecordingLayout[RecordingLayout.CUSTOM]) { + this.properties.customLayout = json['customLayout']; + } + } } /* tslint:enable:no-string-literal */ } @@ -133,4 +126,20 @@ export namespace Recording { */ failed } + + /** + * See [[RecordingProperties.outputMode]] + */ + export enum OutputMode { + + /** + * Record all streams in a grid layout in a single archive + */ + COMPOSED, + + /** + * Record each stream individually + */ + INDIVIDUAL + } } \ No newline at end of file diff --git a/openvidu-node-client/src/RecordingProperties.ts b/openvidu-node-client/src/RecordingProperties.ts index 247e4c60..e645da2b 100644 --- a/openvidu-node-client/src/RecordingProperties.ts +++ b/openvidu-node-client/src/RecordingProperties.ts @@ -15,6 +15,7 @@ * */ +import { Recording } from './Recording'; import { RecordingLayout } from './RecordingLayout'; /** @@ -23,19 +24,37 @@ import { RecordingLayout } from './RecordingLayout'; export interface RecordingProperties { /** - * The name you want to give to the video file. You can access this same value in your clients on recording events (`recordingStarted`, `recordingStopped`). - * **WARNING: this parameter follows an overwriting policy.** If you name two recordings the same, the newest MP4 file will overwrite the oldest one + * Name of the Recording. The video file will be named after this property. + * You can access this same value in your clients on recording events + * (`recordingStarted`, `recordingStopped`) */ name?: string; /** - * The layout to be used in the recording + * The mode of recording: COMPOSED for a single archive in a grid layout or INDIVIDUAL for one archive for each stream + */ + outputMode?: Recording.OutputMode; + + /** + * The layout to be used in the recording.
+ * Will only have effect if [[RecordingProperties.outputMode]] is `COMPOSED` */ recordingLayout?: RecordingLayout; /** - * If [[recordingLayout]] is `CUSTOM`, the relative path to the specific custom layout you want to use. + * The relative path to the specific custom layout you want to use.
+ * Will only have effect if [[RecordingProperties.outputMode]] is `COMPOSED` and [[RecordingProperties.recordingLayout]] is `CUSTOM`
* See [Custom recording layouts](https://openvidu.io/docs/advanced-features/recording#custom-recording-layouts) to learn more */ customLayout?: string; + + /** + * Whether or not to record the audio track (currently fixed to true) + */ + hasAudio: boolean; + + /** + * Whether or not to record the video track (currently fixed to true) + */ + hasVideo: boolean; } \ No newline at end of file