I have a working WebRTC client, and I want to receive it's video via WebRTC using aiotrc (python). The other client is working fine as the recipient, we have tested it with a browser.
Using python, I configure the server, I create an offer with a Transceiver (I only want to receive the video), and I set the offer as the localDescription:
import json
import socketio
import asyncio
from asgiref.sync import async_to_sync
from aiortc import RTCPeerConnection, RTCSessionDescription, RTCIceCandidate, RTCConfiguration, RTCIceServer, RTCIceGatherer, RTCRtpTransceiver
session_id = 'default'
sio = socketio.Client()
ice_server = RTCIceServer(urls='stun:stun.l.google.com:19302')
pc = RTCPeerConnection(configuration=RTCConfiguration(iceServers=[ice_server]))
pc.addTransceiver("video", direction="recvonly")
def connect():
sio.connect('https://192.168.10.123', namespaces=['/live'])
connect()
@async_to_sync
async def set_local_description():
await pc.setLocalDescription(await pc.createOffer())
print('Local description set to: ', pc.localDescription)
#send_signaling_message(json.dumps({'sdp':{'sdp': pc.localDescription.sdp, 'type':pc.localDescription.type}}))
set_local_description()
(Where the socket.io is connecting is a fake address in this case). After this point, I have no idea how to gather the ice candidates. I have tried using the iceGatherer with no luck:
ice_gath = RTCIceGatherer(iceServers=[ice_server])
candidates = ice_gath.getLocalCandidates()
I have to send the ice candidate to the recipient. At this point I couldn't find any information about, how to get the ice candidates using aiortc. What is the next step?