openvidu-node-client: individual stream recording

pull/203/head
pabloFuente 2019-01-18 20:59:27 +01:00
parent 864ffd8672
commit 7c9f8209d4
3 changed files with 57 additions and 27 deletions

View File

@ -124,7 +124,6 @@ export class OpenVidu {
* *
* @param sessionId The `sessionId` of the [[Session]] you want to start recording * @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`) * @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: * @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` * - `404`: no session exists for the passed `sessionId`
@ -143,6 +142,7 @@ export class OpenVidu {
data = JSON.stringify({ data = JSON.stringify({
session: sessionId, session: sessionId,
name: !!properties.name ? properties.name : '', name: !!properties.name ? properties.name : '',
outputMode: !!properties.outputMode ? properties.outputMode : '',
recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '', recordingLayout: !!properties.recordingLayout ? properties.recordingLayout : '',
customLayout: !!properties.customLayout ? properties.customLayout : '' customLayout: !!properties.customLayout ? properties.customLayout : ''
}); });
@ -150,6 +150,7 @@ export class OpenVidu {
data = JSON.stringify({ data = JSON.stringify({
session: sessionId, session: sessionId,
name: param2, name: param2,
outputMode: '',
recordingLayout: '', recordingLayout: '',
customLayout: '' customLayout: ''
}); });
@ -158,6 +159,7 @@ export class OpenVidu {
data = JSON.stringify({ data = JSON.stringify({
session: sessionId, session: sessionId,
name: '', name: '',
outputMode: '',
recordingLayout: '', recordingLayout: '',
customLayout: '' customLayout: ''
}); });

View File

@ -15,6 +15,7 @@
* *
*/ */
import { RecordingProperties } from './RecordingProperties';
import { RecordingLayout } from './RecordingLayout'; import { RecordingLayout } from './RecordingLayout';
/** /**
@ -52,32 +53,16 @@ export class Recording {
*/ */
url: string; 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 of the recording
*/ */
status: Recording.Status; status: Recording.Status;
/** /**
* Name of the Recording. The video file will be named after this property. * Technical properties of the recorded file
* You can access this same value in your clients on recording events
* (`recordingStarted`, `recordingStopped`)
*/ */
name: string; properties: RecordingProperties;
/**
* The layout used in this Recording
*/
recordingLayout: RecordingLayout;
/* tslint:disable:no-string-literal */ /* tslint:disable:no-string-literal */
/** /**
@ -90,11 +75,19 @@ export class Recording {
this.size = json['size']; this.size = json['size'];
this.duration = json['duration']; this.duration = json['duration'];
this.url = json['url']; this.url = json['url'];
this.hasAudio = json['hasAudio'];
this.hasVideo = json['hasVideo'];
this.status = json['status']; this.status = json['status'];
this.name = json['name']; this.properties = {
this.recordingLayout = json['recordingLayout']; 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 */ /* tslint:enable:no-string-literal */
} }
@ -133,4 +126,20 @@ export namespace Recording {
*/ */
failed failed
} }
/**
* See [[RecordingProperties.outputMode]]
*/
export enum OutputMode {
/**
* Record all streams in a grid layout in a single archive
*/
COMPOSED,
/**
* Record each stream individually
*/
INDIVIDUAL
}
} }

View File

@ -15,6 +15,7 @@
* *
*/ */
import { Recording } from './Recording';
import { RecordingLayout } from './RecordingLayout'; import { RecordingLayout } from './RecordingLayout';
/** /**
@ -23,19 +24,37 @@ import { RecordingLayout } from './RecordingLayout';
export interface RecordingProperties { 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`). * Name of the Recording. The video file will be named after this property.
* **WARNING: this parameter follows an overwriting policy.** If you name two recordings the same, the newest MP4 file will overwrite the oldest one * You can access this same value in your clients on recording events
* (`recordingStarted`, `recordingStopped`)
*/ */
name?: string; 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.<br>
* Will only have effect if [[RecordingProperties.outputMode]] is `COMPOSED`
*/ */
recordingLayout?: RecordingLayout; 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.<br>
* Will only have effect if [[RecordingProperties.outputMode]] is `COMPOSED` and [[RecordingProperties.recordingLayout]] is `CUSTOM`<br>
* See [Custom recording layouts](https://openvidu.io/docs/advanced-features/recording#custom-recording-layouts) to learn more * See [Custom recording layouts](https://openvidu.io/docs/advanced-features/recording#custom-recording-layouts) to learn more
*/ */
customLayout?: string; 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;
} }