Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
VideoLAN
medialibrary
Commits
329e15d0
Commit
329e15d0
authored
Oct 16, 2015
by
Hugo Beauzée-Luyssen
Browse files
Rename IFile/File to IMedia/Media
parent
7c56df4c
Changes
42
Hide whitespace changes
Inline
Side-by-side
include/IAlbumTrack.h
View file @
329e15d0
...
...
@@ -39,7 +39,7 @@ class IAlbumTrack
virtual
std
::
shared_ptr
<
IAlbum
>
album
()
=
0
;
virtual
bool
addArtist
(
ArtistPtr
artist
)
=
0
;
virtual
std
::
vector
<
ArtistPtr
>
artists
()
const
=
0
;
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
};
#endif // IALBUMTRACK_H
include/IFolder.h
View file @
329e15d0
...
...
@@ -33,7 +33,7 @@ public:
virtual
unsigned
int
id
()
const
=
0
;
virtual
const
std
::
string
&
path
()
=
0
;
// This will only returns the files in this immediate folder
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
FolderPtr
>
folders
()
=
0
;
virtual
unsigned
int
lastModificationDate
()
=
0
;
virtual
bool
isRemovable
()
=
0
;
...
...
include/ILabel.h
View file @
329e15d0
...
...
@@ -35,7 +35,7 @@ class ILabel
virtual
unsigned
int
id
()
const
=
0
;
virtual
const
std
::
string
&
name
()
=
0
;
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
};
#endif // ILABEL_H
include/I
File
.h
→
include/I
Media
.h
View file @
329e15d0
...
...
@@ -32,7 +32,7 @@ class IAlbumTrack;
class
IShowEpisode
;
class
ITrackInformation
;
class
I
File
class
I
Media
{
public:
enum
class
Type
:
uint8_t
...
...
@@ -41,7 +41,7 @@ class IFile
AudioType
,
// Any kind of audio file, not being an album track
UnknownType
};
virtual
~
I
File
()
{}
virtual
~
I
Media
()
{}
virtual
unsigned
int
id
()
const
=
0
;
virtual
Type
type
()
=
0
;
...
...
include/IMediaLibrary.h
View file @
329e15d0
...
...
@@ -41,12 +41,12 @@ public:
* available yet.
* @param file
*/
virtual
void
onFileAdded
(
File
Ptr
file
)
=
0
;
virtual
void
onFileAdded
(
Media
Ptr
file
)
=
0
;
/**
* @brief onFileUpdated Will be called when a file metadata gets updated.
* @param file The updated file.
*/
virtual
void
onFileUpdated
(
File
Ptr
file
)
=
0
;
virtual
void
onFileUpdated
(
Media
Ptr
file
)
=
0
;
virtual
void
onDiscoveryStarted
(
const
std
::
string
&
entryPoint
)
=
0
;
virtual
void
onDiscoveryCompleted
(
const
std
::
string
&
entryPoint
)
=
0
;
...
...
@@ -79,9 +79,9 @@ class IMediaLibrary
/// a stand alone file.
/// \return The newly created file, or nullptr in case of error
///
virtual
File
Ptr
file
(
const
std
::
string
&
path
)
=
0
;
virtual
Media
Ptr
file
(
const
std
::
string
&
path
)
=
0
;
virtual
bool
deleteFile
(
const
std
::
string
&
mrl
)
=
0
;
virtual
bool
deleteFile
(
File
Ptr
file
)
=
0
;
virtual
bool
deleteFile
(
Media
Ptr
file
)
=
0
;
/// Adds a folder and all the files it contains
virtual
FolderPtr
folder
(
const
std
::
string
&
path
)
=
0
;
...
...
@@ -90,9 +90,9 @@ class IMediaLibrary
virtual
LabelPtr
createLabel
(
const
std
::
string
&
label
)
=
0
;
virtual
bool
deleteLabel
(
const
std
::
string
&
label
)
=
0
;
virtual
bool
deleteLabel
(
LabelPtr
label
)
=
0
;
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
File
Ptr
>
audioFiles
()
=
0
;
virtual
std
::
vector
<
File
Ptr
>
videoFiles
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
audioFiles
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
videoFiles
()
=
0
;
virtual
AlbumPtr
album
(
const
std
::
string
&
title
)
=
0
;
virtual
std
::
vector
<
AlbumPtr
>
albums
()
=
0
;
virtual
ShowPtr
show
(
const
std
::
string
&
name
)
=
0
;
...
...
include/IMetadataService.h
View file @
329e15d0
...
...
@@ -24,7 +24,7 @@
#define IMETADATASERVICE_H
#include
"IMediaLibrary.h"
#include
"
File
.h"
#include
"
Media
.h"
class
MediaLibrary
;
...
...
@@ -32,7 +32,7 @@ class IMetadataServiceCb
{
public:
virtual
~
IMetadataServiceCb
(){}
virtual
void
done
(
std
::
shared_ptr
<
File
>
file
,
ServiceStatus
status
,
void
*
data
)
=
0
;
virtual
void
done
(
std
::
shared_ptr
<
Media
>
file
,
ServiceStatus
status
,
void
*
data
)
=
0
;
};
class
IMetadataService
...
...
@@ -41,7 +41,7 @@ class IMetadataService
virtual
~
IMetadataService
()
=
default
;
virtual
bool
initialize
(
IMetadataServiceCb
*
callback
,
MediaLibrary
*
ml
)
=
0
;
virtual
unsigned
int
priority
()
const
=
0
;
virtual
bool
run
(
std
::
shared_ptr
<
File
>
file
,
void
*
data
)
=
0
;
virtual
bool
run
(
std
::
shared_ptr
<
Media
>
file
,
void
*
data
)
=
0
;
};
#endif // IMETADATASERVICE_H
include/IMovie.h
View file @
329e15d0
...
...
@@ -35,7 +35,7 @@ class IMovie
virtual
const
std
::
string
&
shortSummary
()
const
=
0
;
virtual
const
std
::
string
&
artworkUrl
()
const
=
0
;
virtual
const
std
::
string
&
imdbId
()
const
=
0
;
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
};
#endif // IMOVIE_H
include/IShowEpisode.h
View file @
329e15d0
...
...
@@ -41,7 +41,7 @@ class IShowEpisode
virtual
const
std
::
string
&
shortSummary
()
const
=
0
;
virtual
const
std
::
string
&
tvdbId
()
const
=
0
;
virtual
std
::
shared_ptr
<
IShow
>
show
()
=
0
;
virtual
std
::
vector
<
File
Ptr
>
files
()
=
0
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
=
0
;
};
#endif // ISHOWEPISODE_H
include/Types.h
View file @
329e15d0
...
...
@@ -29,7 +29,7 @@ class IAlbum;
class
IAlbumTrack
;
class
IAudioTrack
;
class
IDiscoverer
;
class
I
File
;
class
I
Media
;
class
IFolder
;
class
ILabel
;
class
IMetadataService
;
...
...
@@ -41,7 +41,7 @@ class ILogger;
class
IArtist
;
class
SqliteConnection
;
typedef
std
::
shared_ptr
<
I
File
>
File
Ptr
;
typedef
std
::
shared_ptr
<
I
Media
>
Media
Ptr
;
typedef
std
::
shared_ptr
<
IFolder
>
FolderPtr
;
typedef
std
::
shared_ptr
<
ILabel
>
LabelPtr
;
typedef
std
::
shared_ptr
<
IAlbum
>
AlbumPtr
;
...
...
src/AlbumTrack.cpp
View file @
329e15d0
...
...
@@ -23,7 +23,7 @@
#include
"AlbumTrack.h"
#include
"Album.h"
#include
"Artist.h"
#include
"
File
.h"
#include
"
Media
.h"
#include
"database/SqliteTools.h"
#include
"logging/Logger.h"
...
...
@@ -134,7 +134,7 @@ bool AlbumTrack::destroy()
{
// Ignore failures to discard from cache, we might want to discard records from
// cache in a near future to avoid running out of memory on mobile devices
File
::
discard
(
std
::
static_pointer_cast
<
File
>
(
f
)
);
Media
::
discard
(
std
::
static_pointer_cast
<
Media
>
(
f
)
);
}
return
_Cache
::
destroy
(
m_dbConnection
,
this
);
}
...
...
@@ -155,9 +155,9 @@ std::vector<ArtistPtr> AlbumTrack::artists() const
return
Artist
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
std
::
vector
<
File
Ptr
>
AlbumTrack
::
files
()
std
::
vector
<
Media
Ptr
>
AlbumTrack
::
files
()
{
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
File
Table
::
Name
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
Media
Table
::
Name
+
" WHERE album_track_id = ? "
;
return
File
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
return
Media
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
src/AlbumTrack.h
View file @
329e15d0
...
...
@@ -60,7 +60,7 @@ class AlbumTrack : public IAlbumTrack, public Cache<AlbumTrack, IAlbumTrack, pol
virtual
bool
destroy
();
virtual
bool
addArtist
(
ArtistPtr
artist
)
override
;
virtual
std
::
vector
<
ArtistPtr
>
artists
()
const
override
;
virtual
std
::
vector
<
File
Ptr
>
files
();
virtual
std
::
vector
<
Media
Ptr
>
files
();
static
bool
createTable
(
DBConnection
dbConnection
);
static
std
::
shared_ptr
<
AlbumTrack
>
create
(
DBConnection
dbConnection
,
unsigned
int
albumId
,
...
...
src/CMakeLists.txt
View file @
329e15d0
...
...
@@ -22,7 +22,7 @@ list(APPEND HEADERS_LIST
${
CMAKE_SOURCE_DIR
}
/include/IShowEpisode.h
${
CMAKE_SOURCE_DIR
}
/include/IAlbum.h
${
CMAKE_SOURCE_DIR
}
/include/IAlbumTrack.h
${
CMAKE_SOURCE_DIR
}
/include/I
File
.h
${
CMAKE_SOURCE_DIR
}
/include/I
Media
.h
${
CMAKE_SOURCE_DIR
}
/include/IFolder.h
${
CMAKE_SOURCE_DIR
}
/include/IMediaLibrary.h
${
CMAKE_SOURCE_DIR
}
/include/ILabel.h
...
...
@@ -53,7 +53,7 @@ include_directories("${CMAKE_SOURCE_DIR}/src")
list
(
APPEND SRC_LIST
${
HEADERS_LIST
}
MediaLibrary.cpp
File
.cpp
Media
.cpp
Folder.cpp
Album.cpp
Show.cpp
...
...
src/Folder.cpp
View file @
329e15d0
...
...
@@ -21,7 +21,7 @@
*****************************************************************************/
#include
"Folder.h"
#include
"
File
.h"
#include
"
Media
.h"
#include
"database/SqliteTools.h"
#include
"filesystem/IDirectory.h"
...
...
@@ -100,11 +100,11 @@ const std::string& Folder::path()
return
m_path
;
}
std
::
vector
<
File
Ptr
>
Folder
::
files
()
std
::
vector
<
Media
Ptr
>
Folder
::
files
()
{
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
File
Table
::
Name
+
static
const
std
::
string
req
=
"SELECT * FROM "
+
policy
::
Media
Table
::
Name
+
" WHERE folder_id = ?"
;
return
File
::
fetchAll
(
m_dbConection
,
req
,
m_id
);
return
Media
::
fetchAll
(
m_dbConection
,
req
,
m_id
);
}
std
::
vector
<
FolderPtr
>
Folder
::
folders
()
...
...
src/Folder.h
View file @
329e15d0
...
...
@@ -65,7 +65,7 @@ public:
virtual
unsigned
int
id
()
const
override
;
virtual
const
std
::
string
&
path
()
override
;
virtual
std
::
vector
<
File
Ptr
>
files
()
override
;
virtual
std
::
vector
<
Media
Ptr
>
files
()
override
;
virtual
std
::
vector
<
FolderPtr
>
folders
()
override
;
virtual
FolderPtr
parent
()
override
;
virtual
unsigned
int
lastModificationDate
()
override
;
...
...
src/Label.cpp
View file @
329e15d0
...
...
@@ -25,7 +25,7 @@
#include
<cstring>
#include
"Label.h"
#include
"
File
.h"
#include
"
Media
.h"
#include
"database/SqliteTools.h"
const
std
::
string
policy
::
LabelTable
::
Name
=
"Label"
;
...
...
@@ -55,12 +55,12 @@ const std::string& Label::name()
return
m_name
;
}
std
::
vector
<
File
Ptr
>
Label
::
files
()
std
::
vector
<
Media
Ptr
>
Label
::
files
()
{
static
const
std
::
string
req
=
"SELECT f.* FROM "
+
policy
::
File
Table
::
Name
+
" f "
static
const
std
::
string
req
=
"SELECT f.* FROM "
+
policy
::
Media
Table
::
Name
+
" f "
"LEFT JOIN LabelFileRelation lfr ON lfr.id_file = f.id_file "
"WHERE lfr.id_label = ?"
;
return
File
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
return
Media
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
LabelPtr
Label
::
create
(
DBConnection
dbConnection
,
const
std
::
string
&
name
)
...
...
src/Label.h
View file @
329e15d0
...
...
@@ -26,7 +26,7 @@
#include
<sqlite3.h>
#include
<string>
class
File
;
class
Media
;
class
Label
;
#include
"ILabel.h"
...
...
@@ -61,7 +61,7 @@ class Label : public ILabel, public Cache<Label, ILabel, policy::LabelTable, pol
public:
virtual
unsigned
int
id
()
const
;
virtual
const
std
::
string
&
name
();
virtual
std
::
vector
<
File
Ptr
>
files
();
virtual
std
::
vector
<
Media
Ptr
>
files
();
static
LabelPtr
create
(
DBConnection
dbConnection
,
const
std
::
string
&
name
);
static
bool
createTable
(
DBConnection
dbConnection
);
...
...
src/
File
.cpp
→
src/
Media
.cpp
View file @
329e15d0
...
...
@@ -28,7 +28,7 @@
#include
"Album.h"
#include
"AlbumTrack.h"
#include
"AudioTrack.h"
#include
"
File
.h"
#include
"
Media
.h"
#include
"Folder.h"
#include
"Label.h"
#include
"logging/Logger.h"
...
...
@@ -38,11 +38,11 @@
#include
"VideoTrack.h"
#include
"filesystem/IFile.h"
const
std
::
string
policy
::
File
Table
::
Name
=
"
File
"
;
const
std
::
string
policy
::
File
Table
::
CacheColumn
=
"mrl"
;
unsigned
int
File
::*
const
policy
::
File
Table
::
PrimaryKey
=
&
File
::
m_id
;
const
std
::
string
policy
::
Media
Table
::
Name
=
"
Media
"
;
const
std
::
string
policy
::
Media
Table
::
CacheColumn
=
"mrl"
;
unsigned
int
Media
::*
const
policy
::
Media
Table
::
PrimaryKey
=
&
Media
::
m_id
;
File
::
File
(
DBConnection
dbConnection
,
sqlite3_stmt
*
stmt
)
Media
::
Media
(
DBConnection
dbConnection
,
sqlite3_stmt
*
stmt
)
:
m_dbConnection
(
dbConnection
)
{
m_id
=
sqlite3_column_int
(
stmt
,
0
);
...
...
@@ -60,7 +60,7 @@ File::File( DBConnection dbConnection, sqlite3_stmt* stmt )
m_name
=
sqlite
::
Traits
<
std
::
string
>::
Load
(
stmt
,
12
);
}
File
::
File
(
const
fs
::
IFile
*
file
,
unsigned
int
folderId
,
const
std
::
string
&
name
,
Type
type
)
Media
::
Media
(
const
fs
::
IFile
*
file
,
unsigned
int
folderId
,
const
std
::
string
&
name
,
Type
type
)
:
m_id
(
0
)
,
m_type
(
type
)
,
m_duration
(
-
1
)
...
...
@@ -76,10 +76,10 @@ File::File( const fs::IFile* file, unsigned int folderId, const std::string& nam
{
}
std
::
shared_ptr
<
File
>
File
::
create
(
DBConnection
dbConnection
,
Type
type
,
const
fs
::
IFile
*
file
,
unsigned
int
folderId
)
std
::
shared_ptr
<
Media
>
Media
::
create
(
DBConnection
dbConnection
,
Type
type
,
const
fs
::
IFile
*
file
,
unsigned
int
folderId
)
{
auto
self
=
std
::
make_shared
<
File
>
(
file
,
folderId
,
file
->
name
(),
type
);
static
const
std
::
string
req
=
"INSERT INTO "
+
policy
::
File
Table
::
Name
+
auto
self
=
std
::
make_shared
<
Media
>
(
file
,
folderId
,
file
->
name
(),
type
);
static
const
std
::
string
req
=
"INSERT INTO "
+
policy
::
Media
Table
::
Name
+
"(type, mrl, folder_id, last_modification_date, name) VALUES(?, ?, ?, ?, ?)"
;
using
type_t
=
std
::
underlying_type
<
Type
>::
type
;
...
...
@@ -90,7 +90,7 @@ std::shared_ptr<File> File::create( DBConnection dbConnection, Type type, const
return
self
;
}
AlbumTrackPtr
File
::
albumTrack
()
AlbumTrackPtr
Media
::
albumTrack
()
{
if
(
m_albumTrack
==
nullptr
&&
m_albumTrackId
!=
0
)
{
...
...
@@ -99,10 +99,10 @@ AlbumTrackPtr File::albumTrack()
return
m_albumTrack
;
}
bool
File
::
setAlbumTrack
(
AlbumTrackPtr
albumTrack
)
bool
Media
::
setAlbumTrack
(
AlbumTrackPtr
albumTrack
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET album_track_id = ? "
"WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET album_track_id = ? "
"WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
albumTrack
->
id
(),
m_id
)
==
false
)
return
false
;
m_albumTrackId
=
albumTrack
->
id
();
...
...
@@ -110,22 +110,22 @@ bool File::setAlbumTrack( AlbumTrackPtr albumTrack )
return
true
;
}
int64_t
File
::
duration
()
const
int64_t
Media
::
duration
()
const
{
return
m_duration
;
}
bool
File
::
setDuration
(
int64_t
duration
)
bool
Media
::
setDuration
(
int64_t
duration
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET duration = ? "
"WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET duration = ? "
"WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
duration
,
m_id
)
==
false
)
return
false
;
m_duration
=
duration
;
return
true
;
}
std
::
shared_ptr
<
IShowEpisode
>
File
::
showEpisode
()
std
::
shared_ptr
<
IShowEpisode
>
Media
::
showEpisode
()
{
if
(
m_showEpisode
==
nullptr
&&
m_showEpisodeId
!=
0
)
{
...
...
@@ -134,10 +134,10 @@ std::shared_ptr<IShowEpisode> File::showEpisode()
return
m_showEpisode
;
}
bool
File
::
setShowEpisode
(
ShowEpisodePtr
showEpisode
)
bool
Media
::
setShowEpisode
(
ShowEpisodePtr
showEpisode
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET show_episode_id = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET show_episode_id = ? WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
showEpisode
->
id
(),
m_id
)
==
false
)
return
false
;
m_showEpisodeId
=
showEpisode
->
id
();
...
...
@@ -145,25 +145,25 @@ bool File::setShowEpisode(ShowEpisodePtr showEpisode)
return
true
;
}
std
::
vector
<
std
::
shared_ptr
<
ILabel
>
>
File
::
labels
()
std
::
vector
<
std
::
shared_ptr
<
ILabel
>
>
Media
::
labels
()
{
static
const
std
::
string
req
=
"SELECT l.* FROM "
+
policy
::
LabelTable
::
Name
+
" l "
"LEFT JOIN LabelFileRelation lfr ON lfr.id_label = l.id_label "
"WHERE lfr.id_
file
= ?"
;
"WHERE lfr.id_
media
= ?"
;
return
Label
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
int
File
::
playCount
()
const
int
Media
::
playCount
()
const
{
return
m_playCount
;
}
const
std
::
string
&
File
::
mrl
()
const
const
std
::
string
&
Media
::
mrl
()
const
{
return
m_mrl
;
}
MoviePtr
File
::
movie
()
MoviePtr
Media
::
movie
()
{
if
(
m_movie
==
nullptr
&&
m_movieId
!=
0
)
{
...
...
@@ -172,10 +172,10 @@ MoviePtr File::movie()
return
m_movie
;
}
bool
File
::
setMovie
(
MoviePtr
movie
)
bool
Media
::
setMovie
(
MoviePtr
movie
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET movie_id = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET movie_id = ? WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
movie
->
id
(),
m_id
)
==
false
)
return
false
;
m_movie
=
movie
;
...
...
@@ -183,7 +183,7 @@ bool File::setMovie( MoviePtr movie )
return
true
;
}
bool
File
::
addVideoTrack
(
const
std
::
string
&
codec
,
unsigned
int
width
,
unsigned
int
height
,
float
fps
)
bool
Media
::
addVideoTrack
(
const
std
::
string
&
codec
,
unsigned
int
width
,
unsigned
int
height
,
float
fps
)
{
static
const
std
::
string
req
=
"INSERT INTO VideoTrackFileRelation VALUES(?, ?)"
;
...
...
@@ -197,15 +197,15 @@ bool File::addVideoTrack(const std::string& codec, unsigned int width, unsigned
return
sqlite
::
Tools
::
executeRequest
(
m_dbConnection
,
req
,
track
->
id
(),
m_id
);
}
std
::
vector
<
VideoTrackPtr
>
File
::
videoTracks
()
std
::
vector
<
VideoTrackPtr
>
Media
::
videoTracks
()
{
static
const
std
::
string
req
=
"SELECT t.* FROM "
+
policy
::
VideoTrackTable
::
Name
+
" t LEFT JOIN VideoTrackFileRelation vtfr ON vtfr.id_track = t.id_track"
" WHERE vtfr.id_
file
= ?"
;
" WHERE vtfr.id_
media
= ?"
;
return
VideoTrack
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
bool
File
::
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
bool
Media
::
addAudioTrack
(
const
std
::
string
&
codec
,
unsigned
int
bitrate
,
unsigned
int
sampleRate
,
unsigned
int
nbChannels
)
{
static
const
std
::
string
req
=
"INSERT INTO AudioTrackFileRelation VALUES(?, ?)"
;
...
...
@@ -220,70 +220,70 @@ bool File::addAudioTrack( const std::string& codec, unsigned int bitrate,
return
sqlite
::
Tools
::
executeRequest
(
m_dbConnection
,
req
,
track
->
id
(),
m_id
);
}
std
::
vector
<
AudioTrackPtr
>
File
::
audioTracks
()
std
::
vector
<
AudioTrackPtr
>
Media
::
audioTracks
()
{
static
const
std
::
string
req
=
"SELECT t.* FROM "
+
policy
::
AudioTrackTable
::
Name
+
" t LEFT JOIN AudioTrackFileRelation atfr ON atfr.id_track = t.id_track"
" WHERE atfr.id_
file
= ?"
;
" WHERE atfr.id_
media
= ?"
;
return
AudioTrack
::
fetchAll
(
m_dbConnection
,
req
,
m_id
);
}
const
std
::
string
&
File
::
snapshot
()
const
std
::
string
&
Media
::
snapshot
()
{
return
m_snapshot
;
}
bool
File
::
setSnapshot
(
const
std
::
string
&
snapshot
)
bool
Media
::
setSnapshot
(
const
std
::
string
&
snapshot
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET snapshot = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET snapshot = ? WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
snapshot
,
m_id
)
==
false
)
return
false
;
m_snapshot
=
snapshot
;
return
true
;
}
bool
File
::
isStandAlone
()
bool
Media
::
isStandAlone
()
{
return
m_folderId
==
0
;
}
unsigned
int
File
::
lastModificationDate
()
unsigned
int
Media
::
lastModificationDate
()
{
return
m_lastModificationDate
;
}
bool
File
::
isParsed
()
const
bool
Media
::
isParsed
()
const
{
return
m_isParsed
;
}
bool
File
::
markParsed
()
bool
Media
::
markParsed
()
{
if
(
m_isParsed
==
true
)
return
true
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET parsed = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET parsed = ? WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
true
,
m_id
)
==
false
)
return
false
;
m_isParsed
=
true
;
return
true
;
}
unsigned
int
File
::
id
()
const
unsigned
int
Media
::
id
()
const
{
return
m_id
;
}
I
File
::
Type
File
::
type
()
I
Media
::
Type
Media
::
type
()
{
return
m_type
;
}
bool
File
::
setType
(
Type
type
)
bool
Media
::
setType
(
Type
type
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET type = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET type = ? WHERE id_
media
= ?"
;
// We need to convert to an integer representation for the sqlite traits to work properly
using
type_t
=
std
::
underlying_type
<
Type
>::
type
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
static_cast
<
type_t
>
(
type
),
m_id
)
==
false
)
...
...
@@ -292,25 +292,25 @@ bool File::setType( Type type )
return
true
;
}
const
std
::
string
&
File
::
name
()
const
std
::
string
&
Media
::
name
()
{
return
m_name
;
}
bool
File
::
setName
(
const
std
::
string
&
name
)
bool
Media
::
setName
(
const
std
::
string
&
name
)
{
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
File
Table
::
Name
+
" SET name = ? WHERE id_
file
= ?"
;
static
const
std
::
string
req
=
"UPDATE "
+
policy
::
Media
Table
::
Name
+
" SET name = ? WHERE id_
media
= ?"
;
if
(
sqlite
::
Tools
::
executeUpdate
(
m_dbConnection
,
req
,
name
,
m_id
)
==
false
)
return
false
;
m_name
=
name
;
return
true
;
}
bool
File
::
createTable
(
DBConnection
connection
)
bool
Media
::
createTable
(
DBConnection
connection
)
{
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
File
Table
::
Name
+
"("
"id_
file
INTEGER PRIMARY KEY AUTOINCREMENT,"
std
::
string
req
=
"CREATE TABLE IF NOT EXISTS "
+
policy
::
Media
Table
::
Name
+
"("
"id_
media
INTEGER PRIMARY KEY AUTOINCREMENT,"
"type INTEGER,"
"duration INTEGER,"
"album_track_id UNSIGNED INTEGER,"
...
...
@@ -336,28 +336,28 @@ bool File::createTable( DBConnection connection )
return
false
;
req
=
"CREATE TABLE IF NOT EXISTS VideoTrackFileRelation("
"id_track INTEGER,"
"id_
file
INTEGER,"
"PRIMARY KEY ( id_track, id_
file
), "
"id_
media
INTEGER,"
"PRIMARY KEY ( id_track, id_
media
), "
"FOREIGN KEY ( id_track ) REFERENCES "
+
policy
::
VideoTrackTable
::
Name
+
"(id_track) ON DELETE CASCADE,"
"FOREIGN KEY ( id_
file
) REFERENCES "
+
policy
::
File
Table
::
Name
+
"(id_
file
) ON DELETE CASCADE"
"FOREIGN KEY ( id_
media
) REFERENCES "
+
policy
::
Media
Table
::
Name
+
"(id_
media
) ON DELETE CASCADE"
")"
;
if
(
sqlite
::
Tools
::
executeRequest
(
connection
,
req
)
==
false
)
return
false
;
req
=
"CREATE TABLE IF NOT EXISTS AudioTrackFileRelation("
"id_track INTEGER,"
"id_
file
INTEGER,"
"PRIMARY KEY ( id_track, id_
file
), "
"id_
media
INTEGER,"
"PRIMARY KEY ( id_track, id_
media
), "
"FOREIGN KEY ( id_track ) REFERENCES "
+
policy
::
AudioTrackTable
::
Name
+