Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
medialibrary
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
56
Issues
56
List
Boards
Labels
Service Desk
Milestones
Merge Requests
8
Merge Requests
8
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
VideoLAN
medialibrary
Commits
1f9548c2
Commit
1f9548c2
authored
Jan 04, 2016
by
Hugo Beauzée-Luyssen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Snapshot -> Thumbnail
parent
ac6949de
Changes
12
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
54 additions
and
51 deletions
+54
-51
include/IMedia.h
include/IMedia.h
+6
-3
include/IMediaLibrary.h
include/IMediaLibrary.h
+2
-2
src/Media.cpp
src/Media.cpp
+9
-9
src/Media.h
src/Media.h
+3
-3
src/MediaLibrary.cpp
src/MediaLibrary.cpp
+4
-4
src/MediaLibrary.h
src/MediaLibrary.h
+3
-3
src/metadata_services/vlc/VLCMetadataService.cpp
src/metadata_services/vlc/VLCMetadataService.cpp
+2
-2
src/metadata_services/vlc/VLCThumbnailer.cpp
src/metadata_services/vlc/VLCThumbnailer.cpp
+13
-13
src/metadata_services/vlc/VLCThumbnailer.h
src/metadata_services/vlc/VLCThumbnailer.h
+3
-3
test/samples/Tester.cpp
test/samples/Tester.cpp
+1
-1
test/unittest/MediaTests.cpp
test/unittest/MediaTests.cpp
+6
-6
test/unittest/ShowTests.cpp
test/unittest/ShowTests.cpp
+2
-2
No files found.
include/IMedia.h
View file @
1f9548c2
...
...
@@ -75,9 +75,12 @@ class IMedia
virtual
std
::
vector
<
LabelPtr
>
labels
()
=
0
;
virtual
std
::
vector
<
VideoTrackPtr
>
videoTracks
()
=
0
;
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
()
=
0
;
// Returns the location of this file snapshot.
// This is likely to be used for album arts as well.
virtual
const
std
::
string
&
snapshot
()
=
0
;
///
/// \brief thumbnail Returns the path of a thumbnail for this file
/// \return A path, relative to the thumbnailPath configured when initializing
/// The media library
///
virtual
const
std
::
string
&
thumbnail
()
=
0
;
virtual
unsigned
int
insertionDate
()
const
=
0
;
};
...
...
include/IMediaLibrary.h
View file @
1f9548c2
...
...
@@ -79,7 +79,7 @@ class IMediaLibrary
/// \param dbPath Path to the database
/// \return true in case of success, false otherwise
///
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshot
Path
,
IMediaLibraryCb
*
metadataCb
)
=
0
;
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
thumbnail
Path
,
IMediaLibraryCb
*
metadataCb
)
=
0
;
virtual
void
setVerbosity
(
LogLevel
v
)
=
0
;
/**
* Replaces the default filesystem factory
...
...
@@ -110,7 +110,7 @@ class IMediaLibrary
* @brief ignoreFolder will blacklist a folder for discovery
*/
virtual
bool
ignoreFolder
(
const
std
::
string
&
path
)
=
0
;
virtual
const
std
::
string
&
snapshot
Path
()
const
=
0
;
virtual
const
std
::
string
&
thumbnail
Path
()
const
=
0
;
virtual
void
setLogger
(
ILogger
*
logger
)
=
0
;
/**
* @brief pauseBackgroundOperations Will stop potentially CPU intensive background
...
...
src/Media.cpp
View file @
1f9548c2
...
...
@@ -61,7 +61,7 @@ Media::Media( DBConnection dbConnection, sqlite::Row& row )
>>
m_folderId
>>
m_lastModificationDate
>>
m_insertionDate
>>
m_
snapshot
>>
m_
thumbnail
>>
m_isParsed
>>
m_title
>>
m_isPresent
...
...
@@ -268,9 +268,9 @@ std::vector<AudioTrackPtr> Media::audioTracks()
return
AudioTrack
::
fetchAll
<
IAudioTrack
>
(
m_dbConnection
,
req
,
m_id
);
}
const
std
::
string
&
Media
::
snapshot
()
const
std
::
string
&
Media
::
thumbnail
()
{
return
m_
snapshot
;
return
m_
thumbnail
;
}
unsigned
int
Media
::
insertionDate
()
const
...
...
@@ -278,11 +278,11 @@ unsigned int Media::insertionDate() const
return
m_insertionDate
;
}
void
Media
::
set
Snapshot
(
const
std
::
string
&
snapshot
)
void
Media
::
set
Thumbnail
(
const
std
::
string
&
thumbnail
)
{
if
(
m_
snapshot
==
snapshot
)
if
(
m_
thumbnail
==
thumbnail
)
return
;
m_
snapshot
=
snapshot
;
m_
thumbnail
=
thumbnail
;
m_changed
=
true
;
}
...
...
@@ -290,7 +290,7 @@ bool Media::save()
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
MediaTable
::
Name
+
" SET "
"type = ?, duration = ?, play_count = ?, progress = ?, rating = ?, show_episode_id = ?,"
"artist = ?, movie_id = ?, last_modification_date = ?,
snapshot
= ?, parsed = ?,"
"artist = ?, movie_id = ?, last_modification_date = ?,
thumbnail
= ?, parsed = ?,"
"title = ? WHERE id_media = ?"
;
if
(
m_changed
==
false
)
return
true
;
...
...
@@ -298,7 +298,7 @@ bool Media::save()
m_progress
,
m_rating
,
sqlite
::
ForeignKey
{
m_showEpisodeId
},
m_artist
,
sqlite
::
ForeignKey
{
m_movieId
},
m_lastModificationDate
,
m_
snapshot
,
m_isParsed
,
m_title
,
m_id
)
==
false
)
m_
thumbnail
,
m_isParsed
,
m_title
,
m_id
)
==
false
)
{
return
false
;
}
...
...
@@ -371,7 +371,7 @@ bool Media::createTable( DBConnection connection )
"folder_id UNSIGNED INTEGER,"
"last_modification_date UNSIGNED INTEGER,"
"insertion_date UNSIGNED INTEGER,"
"
snapshot
TEXT,"
"
thumbnail
TEXT,"
"parsed BOOLEAN NOT NULL DEFAULT 0,"
"title TEXT,"
"is_present BOOLEAN NOT NULL DEFAULT 1,"
...
...
src/Media.h
View file @
1f9548c2
...
...
@@ -90,9 +90,9 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
bool
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
,
const
std
::
string
&
language
,
const
std
::
string
&
desc
);
virtual
std
::
vector
<
AudioTrackPtr
>
audioTracks
()
override
;
virtual
const
std
::
string
&
snapshot
()
override
;
virtual
const
std
::
string
&
thumbnail
()
override
;
virtual
unsigned
int
insertionDate
()
const
override
;
void
set
Snapshot
(
const
std
::
string
&
snapshot
);
void
set
Thumbnail
(
const
std
::
string
&
thumbnail
);
bool
save
();
unsigned
int
lastModificationDate
();
...
...
@@ -120,7 +120,7 @@ class Media : public IMedia, public DatabaseHelpers<Media, policy::MediaTable>
unsigned
int
m_folderId
;
unsigned
int
m_lastModificationDate
;
unsigned
int
m_insertionDate
;
std
::
string
m_
snapshot
;
std
::
string
m_
thumbnail
;
bool
m_isParsed
;
std
::
string
m_title
;
bool
m_isPresent
;
...
...
src/MediaLibrary.cpp
View file @
1f9548c2
...
...
@@ -137,12 +137,12 @@ bool MediaLibrary::createAllTables()
return
true
;
}
bool
MediaLibrary
::
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshot
Path
,
IMediaLibraryCb
*
mlCallback
)
bool
MediaLibrary
::
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
thumbnail
Path
,
IMediaLibraryCb
*
mlCallback
)
{
if
(
m_fsFactory
==
nullptr
)
m_fsFactory
.
reset
(
new
factory
::
FileSystemFactory
);
Folder
::
setFileSystemFactory
(
m_fsFactory
);
m_
snapshotPath
=
snapshot
Path
;
m_
thumbnailPath
=
thumbnail
Path
;
m_callback
=
mlCallback
;
m_dbConnection
.
reset
(
new
SqliteConnection
(
dbPath
)
);
...
...
@@ -434,9 +434,9 @@ bool MediaLibrary::ignoreFolder( const std::string& path )
return
Folder
::
blacklist
(
m_dbConnection
.
get
(),
path
);
}
const
std
::
string
&
MediaLibrary
::
snapshot
Path
()
const
const
std
::
string
&
MediaLibrary
::
thumbnail
Path
()
const
{
return
m_
snapshot
Path
;
return
m_
thumbnail
Path
;
}
void
MediaLibrary
::
setLogger
(
ILogger
*
logger
)
...
...
src/MediaLibrary.h
View file @
1f9548c2
...
...
@@ -46,7 +46,7 @@ class MediaLibrary : public IMediaLibrary
public:
MediaLibrary
();
~
MediaLibrary
();
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
snapshot
Path
,
IMediaLibraryCb
*
metadataCb
)
override
;
virtual
bool
initialize
(
const
std
::
string
&
dbPath
,
const
std
::
string
&
thumbnail
Path
,
IMediaLibraryCb
*
metadataCb
)
override
;
virtual
void
setVerbosity
(
LogLevel
v
)
override
;
virtual
void
setFsFactory
(
std
::
shared_ptr
<
factory
::
IFileSystem
>
fsFactory
)
override
;
...
...
@@ -81,7 +81,7 @@ class MediaLibrary : public IMediaLibrary
virtual
void
discover
(
const
std
::
string
&
entryPoint
)
override
;
bool
ignoreFolder
(
const
std
::
string
&
path
)
override
;
virtual
const
std
::
string
&
snapshot
Path
()
const
override
;
virtual
const
std
::
string
&
thumbnail
Path
()
const
override
;
virtual
void
setLogger
(
ILogger
*
logger
)
override
;
//Temporarily public, move back to private as soon as we start monitoring the FS
virtual
void
reload
()
override
;
...
...
@@ -106,7 +106,7 @@ class MediaLibrary : public IMediaLibrary
protected:
std
::
unique_ptr
<
SqliteConnection
>
m_dbConnection
;
std
::
shared_ptr
<
factory
::
IFileSystem
>
m_fsFactory
;
std
::
string
m_
snapshot
Path
;
std
::
string
m_
thumbnail
Path
;
IMediaLibraryCb
*
m_callback
;
// This probably qualifies as a work around, but we need to keep the VLC::Instance
...
...
src/metadata_services/vlc/VLCMetadataService.cpp
View file @
1f9548c2
...
...
@@ -187,7 +187,7 @@ bool VLCMetadataService::parseAudioFile( std::shared_ptr<Media> media, VLC::Medi
auto
cover
=
vlcMedia
.
meta
(
libvlc_meta_ArtworkURL
);
if
(
cover
.
empty
()
==
false
)
media
->
set
Snapshot
(
cover
);
media
->
set
Thumbnail
(
cover
);
auto
artists
=
handleArtists
(
media
,
vlcMedia
);
auto
album
=
handleAlbum
(
media
,
vlcMedia
,
artists
.
first
.
get
(),
artists
.
second
.
get
()
);
...
...
@@ -448,7 +448,7 @@ bool VLCMetadataService::link( std::shared_ptr<Media> media, std::shared_ptr<Alb
albumArtist
=
Artist
::
fetch
(
m_dbConn
,
medialibrary
::
UnknownArtistID
);
}
// We might modify albumArtist later, hence handle
snapshot
s before.
// We might modify albumArtist later, hence handle
thumbnail
s before.
// If we have an albumArtist (meaning the track was properly tagged, we
// can assume this artist is a correct match. We can use the thumbnail from
// the current album for the albumArtist, if none has been set before.
...
...
src/metadata_services/vlc/VLCThumbnailer.cpp
View file @
1f9548c2
...
...
@@ -48,7 +48,7 @@ VLCThumbnailer::VLCThumbnailer(const VLC::Instance &vlc)
#ifdef WITH_EVAS
,
m_canvas
(
nullptr
,
&
evas_free
)
#endif
,
m_
snapshot
Required
(
false
)
,
m_
thumbnail
Required
(
false
)
,
m_width
(
0
)
,
m_height
(
0
)
,
m_prevSize
(
0
)
...
...
@@ -114,9 +114,9 @@ void VLCThumbnailer::run(std::shared_ptr<Media> file, void *data )
m_cb
->
done
(
file
,
Status
::
Success
,
data
);
return
;
}
else
if
(
file
->
snapshot
().
empty
()
==
false
)
else
if
(
file
->
thumbnail
().
empty
()
==
false
)
{
LOG_INFO
(
file
->
snapshot
(),
" already has a snapshot
"
);
LOG_INFO
(
file
->
thumbnail
(),
" already has a thumbnail
"
);
m_cb
->
done
(
file
,
Status
::
Success
,
data
);
return
;
}
...
...
@@ -140,7 +140,7 @@ void VLCThumbnailer::run(std::shared_ptr<Media> file, void *data )
LOG_WARN
(
"Failed to generate "
,
file
->
mrl
(),
" thumbnail"
);
return
;
}
take
Snapshot
(
file
,
mp
,
data
);
take
Thumbnail
(
file
,
mp
,
data
);
LOG_INFO
(
"Done generating "
,
file
->
mrl
(),
" thumbnail"
);
}
...
...
@@ -233,7 +233,7 @@ void VLCThumbnailer::setupVout( VLC::MediaPlayer& mp )
//unlock
[
this
](
void
*
,
void
*
const
*
)
{
bool
expected
=
true
;
if
(
m_
snapshot
Required
.
compare_exchange_strong
(
expected
,
false
)
)
if
(
m_
thumbnail
Required
.
compare_exchange_strong
(
expected
,
false
)
)
{
m_cond
.
notify_all
();
}
...
...
@@ -244,15 +244,15 @@ void VLCThumbnailer::setupVout( VLC::MediaPlayer& mp )
);
}
bool
VLCThumbnailer
::
take
Snapshot
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
)
bool
VLCThumbnailer
::
take
Thumbnail
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
)
{
// lock, signal that we want a
snapshot
, and wait.
// lock, signal that we want a
thumbnail
, and wait.
{
std
::
unique_lock
<
std
::
mutex
>
lock
(
m_mutex
);
m_
snapshot
Required
=
true
;
m_
thumbnail
Required
=
true
;
bool
success
=
m_cond
.
wait_for
(
lock
,
std
::
chrono
::
seconds
(
3
),
[
this
]()
{
// Keep waiting if the vmem thread hasn't restored m_
snapshot
Required to false
return
m_
snapshot
Required
==
false
;
// Keep waiting if the vmem thread hasn't restored m_
thumbnail
Required to false
return
m_
thumbnail
Required
==
false
;
});
if
(
success
==
false
)
{
...
...
@@ -283,7 +283,7 @@ struct jpegError : public jpeg_error_mgr
bool
VLCThumbnailer
::
compress
(
std
::
shared_ptr
<
Media
>
file
,
void
*
data
)
{
auto
path
=
m_ml
->
snapshot
Path
();
auto
path
=
m_ml
->
thumbnail
Path
();
path
+=
"/"
;
path
+=
std
::
to_string
(
file
->
id
()
)
+
#ifdef WITH_EVAS
...
...
@@ -301,7 +301,7 @@ bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
auto
fOut
=
std
::
unique_ptr
<
FILE
,
int
(
*
)(
FILE
*
)
>
(
fopen
(
path
.
c_str
(),
"wb"
),
&
fclose
);
if
(
fOut
==
nullptr
)
{
LOG_ERROR
(
"Failed to open
snapshot
file "
,
path
);
LOG_ERROR
(
"Failed to open
thumbnail
file "
,
path
);
m_cb
->
done
(
file
,
Status
::
Error
,
data
);
return
false
;
}
...
...
@@ -368,7 +368,7 @@ bool VLCThumbnailer::compress( std::shared_ptr<Media> file, void *data )
#error FIXME
#endif
file
->
set
Snapshot
(
path
);
file
->
set
Thumbnail
(
path
);
if
(
file
->
save
()
==
false
)
m_cb
->
done
(
file
,
Status
::
Error
,
data
);
else
...
...
src/metadata_services/vlc/VLCThumbnailer.h
View file @
1f9548c2
...
...
@@ -55,7 +55,7 @@ private:
bool
startPlayback
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
);
bool
seekAhead
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
);
void
setupVout
(
VLC
::
MediaPlayer
&
mp
);
bool
take
Snapshot
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
);
bool
take
Thumbnail
(
std
::
shared_ptr
<
Media
>
file
,
VLC
::
MediaPlayer
&
mp
,
void
*
data
);
bool
compress
(
std
::
shared_ptr
<
Media
>
file
,
void
*
data
);
private:
...
...
@@ -70,13 +70,13 @@ private:
MediaLibrary
*
m_ml
;
std
::
mutex
m_mutex
;
std
::
condition_variable
m_cond
;
// Per
snapshot
variables
// Per
thumbnail
variables
#ifdef WITH_EVAS
std
::
unique_ptr
<
Evas
,
void
(
*
)(
Evas
*
)
>
m_canvas
;
std
::
unique_ptr
<
uint8_t
[]
>
m_cropBuffer
;
#endif
std
::
unique_ptr
<
uint8_t
[]
>
m_buff
;
std
::
atomic_bool
m_
snapshot
Required
;
std
::
atomic_bool
m_
thumbnail
Required
;
uint32_t
m_width
;
uint32_t
m_height
;
uint32_t
m_prevSize
;
...
...
test/samples/Tester.cpp
View file @
1f9548c2
...
...
@@ -127,7 +127,7 @@ void Tests::checkMedias(const rapidjson::Value& expectedMedias)
if
(
expectedMedia
.
HasMember
(
"snapshotExpected"
)
==
true
)
{
auto
snapshotExpected
=
expectedMedia
[
"snapshotExpected"
].
GetBool
();
ASSERT_EQ
(
!
snapshotExpected
,
media
->
snapshot
().
empty
()
);
ASSERT_EQ
(
!
snapshotExpected
,
media
->
thumbnail
().
empty
()
);
}
}
}
...
...
test/unittest/MediaTests.cpp
View file @
1f9548c2
...
...
@@ -127,21 +127,21 @@ TEST_F( Medias, Artist )
ASSERT_EQ
(
f2
->
artist
(),
newArtist
);
}
TEST_F
(
Medias
,
Snapshot
)
TEST_F
(
Medias
,
Thumbnail
)
{
auto
f
=
ml
->
addFile
(
"media.avi"
);
ASSERT_EQ
(
f
->
snapshot
(),
""
);
ASSERT_EQ
(
f
->
thumbnail
(),
""
);
std
::
string
new
Snapshot
(
"/path/to/snapshot
"
);
std
::
string
new
Thumbnail
(
"/path/to/thumbnail
"
);
f
->
set
Snapshot
(
newSnapshot
);
f
->
set
Thumbnail
(
newThumbnail
);
f
->
save
();
ASSERT_EQ
(
f
->
snapshot
(),
newSnapshot
);
ASSERT_EQ
(
f
->
thumbnail
(),
newThumbnail
);
Reload
();
auto
f2
=
ml
->
media
(
f
->
id
()
);
ASSERT_EQ
(
f2
->
snapshot
(),
newSnapshot
);
ASSERT_EQ
(
f2
->
thumbnail
(),
newThumbnail
);
}
TEST_F
(
Medias
,
PlayCount
)
...
...
test/unittest/ShowTests.cpp
View file @
1f9548c2
...
...
@@ -152,9 +152,9 @@ TEST_F( Shows, SetEpisodeArtwork )
{
auto
show
=
ml
->
createShow
(
"show"
);
auto
e
=
show
->
addEpisode
(
"episode 1"
,
1
);
bool
res
=
e
->
setArtworkUrl
(
"path-to-
snapsho
t"
);
bool
res
=
e
->
setArtworkUrl
(
"path-to-
ar
t"
);
ASSERT_TRUE
(
res
);
ASSERT_EQ
(
e
->
artworkUrl
(),
"path-to-
snapsho
t"
);
ASSERT_EQ
(
e
->
artworkUrl
(),
"path-to-
ar
t"
);
Reload
();
...
...
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