# User

#### new User(id, name, data)

Description:

  - 用户User构造函数。

##### Parameters:

Name | Type | Description
--- | --- | ---
`id` | String | 用户id
`name` | String | 用户名称
`data` | String | 用户扩展字段

### Methods

#### addCallback(type, callback)

Description:

  - 用户级别的回调

##### Example

    user.addCallback(UserCallback.microphone_status_notify, onMicrophoneStatusNotify);
    user.addCallback(UserCallback.camera_status_notify, onCameraStatusNotify);
    user.addCallback(UserCallback.screen_status_notify, onScreenStatusNotify);

    user.addCallback(UserCallback.camera_data_notify, onCameraDataNotify);
    user.addCallback(UserCallback.screen_data_notify, onScreenDataNotify);

    user.addCallback(UserCallback.publish_camera_notify, onPublishCameraNotify);
    user.addCallback(UserCallback.unpublish_camera_notify, onUnpublishCameraNotify);
    user.addCallback(UserCallback.subscrible_camera_result, onSubscribleCameraResult);
    user.addCallback(UserCallback.unsubscrible_camera_result, onUnsubscribleCameraResult);

    user.addCallback(UserCallback.publish_screen_notify, onPublishScreenNotify);
    user.addCallback(UserCallback.unpublish_screen_notify, onUnpublishScreenNotify);
    user.addCallback(UserCallback.subscrible_screen_result, onSubscribleScreenResult);
    user.addCallback(UserCallback.unsubscrible_screen_result, onUnsubscribleScreenResult);

    user.addCallback(UserCallback.publish_microphone_notify, onPublishMicrophoneNotify);
    user.addCallback(UserCallback.unpublish_microphone_notify, onUnpublishMicrophoneNotify);
    user.addCallback(UserCallback.subscrible_microphone_result, onSubscribleMicrophoneResult);
    user.addCallback(UserCallback.unsubscrible_microphone_result, onUnsubscribleMicrophoneResult);

    user.addCallback(UserCallback.subscrible_screen_audio_result, onSubscribleScreenAudioResult);
    user.addCallback(UserCallback.unsubscrible_screen_audio_result, onUnsubscribleScreenAudioResult);

    user.addCallback(UserCallback.board_add_result, onBoardAddResult);
    user.addCallback(UserCallback.board_update_result, onBoardUpateResult);
    user.addCallback(UserCallback.board_remove_result, onBoardremoveResult);

    麦克风状态更新
    param:status － 状态
    param:microphoneId － 麦克风设备Id
    param:microphoneName － 麦克风设备名称
    param:userId － 麦克风设备所属者ＩＤ

    function onMicrophoneStatusNotify(status, microphoneId, microphoneName, userId) {

    }

    摄像头状态更新
    param : status － 状态
    param : cameraId － 摄像头设备Id
    param : cameraName－ 摄像头设备名称
    param : userId－ 摄像头设备所属者ＩＤ

    function onCameraStatusNotify(status, cameraId, cameraName, userId) {

    }

    桌面共享状态更新
    param : status － 状态
    param : cameraId － 桌面共享设备Id
    param : cameraName－ 桌面共享设备名称
    param : userId－ 桌面共享设置所属者ＩＤ

    function onScreenStatusNotify(status, screenId, screenName, userId) {

    }

    摄像头数据更新
    param : level － 级别
    param : description － 描述
    param : cameraId － 摄像头设备Id
    param : cameraName－ 摄像头设备名称
    param : userId－ 摄像头设备所属者ＩＤ
    function onCameraDataNotify(level, description, cameraId, cameraName, userId) {

    }

    桌面共享数据更新
    param : level － 级别
    param : description － 描述
    param : screenId － 桌面共享设备Id
    param : screenName－ 桌面共享设备名称
    param : userId－ 桌面共享设置所属者ＩＤ

    function onScreenDataNotify(level, description, screenId, screenName, userId) {

    }

    发布视频的回调
    param : videos － 发布的视频数组
    function onPublishCameraNotify(videos) {

    }

    取消发布视频的回调
    param : video － 取消发布的视频

    function onUnpublishCameraNotify(video) {

    }

    订阅远端视频流反馈
    param： stream － 远端视频流
    param ：userId － 所属用户ＩＤ
    param ：userName－ 所属用户名称
    param ：cameraId－ 摄像头设备ＩＤ

    function onSubscribleCameraResult(stream, userId, userName,cameraId) {

    }

    取消订阅远端视频流反馈
    param ：userId－ 所属用户ＩＤ
    param ：userName－所属用户名称
    param ： cameraId－摄像头设备ＩＤ

    function onUnsubscribleCameraResult(userId, userName,cameraId){

    }

    发布桌面共享的回调
    param : screens － 发布的桌面共享数组

    function onPublishScreenNotify(screens){

    }

    取消发布桌面共享的回调
    param : screen － 取消发布的桌面共享

    function onUnpublishScreenNotify(screen) {

    }

    订阅远端桌面共享流反馈
    param： stream － 远端桌面共享流
    param ：userId － 所属用户ＩＤ
    param ：userName－ 所属用户名称
    param ：screenId－ 桌面共享设备ＩＤ
    param ：width－ 分辨率宽度
    param ：height－ 分辨率高度
    param ：framerate－ 帧率

    function onSubscribleScreenResult(stream, userId, userName,screenId,width,height,framerate) {

    }

    取消订阅远端桌面共享流反馈
    param ：userId－ 所属用户ＩＤ
    param ：userName－所属用户名称
    param ： cameraId－桌面共享设备ＩＤ

    function onUnsubscribleScreenResult(userId, userName,screenId){

    }

    发布音频的回调
    param : audios － 发布的音频数组
    function onPublishMicrophoneNotify(audios) {

    }

    取消发布音频的回调
    param : audio － 取消发布的音频

    function onUnpublishMicrophoneNotify(audio) {

    }

    订阅远端音频流反馈
    param：stream－ 远端音频流
    param：userId－ 所属用户ＩＤ
    param：userName－所属用户名称

    function onSubscribleMicrophoneResult(stream, userId, userName){

    }

    取消订阅远端音频流反馈
    param ：userId－ 所属用户ＩＤ
    param ： userName－所属用户名称

    function onUnsubscribleMicrophoneResult(userId, userName){

    }

    * 订阅远端屏幕共享音频流反馈
    param：stream－ 远端屏幕共享音频流
    param：userId－ 所属用户ＩＤ
    param：userName－所属用户名称

    function onSubscribleMicrophoneResult(stream, userId, userName){

    }

    取消订阅远端屏幕共享音频流反馈
    param ：userId－ 所属用户ＩＤ
    param ： userName－所属用户名称

    function onUnsubscribleMicrophoneResult(userId, userName){

    }

    白板新增操作反馈
    param ：board－白板对象

    function onBoardAddResult(board){

    }

    白板删除操作反馈
    param ：boardId－白板对象Id

    function onBoardRemoveResult(boardId){

    }

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | UserCallback | 回调枚举标识
`callback` | Object | 回调方法名,可以自定义

#### attachAudioElementMediaStream(element, stream)

Description:

  - 音频流渲染进音频控件

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | － 音频控件对象
`stream` | Object | － 音频流

#### attachScreenAudioElementMediaStream(element, stream)

Description:

  - 桌面共享音频流渲染进音频控件

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | －音频控件对象
`stream` | Object | － 桌面共享音频流

#### attachScreenElementMediaStream(element, stream)

Description:

  - 桌面共享流渲染进视频控件

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | － 视频控件对象
`stream` | Object | － 桌面共享流

#### attachVideoElementMediaStream(element, stream)

Description:

  - 视频流渲染进视频控件

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | － 视频控件对象
`stream` | Object | － 视频流

#### bindAudioToVideo(audioId, videoId)

Description:

  - 仅针对有微信小程序端加入的情况下使用，且当前web端有多个摄像头。一个摄像头原则上不用调该接口。

##### Parameters:

Name | Type | Description
--- | --- | ---
`audioId` | String | 音频设备ID
`videoId` | String | 视频设备ID

#### (async) closeBoardById(boardId)

Description:

  - 关闭指定的共享白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`boardId` | String | 白板Id

#### (async) closeMobileBackVideo()

Description:

  - 针对移动端H5关闭后置摄像头

#### (async) closeMobileFrontVideo()

Description:

  - 针对移动端H5关闭前置摄像头

#### (async) createBoard(width, height, backgroundColor, backgroundImage, outputWidth, outputHeight, title)

Description:

  - 创建白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`width` | int | 白板的渲染宽度
`height` | int | 白板的渲染高度
`backgroundColor` | String | 白板的背景色，格式为RGBA 例如 透明："0,0,0,0" 红色不透明: "255,0,0,1"
`backgroundImage` | String | 白板的背景图访问路径
`outputWidth` | int | 白板的输出宽度
`outputHeight` | int | 白板的输出高度
`title` | String | 白板标题

#### (async) createCustomAudioTrack(mediaStreamTrack, trackName)

