*
* Authors: RĂ©mi Denis-Courmont <rem # videolan.org>
*
- * Based on original wxWindows patch for VLC, and dependant on CyberLink
+ * Based on original wxWindows patch for VLC, and dependent on CyberLink
* UPnP library from :
* Satoshi Konno <skonno@cybergarage.org>
*
#include <cybergarage/upnp/media/player/MediaPlayer.h>
#undef PACKAGE_NAME
-#include <vlc/vlc.h>
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
#include <vlc_playlist.h>
+#include <vlc_services_discovery.h>
/* FIXME: thread-safety ?? */
/* FIXME: playlist locking */
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
-vlc_module_begin();
- set_shortname( "UPnP");
- set_description( _("Universal Plug'n'Play discovery") );
- set_category( CAT_PLAYLIST );
- set_subcategory( SUBCAT_PLAYLIST_SD );
-
- set_capability( "services_discovery", 0 );
- set_callbacks( Open, Close );
-
-vlc_module_end();
-
-/*****************************************************************************
- * Local prototypes
- *****************************************************************************/
+vlc_module_begin ()
+ set_shortname( "UPnP")
+ set_description( N_("Universal Plug'n'Play discovery") )
+ set_category( CAT_PLAYLIST )
+ set_subcategory( SUBCAT_PLAYLIST_SD )
-/* Main functions */
- static void Run ( services_discovery_t *p_sd );
+ set_capability( "services_discovery", 0 )
+ set_callbacks( Open, Close )
-/*****************************************************************************
- * Open: initialize and create stuff
- *****************************************************************************/
-static int Open( vlc_object_t *p_this )
-{
- services_discovery_t *p_sd = ( services_discovery_t* )p_this;
-
- p_sd->pf_run = Run;
-
- services_discovery_SetLocalizedName( p_sd, _("Devices") );
-
- return VLC_SUCCESS;
-}
-
-
-/*****************************************************************************
- * Close:
- *****************************************************************************/
-static void Close( vlc_object_t *p_this )
-{
-}
+vlc_module_end ()
/*****************************************************************************
* Run: main UPnP thread
addSearchResponseListener( this );
//addEventListener( this );
}
-
};
-static void Run( services_discovery_t *p_sd )
+/*****************************************************************************
+ * Open: initialize and create stuff
+ *****************************************************************************/
+static int Open( vlc_object_t *p_this )
{
- UPnPHandler u( p_sd );
+ services_discovery_t *p_sd = ( services_discovery_t* )p_this;
- u.start();
+ UPnPHandler *u = new UPnPHandler( p_sd );
+ u->start( );
+ msg_Dbg( p_sd, "upnp discovery started" );
+ p_sd->p_private = u;
- msg_Dbg( p_sd, "UPnP discovery started" );
- /* read SAP packets */
- while( !p_sd->b_die )
- {
- msleep( 500 );
- }
+ return VLC_SUCCESS;
+}
+
+
+/*****************************************************************************
+ * Close:
+ *****************************************************************************/
+static void Close( vlc_object_t *p_this )
+{
+ UPnPHandler *u = (UPnPHandler *)p_this->p_private;
+ u->stop( );
- u.stop();
- msg_Dbg( p_sd, "UPnP discovery stopped" );
+ msg_Dbg( p_this, "upnp discovery started" );
}
if ( node->isItemNode() )
{
ItemNode *iNode = (ItemNode *)node;
- input_item_t *p_input = input_ItemNew( p_sd, iNode->getResource(), title );
+ input_item_t *p_input = input_item_New( p_sd, iNode->getResource(), title );
+ /* FIXME: playlist_AddInput() can fail */
playlist_BothAddInput( p_playlist, p_input, p_parent,
PLAYLIST_APPEND, PLAYLIST_END, NULL, NULL,
- VLC_FALSE );
+ false );
+ vlc_gc_decref( p_input );
} else if ( node->isContainerNode() )
{
ContainerNode *conNode = (ContainerNode *)node;
playlist_item_t *p_item = FindDeviceNode( dev );
if( p_item != NULL )
- playlist_NodeDelete( p_playlist, p_item, VLC_TRUE, VLC_TRUE );
+ playlist_NodeDelete( p_playlist, p_item, true, true );
}