@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.
Files changed (171) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +124 -0
  3. package/dist/src/builder/media-builder.d.ts +221 -0
  4. package/dist/src/builder/media-builder.d.ts.map +1 -0
  5. package/dist/src/builder/media-builder.js +385 -0
  6. package/dist/src/builder/session-builder.d.ts +195 -0
  7. package/dist/src/builder/session-builder.d.ts.map +1 -0
  8. package/dist/src/builder/session-builder.js +366 -0
  9. package/dist/src/index.d.ts +67 -0
  10. package/dist/src/index.d.ts.map +1 -0
  11. package/dist/src/index.js +250 -0
  12. package/dist/src/parser/attribute-parser.d.ts +100 -0
  13. package/dist/src/parser/attribute-parser.d.ts.map +1 -0
  14. package/dist/src/parser/attribute-parser.js +217 -0
  15. package/dist/src/parser/field-parser.d.ts +124 -0
  16. package/dist/src/parser/field-parser.d.ts.map +1 -0
  17. package/dist/src/parser/field-parser.js +335 -0
  18. package/dist/src/parser/media-parser.d.ts +45 -0
  19. package/dist/src/parser/media-parser.d.ts.map +1 -0
  20. package/dist/src/parser/media-parser.js +157 -0
  21. package/dist/src/parser/primitive-parser.d.ts +138 -0
  22. package/dist/src/parser/primitive-parser.d.ts.map +1 -0
  23. package/dist/src/parser/primitive-parser.js +316 -0
  24. package/dist/src/parser/scanner.d.ts +142 -0
  25. package/dist/src/parser/scanner.d.ts.map +1 -0
  26. package/dist/src/parser/scanner.js +284 -0
  27. package/dist/src/parser/session-parser.d.ts +35 -0
  28. package/dist/src/parser/session-parser.d.ts.map +1 -0
  29. package/dist/src/parser/session-parser.js +207 -0
  30. package/dist/src/parser/time-parser.d.ts +74 -0
  31. package/dist/src/parser/time-parser.d.ts.map +1 -0
  32. package/dist/src/parser/time-parser.js +168 -0
  33. package/dist/src/serializer/attribute-serializer.d.ts +18 -0
  34. package/dist/src/serializer/attribute-serializer.d.ts.map +1 -0
  35. package/dist/src/serializer/attribute-serializer.js +34 -0
  36. package/dist/src/serializer/field-serializer.d.ts +112 -0
  37. package/dist/src/serializer/field-serializer.d.ts.map +1 -0
  38. package/dist/src/serializer/field-serializer.js +212 -0
  39. package/dist/src/serializer/media-serializer.d.ts +31 -0
  40. package/dist/src/serializer/media-serializer.d.ts.map +1 -0
  41. package/dist/src/serializer/media-serializer.js +83 -0
  42. package/dist/src/serializer/session-serializer.d.ts +29 -0
  43. package/dist/src/serializer/session-serializer.d.ts.map +1 -0
  44. package/dist/src/serializer/session-serializer.js +99 -0
  45. package/dist/src/serializer/time-serializer.d.ts +46 -0
  46. package/dist/src/serializer/time-serializer.d.ts.map +1 -0
  47. package/dist/src/serializer/time-serializer.js +86 -0
  48. package/dist/src/types/attributes.d.ts +318 -0
  49. package/dist/src/types/attributes.d.ts.map +1 -0
  50. package/dist/src/types/attributes.js +225 -0
  51. package/dist/src/types/errors.d.ts +129 -0
  52. package/dist/src/types/errors.d.ts.map +1 -0
  53. package/dist/src/types/errors.js +186 -0
  54. package/dist/src/types/fields.d.ts +100 -0
  55. package/dist/src/types/fields.d.ts.map +1 -0
  56. package/dist/src/types/fields.js +48 -0
  57. package/dist/src/types/media.d.ts +148 -0
  58. package/dist/src/types/media.d.ts.map +1 -0
  59. package/dist/src/types/media.js +137 -0
  60. package/dist/src/types/network.d.ts +136 -0
  61. package/dist/src/types/network.d.ts.map +1 -0
  62. package/dist/src/types/network.js +130 -0
  63. package/dist/src/types/primitives.d.ts +193 -0
  64. package/dist/src/types/primitives.d.ts.map +1 -0
  65. package/dist/src/types/primitives.js +195 -0
  66. package/dist/src/types/session.d.ts +122 -0
  67. package/dist/src/types/session.d.ts.map +1 -0
  68. package/dist/src/types/session.js +81 -0
  69. package/dist/src/types/time.d.ts +129 -0
  70. package/dist/src/types/time.d.ts.map +1 -0
  71. package/dist/src/types/time.js +84 -0
  72. package/dist/src/utils/address-parser.d.ts +100 -0
  73. package/dist/src/utils/address-parser.d.ts.map +1 -0
  74. package/dist/src/utils/address-parser.js +338 -0
  75. package/dist/src/utils/format-validators.d.ts +77 -0
  76. package/dist/src/utils/format-validators.d.ts.map +1 -0
  77. package/dist/src/utils/format-validators.js +504 -0
  78. package/dist/src/utils/line-reader.d.ts +84 -0
  79. package/dist/src/utils/line-reader.d.ts.map +1 -0
  80. package/dist/src/utils/line-reader.js +169 -0
  81. package/dist/src/utils/time-converter.d.ts +99 -0
  82. package/dist/src/utils/time-converter.d.ts.map +1 -0
  83. package/dist/src/utils/time-converter.js +195 -0
  84. package/dist/src/validator/media-validator.d.ts +27 -0
  85. package/dist/src/validator/media-validator.d.ts.map +1 -0
  86. package/dist/src/validator/media-validator.js +241 -0
  87. package/dist/src/validator/semantic-validator.d.ts +47 -0
  88. package/dist/src/validator/semantic-validator.d.ts.map +1 -0
  89. package/dist/src/validator/semantic-validator.js +207 -0
  90. package/dist/src/validator/session-validator.d.ts +36 -0
  91. package/dist/src/validator/session-validator.d.ts.map +1 -0
  92. package/dist/src/validator/session-validator.js +280 -0
  93. package/dist/tests/integration/round-trip.test.d.ts +5 -0
  94. package/dist/tests/integration/round-trip.test.d.ts.map +1 -0
  95. package/dist/tests/integration/round-trip.test.js +320 -0
  96. package/dist/tests/integration/voip-examples.test.d.ts +5 -0
  97. package/dist/tests/integration/voip-examples.test.d.ts.map +1 -0
  98. package/dist/tests/integration/voip-examples.test.js +361 -0
  99. package/dist/tests/unit/builder/media-builder.test.d.ts +5 -0
  100. package/dist/tests/unit/builder/media-builder.test.d.ts.map +1 -0
  101. package/dist/tests/unit/builder/media-builder.test.js +524 -0
  102. package/dist/tests/unit/builder/session-builder.test.d.ts +5 -0
  103. package/dist/tests/unit/builder/session-builder.test.d.ts.map +1 -0
  104. package/dist/tests/unit/builder/session-builder.test.js +367 -0
  105. package/dist/tests/unit/parser/attribute-parser.test.d.ts +5 -0
  106. package/dist/tests/unit/parser/attribute-parser.test.d.ts.map +1 -0
  107. package/dist/tests/unit/parser/attribute-parser.test.js +319 -0
  108. package/dist/tests/unit/parser/field-parser.test.d.ts +5 -0
  109. package/dist/tests/unit/parser/field-parser.test.d.ts.map +1 -0
  110. package/dist/tests/unit/parser/field-parser.test.js +355 -0
  111. package/dist/tests/unit/parser/media-parser.test.d.ts +5 -0
  112. package/dist/tests/unit/parser/media-parser.test.d.ts.map +1 -0
  113. package/dist/tests/unit/parser/media-parser.test.js +241 -0
  114. package/dist/tests/unit/parser/primitive-parser.test.d.ts +5 -0
  115. package/dist/tests/unit/parser/primitive-parser.test.d.ts.map +1 -0
  116. package/dist/tests/unit/parser/primitive-parser.test.js +261 -0
  117. package/dist/tests/unit/parser/scanner.test.d.ts +5 -0
  118. package/dist/tests/unit/parser/scanner.test.d.ts.map +1 -0
  119. package/dist/tests/unit/parser/scanner.test.js +241 -0
  120. package/dist/tests/unit/parser/session-parser.test.d.ts +5 -0
  121. package/dist/tests/unit/parser/session-parser.test.d.ts.map +1 -0
  122. package/dist/tests/unit/parser/session-parser.test.js +346 -0
  123. package/dist/tests/unit/parser/time-parser.test.d.ts +5 -0
  124. package/dist/tests/unit/parser/time-parser.test.d.ts.map +1 -0
  125. package/dist/tests/unit/parser/time-parser.test.js +173 -0
  126. package/dist/tests/unit/serializer/attribute-serializer.test.d.ts +5 -0
  127. package/dist/tests/unit/serializer/attribute-serializer.test.d.ts.map +1 -0
  128. package/dist/tests/unit/serializer/attribute-serializer.test.js +78 -0
  129. package/dist/tests/unit/serializer/field-serializer.test.d.ts +5 -0
  130. package/dist/tests/unit/serializer/field-serializer.test.d.ts.map +1 -0
  131. package/dist/tests/unit/serializer/field-serializer.test.js +159 -0
  132. package/dist/tests/unit/serializer/media-serializer.test.d.ts +5 -0
  133. package/dist/tests/unit/serializer/media-serializer.test.d.ts.map +1 -0
  134. package/dist/tests/unit/serializer/media-serializer.test.js +155 -0
  135. package/dist/tests/unit/serializer/session-serializer.test.d.ts +5 -0
  136. package/dist/tests/unit/serializer/session-serializer.test.d.ts.map +1 -0
  137. package/dist/tests/unit/serializer/session-serializer.test.js +317 -0
  138. package/dist/tests/unit/serializer/time-serializer.test.d.ts +5 -0
  139. package/dist/tests/unit/serializer/time-serializer.test.d.ts.map +1 -0
  140. package/dist/tests/unit/serializer/time-serializer.test.js +115 -0
  141. package/dist/tests/unit/types/errors.test.d.ts +5 -0
  142. package/dist/tests/unit/types/errors.test.d.ts.map +1 -0
  143. package/dist/tests/unit/types/errors.test.js +127 -0
  144. package/dist/tests/unit/types/network.test.d.ts +5 -0
  145. package/dist/tests/unit/types/network.test.d.ts.map +1 -0
  146. package/dist/tests/unit/types/network.test.js +132 -0
  147. package/dist/tests/unit/types/primitives.test.d.ts +5 -0
  148. package/dist/tests/unit/types/primitives.test.d.ts.map +1 -0
  149. package/dist/tests/unit/types/primitives.test.js +108 -0
  150. package/dist/tests/unit/utils/address-parser.test.d.ts +5 -0
  151. package/dist/tests/unit/utils/address-parser.test.d.ts.map +1 -0
  152. package/dist/tests/unit/utils/address-parser.test.js +203 -0
  153. package/dist/tests/unit/utils/format-validators.test.d.ts +5 -0
  154. package/dist/tests/unit/utils/format-validators.test.d.ts.map +1 -0
  155. package/dist/tests/unit/utils/format-validators.test.js +224 -0
  156. package/dist/tests/unit/utils/line-reader.test.d.ts +5 -0
  157. package/dist/tests/unit/utils/line-reader.test.d.ts.map +1 -0
  158. package/dist/tests/unit/utils/line-reader.test.js +157 -0
  159. package/dist/tests/unit/utils/time-converter.test.d.ts +5 -0
  160. package/dist/tests/unit/utils/time-converter.test.d.ts.map +1 -0
  161. package/dist/tests/unit/utils/time-converter.test.js +190 -0
  162. package/dist/tests/unit/validator/media-validator.test.d.ts +5 -0
  163. package/dist/tests/unit/validator/media-validator.test.d.ts.map +1 -0
  164. package/dist/tests/unit/validator/media-validator.test.js +313 -0
  165. package/dist/tests/unit/validator/semantic-validator.test.d.ts +5 -0
  166. package/dist/tests/unit/validator/semantic-validator.test.d.ts.map +1 -0
  167. package/dist/tests/unit/validator/semantic-validator.test.js +262 -0
  168. package/dist/tests/unit/validator/session-validator.test.d.ts +5 -0
  169. package/dist/tests/unit/validator/session-validator.test.d.ts.map +1 -0
  170. package/dist/tests/unit/validator/session-validator.test.js +447 -0
  171. package/package.json +50 -0
