2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
22 #include "MusicInfoTagLoaderFactory.h"
23 #include "TagLoaderTagLib.h"
24 #include "MusicInfoTagLoaderCDDA.h"
25 #include "MusicInfoTagLoaderShn.h"
26 #include "MusicInfoTagLoaderWav.h"
28 #include "cores/ModPlayer.h"
30 #include "MusicInfoTagLoaderNSF.h"
31 #include "MusicInfoTagLoaderSPC.h"
32 #include "MusicInfoTagLoaderYM.h"
33 #include "MusicInfoTagLoaderDatabase.h"
34 #include "MusicInfoTagLoaderASAP.h"
35 #include "MusicInfoTagLoaderMidi.h"
36 #include "utils/StringUtils.h"
37 #include "utils/URIUtils.h"
41 #include "cores/paplayer/ASAPCodec.h"
44 using namespace MUSIC_INFO;
46 CMusicInfoTagLoaderFactory::CMusicInfoTagLoaderFactory()
49 CMusicInfoTagLoaderFactory::~CMusicInfoTagLoaderFactory()
52 IMusicInfoTagLoader* CMusicInfoTagLoaderFactory::CreateLoader(const CStdString& strFileName)
54 // dont try to read the tags for streams & shoutcast
55 CFileItem item(strFileName, false);
56 if (item.IsInternetStream())
60 return new CMusicInfoTagLoaderDatabase();
62 CStdString strExtension = URIUtils::GetExtension(strFileName);
63 StringUtils::ToLower(strExtension);
64 StringUtils::TrimLeft(strExtension, ".");
66 if (strExtension.empty())
69 if (strExtension == "aac" ||
70 strExtension == "ape" || strExtension == "mac" ||
71 strExtension == "mp3" ||
72 strExtension == "wma" ||
73 strExtension == "flac" ||
74 strExtension == "m4a" || strExtension == "mp4" ||
75 strExtension == "mpc" || strExtension == "mpp" || strExtension == "mp+" ||
76 strExtension == "ogg" || strExtension == "oga" || strExtension == "oggstream" ||
78 ModPlayer::IsSupportedFormat(strExtension) ||
79 strExtension == "mod" || strExtension == "nsf" || strExtension == "nsfstream" ||
80 strExtension == "s3m" || strExtension == "it" || strExtension == "xm" ||
84 CTagLoaderTagLib *pTagLoader = new CTagLoaderTagLib();
85 return (IMusicInfoTagLoader*)pTagLoader;
88 else if (strExtension == "cdda")
90 CMusicInfoTagLoaderCDDA *pTagLoader = new CMusicInfoTagLoaderCDDA();
91 return (IMusicInfoTagLoader*)pTagLoader;
94 else if (strExtension == "shn")
96 CMusicInfoTagLoaderSHN *pTagLoader = new CMusicInfoTagLoaderSHN();
97 return (IMusicInfoTagLoader*)pTagLoader;
99 else if (strExtension == "wav")
101 CMusicInfoTagLoaderWAV *pTagLoader = new CMusicInfoTagLoaderWAV();
102 return (IMusicInfoTagLoader*)pTagLoader;
104 else if (strExtension == "spc")
106 CMusicInfoTagLoaderSPC *pTagLoader = new CMusicInfoTagLoaderSPC();
107 return (IMusicInfoTagLoader*)pTagLoader;
109 else if (strExtension == "ym")
111 CMusicInfoTagLoaderYM *pTagLoader = new CMusicInfoTagLoaderYM();
112 return (IMusicInfoTagLoader*)pTagLoader;
114 #ifdef HAS_ASAP_CODEC
115 else if (ASAPCodec::IsSupportedFormat(strExtension) || strExtension == "asapstream")
117 CMusicInfoTagLoaderASAP *pTagLoader = new CMusicInfoTagLoaderASAP();
118 return (IMusicInfoTagLoader*)pTagLoader;
121 else if ( TimidityCodec::IsSupportedFormat( strExtension ) )
123 CMusicInfoTagLoaderMidi * pTagLoader = new CMusicInfoTagLoaderMidi();
124 return (IMusicInfoTagLoader*)pTagLoader;