trtc-electron-sdk
Version:
trtc electron sdk
130 lines (129 loc) • 4.77 kB
TypeScript
import { TRTCVideoRotation, TRTCVideoFillMode, TRTCVideoMirrorType, TRTCVideoEncParam, TRTCCameraCaptureParams, Rect, TRTCScreenCaptureProperty } from '../../trtc_define';
export declare enum TRTCMediaMixingErrorCode {
Success = 0,
Error = -1,
InvalidParams = -2,
NotFoundSource = -3,
ImageSourceLoadFailed = -4,
CameraNotAuthorized = -5,
CameraIsOccupied = -6,
CameraDisconnected = -7,
UnsupportedOnlineVideoProtocol = -8,
UnsupportedLocalVideoFileFormat = -9,
OnlineVideoConnectFailed = -10,
OnlineVideoConnectionLost = -11,
NoAvailableHevcDecoder = -12,
VideoFileNotExist = -13,
/**
* SDK 兜底超时(addMediaSource 在 cpp / js 双层超时内未收到底层 onXxxStarted 回调)。
*
* 取一个远离 SDK 自然错误码区间(-1..-13)的值,便于上层稳定区分。
* 必须与 C++ 端 `kInsertTimeoutErrCode`(SourceManagerProxy)保持一致。
*/
InsertTimeout = -9001
}
export declare enum TRTCMediaSourceType {
kCamera = 0,
kScreen = 1,
kImage = 2,
kPhoneMirror = 4,
kOnlineVideo = 5,
kVideoFile = 6
}
export declare type TRTCPhoneMirrorParam = {
platformType: number;
connectType: number;
deviceId: string;
deviceName: string;
placeholderImagePath: string;
frameRate: number;
bitrateKbps: number;
};
export declare type TRTCMediaSource = {
sourceType: TRTCMediaSourceType;
sourceId: string;
zOrder: number;
enableGreenScreen?: boolean;
rect: Rect;
isSelected?: boolean;
rotation?: TRTCVideoRotation;
fillMode?: TRTCVideoFillMode;
mirrorType?: TRTCVideoMirrorType;
};
export declare type TRTCMediaMixingEncParam = {
videoEncoderParams: TRTCVideoEncParam;
canvasColor: number;
selectedBorderColor?: number | 0xFFFF00;
};
export declare enum TRTCStreamLayoutMode {
Custom = "Custom",
None = "None"
}
export declare type TRTCUserStream = {
userId: string;
fillMode?: TRTCVideoFillMode;
rect?: Rect;
zOrder?: number;
};
export declare type TRTCStreamInfo = {
userId: string;
x: number;
y: number;
w: number;
h: number;
zOrder?: number;
fillMode?: TRTCVideoFillMode;
};
export declare type TRTCStreamLayout = {
layoutMode: TRTCStreamLayoutMode;
userList?: Array<TRTCUserStream>;
size?: {
width: number;
height: number;
};
streams?: Array<TRTCStreamInfo>;
};
export declare type TRTCOnlineVideoParam = {
networkCacheSizeKB: number;
playoutVolume: number;
};
export declare type TRTCVideoFileParam = {
playoutVolume: number;
};
export interface ITRTCMediaMixingManager {
addMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
removeMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
updateMediaSource(mediaSource: TRTCMediaSource): Promise<void>;
setCameraCaptureParam(cameraID: string, param: TRTCCameraCaptureParams): void;
setPhoneMirrorParam(phoneMirrorSourceId: string, param: TRTCPhoneMirrorParam): void;
setScreenCaptureProperty(screenWindowID: string, property: TRTCScreenCaptureProperty): void;
startPublish(): Promise<void>;
stopPublish(): Promise<void>;
updatePublishParams(params: TRTCMediaMixingEncParam): Promise<void>;
/**
* @deprecated
*/
setDisplayParams(windowID: number | Uint8Array, regionOrView: HTMLElement | Rect | null): void;
bindPreviewArea(windowID: Uint8Array, view: HTMLElement | Rect | null): Promise<void>;
setStreamLayout(options: TRTCStreamLayout): void;
destroy(): void;
on(event: string, func: (...args: any[]) => void): void;
off(event: string, func: (...args: any[]) => void): void;
}
export interface ITRTCMediaMixingEvent {
onSourceSelected(mediaSource: TRTCMediaSource | null): void;
onSourceMoved(mediaSource: TRTCMediaSource, rect: Rect): void;
onSourceResized(mediaSource: TRTCMediaSource, rect: Rect): void;
onRightButtonClicked(mediaSource: TRTCMediaSource | null): void;
onSourcePlugged(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
onSourceConnected(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
onSourceDisconnected(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
onSourceUnplugged(source: TRTCMediaSource | TRTCPhoneMirrorParam, detail: string): void;
}
export interface ITRTCMediaMixingService {
startMediaMixingServer(path: string): Promise<void>;
stopMediaMixingServer(): Promise<void>;
}
export interface ITRTCMediaMixingServiceEvent {
onMediaMixingServerLost(): void;
}