Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mpd
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Иван Мажукин
mpd
Commits
3d446d32
Commit
3d446d32
authored
Feb 02, 2015
by
Max Kellermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lib/upnp/Discovery: apply naming convention
parent
e660229c
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
42 deletions
+42
-42
UpnpDatabasePlugin.cxx
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
+4
-4
ContentDirectoryService.hxx
src/lib/upnp/ContentDirectoryService.hxx
+2
-1
Discovery.cxx
src/lib/upnp/Discovery.cxx
+23
-23
Discovery.hxx
src/lib/upnp/Discovery.hxx
+12
-13
UpnpNeighborPlugin.cxx
src/neighbor/plugins/UpnpNeighborPlugin.cxx
+1
-1
No files found.
src/db/plugins/upnp/UpnpDatabasePlugin.cxx
View file @
3d446d32
...
...
@@ -222,7 +222,7 @@ UpnpDatabase::GetSong(const char *uri, Error &error) const
}
ContentDirectoryService
server
;
if
(
!
discovery
->
g
etServer
(
vpath
.
front
().
c_str
(),
server
,
error
))
if
(
!
discovery
->
G
etServer
(
vpath
.
front
().
c_str
(),
server
,
error
))
return
nullptr
;
vpath
.
pop_front
();
...
...
@@ -689,7 +689,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
auto
vpath
=
stringToTokens
(
selection
.
uri
,
"/"
,
true
);
if
(
vpath
.
empty
())
{
std
::
vector
<
ContentDirectoryService
>
servers
;
if
(
!
discovery
->
getDirServic
es
(
servers
,
error
))
if
(
!
discovery
->
GetDirectori
es
(
servers
,
error
))
return
false
;
for
(
const
auto
&
server
:
servers
)
{
...
...
@@ -714,7 +714,7 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
vpath
.
pop_front
();
ContentDirectoryService
server
;
if
(
!
discovery
->
g
etServer
(
servername
.
c_str
(),
server
,
error
))
if
(
!
discovery
->
G
etServer
(
servername
.
c_str
(),
server
,
error
))
return
false
;
return
VisitServer
(
server
,
vpath
,
selection
,
...
...
@@ -733,7 +733,7 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
return
true
;
std
::
vector
<
ContentDirectoryService
>
servers
;
if
(
!
discovery
->
getDirServic
es
(
servers
,
error
))
if
(
!
discovery
->
GetDirectori
es
(
servers
,
error
))
return
false
;
std
::
set
<
std
::
string
>
values
;
...
...
src/lib/upnp/ContentDirectoryService.hxx
View file @
3d446d32
...
...
@@ -62,7 +62,8 @@ public:
/**
* Construct by copying data from device and service objects.
*
* The discovery service does this: use getDirServices()
* The discovery service does this: use
* UPnPDeviceDirectory::GetDirectories()
*/
ContentDirectoryService
(
const
UPnPDevice
&
device
,
const
UPnPService
&
service
);
...
...
src/lib/upnp/Discovery.cxx
View file @
3d446d32
...
...
@@ -107,12 +107,12 @@ UPnPDeviceDirectory::LockRemove(const std::string &id)
}
inline
void
UPnPDeviceDirectory
::
discoExplorer
()
UPnPDeviceDirectory
::
Explore
()
{
for
(;;)
{
DiscoveredTask
*
tsk
=
0
;
if
(
!
discoveredQ
ueue
.
take
(
tsk
))
{
discoveredQ
ueue
.
workerExit
();
if
(
!
q
ueue
.
take
(
tsk
))
{
q
ueue
.
workerExit
();
return
;
}
...
...
@@ -128,7 +128,7 @@ UPnPDeviceDirectory::discoExplorer()
}
// Update or insert the device
ContentDirectoryDescriptor
d
(
std
::
move
(
tsk
->
device
I
d
),
ContentDirectoryDescriptor
d
(
std
::
move
(
tsk
->
device
_i
d
),
MonotonicClockS
(),
tsk
->
expires
);
{
...
...
@@ -148,10 +148,10 @@ UPnPDeviceDirectory::discoExplorer()
}
void
*
UPnPDeviceDirectory
::
discoExplorer
(
void
*
ctx
)
UPnPDeviceDirectory
::
Explore
(
void
*
ctx
)
{
UPnPDeviceDirectory
&
directory
=
*
(
UPnPDeviceDirectory
*
)
ctx
;
directory
.
discoExplorer
();
directory
.
Explore
();
return
(
void
*
)
1
;
}
...
...
@@ -161,7 +161,7 @@ UPnPDeviceDirectory::OnAlive(Upnp_Discovery *disco)
if
(
isMSDevice
(
disco
->
DeviceType
)
||
isCDService
(
disco
->
ServiceType
))
{
DiscoveredTask
*
tp
=
new
DiscoveredTask
(
disco
);
if
(
discoveredQ
ueue
.
put
(
tp
))
if
(
q
ueue
.
put
(
tp
))
return
UPNP_E_FINISH
;
}
...
...
@@ -210,7 +210,7 @@ UPnPDeviceDirectory::Invoke(Upnp_EventType et, void *evp)
}
bool
UPnPDeviceDirectory
::
e
xpireDevices
(
Error
&
error
)
UPnPDeviceDirectory
::
E
xpireDevices
(
Error
&
error
)
{
const
ScopeLock
protect
(
mutex
);
const
unsigned
now
=
MonotonicClockS
();
...
...
@@ -227,7 +227,7 @@ UPnPDeviceDirectory::expireDevices(Error &error)
}
if
(
didsomething
)
return
s
earch
(
error
);
return
S
earch
(
error
);
return
true
;
}
...
...
@@ -236,8 +236,8 @@ UPnPDeviceDirectory::UPnPDeviceDirectory(UpnpClient_Handle _handle,
UPnPDiscoveryListener
*
_listener
)
:
handle
(
_handle
),
listener
(
_listener
),
discoveredQ
ueue
(
"DiscoveredQueue"
),
m_searchTimeout
(
2
),
m_lastS
earch
(
0
)
q
ueue
(
"DiscoveredQueue"
),
search_timeout
(
2
),
last_s
earch
(
0
)
{
}
...
...
@@ -249,24 +249,24 @@ UPnPDeviceDirectory::~UPnPDeviceDirectory()
bool
UPnPDeviceDirectory
::
Start
(
Error
&
error
)
{
if
(
!
discoveredQueue
.
start
(
1
,
discoExplorer
,
this
))
{
if
(
!
queue
.
start
(
1
,
Explore
,
this
))
{
error
.
Set
(
upnp_domain
,
"Discover work queue start failed"
);
return
false
;
}
return
s
earch
(
error
);
return
S
earch
(
error
);
}
bool
UPnPDeviceDirectory
::
s
earch
(
Error
&
error
)
UPnPDeviceDirectory
::
S
earch
(
Error
&
error
)
{
const
unsigned
now
=
MonotonicClockS
();
if
(
now
-
m_lastS
earch
<
10
)
if
(
now
-
last_s
earch
<
10
)
return
true
;
m_lastS
earch
=
now
;
last_s
earch
=
now
;
// We search both for device and service just in case.
int
code
=
UpnpSearchAsync
(
handle
,
m_searchT
imeout
,
int
code
=
UpnpSearchAsync
(
handle
,
search_t
imeout
,
ContentDirectorySType
,
GetUpnpCookie
());
if
(
code
!=
UPNP_E_SUCCESS
)
{
error
.
Format
(
upnp_domain
,
code
,
...
...
@@ -275,7 +275,7 @@ UPnPDeviceDirectory::search(Error &error)
return
false
;
}
code
=
UpnpSearchAsync
(
handle
,
m_searchT
imeout
,
code
=
UpnpSearchAsync
(
handle
,
search_t
imeout
,
MediaServerDType
,
GetUpnpCookie
());
if
(
code
!=
UPNP_E_SUCCESS
)
{
error
.
Format
(
upnp_domain
,
code
,
...
...
@@ -288,11 +288,11 @@ UPnPDeviceDirectory::search(Error &error)
}
bool
UPnPDeviceDirectory
::
getDirServic
es
(
std
::
vector
<
ContentDirectoryService
>
&
out
,
UPnPDeviceDirectory
::
GetDirectori
es
(
std
::
vector
<
ContentDirectoryService
>
&
out
,
Error
&
error
)
{
// Has locking, do it before our own lock
if
(
!
e
xpireDevices
(
error
))
if
(
!
E
xpireDevices
(
error
))
return
false
;
const
ScopeLock
protect
(
mutex
);
...
...
@@ -310,12 +310,12 @@ UPnPDeviceDirectory::getDirServices(std::vector<ContentDirectoryService> &out,
}
bool
UPnPDeviceDirectory
::
getServer
(
const
char
*
friendlyN
ame
,
UPnPDeviceDirectory
::
GetServer
(
const
char
*
friendly_n
ame
,
ContentDirectoryService
&
server
,
Error
&
error
)
{
// Has locking, do it before our own lock
if
(
!
e
xpireDevices
(
error
))
if
(
!
E
xpireDevices
(
error
))
return
false
;
const
ScopeLock
protect
(
mutex
);
...
...
@@ -323,7 +323,7 @@ UPnPDeviceDirectory::getServer(const char *friendlyName,
for
(
const
auto
&
i
:
directories
)
{
const
auto
&
device
=
i
.
device
;
if
(
device
.
friendlyName
!=
friendly
N
ame
)
if
(
device
.
friendlyName
!=
friendly
_n
ame
)
continue
;
for
(
const
auto
&
service
:
device
.
services
)
{
...
...
src/lib/upnp/Discovery.hxx
View file @
3d446d32
...
...
@@ -55,13 +55,13 @@ class UPnPDeviceDirectory final : UpnpCallback {
*/
struct
DiscoveredTask
{
std
::
string
url
;
std
::
string
device
I
d
;
std
::
string
device
_i
d
;
unsigned
expires
;
// Seconds valid
DiscoveredTask
(
const
Upnp_Discovery
*
disco
)
:
url
(
disco
->
Location
),
deviceI
d
(
disco
->
DeviceId
),
expires
(
disco
->
Expires
)
{}
device_i
d
(
disco
->
DeviceId
),
expires
(
disco
->
Expires
)
{}
};
/**
...
...
@@ -97,19 +97,19 @@ class UPnPDeviceDirectory final : UpnpCallback {
Mutex
mutex
;
std
::
list
<
ContentDirectoryDescriptor
>
directories
;
WorkQueue
<
DiscoveredTask
*>
discoveredQ
ueue
;
WorkQueue
<
DiscoveredTask
*>
q
ueue
;
/**
* The UPnP device search timeout, which should actually be
* called delay because it's the base of a random delay that
* the devices apply to avoid responding all at the same time.
*/
int
m_searchT
imeout
;
int
search_t
imeout
;
/**
* The MonotonicClockS() time stamp of the last search.
*/
unsigned
m_lastS
earch
;
unsigned
last_s
earch
;
public
:
UPnPDeviceDirectory
(
UpnpClient_Handle
_handle
,
...
...
@@ -122,24 +122,24 @@ public:
bool
Start
(
Error
&
error
);
/** Retrieve the directory services currently seen on the network */
bool
getDirServic
es
(
std
::
vector
<
ContentDirectoryService
>
&
,
Error
&
);
bool
GetDirectori
es
(
std
::
vector
<
ContentDirectoryService
>
&
,
Error
&
);
/**
* Get server by friendly name.
*/
bool
getServer
(
const
char
*
friendlyN
ame
,
bool
GetServer
(
const
char
*
friendly_n
ame
,
ContentDirectoryService
&
server
,
Error
&
error
);
private
:
bool
s
earch
(
Error
&
error
);
bool
S
earch
(
Error
&
error
);
/**
* Look at the devices and get rid of those which have not
* been seen for too long. We do this when listing the top
* directory.
*/
bool
e
xpireDevices
(
Error
&
error
);
bool
E
xpireDevices
(
Error
&
error
);
void
LockAdd
(
ContentDirectoryDescriptor
&&
d
);
void
LockRemove
(
const
std
::
string
&
id
);
...
...
@@ -149,12 +149,11 @@ private:
* devices appearing and disappearing, and update the
* directory pool accordingly.
*/
static
void
*
discoExplorer
(
void
*
);
void
discoExplorer
();
static
void
*
Explore
(
void
*
);
void
Explore
();
int
OnAlive
(
Upnp_Discovery
*
disco
);
int
OnByeBye
(
Upnp_Discovery
*
disco
);
int
cluCallBack
(
Upnp_EventType
et
,
void
*
evp
);
/* virtual methods from class UpnpCallback */
virtual
int
Invoke
(
Upnp_EventType
et
,
void
*
evp
)
override
;
...
...
src/neighbor/plugins/UpnpNeighborPlugin.cxx
View file @
3d446d32
...
...
@@ -100,7 +100,7 @@ UpnpNeighborExplorer::GetList() const
{
Error
error
;
if
(
!
discovery
->
getDirServic
es
(
tmp
,
error
))
if
(
!
discovery
->
GetDirectori
es
(
tmp
,
error
))
LogError
(
error
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment