twilio/video-quickstart-android

Can't modify LocalVideoTrack video dimension on orientation change in Screen Capture

Closed this issue · 0 comments

Description

After starting screen capture and connecting to a room, everything works fine. But I cannot change the video dimension on screen orientation change. I have tried different hacks but Twilio SDK will rather send them as different videos in the cloud when I override void onConfigurationChanged(@nonnull Configuration newConfig).

Steps to Reproduce

  1. After connecting to a room
  2. override void onConfigurationChanged(@nonnull Configuration newConfig) to change dimension on landscape and potrait mode (different dimension)
  3. It creates different videos on the cloud

Code

@Override
    public void onConfigurationChanged(@NonNull Configuration newConfig) {
        super.onConfigurationChanged(newConfig);
        if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if(localParticipant != null) {
                VideoDimensions dimen = new VideoDimensions(VideoDimensions.HD_720P_VIDEO_HEIGHT, VideoDimensions.HD_720P_VIDEO_WIDTH);
                videoFormat = new VideoFormat(dimen, 15);
                localParticipant.unpublishTrack(screenVideoTrack);
                screenVideoTrack.release();
                screenVideoTrack = LocalVideoTrack.create(this, true, screenCapturer, videoFormat);
                localVideoView.setVisibility(View.VISIBLE);
                screenVideoTrack.addSink(localVideoView);
                localParticipant.publishTrack(screenVideoTrack);
            }
        }else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT){
            if(localParticipant != null) {
                videoFormat = new VideoFormat(VideoDimensions.HD_720P_VIDEO_DIMENSIONS, 15);
                localParticipant.unpublishTrack(screenVideoTrack);
                screenVideoTrack.release();
                screenVideoTrack = LocalVideoTrack.create(this, true, screenCapturer, videoFormat);
                localVideoView.setVisibility(View.VISIBLE);
                screenVideoTrack.addSink(localVideoView);
                localParticipant.publishTrack(screenVideoTrack);
            }
        }
    }

Expected Behavior

I want the dimension to adjust to new dimension on runtime and not create different videos with the new dimension

Actual Behavior

It creates a new video with the new dimension

Reproduces how Often

100%

Logs

No logs as it doesn't cause any crash

Versions

'com.twilio:video-android:7.5.1'

Video Android SDK

7.5.1

Android API

Android 12

Android Device

Samsung S20