Home Reference Source

src/calls/CallRemoteRecorder.js

import {EventEmitter} from '../eventemitter';

/**
 * This class creates an instances that can indicate to the WAC
 * when he has to start/stop a recording using the source specified
 * by param
 */
export class CallRemoteRecorder extends EventEmitter {
	constructor(wacProxy, idCall) {
		super();
		this._wacproxy = wacProxy;
		this._callId = idCall;
	}

	/**
	 * Start a recording of a call and save it in
	 * a file called "filename"
	 *
	 * @param  {String} filename Name file to save the recording
	 * @return {Promise} Resolved promise if success
	 */
	start(filename) {
		return this._wacproxy.startRecording(this._callId, filename);
	}

	/**
	 * Stop a recording of a call
	 *
	 * @return {Promise} Resolved promise if success
	 */
	stop() {
		return this._wacproxy.stopRecording(this._callId);
	}

	pause() {
		throw Error('Not implemented');
	}

	/**
	 * Retrieve info about recordings
	 *
	 * @return {Promise<Array>} A list of recordings if success
	 */
	getRecordings() {
		const filter = {};
		filter.callIdWAC = this._callId;
		return this._wacproxy.getRecordings(filter);
	}
}