ICodec* CodecFactory::CreateOGGCodec(const CStdString& strFile, unsigned int filecache) { // oldnemesis: we want to use OGGCodec() for OGG music since unlike DVDCodec // it provides better timings for Karaoke. However OGGCodec() cannot handle // ogg-flac and ogg videos, that's why this block. ICodec* codec = new OGGCodec(); try { if (codec->Init(strFile, filecache)) return codec; } catch( ... ) { } delete codec; return new DVDPlayerCodec(); }
ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdString& strContent, unsigned int filecache) { CURL urlFile(strFile); if( strContent.Equals("audio/mpeg") || strContent.Equals("audio/mp3") ) return new MP3Codec(); else if (strContent.Left(9).Equals("audio/l16")) { PCMCodec * pcm_codec = new PCMCodec(); pcm_codec->SetMimeParams(strContent); return pcm_codec; } else if( strContent.Equals("audio/aac") || strContent.Equals("audio/aacp") ) { DVDPlayerCodec *pCodec = new DVDPlayerCodec; if (urlFile.GetProtocol() == "shout" ) pCodec->SetContentType(strContent); return pCodec; } else if( strContent.Equals("audio/x-ms-wma") ) return new DVDPlayerCodec(); else if( strContent.Equals("application/ogg") || strContent.Equals("audio/ogg")) return CreateOGGCodec(strFile,filecache); else if (strContent.Equals("audio/x-xbmc-pcm")) return (ICodec*)new BXACodec(); else if (strContent.Equals("audio/flac") || strContent.Equals("audio/x-flac") || strContent.Equals("application/x-flac")) return new FLACCodec(); if (urlFile.GetProtocol() == "lastfm" || urlFile.GetProtocol() == "shout") { return new MP3Codec(); // if we got this far with internet radio - content-type was wrong. gamble on mp3. } if (urlFile.GetFileType().Equals("wav")) { ICodec* codec; //lets see what it contains... //this kinda sucks 'cause if it's a plain wav file the file //will be opened, sniffed and closed 2 times before it is opened *again* for wav //would be better if the papcodecs could work with bitstreams instead of filenames. DVDPlayerCodec *dvdcodec = new DVDPlayerCodec(); dvdcodec->SetContentType("audio/x-spdif-compressed"); if (dvdcodec->Init(strFile, filecache)) { return dvdcodec; } delete dvdcodec; codec = new ADPCMCodec(); if (codec->Init(strFile, filecache)) { return codec; } delete codec; codec = new WAVCodec(); if (codec->Init(strFile, filecache)) { return codec; } delete codec; } if (urlFile.GetFileType().Equals("cdda")) { //lets see what it contains... //this kinda sucks 'cause if it's plain cdda the file //will be opened, sniffed and closed before it is opened *again* for cdda //would be better if the papcodecs could work with bitstreams instead of filenames. DVDPlayerCodec *dvdcodec = new DVDPlayerCodec(); dvdcodec->SetContentType("audio/x-spdif-compressed"); if (dvdcodec->Init(strFile, filecache)) { return dvdcodec; } delete dvdcodec; } else if (urlFile.GetFileType().Equals("ogg") || urlFile.GetFileType().Equals("oggstream") || urlFile.GetFileType().Equals("oga")) return CreateOGGCodec(strFile,filecache); //default return CreateCodec(urlFile.GetFileType()); }