8000 web/rtc_peerconnection_impl.dart -> addTransceiver fails, due to missing conversion of RTCRtpMediaType to string · Issue #437 · flutter-webrtc/flutter-webrtc · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

8000
Appearance settings
web/rtc_peerconnection_impl.dart -> addTransceiver fails, due to missing conversion of RTCRtpMediaType to string #437
Closed
@jokrey

Description

@jokrey

Describe the bug
Receive the following error, when calling the code in 'To Reproduce' Section.

TypeError: Failed to execute 'addTransceiver' on 'RTCPeerConnection': The argument provided as parameter 1 is not a valid MediaStreamTrack
kind ('audio' or 'video').

To Reproduce
Calling the following code on a properly instantiated(createOffer etc.) peer connection in Chrome - Version 87.0.4280.88 (Official Build) (64-bit):

peerConnection.addTransceiver(
    kind: RTCRtpMediaType.RTCRtpMediaTypeAudio,
    init: RTCRtpTransceiverInit(
      direction: TransceiverDirection.RecvOnly
    )
);

Expected behavior
The transceiver should be added to the peer connection. In android this works as expected.

The error occurs, because the implementation web/rtc_peerconnection_impl.dart -> addTransceiver (lines: 341-352), fails to convert the RTCRtpMediaType to string.
The mapping exists ('typeRTCRtpMediaTypetoString') in enums.dart, but is not called.
I also found that the error is fixed in branch 'add-unfied-plan-for-flutter-web'.

I suggest a quick fix, independent of that branch.
The following should work:

  //'audio|video', { 'direction': 'recvonly|sendonly|sendrecv' }
  @override
  Future<RTCRtpTransceiver> addTransceiver(
      {MediaStreamTrack track,
      RTCRtpMediaType kind,
      RTCRtpTransceiverInit init}) async {
    var kindOrTrack = kind == null?null : typeRTCRtpMediaTypetoString[kind];
    if(kindOrTrack == null) {
        kindOrTrack = (track as MediaStreamTrackWeb).jsTrack;
    }
    final jsOptions = jsutil
        .jsify(init != null ? RTCRtpTransceiverInitWeb.initToMap(init) : {});
    var transceiver =
        jsutil.callMethod(_jsPc, 'addTransceiver', [kindOrTrack, jsOptions]);
    return RTCRtpTransceiverWeb.fromJsObject(transceiver,
        peerConnectionId: _peerConnectionId);
  }

Platform information

  • Flutter version
    [✓] Flutter (Channel master, 1.26.0-2.0.pre.91, on Linux, locale en_US.UTF-8)
  • Plugin version:
    0.5.7
  • OS: Chrome
  • OS version:
    Version 87.0.4280.88 (Official Build) (64-bit).

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

      0