Mercurial > libervia-backend
annotate tests/unit/test_plugin_xep_0293.py @ 4326:5fd6a4dc2122
cli (output/std): use `rich` to output JSON.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 20 Nov 2024 11:38:44 +0100 |
parents | f1d0cde61af7 |
children |
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 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
22 from libervia.backend.plugins.plugin_xep_0293 import ( |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
23 NS_JINGLE_RTP_RTCP_FB, |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
24 RTCP_FB_KEY, |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
25 XEP_0293, |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
26 ) |
4071
4b842c1fb686
refactoring: renamed `sat` package to `libervia.backend`
Goffi <goffi@goffi.org>
parents:
4061
diff
changeset
|
27 from libervia.backend.tools import xml_tools |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
28 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
29 |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
30 class TestXEP0293: |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
31 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
32 def test_parse_sdp_rtcp_fb_general(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
33 """Parsing of a general RTCP feedback SDP line.""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
34 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
35 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
36 application_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
37 transport_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
38 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
39 # SDP line: a=rtcp-fb:* nack pli |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
40 attribute = "rtcp-fb" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
41 parts = ["*", "nack", "pli"] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
42 xep_0293._parse_sdp_a_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
43 attribute=attribute, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
44 parts=parts, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
45 call_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
46 metadata={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
47 media_type="video", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
48 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
49 transport_data=transport_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
50 ) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
51 assert application_data[RTCP_FB_KEY][0] == ("nack", "pli", {}) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
52 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
53 def test_parse_sdp_rtcp_fb_specific(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
54 """Parsing of a payload-specific RTCP feedback SDP line.""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
55 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
56 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
57 application_data = {"payload_types": {96: {}}} |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
58 transport_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
59 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
60 # SDP line: a=rtcp-fb:96 nack |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
61 attribute = "rtcp-fb" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
62 parts = ["96", "nack"] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
63 xep_0293._parse_sdp_a_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
64 attribute=attribute, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
65 parts=parts, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
66 call_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
67 metadata={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
68 media_type="video", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
69 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
70 transport_data=transport_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
71 ) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
72 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
|
73 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
74 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
|
75 """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
|
76 xep_0293 = XEP_0293(host) |
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 application_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
79 transport_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
80 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
81 # SDP line: a=rtcp-fb-trr-int:* 100 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
82 attribute = "rtcp-fb-trr-int" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
83 parts = ["*", "100"] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
84 xep_0293._parse_sdp_a_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
85 attribute=attribute, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
86 parts=parts, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
87 call_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
88 metadata={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
89 media_type="video", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
90 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
91 transport_data=transport_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
92 ) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
93 assert application_data["rtcp-fb-trr-int"] == 100 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
94 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
95 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
|
96 """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
|
97 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
98 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
99 application_data = {"payload_types": {96: {}}} |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
100 transport_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
101 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
102 # SDP line: a=rtcp-fb-trr-int:96 100 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
103 attribute = "rtcp-fb-trr-int" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
104 parts = ["96", "100"] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
105 xep_0293._parse_sdp_a_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
106 attribute=attribute, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
107 parts=parts, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
108 call_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
109 metadata={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
110 media_type="video", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
111 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
112 transport_data=transport_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
113 ) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
114 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
|
115 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
116 def test_generate_sdp_session(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
117 """Generation of SDP lines for session data.""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
118 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
119 sdp_lines = [] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
120 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
|
121 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
122 xep_0293._generate_sdp_content_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
123 session={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
124 local=True, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
125 content_name="test", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
126 content_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
127 sdp_lines=sdp_lines, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
128 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
129 app_data_key="test", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
130 media_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
131 media="video", |
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 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
134 assert sdp_lines[0] == "a=rtcp-fb:* nack pli" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
135 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
|
136 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
137 def test_generate_sdp_payload_type(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
138 """Generation of SDP lines for each payload type.""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
139 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
140 sdp_lines = [] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
141 application_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
142 media_data = { |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
143 "payload_types": { |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
144 96: {RTCP_FB_KEY: [("nack", None, {})], "rtcp-fb-trr-int": 100} |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
145 } |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
146 } |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
147 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
148 xep_0293._generate_sdp_content_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
149 session={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
150 local=True, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
151 content_name="test", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
152 content_data={}, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
153 sdp_lines=sdp_lines, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
154 application_data=application_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
155 app_data_key="test", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
156 media_data=media_data, |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
157 media="video", |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
158 ) |
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 assert sdp_lines[0] == "a=rtcp-fb:96 nack" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
161 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
|
162 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
163 def test_parse_description(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
164 """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
|
165 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
166 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
167 desc_element = xml_tools.parse( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
168 f""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
169 <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
|
170 <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
|
171 <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
|
172 </description> |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
173 """ |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
174 ) |
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 media_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
177 xep_0293._parse_description_trigger(desc_element, media_data) |
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 assert media_data[RTCP_FB_KEY][0] == ("nack", "pli", {}) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
180 assert media_data["rtcp_fb_trr_int"][0] == 100 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
181 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
182 def test_parse_description_payload_type(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
183 """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
|
184 xep_0293 = XEP_0293(host) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
185 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
186 desc_element = xml_tools.parse( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
187 f""" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
188 <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
|
189 <payload-type id="96"> |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
190 <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
|
191 <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
|
192 </payload-type> |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
193 </description> |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
194 """ |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
195 ) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
196 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
197 media_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
198 payload_type_elt = desc_element.firstChildElement() |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
199 payload_type_data = {} |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
200 xep_0293._parse_description_payload_type_trigger( |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
201 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
|
202 ) |
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 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
|
205 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
|
206 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
207 def test_build_rtcp_fb_elements(self, host): |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
208 """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
|
209 xep_0293 = XEP_0293(host) |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
210 data = {RTCP_FB_KEY: [("nack", "pli", {})], "rtcp-fb-trr-int": 100} |
4061
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 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
222 rtcp_fb_trr_int_elts = list( |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
223 desc_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int") |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
224 ) |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
225 assert len(rtcp_fb_trr_int_elts) == 1 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
226 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
|
227 assert int(rtcp_fb_trr_int_elt["value"]) == 100 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
228 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
229 # Test _build_description_payload_type_trigger |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
230 desc_elt = domish.Element((NS_JINGLE_RTP, "description")) |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
231 payload_type_elt = desc_elt.addElement((NS_JINGLE_RTP, "payload-type")) |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
232 xep_0293._build_description_payload_type_trigger( |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
233 desc_elt, {}, data, payload_type_elt |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
234 ) |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
235 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
236 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
|
237 assert len(rtcp_fb_elts) == 1 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
238 rtcp_fb_elt = rtcp_fb_elts[0] |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
239 assert rtcp_fb_elt["type"] == "nack" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
240 assert rtcp_fb_elt["subtype"] == "pli" |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
241 |
4285
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
242 rtcp_fb_trr_int_elts = list( |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
243 payload_type_elt.elements(NS_JINGLE_RTP_RTCP_FB, "rtcp-fb-trr-int") |
f1d0cde61af7
tests (unit): fix tests + black reformatting.
Goffi <goffi@goffi.org>
parents:
4071
diff
changeset
|
244 ) |
4061
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
245 assert len(rtcp_fb_trr_int_elts) == 1 |
fddd76dedc97
tests (units): tests for plugin XEP-0293:
Goffi <goffi@goffi.org>
parents:
diff
changeset
|
246 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
|
247 assert int(rtcp_fb_trr_int_elt["value"]) == 100 |