Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
VideoLAN
medialibrary
Commits
7377c51f
Commit
7377c51f
authored
Jun 06, 2018
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MediaLibrary: Rework network filesystem factories management
parent
ec036d25
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
15 deletions
+25
-15
src/MediaLibrary.cpp
src/MediaLibrary.cpp
+18
-15
src/MediaLibrary.h
src/MediaLibrary.h
+2
-0
test/common/MediaLibraryTester.cpp
test/common/MediaLibraryTester.cpp
+4
-0
test/common/MediaLibraryTester.h
test/common/MediaLibraryTester.h
+1
-0
No files found.
src/MediaLibrary.cpp
View file @
7377c51f
...
...
@@ -330,6 +330,7 @@ bool MediaLibrary::start()
if
(
m_parser
!=
nullptr
)
return
false
;
populateFsFactories
();
for
(
auto
&
fsFactory
:
m_fsFactories
)
refreshDevices
(
*
fsFactory
);
startDiscoverer
();
...
...
@@ -767,6 +768,13 @@ bool MediaLibrary::startThumbnailer()
#endif
}
void
MediaLibrary
::
populateFsFactories
()
{
#ifdef HAVE_LIBVLC
m_externalFsFactories
.
emplace_back
(
std
::
make_shared
<
factory
::
NetworkFileSystemFactory
>
(
"smb"
,
"dsm-sd"
)
);
#endif
}
void
MediaLibrary
::
addLocalFsFactory
()
{
m_fsFactories
.
insert
(
begin
(
m_fsFactories
),
std
::
make_shared
<
factory
::
FileSystemFactory
>
(
m_deviceLister
)
);
...
...
@@ -1218,25 +1226,20 @@ void MediaLibrary::discover( const std::string& entryPoint )
bool
MediaLibrary
::
setDiscoverNetworkEnabled
(
bool
enabled
)
{
#ifdef HAVE_LIBVLC
if
(
enabled
)
{
auto
it
=
std
::
find_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
});
if
(
it
==
end
(
m_fsFactories
)
)
m_fsFactories
.
push_back
(
std
::
make_shared
<
factory
::
NetworkFileSystemFactory
>
(
"smb"
,
"dsm-sd"
)
);
}
else
{
m_fsFactories
.
erase
(
std
::
remove_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
}),
end
(
m_fsFactories
)
);
auto
previousSize
=
m_fsFactories
.
size
();
std
::
copy_if
(
begin
(
m_externalFsFactories
),
end
(
m_externalFsFactories
),
std
::
back_inserter
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
});
return
m_fsFactories
.
size
()
==
previousSize
;
}
m_fsFactories
.
erase
(
std
::
remove_if
(
begin
(
m_fsFactories
),
end
(
m_fsFactories
),
[](
const
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>
fs
)
{
return
fs
->
isNetworkFileSystem
();
}),
end
(
m_fsFactories
)
);
return
true
;
#else
return
false
;
#endif
}
Query
<
IFolder
>
MediaLibrary
::
entryPoints
()
const
...
...
src/MediaLibrary.h
View file @
7377c51f
...
...
@@ -178,6 +178,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
virtual
void
startDiscoverer
();
virtual
void
startDeletionNotifier
();
virtual
bool
startThumbnailer
();
virtual
void
populateFsFactories
();
private:
bool
recreateDatabase
(
const
std
::
string
&
dbPath
);
...
...
@@ -211,6 +212,7 @@ class MediaLibrary : public IMediaLibrary, public IDeviceListerCb
protected:
std
::
shared_ptr
<
sqlite
::
Connection
>
m_dbConnection
;
std
::
vector
<
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>>
m_fsFactories
;
std
::
vector
<
std
::
shared_ptr
<
fs
::
IFileSystemFactory
>>
m_externalFsFactories
;
std
::
string
m_thumbnailPath
;
IMediaLibraryCb
*
m_callback
;
DeviceListerPtr
m_deviceLister
;
...
...
test/common/MediaLibraryTester.cpp
View file @
7377c51f
...
...
@@ -195,3 +195,7 @@ bool MediaLibraryTester::startThumbnailer()
{
return
true
;
}
void
MediaLibraryTester
::
populateFsFactories
()
{
}
test/common/MediaLibraryTester.h
View file @
7377c51f
...
...
@@ -73,6 +73,7 @@ public:
std
::
pair
<
std
::
shared_ptr
<
Playlist
>
,
unsigned
int
>
parentPlaylist
)
override
;
sqlite
::
Connection
*
getDbConn
();
virtual
bool
startThumbnailer
();
virtual
void
populateFsFactories
();
private:
std
::
shared_ptr
<
fs
::
IDirectory
>
dummyDirectory
;
...
...
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