UNPKG

@millicast/sdk-interactivity

Version:

Dolby Millicast Interactivity SDK

112 lines 4.31 kB
import { View } from '@millicast/sdk'; import { EventEmitter } from 'events'; import { ConnectOptions, PublishOptions, StreamInformation, WatchOptions } from './types/options'; import { RoomEvents } from './types/roomEvents'; import { Publisher } from './publisher'; import { PublishedSource } from './publishedSource'; export interface Room { /** * Adds the `listener` function to the end of the listeners array for the * event named `eventName`. No checks are made to see if the `listener` has * already been added. Multiple calls passing the same combination of `eventName`and `listener` will result in the `listener` being added, and called, multiple * times. * * Returns a reference to the `EventEmitter`, so that calls can be chained. * @param eventName The name of the event. * @param listener The callback function. */ on<N extends keyof RoomEvents>(eventName: N, listener: RoomEvents[N]): this; /** @hidden */ emit<N extends keyof RoomEvents>(eventName: N, ...args: Parameters<RoomEvents[N]>): boolean; } /** * Representation of a stream. This class is the starting point for the SDK. * Create a instance of this class, connect to the Dolby Millicast platform and start receiving & publishing streams. * * @example * ```ts * import { Room } from '@millicast/sdk-interactivity'; * * const room = new Room({ * streamName, * streamAccountId, * }); * * // Start publishing to the stream and listen to the available sources * await room.connect({ * publisherName, * publishToken, * constraints: { * audio: true, * video: true, * }, * }); * ``` */ export declare class Room extends EventEmitter implements Room { #private; /** * Gets the Millicast {@link !View View} object once the SDK has been initialized. */ get viewer(): View; /** * Gets the list of {@link Publisher} objects that are currently publishing a stream. */ get publishers(): Array<Publisher>; /** * Gets the list of {@link PublishedSource} objects that are currently published to the stream from the local device. */ get publishedSources(): Array<PublishedSource>; /** Maximum number of sources that can be published from a single client. */ readonly MAX_SOURCES: number; /** * Create an instance of the {@link Room} class. * * @param streamInfo Information about the stream to connect to. */ constructor(streamInfo: StreamInformation); private onBroadcastEvent; /** * Connects to the stream. This function will publish a stream and listen to the sources. * * @param options Options to connect to the stream. * * @returns A {@link !Promise Promise} whose fulfillment handler receives a {@link PublishedSource} object when the source has successfully been published to the platform. */ connect: (options: ConnectOptions) => Promise<PublishedSource>; /** * Start watching the stream. * * @param options Additional options to watch to the stream. */ watch: (options?: WatchOptions) => Promise<void>; /** * Publishes a video / audio feed to a stream. * * @param options Information about the stream to publish to. * * @returns A {@link !Promise Promise} whose fulfillment handler receives a {@link PublishedSource} object when the source has successfully been published to the platform. * * @throws {@link !Error Error} if you have not set the `publisherName` when connecting to the stream. * @throws {@link !Error Error} if you've reached the maximum number of sources that can be published from a single publisher. */ publish: (options: PublishOptions) => Promise<PublishedSource>; /** * Stops publishing the source to the stream. * * @param publishedSource Source that's currently being published. */ unpublish: (publishedSource: PublishedSource) => void; /** * Leaves the stream. Will stop publishing into the stream and will stop listening to it. * * _Note_, the audio / video stream will be stopped to release allocated resources. * * @example * ```js * room.leave(); * ``` */ leave: () => void; } //# sourceMappingURL=room.d.ts.map