comparison libervia/backend/plugins/plugin_xep_0167/mapping.py @ 4231:e11b13418ba6

plugin XEP-0353, XEP-0234, jingle: WebRTC data channel signaling implementation: Implement XEP-0343: Signaling WebRTC Data Channels in Jingle. The current version of the XEP (0.3.1) has no implementation and contains some flaws. After discussing this on xsf@, Daniel (from Conversations) mentioned that they had a sprint with Larma (from Dino) to work on another version and provided me with this link: https://gist.github.com/iNPUTmice/6c56f3e948cca517c5fb129016d99e74 . I have used it for my implementation. This implementation reuses work done on Jingle A/V call (notably XEP-0176 and XEP-0167 plugins), with adaptations. When used, XEP-0234 will not handle the file itself as it normally does. This is because WebRTC has several implementations (browser for web interface, GStreamer for others), and file/data must be handled directly by the frontend. This is particularly important for web frontends, as the file is not sent from the backend but from the end-user's browser device. Among the changes, there are: - XEP-0343 implementation. - `file_send` bridge method now use serialised dict as output. - New `BaseTransportHandler.is_usable` method which get content data and returns a boolean (default to `True`) to tell if this transport can actually be used in this context (when we are initiator). Used in webRTC case to see if call data are available. - Support of `application` media type, and everything necessary to handle data channels. - Better confirmation message, with file name, size and description when available. - When file is accepted in preflight, it is specified in following `action_new` signal for actual file transfer. This way, frontend can avoid the display or 2 confirmation messages. - XEP-0166: when not specified, default `content` name is now its index number instead of a UUID. This follows the behaviour of browsers. - XEP-0353: better handling of events such as call taken by another device. - various other updates. rel 441
author Goffi <goffi@goffi.org>
date Sat, 06 Apr 2024 12:57:23 +0200
parents b2709504586a
children 79c8a70e1813
comparison
equal deleted inserted replaced
4230:314d3c02bb67 4231:e11b13418ba6
120 media_data = application_data[app_data_key] 120 media_data = application_data[app_data_key]
121 media = application_data["media"] 121 media = application_data["media"]
122 payload_types = media_data.get("payload_types", {}) 122 payload_types = media_data.get("payload_types", {})
123 123
124 # Generate m= line 124 # Generate m= line
125 transport = "UDP/TLS/RTP/SAVPF" 125 if media == "application":
126 payload_type_ids = [str(pt_id) for pt_id in payload_types] 126 transport = "UDP/DTLS/SCTP"
127 m_line = f"m={media} {port} {transport} {' '.join(payload_type_ids)}" 127 m_line = f"m={media} {port} {transport} webrtc-datachannel"
128 else:
129 transport = "UDP/TLS/RTP/SAVPF"
130 payload_type_ids = [str(pt_id) for pt_id in payload_types]
131 m_line = f"m={media} {port} {transport} {' '.join(payload_type_ids)}"
128 sdp_lines.append(m_line) 132 sdp_lines.append(m_line)
129 133
130 sdp_lines.append(f"c={network_type} {address_type} {connection_address}") 134 sdp_lines.append(f"c={network_type} {address_type} {connection_address}")
131 135
132 sdp_lines.append(f"a=mid:{content_name}") 136 sdp_lines.append(f"a=mid:{content_name}")
267 parts[0] = parts[0][2:] # Remove the prefix from the first element 271 parts[0] = parts[0][2:] # Remove the prefix from the first element
268 272
269 if prefix == "m=": 273 if prefix == "m=":
270 media_type = parts[0] 274 media_type = parts[0]
271 port = int(parts[1]) 275 port = int(parts[1])
272 payload_types = {} 276 application_data = {"media": media_type}
273 for payload_type_id in [int(pt_id) for pt_id in parts[3:]]: 277 if media_type in ("video", "audio"):
274 payload_type = {"id": payload_type_id} 278 payload_types = application_data["payload_types"] = {}
275 payload_types[payload_type_id] = payload_type 279 for payload_type_id in [int(pt_id) for pt_id in parts[3:]]:
276 280 payload_type = {"id": payload_type_id}
277 application_data = {"media": media_type, "payload_types": payload_types} 281 payload_types[payload_type_id] = payload_type
282 elif media_type == "application":
283 if parts[3] != "webrtc-datachannel":
284 raise NotImplementedError(
285 f"{media_type!r} application is not supported"
286 )
287
278 transport_data = {"port": port} 288 transport_data = {"port": port}
279 if fingerprint_data is not None: 289 if fingerprint_data is not None:
280 transport_data["fingerprint"] = fingerprint_data 290 transport_data["fingerprint"] = fingerprint_data
281 if ice_pwd is not None: 291 if ice_pwd is not None:
282 transport_data["pwd"] = ice_pwd 292 transport_data["pwd"] = ice_pwd