aiortc / aiortc

WebRTC and ORTC implementation for Python using asyncio
BSD 3-Clause "New" or "Revised" License
4.18k stars 759 forks source link

SDP rfc4145: AIORTC does not support "a=setup" in the session-level section #255

Closed andrews239 closed 4 years ago

andrews239 commented 4 years ago
$ egrep "setup|fingerprint|m=" remoteSDP
a=setup:active
a=fingerprint:sha-256 EF:51:DF:C7:E7:DF:28:BC:AD:2D:CC:C6:6A:00:11:1E:47:CA:FF:99:35:6D:DB:18:D0:18:7D:88:92:D8:14:74
m=audio 57970 RTP/SAVPF 96 0 8
m=video 57970 RTP/SAVPF 99 97
m=video 57970 RTP/SAVPF 99 97

  File "~/.local/lib/python3.8/site-packages/aiortc/rtcpeerconnection.py", line 841, in __connect
    await dtlsTransport.start(self.__remoteDtls[transceiver])
  File "~/.local/lib/python3.8/site-packages/aiortc/rtcdtlstransport.py", line 425, in start
    assert len(remoteParameters.fingerprints)
AttributeError: 'NoneType' object has no attribute 'fingerprints'
andrews239 commented 4 years ago

RFC4145

   The 'setup' attribute indicates which of the end points should
   initiate the TCP connection establishment (i.e., send the initial TCP
   SYN).  The 'setup' attribute is charset-independent and can be a
   session-level or a media-level attribute.  The following is the ABNF
   of the 'setup' attribute:
andrews239 commented 4 years ago
--- sdp.py-orig 2019-12-13 17:57:43.987661838 -0800
+++ sdp.py 2020-01-23 19:56:52.904828227 -0800
@@ -292,6 +292,7 @@

     @classmethod
     def parse(cls, sdp):
+        dtls_role = None
         current_media = None
         dtls_fingerprints = []
         ice_options = None
@@ -323,6 +324,8 @@
                     dtls_fingerprints.append(
                         RTCDtlsFingerprint(algorithm=algorithm, value=fingerprint)
                     )
+                elif attr == "setup":
+                    dtls_role = DTLS_SETUP_ROLE[value]
                 elif attr == "ice-options":
                     ice_options = value
                 elif attr == "group":
@@ -440,6 +443,8 @@
                             setattr(ssrc_info, ssrc_attr, ssrc_value)

             if current_media.dtls.role is None:
+                current_media.dtls.role = dtls_role
+            if current_media.dtls.role is None:
                 current_media.dtls = None

             # requires codecs to have been parsed
jlaine commented 4 years ago

Could you please provide an actual PR, with an example of such SDP captured as a unit test?