UNPKG

@4players/odin

Version:

A cross-platform SDK enabling developers to integrate real-time VoIP chat technology into their projects

41 lines (40 loc) 1.39 kB
import { assert } from '../../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. */ export 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() { 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(); } }