Commit ca54535f authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

IMedia: Remove Type suffix from IMedia::Type members

parent 85bbf654
......@@ -39,9 +39,9 @@ class IMedia
public:
enum class Type : uint8_t
{
UnknownType,
VideoType,
AudioType,
Unknown,
Video,
Audio,
};
enum class SubType : uint8_t
{
......
......@@ -305,17 +305,17 @@ MediaPtr MediaLibrary::media( const std::string& mrl ) const
std::vector<MediaPtr> MediaLibrary::audioFiles( SortingCriteria sort, bool desc ) const
{
return Media::listAll( this, IMedia::Type::AudioType, sort, desc );
return Media::listAll( this, IMedia::Type::Audio, sort, desc );
}
std::vector<MediaPtr> MediaLibrary::videoFiles( SortingCriteria sort, bool desc ) const
{
return Media::listAll( this, IMedia::Type::VideoType, sort, desc );
return Media::listAll( this, IMedia::Type::Video, sort, desc );
}
std::shared_ptr<Media> MediaLibrary::addFile( const fs::IFile& fileFs, Folder& parentFolder, fs::IDirectory& parentFolderFs )
{
auto type = IMedia::Type::UnknownType;
auto type = IMedia::Type::Unknown;
auto ext = fileFs.extension();
auto predicate = [ext](const std::string& v) {
return strcasecmp(v.c_str(), ext.c_str()) == 0;
......
......@@ -79,7 +79,7 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
if ( tracks.empty() == true )
{
// However, if the file is not unknown anymore, it means the thumbnailer has already processed it
if ( task.media->type() == Media::Type::UnknownType )
if ( task.media->type() == Media::Type::Unknown )
return parser::Task::Status::Success;
// In that case, stop trying to do something with this file.
return parser::Task::Status::Fatal;
......@@ -139,7 +139,7 @@ parser::Task::Status MetadataParser::run( parser::Task& task )
bool MetadataParser::parseVideoFile( parser::Task& task ) const
{
auto media = task.media.get();
media->setType( IMedia::Type::VideoType );
media->setType( IMedia::Type::Video );
const auto& title = task.vlcMedia.meta( libvlc_meta_Title );
if ( title.length() == 0 )
return true;
......@@ -172,7 +172,7 @@ bool MetadataParser::parseVideoFile( parser::Task& task ) const
bool MetadataParser::parseAudioFile( parser::Task& task ) const
{
task.media->setType( IMedia::Type::AudioType );
task.media->setType( IMedia::Type::Audio );
const auto artworkMrl = task.vlcMedia.meta( libvlc_meta_ArtworkURL );
if ( artworkMrl.empty() == false )
......
......@@ -73,7 +73,7 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
auto media = task.media;
auto file = task.file;
if ( media->type() == IMedia::Type::AudioType )
if ( media->type() == IMedia::Type::Audio )
{
// There's no point in generating a thumbnail for a non-video media.
task.file->markStepCompleted( File::ParserStep::Thumbnailer );
......@@ -112,7 +112,7 @@ parser::Task::Status VLCThumbnailer::run( parser::Task& task )
if ( res != parser::Task::Status::Success )
{
// If the media became an audio file, it's not an error
if ( task.media->type() == Media::Type::AudioType )
if ( task.media->type() == Media::Type::Audio )
{
task.file->markStepCompleted( File::ParserStep::Thumbnailer );
task.file->saveParserStep();
......@@ -179,9 +179,9 @@ parser::Task::Status VLCThumbnailer::startPlayback( parser::Task& task, VLC::Med
return parser::Task::Status::Fatal;
// We are now in the case of a timeout: No failure, but no video track either.
// The file might be an audio file we haven't detected yet:
if ( task.media->type() == Media::Type::UnknownType )
if ( task.media->type() == Media::Type::Unknown )
{
task.media->setType( Media::Type::AudioType );
task.media->setType( Media::Type::Audio );
if ( task.media->save() == false )
return parser::Task::Status::Fatal;
// We still return an error since we don't want to attempt the thumbnail generation for a
......
......@@ -346,17 +346,17 @@ TEST_F( Medias, SortByAlpha )
{
auto m1 = ml->addFile( "media1.mp3" );
m1->setTitle( "Abcd" );
m1->setType( Media::Type::AudioType );
m1->setType( Media::Type::Audio );
m1->save();
auto m2 = ml->addFile( "media2.mp3" );
m2->setTitle( "Zyxw" );
m2->setType( Media::Type::AudioType );
m2->setType( Media::Type::Audio );
m2->save();
auto m3 = ml->addFile( "media3.mp3" );
m3->setTitle( "afterA-beforeZ" );
m3->setType( Media::Type::AudioType );
m3->setType( Media::Type::Audio );
m3->save();
auto media = ml->audioFiles( SortingCriteria::Alpha, false );
......@@ -377,13 +377,13 @@ TEST_F( Medias, SortByLastModifDate )
auto file1 = std::make_shared<mock::NoopFile>( "media.mkv" );
file1->setLastModificationDate( 666 );
auto m1 = ml->addFile( *file1 );
m1->setType( Media::Type::VideoType );
m1->setType( Media::Type::Video );
m1->save();
auto file2 = std::make_shared<mock::NoopFile>( "media2.mkv" );
file2->setLastModificationDate( 111 );
auto m2 = ml->addFile( *file2 );
m2->setType( Media::Type::VideoType );
m2->setType( Media::Type::Video );
m2->save();
auto media = ml->videoFiles( SortingCriteria::LastModificationDate, false );
......@@ -402,13 +402,13 @@ TEST_F( Medias, SortByFileSize )
auto file1 = std::make_shared<mock::NoopFile>( "media.mkv" );
file1->setSize( 666 );
auto m1 = ml->addFile( *file1 );
m1->setType( Media::Type::VideoType );
m1->setType( Media::Type::Video );
m1->save();
auto file2 = std::make_shared<mock::NoopFile>( "media2.mkv" );
file2->setSize( 111 );
auto m2 = ml->addFile( *file2 );
m2->setType( Media::Type::VideoType );
m2->setType( Media::Type::Video );
m2->save();
auto media = ml->videoFiles( SortingCriteria::FileSize, false );
......@@ -425,17 +425,17 @@ TEST_F( Medias, SortByFileSize )
TEST_F( Medias, SetType )
{
auto m1 = ml->addFile( "media1.mp3" );
ASSERT_EQ( IMedia::Type::UnknownType, m1->type() );
ASSERT_EQ( IMedia::Type::Unknown, m1->type() );
m1->setType( IMedia::Type::VideoType );
m1->setType( IMedia::Type::Video );
m1->save();
ASSERT_EQ( IMedia::Type::VideoType, m1->type() );
ASSERT_EQ( IMedia::Type::Video, m1->type() );
Reload();
auto m2 = ml->media( m1->id() );
ASSERT_EQ( IMedia::Type::VideoType, m2->type() );
ASSERT_EQ( IMedia::Type::Video, m2->type() );
}
class FetchMedia : public Tests
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment