Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Stream

The Stream interface provides methods that define the behaviors of a Stream object, such as the mute audio, capture video.

The Stream object is created by the getMediaStream method..

Index

Functions

adjustRenderedVideoPosition

  • adjustRenderedVideoPosition(canvas: HTMLCanvasElement, userId: number, width: number, height: number, x: number, y: number, additionalUserKey?: string): ExecutedResult
  • Adjust the coordinates and dimension of rendered video.

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • userId: number

      Required. The user id which to render the video.

    • width: number

      Required. Width of the video.

    • height: number

      Required. Height of the video.

    • x: number

      Required. Coordinate x of video.

    • y: number

      Required. Coordinate y of video.

    • Optional additionalUserKey: string

      Optional. Must be paired with renderVideo.

      • @returns
      • '': Success.
      • Error: Failure. Details in ErrorTypes.

    Returns ExecutedResult

clearVideoCanvas

  • Clear all the canvas

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • Optional underlyingColor: UnderlyingColor

      Optional. Underlying color when video is stopped,default is transparent.

    Returns ExecutedResult

getActiveCamera

  • getActiveCamera(): string
  • Get the recently active camera devices id.

    Example

    try{
      const activeCamera = stream.getActiveCamera();
      console.log(activeCamera);
    } catch (error) {
      console.log(error);
    }
    

    Returns string

    • '': The video flag is false in media constraints.
    • 'default': No camera device id is passed to startVideo and it will use system default camera.
    • string: Recently active camera devices id.

getActiveMicrophone

  • getActiveMicrophone(): string
  • Get the active device id of microphone.

    Returns string

    device id

getActiveShareUserId

  • getActiveShareUserId(): number
  • Get the user id of received shared content

    Returns number

getActiveSpeaker

  • getActiveSpeaker(): string
  • Get the active device of speaker.

    Returns string

    device id

getActiveVideoId

  • getActiveVideoId(): number
  • Get the recently active video id.

    Example

    try{
      const activeVideoId = stream.getActiveVideoId();
      console.log(activeVideoId);
    } catch (error) {
      console.log(error);
    }
    

    Returns number

    • 0: No video is active or the video flag is false in media constraints.
    • number: Id of current active video.

getCameraList

  • Get the current camera devices list.

    Note

    • This camera device list is collected from browser's navigator.mediaDevices object and maintained by the stream object.
    • If the user does not allow permission to access the camera, this list will have a default CameraDevice object with all property set to empty string.

    Example

    try{
      const currentCameraDevicesList = stream.getCameraList();
      console.log(currentCameraDevicesList);
    } catch (error) {
      console.log(error);
    }
    

    Returns MediaDevice[]

    • []: The video flag is false in media constraints.
    • Array<CameraDevice>: A CameraDevice interface has following property:
      • label: string: The label of camera device.
      • deviceId: string: The string of camera device.

getMicList

getReceivedVideoDimension

  • getReceivedVideoDimension(): { height: number; width: number }
  • Get the dimension of received video.

    Returns { height: number; width: number }

    • height: number
    • width: number

getSpeakerList

getVideoMaxQuality

  • getVideoMaxQuality(): number
  • Get the max quality of video.

    Returns number

isAudioMuted

  • isAudioMuted(userId?: number): boolean
  • Whether the user is muted.

    • If not specified the user id, get the muted of current user.

    Parameters

    • Optional userId: number

      Default undefined

    Returns boolean

    boolean

isCameraTaken

  • isCameraTaken(): boolean
  • Get the isCameraTaken flag status.

    Example

    try{
      const isCameraTaken = stream.isCameraTaken();
      console.log(isCameraTaken);
    } catch (error) {
      console.log(error);
    }
    

    Returns boolean

    • true: The camera is taken by other program.
    • false: The camera is taken by other program.

isCaptureForbidden

  • isCaptureForbidden(): boolean
  • Get the isCaptureForbidden flag status.

    Example

    try{
      const isCaptureForbidden = stream.isCaptureForbidden();
      console.log(isCaptureForbidden);
    } catch (error) {
      console.log(error);
    }
    

    Parameters

    None.

    Returns boolean

    • true: The capture is forbidden by user.
    • false: The capture is not forbidden by user or the video flag is false in media constraints.

