annotate tests/unit/test_plugin_xep_0293.py @ 4152:23d21daed216

core (memory/sqla_mapping): add a `version_id` column to detect race conditions.
author Goffi <goffi@goffi.org>
date Wed, 22 Nov 2023 14:52:00 +0100
parents 4b842c1fb686
children f1d0cde61af7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4061
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/env python3
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
2
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
3 # Libervia: an XMPP client
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Copyright (C) 2009-2023 Jérôme Poisson (goffi@goffi.org)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
5
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or modify
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # it under the terms of the GNU Affero General Public License as published by
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # the Free Software Foundation, either version 3 of the License, or
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # (at your option) any later version.
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
10
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
11 # This program is distributed in the hope that it will be useful,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # GNU Affero General Public License for more details.
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
15
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
16 # You should have received a copy of the GNU Affero General Public License
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
18
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
19 from twisted.words.xish import domish
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
4071
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4061
diff changeset
21 from libervia.backend.plugins.plugin_xep_0167.constants import NS_JINGLE_RTP
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4061
diff changeset
22 from libervia.backend.plugins.plugin_xep_0293 import NS_JINGLE_RTP_RTCP_FB, RTCP_FB_KEY, XEP_0293
4b842c1fb686 refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents: 4061
diff changeset
23 from libervia.backend.tools import xml_tools
4061
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
24
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 class TestXEP0293:
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
26
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 def test_parse_sdp_rtcp_fb_general(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 """Parsing of a general RTCP feedback SDP line."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
30
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
31 application_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
32 transport_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
34 # SDP line: a=rtcp-fb:* nack pli
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 attribute = "rtcp-fb"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 parts = ["*", "nack", "pli"]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
37 xep_0293._parse_sdp_a_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
38 attribute=attribute,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 parts=parts,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
40 call_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 metadata={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 media_type="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
44 transport_data=transport_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 assert application_data[RTCP_FB_KEY][0] == ("nack", "pli", {})
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
47
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
48 def test_parse_sdp_rtcp_fb_specific(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 """Parsing of a payload-specific RTCP feedback SDP line."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
51
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 application_data = {
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 "payload_types": {96: {}}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 }
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 transport_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
56
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
57 # SDP line: a=rtcp-fb:96 nack
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 attribute = "rtcp-fb"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 parts = ["96", "nack"]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 xep_0293._parse_sdp_a_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 attribute=attribute,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
62 parts=parts,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
63 call_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
64 metadata={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
65 media_type="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
66 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 transport_data=transport_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
68 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
69 assert application_data["payload_types"][96][RTCP_FB_KEY][0] == ("nack", None, {})
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
70
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
71 def test_parse_sdp_rtcp_fb_trr_int_general(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
72 """Parsing of a general RTCP feedback with trr-int SDP line."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
73 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
74
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
75 application_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
76 transport_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
77
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
78 # SDP line: a=rtcp-fb-trr-int:* 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
79 attribute = "rtcp-fb-trr-int"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
80 parts = ["*", "100"]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 xep_0293._parse_sdp_a_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
82 attribute=attribute,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
83 parts=parts,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
84 call_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
85 metadata={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
86 media_type="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
87 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
88 transport_data=transport_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
89 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
90 assert application_data["rtcp-fb-trr-int"] == 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
91
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
92 def test_parse_sdp_rtcp_fb_trr_int_specific(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
93 """Parsing of a payload-specific RTCP feedback with trr-int SDP line."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
94 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
95
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
96 application_data = {
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
97 "payload_types": {96: {}}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
98 }
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
99 transport_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
101 # SDP line: a=rtcp-fb-trr-int:96 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
102 attribute = "rtcp-fb-trr-int"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
103 parts = ["96", "100"]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
104 xep_0293._parse_sdp_a_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
105 attribute=attribute,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
106 parts=parts,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
107 call_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
108 metadata={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
109 media_type="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
110 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
111 transport_data=transport_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
112 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
113 assert application_data["payload_types"][96]["rtcp-fb-trr-int"] == 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
114
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
115 def test_generate_sdp_session(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
116 """Generation of SDP lines for session data."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
117 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
118 sdp_lines = []
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
119 application_data = {RTCP_FB_KEY: [("nack", "pli", {})], "rtcp-fb-trr-int": 100}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
120
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
121 xep_0293._generate_sdp_content_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
122 session={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
123 local=True,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
124 content_name="test",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
125 content_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
126 sdp_lines=sdp_lines,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
127 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
128 app_data_key="test",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
129 media_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
130 media="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
131 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
132
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
133 assert sdp_lines[0] == "a=rtcp-fb:* nack pli"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
134 assert sdp_lines[1] == "a=rtcp-fb:* trr-int 100"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
135
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 def test_generate_sdp_payload_type(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
137 """Generation of SDP lines for each payload type."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
138 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
139 sdp_lines = []
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
140 application_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
141 media_data = {
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
142 "payload_types": {96: {RTCP_FB_KEY: [("nack", None, {})], "rtcp-fb-trr-int": 100}}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
143 }
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
144
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
145 xep_0293._generate_sdp_content_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
146 session={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 local=True,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
148 content_name="test",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
149 content_data={},
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
150 sdp_lines=sdp_lines,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
151 application_data=application_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
152 app_data_key="test",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
153 media_data=media_data,
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
154 media="video",
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
155 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
156
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
157 assert sdp_lines[0] == "a=rtcp-fb:96 nack"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
158 assert sdp_lines[1] == "a=rtcp-fb:96 trr-int 100"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
159
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
160 def test_parse_description(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 """Parsing of <rtcp-fb> and <rtcp-fb-trr-int> elements from a description."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
162 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
163
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
164 desc_element = xml_tools.parse(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 f"""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 <description xmlns="urn:xmpp:jingle:apps:rtp:1" media="audio">
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
167 <rtcp-fb xmlns="{NS_JINGLE_RTP_RTCP_FB}" type="nack" subtype="pli"/>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
168 <rtcp-fb-trr-int xmlns="{NS_JINGLE_RTP_RTCP_FB}" value="100"/>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
169 </description>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 """
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
172
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
173 media_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
174 xep_0293._parse_description_trigger(desc_element, media_data)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
175
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
176 assert media_data[RTCP_FB_KEY][0] == ("nack", "pli", {})
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
177 assert media_data["rtcp_fb_trr_int"][0] == 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
178
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
179 def test_parse_description_payload_type(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
180 """Parsing of <rtcp-fb> and <rtcp-fb-trr-int> elements from a payload type."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
181 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
182
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
183 desc_element = xml_tools.parse(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
184 f"""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
185 <description xmlns="urn:xmpp:jingle:apps:rtp:1" media="audio">
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
186 <payload-type id="96">
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
187 <rtcp-fb xmlns="{NS_JINGLE_RTP_RTCP_FB}" type="nack" subtype="pli"/>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
188 <rtcp-fb-trr-int xmlns="{NS_JINGLE_RTP_RTCP_FB}" value="100"/>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
189 </payload-type>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
190 </description>
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
191 """
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
192 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
193
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
194 media_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
195 payload_type_elt = desc_element.firstChildElement()
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
196 payload_type_data = {}
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
197 xep_0293._parse_description_payload_type_trigger(
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
198 desc_element, media_data, payload_type_elt, payload_type_data
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
199 )
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
200
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
201 assert payload_type_data[RTCP_FB_KEY][0] == ("nack", "pli", {})
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
202 assert payload_type_data["rtcp_fb_trr_int"][0] == 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
203
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
204 def test_build_rtcp_fb_elements(self, host):
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
205 """Building the <rtcp-fb> and <rtcp-fb-trr-int> elements."""
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
206 xep_0293 = XEP_0293(host)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
207 data = {
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
208 RTCP_FB_KEY: [("nack", "pli", {})],
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
209 "rtcp-fb-trr-int": 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
210 }
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
211
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
212 # Test _build_description_trigger
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
213 desc_elt = domish.Element((NS_JINGLE_RTP, "description"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
214 xep_0293._build_description_trigger(desc_elt, data, {})
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
215
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
216 rtcp_fb_elts = list(desc_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
217 assert len(rtcp_fb_elts) == 1
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
218 rtcp_fb_elt = rtcp_fb_elts[0]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
219 assert rtcp_fb_elt["type"] == "nack"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
220 assert rtcp_fb_elt["subtype"] == "pli"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
221
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
222 rtcp_fb_trr_int_elts = list(desc_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
223 assert len(rtcp_fb_trr_int_elts) == 1
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
224 rtcp_fb_trr_int_elt = rtcp_fb_trr_int_elts[0]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
225 assert int(rtcp_fb_trr_int_elt["value"]) == 100
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
226
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
227 # Test _build_description_payload_type_trigger
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
228 desc_elt = domish.Element((NS_JINGLE_RTP, "description"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
229 payload_type_elt = desc_elt.addElement((NS_JINGLE_RTP, "payload-type"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
230 xep_0293._build_description_payload_type_trigger(desc_elt, {}, data, payload_type_elt)
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
231
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
232 rtcp_fb_elts = list(payload_type_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
233 assert len(rtcp_fb_elts) == 1
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
234 rtcp_fb_elt = rtcp_fb_elts[0]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
235 assert rtcp_fb_elt["type"] == "nack"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
236 assert rtcp_fb_elt["subtype"] == "pli"
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
237
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
238 rtcp_fb_trr_int_elts = list(payload_type_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int"))
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
239 assert len(rtcp_fb_trr_int_elts) == 1
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
240 rtcp_fb_trr_int_elt = rtcp_fb_trr_int_elts[0]
fddd76dedc97 tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff changeset
241 assert int(rtcp_fb_trr_int_elt["value"]) == 100