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
9a461fa6
Commit
9a461fa6
authored
Sep 24, 2015
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Store thumbnails to a user defined location
parent
ae90cfa7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
6 deletions
+24
-6
include/IMediaLibrary.h
include/IMediaLibrary.h
+2
-1
src/MediaLibrary.cpp
src/MediaLibrary.cpp
+7
-1
src/MediaLibrary.h
src/MediaLibrary.h
+11
-2
src/metadata_services/vlc/VLCThumbnailer.cpp
src/metadata_services/vlc/VLCThumbnailer.cpp
+3
-1
test/Tests.cpp
test/Tests.cpp
+1
-1
No files found.
include/IMediaLibrary.h
View file @
9a461fa6
...
...
@@ -40,7 +40,7 @@ class IMediaLibrary : public IDiscovererCb
/// \param dbPath Path to the database
/// \return true in case of success, false otherwise
///
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
)
=
0
;
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshotPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
)
=
0
;
/// Adds a stand alone file
virtual
FilePtr
addFile
(
const
std
::
string
&
path
)
=
0
;
virtual
FilePtr
file
(
const
std
::
string
&
path
)
=
0
;
...
...
@@ -81,6 +81,7 @@ class IMediaLibrary : public IDiscovererCb
* @param entryPoint What to discover.
*/
virtual
void
discover
(
const
std
::
string
&
entryPoint
)
=
0
;
virtual
const
std
::
string
&
snapshotPath
()
const
=
0
;
};
class
MediaLibraryFactory
...
...
src/MediaLibrary.cpp
View file @
9a461fa6
...
...
@@ -56,12 +56,13 @@ MediaLibrary::~MediaLibrary()
AudioTrack
::
clear
();
}
bool
MediaLibrary
::
initialize
(
const
std
::
string
&
dbPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
)
bool
MediaLibrary
::
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshotPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
)
{
if
(
fsFactory
!=
nullptr
)
m_fsFactory
=
fsFactory
;
else
m_fsFactory
.
reset
(
new
factory
::
FileSystemDefaultFactory
);
m_snapshotPath
=
snapshotPath
;
sqlite3
*
dbConnection
;
int
res
=
sqlite3_open
(
dbPath
.
c_str
(),
&
dbConnection
);
...
...
@@ -224,6 +225,11 @@ FilePtr MediaLibrary::onNewFile( const fs::IFile *file, FolderPtr parent )
return
addFile
(
file
,
parent
==
nullptr
?
0
:
parent
->
id
()
);
}
const
std
::
string
&
MediaLibrary
::
snapshotPath
()
const
{
return
m_snapshotPath
;
}
bool
MediaLibrary
::
loadFolders
()
{
//FIXME: This should probably be in a sql transaction
...
...
src/MediaLibrary.h
View file @
9a461fa6
...
...
@@ -13,7 +13,7 @@ class MediaLibrary : public IMediaLibrary
public:
MediaLibrary
();
~
MediaLibrary
();
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
);
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshotPath
,
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
);
virtual
std
::
vector
<
FilePtr
>
files
();
virtual
FilePtr
file
(
const
std
::
string
&
path
);
...
...
@@ -46,6 +46,8 @@ class MediaLibrary : public IMediaLibrary
virtual
FolderPtr
onNewFolder
(
const
fs
::
IDirectory
*
directory
,
FolderPtr
parent
)
override
;
virtual
FilePtr
onNewFile
(
const
fs
::
IFile
*
file
,
FolderPtr
parent
)
override
;
virtual
const
std
::
string
&
snapshotPath
()
const
override
;
private:
static
const
std
::
vector
<
std
::
string
>
supportedExtensions
;
...
...
@@ -57,8 +59,15 @@ class MediaLibrary : public IMediaLibrary
private:
std
::
shared_ptr
<
sqlite3
>
m_dbConnection
;
std
::
unique_ptr
<
Parser
>
m_parser
;
std
::
shared_ptr
<
factory
::
IFileSystem
>
m_fsFactory
;
std
::
vector
<
std
::
unique_ptr
<
IDiscoverer
>>
m_discoverers
;
std
::
string
m_snapshotPath
;
// Keep the parser as last field.
// The parser holds a (raw) pointer to the media library. When MediaLibrary's destructor gets called
// it might still finish a few operations before exiting the parser thread. Those operations are
// likely to require a valid MediaLibrary, which would be compromised if some fields have already been
// deleted/destroyed.
std
::
unique_ptr
<
Parser
>
m_parser
;
};
#endif // MEDIALIBRARY_H
src/metadata_services/vlc/VLCThumbnailer.cpp
View file @
9a461fa6
...
...
@@ -53,7 +53,9 @@ bool VLCThumbnailer::run( FilePtr file, void *data )
if
(
seekAhead
(
file
,
mp
,
data
)
==
false
)
return
false
;
std
::
string
path
(
"/tmp/test.jpg"
);
auto
path
=
m_ml
->
snapshotPath
();
path
+=
"/"
;
path
+=
std
::
to_string
(
file
->
id
()
)
+
".jpg"
;
if
(
mp
.
takeSnapshot
(
0
,
path
,
320
,
240
)
==
false
)
{
m_cb
->
done
(
file
,
StatusError
,
data
);
...
...
test/Tests.cpp
View file @
9a461fa6
...
...
@@ -37,7 +37,7 @@ void Tests::Reload(std::shared_ptr<factory::IFileSystem> fs /* = nullptr */ )
{
fs
=
std
::
shared_ptr
<
factory
::
IFileSystem
>
(
new
mock
::
NoopFsFactory
);
}
bool
res
=
ml
->
initialize
(
"test.db"
,
fs
);
bool
res
=
ml
->
initialize
(
"test.db"
,
"/tmp"
,
fs
);
ASSERT_TRUE
(
res
);
}
...
...
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