Skip to content

[stream_webrtc_flutter] Why is RTCVideoView is been rotated wrongly #1146

@generalomosco

Description

@generalomosco

Don't know why RTCVideoView is been rotated wrongly to landscaped on other peer, Even the video dimensions is inverted, width turn to height while height to width on using getUserMedia

navigator.mediaDevices.getUserMedia({
      'audio': true,
      'video': videoID == null || videoID.isEmpty? true : {
        'optional': [
          {'sourceId': videoID}
        ],
        'width': 480, 'height': 640
      },
    });

Image

Image

LayoutBuilder(
        builder: (context, constraints) {
          return ValueListenableBuilder<RTCVideoValue>(
              valueListenable: ps.renderer!,
              builder:
                  (BuildContext context, RTCVideoValue value, Widget? child) {
                if(!forcedCover){
                  forcedCover = canCoverVideoToScreen(
                      constraints.maxWidth,
                      constraints.maxHeight,
                      ps.renderer!.videoWidth.toDouble(),
                      ps.renderer!.videoHeight.toDouble());
                }
                return Container(
                  margin: const EdgeInsets.all(1),
                  decoration: BoxDecoration(
                    color: Colors.blue,
                    borderRadius: BorderRadius.circular(12),
                  ),
                  child: Stack(
                      children: [
                        RTCVideoView(
                    ps.renderer!,
                    objectFit: forcedCover?RTCVideoViewObjectFit
                        .RTCVideoViewObjectFitCover:RTCVideoViewObjectFit
                        .RTCVideoViewObjectFitContain,
                    mirror: ps.isMirror,
                  ),
                        Text(
                          "value.width:${ps.renderer!.videoWidth}x${ps.renderer!.videoHeight}",
                          style: TextStyle(color:Colors.red),
                        )]),
                );
              });
        });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions