Skip to content

Commit

Permalink
bug #31: code cherry picked from aiortc_adapter to better handle an i…
Browse files Browse the repository at this point in the history
…ce candidate
  • Loading branch information
FabienDanieau committed Nov 23, 2023
1 parent b78db91 commit a33f20d
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/gst_signalling/gst_abstract_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import pyee
from typing import Any, Dict, NamedTuple, Optional

from aiortc.sdp import candidate_from_sdp


from .gst_signalling import GstSignalling

Expand Down Expand Up @@ -118,10 +120,15 @@ async def peer_for_session(
await pc.setRemoteDescription(obj)

elif "ice" in message:
obj = object_from_string(json.dumps(message["ice"]))
if isinstance(obj, RTCIceCandidate):
self.logger.info("Received ice candidate")
pc.addIceCandidate(obj)
message = message["ice"]
if message["candidate"] == "":
self.logger.info("Received empty candidate, ignoring")
return None

obj = candidate_from_sdp(message["candidate"].split(":", 1)[1])
obj.sdpMLineIndex = message["sdpMLineIndex"]

await pc.addIceCandidate(obj)

async def close_session(self, session_id: str) -> None:
session = self.sessions.pop(session_id)
Expand Down

0 comments on commit a33f20d

Please sign in to comment.