예제 #1
0
 async def do_sdp_offer(self):
     width = 320
     height = 240
     iceservers = RTCIceServer(self.ice_servers)
     self.ice_env = RTCPeerConnection(configuration=RTCConfiguration(
         iceServers=[iceservers]))
     #self.ice_env = RTCPeerConnection()
     print(iceservers)
     gatherer = RTCIceGatherer(iceServers=[iceservers])
     await gatherer.gather()
     __ice = RTCIceTransport(gatherer)
     print(__ice.iceGatherer)
     print(gatherer.getLocalParameters())
     print(__ice.getRemoteCandidates())
     local_video = CombinedVideoStreamTrack(tracks=[
         ColorVideoStreamTrack(width=width, height=height, color=BLUE),
         ColorVideoStreamTrack(width=width, height=height, color=GREEN),
         ColorVideoStreamTrack(width=width, height=height, color=RED),
     ])
     self.ice_env.addTrack(local_video)
     await self.ice_env.setLocalDescription(await
                                            self.ice_env.createOffer())
     print(self.ice_env.localDescription)
     payload = {
         'tc': 'sdp',
         'type': 'offer',
         'sdp':
         self.description_to_dict(self.ice_env.localDescription)['sdp'],
         'handle': self.client_id
     }
     await self.send(payload)
     await asyncio.sleep(5)
예제 #2
0
async def start_ice_pair():
    ice_a = RTCIceTransport(gatherer=RTCIceGatherer())
    ice_b = RTCIceTransport(gatherer=RTCIceGatherer())

    await asyncio.gather(ice_a.iceGatherer.gather(),
                         ice_b.iceGatherer.gather())

    for candidate in ice_b.iceGatherer.getLocalCandidates():
        ice_a.addRemoteCandidate(candidate)
    for candidate in ice_a.iceGatherer.getLocalCandidates():
        ice_b.addRemoteCandidate(candidate)
    await asyncio.gather(ice_a.start(ice_b.iceGatherer.getLocalParameters()),
                         ice_b.start(ice_a.iceGatherer.getLocalParameters()))

    return ice_a, ice_b
예제 #3
0
    async def on_connect(self, websocket):
        gatherer = RTCIceGatherer(iceServers=[])
        websocket.state.iceTransport = RTCIceTransport(gatherer)
        certificate = RTCCertificate.generateCertificate()
        websocket.state.dtlsTransport = RTCDtlsTransport(
            websocket.state.iceTransport, [certificate])

        # monkey-patch RTCDtlsTransport
        websocket.state.dtlsTransport._handle_rtp_data = functools.partial(
            handle_rtp_data, websocket)
        websocket.state.dtlsTransport._handle_rtcp_data = functools.partial(
            handle_rtcp_data, websocket)

        await websocket.accept()
예제 #4
0
 def __init__(self):
     self._gatherer = RTCIceGatherer()
     self._transport = RTCIceTransport(self._gatherer)