isCapturingVideo

  • isCapturingVideo(): boolean
  • Get the isCapturingVideo flag status.

    Example

    try{
      const isCapturingVideo = stream.isCapturingVideo();
      console.log(isCapturingVideo);
    } catch (error) {
      console.log(error);
    }
    

    Returns boolean

    • true: The stream object is capturing video.
    • false: The stream object is not capturing video.

isShareLocked

  • isShareLocked(): boolean
  • Whether the host locked the share

    Returns boolean

isSupportHDVideo

  • isSupportHDVideo(): boolean
  • Whether video sdk supports HD video

    Returns boolean

isSupportMultipleVideos

  • isSupportMultipleVideos(): boolean
  • Whether the browser is support render multiple videos simultaneously

    Returns boolean

lockShare

  • Lock the privilege of screen share, only the host(manager) can share.

    • Only the host or manager has the permission.
    • If the non-host is sharing the screen, once the host locked screen share, his/her sharing will be forcibly stopped.
    // host
    stream.lockShare(true);
    // sharing user
    client.on('passively-stop-share',payload=>{
     if(payload.reason==='PrivilegeChange'){
     console.log('passively stop share because of privilege change')
     }
    })
    

    Parameters

    • isLocked: boolean

      set true to lock share, or false to unlock.

    Returns ExecutedResult

muteAudio

  • Mute audio

    • If userId is not specified, this will mute muself.
    • Only the host or manager can mute others.
    • If an attendee is allowed to talk, the host can also mute him/her.

    Parameters

    • Optional userId: number

      Default undefined

    Returns ExecutedResult

pauseShareScreen

renderVideo

  • renderVideo(canvas: HTMLCanvasElement, userId: number, width: number, height: number, x: number, y: number, videoQuality: VideoQuality, additionalUserKey?: string): Promise<"" | Error>
  • Start render video

    Note

    • It works only when the video flag is true in media constraints.

    Example

    try{
      const canvas = document.querySelector('#canvas-id');
      await stream.renderVideo(canvas,userId,300,200,0,0,1);
    } catch (error)  {
      console.log(error);
    }
    

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • userId: number

      Required. The user id which to render the video.

    • width: number

      Required. Width of the video.

    • height: number

      Required. Height of the video.

      ** Note **

      The origin of the coordinates is in the lower left corner of the canvas

    • x: number

      Required. Coordinate x of video.

    • y: number

      Required. Coordinate y of video.

    • videoQuality: VideoQuality

      Required. Quality of the video. 90P/180P/360P/720P. Currently supports up to 720P

    • Optional additionalUserKey: string

      Optional. Used for render the same video on different coordinate of the canvas.

    Returns Promise<"" | Error>

    • '': Success
    • Error: Failure. Deatils in ErrorTypes.

resumeShareScreen

startAudio

  • Join audio by the microphone and speaker.

    • It works only the audio flag is true in the media constraints.
    • If the participant has joined audio by the phone, he/she cannot join the computer audio.
    await client.init();
    await client.join(topic, signature, username, password);
    const stream = client.getMediaStream();
    await stream.startAudio();
    

    Returns ExecutedResult

    executed promise. Following are the possible error reasons:

    • type=USER_FORBIDDEN_MICROPHONE: The user has blocked accesses to the microphone from the sdk, try to grant the privilege and rejoin the meeting.

startShareScreen

  • Start screen share.

    • Check the share privilege before start screen share.
    • If you start screen share, you will stop reveived others shared content.
    • Legacy Chrome browser need to install chrome extension before start screen share, check the promise return value.

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas which renders the screen share content.

    Returns ExecutedResult

    executed promise.

    • {type:'INVALID_OPERATION', reason:'required extension', extensionUrl:'url'} : Installed the extension before start share

startShareView

  • startShareView(canvas: HTMLCanvasElement, activeUserId: number): ExecutedResult
  • Render the received screen share content.

    • It is usually called in the active-share-change callback.
    client.on('active-share-change',payload=>{
     if(payload.state==='Active'){
      stream.startShareView(payload.activeUserId,canvas);
     }else if(payload.state==='Inactive'){
      stream.stopShareView();
     }
    })
    

    Parameters

    • canvas: HTMLCanvasElement

      Required. the canvas to render the share content

    • activeUserId: number

      Required. active share user id

    Returns ExecutedResult

    executed promise.

