Commit 47306fda authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

upnp: Use m_ prefix for class members instead of _ suffix

parent 225e4894
......@@ -297,25 +297,25 @@ MediaServerDesc::~MediaServerDesc()
* MediaServerList class
*/
MediaServerList::MediaServerList( services_discovery_t* p_sd )
: p_sd_( p_sd )
: m_sd( p_sd )
{
vlc_mutex_init( &lock_ );
vlc_mutex_init( &m_lock );
}
MediaServerList::~MediaServerList()
{
vlc_delete_all(list_);
vlc_mutex_destroy( &lock_ );
vlc_delete_all(m_list);
vlc_mutex_destroy( &m_lock );
}
bool MediaServerList::addServer( MediaServerDesc* desc )
{
vlc_mutex_locker lock( &lock_ );
vlc_mutex_locker lock( &m_lock );
input_item_t* p_input_item = NULL;
if ( getServer( desc->UDN ) )
return false;
msg_Dbg( p_sd_, "Adding server '%s' with uuid '%s'", desc->friendlyName.c_str(), desc->UDN.c_str() );
msg_Dbg( m_sd, "Adding server '%s' with uuid '%s'", desc->friendlyName.c_str(), desc->UDN.c_str() );
if ( desc->isSatIp )
{
......@@ -341,16 +341,16 @@ bool MediaServerList::addServer( MediaServerDesc* desc )
input_item_SetArtworkURL( p_input_item, desc->iconUrl.c_str() );
desc->inputItem = p_input_item;
input_item_SetDescription( p_input_item, desc->UDN.c_str() );
services_discovery_AddItem( p_sd_, p_input_item, NULL );
list_.push_back( desc );
services_discovery_AddItem( m_sd, p_input_item, NULL );
m_list.push_back( desc );
return true;
}
MediaServerDesc* MediaServerList::getServer( const std::string& udn )
{
std::vector<MediaServerDesc*>::const_iterator it = list_.begin();
std::vector<MediaServerDesc*>::const_iterator ite = list_.end();
std::vector<MediaServerDesc*>::const_iterator it = m_list.begin();
std::vector<MediaServerDesc*>::const_iterator ite = m_list.end();
for ( ; it != ite; ++it )
{
......@@ -366,13 +366,13 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
{
if ( !doc )
{
msg_Err( p_sd_, "Null IXML_Document" );
msg_Err( m_sd, "Null IXML_Document" );
return;
}
if ( location.empty() )
{
msg_Err( p_sd_, "Empty location" );
msg_Err( m_sd, "Empty location" );
return;
}
......@@ -407,7 +407,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
if ( !psz_device_type )
{
msg_Warn( p_sd_, "No deviceType found!" );
msg_Warn( m_sd, "No deviceType found!" );
continue;
}
......@@ -421,14 +421,14 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
"UDN" );
if ( !psz_udn )
{
msg_Warn( p_sd_, "No UDN!" );
msg_Warn( m_sd, "No UDN!" );
continue;
}
/* Check if server is already added */
if ( p_sd_->p_sys->p_server_list->getServer( psz_udn ) )
if ( m_sd->p_sys->p_server_list->getServer( psz_udn ) )
{
msg_Warn( p_sd_, "Server with uuid '%s' already exists.", psz_udn );
msg_Warn( m_sd, "Server with uuid '%s' already exists.", psz_udn );
continue;
}
......@@ -438,7 +438,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
if ( !psz_friendly_name )
{
msg_Dbg( p_sd_, "No friendlyName!" );
msg_Dbg( m_sd, "No friendlyName!" );
continue;
}
......@@ -475,7 +475,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
} else {
/* if no playlist is found, add a playlist from the web based on the chosen
* satellite, which will be processed by a lua script a bit later */
char *psz_satellite = config_GetPsz(p_sd_, "satip-satellite");
char *psz_satellite = config_GetPsz(m_sd, "satip-satellite");
if( !psz_satellite ) {
break;
}
......@@ -517,7 +517,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
const char* psz_service_type = xml_getChildElementValue( p_service_element, "serviceType" );
if ( !psz_service_type )
{
msg_Warn( p_sd_, "No service type found." );
msg_Warn( m_sd, "No service type found." );
continue;
}
......@@ -530,7 +530,7 @@ void MediaServerList::parseNewServer( IXML_Document *doc, const std::string &loc
"controlURL" );
if ( !psz_control_url )
{
msg_Warn( p_sd_, "No control url found." );
msg_Warn( m_sd, "No control url found." );
continue;
}
......@@ -617,21 +617,21 @@ std::string MediaServerList::getIconURL( IXML_Element* p_device_elem, const char
void MediaServerList::removeServer( const std::string& udn )
{
vlc_mutex_locker lock( &lock_ );
vlc_mutex_locker lock( &m_lock );
MediaServerDesc* p_server = getServer( udn );
if ( !p_server )
return;
msg_Dbg( p_sd_, "Removing server '%s'", p_server->friendlyName.c_str() );
msg_Dbg( m_sd, "Removing server '%s'", p_server->friendlyName.c_str() );
assert(p_server->inputItem);
services_discovery_RemoveItem( p_sd_, p_server->inputItem );
services_discovery_RemoveItem( m_sd, p_server->inputItem );
std::vector<MediaServerDesc*>::iterator it = std::find(list_.begin(), list_.end(), p_server);
if (it != list_.end())
std::vector<MediaServerDesc*>::iterator it = std::find(m_list.begin(), m_list.end(), p_server);
if (it != m_list.end())
{
list_.erase( it );
m_list.erase( it );
}
delete p_server;
}
......@@ -642,7 +642,7 @@ void MediaServerList::removeServer( const std::string& udn )
int MediaServerList::Callback( Upnp_EventType event_type, void* p_event, void* p_user_data )
{
MediaServerList* self = static_cast<MediaServerList*>( p_user_data );
services_discovery_t* p_sd = self->p_sd_;
services_discovery_t* p_sd = self->m_sd;
switch( event_type )
{
......@@ -703,35 +703,35 @@ namespace Access
{
Upnp_i11e_cb::Upnp_i11e_cb( Upnp_FunPtr callback, void *cookie )
: refCount_( 2 ) /* 2: owned by the caller, and the Upnp Async function */
, callback_( callback )
, cookie_( cookie )
: m_refCount( 2 ) /* 2: owned by the caller, and the Upnp Async function */
, m_callback( callback )
, m_cookie( cookie )
{
vlc_mutex_init( &lock_ );
vlc_sem_init( &sem_, 0 );
vlc_mutex_init( &m_lock );
vlc_sem_init( &m_sem, 0 );
}
Upnp_i11e_cb::~Upnp_i11e_cb()
{
vlc_mutex_destroy( &lock_ );
vlc_sem_destroy( &sem_ );
vlc_mutex_destroy( &m_lock );
vlc_sem_destroy( &m_sem );
}
void Upnp_i11e_cb::waitAndRelease( void )
{
vlc_sem_wait_i11e( &sem_ );
vlc_sem_wait_i11e( &m_sem );
vlc_mutex_lock( &lock_ );
if ( --refCount_ == 0 )
vlc_mutex_lock( &m_lock );
if ( --m_refCount == 0 )
{
/* The run callback is processed, we can destroy this object */
vlc_mutex_unlock( &lock_ );
vlc_mutex_unlock( &m_lock );
delete this;
} else
{
/* Interrupted, let the run callback destroy this object */
vlc_mutex_unlock( &lock_ );
vlc_mutex_unlock( &m_lock );
}
}
......@@ -739,43 +739,43 @@ int Upnp_i11e_cb::run( Upnp_EventType eventType, void *p_event, void *p_cookie )
{
Upnp_i11e_cb *self = static_cast<Upnp_i11e_cb*>( p_cookie );
vlc_mutex_lock( &self->lock_ );
if ( --self->refCount_ == 0 )
vlc_mutex_lock( &self->m_lock );
if ( --self->m_refCount == 0 )
{
/* Interrupted, we can destroy self */
vlc_mutex_unlock( &self->lock_ );
vlc_mutex_unlock( &self->m_lock );
delete self;
return 0;
}
/* Process the user callback_ */
self->callback_( eventType, p_event, self->cookie_);
vlc_mutex_unlock( &self->lock_ );
self->m_callback( eventType, p_event, self->m_cookie);
vlc_mutex_unlock( &self->m_lock );
/* Signal that the callback is processed */
vlc_sem_post( &self->sem_ );
vlc_sem_post( &self->m_sem );
return 0;
}
MediaServer::MediaServer( access_t *p_access, input_item_node_t *node )
: psz_objectId_( NULL )
, access_( p_access )
, node_( node )
: m_psz_objectId( NULL )
, m_access( p_access )
, m_node( node )
{
psz_root_ = strdup( p_access->psz_location );
char* psz_objectid = strstr( psz_root_, "ObjectID=" );
m_psz_root = strdup( p_access->psz_location );
char* psz_objectid = strstr( m_psz_root, "ObjectID=" );
if ( psz_objectid != NULL )
{
// Remove this parameter from the URL, since it might cause some servers to fail
// Keep in mind that we added a '&' or a '?' to the URL, so remove it as well
*( psz_objectid - 1) = 0;
psz_objectId_ = &psz_objectid[strlen( "ObjectID=" )];
m_psz_objectId = &psz_objectid[strlen( "ObjectID=" )];
}
}
MediaServer::~MediaServer()
{
free( psz_root_ );
free( m_psz_root );
}
bool MediaServer::addContainer( IXML_Element* containerElement )
......@@ -790,15 +790,15 @@ bool MediaServer::addContainer( IXML_Element* containerElement )
if ( !title )
return false;
if( asprintf( &psz_url, "upnp://%s?ObjectID=%s", psz_root_, objectID ) < 0 )
if( asprintf( &psz_url, "upnp://%s?ObjectID=%s", m_psz_root, objectID ) < 0 )
return false;
input_item_t* p_item = input_item_NewDirectory( psz_url, title, ITEM_NET );
free( psz_url);
if ( !p_item )
return false;
input_item_CopyOptions( p_item, node_->p_item );
input_item_node_AppendItem( node_, p_item );
input_item_CopyOptions( p_item, m_node->p_item );
input_item_node_AppendItem( m_node, p_item );
input_item_Release( p_item );
return true;
}
......@@ -893,8 +893,8 @@ bool MediaServer::addItem( IXML_Element* itemElement )
input_item_AddSlave( p_item, p_slave );
}
input_item_CopyOptions( p_item, node_->p_item );
input_item_node_AppendItem( node_, p_item );
input_item_CopyOptions( p_item, m_node->p_item );
input_item_node_AppendItem( m_node, p_item );
input_item_Release( p_item );
ixmlNodeList_free( p_resource_list );
......@@ -940,7 +940,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'ContainerID' failed: %s",
msg_Dbg( m_access, "AddToAction 'ContainerID' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -950,7 +950,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'BrowseFlag' failed: %s",
msg_Dbg( m_access, "AddToAction 'BrowseFlag' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -960,7 +960,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'Filter' failed: %s",
msg_Dbg( m_access, "AddToAction 'Filter' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -969,7 +969,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
CONTENT_DIRECTORY_SERVICE_TYPE, "StartingIndex", "0" );
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'StartingIndex' failed: %s",
msg_Dbg( m_access, "AddToAction 'StartingIndex' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -979,7 +979,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'RequestedCount' failed: %s",
msg_Dbg( m_access, "AddToAction 'RequestedCount' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -989,7 +989,7 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Dbg( access_, "AddToAction 'SortCriteria' failed: %s",
msg_Dbg( m_access, "AddToAction 'SortCriteria' failed: %s",
UpnpGetErrorMessage( i_res ) );
goto browseActionCleanup;
}
......@@ -997,8 +997,8 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
/* Setup an interruptible callback that will call sendActionCb if not
* interrupted by vlc_interrupt_kill */
i11eCb = new Upnp_i11e_cb( sendActionCb, &p_response );
i_res = UpnpSendActionAsync( access_->p_sys->p_upnp->handle(),
psz_root_,
i_res = UpnpSendActionAsync( m_access->p_sys->p_upnp->handle(),
m_psz_root,
CONTENT_DIRECTORY_SERVICE_TYPE,
NULL, /* ignored in SDK, must be NULL */
p_action,
......@@ -1006,8 +1006,8 @@ IXML_Document* MediaServer::_browseAction( const char* psz_object_id_,
if ( i_res != UPNP_E_SUCCESS )
{
msg_Err( access_, "%s when trying the send() action with URL: %s",
UpnpGetErrorMessage( i_res ), access_->psz_location );
msg_Err( m_access, "%s when trying the send() action with URL: %s",
UpnpGetErrorMessage( i_res ), m_access->psz_location );
}
/* Wait for the callback to fill p_response or wait for an interrupt */
i11eCb->waitAndRelease();
......@@ -1022,7 +1022,7 @@ browseActionCleanup:
*/
bool MediaServer::fetchContents()
{
IXML_Document* p_response = _browseAction( psz_objectId_,
IXML_Document* p_response = _browseAction( m_psz_objectId,
"BrowseDirectChildren",
"*",
// Some servers don't understand "0" as "no-limit"
......@@ -1031,7 +1031,7 @@ bool MediaServer::fetchContents()
);
if ( !p_response )
{
msg_Err( access_, "No response from browse() action" );
msg_Err( m_access, "No response from browse() action" );
return false;
}
......@@ -1041,12 +1041,12 @@ bool MediaServer::fetchContents()
if ( !p_result )
{
msg_Err( access_, "browse() response parsing failed" );
msg_Err( m_access, "browse() response parsing failed" );
return false;
}
#ifndef NDEBUG
msg_Dbg( access_, "Got DIDL document: %s", ixmlPrintDocument( p_result ) );
msg_Dbg( m_access, "Got DIDL document: %s", ixmlPrintDocument( p_result ) );
#endif
IXML_NodeList* containerNodeList =
......@@ -1126,19 +1126,19 @@ static void Close( vlc_object_t* p_this )
}
UpnpInstanceWrapper::UpnpInstanceWrapper()
: handle_( -1 )
, opaque_( NULL )
, callback_( NULL )
, refcount_( 0 )
: m_handle( -1 )
, m_opaque( NULL )
, m_callback( NULL )
, m_refcount( 0 )
{
vlc_mutex_init( &callback_lock_ );
vlc_mutex_init( &m_callback_lock );
}
UpnpInstanceWrapper::~UpnpInstanceWrapper()
{
UpnpUnRegisterClient( handle_ );
UpnpUnRegisterClient( m_handle );
UpnpFinish();
vlc_mutex_destroy( &callback_lock_ );
vlc_mutex_destroy( &m_callback_lock );
}
UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, Upnp_FunPtr callback, SD::MediaServerList *opaque)
......@@ -1169,7 +1169,7 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, Upnp_FunPtr c
ixmlRelaxParser( 1 );
/* Register a control point */
i_res = UpnpRegisterClient( Callback, instance, &instance->handle_ );
i_res = UpnpRegisterClient( Callback, instance, &instance->m_handle );
if( i_res != UPNP_E_SUCCESS )
{
msg_Err( p_obj, "Client registration failed: %s", UpnpGetErrorMessage( i_res ) );
......@@ -1189,14 +1189,14 @@ UpnpInstanceWrapper *UpnpInstanceWrapper::get(vlc_object_t *p_obj, Upnp_FunPtr c
}
s_instance = instance;
}
s_instance->refcount_++;
s_instance->m_refcount++;
// This assumes a single UPNP SD instance
if (callback && opaque)
{
vlc_mutex_locker lock( &s_instance->callback_lock_ );
assert(!s_instance->callback_ && !s_instance->opaque_);
s_instance->opaque_ = opaque;
s_instance->callback_ = callback;
vlc_mutex_locker lock( &s_instance->m_callback_lock );
assert(!s_instance->m_callback && !s_instance->m_opaque);
s_instance->m_opaque = opaque;
s_instance->m_callback = callback;
}
return s_instance;
}
......@@ -1206,11 +1206,11 @@ void UpnpInstanceWrapper::release(bool isSd)
vlc_mutex_locker lock( &s_lock );
if ( isSd )
{
vlc_mutex_locker lock( &callback_lock_ );
callback_ = NULL;
opaque_ = NULL;
vlc_mutex_locker lock( &m_callback_lock );
m_callback = NULL;
m_opaque = NULL;
}
if (--s_instance->refcount_ == 0)
if (--s_instance->m_refcount == 0)
{
delete s_instance;
s_instance = NULL;
......@@ -1219,15 +1219,15 @@ void UpnpInstanceWrapper::release(bool isSd)
UpnpClient_Handle UpnpInstanceWrapper::handle() const
{
return handle_;
return m_handle;
}
int UpnpInstanceWrapper::Callback(Upnp_EventType event_type, void *p_event, void *p_user_data)
{
UpnpInstanceWrapper* self = static_cast<UpnpInstanceWrapper*>( p_user_data );
vlc_mutex_locker lock( &self->callback_lock_ );
if ( !self->callback_ )
vlc_mutex_locker lock( &self->m_callback_lock );
if ( !self->m_callback )
return 0;
self->callback_( event_type, p_event, self->opaque_ );
self->m_callback( event_type, p_event, self->m_opaque );
return 0;
}
......@@ -71,11 +71,11 @@ private:
private:
static UpnpInstanceWrapper* s_instance;
static vlc_mutex_t s_lock;
UpnpClient_Handle handle_;
vlc_mutex_t callback_lock_; // protect opaque_ and callback_
SD::MediaServerList* opaque_;
Upnp_FunPtr callback_;
int refcount_;
UpnpClient_Handle m_handle;
vlc_mutex_t m_callback_lock; // protect opaque_ and callback_
SD::MediaServerList* m_opaque;
Upnp_FunPtr m_callback;
int m_refcount;
};
namespace SD
......@@ -112,9 +112,9 @@ private:
std::string getIconURL( IXML_Element* p_device_elem , const char* psz_base_url );
private:
services_discovery_t* p_sd_;
std::vector<MediaServerDesc*> list_;
vlc_mutex_t lock_;
services_discovery_t* m_sd;
std::vector<MediaServerDesc*> m_list;
vlc_mutex_t m_lock;
};
}
......@@ -131,11 +131,11 @@ public:
static int run( Upnp_EventType, void *, void *);
private:
vlc_sem_t sem_;
vlc_mutex_t lock_;
int refCount_;
Upnp_FunPtr callback_;
void* cookie_;
vlc_sem_t m_sem;
vlc_mutex_t m_lock;
int m_refCount;
Upnp_FunPtr m_callback;
void* m_cookie;
};
class MediaServer
......@@ -157,10 +157,10 @@ private:
static int sendActionCb( Upnp_EventType, void *, void *);
private:
char* psz_root_;
char* psz_objectId_;
access_t* access_;
input_item_node_t* node_;
char* m_psz_root;
char* m_psz_objectId;
access_t* m_access;
input_item_node_t* m_node;
};
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment