hevc: use pic timing
[vlc.git] / modules / services_discovery / upnp.hpp
blob465a3a59c6f62cb61c2258ea7f51b9c77db7c00c
1 /*****************************************************************************
2 * upnp.hpp : UPnP discovery module (libupnp) header
3 *****************************************************************************
4 * Copyright (C) 2004-2016 VLC authors and VideoLAN
5 * $Id$
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 * Hugo Beauzée-Luyssen <hugo@beauzee.fr>
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU Lesser General Public License as published by
14 * the Free Software Foundation; either version 2.1 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 Lesser General Public License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this program; if not, write to the Free Software Foundation,
24 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
31 #include <vector>
32 #include <string>
34 #include <upnp/upnp.h>
35 #include <upnp/upnptools.h>
37 #include <vlc_common.h>
38 #include <vlc_url.h>
40 namespace SD
42 class MediaServerList;
46 * libUpnp allows only one instance per process, so we have to share one for
47 * both SD & Access module
48 * Since the callback is bound to the UpnpClient_Handle, we have to register
49 * a wrapper callback, in order for the access module to be able to initialize
50 * libUpnp first.
51 * When a SD wishes to use libUpnp, it will provide its own callback, that the
52 * wrapper will forward.
53 * This way, we always have a register callback & a client handle.
55 class UpnpInstanceWrapper
57 public:
58 // This increases the refcount before returning the instance
59 static UpnpInstanceWrapper* get(vlc_object_t* p_obj, services_discovery_t *p_sd);
60 void release(bool isSd);
61 UpnpClient_Handle handle() const;
62 static SD::MediaServerList *lockMediaServerList();
63 static void unlockMediaServerList();
65 private:
66 static int Callback( Upnp_EventType event_type, void* p_event, void* p_user_data );
68 UpnpInstanceWrapper();
69 ~UpnpInstanceWrapper();
71 private:
72 static UpnpInstanceWrapper* s_instance;
73 static vlc_mutex_t s_lock;
74 UpnpClient_Handle m_handle;
75 static SD::MediaServerList* p_server_list;
76 int m_refcount;
79 namespace SD
82 struct MediaServerDesc
84 MediaServerDesc( const std::string& udn, const std::string& fName,
85 const std::string& loc, const std::string& iconUrl );
86 ~MediaServerDesc();
87 std::string UDN;
88 std::string friendlyName;
89 std::string location;
90 std::string iconUrl;
91 input_item_t* inputItem;
92 bool isSatIp;
93 std::string satIpHost;
97 class MediaServerList
99 public:
101 MediaServerList( services_discovery_t* p_sd );
102 ~MediaServerList();
104 bool addServer(MediaServerDesc *desc );
105 void removeServer(const std::string &udn );
106 MediaServerDesc* getServer( const std::string& udn );
107 static int Callback( Upnp_EventType event_type, void* p_event );
109 private:
110 void parseNewServer( IXML_Document* doc, const std::string& location );
111 std::string getIconURL( IXML_Element* p_device_elem , const char* psz_base_url );
113 private:
114 services_discovery_t* const m_sd;
115 std::vector<MediaServerDesc*> m_list;
120 namespace Access
123 class Upnp_i11e_cb
125 public:
126 Upnp_i11e_cb( Upnp_FunPtr callback, void *cookie );
127 ~Upnp_i11e_cb();
128 void waitAndRelease( void );
129 static int run( Upnp_EventType, void *, void *);
131 private:
132 vlc_sem_t m_sem;
133 vlc_mutex_t m_lock;
134 int m_refCount;
135 Upnp_FunPtr m_callback;
136 void* m_cookie;
139 class MediaServer
141 public:
142 MediaServer( access_t* p_access, input_item_node_t* node );
143 ~MediaServer();
144 bool fetchContents();
146 private:
147 MediaServer(const MediaServer&);
148 MediaServer& operator=(const MediaServer&);
150 bool addContainer( IXML_Element* containerElement );
151 bool addItem( IXML_Element* itemElement );
153 IXML_Document* _browseAction(const char*, const char*,
154 const char*, const char*, const char* );
155 static int sendActionCb( Upnp_EventType, void *, void *);
157 private:
158 char* m_psz_root;
159 char* m_psz_objectId;
160 access_t* m_access;
161 input_item_node_t* m_node;