File: rtsp.lua

package info (click to toggle)
lua-uri 0.1%2B20130926%2Bgit14fa255d-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, jessie, jessie-kfreebsd, stretch
  • size: 408 kB
  • ctags: 332
  • sloc: makefile: 53
file content (44 lines) | stat: -rw-r--r-- 1,483 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
require "uri-test"
local URI = require "uri"

module("test.rtsp", lunit.testcase, package.seeall)

function test_rtsp ()
    local u = assert(URI:new("RTSP://MEDIA.EXAMPLE.COM:554/twister/audiotrack"))
    is("rtsp://media.example.com/twister/audiotrack", tostring(u))
    is("media.example.com", u:host())
    is("/twister/audiotrack", u:path())
end

function test_rtspu ()
    local uri = assert(URI:new("rtspu://media.perl.com/f%C3%B4o.smi/"))
    is("rtspu://media.perl.com/f%C3%B4o.smi/", tostring(uri))
    is("media.perl.com", uri:host())
    is("/f%C3%B4o.smi/", uri:path())
end

function test_switch_scheme ()
    -- Should be no problem switching between TCP and UDP URIs, because they
    -- have the same syntax.
    local uri = assert(URI:new("rtsp://media.example.com/twister/audiotrack"))
    is("rtsp://media.example.com/twister/audiotrack", tostring(uri))
    is("rtsp", uri:scheme("rtspu"))
    is("rtspu://media.example.com/twister/audiotrack", tostring(uri))
    is("rtspu", uri:scheme("rtsp"))
    is("rtsp://media.example.com/twister/audiotrack", tostring(uri))
    is("rtsp", uri:scheme())
end

function test_rtsp_default_port ()
    local uri = assert(URI:new("rtsp://host/path/"))
    is(554, uri:port())
    uri = assert(URI:new("rtspu://host/path/"))
    is(554, uri:port())

    is(554, uri:port(8554))
    is("rtspu://host:8554/path/", tostring(uri))
    is(8554, uri:port(554))
    is("rtspu://host/path/", tostring(uri))
end

-- vi:ts=4 sw=4 expandtab