]> git.sesse.net Git - vlc/blob - modules/services_discovery/upnp.hpp
avcodec: unused variable
[vlc] / modules / services_discovery / upnp.hpp
1 /*****************************************************************************
2  * upnp.hpp :  UPnP discovery module (libupnp) header
3  *****************************************************************************
4  * Copyright (C) 2004-2010 the VideoLAN team
5  * $Id$
6  *
7  * Authors: RĂ©mi Denis-Courmont <rem # videolan.org> (original plugin)
8  *          Christian Henz <henz # c-lab.de>
9  *          Mirsal Ennaime <mirsal dot ennaime at gmail dot com>
10  *
11  * UPnP Plugin using the Intel SDK (libupnp) instead of CyberLink
12  *
13  * This program is free software; you can redistribute it and/or modify
14  * it under the terms of the GNU General Public License as published by
15  * the Free Software Foundation; either version 2 of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
26  *****************************************************************************/
27
28 #include <vector>
29 #include <string>
30
31 #include <upnp/upnp.h>
32 #include <upnp/upnptools.h>
33
34 #include <vlc_common.h>
35
36 // Classes
37 class Container;
38
39 class MediaServer
40 {
41 public:
42
43     static void parseDeviceDescription( IXML_Document* p_doc,
44                                         const char*    psz_location,
45                                         services_discovery_t* p_sd );
46
47     MediaServer( const char* psz_udn,
48                  const char* psz_friendly_name,
49                  services_discovery_t* p_sd );
50
51     ~MediaServer();
52
53     const char* getUDN() const;
54     const char* getFriendlyName() const;
55
56     void setContentDirectoryEventURL( const char* psz_url );
57     const char* getContentDirectoryEventURL() const;
58
59     void setContentDirectoryControlURL( const char* psz_url );
60     const char* getContentDirectoryControlURL() const;
61
62     void subscribeToContentDirectory();
63     void fetchContents();
64
65     void setInputItem( input_item_t* p_input_item );
66     input_item_t* getInputItem() const;
67
68     bool compareSID( const char* psz_sid );
69
70 private:
71
72     bool _fetchContents( Container* p_parent, int i_starting_index );
73     void _buildPlaylist( Container* p_container, input_item_node_t *p_item_node );
74
75     IXML_Document* _browseAction( const char*, const char*,
76             const char*, const char*, const char*, const char* );
77
78     services_discovery_t* _p_sd;
79
80     Container* _p_contents;
81     input_item_t* _p_input_item;
82
83     std::string _UDN;
84     std::string _friendly_name;
85
86     std::string _content_directory_event_url;
87     std::string _content_directory_control_url;
88
89     int _i_subscription_timeout;
90     int _i_content_directory_service_version;
91     Upnp_SID _subscription_id;
92 };
93
94
95 class MediaServerList
96 {
97 public:
98
99     MediaServerList( services_discovery_t* p_sd );
100     ~MediaServerList();
101
102     bool addServer( MediaServer* p_server );
103     void removeServer( const char* psz_udn );
104
105     MediaServer* getServer( const char* psz_udn );
106     MediaServer* getServerBySID( const char* psz_sid );
107
108 private:
109
110     services_discovery_t* _p_sd;
111
112     std::vector<MediaServer*> _list;
113 };
114
115
116 class Item
117 {
118 public:
119
120     Item( Container*  parent,
121           const char* objectID,
122           const char* title,
123           const char* subtitles,
124           const char* resource,
125           mtime_t duration );
126     ~Item();
127
128     const char* getObjectID() const;
129     const char* getTitle() const;
130     const char* getResource() const;
131     const char* getSubtitles() const;
132     char* buildInputSlaveOption() const;
133     char* buildSubTrackIdOption() const;
134     mtime_t getDuration() const;
135
136     void setInputItem( input_item_t* p_input_item );
137
138 private:
139
140     input_item_t* _p_input_item;
141
142     Container* _parent;
143     std::string _objectID;
144     std::string _title;
145     std::string _resource;
146     std::string _subtitles;
147     mtime_t _duration;
148 };
149
150
151 class Container
152 {
153 public:
154
155     Container( Container* parent, const char* objectID, const char* title );
156     ~Container();
157
158     void addItem( Item* item );
159     void addContainer( Container* container );
160
161     const char* getObjectID() const;
162     const char* getTitle() const;
163
164     unsigned int getNumItems() const;
165     unsigned int getNumContainers() const;
166
167     Item* getItem( unsigned int i ) const;
168     Container* getContainer( unsigned int i ) const;
169     Container* getParent();
170
171     void setInputItem( input_item_t* p_input_item );
172     input_item_t* getInputItem() const;
173
174 private:
175
176     input_item_t* _p_input_item;
177
178     Container* _parent;
179
180     std::string _objectID;
181     std::string _title;
182     std::vector<Item*> _items;
183     std::vector<Container*> _containers;
184 };
185