# A custom stream source is working on desktop but not on mobile

**URL:** <https://devforum.zoom.us/t/a-custom-stream-source-is-working-on-desktop-but-not-on-mobile/116768>\
**Category:** Web\
**Tags:** phone, video-sdk\
**Created:** [September 2, 2024, 7:24pm UTC](https://devforum.zoom.us/t/a-custom-stream-source-is-working-on-desktop-but-not-on-mobile/116768 "2024-09-02T19:24:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![danielgustavo](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/danielgustavo/32/62973_2.png) [@danielgustavo](https://devforum.zoom.us/u/danielgustavo)\
**Post date:** [September 2, 2024, 7:24pm UTC](https://devforum.zoom.us/t/a-custom-stream-source-is-working-on-desktop-but-not-on-mobile/116768/1 "2024-09-02T19:24:01Z")

</div>

**Description**  
In my project, the **“getUserMedia”** method was modified to create a “virtual camera”. This means that when the method is called with the virtual camera id, it will return a stream from the **“captureStream”** method of a hidden canvas element, which has a 3D avatar rendered. Additionally, the **“enumerateDevices”** method was also modified so that when it is called, the virtual camera will be listed as well.

The virtual camera id is passed in the methods **“createLocalVideoTrack”** (preview) and **“startVideo”** (actual room), and it’s working correctly in the desktop browser: the 3D avatar is streaming as expected. However, the problem I’m currently facing happens in the mobile browser: the avatar stream is working on the preview page, but not in the room, the avatar isn’t streaming (nothing is being streamed), although **it is** rendering the avatar in the canvas element correctly.

Being able to stream this avatar is essential for my project, so I would appreciate your help in making it work on mobile too.

**Browser Console Error**  
There are no console errors.

**Which Web Video SDK version?**  
^1.11.0

**Video SDK Code Snippets**

```ts
      const initialVideoOption: CaptureVideoOption = {
        hd: false,
        fullHd: false,
        ptz: false,
        originalRatio: true,
        cameraId
      }

      if (anonymous) {
        await startEngine(cameraId)
        initialVideoOption.cameraId = 'jb_virtual_cam'

        await mediaStream?.startVideo(initialVideoOption)
      }

```

- The method **startEngine** starts the avatar render and it’s working as expected.
- **“jb\_virtual\_cam”** is the id of the “virtual camera”
- The method “startVideo” should stream the canvas stream from the device **“jb\_virtual\_cam”** , but it isn’t working on mobile.

**To Reproduce**

1. modify the method **enumerateDevices**

```auto
  MediaDevices.prototype.enumerateDevices = async function () {
    const res = await enumerateDevicesFn.call(navigator.mediaDevices)

    const dv: MediaDeviceInfoAttributes = {
      deviceId: 'custom_virtual_camera_id',
      groupId: 'custom_virtual_devices',
      kind: 'videoinput',
      label: 'virtual webcam'
    }

    res.push({
      ...dv,
      toJSON: () => {
        return dv
      }
    })

    return res
  }

```

1. Modify the method **getUserMedia**

```auto
  MediaDevices.prototype.getUserMedia = async function (...args: any) {
    if (args.length && args[0].video && args[0].video.deviceId) {
      if (
        args[0].video.deviceId === 'custom_virtual_camera_id' ||
        args[0].video.deviceId.exact === 'custom_virtual_camera_id'
      ) {
        const constraints = {
          video: { ...(args?.video ?? {}) },
          audio: false
        }
        const res = await getUserMediaFn.call(
          navigator.mediaDevices,
          constraints
        )

        const canvas: HTMLCanvasElement | null = document.querySelector('#canvas-with-avatar')

        if (res && canvas) {
          return canvas.captureStream(30)
        }
      }
    }

    const res = await getUserMediaFn.call(navigator.mediaDevices, ...args)

    return res
  }

```

1. Try to use the virtual camera with the zoom video-sdk. In this case the camera id is **“custom\_virtual\_camera\_id”**

**Device:**

- Device: Motorola Moto G54
- OS: Android 14
- Browser: Chrome
- Browser Version: Chrome 127.0.6533.106

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [October 3, 2024, 5:24am UTC](https://devforum.zoom.us/t/a-custom-stream-source-is-working-on-desktop-but-not-on-mobile/116768/2 "2024-10-03T05:24:40Z")

</div>

Closed on October 3, 2024, 5:24am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
