@tomgiee/tsdp 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +124 -0
- package/dist/src/builder/media-builder.d.ts +221 -0
- package/dist/src/builder/media-builder.d.ts.map +1 -0
- package/dist/src/builder/media-builder.js +385 -0
- package/dist/src/builder/session-builder.d.ts +195 -0
- package/dist/src/builder/session-builder.d.ts.map +1 -0
- package/dist/src/builder/session-builder.js +366 -0
- package/dist/src/index.d.ts +67 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +250 -0
- package/dist/src/parser/attribute-parser.d.ts +100 -0
- package/dist/src/parser/attribute-parser.d.ts.map +1 -0
- package/dist/src/parser/attribute-parser.js +217 -0
- package/dist/src/parser/field-parser.d.ts +124 -0
- package/dist/src/parser/field-parser.d.ts.map +1 -0
- package/dist/src/parser/field-parser.js +335 -0
- package/dist/src/parser/media-parser.d.ts +45 -0
- package/dist/src/parser/media-parser.d.ts.map +1 -0
- package/dist/src/parser/media-parser.js +157 -0
- package/dist/src/parser/primitive-parser.d.ts +138 -0
- package/dist/src/parser/primitive-parser.d.ts.map +1 -0
- package/dist/src/parser/primitive-parser.js +316 -0
- package/dist/src/parser/scanner.d.ts +142 -0
- package/dist/src/parser/scanner.d.ts.map +1 -0
- package/dist/src/parser/scanner.js +284 -0
- package/dist/src/parser/session-parser.d.ts +35 -0
- package/dist/src/parser/session-parser.d.ts.map +1 -0
- package/dist/src/parser/session-parser.js +207 -0
- package/dist/src/parser/time-parser.d.ts +74 -0
- package/dist/src/parser/time-parser.d.ts.map +1 -0
- package/dist/src/parser/time-parser.js +168 -0
- package/dist/src/serializer/attribute-serializer.d.ts +18 -0
- package/dist/src/serializer/attribute-serializer.d.ts.map +1 -0
- package/dist/src/serializer/attribute-serializer.js +34 -0
- package/dist/src/serializer/field-serializer.d.ts +112 -0
- package/dist/src/serializer/field-serializer.d.ts.map +1 -0
- package/dist/src/serializer/field-serializer.js +212 -0
- package/dist/src/serializer/media-serializer.d.ts +31 -0
- package/dist/src/serializer/media-serializer.d.ts.map +1 -0
- package/dist/src/serializer/media-serializer.js +83 -0
- package/dist/src/serializer/session-serializer.d.ts +29 -0
- package/dist/src/serializer/session-serializer.d.ts.map +1 -0
- package/dist/src/serializer/session-serializer.js +99 -0
- package/dist/src/serializer/time-serializer.d.ts +46 -0
- package/dist/src/serializer/time-serializer.d.ts.map +1 -0
- package/dist/src/serializer/time-serializer.js +86 -0
- package/dist/src/types/attributes.d.ts +318 -0
- package/dist/src/types/attributes.d.ts.map +1 -0
- package/dist/src/types/attributes.js +225 -0
- package/dist/src/types/errors.d.ts +129 -0
- package/dist/src/types/errors.d.ts.map +1 -0
- package/dist/src/types/errors.js +186 -0
- package/dist/src/types/fields.d.ts +100 -0
- package/dist/src/types/fields.d.ts.map +1 -0
- package/dist/src/types/fields.js +48 -0
- package/dist/src/types/media.d.ts +148 -0
- package/dist/src/types/media.d.ts.map +1 -0
- package/dist/src/types/media.js +137 -0
- package/dist/src/types/network.d.ts +136 -0
- package/dist/src/types/network.d.ts.map +1 -0
- package/dist/src/types/network.js +130 -0
- package/dist/src/types/primitives.d.ts +193 -0
- package/dist/src/types/primitives.d.ts.map +1 -0
- package/dist/src/types/primitives.js +195 -0
- package/dist/src/types/session.d.ts +122 -0
- package/dist/src/types/session.d.ts.map +1 -0
- package/dist/src/types/session.js +81 -0
- package/dist/src/types/time.d.ts +129 -0
- package/dist/src/types/time.d.ts.map +1 -0
- package/dist/src/types/time.js +84 -0
- package/dist/src/utils/address-parser.d.ts +100 -0
- package/dist/src/utils/address-parser.d.ts.map +1 -0
- package/dist/src/utils/address-parser.js +338 -0
- package/dist/src/utils/format-validators.d.ts +77 -0
- package/dist/src/utils/format-validators.d.ts.map +1 -0
- package/dist/src/utils/format-validators.js +504 -0
- package/dist/src/utils/line-reader.d.ts +84 -0
- package/dist/src/utils/line-reader.d.ts.map +1 -0
- package/dist/src/utils/line-reader.js +169 -0
- package/dist/src/utils/time-converter.d.ts +99 -0
- package/dist/src/utils/time-converter.d.ts.map +1 -0
- package/dist/src/utils/time-converter.js +195 -0
- package/dist/src/validator/media-validator.d.ts +27 -0
- package/dist/src/validator/media-validator.d.ts.map +1 -0
- package/dist/src/validator/media-validator.js +241 -0
- package/dist/src/validator/semantic-validator.d.ts +47 -0
- package/dist/src/validator/semantic-validator.d.ts.map +1 -0
- package/dist/src/validator/semantic-validator.js +207 -0
- package/dist/src/validator/session-validator.d.ts +36 -0
- package/dist/src/validator/session-validator.d.ts.map +1 -0
- package/dist/src/validator/session-validator.js +280 -0
- package/dist/tests/integration/round-trip.test.d.ts +5 -0
- package/dist/tests/integration/round-trip.test.d.ts.map +1 -0
- package/dist/tests/integration/round-trip.test.js +320 -0
- package/dist/tests/integration/voip-examples.test.d.ts +5 -0
- package/dist/tests/integration/voip-examples.test.d.ts.map +1 -0
- package/dist/tests/integration/voip-examples.test.js +361 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/media-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/media-builder.test.js +524 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts +5 -0
- package/dist/tests/unit/builder/session-builder.test.d.ts.map +1 -0
- package/dist/tests/unit/builder/session-builder.test.js +367 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/attribute-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/attribute-parser.test.js +319 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/field-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/field-parser.test.js +355 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/media-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/media-parser.test.js +241 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/primitive-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/primitive-parser.test.js +261 -0
- package/dist/tests/unit/parser/scanner.test.d.ts +5 -0
- package/dist/tests/unit/parser/scanner.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/scanner.test.js +241 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/session-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/session-parser.test.js +346 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts +5 -0
- package/dist/tests/unit/parser/time-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/parser/time-parser.test.js +173 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/attribute-serializer.test.js +78 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/field-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/field-serializer.test.js +159 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/media-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/media-serializer.test.js +155 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/session-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/session-serializer.test.js +317 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts +5 -0
- package/dist/tests/unit/serializer/time-serializer.test.d.ts.map +1 -0
- package/dist/tests/unit/serializer/time-serializer.test.js +115 -0
- package/dist/tests/unit/types/errors.test.d.ts +5 -0
- package/dist/tests/unit/types/errors.test.d.ts.map +1 -0
- package/dist/tests/unit/types/errors.test.js +127 -0
- package/dist/tests/unit/types/network.test.d.ts +5 -0
- package/dist/tests/unit/types/network.test.d.ts.map +1 -0
- package/dist/tests/unit/types/network.test.js +132 -0
- package/dist/tests/unit/types/primitives.test.d.ts +5 -0
- package/dist/tests/unit/types/primitives.test.d.ts.map +1 -0
- package/dist/tests/unit/types/primitives.test.js +108 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts +5 -0
- package/dist/tests/unit/utils/address-parser.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/address-parser.test.js +203 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts +5 -0
- package/dist/tests/unit/utils/format-validators.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/format-validators.test.js +224 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts +5 -0
- package/dist/tests/unit/utils/line-reader.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/line-reader.test.js +157 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts +5 -0
- package/dist/tests/unit/utils/time-converter.test.d.ts.map +1 -0
- package/dist/tests/unit/utils/time-converter.test.js +190 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/media-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/media-validator.test.js +313 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/semantic-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/semantic-validator.test.js +262 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts +5 -0
- package/dist/tests/unit/validator/session-validator.test.d.ts.map +1 -0
- package/dist/tests/unit/validator/session-validator.test.js +447 -0
- package/package.json +50 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for session-parser.ts
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const session_parser_1 = require("../../../src/parser/session-parser");
|
|
7
|
+
const errors_1 = require("../../../src/types/errors");
|
|
8
|
+
describe('session-parser', () => {
|
|
9
|
+
describe('parseSessionDescription', () => {
|
|
10
|
+
it('should parse minimal valid SDP', () => {
|
|
11
|
+
const sdp = `v=0\r
|
|
12
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
13
|
+
s=SDP Seminar\r
|
|
14
|
+
t=0 0\r
|
|
15
|
+
`;
|
|
16
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
17
|
+
expect(session.version).toBe(0);
|
|
18
|
+
expect(session.origin.username).toBe('jdoe');
|
|
19
|
+
expect(session.sessionName).toBe('SDP Seminar');
|
|
20
|
+
expect(session.timeDescriptions).toHaveLength(1);
|
|
21
|
+
expect(session.timeDescriptions[0].timing.startTime).toBe(0);
|
|
22
|
+
expect(session.timeDescriptions[0].timing.stopTime).toBe(0);
|
|
23
|
+
});
|
|
24
|
+
it('should parse SDP with optional session information', () => {
|
|
25
|
+
const sdp = `v=0\r
|
|
26
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
27
|
+
s=SDP Seminar\r
|
|
28
|
+
i=A Seminar on the session description protocol\r
|
|
29
|
+
t=0 0\r
|
|
30
|
+
`;
|
|
31
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
32
|
+
expect(session.sessionInformation).toBe('A Seminar on the session description protocol');
|
|
33
|
+
});
|
|
34
|
+
it('should parse SDP with URI', () => {
|
|
35
|
+
const sdp = `v=0\r
|
|
36
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
37
|
+
s=SDP Seminar\r
|
|
38
|
+
u=http://www.example.com/seminars/sdp.pdf\r
|
|
39
|
+
t=0 0\r
|
|
40
|
+
`;
|
|
41
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
42
|
+
expect(session.uri).toBe('http://www.example.com/seminars/sdp.pdf');
|
|
43
|
+
});
|
|
44
|
+
it('should parse SDP with email', () => {
|
|
45
|
+
const sdp = `v=0\r
|
|
46
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
47
|
+
s=SDP Seminar\r
|
|
48
|
+
e=j.doe@example.com (Jane Doe)\r
|
|
49
|
+
t=0 0\r
|
|
50
|
+
`;
|
|
51
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
52
|
+
expect(session.emails).toHaveLength(1);
|
|
53
|
+
expect(session.emails[0]).toBe('j.doe@example.com (Jane Doe)');
|
|
54
|
+
});
|
|
55
|
+
it('should parse SDP with multiple emails', () => {
|
|
56
|
+
const sdp = `v=0\r
|
|
57
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
58
|
+
s=SDP Seminar\r
|
|
59
|
+
e=j.doe@example.com\r
|
|
60
|
+
e=jane@example.com\r
|
|
61
|
+
t=0 0\r
|
|
62
|
+
`;
|
|
63
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
64
|
+
expect(session.emails).toHaveLength(2);
|
|
65
|
+
});
|
|
66
|
+
it('should parse SDP with phone', () => {
|
|
67
|
+
const sdp = `v=0\r
|
|
68
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
69
|
+
s=SDP Seminar\r
|
|
70
|
+
p=+1 617 555-6011\r
|
|
71
|
+
t=0 0\r
|
|
72
|
+
`;
|
|
73
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
74
|
+
expect(session.phones).toHaveLength(1);
|
|
75
|
+
expect(session.phones[0]).toBe('+1 617 555-6011');
|
|
76
|
+
});
|
|
77
|
+
it('should parse SDP with connection', () => {
|
|
78
|
+
const sdp = `v=0\r
|
|
79
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
80
|
+
s=SDP Seminar\r
|
|
81
|
+
c=IN IP4 224.2.17.12/127\r
|
|
82
|
+
t=0 0\r
|
|
83
|
+
`;
|
|
84
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
85
|
+
expect(session.connection).toBeDefined();
|
|
86
|
+
expect(session.connection.netType).toBe('IN');
|
|
87
|
+
expect(session.connection.addrType).toBe('IP4');
|
|
88
|
+
});
|
|
89
|
+
it('should parse SDP with bandwidth', () => {
|
|
90
|
+
const sdp = `v=0\r
|
|
91
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
92
|
+
s=SDP Seminar\r
|
|
93
|
+
b=AS:128\r
|
|
94
|
+
t=0 0\r
|
|
95
|
+
`;
|
|
96
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
97
|
+
expect(session.bandwidths).toHaveLength(1);
|
|
98
|
+
expect(session.bandwidths[0].type).toBe('AS');
|
|
99
|
+
expect(session.bandwidths[0].value).toBe(128);
|
|
100
|
+
});
|
|
101
|
+
it('should parse SDP with multiple time descriptions', () => {
|
|
102
|
+
const sdp = `v=0\r
|
|
103
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
104
|
+
s=SDP Seminar\r
|
|
105
|
+
t=2873397496 2873404696\r
|
|
106
|
+
t=3034423619 3042462419\r
|
|
107
|
+
`;
|
|
108
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
109
|
+
expect(session.timeDescriptions).toHaveLength(2);
|
|
110
|
+
});
|
|
111
|
+
it('should parse SDP with repeat times', () => {
|
|
112
|
+
const sdp = `v=0\r
|
|
113
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
114
|
+
s=SDP Seminar\r
|
|
115
|
+
t=2873397496 2873404696\r
|
|
116
|
+
r=7d 1h 0 25h\r
|
|
117
|
+
`;
|
|
118
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
119
|
+
expect(session.timeDescriptions[0].repeats).toHaveLength(1);
|
|
120
|
+
expect(session.timeDescriptions[0].repeats[0].interval).toEqual({
|
|
121
|
+
value: 7,
|
|
122
|
+
unit: 'days',
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
it('should parse SDP with timezone adjustments', () => {
|
|
126
|
+
const sdp = `v=0\r
|
|
127
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
128
|
+
s=SDP Seminar\r
|
|
129
|
+
t=2873397496 2873404696\r
|
|
130
|
+
z=2882844526 -1h 2898848070 0\r
|
|
131
|
+
`;
|
|
132
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
133
|
+
expect(session.timeDescriptions[0].timezone).toBeDefined();
|
|
134
|
+
expect(session.timeDescriptions[0].timezone.adjustments).toHaveLength(2);
|
|
135
|
+
});
|
|
136
|
+
it('should parse SDP with session-level key', () => {
|
|
137
|
+
const sdp = `v=0\r
|
|
138
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
139
|
+
s=SDP Seminar\r
|
|
140
|
+
t=0 0\r
|
|
141
|
+
k=clear:mypassword\r
|
|
142
|
+
`;
|
|
143
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
144
|
+
expect(session.key).toBe('clear:mypassword');
|
|
145
|
+
});
|
|
146
|
+
it('should parse SDP with session-level attributes', () => {
|
|
147
|
+
const sdp = `v=0\r
|
|
148
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
149
|
+
s=SDP Seminar\r
|
|
150
|
+
t=0 0\r
|
|
151
|
+
a=recvonly\r
|
|
152
|
+
a=type:broadcast\r
|
|
153
|
+
`;
|
|
154
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
155
|
+
expect(session.attributes).toHaveLength(2);
|
|
156
|
+
});
|
|
157
|
+
it('should parse SDP with single media description', () => {
|
|
158
|
+
const sdp = `v=0\r
|
|
159
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
160
|
+
s=SDP Seminar\r
|
|
161
|
+
c=IN IP4 224.2.17.12/127\r
|
|
162
|
+
t=0 0\r
|
|
163
|
+
m=audio 49170 RTP/AVP 0\r
|
|
164
|
+
`;
|
|
165
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
166
|
+
expect(session.mediaDescriptions).toHaveLength(1);
|
|
167
|
+
expect(session.mediaDescriptions[0].media.type).toBe('audio');
|
|
168
|
+
});
|
|
169
|
+
it('should parse SDP with multiple media descriptions', () => {
|
|
170
|
+
const sdp = `v=0\r
|
|
171
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
172
|
+
s=SDP Seminar\r
|
|
173
|
+
c=IN IP4 224.2.17.12/127\r
|
|
174
|
+
t=0 0\r
|
|
175
|
+
m=audio 49170 RTP/AVP 0\r
|
|
176
|
+
m=video 51372 RTP/AVP 99\r
|
|
177
|
+
`;
|
|
178
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
179
|
+
expect(session.mediaDescriptions).toHaveLength(2);
|
|
180
|
+
expect(session.mediaDescriptions[0].media.type).toBe('audio');
|
|
181
|
+
expect(session.mediaDescriptions[1].media.type).toBe('video');
|
|
182
|
+
});
|
|
183
|
+
it('should parse SDP with media-level fields', () => {
|
|
184
|
+
const sdp = `v=0\r
|
|
185
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
186
|
+
s=SDP Seminar\r
|
|
187
|
+
t=0 0\r
|
|
188
|
+
m=audio 49170 RTP/AVP 0 8\r
|
|
189
|
+
i=Audio Stream\r
|
|
190
|
+
c=IN IP4 192.168.1.100\r
|
|
191
|
+
b=AS:64\r
|
|
192
|
+
a=rtpmap:0 PCMU/8000\r
|
|
193
|
+
a=rtpmap:8 PCMA/8000\r
|
|
194
|
+
a=ptime:20\r
|
|
195
|
+
a=sendrecv\r
|
|
196
|
+
`;
|
|
197
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
198
|
+
expect(session.mediaDescriptions).toHaveLength(1);
|
|
199
|
+
const media = session.mediaDescriptions[0];
|
|
200
|
+
expect(media.information).toBe('Audio Stream');
|
|
201
|
+
expect(media.connections).toHaveLength(1);
|
|
202
|
+
expect(media.bandwidths).toHaveLength(1);
|
|
203
|
+
expect(media.attributes).toHaveLength(4);
|
|
204
|
+
});
|
|
205
|
+
it('should parse complete SDP with all fields', () => {
|
|
206
|
+
const sdp = `v=0\r
|
|
207
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
208
|
+
s=SDP Seminar\r
|
|
209
|
+
i=A Seminar on the session description protocol\r
|
|
210
|
+
u=http://www.example.com/seminars/sdp.pdf\r
|
|
211
|
+
e=j.doe@example.com (Jane Doe)\r
|
|
212
|
+
p=+1 617 555-6011\r
|
|
213
|
+
c=IN IP4 224.2.17.12/127\r
|
|
214
|
+
b=AS:128\r
|
|
215
|
+
t=2873397496 2873404696\r
|
|
216
|
+
r=7d 1h 0 25h\r
|
|
217
|
+
z=2882844526 -1h 2898848070 0\r
|
|
218
|
+
k=clear:mypassword\r
|
|
219
|
+
a=recvonly\r
|
|
220
|
+
a=type:broadcast\r
|
|
221
|
+
m=audio 49170 RTP/AVP 0\r
|
|
222
|
+
i=Audio Stream\r
|
|
223
|
+
c=IN IP4 192.168.1.100\r
|
|
224
|
+
b=AS:64\r
|
|
225
|
+
k=clear:mediakey\r
|
|
226
|
+
a=rtpmap:0 PCMU/8000\r
|
|
227
|
+
a=ptime:20\r
|
|
228
|
+
`;
|
|
229
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
230
|
+
// Session-level checks
|
|
231
|
+
expect(session.version).toBe(0);
|
|
232
|
+
expect(session.origin.username).toBe('jdoe');
|
|
233
|
+
expect(session.sessionName).toBe('SDP Seminar');
|
|
234
|
+
expect(session.sessionInformation).toBe('A Seminar on the session description protocol');
|
|
235
|
+
expect(session.uri).toBe('http://www.example.com/seminars/sdp.pdf');
|
|
236
|
+
expect(session.emails).toHaveLength(1);
|
|
237
|
+
expect(session.phones).toHaveLength(1);
|
|
238
|
+
expect(session.connection).toBeDefined();
|
|
239
|
+
expect(session.bandwidths).toHaveLength(1);
|
|
240
|
+
expect(session.timeDescriptions).toHaveLength(1);
|
|
241
|
+
expect(session.key).toBe('clear:mypassword');
|
|
242
|
+
expect(session.attributes).toHaveLength(2);
|
|
243
|
+
// Media-level checks
|
|
244
|
+
expect(session.mediaDescriptions).toHaveLength(1);
|
|
245
|
+
const media = session.mediaDescriptions[0];
|
|
246
|
+
expect(media.information).toBe('Audio Stream');
|
|
247
|
+
expect(media.connections).toHaveLength(1);
|
|
248
|
+
expect(media.bandwidths).toHaveLength(1);
|
|
249
|
+
expect(media.key).toBe('clear:mediakey');
|
|
250
|
+
expect(media.attributes).toHaveLength(2);
|
|
251
|
+
});
|
|
252
|
+
it('should parse SDP with LF line endings', () => {
|
|
253
|
+
const sdp = `v=0
|
|
254
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5
|
|
255
|
+
s=SDP Seminar
|
|
256
|
+
t=0 0
|
|
257
|
+
`;
|
|
258
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
259
|
+
expect(session.version).toBe(0);
|
|
260
|
+
expect(session.sessionName).toBe('SDP Seminar');
|
|
261
|
+
});
|
|
262
|
+
it('should parse SDP with multiple media and complex structure', () => {
|
|
263
|
+
const sdp = `v=0\r
|
|
264
|
+
o=- 1234567890 1234567890 IN IP4 192.168.1.100\r
|
|
265
|
+
s=VoIP Call\r
|
|
266
|
+
t=0 0\r
|
|
267
|
+
m=audio 10000 RTP/AVP 0 8 101\r
|
|
268
|
+
c=IN IP4 192.168.1.100\r
|
|
269
|
+
a=rtpmap:0 PCMU/8000\r
|
|
270
|
+
a=rtpmap:8 PCMA/8000\r
|
|
271
|
+
a=rtpmap:101 telephone-event/8000\r
|
|
272
|
+
a=fmtp:101 0-15\r
|
|
273
|
+
a=ptime:20\r
|
|
274
|
+
a=sendrecv\r
|
|
275
|
+
m=video 10002 RTP/AVP 96\r
|
|
276
|
+
c=IN IP4 192.168.1.100\r
|
|
277
|
+
a=rtpmap:96 H264/90000\r
|
|
278
|
+
a=fmtp:96 profile-level-id=42e01f\r
|
|
279
|
+
a=sendrecv\r
|
|
280
|
+
`;
|
|
281
|
+
const session = (0, session_parser_1.parseSessionDescription)(sdp);
|
|
282
|
+
expect(session.sessionName).toBe('VoIP Call');
|
|
283
|
+
expect(session.mediaDescriptions).toHaveLength(2);
|
|
284
|
+
expect(session.mediaDescriptions[0].media.type).toBe('audio');
|
|
285
|
+
expect(session.mediaDescriptions[0].attributes).toHaveLength(6);
|
|
286
|
+
expect(session.mediaDescriptions[1].media.type).toBe('video');
|
|
287
|
+
expect(session.mediaDescriptions[1].attributes).toHaveLength(3);
|
|
288
|
+
});
|
|
289
|
+
it('should throw for empty input', () => {
|
|
290
|
+
expect(() => (0, session_parser_1.parseSessionDescription)('')).toThrow(errors_1.ParseError);
|
|
291
|
+
expect(() => (0, session_parser_1.parseSessionDescription)('')).toThrow('Empty SDP input');
|
|
292
|
+
});
|
|
293
|
+
it('should throw for missing version', () => {
|
|
294
|
+
const sdp = `o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
295
|
+
s=SDP Seminar\r
|
|
296
|
+
t=0 0\r
|
|
297
|
+
`;
|
|
298
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
299
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('Expected version');
|
|
300
|
+
});
|
|
301
|
+
it('should throw for missing origin', () => {
|
|
302
|
+
const sdp = `v=0\r
|
|
303
|
+
s=SDP Seminar\r
|
|
304
|
+
t=0 0\r
|
|
305
|
+
`;
|
|
306
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
307
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('Expected origin');
|
|
308
|
+
});
|
|
309
|
+
it('should throw for missing session name', () => {
|
|
310
|
+
const sdp = `v=0\r
|
|
311
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
312
|
+
t=0 0\r
|
|
313
|
+
`;
|
|
314
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
315
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('Expected session name');
|
|
316
|
+
});
|
|
317
|
+
it('should throw for missing time description', () => {
|
|
318
|
+
const sdp = `v=0\r
|
|
319
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
320
|
+
s=SDP Seminar\r
|
|
321
|
+
`;
|
|
322
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
323
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('at least one time description');
|
|
324
|
+
});
|
|
325
|
+
it('should throw for wrong field ordering', () => {
|
|
326
|
+
const sdp = `v=0\r
|
|
327
|
+
s=SDP Seminar\r
|
|
328
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
329
|
+
t=0 0\r
|
|
330
|
+
`;
|
|
331
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
332
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('Expected origin');
|
|
333
|
+
});
|
|
334
|
+
it('should throw for unexpected field after media descriptions', () => {
|
|
335
|
+
const sdp = `v=0\r
|
|
336
|
+
o=jdoe 2890844526 2890842807 IN IP4 10.47.16.5\r
|
|
337
|
+
s=SDP Seminar\r
|
|
338
|
+
t=0 0\r
|
|
339
|
+
m=audio 49170 RTP/AVP 0\r
|
|
340
|
+
v=1\r
|
|
341
|
+
`;
|
|
342
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow(errors_1.ParseError);
|
|
343
|
+
expect(() => (0, session_parser_1.parseSessionDescription)(sdp)).toThrow('Unexpected field');
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"time-parser.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/parser/time-parser.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for time-parser.ts
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const scanner_1 = require("../../../src/parser/scanner");
|
|
7
|
+
const time_parser_1 = require("../../../src/parser/time-parser");
|
|
8
|
+
const errors_1 = require("../../../src/types/errors");
|
|
9
|
+
const time_1 = require("../../../src/types/time");
|
|
10
|
+
describe('time-parser', () => {
|
|
11
|
+
describe('parseTimingField', () => {
|
|
12
|
+
it('should parse permanent timing (0 to 0)', () => {
|
|
13
|
+
const scanner = new scanner_1.Scanner('0 0');
|
|
14
|
+
const timing = (0, time_parser_1.parseTimingField)(scanner);
|
|
15
|
+
expect(timing.startTime).toBe(0);
|
|
16
|
+
expect(timing.stopTime).toBe(0);
|
|
17
|
+
});
|
|
18
|
+
it('should parse bounded timing', () => {
|
|
19
|
+
const scanner = new scanner_1.Scanner('2873397496 2873404696');
|
|
20
|
+
const timing = (0, time_parser_1.parseTimingField)(scanner);
|
|
21
|
+
expect(timing.startTime).toBe(2873397496);
|
|
22
|
+
expect(timing.stopTime).toBe(2873404696);
|
|
23
|
+
});
|
|
24
|
+
it('should parse open-ended session (0 stop time)', () => {
|
|
25
|
+
const scanner = new scanner_1.Scanner('3724394400 0');
|
|
26
|
+
const timing = (0, time_parser_1.parseTimingField)(scanner);
|
|
27
|
+
expect(timing.startTime).toBe(3724394400);
|
|
28
|
+
expect(timing.stopTime).toBe(0);
|
|
29
|
+
});
|
|
30
|
+
it('should throw for missing stop time', () => {
|
|
31
|
+
const scanner = new scanner_1.Scanner('123456');
|
|
32
|
+
expect(() => (0, time_parser_1.parseTimingField)(scanner)).toThrow(errors_1.ParseError);
|
|
33
|
+
});
|
|
34
|
+
it('should throw for negative start time', () => {
|
|
35
|
+
const scanner = new scanner_1.Scanner('-1 0');
|
|
36
|
+
expect(() => (0, time_parser_1.parseTimingField)(scanner)).toThrow(errors_1.ParseError);
|
|
37
|
+
});
|
|
38
|
+
it('should throw when start > stop (both non-zero)', () => {
|
|
39
|
+
expect(() => (0, time_parser_1.parseTimingField)(new scanner_1.Scanner('2000 1000'))).toThrow(errors_1.ParseError);
|
|
40
|
+
expect(() => (0, time_parser_1.parseTimingField)(new scanner_1.Scanner('2000 1000'))).toThrow('Start time must be before');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('parseRepeatField', () => {
|
|
44
|
+
it('should parse repeat with single offset', () => {
|
|
45
|
+
const scanner = new scanner_1.Scanner('7d 1h 0');
|
|
46
|
+
const repeat = (0, time_parser_1.parseRepeatField)(scanner);
|
|
47
|
+
expect(repeat.interval).toEqual({ value: 7, unit: 'days' });
|
|
48
|
+
expect(repeat.duration).toEqual({ value: 1, unit: 'hours' });
|
|
49
|
+
expect(repeat.offsets).toHaveLength(1);
|
|
50
|
+
expect(repeat.offsets[0]).toEqual({ value: 0, unit: 'seconds' });
|
|
51
|
+
});
|
|
52
|
+
it('should parse repeat with multiple offsets', () => {
|
|
53
|
+
const scanner = new scanner_1.Scanner('7d 1h 0 25h');
|
|
54
|
+
const repeat = (0, time_parser_1.parseRepeatField)(scanner);
|
|
55
|
+
expect(repeat.interval).toEqual({ value: 7, unit: 'days' });
|
|
56
|
+
expect(repeat.duration).toEqual({ value: 1, unit: 'hours' });
|
|
57
|
+
expect(repeat.offsets).toHaveLength(2);
|
|
58
|
+
expect(repeat.offsets[0]).toEqual({ value: 0, unit: 'seconds' });
|
|
59
|
+
expect(repeat.offsets[1]).toEqual({ value: 25, unit: 'hours' });
|
|
60
|
+
});
|
|
61
|
+
it('should parse repeat with seconds (no suffix)', () => {
|
|
62
|
+
const scanner = new scanner_1.Scanner('604800 3600 0 90000');
|
|
63
|
+
const repeat = (0, time_parser_1.parseRepeatField)(scanner);
|
|
64
|
+
expect(repeat.interval).toEqual({ value: 604800, unit: 'seconds' });
|
|
65
|
+
expect(repeat.duration).toEqual({ value: 3600, unit: 'seconds' });
|
|
66
|
+
expect(repeat.offsets).toHaveLength(2);
|
|
67
|
+
});
|
|
68
|
+
it('should parse repeat with mixed units', () => {
|
|
69
|
+
const scanner = new scanner_1.Scanner('7d 90m 0 1800 25h');
|
|
70
|
+
const repeat = (0, time_parser_1.parseRepeatField)(scanner);
|
|
71
|
+
expect(repeat.interval).toEqual({ value: 7, unit: 'days' });
|
|
72
|
+
expect(repeat.duration).toEqual({ value: 90, unit: 'minutes' });
|
|
73
|
+
expect(repeat.offsets).toHaveLength(3);
|
|
74
|
+
expect(repeat.offsets[0]).toEqual({ value: 0, unit: 'seconds' });
|
|
75
|
+
expect(repeat.offsets[1]).toEqual({ value: 1800, unit: 'seconds' });
|
|
76
|
+
expect(repeat.offsets[2]).toEqual({ value: 25, unit: 'hours' });
|
|
77
|
+
});
|
|
78
|
+
it('should throw for missing duration', () => {
|
|
79
|
+
const scanner = new scanner_1.Scanner('7d');
|
|
80
|
+
expect(() => (0, time_parser_1.parseRepeatField)(scanner)).toThrow(errors_1.ParseError);
|
|
81
|
+
});
|
|
82
|
+
it('should throw for missing offsets', () => {
|
|
83
|
+
expect(() => (0, time_parser_1.parseRepeatField)(new scanner_1.Scanner('7d 1h'))).toThrow(errors_1.ParseError);
|
|
84
|
+
expect(() => (0, time_parser_1.parseRepeatField)(new scanner_1.Scanner('7d 1h'))).toThrow('at least one offset');
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
describe('parseTimezoneField', () => {
|
|
88
|
+
it('should parse single timezone adjustment', () => {
|
|
89
|
+
const scanner = new scanner_1.Scanner('2882844526 -1h');
|
|
90
|
+
const timezone = (0, time_parser_1.parseTimezoneField)(scanner);
|
|
91
|
+
expect(timezone.adjustments).toHaveLength(1);
|
|
92
|
+
expect(timezone.adjustments[0].time).toBe(2882844526);
|
|
93
|
+
expect(timezone.adjustments[0].offset).toEqual({ value: -1, unit: 'hours' });
|
|
94
|
+
});
|
|
95
|
+
it('should parse multiple timezone adjustments', () => {
|
|
96
|
+
const scanner = new scanner_1.Scanner('2882844526 -1h 2898848070 0');
|
|
97
|
+
const timezone = (0, time_parser_1.parseTimezoneField)(scanner);
|
|
98
|
+
expect(timezone.adjustments).toHaveLength(2);
|
|
99
|
+
expect(timezone.adjustments[0].time).toBe(2882844526);
|
|
100
|
+
expect(timezone.adjustments[0].offset).toEqual({ value: -1, unit: 'hours' });
|
|
101
|
+
expect(timezone.adjustments[1].time).toBe(2898848070);
|
|
102
|
+
expect(timezone.adjustments[1].offset).toEqual({ value: 0, unit: 'seconds' });
|
|
103
|
+
});
|
|
104
|
+
it('should parse timezone with positive offset', () => {
|
|
105
|
+
const scanner = new scanner_1.Scanner('3034423619 1h');
|
|
106
|
+
const timezone = (0, time_parser_1.parseTimezoneField)(scanner);
|
|
107
|
+
expect(timezone.adjustments).toHaveLength(1);
|
|
108
|
+
expect(timezone.adjustments[0].offset).toEqual({ value: 1, unit: 'hours' });
|
|
109
|
+
});
|
|
110
|
+
it('should parse timezone with seconds offset', () => {
|
|
111
|
+
const scanner = new scanner_1.Scanner('2882844526 -3600');
|
|
112
|
+
const timezone = (0, time_parser_1.parseTimezoneField)(scanner);
|
|
113
|
+
expect(timezone.adjustments[0].offset).toEqual({ value: -3600, unit: 'seconds' });
|
|
114
|
+
});
|
|
115
|
+
it('should parse timezone with days offset', () => {
|
|
116
|
+
const scanner = new scanner_1.Scanner('2882844526 -1d 2898848070 1d');
|
|
117
|
+
const timezone = (0, time_parser_1.parseTimezoneField)(scanner);
|
|
118
|
+
expect(timezone.adjustments).toHaveLength(2);
|
|
119
|
+
expect(timezone.adjustments[0].offset).toEqual({ value: -1, unit: 'days' });
|
|
120
|
+
expect(timezone.adjustments[1].offset).toEqual({ value: 1, unit: 'days' });
|
|
121
|
+
});
|
|
122
|
+
it('should throw for missing offset', () => {
|
|
123
|
+
const scanner = new scanner_1.Scanner('2882844526');
|
|
124
|
+
expect(() => (0, time_parser_1.parseTimezoneField)(scanner)).toThrow(errors_1.ParseError);
|
|
125
|
+
});
|
|
126
|
+
it('should throw for empty timezone field', () => {
|
|
127
|
+
const scanner = new scanner_1.Scanner('');
|
|
128
|
+
expect(() => (0, time_parser_1.parseTimezoneField)(scanner)).toThrow(errors_1.ParseError);
|
|
129
|
+
expect(() => (0, time_parser_1.parseTimezoneField)(scanner)).toThrow('at least one adjustment');
|
|
130
|
+
});
|
|
131
|
+
});
|
|
132
|
+
describe('parseTimeDescription', () => {
|
|
133
|
+
it('should create time description with timing only', () => {
|
|
134
|
+
const timing = (0, time_1.createTiming)(0, 0);
|
|
135
|
+
const td = (0, time_parser_1.parseTimeDescription)(timing);
|
|
136
|
+
expect(td.timing).toBe(timing);
|
|
137
|
+
expect(td.repeats).toHaveLength(0);
|
|
138
|
+
expect(td.timezone).toBeUndefined();
|
|
139
|
+
});
|
|
140
|
+
it('should create time description with timing and repeats', () => {
|
|
141
|
+
const timing = (0, time_1.createTiming)(2873397496, 2873404696);
|
|
142
|
+
const repeat = {
|
|
143
|
+
interval: { value: 7, unit: 'days' },
|
|
144
|
+
duration: { value: 1, unit: 'hours' },
|
|
145
|
+
offsets: [{ value: 0, unit: 'seconds' }],
|
|
146
|
+
};
|
|
147
|
+
const td = (0, time_parser_1.parseTimeDescription)(timing, [repeat]);
|
|
148
|
+
expect(td.timing).toBe(timing);
|
|
149
|
+
expect(td.repeats).toHaveLength(1);
|
|
150
|
+
expect(td.repeats[0]).toBe(repeat);
|
|
151
|
+
});
|
|
152
|
+
it('should create time description with all fields', () => {
|
|
153
|
+
const timing = (0, time_1.createTiming)(2873397496, 2873404696);
|
|
154
|
+
const repeat = {
|
|
155
|
+
interval: { value: 7, unit: 'days' },
|
|
156
|
+
duration: { value: 1, unit: 'hours' },
|
|
157
|
+
offsets: [{ value: 0, unit: 'seconds' }],
|
|
158
|
+
};
|
|
159
|
+
const timezone = {
|
|
160
|
+
adjustments: [
|
|
161
|
+
{
|
|
162
|
+
time: 2882844526,
|
|
163
|
+
offset: { value: -1, unit: 'hours' },
|
|
164
|
+
},
|
|
165
|
+
],
|
|
166
|
+
};
|
|
167
|
+
const td = (0, time_parser_1.parseTimeDescription)(timing, [repeat], timezone);
|
|
168
|
+
expect(td.timing).toBe(timing);
|
|
169
|
+
expect(td.repeats).toHaveLength(1);
|
|
170
|
+
expect(td.timezone).toBe(timezone);
|
|
171
|
+
});
|
|
172
|
+
});
|
|
173
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"attribute-serializer.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/serializer/attribute-serializer.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tests for attribute-serializer.ts
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const attribute_serializer_1 = require("../../../src/serializer/attribute-serializer");
|
|
7
|
+
const attributes_1 = require("../../../src/types/attributes");
|
|
8
|
+
describe('attribute-serializer', () => {
|
|
9
|
+
describe('serializeAttributeField', () => {
|
|
10
|
+
describe('property attributes', () => {
|
|
11
|
+
it('should serialize recvonly attribute', () => {
|
|
12
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createRecvonly)())).toBe('a=recvonly');
|
|
13
|
+
});
|
|
14
|
+
it('should serialize sendrecv attribute', () => {
|
|
15
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createSendrecv)())).toBe('a=sendrecv');
|
|
16
|
+
});
|
|
17
|
+
it('should serialize sendonly attribute', () => {
|
|
18
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createSendonly)())).toBe('a=sendonly');
|
|
19
|
+
});
|
|
20
|
+
it('should serialize inactive attribute', () => {
|
|
21
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createInactive)())).toBe('a=inactive');
|
|
22
|
+
});
|
|
23
|
+
it('should serialize custom property attribute', () => {
|
|
24
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createPropertyAttribute)('myattr'))).toBe('a=myattr');
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
describe('value attributes', () => {
|
|
28
|
+
it('should serialize rtpmap attribute', () => {
|
|
29
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createRtpmap)(0, 'PCMU', 8000))).toBe('a=rtpmap:0 PCMU/8000');
|
|
30
|
+
});
|
|
31
|
+
it('should serialize rtpmap with encoding params', () => {
|
|
32
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createRtpmap)(97, 'L16', 8000, 2))).toBe('a=rtpmap:97 L16/8000/2');
|
|
33
|
+
});
|
|
34
|
+
it('should serialize fmtp attribute', () => {
|
|
35
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createFmtp)('96', 'profile-level-id=42e01f'))).toBe('a=fmtp:96 profile-level-id=42e01f');
|
|
36
|
+
});
|
|
37
|
+
it('should serialize ptime attribute', () => {
|
|
38
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createPtime)(20))).toBe('a=ptime:20');
|
|
39
|
+
});
|
|
40
|
+
it('should serialize maxptime attribute', () => {
|
|
41
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createMaxptime)(150))).toBe('a=maxptime:150');
|
|
42
|
+
});
|
|
43
|
+
it('should serialize custom value attribute', () => {
|
|
44
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('customattr', 'customvalue'))).toBe('a=customattr:customvalue');
|
|
45
|
+
});
|
|
46
|
+
it('should serialize value with colons', () => {
|
|
47
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('candidate', '1 1 UDP 2130706431 192.168.1.1 8998 typ host'))).toBe('a=candidate:1 1 UDP 2130706431 192.168.1.1 8998 typ host');
|
|
48
|
+
});
|
|
49
|
+
it('should serialize cat attribute', () => {
|
|
50
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('cat', 'conference'))).toBe('a=cat:conference');
|
|
51
|
+
});
|
|
52
|
+
it('should serialize tool attribute', () => {
|
|
53
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('tool', 'my-sdp-tool v1.0'))).toBe('a=tool:my-sdp-tool v1.0');
|
|
54
|
+
});
|
|
55
|
+
it('should serialize orient attribute', () => {
|
|
56
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('orient', 'landscape'))).toBe('a=orient:landscape');
|
|
57
|
+
});
|
|
58
|
+
it('should serialize type attribute', () => {
|
|
59
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('type', 'broadcast'))).toBe('a=type:broadcast');
|
|
60
|
+
});
|
|
61
|
+
it('should serialize charset attribute', () => {
|
|
62
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('charset', 'UTF-8'))).toBe('a=charset:UTF-8');
|
|
63
|
+
});
|
|
64
|
+
it('should serialize sdplang attribute', () => {
|
|
65
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('sdplang', 'en-US'))).toBe('a=sdplang:en-US');
|
|
66
|
+
});
|
|
67
|
+
it('should serialize lang attribute', () => {
|
|
68
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('lang', 'fr'))).toBe('a=lang:fr');
|
|
69
|
+
});
|
|
70
|
+
it('should serialize framerate attribute', () => {
|
|
71
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('framerate', '29.97'))).toBe('a=framerate:29.97');
|
|
72
|
+
});
|
|
73
|
+
it('should serialize quality attribute', () => {
|
|
74
|
+
expect((0, attribute_serializer_1.serializeAttributeField)((0, attributes_1.createValueAttribute)('quality', '8'))).toBe('a=quality:8');
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"field-serializer.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/serializer/field-serializer.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|