Description:

  - 创建一个自定义的音频轨道

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaStreamTrack` | MediaStreamTrack | 音频轨道
`trackName` | String | 音频轨道名称，非必填项，不填时默认为userName + "_custom_audio"

#### (async) createCustomVideoTrack(mediaStreamTrack, trackName)

Description:

  - 创建一个自定义的视频轨道

##### Example

    以从Canvas中获取流为例:
     var stream = customCanvas.captureStream();
     var track = stream.getVideoTracks()[0];
     user.createCustomVideoTrack(track).then(function(video){
    	   video.publish().then(function(){});
     }).otherwise(function(error){});

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaStreamTrack` | MediaStreamTrack | 视频轨道
`trackName` | String | 视频轨道名称，非必填项，不填时默认为userName + "_custom_video"

#### (async) deleteCustomAudioTrack(audioId)

Description:

  - 删除一个自定义的音频轨道

##### Parameters:

Name | Type | Description
--- | --- | ---
`audioId` | String | 音频设备ID

#### (async) deleteCustomVideoTrack(videoId)

Description:

  - 删除一个自定义的视频轨道

##### Parameters:

Name | Type | Description
--- | --- | ---
`videoId` | String | 视频设备ID

#### getAllBoards()

Description:

  - 获取所有的白板

#### getAudio(microphoneId) → {Object}

Description:

  - 获取Audio对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`microphoneId` | String | 麦克风设备ID

##### Returns:

- audio Audio对象

Type
  Object

#### getBoard(boardId)

Description:

  - 通过白板Id获取白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`boardId` | String | 白板Id

#### getCustomAudio(customAudioId) → {Object}

Description:

  - 获取Audio对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`customAudioId` | String | 第三方音频设备Id

##### Returns:

- audio Aduio对象

Type
  Object

#### getScreen() → {Object}

Description:

  - 获取Screen对象

##### Returns:

- screen Screen对象

Type
  Object

#### getScreenAudio() → {Object}

Description:

  - 获取ScreenAudio对象

##### Returns:

- screenAudio ScreenAudio对象

Type
  Object

#### getUserData(userId)

Description:

  - 获得用户的扩展信息

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 用户id不填，表示自己

#### getVideo(cameraId) → {Object}

Description:

  - 获取Video对象

##### Parameters:

Name | Type | Description
--- | --- | ---
`cameraId` | String | 摄像头设备Id

##### Returns:

- video Video对象

Type
  Object

#### (async) openCameraAndMicrophone(video, audio, videoElement, audioElement)

Description:

  - 打开摄像头和麦克风

##### Parameters:

Name | Type | Description
--- | --- | ---
`video` | Obejct | video对象
`audio` | Obejct | audio对象
`videoElement` | Object | 视频控件对象
`audioElement` | Object | 音频控件对象

#### (async) openMobileBackVideo(element)

Description:

  - 针对移动端H5打开后置摄像头

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | 视频控件对象

#### (async) openMobileFrontVideo(element)

Description:

  - 针对移动端H5打开前置摄像头

##### Parameters:

Name | Type | Description
--- | --- | ---
`element` | Object | 视频控件对象

#### remotecmdCloseMicrophone(userId)

Description:

  - 命令远端用户关闭麦克风

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 远端用户Id

#### remotecmdMuteMicrophone(userId)

Description:

  - 命令远端用户麦克风静音

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 远端用户Id

#### remotecmdOpenMicrophone(userId)

Description:

  - 命令远端用户打开麦克风

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 远端用户Id

#### remotecmdPublishCamera(video)

Description:

  - 命令远端用户发布某一摄像头视频

##### Parameters:

Name | Type | Description
--- | --- | ---
`video` | Obejct | 视频对象

#### remotecmdUnmuteMicrophone(userId)

Description:

  - 命令远端用户麦克风取消静音

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 远端用户Id

#### remotecmdUnpublishCamera(userId, cameraId)

Description:

  - 命令远端用户取消发布摄像头视频

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 用户Id
`cameraId` | String | 摄像头设备Id

#### removeBoard(userId)

Description:

  - 删除自己所属的全部白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`userId` | String | 白板创建者Id

#### (async) removeBoardById(boardId, userId)

Description:

  - 删除指定的白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`boardId` | String | 白板Id
`userId` | String | 白板所属的用户id，允许不传，不传时，白板必现是当前自己的白板。填写是userid所属的白板

#### (async) shareBoardById(boardId)

Description:

  - 共享指定白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`boardId` | String | 白板Id

#### (async) updateBoard(board)

Description:

  - 更新白板

##### Parameters:

Name | Type | Description
--- | --- | ---
`board` | Object | 对象

#### updateUserData(userData)

Description:

  - 更新用户扩展内容

##### Parameters:

Name | Type | Description
--- | --- | ---
`userData` | String | 用户扩展内容

#### updateUserName(userName)

Description:

  - 更新用户名称

##### Parameters:

Name | Type | Description
--- | --- | ---
`userName` | String | 用户名称