Files
nl-um-vue-ts/src/config/call.ts
2025-12-15 14:13:56 +08:00

40 lines
811 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/**
* 通话模式配置
*
* 支持两种模式:
* - webrtc: 原有 WebRTC P2P 模式Web 与 Web 之间通话,低延迟
* - rtmp: RTMP 服务器中转模式,支持 Web 与小程序端互通
*/
export type CallMode = 'webrtc' | 'rtmp'
/**
* 获取当前通话模式
* 从 window.__CALL_MODE__ 读取,默认为 'webrtc'
*/
export function getCallMode(): CallMode {
return (window as any).__CALL_MODE__ || 'webrtc'
}
/**
* 是否为 RTMP 模式
*/
export function isRTMPMode(): boolean {
return getCallMode() === 'rtmp'
}
/**
* 是否为 WebRTC 模式
*/
export function isWebRTCMode(): boolean {
return getCallMode() === 'webrtc'
}
/**
* 设置通话模式(运行时切换)
*/
export function setCallMode(mode: CallMode): void {
(window as any).__CALL_MODE__ = mode
}