Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I need help,always RTCPeerConnectionStateFailed #1557

Open
caigp opened this issue Apr 3, 2024 · 4 comments
Open

I need help,always RTCPeerConnectionStateFailed #1557

caigp opened this issue Apr 3, 2024 · 4 comments

Comments

@caigp
Copy link

caigp commented Apr 3, 2024

Describe the bug

To Reproduce

Expected behavior

Platform information

  • Flutter version: 3.16.8
  • Plugin version:0.9.48+hotfix.1
  • OS: Android
  • OS version: all

this my code, change info by websocket

import 'dart:convert';
import 'dart:io';

import 'package:flutter/material.dart';
import 'package:flutter_webrtc/flutter_webrtc.dart';
import 'package:freechat/Constant.dart';
import 'package:freechat/EventBus.dart';

class P2PVideoWidget extends StatelessWidget {

  dynamic arguments;

  @override
  Widget build(BuildContext context) {
    arguments = ModalRoute.of(context)?.settings.arguments;
    return _P2PVideoWidget(this.arguments);
  }
}

class _P2PVideoWidget extends StatefulWidget {

  final dynamic args;

  _P2PVideoWidget(this.args);

  @override
  State<StatefulWidget> createState() {
    return _P2PVideoWidgetState(args);
  }
}

class _P2PVideoWidgetState extends State<_P2PVideoWidget> {

  dynamic args;


  _P2PVideoWidgetState(this.args);

  RTCVideoRenderer _localRenderer = RTCVideoRenderer();
  RTCVideoRenderer _remoteRenderer = RTCVideoRenderer();
  String get sdpSemantics => 'unified-plan';
  MediaStream? _localStream;
  List<RTCRtpSender> _senders = <RTCRtpSender>[];
  late RTCPeerConnection pc;
  List<RTCIceCandidate> _ices = <RTCIceCandidate>[];

  @override
  void initState() {
    initPeer();
    bus.on(BusNames.call_action, (str) {
      print('webrtc -> $str');
      dynamic arg = jsonDecode(str);
      var action = arg['action'];
      switch(action) {
        case 'remoteSdp':
          setRemoteSdp(arg);

          break;
        case 'ice':

          addIce(arg);
          break;
        case 'hangup':
          Navigator.pop(context);
          break;
      }
    });
    super.initState();
  }

  void setRemoteSdp(arg) async {
    RTCSessionDescription description = RTCSessionDescription(arg['sdp']['sdp'], arg['sdp']['type']);
    await pc.setRemoteDescription(description);

    _ices.forEach((ice) {
      var json = {
        'action': 'ice',
        'type': 1,
        'fromInfo': args['fromInfo'],
        'toInfo': args['toInfo'],
        'ice': ice.toMap()
      };

      bus.emit(BusNames.websocket, jsonEncode(json));
    });
  }

  void addIce(arg) async {
    RTCIceCandidate candidate = RTCIceCandidate(arg['ice']['candidate'], arg['ice']['sdpMid'], arg['ice']['sdpMLineIndex']);
    await pc.addCandidate(candidate);
  }

