Skip to content

Commit

Permalink
remove broken code & deps
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanUC committed Mar 12, 2024
1 parent d955d8b commit 11812ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 48 deletions.
5 changes: 0 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,6 @@ fake-s3 = "1.0.2"
types-protobuf = "^4.24.0.4"
pytest-httpx = "^0.30.0"


[tool.poetry.group.extras.dependencies]
pymedooze = "^0.1.0b3"
semanticsdp = ">=0.1.0b5"

[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
51 changes: 8 additions & 43 deletions yepcord/voice_gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,6 @@
from .schemas import SelectProtocol
from ..gateway.utils import require_auth

try:
from semanticsdp import SDPInfo, DTLSInfo, Setup
from pymedooze import MediaServer

_DISABLED = False
except ImportError:
_DISABLED = True


class GatewayClient:
def __init__(self, ws: Websocket, gw: Gateway):
Expand All @@ -32,8 +24,6 @@ def __init__(self, ws: Websocket, gw: Gateway):
self.rtx_ssrc = 0
self.mode: Optional[str] = None
self.key: Optional[bytes] = None
self.sdp: Optional[SDPInfo] = None
self.transport = None

self._gw = gw

Expand All @@ -60,12 +50,7 @@ async def handle_IDENTIFY(self, data: dict):
self.rtx_ssrc = self._gw.ssrc
self._gw.ssrc += 1

self.sdp = SDPInfo.from_dict(DEFAULT_SDP)
self.sdp.dtls = DTLSInfo(
setup=Setup.ACTPASS, hash="sha-256", fingerprint=self._gw.endpoint.get_dtls_fingerprint()
)

await self.esend(ReadyEvent(self.ssrc, self.video_ssrc, self.rtx_ssrc, self._gw.endpoint.get_local_port()))
await self.esend(ReadyEvent(self.ssrc, self.video_ssrc, self.rtx_ssrc, 0))

@require_auth(4003)
async def handle_HEARTBEAT(self, data: dict):
Expand All @@ -80,29 +65,16 @@ async def handle_SELECT_PROTOCOL(self, data: dict):
return await self.ws.close(4012)

if d.protocol == "webrtc":
offer = SDPInfo.parse(f"m=audio\n{d.sdp}")
self.sdp.ice = offer.ice
self.sdp.dtls = offer.dtls

self.transport = self._gw.endpoint.create_transport(self.sdp)
self.transport.set_remote_properties(self.sdp)
self.transport.set_local_properties(self.sdp)

dtls = self.transport.get_local_dtls()
ice = self.transport.get_local_ice()
port = self._gw.endpoint.get_local_port()
fp = f"{dtls.hash} {dtls.fingerprint}"
candidate = self.transport.get_local_candidates()[0]

answer = (
f"m=audio {port} ICE/SDP\n" +
f"a=fingerprint:{fp}\n" +
f"m=audio {...} ICE/SDP\n" +
f"a=fingerprint:{...}\n" +
f"c=IN IP4 127.0.0.1\n" +
f"a=rtcp:{port}\n" +
f"a=ice-ufrag:{ice.ufrag}\n" +
f"a=ice-pwd:{ice.pwd}\n" +
f"a=fingerprint:{fp}\n" +
f"a=candidate:1 1 {candidate.transport} {candidate.foundation} {candidate.address} {candidate.port} typ host\n"
f"a=rtcp:{...}\n" +
f"a=ice-ufrag:{...}\n" +
f"a=ice-pwd:{...}\n" +
f"a=fingerprint:{...}\n" +
f"a=candidate:1 1 {...} {...} {...} {...} typ host\n"
)

await self.esend(RtcSessionDescriptionEvent(answer))
Expand All @@ -128,14 +100,7 @@ class Gateway:
def __init__(self):
self.ssrc = 1

if not _DISABLED:
MediaServer.initialize()
MediaServer.set_port_range(3690, 3960)
self.endpoint = MediaServer.create_endpoint("127.0.0.1")

async def sendHello(self, ws: Websocket) -> None:
if _DISABLED:
return await ws.close(4005)
client = GatewayClient(ws, self)
setattr(ws, "_yepcord_client", client)
await ws.send_json({"op": VoiceGatewayOp.HELLO, "d": {"v": 7, "heartbeat_interval": 13750}})
Expand Down

0 comments on commit 11812ee

Please sign in to comment.