webrtc-sdk / webrtc

BSD 3-Clause "New" or "Revised" License
225 stars 89 forks source link

webrtc ios fails to initate connection #130

Open windmillcode0 opened 2 months ago

windmillcode0 commented 2 months ago

Greetings for the flutter webrtc ios library it seems that when ios is the intiatior of the connection it has a problem with setting the remote descriptiion even wehn the signaling state is correct

image

this is indeed correct for the caller the frame work still seems to throw the error, its fine when the ios device is the callee but not the caller heres my code


// File: RTCPeerConnection.m

- (void)peerConnectionSetRemoteDescription:(RTCSessionDescription*)sdp
                            peerConnection:(RTCPeerConnection*)peerConnection
                                    result:(FlutterResult)result {
  // Log SDP
  NSLog(@"Setting remote description with SDP: %@", sdp.sdp);

  // Ensure this is called on the main thread
  dispatch_async(dispatch_get_main_queue(), ^{
    // Log signaling state before setting the remote description
    NSLog(@"Signaling state before setting remote description: %ld", (long)peerConnection.signalingState);

    [peerConnection setRemoteDescription:sdp completionHandler:^(NSError * _Nullable error) {
      if (error) {
        NSLog(@"Failed to set remote description: %@", error.localizedDescription);
        result([FlutterError errorWithCode:@"SetRemoteDescriptionFailed"
                                   message:[NSString stringWithFormat:@"Error %@", error.localizedDescription]
                                   details:nil]);
      } else {
        // Log signaling state after setting the remote description
        NSString *stateString = [self stringForSignalingState:peerConnection.signalingState];
             result(stateString);
      }
    }];
  });
}

can this be fixed