Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
cfad5074
Commit
cfad5074
authored
Sep 28, 2015
by
Hugo Beauzée-Luyssen
Browse files
Let the MediaLibrary populates its own discoverers
parent
139bc49e
Changes
4
Hide whitespace changes
Inline
Side-by-side
include/IMediaLibrary.h
View file @
cfad5074
...
...
@@ -73,7 +73,6 @@ class IMediaLibrary : public IDiscovererCb
virtual
void
addMetadataService
(
std
::
unique_ptr
<
IMetadataService
>
service
)
=
0
;
virtual
void
parse
(
FilePtr
file
,
IParserCb
*
cb
)
=
0
;
virtual
void
addDiscoverer
(
std
::
unique_ptr
<
IDiscoverer
>
discoverer
)
=
0
;
/**
* @brief discover Launch a discovery on the provided entry point.
* There no garanty on how this will be processed, or if it will be processed synchronously or not.
...
...
src/MediaLibrary.cpp
View file @
cfad5074
...
...
@@ -16,6 +16,9 @@
#include "Utils.h"
#include "VideoTrack.h"
// Discoverers:
#include "discoverer/FsDiscoverer.h"
#include "filesystem/IDirectory.h"
#include "filesystem/IFile.h"
#include "factory/FileSystem.h"
...
...
@@ -64,6 +67,8 @@ bool MediaLibrary::initialize( const std::string& dbPath, const std::string& sna
m_fsFactory
.
reset
(
new
factory
::
FileSystemDefaultFactory
);
m_snapshotPath
=
snapshotPath
;
m_discoverers
.
emplace_back
(
new
FsDiscoverer
(
m_fsFactory
,
this
)
);
sqlite3
*
dbConnection
;
int
res
=
sqlite3_open
(
dbPath
.
c_str
(),
&
dbConnection
);
if
(
res
!=
SQLITE_OK
)
...
...
@@ -197,11 +202,6 @@ void MediaLibrary::parse(FilePtr file , IParserCb* cb)
m_parser
->
parse
(
file
,
cb
);
}
void
MediaLibrary
::
addDiscoverer
(
std
::
unique_ptr
<
IDiscoverer
>
discoverer
)
{
m_discoverers
.
emplace_back
(
std
::
move
(
discoverer
)
);
}
void
MediaLibrary
::
discover
(
const
std
::
string
&
entryPoint
)
{
for
(
auto
&
d
:
m_discoverers
)
...
...
src/MediaLibrary.h
View file @
cfad5074
...
...
@@ -40,7 +40,6 @@ class MediaLibrary : public IMediaLibrary
virtual
void
addMetadataService
(
std
::
unique_ptr
<
IMetadataService
>
service
);
virtual
void
parse
(
FilePtr
file
,
IParserCb
*
cb
);
virtual
void
addDiscoverer
(
std
::
unique_ptr
<
IDiscoverer
>
discoverer
)
override
;
virtual
void
discover
(
const
std
::
string
&
entryPoint
)
override
;
// IDiscovererCb implementation
virtual
FolderPtr
onNewFolder
(
const
fs
::
IDirectory
*
directory
,
FolderPtr
parent
)
override
;
...
...
test/Tests.cpp
View file @
cfad5074
...
...
@@ -28,12 +28,7 @@ void Tests::TearDown()
void
Tests
::
Reload
(
std
::
shared_ptr
<
factory
::
IFileSystem
>
fs
/* = nullptr */
)
{
ml
.
reset
(
MediaLibraryFactory
::
create
()
);
if
(
fs
!=
nullptr
)
{
std
::
unique_ptr
<
IDiscoverer
>
discoverer
(
new
FsDiscoverer
(
fs
,
ml
.
get
()
)
);
ml
->
addDiscoverer
(
std
::
move
(
discoverer
)
);
}
else
if
(
fs
==
nullptr
)
{
fs
=
std
::
shared_ptr
<
factory
::
IFileSystem
>
(
new
mock
::
NoopFsFactory
);
}
...
...
Write
Preview
Supports
Markdown
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