comparison libervia/backend/plugins/plugin_xep_0343.py @ 4240:79c8a70e1813

backend, frontend: prepare remote control: This is a series of changes necessary to prepare the implementation of remote control feature: - XEP-0166: add a `priority` attribute to `ApplicationData`: this is needed when several applications are working in a same session, to know which one must be handled first. Will be used to make Remote Control have precedence over Call content. - XEP-0166: `_call_plugins` is now async and is not used with `DeferredList` anymore: the benefit to have methods called in parallels is very low, and it cause a lot of trouble as we can't predict order. Methods are now called sequentially so workflow can be predicted. - XEP-0167: fix `senders` XMPP attribute <=> SDP mapping - XEP-0234: preflight acceptance key is now `pre-accepted` instead of `file-accepted`, so the same key can be used with other jingle applications. - XEP-0167, XEP-0343: move some method to XEP-0167 - XEP-0353: use new `priority` feature to call preflight methods of applications according to it. - frontend (webrtc): refactor the sources/sink handling with a more flexible mechanism based on Pydantic models. It is now possible to have has many Data Channel as necessary, to have them in addition to A/V streams, to specify manually GStreamer sources and sinks, etc. - frontend (webrtc): rework of the pipeline to reduce latency. - frontend: new `portal_desktop` method. Screenshare portal handling has been moved there, and RemoteDesktop portal has been added. - frontend (webrtc): fix `extract_ufrag_pwd` method. rel 436
author Goffi <goffi@goffi.org>
date Sat, 11 May 2024 13:52:41 +0200
parents e11b13418ba6
children 0d7bb4df2343
comparison
equal deleted inserted replaced
4239:a38559e6d6e2 4240:79c8a70e1813
288 except (KeyError, ValueError): 288 except (KeyError, ValueError):
289 raise exceptions.DataError( 289 raise exceptions.DataError(
290 f"Invalid datachannel signaling element: {transport_elt.toXml()}" 290 f"Invalid datachannel signaling element: {transport_elt.toXml()}"
291 ) 291 )
292 transport_data["webrtc"] = True 292 transport_data["webrtc"] = True
293 elif action in ( 293 elif action in (self._j.A_PREPARE_INITIATOR, self._j.A_TRANSPORT_INFO):
294 self._j.A_PREPARE_CONFIRMATION, self._j.A_PREPARE_INITIATOR,
295 self._j.A_TRANSPORT_INFO
296 ):
297 await self._call_ice_udp_handler( 294 await self._call_ice_udp_handler(
298 client, action, session, content_name, transport_elt 295 client, action, session, content_name, transport_elt
299 ) 296 )
300 elif action == self._j.A_SESSION_ACCEPT: 297 elif action == self._j.A_SESSION_ACCEPT:
301 await self._call_ice_udp_handler( 298 await self._call_ice_udp_handler(
317 elif action == self._j.A_START: 314 elif action == self._j.A_START:
318 pass 315 pass
319 elif action == self._j.A_SESSION_INITIATE: 316 elif action == self._j.A_SESSION_INITIATE:
320 # responder side 317 # responder side
321 318
322 sdp = mapping.generate_sdp_from_session(session) 319 # answer_sdp_d is a deferred handled in XEP-0167: it is called when the
320 # frontend answers with its SDP.
323 session["answer_sdp_d"] = answer_sdp_d = defer.Deferred() 321 session["answer_sdp_d"] = answer_sdp_d = defer.Deferred()
324 # we should have the answer long before 2 min 322 # we should have the answer long before 2 min
325 answer_sdp_d.addTimeout(2 * 60, reactor) 323 answer_sdp_d.addTimeout(2 * 60, reactor)
326 324
327 self.host.bridge.call_setup( 325 self._rtp.send_answer_sdp(client, session)
328 session["id"],
329 data_format.serialise(
330 {
331 "role": session["role"],
332 "sdp": sdp,
333 }
334 ),
335 client.profile,
336 )
337 326
338 answer_sdp = await answer_sdp_d 327 answer_sdp = await answer_sdp_d
339 parsed_answer = mapping.parse_sdp(answer_sdp) 328 parsed_answer = mapping.parse_sdp(answer_sdp, session["role"])
340 session["metadata"].update(parsed_answer["metadata"]) 329 session["metadata"].update(parsed_answer["metadata"])
341 contents = session["contents"] 330 self._rtp.propagate_data(session, parsed_answer)
342 if len(contents) != 1: 331
343 raise NotImplementedError(
344 "Only a singlecontent is supported at the moment."
345 )
346 content = next(iter(contents.values()))
347 media_data = parsed_answer["application"]
348 application_data = content["application_data"]
349 application_data["local_data"] = media_data["application_data"]
350 transport_data = content["transport_data"]
351 local_ice_data = media_data["transport_data"]
352 transport_data["local_ice_data"] = local_ice_data
353 transport_elt.children.clear() 332 transport_elt.children.clear()
354 ice_transport_elt = await self._ice_udp.jingle_handler( 333 ice_transport_elt = await self._ice_udp.jingle_handler(
355 client, action, session, content_name, transport_elt 334 client, action, session, content_name, transport_elt
356 ) 335 )
357 transport_elt.addChild(ice_transport_elt) 336 transport_elt.addChild(ice_transport_elt)