index.d.ts 6.6 KB

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