@4players/odin
Version:
A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects
45 lines (44 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.VideoInput = void 0;
const helpers_1 = require("../../utils/helpers");
/**
* Represents a video input media for use in applications that involve video
* communication or playback. The VideoInput class encapsulates a video capture
* source and provides access to its related MediaStream and custom type.
*/
class VideoInput {
constructor(capture) {
this.capture = capture;
this.kind = 'video-input';
}
get volume() {
// @ts-ignore
return this.capture.volume;
}
/**
* The MediaStream of the VideoInput that is sent to remote peers for video
* playback.
*
* @return {MediaStream} The MediaStream object if playback has been started.
* @throws {Error} Throws an error if the MediaStream is not available.
*/
get mediaStream() {
(0, helpers_1.assert)(this.capture.mediaStream, "Can't get the MediaStream, was the playback started?");
return this.capture.mediaStream;
}
/**
* The custom type helps to identify the purpose of the VideoInput.
* When adding the VideoInput to a room, the customType can be used by
* remote peers to understand the purpose of the stream.
*
* @return {string | undefined} The custom type value if available; otherwise, undefined.
*/
get customType() {
return this.capture.customType;
}
close() {
this.capture.close();
}
}
exports.VideoInput = VideoInput;