@@ -0,0 +1,319 @@
1
+ "use strict";
2
+ /**
3
+ * Tests for attribute-parser.ts
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const scanner_1 = require("../../../src/parser/scanner");
7
+ const attribute_parser_1 = require("../../../src/parser/attribute-parser");
8
+ const errors_1 = require("../../../src/types/errors");
9
+ describe('attribute-parser', () => {
10
+ describe('parseAttributeField', () => {
11
+ describe('property attributes', () => {
12
+ it('should parse recvonly attribute', () => {
13
+ const scanner = new scanner_1.Scanner('recvonly');
14
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
15
+ expect(attr.kind).toBe('property');
16
+ expect(attr.name).toBe('recvonly');
17
+ });
18
+ it('should parse sendrecv attribute', () => {
19
+ const scanner = new scanner_1.Scanner('sendrecv');
20
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
21
+ expect(attr.kind).toBe('property');
22
+ expect(attr.name).toBe('sendrecv');
23
+ });
24
+ it('should parse sendonly attribute', () => {
25
+ const scanner = new scanner_1.Scanner('sendonly');
26
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
27
+ expect(attr.kind).toBe('property');
28
+ expect(attr.name).toBe('sendonly');
29
+ });
30
+ it('should parse inactive attribute', () => {
31
+ const scanner = new scanner_1.Scanner('inactive');
32
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
33
+ expect(attr.kind).toBe('property');
34
+ expect(attr.name).toBe('inactive');
35
+ });
36
+ it('should parse custom property attribute', () => {
37
+ const scanner = new scanner_1.Scanner('myattr');
38
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
39
+ expect(attr.kind).toBe('property');
40
+ expect(attr.name).toBe('myattr');
41
+ });
42
+ });
43
+ describe('value attributes', () => {
44
+ it('should parse rtpmap attribute', () => {
45
+ const scanner = new scanner_1.Scanner('rtpmap:0 PCMU/8000');
46
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
47
+ expect(attr.kind).toBe('value');
48
+ expect(attr.name).toBe('rtpmap');
49
+ expect(attr.value).toBe('0 PCMU/8000');
50
+ });
51
+ it('should parse fmtp attribute', () => {
52
+ const scanner = new scanner_1.Scanner('fmtp:96 profile-level-id=42e01f');
53
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
54
+ expect(attr.kind).toBe('value');
55
+ expect(attr.name).toBe('fmtp');
56
+ expect(attr.value).toBe('96 profile-level-id=42e01f');
57
+ });
58
+ it('should parse ptime attribute', () => {
59
+ const scanner = new scanner_1.Scanner('ptime:20');
60
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
61
+ expect(attr.kind).toBe('value');
62
+ expect(attr.name).toBe('ptime');
63
+ expect(attr.value).toBe('20');
64
+ });
65
+ it('should parse maxptime attribute', () => {
66
+ const scanner = new scanner_1.Scanner('maxptime:150');
67
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
68
+ expect(attr.kind).toBe('value');
69
+ expect(attr.name).toBe('maxptime');
70
+ expect(attr.value).toBe('150');
71
+ });
72
+ it('should parse cat attribute', () => {
73
+ const scanner = new scanner_1.Scanner('cat:conference');
74
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
75
+ expect(attr.kind).toBe('value');
76
+ expect(attr.name).toBe('cat');
77
+ expect(attr.value).toBe('conference');
78
+ });
79
+ it('should parse keywds attribute', () => {
80
+ const scanner = new scanner_1.Scanner('keywds:audio,video,meeting');
81
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
82
+ expect(attr.kind).toBe('value');
83
+ expect(attr.name).toBe('keywds');
84
+ expect(attr.value).toBe('audio,video,meeting');
85
+ });
86
+ it('should parse tool attribute', () => {
87
+ const scanner = new scanner_1.Scanner('tool:my-sdp-tool v1.0');
88
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
89
+ expect(attr.kind).toBe('value');
90
+ expect(attr.name).toBe('tool');
91
+ expect(attr.value).toBe('my-sdp-tool v1.0');
92
+ });
93
+ it('should parse orient attribute', () => {
94
+ const scanner = new scanner_1.Scanner('orient:landscape');
95
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
96
+ expect(attr.kind).toBe('value');
97
+ expect(attr.name).toBe('orient');
98
+ expect(attr.value).toBe('landscape');
99
+ });
100
+ it('should parse type attribute', () => {
101
+ const scanner = new scanner_1.Scanner('type:broadcast');
102
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
103
+ expect(attr.kind).toBe('value');
104
+ expect(attr.name).toBe('type');
105
+ expect(attr.value).toBe('broadcast');
106
+ });
107
+ it('should parse charset attribute', () => {
108
+ const scanner = new scanner_1.Scanner('charset:UTF-8');
109
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
110
+ expect(attr.kind).toBe('value');
111
+ expect(attr.name).toBe('charset');
112
+ expect(attr.value).toBe('UTF-8');
113
+ });
114
+ it('should parse sdplang attribute', () => {
115
+ const scanner = new scanner_1.Scanner('sdplang:en-US');
116
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
117
+ expect(attr.kind).toBe('value');
118
+ expect(attr.name).toBe('sdplang');
119
+ expect(attr.value).toBe('en-US');
120
+ });
121
+ it('should parse lang attribute', () => {
122
+ const scanner = new scanner_1.Scanner('lang:fr');
123
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
124
+ expect(attr.kind).toBe('value');
125
+ expect(attr.name).toBe('lang');
126
+ expect(attr.value).toBe('fr');
127
+ });
128
+ it('should parse framerate attribute', () => {
129
+ const scanner = new scanner_1.Scanner('framerate:29.97');
130
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
131
+ expect(attr.kind).toBe('value');
132
+ expect(attr.name).toBe('framerate');
133
+ expect(attr.value).toBe('29.97');
134
+ });
135
+ it('should parse quality attribute', () => {
136
+ const scanner = new scanner_1.Scanner('quality:8');
137
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
138
+ expect(attr.kind).toBe('value');
139
+ expect(attr.name).toBe('quality');
140
+ expect(attr.value).toBe('8');
141
+ });
142
+ it('should parse custom value attribute', () => {
143
+ const scanner = new scanner_1.Scanner('customattr:customvalue');
144
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
145
+ expect(attr.kind).toBe('value');
146
+ expect(attr.name).toBe('customattr');
147
+ expect(attr.value).toBe('customvalue');
148
+ });
149
+ it('should parse value with colons', () => {
150
+ const scanner = new scanner_1.Scanner('candidate:1 1 UDP 2130706431 192.168.1.1 8998 typ host');
151
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
152
+ expect(attr.kind).toBe('value');
153
+ expect(attr.name).toBe('candidate');
154
+ expect(attr.value).toBe('1 1 UDP 2130706431 192.168.1.1 8998 typ host');
155
+ });
156
+ it('should stop at newline', () => {
157
+ const scanner = new scanner_1.Scanner('rtpmap:0 PCMU/8000\r\n');
158
+ const attr = (0, attribute_parser_1.parseAttributeField)(scanner);
159
+ expect(attr.value).toBe('0 PCMU/8000');
160
+ });
161
+ });
162
+ });
163
+ describe('parseRtpmapValue', () => {
164
+ it('should parse basic rtpmap', () => {
165
+ const rtpmap = (0, attribute_parser_1.parseRtpmapValue)('0 PCMU/8000');
166
+ expect(rtpmap.payloadType).toBe(0);
167
+ expect(rtpmap.encodingName).toBe('PCMU');
168
+ expect(rtpmap.clockRate).toBe(8000);
169
+ expect(rtpmap.encodingParams).toBeUndefined();
170
+ });
171
+ it('should parse rtpmap with encoding params', () => {
172
+ const rtpmap = (0, attribute_parser_1.parseRtpmapValue)('97 L16/8000/2');
173
+ expect(rtpmap.payloadType).toBe(97);
174
+ expect(rtpmap.encodingName).toBe('L16');
175
+ expect(rtpmap.clockRate).toBe(8000);
176
+ expect(rtpmap.encodingParams).toBe(2);
177
+ });
178
+ it('should parse video rtpmap', () => {
179
+ const rtpmap = (0, attribute_parser_1.parseRtpmapValue)('96 H264/90000');
180
+ expect(rtpmap.payloadType).toBe(96);
181
+ expect(rtpmap.encodingName).toBe('H264');
182
+ expect(rtpmap.clockRate).toBe(90000);
183
+ });
184
+ it('should parse PCMA rtpmap', () => {
185
+ const rtpmap = (0, attribute_parser_1.parseRtpmapValue)('8 PCMA/8000');
186
+ expect(rtpmap.payloadType).toBe(8);
187
+ expect(rtpmap.encodingName).toBe('PCMA');
188
+ expect(rtpmap.clockRate).toBe(8000);
189
+ });
190
+ it('should parse telephone-event rtpmap', () => {
191
+ const rtpmap = (0, attribute_parser_1.parseRtpmapValue)('101 telephone-event/8000');
192
+ expect(rtpmap.payloadType).toBe(101);
193
+ expect(rtpmap.encodingName).toBe('telephone-event');
194
+ expect(rtpmap.clockRate).toBe(8000);
195
+ });
196
+ it('should throw for invalid payload type', () => {
197
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('abc PCMU/8000')).toThrow(errors_1.ParseError);
198
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('abc PCMU/8000')).toThrow('Invalid payload type');
199
+ });
200
+ it('should throw for payload type out of range', () => {
201
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('128 PCMU/8000')).toThrow(errors_1.ParseError);
202
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('-1 PCMU/8000')).toThrow(errors_1.ParseError);
203
+ });
204
+ it('should throw for missing encoding spec', () => {
205
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96')).toThrow(errors_1.ParseError);
206
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96')).toThrow('Invalid rtpmap format');
207
+ });
208
+ it('should throw for invalid encoding spec', () => {
209
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96 H264')).toThrow(errors_1.ParseError);
210
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96 H264')).toThrow('Invalid encoding spec');
211
+ });
212
+ it('should throw for invalid clock rate', () => {
213
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96 H264/abc')).toThrow(errors_1.ParseError);
214
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('96 H264/0')).toThrow('Invalid clock rate');
215
+ });
216
+ it('should throw for invalid encoding params', () => {
217
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('97 L16/8000/abc')).toThrow(errors_1.ParseError);
218
+ expect(() => (0, attribute_parser_1.parseRtpmapValue)('97 L16/8000/0')).toThrow('Invalid encoding parameters');
219
+ });
220
+ });
221
+ describe('parseFmtpValue', () => {
222
+ it('should parse fmtp with profile', () => {
223
+ const fmtp = (0, attribute_parser_1.parseFmtpValue)('96 profile-level-id=42e01f');
224
+ expect(fmtp.format).toBe('96');
225
+ expect(fmtp.parameters).toBe('profile-level-id=42e01f');
226
+ });
227
+ it('should parse fmtp with multiple parameters', () => {
228
+ const fmtp = (0, attribute_parser_1.parseFmtpValue)('96 profile-level-id=42e01f;packetization-mode=1');
229
+ expect(fmtp.format).toBe('96');
230
+ expect(fmtp.parameters).toBe('profile-level-id=42e01f;packetization-mode=1');
231
+ });
232
+ it('should parse fmtp with apt', () => {
233
+ const fmtp = (0, attribute_parser_1.parseFmtpValue)('97 apt=96');
234
+ expect(fmtp.format).toBe('97');
235
+ expect(fmtp.parameters).toBe('apt=96');
236
+ });
237
+ it('should parse telephone-event fmtp', () => {
238
+ const fmtp = (0, attribute_parser_1.parseFmtpValue)('101 0-15');
239
+ expect(fmtp.format).toBe('101');
240
+ expect(fmtp.parameters).toBe('0-15');
241
+ });
242
+ it('should throw for missing parameters', () => {
243
+ expect(() => (0, attribute_parser_1.parseFmtpValue)('96')).toThrow(errors_1.ParseError);
244
+ expect(() => (0, attribute_parser_1.parseFmtpValue)('96')).toThrow('Invalid fmtp format');
245
+ });
246
+ it('should throw for empty parameters', () => {
247
+ expect(() => (0, attribute_parser_1.parseFmtpValue)('96 ')).toThrow(errors_1.ParseError);
248
+ expect(() => (0, attribute_parser_1.parseFmtpValue)('96 ')).toThrow('parameters cannot be empty');
249
+ });
250
+ });
251
+ describe('parsePtimeValue', () => {
252
+ it('should parse valid integer ptime', () => {
253
+ expect((0, attribute_parser_1.parsePtimeValue)('20')).toBe(20);
254
+ expect((0, attribute_parser_1.parsePtimeValue)('30')).toBe(30);
255
+ expect((0, attribute_parser_1.parsePtimeValue)('60')).toBe(60);
256
+ });
257
+ it('should parse valid decimal ptime (RFC 8866 non-zero-int-or-real)', () => {
258
+ expect((0, attribute_parser_1.parsePtimeValue)('20.5')).toBeCloseTo(20.5, 2);
259
+ expect((0, attribute_parser_1.parsePtimeValue)('30.0')).toBeCloseTo(30.0, 2);
260
+ expect((0, attribute_parser_1.parsePtimeValue)('0.5')).toBeCloseTo(0.5, 2);
261
+ expect((0, attribute_parser_1.parsePtimeValue)('100.125')).toBeCloseTo(100.125, 3);
262
+ });
263
+ it('should throw for invalid ptime', () => {
264
+ expect(() => (0, attribute_parser_1.parsePtimeValue)('abc')).toThrow(errors_1.ParseError);
265
+ expect(() => (0, attribute_parser_1.parsePtimeValue)('0')).toThrow('must be positive');
266
+ expect(() => (0, attribute_parser_1.parsePtimeValue)('-10')).toThrow('must be positive');
267
+ expect(() => (0, attribute_parser_1.parsePtimeValue)('-0.5')).toThrow('must be positive');
268
+ });
269
+ });
270
+ describe('parseMaxptimeValue', () => {
271
+ it('should parse valid integer maxptime', () => {
272
+ expect((0, attribute_parser_1.parseMaxptimeValue)('150')).toBe(150);
273
+ expect((0, attribute_parser_1.parseMaxptimeValue)('200')).toBe(200);
274
+ });
275
+ it('should parse valid decimal maxptime (RFC 8866 non-zero-int-or-real)', () => {
276
+ expect((0, attribute_parser_1.parseMaxptimeValue)('150.5')).toBeCloseTo(150.5, 2);
277
+ expect((0, attribute_parser_1.parseMaxptimeValue)('200.0')).toBeCloseTo(200.0, 2);
278
+ expect((0, attribute_parser_1.parseMaxptimeValue)('0.5')).toBeCloseTo(0.5, 2);
279
+ expect((0, attribute_parser_1.parseMaxptimeValue)('100.125')).toBeCloseTo(100.125, 3);
280
+ });
281
+ it('should throw for invalid maxptime', () => {
282
+ expect(() => (0, attribute_parser_1.parseMaxptimeValue)('abc')).toThrow(errors_1.ParseError);
283
+ expect(() => (0, attribute_parser_1.parseMaxptimeValue)('0')).toThrow('must be positive');
284
+ expect(() => (0, attribute_parser_1.parseMaxptimeValue)('-10')).toThrow('must be positive');
285
+ expect(() => (0, attribute_parser_1.parseMaxptimeValue)('-0.5')).toThrow('must be positive');
286
+ });
287
+ });
288
+ describe('parseFramerateValue', () => {
289
+ it('should parse integer framerate', () => {
290
+ expect((0, attribute_parser_1.parseFramerateValue)('30')).toBe(30);
291
+ expect((0, attribute_parser_1.parseFramerateValue)('60')).toBe(60);
292
+ });
293
+ it('should parse decimal framerate', () => {
294
+ expect((0, attribute_parser_1.parseFramerateValue)('29.97')).toBeCloseTo(29.97, 2);
295
+ expect((0, attribute_parser_1.parseFramerateValue)('23.976')).toBeCloseTo(23.976, 3);
296
+ });
297
+ it('should throw for invalid framerate', () => {
298
+ expect(() => (0, attribute_parser_1.parseFramerateValue)('abc')).toThrow(errors_1.ParseError);
299
+ expect(() => (0, attribute_parser_1.parseFramerateValue)('0')).toThrow('must be positive');
300
+ expect(() => (0, attribute_parser_1.parseFramerateValue)('-30')).toThrow('must be positive');
301
+ });
302
+ });
303
+ describe('parseQualityValue', () => {
304
+ it('should parse valid quality values', () => {
305
+ expect((0, attribute_parser_1.parseQualityValue)('0')).toBe(0);
306
+ expect((0, attribute_parser_1.parseQualityValue)('5')).toBe(5);
307
+ expect((0, attribute_parser_1.parseQualityValue)('10')).toBe(10);
308
+ });
309
+ it('should throw for quality out of range', () => {
310
+ expect(() => (0, attribute_parser_1.parseQualityValue)('-1')).toThrow(errors_1.ParseError);
311
+ expect(() => (0, attribute_parser_1.parseQualityValue)('-1')).toThrow('must be 0-10');
312
+ expect(() => (0, attribute_parser_1.parseQualityValue)('11')).toThrow(errors_1.ParseError);
313
+ expect(() => (0, attribute_parser_1.parseQualityValue)('11')).toThrow('must be 0-10');
314
+ });
315
+ it('should throw for invalid quality', () => {
316
+ expect(() => (0, attribute_parser_1.parseQualityValue)('abc')).toThrow(errors_1.ParseError);
317
+ });
318
+ });
319
+ });
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tests for field-parser.ts
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=field-parser.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"field-parser.test.d.ts","sourceRoot":"","sources":["../../../../tests/unit/parser/field-parser.test.ts"],"names":[],"mappings":"AAAA;;GAEG"}