bool CMusicInfoTagLoaderApe::Load(const CStdString& strFileName, CMusicInfoTag& tag, EmbeddedArt *art)
{
  try
  {
    // retrieve the APE Tag info from strFileName
    // and put it in tag
    tag.SetURL(strFileName);
    DVDPlayerCodec codec;
    if (codec.Init(strFileName, 4096))
    {
      tag.SetDuration((int)(codec.m_TotalTime/1000));
      codec.DeInit();
    }
    CAPEv2Tag myTag;
    if (myTag.ReadTag((char*)strFileName.c_str())) // true to check ID3 tag as well
    {
      tag.SetTitle(myTag.GetTitle());
      tag.SetAlbum(myTag.GetAlbum());
      tag.SetArtist(myTag.GetArtist());
      tag.SetAlbumArtist(myTag.GetAlbumArtist());
      tag.SetGenre(myTag.GetGenre());
      tag.SetTrackNumber(myTag.GetTrackNum());
      tag.SetPartOfSet(myTag.GetDiscNum());
      tag.SetComment(myTag.GetComment());
      tag.SetLyrics(myTag.GetLyrics());
      tag.SetMusicBrainzAlbumArtistID(myTag.GetMusicBrainzAlbumArtistID());
      tag.SetMusicBrainzAlbumID(myTag.GetMusicBrainzAlbumID());
      tag.SetMusicBrainzArtistID(myTag.GetMusicBrainzArtistID());
      tag.SetMusicBrainzTrackID(myTag.GetMusicBrainzTrackID());
      tag.SetMusicBrainzTRMID(myTag.GetMusicBrainzTRMID());
      SYSTEMTIME dateTime;
      ZeroMemory(&dateTime, sizeof(SYSTEMTIME));
      dateTime.wYear = atoi(myTag.GetYear());
      tag.SetRating(myTag.GetRating());
      tag.SetReleaseDate(dateTime);
      tag.SetLoaded();
      return true;
    }
  }
  catch (...)
  {
    CLog::Log(LOGERROR, "Tag loader ape: exception in file %s", strFileName.c_str());
  }

  tag.SetLoaded(false);
  return false;
}
示例#2
0
ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdString& strContent, unsigned int filecache)
{
  CURL urlFile(strFile);

  if (!strContent.empty())
  {
    VECADDONS codecs;
    CAddonMgr::Get().GetAddons(ADDON_AUDIODECODER, codecs);
    for (size_t i=0;i<codecs.size();++i)
    {
      boost::shared_ptr<CAudioDecoder> dec(boost::static_pointer_cast<CAudioDecoder>(codecs[i]));
      if (dec->GetMimetypes().find(strContent) != std::string::npos)
      {
        CAudioDecoder* result = new CAudioDecoder(*dec);
        static_cast<AudioDecoderDll&>(*result).Create();
        return result;
      }
    }
  }
  if (StringUtils::StartsWithNoCase(strContent, "audio/l16"))
  {
    PCMCodec * pcm_codec = new PCMCodec();
    pcm_codec->SetMimeParams(strContent);
    return pcm_codec;
  }
  else if( strContent.Equals("audio/aac") || strContent.Equals("audio/aacp") ||
      strContent.Equals("audio/x-ms-wma") ||
      strContent.Equals("audio/x-ape") || strContent.Equals("audio/ape"))
  {
    DVDPlayerCodec *pCodec = new DVDPlayerCodec;
    pCodec->SetContentType(strContent);
    return pCodec;
  }
  else if (strContent.Equals("audio/x-xbmc-pcm"))
  {
    // audio/x-xbmc-pcm this is the used codec for AirTunes
    // (apples audio only streaming)
    DVDPlayerCodec *dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;
  }

  if (urlFile.GetFileType().Equals("wav") || strContent.Equals("audio/wav") || strContent.Equals("audio/x-wav"))
  {
    //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;

    dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;

  }

  //default
  return CreateCodec(urlFile.GetFileType());
}
示例#3
0
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());
}
示例#4
0
ICodec* CodecFactory::CreateCodecDemux(const CStdString& strFile, const CStdString& strContent, unsigned int filecache)
{
  CURL urlFile(strFile);
  if( strContent.Equals("audio/mpeg")
  ||  strContent.Equals("audio/mpeg3")
  ||  strContent.Equals("audio/mp3") )
  {
    DVDPlayerCodec *dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;
  }
  else if (StringUtils::StartsWithNoCase(strContent, "audio/l16"))
  {
    PCMCodec * pcm_codec = new PCMCodec();
    pcm_codec->SetMimeParams(strContent);
    return pcm_codec;
  }
  else if( strContent.Equals("audio/aac") || strContent.Equals("audio/aacp") ||
      strContent.Equals("audio/x-ms-wma") ||
      strContent.Equals("audio/x-ape") || strContent.Equals("audio/ape"))
  {
    DVDPlayerCodec *pCodec = new DVDPlayerCodec;
    pCodec->SetContentType(strContent);
    return pCodec;
  }
  else if( strContent.Equals("application/ogg") || strContent.Equals("audio/ogg"))
    return CreateOGGCodec(strFile,filecache);
  else if (strContent.Equals("audio/x-xbmc-pcm"))
  {
    // audio/x-xbmc-pcm this is the used codec for AirTunes
    // (apples audio only streaming)
    DVDPlayerCodec *dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;
  }
  else if (strContent.Equals("audio/flac") || strContent.Equals("audio/x-flac") || strContent.Equals("application/x-flac"))
  {
    DVDPlayerCodec *dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;
  }

  if (urlFile.GetProtocol() == "shout")
  {
    DVDPlayerCodec *dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType("audio/mp3");
    return dvdcodec; // if we got this far with internet radio - content-type was wrong. gamble on mp3.
  }

  if (urlFile.GetFileType().Equals("wav") || strContent.Equals("audio/wav") || strContent.Equals("audio/x-wav"))
  {
    //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;
    }

    dvdcodec = new DVDPlayerCodec();
    dvdcodec->SetContentType(strContent);
    return dvdcodec;

  }
  else if (urlFile.GetFileType().Equals("ogg") || urlFile.GetFileType().Equals("oggstream") || urlFile.GetFileType().Equals("oga"))
    return CreateOGGCodec(strFile,filecache);

  //default
  return CreateCodec(urlFile.GetFileType());
}
void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores)
{
  CURL url(item.m_strPath);

  CLog::Log(LOGDEBUG, "CPlayerCoreFactory::GetPlayers(%s)", item.m_strPath.c_str());

  // ugly hack for ReplayTV. our filesystem is broken against real ReplayTV's (not the psuedo DVArchive)
  // it breaks down for small requests. As we can't allow truncated reads for all emulated dll file functions
  // we are often forced to do small reads to fill up the full buffer size wich seems gives garbage back
  if (url.GetProtocol().Equals("rtv"))
  {
    vecCores.push_back(EPC_MPLAYER); // vecCores.push_back(EPC_DVDPLAYER);
  }
  
  if (url.GetProtocol().Equals("hdhomerun")
  ||  url.GetProtocol().Equals("myth")
  ||  url.GetProtocol().Equals("cmyth")
  ||  url.GetProtocol().Equals("rtmp"))
  {
    vecCores.push_back(EPC_DVDPLAYER);
  }
  
  if (url.GetProtocol().Equals("lastfm") ||
      url.GetProtocol().Equals("shout"))
  {
    vecCores.push_back(EPC_PAPLAYER);
  }
   
  if (url.GetProtocol().Equals("mms"))
  {
    vecCores.push_back(EPC_DVDPLAYER);    
  }

  // dvdplayer can play standard rtsp streams
  if (url.GetProtocol().Equals("rtsp") 
  && !url.GetFileType().Equals("rm") 
  && !url.GetFileType().Equals("ra"))
  {
    vecCores.push_back(EPC_DVDPLAYER);
  }

  // Special care in case it's an internet stream
  if (item.IsInternetStream())
  {
    CStdString content = item.GetContentType();
    CLog::Log(LOGDEBUG, "%s - Item is an internet stream, content-type=%s", __FUNCTION__, content.c_str());

    if (content == "video/x-flv"
    ||  content == "video/flv")
    {
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else if (content == "audio/aacp")
    {
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else if (content == "application/sdp")
    {
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else if (content == "application/octet-stream")
    {
      //unknown contenttype, send mp2 to pap
      if( url.GetFileType() == "mp2")
        vecCores.push_back(EPC_PAPLAYER);
    }
  }

  if (item.IsDVD() || item.IsDVDFile() || item.IsDVDImage())
  {
    if ( g_advancedSettings.m_videoDefaultDVDPlayer == "externalplayer" )
    {
      vecCores.push_back(EPC_EXTPLAYER);
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else
    {
      vecCores.push_back(EPC_DVDPLAYER);
      vecCores.push_back(EPC_EXTPLAYER);
    }
  }

  
  // only dvdplayer can handle these normally
  if (url.GetFileType().Equals("sdp") 
  ||  url.GetFileType().Equals("asf"))
  {
    vecCores.push_back(EPC_DVDPLAYER);
  }

  // Set video default player. Check whether it's video first (overrule audio check)
  // Also push these players in case it is NOT audio either
  if (item.IsVideo() || !item.IsAudio())
  {
    if ( g_advancedSettings.m_videoDefaultPlayer == "externalplayer" )
    {
      vecCores.push_back(EPC_EXTPLAYER);
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else
    {
      vecCores.push_back(EPC_DVDPLAYER);
      vecCores.push_back(EPC_EXTPLAYER);
    }
  }

  if( PAPlayer::HandlesType(url.GetFileType()) )
  {
    // We no longer force PAPlayer as our default audio player (used to be true):
    bool bAdd = false;
    if (url.GetProtocol().Equals("mms"))
    {
       bAdd = false;
    }
    else if (item.IsType(".wma"))
    {
      bAdd = true;
      DVDPlayerCodec codec;
      if (!codec.Init(item.m_strPath,2048))
        bAdd = false;
      codec.DeInit();
    }

    if (bAdd)
    {
      if( g_guiSettings.GetInt("audiooutput.mode") == AUDIO_ANALOG )
      {
        vecCores.push_back(EPC_PAPLAYER);
      }
      else if ((url.GetFileType().Equals("ac3") && g_audioConfig.GetAC3Enabled())
           ||  (url.GetFileType().Equals("dts") && g_audioConfig.GetDTSEnabled())) 
      {
        vecCores.push_back(EPC_DVDPLAYER);
      }
      else
      {
        vecCores.push_back(EPC_PAPLAYER);
      }
    }
  }

  // Set audio default player
  // Pushback all audio players in case we don't know the type
  if( item.IsAudio())
  {
    if ( g_advancedSettings.m_audioDefaultPlayer == "dvdplayer" )
    {
      vecCores.push_back(EPC_DVDPLAYER);
      vecCores.push_back(EPC_PAPLAYER);
      vecCores.push_back(EPC_EXTPLAYER);
    }
    else if ( g_advancedSettings.m_audioDefaultPlayer == "externalplayer" )
    {
      vecCores.push_back(EPC_EXTPLAYER);
      vecCores.push_back(EPC_PAPLAYER);
      vecCores.push_back(EPC_DVDPLAYER);
    }
    else
    { // default to paplayer
      vecCores.push_back(EPC_PAPLAYER);
      vecCores.push_back(EPC_DVDPLAYER);
      vecCores.push_back(EPC_EXTPLAYER);
    }
  }

  // Always pushback DVDplayer as it can do both audio & video
//  vecCores.push_back(EPC_DVDPLAYER);

  /* make our list unique, preserving first added players */
  unique(vecCores);
}
示例#6
0
void CPlayerCoreFactory::GetPlayers( const CFileItem& item, VECPLAYERCORES &vecCores)
{
  CURL url(item.m_strPath);

  CLog::Log(LOGDEBUG,"CPlayerCoreFactor::GetPlayers(%s)",item.m_strPath.c_str());

  // Plex media server streams.
  if (url.GetProtocol().Equals("plex", false))
      vecCores.push_back(EPC_PMSPLAYER);
  
  // Play audio files with iTunes DRM using QuickTime
  if (url.GetFileType().Equals("m4p") || url.GetFileType().Equals("m4b"))
  {
    vecCores.push_back(EPC_QTPLAYER);
    CLog::Log(LOGDEBUG,"CPlayerCoreFactor::GetPlayers(%s) - matched M4P file",item.m_strPath.c_str());
  }
  
  // ugly hack for ReplayTV. our filesystem is broken against real ReplayTV's (not the psuevdo DVArchive)
  // it breaks down for small requests. As we can't allow truncated reads for all emulated dll file functions
  // we are often forced to do small reads to fill up the full buffer size wich seems gives garbage back
  if (url.GetProtocol().Equals("rtv"))
    vecCores.push_back(EPC_MPLAYER); // vecCores.push_back(EPC_DVDPLAYER);

  if (url.GetProtocol().Equals("hdhomerun")
  ||  url.GetProtocol().Equals("myth")
  ||  url.GetProtocol().Equals("cmyth")
  ||  url.GetProtocol().Equals("rtmp"))
    vecCores.push_back(EPC_DVDPLAYER);

  if (url.GetProtocol().Equals("lastfm") ||
      url.GetProtocol().Equals("shout"))
  {
    vecCores.push_back(EPC_PAPLAYER);
  }
   
  if (url.GetProtocol().Equals("mms"))
  {
    vecCores.push_back(EPC_DVDPLAYER);    
  }

  // dvdplayer can play standard rtsp streams
  if (url.GetProtocol().Equals("rtsp") 
  && !url.GetFileType().Equals("rm") 
  && !url.GetFileType().Equals("ra"))
    vecCores.push_back(EPC_DVDPLAYER);

  // only dvdplayer can handle these normally
  if (url.GetFileType().Equals("sdp") ||
      url.GetFileType().Equals("asf"))
    vecCores.push_back(EPC_DVDPLAYER);

  if ( item.IsInternetStream() )
  {
    CStdString content = item.GetContentType();

    if (content == "video/x-flv"
     || content == "video/flv")
      vecCores.push_back(EPC_DVDPLAYER);
    else if (content == "audio/aacp")
      vecCores.push_back(EPC_DVDPLAYER);
    else if (content == "application/sdp")
      vecCores.push_back(EPC_DVDPLAYER);
    else if (content == "application/octet-stream")
    {
      //unknown contenttype, send mp2 to pap
      if( url.GetFileType() == "mp2")
        vecCores.push_back(EPC_PAPLAYER);
    }
  }

  if (((item.IsDVD()) || item.IsDVDFile() || item.IsDVDImage()))
  {
    vecCores.push_back(EPC_DVDPLAYER);
  }

  if( PAPlayer::HandlesType(url.GetFileType()) )
  {
    bool bAdd = true;
    if (url.GetProtocol().Equals("mms"))
    {
       bAdd = false;
    }
    else if (item.IsType(".wma"))
    {
      DVDPlayerCodec codec;
      if (!codec.Init(item.m_strPath,2048))
        bAdd = false;
      codec.DeInit();        
    }

    if (bAdd)
    {
      if(!g_audioConfig.UseDigitalOutput())
      {
        vecCores.push_back(EPC_PAPLAYER);
      }
      //else if( ( url.GetFileType().Equals("ac3") && g_audioConfig.GetAC3Enabled() )
      //  ||  ( url.GetFileType().Equals("dts") && g_audioConfig.GetDTSEnabled() ) ) 
      //{
      //  vecCores.push_back(EPC_DVDPLAYER);
      //}
      //else
      {
        vecCores.push_back(EPC_PAPLAYER);
      }
    }
  }

  //Add all normal players last so you can force them, should you want to
  if ( item.IsAudio() )
    vecCores.push_back(EPC_PAPLAYER);

  vecCores.push_back(EPC_DVDPLAYER);

  /* make our list unique, presevering first added players */
  unique(vecCores);
}