AgoraIO / API-Examples

Play with AgoraSDK and have fun! Everything you need to start learning Agora.
304 stars 218 forks source link

Local video orientation is incorrect starting 3.7.0 #293

Open ArcherEmiya05 opened 2 years ago

ArcherEmiya05 commented 2 years ago

Migrating from 3.4.2 to 3.7.0, CreateRendererView has been deprecated thus we update it using the plain SurfaceView

Old code

SurfaceView surface = RtcEngine.CreateRendererView(this);
        surface.setZOrderOnTop(true);
        rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas.RENDER_MODE_FILL, 0));
        mLocalPreview.addView(surface);

New code

SurfaceView surface = new SurfaceView(this);
        surface.setZOrderOnTop(true);
        rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas.RENDER_MODE_FIT, 0));
        mLocalPreview.addView(surface, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

The issue is the local video is now always landscape but its rendered remote is fine.

This is the configuration,


public static final VideoEncoderConfiguration.VideoDimensions[] VIDEO_DIMENSIONS = new VideoEncoderConfiguration.VideoDimensions[] {
            VideoEncoderConfiguration.VD_320x240,
            VideoEncoderConfiguration.VD_480x360,
            VideoEncoderConfiguration.VD_640x360,
            VideoEncoderConfiguration.VD_640x480,
            VideoEncoderConfiguration.VD_840x480,
            VideoEncoderConfiguration.VD_960x720,
            new VideoEncoderConfiguration.VideoDimensions(960, 540),
            VideoEncoderConfiguration.VD_1280x720
    };

    public static final int DEFAULT_PROFILE_IDX = 7;

rtcEngine().setVideoEncoderConfiguration(new VideoEncoderConfiguration(
                    AgoraConstants.VIDEO_DIMENSIONS[AgoraConstants.DEFAULT_PROFILE_IDX],
                    VideoEncoderConfiguration.FRAME_RATE.FRAME_RATE_FPS_30,
                    VideoEncoderConfiguration.STANDARD_BITRATE,
                    VideoEncoderConfiguration.ORIENTATION_MODE.ORIENTATION_MODE_FIXED_PORTRAIT
            ));

image

ArcherEmiya05 commented 2 years ago

I discover that the culprit is changing RtcEngine.CreateRendererView(this); to new SurfaceView(this); but it was stated here #283 that it is no longer recommended starting v4.

plutoless commented 2 years ago

you are using fill before but now using fit. rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas.RENDER_MODE_FILL, 0)); rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas. RENDER_MODE_FIT, 0));

ArcherEmiya05 commented 2 years ago

you are using fill before but now using fit. rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas.RENDER_MODE_FILL, 0)); rtcEngine().setupLocalVideo(new VideoCanvas(surface, VideoCanvas. RENDER_MODE_FIT, 0));

Fill is no longer available in SDK v4, the changes was meant to prepare it for migration. However is changing render mode the reason for it to rotate?