index.d.ts 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  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. 'connection-state-change' | 'kick-off' | 'network-quality';
  11. export declare type ConnectionState = 'OPEN' | 'CONNECTING' | 'CLOSING' | 'RECONNECTING' | 'CLOSED';
  12. export declare type WaterMarkPosition = 'left-top' | 'left-bottom' | 'right-top' | 'right-bottom'; // 左上,左下,右上,右下
  13. export declare type WaterMarkType = 'time' | 'image' | 'text';
  14. export declare type MainViewType = 'desktop' | 'screen' | 'camera'; // todo - remove desktop
  15. export declare type NetworkQuality = '0' | '1' | '2' | '3' | '4' | '5' | '6';
  16. export interface ClientOptions {
  17. type?: RoomType
  18. role?: UserRole
  19. codec?: VideoCodec // 可设 vp8 或 h264,默认为 h264
  20. }
  21. export interface Codecs {
  22. audio: Array<AudioCodec>,
  23. video: Array<VideoCodec>
  24. }
  25. declare type FacingMode = 'user' | 'environment' | 'left' | 'right';
  26. export interface PublishOptions {
  27. audio: boolean // 是否开启麦克风
  28. video: boolean // 是否开启摄像头
  29. facingMode?: FacingMode
  30. screen: boolean // 是否共享屏幕
  31. microphoneId?: string // 麦克风设备ID
  32. cameraId?: string // 摄像头设备ID
  33. extensionId?: string // chrome插件ID
  34. mediaStream?: MediaStream // 自定义的媒体流
  35. }
  36. export interface DeviceOptions {
  37. audio: boolean // 是否开启麦克风
  38. video: boolean // 是否开启摄像头
  39. microphoneId?: string // 麦克风设备ID
  40. cameraId?: string // 摄像头设备ID
  41. }
  42. export interface DeviceDetectionOptions {
  43. audio: boolean // 必填,指定是否检测麦克风设备
  44. video: boolean // 必填,指定是否检测摄像头设备
  45. microphoneId?: string // 选填,指定需要检测的麦克风设备的ID,可通过 getMicrophones 方法查询获得该ID,不填时,将检测默认的麦克风设备
  46. cameraId?: string // 选填,指定需要检测的摄像头设备的ID,可以通过 getCameras 方法查询获得该ID,不填时,将检测默认的摄像头设备
  47. }
  48. export interface DeviceDetectionResult {
  49. audio: boolean
  50. audioError?: string
  51. video: boolean
  52. videoError?: string
  53. }
  54. export interface User {
  55. uid: string // 用户ID
  56. }
  57. export interface Stream {
  58. sid: string // 流ID
  59. uid: string // 对应的用户的ID
  60. type: 'publish'|'subscribe' // 流类型
  61. mediaType?: 'camera'|'screen' // 流的媒体类型,用于对发布流的区分
  62. video: boolean // 是否包含音频
  63. audio: boolean // 是否包含视频
  64. muteAudio: boolean // 音频是否静音
  65. muteVideo: boolean // 视频是否静音
  66. mediaStream?: MediaStream // 业务侧自定义媒体流
  67. }
  68. export interface LeaveRoomOptions {
  69. keepRecording: boolean // 是否保持服务端录制,默认不保持
  70. }
  71. export interface AudioVolumeOptions {
  72. streamId?: string
  73. element?: HTMLMediaElement
  74. volume: number
  75. }
  76. export interface WaterMarkOptions {
  77. position?: WaterMarkPosition
  78. type?: WaterMarkType // 水印类型
  79. remarks?: string // 水印备注
  80. }
  81. export interface MixStreamOptions {
  82. width?: number // 混流后视频的宽度
  83. height?: number // 混流后视频的高度
  84. template?: number // 混流模板,对应不同的录制布局
  85. isAverage?: boolean // 是否均匀,均分对应平铺,不均分对应垂直
  86. }
  87. export interface RelayOptions {
  88. time?: number, // 转推开启时间的时间戳,不填时,将默认使用当前时间的时间戳
  89. fragment: number, // 切片
  90. }
  91. export interface RecordOptions {
  92. bucket: string
  93. region: string
  94. uid?: string // 指定某用户的流为主画面
  95. mainViewType?: MainViewType // 主画面类型
  96. mixStream?: MixStreamOptions
  97. waterMark?: WaterMarkOptions
  98. relay?: RelayOptions
  99. }
  100. export interface Record {
  101. FileName: string,
  102. RecordId: string
  103. }
  104. export interface EffectOptions {
  105. streamId?: string
  106. effectId: number
  107. filePath?: string
  108. loop?: boolean
  109. playTime?: number
  110. replace?: boolean
  111. }
  112. export interface EffectVolumeOptions {
  113. streamId?: string
  114. effectId: number
  115. volume: number
  116. }
  117. export interface SwitchDeviceOptions {
  118. streamId?: string
  119. type: DeviceType
  120. deviceId: string
  121. }
  122. export interface SwitchImageOptions {
  123. streamId?: string
  124. file?: File,
  125. filePath?: string
  126. }
  127. export interface SnapshotOptions {
  128. streamId?: string
  129. download?: string | boolean
  130. }
  131. export interface AudioStats {
  132. br: number
  133. lostpre: number
  134. vol: number
  135. mime: string
  136. }
  137. export interface VideoStats {
  138. br: number,
  139. lostpre: number,
  140. frt: number,
  141. w: number,
  142. h: number,
  143. mime: string
  144. }
  145. export interface NetworkStats {
  146. rtt: number
  147. }
  148. export interface ReplaceTrackOptions {
  149. streamId?: string
  150. track: MediaStreamTrack
  151. retain?: boolean
  152. }
  153. export declare type MixType = 'relay' | 'record' | 'relay-and-record' | 'update-config'
  154. export declare type MixLayoutType = 'flow' | 'main' | 'custom'
  155. export declare type MixAudioCodec = 'aac'
  156. export declare type MixVideoCodec = 'h264' | 'h265'
  157. export declare type H264Quality = 'B' | 'CB' | 'M' | 'E' | 'H'
  158. export interface MixLayoutOptions {
  159. type: MixLayoutType // layout 类型
  160. custom?: Object[] // layout 为 'custom',自定义布局填在custom里,格式参照RFC5707 Media Server Markup Language (MSML)
  161. mainViewUId?: string // 指定某用户的流为主画面
  162. mainViewType?: MainViewType // 主画面类型
  163. }
  164. export interface MixAudioOptions {
  165. codec: MixAudioCodec
  166. }
  167. export interface MixVideoOptions {
  168. codec: MixVideoCodec
  169. quality?: H264Quality // 当 codec 为 h264 时,此项起作用
  170. frameRate?: number
  171. bitRate?: number
  172. }
  173. export interface BackgroundColorOptions {
  174. r: number
  175. g: number
  176. b: number
  177. }
  178. export interface MixOptions {
  179. type?: MixType // 默认为 record
  180. bucket?: string
  181. region?: string
  182. pushURL?: string[] // type 是 转推,转推和录制时,需指定
  183. layout?: MixLayoutOptions
  184. audio?: MixAudioOptions
  185. video?: MixVideoOptions
  186. width?: number
  187. height?: number
  188. backgroundColor?: BackgroundColorOptions
  189. waterMark?: WaterMarkOptions
  190. streams?: MixStream[]
  191. }
  192. export interface StopMixOptions {
  193. type?: MixType // 默认为 record
  194. }
  195. export interface MixResult {
  196. MixId: string
  197. FileName?: string
  198. Type?: MixType
  199. PushURL?: string[]
  200. }
  201. export interface MixStream {
  202. uid: string, // 用户 ID
  203. mediaType: 'camera'|'screen' // 流的媒体类型
  204. }
  205. export interface AddMixStreamsOptions {
  206. streams: MixStream[]
  207. }
  208. export interface RemoveMixStreamsOptions {
  209. streams: MixStream[]
  210. }