2009-01-08 11:40:57 +01:00
|
|
|
/*****************************************************************************
|
2011-12-14 00:29:36 +01:00
|
|
|
* upnp.hpp : UPnP discovery module (libupnp) header
|
2009-01-08 11:40:57 +01:00
|
|
|
*****************************************************************************
|
2018-06-27 14:14:29 +02:00
|
|
|
* Copyright (C) 2004-2018 VLC authors and VideoLAN
|
2009-01-08 11:40:57 +01:00
|
|
|
*
|
2019-09-04 21:10:51 +02:00
|
|
|
* Authors: Rémi Denis-Courmont (original plugin)
|
2009-01-08 11:40:57 +01:00
|
|
|
* Christian Henz <henz # c-lab.de>
|
|
|
|
* Mirsal Ennaime <mirsal dot ennaime at gmail dot com>
|
2015-03-10 18:52:44 +01:00
|
|
|
* Hugo Beauzée-Luyssen <hugo@beauzee.fr>
|
2018-06-27 14:14:29 +02:00
|
|
|
* Shaleen Jain <shaleen@jain.sh>
|
2009-01-08 11:40:57 +01:00
|
|
|
*
|
2016-07-25 17:47:37 +02:00
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2.1 of the License, or
|
2009-01-08 11:40:57 +01:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2016-07-25 17:47:37 +02:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
2009-01-08 11:40:57 +01:00
|
|
|
*
|
2016-07-25 17:47:37 +02:00
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
|
2009-01-08 11:40:57 +01:00
|
|
|
*****************************************************************************/
|
2015-05-11 18:28:36 +02:00
|
|
|
|
2009-01-08 11:40:57 +01:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
|
2018-06-29 14:14:13 +02:00
|
|
|
#include "upnp-wrapper.hpp"
|
2018-10-11 13:43:42 +02:00
|
|
|
#include "../stream_out/dlna/dlna_common.hpp"
|
2018-06-29 14:14:13 +02:00
|
|
|
|
2015-12-03 14:24:19 +01:00
|
|
|
#include <vlc_url.h>
|
2018-08-18 00:18:55 +02:00
|
|
|
#include <vlc_interrupt.h>
|
|
|
|
#include <vlc_threads.h>
|
2018-10-23 08:51:18 +02:00
|
|
|
#include <vlc_cxx_helpers.hpp>
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
namespace SD
|
|
|
|
{
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
struct MediaServerDesc
|
|
|
|
{
|
2016-02-17 15:41:45 +01:00
|
|
|
MediaServerDesc( const std::string& udn, const std::string& fName,
|
|
|
|
const std::string& loc, const std::string& iconUrl );
|
2015-03-10 18:52:44 +01:00
|
|
|
~MediaServerDesc();
|
|
|
|
std::string UDN;
|
|
|
|
std::string friendlyName;
|
|
|
|
std::string location;
|
2016-02-17 15:41:45 +01:00
|
|
|
std::string iconUrl;
|
2015-03-10 18:52:44 +01:00
|
|
|
input_item_t* inputItem;
|
2015-10-14 17:10:17 +02:00
|
|
|
bool isSatIp;
|
2016-08-12 16:27:42 +02:00
|
|
|
std::string satIpHost;
|
2009-01-08 11:40:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-06-27 14:14:29 +02:00
|
|
|
class MediaServerList : public UpnpInstanceWrapper::Listener
|
2009-01-08 11:40:57 +01:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
MediaServerList( services_discovery_t* p_sd );
|
|
|
|
~MediaServerList();
|
|
|
|
|
2016-06-02 14:08:18 +02:00
|
|
|
bool addServer(MediaServerDesc *desc );
|
2015-03-10 18:52:44 +01:00
|
|
|
void removeServer(const std::string &udn );
|
2016-06-02 14:08:18 +02:00
|
|
|
MediaServerDesc* getServer( const std::string& udn );
|
2018-06-27 14:14:29 +02:00
|
|
|
int onEvent( Upnp_EventType event_type,
|
|
|
|
UpnpEventPtr p_event,
|
|
|
|
void* p_user_data ) override;
|
2009-01-08 11:40:57 +01:00
|
|
|
|
|
|
|
private:
|
2015-03-10 18:52:44 +01:00
|
|
|
void parseNewServer( IXML_Document* doc, const std::string& location );
|
2018-07-29 18:28:48 +02:00
|
|
|
void parseSatipServer( IXML_Element* p_device_elem, const char *psz_base_url, const char *psz_udn, const char *psz_friendly_name, std::string iconUrl );
|
2016-02-17 15:41:45 +01:00
|
|
|
std::string getIconURL( IXML_Element* p_device_elem , const char* psz_base_url );
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
private:
|
2016-06-01 16:38:06 +02:00
|
|
|
services_discovery_t* const m_sd;
|
2016-05-25 19:03:19 +02:00
|
|
|
std::vector<MediaServerDesc*> m_list;
|
2009-01-08 11:40:57 +01:00
|
|
|
};
|
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
}
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
namespace Access
|
2009-01-08 11:40:57 +01:00
|
|
|
{
|
|
|
|
|
2015-12-08 10:34:35 +01:00
|
|
|
class Upnp_i11e_cb
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Upnp_i11e_cb( Upnp_FunPtr callback, void *cookie );
|
2018-08-18 00:18:55 +02:00
|
|
|
~Upnp_i11e_cb() = default;
|
2015-12-08 10:34:35 +01:00
|
|
|
void waitAndRelease( void );
|
2017-08-29 23:10:15 +02:00
|
|
|
static int run( Upnp_EventType, UpnpEventPtr, void *);
|
2015-12-08 10:34:35 +01:00
|
|
|
|
|
|
|
private:
|
2018-08-18 00:18:55 +02:00
|
|
|
vlc::threads::semaphore m_sem;
|
|
|
|
vlc::threads::mutex m_lock;
|
2016-05-25 19:03:19 +02:00
|
|
|
int m_refCount;
|
|
|
|
Upnp_FunPtr m_callback;
|
|
|
|
void* m_cookie;
|
2015-12-08 10:34:35 +01:00
|
|
|
};
|
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
class MediaServer
|
2009-01-08 11:40:57 +01:00
|
|
|
{
|
|
|
|
public:
|
2017-07-23 07:43:16 +02:00
|
|
|
MediaServer( stream_t* p_access, input_item_node_t* node );
|
2015-05-07 09:32:39 +02:00
|
|
|
~MediaServer();
|
2016-04-12 15:07:22 +02:00
|
|
|
bool fetchContents();
|
2009-01-08 11:40:57 +01:00
|
|
|
|
|
|
|
private:
|
2015-03-10 18:52:44 +01:00
|
|
|
MediaServer(const MediaServer&);
|
|
|
|
MediaServer& operator=(const MediaServer&);
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2016-05-03 13:44:05 +02:00
|
|
|
bool addContainer( IXML_Element* containerElement );
|
2016-05-03 14:03:06 +02:00
|
|
|
bool addItem( IXML_Element* itemElement );
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
IXML_Document* _browseAction(const char*, const char*,
|
|
|
|
const char*, const char*, const char* );
|
2017-08-29 23:10:15 +02:00
|
|
|
static int sendActionCb( Upnp_EventType, UpnpEventPtr, void *);
|
2009-01-08 11:40:57 +01:00
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
private:
|
2016-05-25 19:03:19 +02:00
|
|
|
char* m_psz_root;
|
|
|
|
char* m_psz_objectId;
|
2017-07-23 07:43:16 +02:00
|
|
|
stream_t* m_access;
|
2016-05-25 19:03:19 +02:00
|
|
|
input_item_node_t* m_node;
|
2009-01-08 11:40:57 +01:00
|
|
|
};
|
|
|
|
|
2015-03-10 18:52:44 +01:00
|
|
|
}
|
2018-10-23 08:51:20 +02:00
|
|
|
|
|
|
|
namespace RD
|
|
|
|
{
|
|
|
|
|
|
|
|
struct MediaRendererDesc
|
|
|
|
{
|
|
|
|
MediaRendererDesc( const std::string& udn, const std::string& fName,
|
|
|
|
const std::string& base, const std::string& loc );
|
|
|
|
~MediaRendererDesc();
|
|
|
|
std::string UDN;
|
|
|
|
std::string friendlyName;
|
|
|
|
std::string base_url; // base url of the renderer
|
|
|
|
std::string location; // device description url
|
|
|
|
vlc_renderer_item_t *inputItem;
|
|
|
|
};
|
|
|
|
|
|
|
|
class MediaRendererList : public UpnpInstanceWrapper::Listener
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
MediaRendererList( vlc_renderer_discovery_t *p_rd );
|
|
|
|
~MediaRendererList();
|
|
|
|
|
|
|
|
bool addRenderer(MediaRendererDesc *desc );
|
|
|
|
void removeRenderer(const std::string &udn );
|
|
|
|
MediaRendererDesc* getRenderer( const std::string& udn );
|
|
|
|
int onEvent( Upnp_EventType event_type,
|
|
|
|
UpnpEventPtr p_event,
|
|
|
|
void* p_user_data ) override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void parseNewRenderer( IXML_Document* doc, const std::string& location );
|
|
|
|
|
|
|
|
private:
|
|
|
|
vlc_renderer_discovery_t* const m_rd;
|
|
|
|
std::vector<MediaRendererDesc*> m_list;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|