startVideo

  • Start capture video by a specified camera.

    Note

    • It may take user some time to allow browser access camera device. Therefore there is no default timeout.

    Example

    try {
      await stream.startVideo();
    } catch (error) {
      console.log(error);
    }
    

    Parameters

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Errors besides ErrorTypes that may be returned are listed below.
      • CAN_NOT_DETECT_CAMERA: Cannot detect camera device.
      • CAN_NOT_FIND_CAMERA: The provided camera device id is not included in camera device list.
      • VIDEO_USER_FORBIDDEN_CAPTURE: The user has forbidden use camera, he/she can allow camera and rejoin the meeting.
      • VIDEO_ESTABLISH_STREAM_ERROR: Video websocket is broken.
      • VIDEO_CAMERA_IS_TAKEN: User's camera is taken by other programs.

stopAudio

  • Leave the computer audio

    • It works only the audio flag is true in the media constraints.

    Returns ExecutedResult

stopRenderVideo

  • stopRenderVideo(canvas: HTMLCanvasElement, userId: number, additionalUserKey?: string, underlyingColor?: UnderlyingColor, isKeepLastFrame?: boolean): ExecutedResult
  • Stop render the video.

    Note

    • It works only when the video flag is true in media constraints.

    Example

    try{
      await stream.stopRenderVideo();
    } catch (error)  {
      console.log(error);
    }
    

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • userId: number

      Required. The user id which to render the video.

    • Optional additionalUserKey: string

      Optional. Must be paired with renderVideo.

    • Optional underlyingColor: UnderlyingColor

      Optional. Underlying color when video is stopped,default is transparent.

    • Optional isKeepLastFrame: boolean

      Optional. Whether keep the last frame when stop the video.

    Returns ExecutedResult

    • '': Success.
    • Error: Failure. Details in ErrorTypes.

stopShareScreen

stopShareView

  • Stop render received screen share content.

    Returns ExecutedResult

    executed promise.

stopVideo

  • Stop current video capturing.

    Example

    try{
      await stream.stopVideo();
    } catch (error) {
      console.log(error);
    }
    

    Returns ExecutedResult

    • '': Success
    • Error: Failure. Details in ErrorTypes.

switchCamera

  • Change camera device for capturing video.

    Note

    • The camera device id is accessible only after the user allows the browser to access camera devices.

    Example

    try{
      const newCameraDeviceId = stream.getCameraList()[0];
      await stream.switchCamera(newCameraDeviceId);
    } catch (error) {
      console.log(error);
    }
    

    Parameters

    • cameraDeviceId: string

      The id of camera device.

    Returns ExecutedResult

switchMicrophone

  • Switch the microphone

     const microphones = stream.getMicList();
     const microphone = microphones.length>0 && microphones[0];
     await switchMicrophone(microphone);
    

    Parameters

    • microphoneId: string

      the device id of microphone

    Returns ExecutedResult

switchSpeaker

  • Switch the speaker

    Parameters

    • speakerId: string

      the device id of speaker

    Returns ExecutedResult

unmuteAudio

  • Unmute audio

    • If userId is not specified, this will unmute self.
    • For privacy and security concerns, the host can not unmute the participant's audio directly, instead, the participant will receive an unmute audio consent.
    // unmute myself
    if(stream.isAllowToUnmute()){
     await stream.unmuteAudio();
    }
    // host unmute others
    await stream.unmuteAudio(userId);
    // participant side
    client.on('unmute-audio-consent',(payload)=>{
     console.log('Host ask me to unmute');
    })
    

    Parameters

    • Optional userId: number

      Default undefined

    Returns ExecutedResult

updateVideoCanvasDimension

  • updateVideoCanvasDimension(canvas: HTMLCanvasElement, width: number, height: number): ExecutedResult
  • Update the dimension of the canvas Used to update the width/height when the styed width/height changed.

    Parameters

    • canvas: HTMLCanvasElement

      Required. The canvas to render the video.

    • width: number

      Required. New width of canvas

    • height: number

      Required. New height of canvas

      • @returns
      • '': Success.
      • Error: Failure. Details in ErrorTypes.

    Returns ExecutedResult

Generated using TypeDoc