Adjust Rendered Video Position returns Error: User Id is Not Correct

Description
I am having an error when I call the mediaStream?.adjustRenderedVideoPosition() method. I called this method when the video element could not be found in the non-shared array buffer Video container. So instead of using the video element to render, I used the canvas element.
I would appreciate response ASAP. Thanks.

Browser Console Error

Object { type: "INVALID_PARAMETERS", reason: "userId is not correct" }
​
reason: "userId is not correct"
​
type: "INVALID_PARAMETERS"
​

Which Web Video SDK version?
1.9.5

Video SDK Code Snippets
Below is a snippet of the code used:

const startVideoWithCanvas = useCallback(async() => {
        const startVideoOptions = { hd: true };
        if (mediaStream?.isSupportVirtualBackground() && isBlur) {
            Object.assign(startVideoOptions, { virtualBackground: { imageUrl: 'blur' } });
        }

        try {
            await mediaStream?.startVideo(startVideoOptions).catch((err) => {
                message.error('Die Videoaufnahme konnte nicht gestartet werden.');
                setIsCameraDisabled(() => true);
                console.log('217 could not start video');
            });
        } catch (error) {
            console.log(error);
        }

        if (!mediaStream?.isSupportMultipleVideos()) {
            console.log('selfVideoLayout', selfVideoLayout);

            if(!visibleParticipants) {
                return;
            }

            if(!videoRef)
            {
                return;
            }

            const index = visibleParticipants.findIndex(
                (user) => user.userId === zmClient.getCurrentUserInfo().userId
            );

            if (index > selfVideoLayout.length - 1 || index < 0) {
                return;
            }

            console.log('visibleParticipants userId', visibleParticipants[index].userId);
            console.log('currentUserInfo userId', zmClient.getCurrentUserInfo().userId);
            console.log('sessionInfo userId', zmClient.getSessionInfo().userId);

            let dimension = selfVideoLayout[index];
            const { width: w, height: h, x: _x, y: _y } = dimension;
            const { height: canvasHeight } = canvasDimension;

            let width = w;
            let height = h;
            let y = canvasHeight - _y - height;
            let x = _x;

            console.log('w, h, y, x', width, height, x, y);

            try {
                mediaStream?.adjustRenderedVideoPosition(
                    canvasElement,
                    zmClient.getSessionInfo().userId,
                    width,
                    height,
                    x,
                    y
                ).catch(err => {
                    console.log(err);
                });

                mediaStream?.renderVideo(
                    canvasElement, 
                    zmClient.getCurrentUserInfo().userId, 
                    width, 
                    height, 
                    _x, 
                    y, 
                    3
                ).then(() => {
                    console.log('Started video with x at ', _x);
                }).catch((err) => {
                    console.log(err);
                    message.error('Die Videoaufnahme konnte nicht gestartet werden.');
                    setIsCameraDisabled(() => true);
                    console.log('201 could not start video');
                });
            } catch (error) {
                console.log(error);
            }
        }
    }, [canvasDimension, canvasElement, isBlur, mediaStream, selfVideoLayout, videoRef, visibleParticipants, zmClient]);

From the console logs above you would notice that the ids returned are the same. But the SDK API returns an error.

Hey @godwin.owonam

Thanks for your feedback.

reason: “userId is not correct”

type: “INVALID_PARAMETERS”

Typically, this error occurs when the video has not been rendered yet, but the stream.adjustRenderedVideoPosition method is called. This call is ineffective.

In practical scenarios, this error has no other side effects; it simply indicates that adjusting the position or size of the video is invalid.

Perhaps we should consider downgrading the error level to a warning in the next version.

Thanks
Vic

Thanks @vic.yang

Definitely. The error should be more descriptive. Because this misled me to think there was something wrong with the SDK that it could not recognize the user Id.

Furthermore, I have tried calling this method after calling the renderVideo() method. Perhaps the renderVideo() method did not resolve before the adjustRenderedVideoPosition() executed, but I still got the same error.

Is this me calling it wrongly as well?

Hey @godwin.owonam

Correct.

You have to wait for the renderVideo() method to get resolved before calling the stream.adjustRenderedVideoPosition method.

Thanks
Vic

1 Like

Okay. Thanks. This helped.

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