Mercurial > libervia-backend
comparison libervia/backend/tools/async_trigger.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 | 4b842c1fb686 |
children | 0d7bb4df2343 |
comparison
equal
deleted
inserted
replaced
4230:314d3c02bb67 | 4231:e11b13418ba6 |
---|---|
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 18 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
19 | 19 |
20 """Misc usefull classes""" | 20 """Misc usefull classes""" |
21 | 21 |
22 from typing import Tuple, Any | 22 from typing import Tuple, Any |
23 | |
24 from libervia.backend.core.xmpp import SatXMPPEntity | |
23 from . import trigger as sync_trigger | 25 from . import trigger as sync_trigger |
24 from . import utils | 26 from . import utils |
25 from twisted.internet import defer | 27 from twisted.internet import defer |
26 | 28 |
27 class TriggerManager(sync_trigger.TriggerManager): | 29 class TriggerManager(sync_trigger.TriggerManager): |
28 """This is a TriggerManager with an new async_point method""" | 30 """This is a TriggerManager with an new async_point method""" |
29 | 31 |
30 @defer.inlineCallbacks | 32 async def async_point( |
31 def async_point(self, point_name, *args, **kwargs): | 33 self, |
34 point_name: str, | |
35 *args, **kwargs | |
36 ) -> bool: | |
32 """This put a trigger point with potentially async Deferred | 37 """This put a trigger point with potentially async Deferred |
33 | 38 |
34 All the triggers for that point will be run | 39 All the triggers for that point will be run |
35 @param point_name: name of the trigger point | 40 @param point_name: name of the trigger point |
36 @param *args: args to transmit to trigger | 41 @param *args: args to transmit to trigger |
39 when set to True, this argument don't let triggers stop | 44 when set to True, this argument don't let triggers stop |
40 the workflow | 45 the workflow |
41 @return D(bool): True if the action must be continued, False else | 46 @return D(bool): True if the action must be continued, False else |
42 """ | 47 """ |
43 if point_name not in self.__triggers: | 48 if point_name not in self.__triggers: |
44 defer.returnValue(True) | 49 return True |
45 | 50 |
46 can_cancel = not kwargs.pop('triggers_no_cancel', False) | 51 can_cancel = not kwargs.pop('triggers_no_cancel', False) |
47 | 52 |
48 for priority, trigger in self.__triggers[point_name]: | 53 for __, trigger in self.__triggers[point_name]: |
49 try: | 54 try: |
50 cont = yield utils.as_deferred(trigger, *args, **kwargs) | 55 cont = await utils.as_deferred(trigger, *args, **kwargs) |
51 if can_cancel and not cont: | 56 if can_cancel and not cont: |
52 defer.returnValue(False) | 57 return False |
53 except sync_trigger.SkipOtherTriggers: | 58 except sync_trigger.SkipOtherTriggers: |
54 break | 59 break |
55 defer.returnValue(True) | 60 return True |
56 | 61 |
57 async def async_return_point( | 62 async def async_return_point( |
58 self, | 63 self, |
59 point_name: str, | 64 point_name: str, |
60 *args, **kwargs | 65 *args, **kwargs |