win32: inhibit: Ensure we restore the state when cancelled
[vlc.git] / share / lua / playlist / anevia_streams.lua
blob93db6bbe38818d9a969b66742cc4e91514307a5d
1 --[[
2 $Id$
4 Parse list of available streams on Anevia Toucan servers.
5 The URI http://ipaddress:554/list_streams.idp describes a list of
6 available streams on the server.
8 Copyright © 2009 M2X BV
10 Authors: Jean-Paul Saman <jpsaman@videolan.org>
12 This program is free software; you can redistribute it and/or modify
13 it under the terms of the GNU General Public License as published by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 --]]
27 -- Probe function.
28 function probe()
29 return vlc.access == "http"
30 and string.match( vlc.path, "/list_streams%.idp" )
31 end
33 -- Parse function.
34 function parse()
35 p = {}
36 _,_,server = string.find( vlc.path, "(.*)/list_streams.idp" )
37 while true do
38 line = vlc.readline()
39 if not line then break end
41 if string.match( line, "<streams[-]list> </stream[-]list>" ) then
42 break
43 elseif string.match( line, "<streams[-]list xmlns=\"(.*)\">" ) then
44 while true do
45 line = vlc.readline()
46 if not line then break end
47 if string.match( line, "<streamer name=\"(.*)\"> </streamer>" ) then
48 break;
49 elseif string.match( line, "<streamer name=\"(.*)\">" ) then
50 _,_,streamer = string.find( line, "name=\"(.*)\"" )
51 while true do
52 line = vlc.readline()
53 if not line then break end
54 -- ignore <host name=".." /> tags
55 -- ignore <port number=".." /> tags
56 if string.match( line, "<input name=\"(.*)\">" ) then
57 _,_,path = string.find( line, "name=\"(.*)\"" )
58 while true do
59 line = vlc.readline()
60 if not line then break end
61 if string.match( line, "<stream id=\"(.*)\" />" ) then
62 _,_,media = string.find( line, "id=\"(.*)\"" )
63 video = "rtsp://" .. tostring(server) .. "/" .. tostring(path) .. "/" .. tostring(media)
64 vlc.msg.dbg( "adding to playlist " .. tostring(video) )
65 table.insert( p, { path = video; name = media, url = video } )
66 end
67 -- end of input tag found
68 if string.match( line, "</input>" ) then
69 break
70 end
71 end
72 end
73 end
74 if not line then break end
75 -- end of streamer tag found
76 if string.match( line, "</streamer>" ) then
77 break
78 end
79 end
80 if not line then break end
81 -- end of streams-list tag found
82 if string.match( line, "</streams-list>" ) then
83 break
84 end
85 end
86 end
88 end
89 return p
90 end