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"
27 #include "cores/ModPlayer.h"
29 #include "MusicInfoTagLoaderNSF.h"
30 #include "MusicInfoTagLoaderSPC.h"
31 #include "MusicInfoTagLoaderYM.h"
32 #include "MusicInfoTagLoaderDatabase.h"
33 #include "MusicInfoTagLoaderASAP.h"
34 #include "MusicInfoTagLoaderMidi.h"
35 #include "utils/StringUtils.h"
36 #include "utils/URIUtils.h"
40 #include "cores/paplayer/ASAPCodec.h"
43 using namespace MUSIC_INFO;
45 CMusicInfoTagLoaderFactory::CMusicInfoTagLoaderFactory()
48 CMusicInfoTagLoaderFactory::~CMusicInfoTagLoaderFactory()
51 IMusicInfoTagLoader* CMusicInfoTagLoaderFactory::CreateLoader(const CStdString& strFileName)
53 // dont try to read the tags for streams & shoutcast
54 CFileItem item(strFileName, false);
55 if (item.IsInternetStream())
59 return new CMusicInfoTagLoaderDatabase();
61 CStdString strExtension = URIUtils::GetExtension(strFileName);
62 StringUtils::ToLower(strExtension);
63 StringUtils::TrimLeft(strExtension, ".");
65 if (strExtension.empty())
68 if (strExtension == "aac" ||
69 strExtension == "ape" || strExtension == "mac" ||
70 strExtension == "mp3" ||
71 strExtension == "wma" ||
72 strExtension == "flac" ||
73 strExtension == "m4a" || strExtension == "mp4" ||
74 strExtension == "mpc" || strExtension == "mpp" || strExtension == "mp+" ||
75 strExtension == "ogg" || strExtension == "oga" || strExtension == "oggstream" ||
76 strExtension == "aif" || strExtension == "aiff" ||
77 strExtension == "wav" ||
79 ModPlayer::IsSupportedFormat(strExtension) ||
80 strExtension == "mod" || strExtension == "nsf" || strExtension == "nsfstream" ||
81 strExtension == "s3m" || strExtension == "it" || strExtension == "xm" ||
85 CTagLoaderTagLib *pTagLoader = new CTagLoaderTagLib();
86 return (IMusicInfoTagLoader*)pTagLoader;
89 else if (strExtension == "cdda")
91 CMusicInfoTagLoaderCDDA *pTagLoader = new CMusicInfoTagLoaderCDDA();
92 return (IMusicInfoTagLoader*)pTagLoader;
95 else if (strExtension == "shn")
97 CMusicInfoTagLoaderSHN *pTagLoader = new CMusicInfoTagLoaderSHN();
98 return (IMusicInfoTagLoader*)pTagLoader;
100 else if (strExtension == "spc")
102 CMusicInfoTagLoaderSPC *pTagLoader = new CMusicInfoTagLoaderSPC();
103 return (IMusicInfoTagLoader*)pTagLoader;
105 else if (strExtension == "ym")
107 CMusicInfoTagLoaderYM *pTagLoader = new CMusicInfoTagLoaderYM();
108 return (IMusicInfoTagLoader*)pTagLoader;
110 #ifdef HAS_ASAP_CODEC
111 else if (ASAPCodec::IsSupportedFormat(strExtension) || strExtension == "asapstream")
113 CMusicInfoTagLoaderASAP *pTagLoader = new CMusicInfoTagLoaderASAP();
114 return (IMusicInfoTagLoader*)pTagLoader;
117 else if ( TimidityCodec::IsSupportedFormat( strExtension ) )
119 CMusicInfoTagLoaderMidi * pTagLoader = new CMusicInfoTagLoaderMidi();
120 return (IMusicInfoTagLoader*)pTagLoader;