  @override
  deactivate() {
    super.deactivate();
    _clean();
    bus.off(BusNames.call_action);
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: Stack(
        children: [
          RTCVideoView(_remoteRenderer),
          Container(
            width: 240,
            height: 240,
            child: RTCVideoView(_localRenderer, objectFit: RTCVideoViewObjectFit.RTCVideoViewObjectFitCover,),
          ),
          Column(
            children: [
              Expanded(child: Container(), flex: 8,),
              GestureDetector(
                child: Container(
                  child: Icon(Icons.call_end, size: 24,),
                  decoration: BoxDecoration(
                      color: Colors.red,
                      shape: BoxShape.circle
                  ),
                  padding: EdgeInsets.all(24),
                  margin: EdgeInsets.only(bottom: 8),
                ),
                onTap: () {
                  Navigator.pop(context);

                  var v = {
                    'action': 'hangup',
                    'type': 1,
                  };

                  if (args['sdp'] == null) {
                    v['fromInfo'] = args['fromInfo'];
                    v['toInfo'] = args['toInfo'];
                  } else {
                    v['fromInfo'] = args['toInfo'];
                    v['toInfo'] = args['fromInfo'];
                  }

                  bus.emit(BusNames.websocket, jsonEncode(v));

                },
              ),
              Expanded(child: Container(), flex: 1,),
            ],
            mainAxisAlignment: MainAxisAlignment.center,
          )
        ],
      ),
    );
  }

  void initPeer() async {
    await _localRenderer.initialize();
    await _remoteRenderer.initialize();

    Map<String, dynamic> _iceServers = {
      'iceServers': [
        {'url': 'stun:stun.l.google.com:19302'},
        /*
       * turn server configuration example.
      {
        'url': 'turn:123.45.67.89:3478',
        'username': 'change_to_real_user',
        'credential': 'change_to_real_secret'
      },
      */
      ]
    };

    final Map<String, dynamic> _config = {
      'mandatory': {},
      'optional': [
        {'DtlsSrtpKeyAgreement': true},
      ]
    };

    final Map<String, dynamic> _dcConstraints = {
      'mandatory': {
        'OfferToReceiveAudio': false,
        'OfferToReceiveVideo': false,
      },
      'optional': [],
    };

    final Map<String, dynamic> mediaConstraints = {
      'audio': true,
      'video': {
        'mandatory': {
          'minWidth':
          '1280', // Provide your own width, height and frame rate here
          'minHeight': '720',
          'minFrameRate': '15',
        },
        'facingMode': 'user',
        'optional': [],
      }
    };

    _localStream = await navigator.mediaDevices.getUserMedia(mediaConstraints);

    setState(() {
      _localRenderer.srcObject = _localStream;
    });

    pc = await createPeerConnection(_iceServers);

    pc.onTrack = (event) {
      if (event.track.kind == 'video') {

      }
    };
    _localStream!.getTracks().forEach((track) async {
      _senders.add(await pc.addTrack(track, _localStream!));
    });

    pc.onIceCandidate = (RTCIceCandidate candidate) async {
      print('ice -> ${candidate.toMap()}');

      if (args['sdp'] == null) {
        _ices.add(candidate);
      } else {
        var json = {
          'action': 'ice',
          'type': 1,
          'fromInfo': args['toInfo'],
          'toInfo': args['fromInfo'],
          'ice': candidate.toMap()
        };

        bus.emit(BusNames.websocket, jsonEncode(json));
      }
    };

    pc.onIceConnectionState = (RTCIceConnectionState state) {
      print('onIceConnectionState -> ${state.name}');
    };

    pc.onRemoveStream = (stream) {

    };

    pc.onAddStream = (stream) {
      setState(() {
        _remoteRenderer.srcObject = stream;
      });
    };

    pc.onSignalingState = (state) {
      print('onSignalingState -> ${state.toString()}');
    };
    pc.onConnectionState = (state) {
      print('onConnectionState -> ${state.toString()}');
    };
    pc.onIceGatheringState = (state) {
      print('onIceGatheringState -> ${state.toString()}');
    };

    if (args['sdp'] == null) {
      RTCSessionDescription s = await pc.createOffer();
      await pc.setLocalDescription(s);

      var json = {
        'action': 'call',
        'type': 1,
        'fromInfo': args['fromInfo'],
        'toInfo': args['toInfo'],
        'sdp': s.toMap()
      };

      bus.emit(BusNames.websocket, jsonEncode(json));
    } else {
      RTCSessionDescription description = RTCSessionDescription(args['sdp']['sdp'], args['sdp']['type']);
      await pc.setRemoteDescription(description);

      RTCSessionDescription s = await pc.createAnswer();
      await pc.setLocalDescription(s);

      var json = {
        'action': 'remoteSdp',
        'type': 1,
        'fromInfo': args['toInfo'],
        'toInfo': args['fromInfo'],
        'sdp': s.toMap()
      };

      bus.emit(BusNames.websocket, jsonEncode(json));
    }

  }

  RTCSessionDescription _fixSdp(RTCSessionDescription s) {
    var sdp = s.sdp;
    s.sdp =
        sdp!.replaceAll('profile-level-id=640c1f', 'profile-level-id=42e032');
    return s;
  }

  Future<MediaStream> createStream(String media, bool userScreen,
      {BuildContext? context}) async {
    final Map<String, dynamic> mediaConstraints = {
      'audio': userScreen ? false : true,
      'video': userScreen
          ? true
          : {
        'mandatory': {
          'minWidth':
          '640', // Provide your own width, height and frame rate here
          'minHeight': '480',
          'minFrameRate': '30',
        },
        'facingMode': 'user',
        'optional': [],
      }
    };
    late MediaStream stream;
    if (userScreen) {
      if (WebRTC.platformIsDesktop) {
        /*final source = await showDialog<DesktopCapturerSource>(
          context: context!,
          builder: (context) => ScreenSelectDialog(),
        );
        stream = await navigator.mediaDevices.getDisplayMedia(<String, dynamic>{
          'video': source == null
              ? true
              : {
            'deviceId': {'exact': source.id},
            'mandatory': {'frameRate': 30.0}
          }
        });*/
      } else {
        stream = await navigator.mediaDevices.getDisplayMedia(mediaConstraints);
      }
    } else {
      stream = await navigator.mediaDevices.getUserMedia(mediaConstraints);
    }

    setState(() {
      _localRenderer.srcObject = stream;
    });

    return stream;
  }

  void _clean() async {
    await _localRenderer.dispose();
    await _remoteRenderer.dispose();

    if (_localStream != null) {
      _localStream!.getTracks().forEach((element) async {
        await element.stop();
      });
      await _localStream!.dispose();
    _localStream = null;
    }

    await pc.dispose();
  }

}

