2 Parse list of available streams on Anevia servers.
3 The URI http://ipaddress/ws/Mgmt/* describes a list of
4 available streams on the server.
6 Copyright © 2009 M2X BV
8 Authors: Jean-Paul Saman <jpsaman@videolan.org>
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License along
21 with this program; if not, write to the Free Software Foundation, Inc.,
22 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
27 return vlc.access == "http"
28 and string.match( vlc.path, "/ws/Mgmt/" )
31 -- Fake readline. Read <>(..*)</> whole, otherwise pretend a newline.
32 -- In lua, indices are from 1, not 0, so no +1 needed.
34 local n = string.find(vlc.peek(998),"><") -- A random large number
35 return n and vlc.read(n) or vlc.readline()
42 _,_,server = string.find( vlc.path, "(.*)/ws/Mgmt/" )
45 if not line then break end
46 if string.match( line, "<struct name=\"stream\">" ) then
49 if not line then break end
50 if string.match( line, "<field name=\"name\">" ) then
51 _,_,name = string.find( line, "name=\"name\">(.*)</field>" )
53 if string.match( line, "<choice name=\"destination\">" ) then
56 if not line then break end
57 if string.match( line, "<struct name=\"(.*)\">" ) then
58 _,_,protocol = string.find( line, "<struct name=\"(.*)\">" )
61 if not line then break end
62 if string.match( line, "<field name=\"address\">(.*)</field>" ) then
63 _,_,address = string.find( line, "<field name=\"address\">(.*)</field>" )
65 if string.match( line, "<field name=\"port\">(.*)</field>" ) then
66 _,_,port = string.find( line, "<field name=\"port\">(.*)</field>" )
69 if string.match( line, "</struct>" ) then
70 media = tostring(protocol) .. "://@" .. tostring(address) .. ":" .. tostring(port)
71 table.insert( p, { path = media; name = name, url = media } )
76 if not line then break end
78 if string.match( line, "</choice>" ) then break end