annotate libervia/backend/plugins/plugin_xep_0293.py @ 4108:238e305f2306

plugin JID Search: JID search plugin, first draft
author Goffi <goffi@goffi.org>
date Thu, 06 Jul 2023 11:34:51 +0200
parents 4b842c1fb686
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4060
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia plugin
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from typing import List
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
21 from twisted.words.protocols.jabber.xmlstream import XMPPHandler
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
22 from twisted.words.xish import domish
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
23 from wokkel import disco, iwokkel
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from zope.interface import implementer
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
25
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4060
diff changeset
26 from libervia.backend.core.constants import Const as C
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4060
diff changeset
27 from libervia.backend.core.i18n import _
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4060
diff changeset
28 from libervia.backend.core.log import getLogger
4060
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
29
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
30 log = getLogger(__name__)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
31
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 NS_JINGLE_RTP_RTCP_FB = "urn:xmpp:jingle:apps:rtp:rtcp-fb:0"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 PLUGIN_INFO = {
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 C.PI_NAME: "Jingle RTP Feedback Negotiation",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 C.PI_IMPORT_NAME: "XEP-0293",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 C.PI_TYPE: "XEP",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 C.PI_MODES: C.PLUG_MODE_BOTH,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 C.PI_PROTOCOLS: ["XEP-0293"],
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 C.PI_DEPENDENCIES: ["XEP-0092", "XEP-0166", "XEP-0167"],
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 C.PI_RECOMMENDATIONS: [],
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 C.PI_MAIN: "XEP_0293",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 C.PI_HANDLER: "yes",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 C.PI_DESCRIPTION: _("""Jingle RTP Feedback Negotiation"""),
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 }
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
46
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 RTCP_FB_KEY = "rtcp-fb"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
49
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 class XEP_0293:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 def __init__(self, host):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 log.info(f"plugin {PLUGIN_INFO[C.PI_NAME]!r} initialization")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 host.trigger.add("XEP-0167_parse_sdp_a", self._parse_sdp_a_trigger)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 host.trigger.add(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 "XEP-0167_generate_sdp_content", self._generate_sdp_content_trigger
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 host.trigger.add("XEP-0167_parse_description", self._parse_description_trigger)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 host.trigger.add(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 "XEP-0167_parse_description_payload_type",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 self._parse_description_payload_type_trigger,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 host.trigger.add("XEP-0167_build_description", self._build_description_trigger)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 host.trigger.add(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 "XEP-0167_build_description_payload_type",
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 self._build_description_payload_type_trigger,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
67
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 def get_handler(self, client):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 return XEP_0293_handler()
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
70
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 ## SDP
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
72
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 def _parse_sdp_a_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
74 self,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 attribute: str,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 parts: List[str],
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
77 call_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 metadata: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 media_type: str,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 application_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 transport_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 """Parse "rtcp-fb" and "rtcp-fb-trr-int" attributes
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
84
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 @param attribute: The attribute being parsed.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 @param parts: The list of parts in the attribute.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 @param call_data: The call data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 @param metadata: The metadata dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 @param media_type: The media type (e.g., audio, video).
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 @param application_data: The application data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
91 @param transport_data: The transport data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 @param payload_map: The payload map dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 """
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 if attribute == "rtcp-fb":
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
95 pt_id = parts[0]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 feedback_type = parts[1]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
97
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 feedback_subtype = None
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 parameters = {}
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 # Check if there are extra parameters
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 if len(parts) > 2:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 feedback_subtype = parts[2]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
104
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 if len(parts) > 3:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 for parameter in parts[3:]:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 name, _, value = parameter.partition("=")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 parameters[name] = value or None
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
109
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 # Check if this feedback is linked to a payload type
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 if pt_id == "*":
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 # Not linked to a payload type, add to application data
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 application_data.setdefault(RTCP_FB_KEY, []).append(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
114 (feedback_type, feedback_subtype, parameters)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 else:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 payload_types = application_data.get("payload_types", {})
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 try:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 payload_type = payload_types[int(pt_id)]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
120 except KeyError:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 log.warning(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 f"Got reference to unknown payload type {pt_id}: "
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 f"{' '.join(parts)}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 else:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 # Linked to a payload type, add to payload data
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 payload_type.setdefault(RTCP_FB_KEY, []).append(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 (feedback_type, feedback_subtype, parameters)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
130
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 elif attribute == "rtcp-fb-trr-int":
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
132 pt_id = parts[0] # Payload type ID
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 interval = int(parts[1])
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
134
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
135 # Check if this interval is linked to a payload type
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 if pt_id == "*":
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 # Not linked to a payload type, add to application data
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 application_data["rtcp-fb-trr-int"] = interval
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 else:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 payload_types = application_data.get("payload_types", {})
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 try:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 payload_type = payload_types[int(pt_id)]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 except KeyError:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
144 log.warning(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 f"Got reference to unknown payload type {pt_id}: "
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 f"{' '.join(parts)}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 else:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 # Linked to a payload type, add to payload data
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 payload_type["rtcp-fb-trr-int"] = interval
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
151
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 def _generate_rtcp_fb_lines(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 self, data: dict, pt_id: str, sdp_lines: List[str]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 for type_, subtype, parameters in data.get(RTCP_FB_KEY, []):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
156 parameters_strs = [
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 f"{k}={v}" if v is not None else k for k, v in parameters.items()
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 ]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
159 parameters_str = " ".join(parameters_strs)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
160
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 sdp_line = f"a=rtcp-fb:{pt_id} {type_}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 if subtype:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
163 sdp_line += f" {subtype}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 if parameters_str:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 sdp_line += f" {parameters_str}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 sdp_lines.append(sdp_line)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
167
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 def _generate_rtcp_fb_trr_int_lines(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 self, data: dict, pt_id: str, sdp_lines: List[str]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 if "rtcp-fb-trr-int" not in data:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 return
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 sdp_lines.append(f"a=rtcp-fb:{pt_id} trr-int {data['rtcp-fb-trr-int']}")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
174
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 def _generate_sdp_content_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 self,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 session: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
178 local: bool,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 content_name: str,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 content_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 sdp_lines: List[str],
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
182 application_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 app_data_key: str,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 media_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 media: str,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 """Generate SDP attributes "rtcp-fb" and "rtcp-fb-trr-int" from application data.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
188
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 @param session: The session data.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 @param local: Whether this is local or remote content.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 @param content_name: The name of the content.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 @param content_data: The data of the content.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
193 @param sdp_lines: The list of SDP lines to append to.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 @param application_data: The application data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 @param app_data_key: The key for the application data.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 @param media_data: The media data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 @param media: The media type (e.g., audio, video).
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 """
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 # Generate lines for application data
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
200 self._generate_rtcp_fb_lines(application_data, "*", sdp_lines)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 self._generate_rtcp_fb_trr_int_lines(application_data, "*", sdp_lines)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
202
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
203 # Generate lines for each payload type
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 for pt_id, payload_data in media_data.get("payload_types", {}).items():
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 self._generate_rtcp_fb_lines(payload_data, pt_id, sdp_lines)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 self._generate_rtcp_fb_trr_int_lines(payload_data, pt_id, sdp_lines)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
207
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 ## XML
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
209
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 def _parse_rtcp_fb_elements(self, parent_elt: domish.Element, data: dict) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
211 """Parse the <rtcp-fb> and <rtcp-fb-trr-int> elements.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
212
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 @param parent_elt: The parent domish.Element.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 @param data: The data dict to populate.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
215 """
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 for rtcp_fb_elt in parent_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb"):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
217 try:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 type_ = rtcp_fb_elt["type"]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 subtype = rtcp_fb_elt.getAttribute("subtype")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
220
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
221 parameters = {}
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 for parameter_elt in rtcp_fb_elt.elements(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 NS_JINGLE_RTP_RTCP_FB, "parameter"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
224 ):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
225 parameters[parameter_elt["name"]] = parameter_elt.getAttribute(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
226 "value"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
228
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 data.setdefault(RTCP_FB_KEY, []).append((type_, subtype, parameters))
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 except (KeyError, ValueError) as e:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
231 log.warning(f"Error while parsing <rtcp-fb>: {e}\n{rtcp_fb_elt.toXml()}")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
232
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
233 for rtcp_fb_trr_int_elt in parent_elt.elements(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
235 ):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 try:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
237 interval_value = int(rtcp_fb_trr_int_elt["value"])
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 data.setdefault("rtcp_fb_trr_int", []).append(interval_value)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 except (KeyError, ValueError) as e:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
240 log.warning(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 f"Error while parsing <rtcp-fb-trr-int>: {e}\n"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
242 f"{rtcp_fb_trr_int_elt.toXml()}"
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
243 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
244
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
245 def _parse_description_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
246 self, desc_elt: domish.Element, media_data: dict
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
247 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
248 """Parse the <rtcp-fb> and <rtcp-fb-trr-int> elements from a description.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
249
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
250 @param desc_elt: The <description> domish.Element.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
251 @param media_data: The media data dict to populate.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
252 """
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
253 self._parse_rtcp_fb_elements(desc_elt, media_data)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
254
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
255 def _parse_description_payload_type_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
256 self,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
257 desc_elt: domish.Element,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
258 media_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
259 payload_type_elt: domish.Element,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
260 payload_type_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
261 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
262 """Parse the <rtcp-fb> and <rtcp-fb-trr-int> elements from a payload type.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
263
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
264 @param desc_elt: The <description> domish.Element.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
265 @param media_data: The media data dict.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
266 @param payload_type_elt: The <payload-type> domish.Element.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
267 @param payload_type_data: The payload type data dict to populate.
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
268 """
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
269 self._parse_rtcp_fb_elements(payload_type_elt, payload_type_data)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
270
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
271 def build_rtcp_fb_elements(self, parent_elt: domish.Element, data: dict) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
272 """Helper method to build the <rtcp-fb> and <rtcp-fb-trr-int> elements"""
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
273 for type_, subtype, parameters in data.get(RTCP_FB_KEY, []):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
274 rtcp_fb_elt = parent_elt.addElement((NS_JINGLE_RTP_RTCP_FB, "rtcp-fb"))
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
275 rtcp_fb_elt["type"] = type_
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
276 if subtype:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
277 rtcp_fb_elt["subtype"] = subtype
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
278 for name, value in parameters.items():
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
279 param_elt = rtcp_fb_elt.addElement(name)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
280 if value is not None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
281 param_elt.addContent(str(value))
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
282
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
283 if "rtcp-fb-trr-int" in data:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
284 rtcp_fb_trr_int_elt = parent_elt.addElement(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
285 (NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int")
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
286 )
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
287 rtcp_fb_trr_int_elt["value"] = str(data["rtcp-fb-trr-int"])
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
288
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
289 def _build_description_payload_type_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
290 self,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
291 desc_elt: domish.Element,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
292 media_data: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
293 payload_type: dict,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
294 payload_type_elt: domish.Element,
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
295 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
296 """Build the <rtcp-fb> and <rtcp-fb-trr-int> elements for a payload type"""
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
297 self.build_rtcp_fb_elements(payload_type_elt, payload_type)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
298
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
299 def _build_description_trigger(
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
300 self, desc_elt: domish.Element, media_data: dict, session: dict
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
301 ) -> None:
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
302 """Build the <rtcp-fb> and <rtcp-fb-trr-int> elements for a media description"""
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
303 self.build_rtcp_fb_elements(desc_elt, media_data)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
304
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
305
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
306 @implementer(iwokkel.IDisco)
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
307 class XEP_0293_handler(XMPPHandler):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
308 def getDiscoInfo(self, requestor, target, nodeIdentifier=""):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
309 return [disco.DiscoFeature(NS_JINGLE_RTP_RTCP_FB)]
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
310
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
311 def getDiscoItems(self, requestor, target, nodeIdentifier=""):
fce92ba311f4 plugin XEP-0293: "Jingle RTP Feedback Negotiation" implementation:
Goffi <goffi@goffi.org>
parents:
diff changeset
312 return []