Mercurial > libervia-backend
diff libervia/backend/plugins/plugin_xep_0167/mapping.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 |
line wrap: on
line diff
--- a/libervia/backend/plugins/plugin_xep_0167/mapping.py Sat May 11 13:25:45 2024 +0200 +++ b/libervia/backend/plugins/plugin_xep_0167/mapping.py Sat May 11 13:52:41 2024 +0200 @@ -37,7 +37,7 @@ return "a=sendrecv" elif senders == "none": return "a=inactive" - elif session["role"] == senders: + elif session["role"] != senders: return "a=sendonly" else: return "a=recvonly" @@ -113,8 +113,9 @@ sdp_lines, triggers_no_cancel=True ) + content_names = sorted(contents) - for content_name, content_data in contents.items(): + for content_name, content_data in [(n, contents[n]) for n in content_names]: # contents.items(): app_data_key = "local_data" if local else "peer_data" application_data = content_data["application_data"] media_data = application_data[app_data_key] @@ -241,11 +242,11 @@ return "\r\n".join(sdp_lines) + "\r\n" -def parse_sdp(sdp: str) -> dict: +def parse_sdp(sdp: str, role: str) -> dict: """Parse SDP string. @param sdp: The SDP string to parse. - + @param role: Role of the entities which produces the SDP. @return: A dictionary containing parsed session data. """ # FIXME: to be removed once host is accessible from global var @@ -263,6 +264,8 @@ ice_pwd: Optional[str] = None ice_ufrag: Optional[str] = None payload_types: Optional[Dict[int, dict]] = None + # default value, will be be modified by SDP + senders: str = "both" for line in lines: try: @@ -295,6 +298,7 @@ media_data = call_data[media_type] = { "application_data": application_data, "transport_data": transport_data, + "senders": senders } elif prefix == "a=": @@ -426,6 +430,24 @@ if transport_data is not None: transport_data["pwd"] = parts[0] + elif attribute in ("sendrecv", "sendonly", "recvonly", "inactive"): + if attribute == "sendrecv": + value = "both" + elif attribute == "sendonly": + value = role + elif attribute == "recvonly": + value = "responder" if role == "initiator" else "initiator" + else: + value = "none" + + if application_data is None: + # this is a global value, we use is as new default value + senders = value + else: + # this is a media specific value, it will replace the one used as + # default for this media + application_data["senders"] = value + host.trigger.point( "XEP-0167_parse_sdp_a", attribute,