UNPKG

@skyway-sdk/core

Version:

The official Next Generation JavaScript SDK for SkyWay

195 lines 8.09 kB
import { type Event, type SkyWayError } from '@skyway-sdk/common'; import type { PersonInit, SkyWayChannelImpl } from '../../channel'; import type { SkyWayContext } from '../../context'; import type { AnalyticsSession } from '../../external/analytics'; import type { IceManager } from '../../external/ice'; import type { SignalingSession } from '../../external/signaling'; import type { Codec, EncodingParameters } from '../../media'; import type { LocalStream, RemoteAudioStream, RemoteDataStream, RemoteVideoStream } from '../../media/stream'; import { MemberImpl } from '../../member'; import { type Publication, type PublicationType } from '../../publication'; import type { Subscription } from '../../subscription'; import type { Person } from '../person'; export * from './adapter'; export * from './factory'; export interface LocalPerson extends Person { /**@internal */ readonly keepaliveIntervalSec?: number | null; /** * @description [japanese] このPersonがStreamをPublishしたときに発火するイベント */ readonly onStreamPublished: Event<{ publication: Publication; }>; /** * @description [japanese] このPersonがStreamをUnpublishしたときに発火するイベント */ readonly onStreamUnpublished: Event<{ publication: Publication; }>; /**@description [japanese] このPersonのPublicationの数が変化したときに発火するイベント */ readonly onPublicationListChanged: Event<void>; /** * @description [japanese] このPersonがStreamをSubscribeしたときに発火するイベント */ readonly onPublicationSubscribed: Event<{ subscription: Subscription; stream: RemoteVideoStream | RemoteAudioStream | RemoteDataStream; }>; /** * @description [japanese] このPersonがStreamをUnsubscribeしたときに発火するイベント */ readonly onPublicationUnsubscribed: Event<{ subscription: Subscription; }>; /**@description [japanese] このPersonのSubscriptionの数が変化したときに発火するイベント */ readonly onSubscriptionListChanged: Event<void>; /** * @description [japanese] 回復不能なエラー。このインスタンスは継続して利用できない。 */ readonly onFatalError: Event<SkyWayError>; /** * @description [japanese] StreamをPublishする */ publish: <T extends LocalStream = LocalStream>(stream: T, options?: PublicationOptions) => Promise<Publication<T>>; /** * @description [japanese] StreamのPublicationをUnpublishする */ unpublish: (publication: string | Publication) => Promise<void>; /** * @description [japanese] StreamのPublicationをSubscribeする */ subscribe: <T extends RemoteDataStream | RemoteAudioStream | RemoteVideoStream>(publication: string | Publication, options?: SubscriptionOptions) => Promise<{ subscription: Subscription<T>; stream: T; }>; /** * @description [japanese] StreamのSubscriptionをUnsubscribeする */ unsubscribe: (subscription: string | Subscription) => Promise<void>; } /**@internal */ export declare class LocalPersonImpl extends MemberImpl implements LocalPerson { private args; readonly type: "person"; readonly subtype: "person"; readonly side: "local"; ttlSec?: number; readonly keepaliveIntervalSec: number | undefined; readonly keepaliveIntervalGapSec: number | undefined; readonly preventAutoLeaveOnBeforeUnload: boolean | undefined; readonly disableSignaling: boolean | undefined; readonly disableAnalytics: boolean | undefined; readonly config: import("../..").ContextConfig; readonly onStreamPublished: Event<{ publication: Publication; }>; readonly onStreamUnpublished: Event<{ publication: Publication; }>; readonly onPublicationListChanged: Event<void>; readonly onPublicationSubscribed: Event<{ subscription: Subscription; stream: RemoteVideoStream | RemoteAudioStream | RemoteDataStream; }>; readonly onPublicationUnsubscribed: Event<{ subscription: Subscription; }>; readonly onSubscriptionListChanged: Event<void>; readonly onFatalError: Event<SkyWayError<Record<string, any>>>; private readonly _onStreamSubscribeFailed; /**@private */ readonly _onDisposed: Event<void>; private _disposer; private readonly _publishingAgent; private readonly _subscribingAgent; private ttlInterval?; private _subscribing; private _requestQueue; /**@private */ readonly iceManager: IceManager; /**@private */ readonly _signaling?: SignalingSession; /**@private */ readonly _analytics?: AnalyticsSession; /**@private */ _disposed: boolean; static Create(...args: ConstructorParameters<typeof LocalPersonImpl>): Promise<LocalPersonImpl>; /**@private */ constructor(args: { channel: SkyWayChannelImpl; signaling?: SignalingSession; analytics?: AnalyticsSession; name?: string; id: string; metadata?: string; iceManager: IceManager; context: SkyWayContext; } & PersonInit); private _listenChannelEvent; /**@throws {@SkyWayError} */ private _setupTtlTimer; private _listenBeforeUnload; /**@throws {@link SkyWayError} */ private _handleOnPublicationSubscribe; /**@throws {@link SkyWayError} */ private _handleOnPublicationUnsubscribe; /**@throws {@link SkyWayError} */ publish<T extends LocalStream>(stream: T, options?: PublicationOptions): Promise<Publication<T>>; private _handleOnStreamPublish; /**@throws {@link SkyWayError} */ unpublish(target: string | Publication): Promise<void>; private _handleOnStreamUnpublished; /**@throws {@link SkyWayError} */ subscribe<T extends RemoteVideoStream | RemoteAudioStream | RemoteDataStream>(target: string | Publication, options?: SubscriptionOptions): Promise<{ subscription: Subscription<T>; stream: T; }>; /**@throws {@link SkyWayError} */ private _validatePublicationForSubscribe; /**@throws {@link SkyWayError} */ unsubscribe(target: string | Subscription): Promise<void>; private _getRemoteMemberConnections; /** * リソース解放 * - メッセージサービスとのセッション * - メディア通信 * - イベントリスナー * - TTL更新 */ dispose(): void; } export declare type PublicationOptions = { metadata?: string | undefined; /** * @description [japanese] * publishする際に優先して利用するCodec設定を指定する。 * 利用するCodecは配列の先頭が優先される。 */ codecCapabilities?: Codec[]; /** * @description [japanese] * メディアのエンコードの設定を行うことができる。 * サイマルキャストに対応している通信モデル(SFU)を利用している場合、encodingsの配列に複数のEncodingを設定するとサイマルキャストが有効になる。 * この時、encodingの配列はビットレートの低い順にソートされて設定される。 * P2Pを利用している場合、最もビットレートの低い設定のみが適用される。 */ encodings?: EncodingParameters[]; /** * @description [japanese] * publicationを有効にしてpublishするか指定する。 * デフォルトではtrueが設定される。 * falseに設定された場合、publicationは一時停止された状態でpublishされる。 */ isEnabled?: boolean; /** * @description [japanese] * DefaultRoom利用時に、publicationがP2Pで利用されるかSFUで利用されるかを指定する。 * デフォルトではP2Pが設定される。 */ type?: PublicationType; }; export declare type SubscriptionOptions = { preferredEncodingId?: string; }; //# sourceMappingURL=index.d.ts.map