@@ -174,38 +174,38 @@ func TestServerPlayPath(t *testing.T) {
174
174
path string
175
175
}{
176
176
{
177
- "normal " ,
177
+ "standard " ,
178
178
"rtsp://localhost:8554/teststream[control]" ,
179
179
"rtsp://localhost:8554/teststream/" ,
180
180
"/teststream" ,
181
181
},
182
182
{
183
- "with query, ffmpeg format" ,
183
+ "no query, ffmpeg format" ,
184
184
"rtsp://localhost:8554/teststream?testing=123[control]" ,
185
185
"rtsp://localhost:8554/teststream/" ,
186
186
"/teststream" ,
187
187
},
188
188
{
189
- "with query, gstreamer format" ,
189
+ "no query, gstreamer format" ,
190
190
"rtsp://localhost:8554/teststream[control]?testing=123" ,
191
191
"rtsp://localhost:8554/teststream/" ,
192
192
"/teststream" ,
193
193
},
194
194
{
195
195
// this is needed to support reading mpegts with ffmpeg
196
- "without media id " ,
196
+ "no control " ,
197
197
"rtsp://localhost:8554/teststream/" ,
198
198
"rtsp://localhost:8554/teststream/" ,
199
199
"/teststream" ,
200
200
},
201
201
{
202
- "without media id , query, ffmpeg" ,
202
+ "no control , query, ffmpeg" ,
203
203
"rtsp://localhost:8554/teststream?testing=123/" ,
204
204
"rtsp://localhost:8554/teststream/" ,
205
205
"/teststream" ,
206
206
},
207
207
{
208
- "without media id , query, gstreamer" ,
208
+ "no control , query, gstreamer" ,
209
209
"rtsp://localhost:8554/teststream/?testing=123" ,
210
210
"rtsp://localhost:8554/teststream/" ,
211
211
"/teststream" ,
@@ -217,7 +217,7 @@ func TestServerPlayPath(t *testing.T) {
217
217
"/test/stream" ,
218
218
},
219
219
{
220
- "subpath without media id " ,
220
+ "subpath, no control " ,
221
221
"rtsp://localhost:8554/test/stream/" ,
222
222
"rtsp://localhost:8554/test/stream/" ,
223
223
"/test/stream" ,
@@ -235,7 +235,7 @@ func TestServerPlayPath(t *testing.T) {
235
235
"/test/stream" ,
236
236
},
237
237
{
238
- "no slash" ,
238
+ "no path, no slash" ,
239
239
"rtsp://localhost:8554[control]" ,
240
240
"rtsp://localhost:8554" ,
241
241
"" ,
@@ -246,6 +246,18 @@ func TestServerPlayPath(t *testing.T) {
246
246
"rtsp://localhost:8554//" ,
247
247
"/" ,
248
248
},
249
+ {
250
+ "no control, no path" ,
251
+ "rtsp://localhost:8554/" ,
252
+ "rtsp://localhost:8554/" ,
253
+ "/" ,
254
+ },
255
+ {
256
+ "no control, no path, no slash" ,
257
+ "rtsp://localhost:8554" ,
258
+ "rtsp://localhost:8554" ,
259
+ "" ,
260
+ },
249
261
} {
250
262
t .Run (ca .name , func (t * testing.T ) {
251
263
var stream * ServerStream
@@ -316,9 +328,10 @@ func TestServerPlayPath(t *testing.T) {
316
328
317
329
func TestServerPlaySetupErrors (t * testing.T ) {
318
330
for _ , ca := range []string {
331
+ "invalid path" ,
332
+ "closed stream" ,
319
333
"different paths" ,
320
334
"double setup" ,
321
- "closed stream" ,
322
335
"different protocols" ,
323
336
} {
324
337
t .Run (ca , func (t * testing.T ) {
@@ -329,15 +342,19 @@ func TestServerPlaySetupErrors(t *testing.T) {
329
342
Handler : & testServerHandler {
330
343
onConnClose : func (ctx * ServerHandlerOnConnCloseCtx ) {
331
344
switch ca {
345
+ case "invalid path" :
346
+ require .EqualError (t , ctx .Error , "invalid SETUP path. " +
347
+ "This typically happens when VLC fails a request, and then switches to an unsupported RTSP dialect" )
348
+
349
+ case "closed stream" :
350
+ require .EqualError (t , ctx .Error , "stream is closed" )
351
+
332
352
case "different paths" :
333
353
require .EqualError (t , ctx .Error , "can't setup medias with different paths" )
334
354
335
355
case "double setup" :
336
356
require .EqualError (t , ctx .Error , "media has already been setup" )
337
357
338
- case "closed stream" :
339
- require .EqualError (t , ctx .Error , "stream is closed" )
340
-
341
358
case "different protocols" :
342
359
require .EqualError (t , ctx .Error , "can't setup medias with different protocols" )
343
360
}
@@ -375,30 +392,64 @@ func TestServerPlaySetupErrors(t *testing.T) {
375
392
defer nconn .Close ()
376
393
conn := conn .NewConn (nconn )
377
394
378
- desc := doDescribe (t , conn )
395
+ var desc * description.Session
396
+ var th * headers.Transport
397
+ var res * base.Response
379
398
380
- th := & headers.Transport {
381
- Protocol : headers .TransportProtocolUDP ,
382
- Delivery : deliveryPtr (headers .TransportDeliveryUnicast ),
383
- Mode : transportModePtr (headers .TransportModePlay ),
384
- ClientPorts : & [2 ]int {35466 , 35467 },
385
- }
399
+ switch ca {
400
+ case "invalid path" :
401
+ th = & headers.Transport {
402
+ Protocol : headers .TransportProtocolUDP ,
403
+ Delivery : deliveryPtr (headers .TransportDeliveryUnicast ),
404
+ Mode : transportModePtr (headers .TransportModePlay ),
405
+ ClientPorts : & [2 ]int {35466 , 35467 },
406
+ }
386
407
387
- res , err := writeReqReadRes (conn , base.Request {
388
- Method : base .Setup ,
389
- URL : mediaURL (t , desc .BaseURL , desc .Medias [0 ]),
390
- Header : base.Header {
391
- "CSeq" : base.HeaderValue {"2" },
392
- "Transport" : th .Marshal (),
393
- },
394
- })
408
+ res , err = writeReqReadRes (conn , base.Request {
409
+ Method : base .Setup ,
410
+ URL : & base.URL {
411
+ Scheme : "rtsp" ,
412
+ Path : "/invalid" ,
413
+ },
414
+ Header : base.Header {
415
+ "CSeq" : base.HeaderValue {"2" },
416
+ "Transport" : th .Marshal (),
417
+ },
418
+ })
395
419
396
- if ca != "closed stream" {
397
420
require .NoError (t , err )
398
- require .Equal (t , base .StatusOK , res .StatusCode )
421
+ require .Equal (t , base .StatusBadRequest , res .StatusCode )
422
+
423
+ default :
424
+ desc = doDescribe (t , conn )
425
+
426
+ th = & headers.Transport {
427
+ Protocol : headers .TransportProtocolUDP ,
428
+ Delivery : deliveryPtr (headers .TransportDeliveryUnicast ),
429
+ Mode : transportModePtr (headers .TransportModePlay ),
430
+ ClientPorts : & [2 ]int {35466 , 35467 },
431
+ }
432
+
433
+ res , err = writeReqReadRes (conn , base.Request {
434
+ Method : base .Setup ,
435
+ URL : mediaURL (t , desc .BaseURL , desc .Medias [0 ]),
436
+ Header : base.Header {
437
+ "CSeq" : base.HeaderValue {"2" },
438
+ "Transport" : th .Marshal (),
439
+ },
440
+ })
441
+
442
+ if ca != "closed stream" {
443
+ require .NoError (t , err )
444
+ require .Equal (t , base .StatusOK , res .StatusCode )
445
+ }
399
446
}
400
447
401
448
switch ca {
449
+ case "closed stream" :
450
+ require .NoError (t , err )
451
+ require .Equal (t , base .StatusBadRequest , res .StatusCode )
452
+
402
453
case "different paths" :
403
454
session := readSession (t , res )
404
455
@@ -433,10 +484,6 @@ func TestServerPlaySetupErrors(t *testing.T) {
433
484
require .NoError (t , err )
434
485
require .Equal (t , base .StatusBadRequest , res .StatusCode )
435
486
436
- case "closed stream" :
437
- require .NoError (t , err )
438
- require .Equal (t , base .StatusBadRequest , res .StatusCode )
439
-
440
487
case "different protocols" :
441
488
session := readSession (t , res )
442
489
0 commit comments