agora-edu-core
Version:
Core APIs for building an online classroom
366 lines (364 loc) • 13.3 kB
TypeScript
import { AgoraRteAudioSourceType, AgoraRteMediaPublishState, AgoraRteScene, AgoraRteVideoSourceType, AGRenderMode, AGRemoteVideoStreamType, AgoraLatencyLevel } from 'agora-rte-sdk';
import { AgoraStreamStates } from '../../../../type';
import { EduStoreBase } from '../base';
import { EduStream } from './struct';
export declare type StreamMessageListener = (streamId: string, message: unknown) => void;
/**
* `StreamStore` 类用于管理媒体流。
*/
/** @en
* The `StreamStore` class is used for managing media streams.
*/
export declare class StreamStore extends EduStoreBase {
private _disposers;
private _streamMessageListeners;
private _streamMessageScene?;
private _handleSceneStreamMessage;
private _dataStore;
/**
* @internal
*
* 主房间数据信息
*/
/** @en
* @internal
*
* main store datastore
*/
get mainRoomDataStore(): DataStore;
/**
* @internal
*
* 分组房间数据信息
*/
/** @en
* @internal
*
* sub store datastore
*/
get subRoomDataStore(): DataStore;
/**
* 本地屏幕共享流信息
* streamUuid: 流 UUID
* shareStreamToken: 流 Token
*/
/** @en
* Local screen stream info
* streamUuid: Stream UUID
* shareStreamToken: Stream token
*/
private get _screenShareTokenAccessor();
/**
* 房间内流信息列表
* key: 流 UUID
* value: 流对象
*/
/** @en
* Streams in the room
* key: Stream UUID
* value: Stream object
*/
get streamByStreamUuid(): Map<string, EduStream>;
/**
* 房间内用户流信息列表
* key: 用户 UUID
* value: 流 UUID 集合
*/
/** @en
* Stream UUID set indexed by User UUID
* key: User UUID
* value: Set of stream UUID
*/
get streamByUserUuid(): Map<string, Set<string>>;
/**
* 音量列表
* key: 流 UUID
* value: 音量值,范围:0 ~ 1
*/
/** @en
* Volume list indexed by stream UUID
* key: Stream UUID
* value: volume value, range by: 0 ~ 1
*/
get streamVolumes(): Map<string, number>;
/**
* 屏幕共享 Tokens
* key: 流 UUID
* value: RTC Token
*/
/** @en
* Screen share tokens
* key: Stream UUID
* value: RTC token
*/
get shareStreamTokens(): Map<string, string>;
/**
* 本地屏幕共享 Token
*/
/** @en
* Local screen share token
*/
get shareStreamToken(): string | undefined;
/**
* 本地摄像头视频流 UUID
*/
/** @en
* Loal camera stream UUID
*/
get localCameraStreamUuid(): string | undefined;
/**
* 本地麦克风音频流 UUID
*/
/** @en
* Local microphone stream UUID
*/
get localMicStreamUuid(): string | undefined;
/**
* 本地屏幕共享视频流 UUID
**/
/** @en
* Local screen stream UUID
*/
get localShareStreamUuid(): string | undefined;
/**
* 初始化屏幕共享流
* @param scene 房间对象
* @param streamUuid 流 UUID
* @param rtcToken RTC Token
*/
/** @en
* Initializes the screen stream
* @param scene Room object
* @param streamUuid Stream UUID
* @param rtcToken RTC Token
*/
initializeScreenShareStream(scene: AgoraRteScene, streamUuid: string, rtcToken: string): void;
/**
* 销毁屏幕共享流
* @param scene 房间对象
*/
/** @en
* Destroys the screen stream
* @param scene Room object
*/
destroyScreenShareStream(scene: AgoraRteScene): void;
/**
* 设置远端视频质量
* @param streamUuid 要设置的流的 UUID
* @param remoteVideoStreamType 要设置的流类型
* @param fromScene 流所在的房间对象,不传默认为当前房间
**/
/** @en
* Sets the remote video stream quality type
* @param streamUuid The UUID of the stream to be set
* @param remoteVideoStreamType The stream type to set
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
setRemoteVideoStreamType(streamUuid: string, remoteVideoStreamType: AGRemoteVideoStreamType, fromScene?: AgoraRteScene): Promise<void>;
/**
* 渲染远端视频
* @param stream 流对象
* @param dom 渲染节点
* @param mirror 是否镜像
* @param renderMode 填充方式
* @param fromScene 流所在的房间对象,不传默认为当前房间
**/
/** @en
* Renders the remote video
* @param stream Stream object
* @param dom DOM node
* @param mirror Whether to apply mirror
* @param renderMode Mode of rendering video
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
setupRemoteVideo(stream: EduStream, dom: HTMLElement, mirror: boolean, renderMode?: AGRenderMode, fromScene?: AgoraRteScene): void;
/**
* 订阅/取消远端视频流
* @param stream 流对象
* @param muted 是否订阅
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Subscribes/Unsubscribes the remote video stream
* @param stream Stream object
* @param muted Whether to subscribe
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
muteRemoteVideoStream(stream: EduStream, muted: boolean, fromScene?: AgoraRteScene): void;
/**
* 订阅/取消远端音频流
* @param stream 流对象
* @param muted 是否订阅
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Subscribes/Unsubscribes the remote audio stream
* @param stream Stream object
* @param muted Whether to subscribe
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
muteRemoteAudioStream(stream: EduStream, muted: boolean, fromScene?: AgoraRteScene): void;
/**
* 批量订阅
* @param streams 流对象列表
* @param muted 是否订阅
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Subscribes a batch of streams
* @param streams Set of stream object
* @param muted Whether to subscribe
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
muteRemoteVideoStreamMass(streams: EduStream[], muted: boolean, fromScene?: AgoraRteScene): Promise<string[]> | undefined;
/**
* 更新本地音频和视频发布状态
* @param state 音频和视频发布状态
* @param fromScene 流所在的房间对象,不传默认为当前房间
*
**/
/** @en
* Updates the local audio ad video publishing states
* @param state The audio ad video publishing state
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
updateLocalPublishState(state: {
videoState?: AgoraRteMediaPublishState;
audioState?: AgoraRteMediaPublishState;
}, fromScene?: AgoraRteScene): Promise<void>;
/**
* 更新远端音频和视频发布状态
* @param userUuid 用户 ID
* @param streamUuid 流 ID
* @param state 音频和视频发布状态
* @param fromScene 流所在的房间对象,不传默认为当前房间
**/
/** @en
* Updates the remote audio ad video publishing states
* @param userUuid The user ID
* @param streamUuid The stream ID
* @param state The audio ad video publishing state
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
updateRemotePublishState(userUuid: string, streamUuid: string, state: {
videoState?: AgoraRteMediaPublishState;
audioState?: AgoraRteMediaPublishState;
}, fromScene?: AgoraRteScene): Promise<void>;
/**
* 批量更新远端音频和视频发布状态
* @param streams 流列表
**/
/** @en
* Batch updates the remote audio ad video publishing states
* @param streams list of stream
*/
updateRemotePublishStateBatch(streams: {
userUuid: string;
streamUuid: string;
videoState?: AgoraRteMediaPublishState | undefined;
audioState?: AgoraRteMediaPublishState | undefined;
videoSourceType?: AgoraRteVideoSourceType | undefined;
audioSourceType?: AgoraRteAudioSourceType | undefined;
}[], fromScene?: AgoraRteScene): Promise<void>;
/**
* 旁路推流,将当前已发布的流推送到CDN
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Bypass push, pushs the currently published stream to CDN
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
publishStreamToCdn(fromScene?: AgoraRteScene): Promise<void>;
/**
* 更新视频墙开关状态和发流用户列表
* @param state 1 开启视频墙 0 关闭视频墙
* @param data userUuids 发流用户列表
*/
/** @en
* Updates the status and users of the video gallery
* @param state 1 open 0 close
* @param data userUuids users who publish streams
*/
updateExpandedScopeAndStreams(state: 1 | 0, data: {
userUuids: string[];
}): Promise<void>;
/**
* 为本地用户创建一条屏幕共享流,返回已创建的流ID与Token。
* 此方法只允许房间内创建一路屏幕共享流,若房间内需要同时存在多路屏幕流,请使用 publishScreenShareStateless
* @param fromScene 流所在的房间对象,不传默认为当前房间
* @param streamOptions 发流选项
*/
/** @en
* Creates a screen share stream for the local user, returns the stream id and the token of the created stream.
* This method only allows creating one screen share stream in the room, if multiple streams are needed, please use publishScreenShareStateless
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
* @param streamOptions Options for publishing stream
*/
publishScreenShare(fromScene?: AgoraRteScene, streamOptions?: Partial<AgoraStreamStates>): Promise<any>;
/**
* 取消发布屏幕共享流
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Removes the screen share stream that is created for the local user before
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
unpublishScreenShare(fromScene?: AgoraRteScene): Promise<void>;
/**
* 为本地用户创建一条屏幕共享流,返回已创建的流ID与Token。
* 此方法允许房间内创建多路屏幕共享流
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Creates a screen share stream for the local user, returns the stream id and the token of the created stream.
* This method allows creating multiple screen share streams in the room
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
publishScreenShareStateless(fromScene?: AgoraRteScene): Promise<any>;
/**
* 取消发布屏幕共享流
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Removes the screen share stream that is created for the local user before
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
unpublishScreenShareStateless(fromScene?: AgoraRteScene): Promise<void>;
/**
* 设置延时等级(仅可在当前端没有发布音视频流的情况下使用)
* @param level 流的延时等级
* @param fromScene 流所在的房间对象,不传默认为当前房间
*/
/** @en
* Sets the delay level (only available if the current user has no audio and video streams published)
* @param level Level of streaming delay
* @param fromScene The room object in which the stream resides, if not passed, defaults to the current room
*/
setLatencyLevel(level: AgoraLatencyLevel, fromScene?: AgoraRteScene): Promise<void>;
private _setEventHandler;
/**
* @internal
*/
/** @en
* @internal
*/
onInstall(): void;
/**
* @internal
*/
/** @en
* @internal
*/
onDestroy(): void;
addStreamMessageListener(listener: StreamMessageListener): () => void;
removeStreamMessageListener(listener: StreamMessageListener): void;
private _attachStreamMessageListener;
private _detachStreamMessageListener;
}
declare type DataStore = {
streamByStreamUuid: Map<string, EduStream>;
streamByUserUuid: Map<string, Set<string>>;
streamVolumes: Map<string, number>;
shareStreamTokens: Map<string, string>;
};
export {};