this my logcat, this device is 测试人员

I/org.webrtc.Logging(14566):
I/org.webrtc.Logging(14566): EglRenderer: EglBase.create shared context
D/HostConnection(14566): HostConnection::get() New Host Connection established 0xe9635fb0, tid 15058
D/HostConnection(14566): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 
I/org.webrtc.Logging(14566): EglBase14Impl: Using OpenGL ES version 2
D/eglCodecCommon(14566): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14566): eglCreateContext: 0xe9607f40: maj 3 min 1 rcv 4
D/EGL_emulation(14566): eglMakeCurrent: 0xe9607f40: ver 3 1 (tinfo 0xc3d62ca0)
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
I/org.webrtc.Logging(14566): EglRenderer: Initializing EglRenderer
I/org.webrtc.Logging(14566): EglRenderer: EglBase.create shared context
D/HostConnection(14566): HostConnection::get() New Host Connection established 0xe7e2ed50, tid 15059
D/HostConnection(14566): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 
I/org.webrtc.Logging(14566): EglBase14Impl: Using OpenGL ES version 2
D/eglCodecCommon(14566): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14566): eglCreateContext: 0xeff60be0: maj 3 min 1 rcv 4
I/FlutterWebRTCPlugin(14566): getUserMedia(audio): mandatory: [], optional: [googNoiseSuppression: true, googEchoCancellation: true, echoCancellation: true, googEchoCancellation2: true, googDAEchoCancellation: true]
D/EGL_emulation(14566): eglMakeCurrent: 0xeff60be0: ver 3 1 (tinfo 0xe6c6efd0)
I/FlutterWebRTCPlugin(14566): getUserMedia(video): ConstraintsMap{mMap={facingMode=user, optional=[], mandatory={minHeight=720, minFrameRate=15, minWidth=1280}}}
D/FlutterWebRTCPlugin(14566): Creating video capturer using Camera2 API.
D/FlutterWebRTCPlugin(14566): Create front camera 1 succeeded
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
D/HostConnection(14566): HostConnection::get() New Host Connection established 0xcf62ba60, tid 15060
D/HostConnection(14566): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 
I/org.webrtc.Logging(14566): EglBase14Impl: Using OpenGL ES version 2
D/eglCodecCommon(14566): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14566): eglCreateContext: 0xc3c138a0: maj 3 min 1 rcv 4
D/EGL_emulation(14566): eglMakeCurrent: 0xc3c138a0: ver 3 1 (tinfo 0xc3c29780)
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/EGL_emulation(14566): eglQueryContext 32c0  EGL_BAD_ATTRIBUTE
E/EGL_emulation(14566): tid 15060: eglQueryContext(1902): error 0x3004 (EGL_BAD_ATTRIBUTE)
I/org.webrtc.Logging(14566): CameraCapturer: startCapture: 1280x720@15
D/FlutterWebRTCPlugin(14566): changeCaptureFormat: 1280x720@15
I/org.webrtc.Logging(14566): Camera2Session: Create new camera2 session on camera 1
D/FlutterWebRTCPlugin(14566): MediaStream id: 4802d220-53bb-48b9-8d34-1c296c2e7162
I/org.webrtc.Logging(14566): Camera2Session: start
I/org.webrtc.Logging(14566): Camera2Session: Available preview sizes: [320x240, 176x144, 1280x720, 640x480, 1280x720]
I/org.webrtc.Logging(14566): Camera2Session: Available fps ranges: [[15.0:30.0], [30.0:30.0]]
I/org.webrtc.Logging(14566): Camera2Session: Using capture format: 1280x720@[15.0:30.0]
I/org.webrtc.Logging(14566): Camera2Session: Opening camera 1
D/FlutterWebRTCPlugin(14566): CameraEventsHandler.onCameraOpening: cameraName=1
I/org.webrtc.Logging(14566): Camera2Session: Camera opened.
W/FlutterWebRTCPlugin(14566): FlutterRTCVideoRenderer.setVideoTrack, set video track to 4cc45a21-e69e-4cec-b1bd-baf8590e80d7
I/org.webrtc.Logging(14566): EglRenderer: Releasing.
I/org.webrtc.Logging(14566): EglRenderer: eglBase detach and release.
I/org.webrtc.Logging(14566): EglRenderer: Releasing done.
I/org.webrtc.Logging(14566): EglRenderer: Quitting render thread.
I/org.webrtc.Logging(14566): EglRenderer: Initializing EglRenderer
I/org.webrtc.Logging(14566): Camera2Session: Camera capture session configured.
I/org.webrtc.Logging(14566): Camera2Session: Stabilization not available.
I/org.webrtc.Logging(14566): Camera2Session: Using continuous video auto-focus.
I/org.webrtc.Logging(14566): EglRenderer: EglBase.create shared context
D/HostConnection(14566): HostConnection::get() New Host Connection established 0xe9635fb0, tid 15066
D/HostConnection(14566): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 
I/org.webrtc.Logging(14566): EglBase14Impl: Using OpenGL ES version 2
I/org.webrtc.Logging(14566): Camera2Session: Camera device successfully started.
I/org.webrtc.Logging(14566): CameraCapturer: Create session done. Switch state: IDLE
I/org.webrtc.Logging(14566): SurfaceTextureHelper: Setting listener to org.webrtc.Camera2Session$CaptureSessionCallback$$ExternalSyntheticLambda0@81383fd
D/eglCodecCommon(14566): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14566): eglCreateContext: 0xe9607f40: maj 3 min 1 rcv 4
D/EGL_emulation(14566): eglMakeCurrent: 0xe9607f40: ver 3 1 (tinfo 0xc3d62ca0)
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
I/org.webrtc.Logging(14566): NetworkMonitor: Start monitoring with native observer -404177424 fieldTrialsString: 
D/FlutterWebRTCPlugin(14566): onIceGatheringChangeGATHERING
I/flutter (14566): onSignalingState -> RTCSignalingState.RTCSignalingStateHaveLocalOffer
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/chatty  (14566): uid=10085(com.example.freechat) signaling_threa identical 10 lines
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: Network handle: 437197393933 becomes available: 101
I/flutter (14566): onIceGatheringState -> RTCIceGatheringState.RTCIceGatheringStateGathering
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: handle: 437197393933 capabilities changed: [ Transports: WIFI Capabilities: NOT_METERED&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&NOT_ROAMING&FOREGROUND&NOT_CONGESTED&NOT_SUSPENDED Unwanted:  LinkUpBandwidth>=1048576Kbps LinkDnBandwidth>=1048576Kbps SignalStrength: -50 SSID: "AndroidWifi"]
I/flutter (14566): ice -> {candidate: candidate:2125347159 1 udp 2122260223 192.168.232.2 54673 typ host generation 0 ufrag 1v/D network-id 5 network-cost 10, sdpMid: 0, sdpMLineIndex: 0}
I/flutter (14566): ice -> {candidate: candidate:2125347159 1 udp 2122129151 192.168.232.2 60240 typ host generation 0 ufrag 1v/D network-id 3 network-cost 900, sdpMid: 0, sdpMLineIndex: 0}
D/FlutterWebRTCPlugin(14566): CameraEventsHandler.onFirstFrameAvailable
I/flutter (14566): ice -> {candidate: candidate:1722155744 1 udp 2121932543 127.0.0.1 43248 typ host generation 0 ufrag 1v/D network-id 1, sdpMid: 0, sdpMLineIndex: 0}
I/flutter (14566): ice -> {candidate: candidate:80733496 1 udp 2122187263 fec0::15:b2ff:fe00:0 48730 typ host generation 0 ufrag 1v/D network-id 6 network-cost 10, sdpMid: 0, sdpMLineIndex: 0}
D/FlutterWebRTCPlugin(14566): onIceCandidate
D/FlutterWebRTCPlugin(14566): onIceCandidate
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/flutter (14566): ice -> {candidate: candidate:80733496 1 udp 2122056191 fec0::15:b2ff:fe00:0 52152 typ host generation 0 ufrag 1v/D network-id 4 network-cost 900, sdpMid: 0, sdpMLineIndex: 0}
D/FlutterWebRTCPlugin(14566): onIceCandidate
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/flutter (14566): ice -> {candidate: candidate:1048053929 1 udp 2122005759 ::1 48392 typ host generation 0 ufrag 1v/D network-id 2, sdpMid: 0, sdpMLineIndex: 0}
I/flutter (14566): ice -> {candidate: candidate:2125347159 1 udp 2122260223 192.168.232.2 53657 typ host generation 0 ufrag 1v/D network-id 5 network-cost 10, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:2125347159 1 udp 2122129151 192.168.232.2 34281 typ host generation 0 ufrag 1v/D network-id 3 network-cost 900, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:1722155744 1 udp 2121932543 127.0.0.1 56627 typ host generation 0 ufrag 1v/D network-id 1, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:80733496 1 udp 2122187263 fec0::15:b2ff:fe00:0 40721 typ host generation 0 ufrag 1v/D network-id 6 network-cost 10, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:80733496 1 udp 2122056191 fec0::15:b2ff:fe00:0 39524 typ host generation 0 ufrag 1v/D network-id 4 network-cost 900, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:1048053929 1 udp 2122005759 ::1 53080 typ host generation 0 ufrag 1v/D network-id 2, sdpMid: 1, sdpMLineIndex: 1}
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: handle: 437197393933 link properties changed
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: Network handle: 432902426637 becomes available: 100
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: handle: 432902426637 capabilities changed: [ Transports: CELLULAR Capabilities: MMS&SUPL&DUN&FOTA&IMS&CBS&IA&INTERNET&NOT_RESTRICTED&TRUSTED&NOT_VPN&NOT_ROAMING&FOREGROUND&NOT_CONGESTED&NOT_SUSPENDED Unwanted:  LinkUpBandwidth>=51200Kbps LinkDnBandwidth>=102400Kbps Specifier: <1>]
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/org.webrtc.Logging(14566): NetworkMonitorAutoDetect: handle: 432902426637 link properties changed
I/flutter (14566): ice -> {candidate: candidate:2550978164 1 tcp 1517952767 127.0.0.1 35155 typ host tcptype passive generation 0 ufrag 1v/D network-id 1, sdpMid: 0, sdpMLineIndex: 0}
I/flutter (14566): ice -> {candidate: candidate:3235044413 1 tcp 1518025983 ::1 43507 typ host tcptype passive generation 0 ufrag 1v/D network-id 2, sdpMid: 0, sdpMLineIndex: 0}
I/flutter (14566): ice -> {candidate: candidate:2550978164 1 tcp 1517952767 127.0.0.1 52365 typ host tcptype passive generation 0 ufrag 1v/D network-id 1, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:3235044413 1 tcp 1518025983 ::1 55097 typ host tcptype passive generation 0 ufrag 1v/D network-id 2, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:2483181349 1 udp 1686052607 183.238.242.125 50152 typ srflx raddr 192.168.232.2 rport 53657 generation 0 ufrag 1v/D network-id 5 network-cost 10, sdpMid: 1, sdpMLineIndex: 1}
I/flutter (14566): ice -> {candidate: candidate:2483181349 1 udp 1686052607 183.238.242.125 50153 typ srflx raddr 192.168.232.2 rport 54673 generation 0 ufrag 1v/D network-id 5 network-cost 10, sdpMid: 0, sdpMLineIndex: 0}
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/flutter (14566): ice -> {candidate: candidate:2483181349 1 udp 1685921535 183.238.242.125 50155 typ srflx raddr 192.168.232.2 rport 34281 generation 0 ufrag 1v/D network-id 3 network-cost 900, sdpMid: 1, sdpMLineIndex: 1}
D/FlutterWebRTCPlugin(14566): onIceCandidate
I/flutter (14566): ice -> {candidate: candidate:2483181349 1 udp 1685921535 183.238.242.125 50157 typ srflx raddr 192.168.232.2 rport 60240 generation 0 ufrag 1v/D network-id 3 network-cost 900, sdpMid: 0, sdpMLineIndex: 0}
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 25.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4007 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4006 ms. Frames received: 59. Dropped: 0. Rendered: 59. Render fps: 14.7. Average render time: 4162 us. Average swapBuffer time: 3215 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 28.
I/flutter (14566): {"action":"remoteSdp","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"sdp":{"sdp":"v=0\r\no=- 1842316625941188663 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS b97e56d2-6202-466a-b248-837d4702f04e\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 102 0 8 13 110 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:/2BJ\r\na=ice-pwd:ggVMxtN318Iq25Hcb/ohlVOH\r\na=ice-options:trickle renomination\r\na=fingerprint:sha-256 A6:AF:E0:7B:A4:63:55:2D:2E:09:A3:C7:15:B9:DE:F6:55:42:99:0F:FE:C5:11:B2:B2:C1:ED:D0:44:43:35:37\r\na=setup:active\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-extensions
I/flutter (14566): webrtc -> {"action":"remoteSdp","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"sdp":{"sdp":"v=0\r\no=- 1842316625941188663 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\na=group:BUNDLE 0 1\r\na=extmap-allow-mixed\r\na=msid-semantic: WMS b97e56d2-6202-466a-b248-837d4702f04e\r\nm=audio 9 UDP/TLS/RTP/SAVPF 111 63 9 102 0 8 13 110 126\r\nc=IN IP4 0.0.0.0\r\na=rtcp:9 IN IP4 0.0.0.0\r\na=ice-ufrag:/2BJ\r\na=ice-pwd:ggVMxtN318Iq25Hcb/ohlVOH\r\na=ice-options:trickle renomination\r\na=fingerprint:sha-256 A6:AF:E0:7B:A4:63:55:2D:2E:09:A3:C7:15:B9:DE:F6:55:42:99:0F:FE:C5:11:B2:B2:C1:ED:D0:44:43:35:37\r\na=setup:active\r\na=mid:0\r\na=extmap:1 urn:ietf:params:rtp-hdrext:ssrc-audio-level\r\na=extmap:2 http://www.webrtc.org/experiments/rtp-hdrext/abs-send-time\r\na=extmap:3 http://www.ietf.org/id/draft-holmer-rmcat-transport-wide-cc-
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:267128344 1 udp 2122260223 10.0.2.15 56552 typ host generation 0 ufrag /2BJ network-id 3 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:267128344 1 udp 2122260223 10.0.2.15 56552 typ host generation 0 ufrag /2BJ network-id 3 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: initPlayout(sampleRate=48000, channels=1, bufferSizeFactor=1.0)
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: byteBuffer.capacity: 960
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: minBufferSizeInBytes: 4616
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: createAudioTrackBeforeOreo
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: nativeOutputSampleRate: 48000
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: AudioTrack: session ID: 217, channels: 1, sample rate: 48000, max gain: 1.0
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: AudioTrack: buffer size in frames: 2308
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: AudioTrack: buffer capacity in frames: 2308
I/org.webrtc.Logging(14566): VolumeLogger: start@[name=worker_thread - 14626, id=373]
I/org.webrtc.Logging(14566): VolumeLogger: audio mode is: MODE_IN_COMMUNICATION
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: startPlayout
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:1507304423 1 udp 2122063615 127.0.0.1 58579 typ host generation 0 ufrag /2BJ network-id 1","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:1507304423 1 udp 2122063615 127.0.0.1 58579 typ host generation 0 ufrag /2BJ network-id 1","sdpMid":"0","sdpMLineIndex":0}}
D/FlutterWebRTCPlugin(14566): onAddTrack
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:803148074 1 udp 2122187263 fec0::58d3:d5ff:fe54:b676 36315 typ host generation 0 ufrag /2BJ network-id 4 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:803148074 1 udp 2122187263 fec0::58d3:d5ff:fe54:b676 36315 typ host generation 0 ufrag /2BJ network-id 4 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
D/FlutterWebRTCPlugin(14566): onAddTrack
I/org.webrtc.Logging(14566): VolumeLogger: VOICE_CALL stream volume: 4 (max=5)
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:4019321818 1 udp 2122136831 ::1 45319 typ host generation 0 ufrag /2BJ network-id 2","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:4019321818 1 udp 2122136831 ::1 45319 typ host generation 0 ufrag /2BJ network-id 2","sdpMid":"0","sdpMLineIndex":0}}
D/FlutterWebRTCPlugin(14566): onConnectionChangeCONNECTING
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: AudioTrackThread@[name=AudioTrackJavaThread, id=430]
I/org.webrtc.Logging(14566): WebRtcAudioTrackExternal: doAudioTrackStateCallback: 0
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:655901055 1 tcp 1518083839 127.0.0.1 49831 typ host tcptype passive generation 0 ufrag /2BJ network-id 1","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:655901055 1 tcp 1518083839 127.0.0.1 49831 typ host tcptype passive generation 0 ufrag /2BJ network-id 1","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): onSignalingState -> RTCSignalingState.RTCSignalingStateStable
I/flutter (14566): onIceConnectionState -> RTCIceConnectionStateChecking
W/FlutterWebRTCPlugin(14566): FlutterRTCVideoRenderer.setVideoTrack, set video track to c310c41b-447f-4b84-9ceb-8bcb9b24cff2
I/org.webrtc.Logging(14566): EglRenderer: Releasing.
I/org.webrtc.Logging(14566): EglRenderer: eglBase detach and release.
I/org.webrtc.Logging(14566): EglRenderer: Releasing done.
I/org.webrtc.Logging(14566): EglRenderer: Initializing EglRenderer
I/org.webrtc.Logging(14566): EglRenderer: Quitting render thread.
I/org.webrtc.Logging(14566): EglRenderer: EglBase.create shared context
D/HostConnection(14566): HostConnection::get() New Host Connection established 0xe7e2ed50, tid 15104
D/HostConnection(14566): HostComposition ext ANDROID_EMU_CHECKSUM_HELPER_v1 ANDROID_EMU_native_sync_v2 ANDROID_EMU_native_sync_v3 ANDROID_EMU_native_sync_v4 ANDROID_EMU_dma_v1 ANDROID_EMU_YUV420_888_to_NV21 ANDROID_EMU_YUV_Cache ANDROID_EMU_sync_buffer_data GL_OES_EGL_image_external_essl3 GL_OES_vertex_array_object GL_KHR_texture_compression_astc_ldr ANDROID_EMU_host_side_tracing ANDROID_EMU_gles_max_version_3_1 
I/org.webrtc.Logging(14566): EglBase14Impl: Using OpenGL ES version 2
I/flutter (14566): onConnectionState -> RTCPeerConnectionState.RTCPeerConnectionStateConnecting
D/eglCodecCommon(14566): setVertexArrayObject: set vao to 0 (0) 0 0
D/EGL_emulation(14566): eglCreateContext: 0xeff60be0: maj 3 min 1 rcv 4
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:2438863170 1 tcp 1518157055 ::1 60955 typ host tcptype passive generation 0 ufrag /2BJ network-id 2","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:2438863170 1 tcp 1518157055 ::1 60955 typ host tcptype passive generation 0 ufrag /2BJ network-id 2","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:2676107444 1 udp 1686052607 183.238.242.125 50163 typ srflx raddr 10.0.2.15 rport 56552 generation 0 ufrag /2BJ network-id 3 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
I/flutter (14566): webrtc -> {"action":"ice","type":1,"fromInfo":{"id":10269,"nickname":"小菜","headImg":"http://114.132.86.6:8080/images/7.jpg"},"toInfo":{"id":10266,"nickname":"测试人员","headImg":"http://114.132.86.6:8080/images/head/10266/4b9c27dd-3b6c-4141-bc97-15387f3e1d5f.jpg"},"ice":{"candidate":"candidate:2676107444 1 udp 1686052607 183.238.242.125 50163 typ srflx raddr 10.0.2.15 rport 56552 generation 0 ufrag /2BJ network-id 3 network-cost 900","sdpMid":"0","sdpMLineIndex":0}}
D/EGL_emulation(14566): eglMakeCurrent: 0xeff60be0: ver 3 1 (tinfo 0xe6c6ee20)
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
E/eglCodecCommon(14566): glUtilsParamSize: unknow param 0x000082da
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 23.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4002 ms. Frames received: 61. Dropped: 0. Rendered: 61. Render fps: 15.2. Average render time: 5522 us. Average swapBuffer time: 4648 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4003 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4002 ms. Frames received: 59. Dropped: 0. Rendered: 59. Render fps: 14.7. Average render time: 2773 us. Average swapBuffer time: 2120 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 28.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4004 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4003 ms. Frames received: 61. Dropped: 0. Rendered: 61. Render fps: 15.2. Average render time: 2502 us. Average swapBuffer time: 2018 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4002 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4007 ms. Frames received: 60. Dropped: 0. Rendered: 60. Render fps: 15.0. Average render time: 2189 us. Average swapBuffer time: 1810 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
D/FlutterWebRTCPlugin(14566): onConnectionChangeFAILED
I/flutter (14566): onIceConnectionState -> RTCIceConnectionStateFailed
I/flutter (14566): onConnectionState -> RTCPeerConnectionState.RTCPeerConnectionStateFailed
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4003 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4003 ms. Frames received: 60. Dropped: 0. Rendered: 60. Render fps: 15.0. Average render time: 2175 us. Average swapBuffer time: 1779 us.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.
I/org.webrtc.Logging(14566): EglRenderer: Duration: 4002 ms. Frames received: 0. Dropped: 0. Rendered: 0. Render fps: .0. Average render time: NA. Average swapBuffer time: NA.
I/org.webrtc.Logging(14566): CameraStatistics: Camera fps: 29.

希望有大佬帮忙看看吧,看了好多遍了,先前使用安卓的webrtc也是这种写法,能够正常使用

@caigp
Copy link
Author

caigp commented Apr 3, 2024

换了一下设备又能通了,有些无语了,昨天也是试了各种设备都不能通

@cloudwebrtc
Copy link
Member

网络问题吧,建议先写一个app 本地 loopback, 建立两个 RTCPeerConnection, 一个发,一个收,这个可以排除网络之外所有问题,第二步再做LAN 内的跨设备/平台的通信,信令交换, 最后为pc加上stun/turn 做跨网络测试。

@caigp
Copy link
Author

caigp commented Apr 3, 2024

网络问题吧,建议先写一个app 本地 loopback, 建立两个 RTCPeerConnection, 一个发,一个收,这个可以排除网络之外所有问题,第二步再做LAN 内的跨设备/平台的通信,信令交换, 最后为pc加上stun/turn 做跨网络测试。

现在能通了,代码逻辑没啥问题,网络缘故

@ALUZZ-Creat
Copy link

what was issue in the network

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants