/// import { EventEmitter } from 'events'; export declare type StreamTrackType = 'audio' | 'video'; export declare type StreamTrackSelection = StreamTrackType | 'both'; /** * @module rtc */ /** * A wrapper around an HTML5 MediaStream * @class rtc.Stream * * @constructor * @param {RTCDataStream} stream The native stream */ export declare class Stream extends EventEmitter { stream: MediaStream; trackChangeCb: () => void; /** * Emitted when tracks are muted or unmuted. Only triggered when changes are * made through this objects mute functions. * @event mute_changed * @param {'audio' | 'video' | 'both'} type The type of tracks which changed * @param {Boolean} muted `true` if tracks were muted, `false` if they were unmuted */ constructor(stream: MediaStream); setStream(stream: MediaStream): void; /** * Get the id of the stream. This is neither user defined nor human readable. * @method id * @return {String} The id of the underlying stream */ id(): string; /** * Checks whether the stream has any tracks of the given type * @method hasTracks * @param {'audio' | 'video' | 'both'} [type='both'] The type of track to check for * @return {Number} The amount of tracks of the given type */ hasTracks(type: StreamTrackSelection): number; /** * Gets the tracks of the given type * @method getTracks * @param {'audio' | 'video' | 'both'} [type='both'] The type of tracks to get * @return {Array} An Array of the tracks */ getTracks(type: StreamTrackSelection): MediaStreamTrack[]; /** * Checks whether a type of track is muted. If there are no tracks of the * specified type they will be considered muted * @param {'audio' | 'video' | 'both'} [type='audio'] The type of tracks * @return {Boolean} Whether the tracks are muted */ muted(type?: StreamTrackSelection): boolean; /** * Mutes or unmutes tracks of the stream * @method mute * @param {Boolean} [muted=true] Mute on `true` and unmute on `false` * @param {'audio' | 'video' | 'both'} [type='audio'] The type of tracks to mute or unmute * @return {Boolean} Whether the tracks were muted or unmuted */ mute(muted?: boolean, type?: StreamTrackSelection): boolean; /** * Toggles the mute state of tracks of the stream * @method toggleMute * @param {'audio' | 'video' | 'both'} [type='audio'] The type of tracks to mute or unmute * @return {Boolean} Whether the tracks were muted or unmuted */ toggleMute(type?: StreamTrackSelection): boolean; /** * Stops the stream * @method stop */ stop(): void; /** * Clones the stream. You can change both streams independently, for example * mute tracks. You will have to `stop()` both streams individually when you * are done. * * This is currently not supported in Firefox and expected to be implemented * in version 47. Use `Stream.canClone()` to check whether cloning is supported by * your browser. * * @method clone * @return {rtc.Stream} A clone of the stream */ clone(): Stream; /** * Checks whether cloning stream is supported by the browser. See `clone()` * for details * @static * @method canClone * @return {Boolean} `true` if cloning is supported, `false` otherwise */ static canClone(): boolean; /** * Creates a stream using `getUserMedia()` * @method createStream * @static * @param {Object} [config={audio: true, video: true}] The configuration to pass to `getUserMedia()` * @return {Promise -> rtc.Stream} Promise to the stream * * @example * var stream = rtc.Stream.createStream({audio: true, video: false}); * rtc.MediaDomElement($('video'), stream); */ static createStream(config?: MediaStreamConstraints): Promise; }