import { Client } from '@urtc/sdk-web'; import { EventEmitter, Listener } from '@urtc/share-utils'; import { StartRecordOptions, StartRecordResult, StartRelayOptions, UpdateRecordOptions, UpdateRelayOptions } from './interfaces'; /** * 混流服务后台通知事件类型,有 'record-notify' 及 'relay-notify',可监听事件并做出相应处理(如提示用户),具体事件参见 {@link MixerEvent}。 * @example * ```js * client * .$mixer * .on('record-notify', (evt) => { * console.log('收到事件通知',evt.data); * }); * ``` */ export declare type MixerEventType = 'record-notify' | 'relay-notify'; /** * 混流服务后台事件,其中 code 的可能值有 '0' | '24151' | '24149' | '24150' | '24152'。 * * '0': (正常)录制/转推任务开启后10秒左右,如果收到这个消息,表示录制/转推任务开启成功。 * * '24151': (正常) 如果收到这个消息,表示加流成功。 * * '24149': (异常)任务被停止,可能的原因有房间内所有用户的推流已停止;或到推流地址(PushURL)的连接已断开(当开启转推时)。 * * '24150': (异常)任务开启后10秒,如果收到这个消息,则表示任务开启失败。 * * '24152': (异常)表示加流失败。 */ export interface MixerEvent { type: MixerEventType; data: { code: string; message: string; }; } /** * 插件方式使用下,Mix API 类,其方法将被扩展到 @urtc/sdk-web 的 Client 对象上 */ export declare class Mixer extends EventEmitter { private client; constructor(client: Client); /** * @internal */ private handleMixNotify; /** * @internal */ private startMix; /** * @intenral */ private queryMix; /** * @intenral */ private stopMix; /** * @internal */ private updateMix; /** * @internal */ once: (type: MixerEventType, listener: Listener) => EventEmitter; /** * 开启录制。 * @param params - 参见 {@link StartRecordOptions} * @returns - 参见 {@link StartRecordResult} * @example * ```js * client * .$mixer * .startRecord({ * storage: { * bucket: 'test-record', * region: 'cn-bj', * }, * output: { * layout: { * type: 'main', * }, * } * }) * .then((res) => { * console.log('开启录制成功,录制文件名:', res.FileName); * }) * .catch((err) => { * console.log('开启录制失败 ', err); * }); * ``` */ startRecord(params: StartRecordOptions): Promise; /** * 更新录制的部分设置。 * @param params - 详见 {@link UpdateRecordOptions} * @example * ```js * client * .$mixer * .updateRecord({ * output: { * layout: { * type: 'main', * mainViewUId: 'user_yyy', * mainViewType: 'screen', * }, * } * }).then(() => { * console.log('更新成功'); * }).catch((err) => { * console.log('更新失败 ', err); * }); * ``` */ updateRecord(params: UpdateRecordOptions): Promise; /** * 停止录制。 * @example * ```js * client * .$mixer * .stopRecord() * .then(() => { * console.log('停止录制成功'); * }) * .catch((err) => { * console.log('停止录制失败 ', err); * }); * ``` */ stopRecord(): Promise; /** * 开启转推。 * @param params - 参见 {@link StartRelayOptions} * @example * ```js * client * .$mixer * .startRelay({ * relay: { * pushURL: [`rtmp://push.xxxxx.com/xxx/${this.roomId}`] * }, * output: { * layout: { * type: 'main', * }, * } * }) * .then(() => { * console.log('开启转推成功'); * }) * .catch((err) => { * console.log('开启转推失败 ', err); * }); * ``` */ startRelay(params: StartRelayOptions): Promise; /** * 更新转推的部分设置。 * @param params - 详见 {@link UpdateRelayOptions} * @example * ```js * client * .$mixer * .updateRelay({ * output: { * layout: { * type: 'main', * mainViewUId: 'user_yyy', * mainViewType: 'screen', * }, * } * }) * .then(() => { * console.log('更新成功'); * }) * .catch((err) => { * console.log('更新失败 ', err); * }); * ``` */ updateRelay(params: UpdateRelayOptions): Promise; /** * 停止转推。 * @example * ```js * client * .$mixer * .stopRelay() * .then(() => { * console.log('停止转推成功'); * }) * .catch((err) => { * console.log('停止转推失败 ', err); * }); * ``` */ stopRelay(): Promise; }