index.d.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. export declare type VideoCodec = 'vp8'|'h264';
  2. export declare type AudioCodec = 'opus';
  3. export declare type RoomType = 'rtc'|'live';
  4. export declare type UserRole = 'pull'|'push'|'push-and-pull';
  5. export declare type DeviceType = 'audio'|'video';
  6. // 业务方使用的事件类型
  7. export declare type EventType = 'user-added' | 'user-removed' |
  8. 'stream-added' | 'stream-removed' | 'stream-published' | 'stream-subscribed' |
  9. 'mute-video' | 'unmute-video' | 'mute-audio' | 'unmute-audio' | 'screenshare-stopped';
  10. export declare type WaterMarkPosition = 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom'; // 左上,左下,右上,右下
  11. export declare type WaterMarkType = 'time' | 'image' | 'text';
  12. export declare type MainViewType = 'desktop' | 'screen' | 'camera'; // todo - remove desktop
  13. export interface ClientOptions {
  14. type?: RoomType
  15. role?: UserRole
  16. codec?: VideoCodec // 可设 vp8 或 h264,默认为 vp8
  17. }
  18. export interface Codecs {
  19. audio: Array<string>,
  20. video: Array<string>
  21. }
  22. export interface PublishOptions {
  23. audio: boolean // 是否开启麦克风
  24. video: boolean // 是否开启摄像头
  25. screen: boolean // 是否共享屏幕
  26. microphoneId?: string // 麦克风设备ID
  27. cameraId?: string // 摄像头设备ID
  28. extensionId?: string // chrome插件ID
  29. mediaStream?: MediaStream // 自定义的媒体流
  30. }
  31. export interface DeviceOptions {
  32. audio: boolean // 是否开启麦克风
  33. video: boolean // 是否开启摄像头
  34. microphoneId?: string // 麦克风设备ID
  35. cameraId?: string // 摄像头设备ID
  36. }
  37. export interface DeviceDetectionOptions {
  38. audio: boolean // 必填,指定是否检测麦克风设备
  39. video: boolean // 必填,指定是否检测摄像头设备
  40. microphoneId?: string // 选填,指定需要检测的麦克风设备的ID,可通过 getMicrophones 方法查询获得该ID,不填时,将检测默认的麦克风设备
  41. cameraId?: string // 选填,指定需要检测的摄像头设备的ID,可以通过 getCameras 方法查询获得该ID,不填时,将检测默认的摄像头设备
  42. }
  43. export interface User {
  44. uid: string // 用户ID
  45. }
  46. export interface Stream {
  47. sid: string // 流ID
  48. uid: string // 对应的用户的ID
  49. type: 'publish'|'subscribe' // 流类型
  50. mediaType?: 'camera'|'screen' // 流的媒体类型,用于对发布流的区分
  51. video: boolean // 是否包含音频
  52. audio: boolean // 是否包含视频
  53. muteAudio: boolean // 音频是否静音
  54. muteVideo: boolean // 视频是否静音
  55. mediaStream?: MediaStream // 业务侧自定义媒体流
  56. }
  57. export interface LeaveRoomOptions {
  58. keepRecording: boolean // 是否保持服务端录制,默认不保持
  59. }
  60. export interface AudioVolumeOptions {
  61. streamId?: string
  62. element?: HTMLMediaElement
  63. volume: number
  64. }
  65. export interface WaterMarkOptions {
  66. position?: WaterMarkPosition
  67. type?: WaterMarkType // 水印类型
  68. remarks?: string // 水印备注
  69. }
  70. export interface MixStreamOptions {
  71. uid?: string // 指定某用户的流为主画面
  72. type?: MainViewType // 主画面类型
  73. width?: number // 混流后视频的宽度
  74. height?: number // 混流后视频的高度
  75. template?: number // 混流模板,对应不同的录制布局
  76. isAverage?: boolean // 是否均匀,均分对应平铺,不均分对应垂直
  77. }
  78. export interface RecordOptions {
  79. waterMark?: WaterMarkOptions
  80. mixStream?: MixStreamOptions
  81. bucket: string
  82. region: string
  83. }
  84. export interface Record {
  85. FileName: string,
  86. RecordId: string
  87. }
  88. export interface EffectOptions {
  89. streamId?: string
  90. effectId: number
  91. filePath?: string
  92. loop?: boolean
  93. playTime?: number
  94. replace?: boolean
  95. }
  96. export interface EffectVolumeOptions {
  97. streamId?: string
  98. effectId: number
  99. volume: number
  100. }
  101. export interface SwitchDeviceOptions {
  102. streamId?: string
  103. type: DeviceType
  104. deviceId: string
  105. }
  106. export interface SwitchImageOptions {
  107. streamId?: string
  108. file?: File,
  109. filePath?: string
  110. }
  111. export interface SnapshotOptions {
  112. streamId?: string
  113. download?: string | boolean
  114. }
  115. export interface AudioStats {
  116. br: number
  117. lostpre: number
  118. vol: number
  119. mime: string
  120. }
  121. export interface VideoStats {
  122. br: number,
  123. lostpre: number,
  124. frt: number,
  125. w: number,
  126. h: number,
  127. mime: string
  128. }
  129. export interface NetworkStats {
  130. rtt: number
  131. }