コード例 #1
0
ファイル: TestStreamDetails.cpp プロジェクト: Arcko/xbmc
TEST(TestStreamDetails, General)
{
  CStreamDetails a;
  CStreamDetailVideo *video = new CStreamDetailVideo();
  CStreamDetailAudio *audio = new CStreamDetailAudio();
  CStreamDetailSubtitle *subtitle = new CStreamDetailSubtitle();

  video->m_iWidth = 1920;
  video->m_iHeight = 1080;
  video->m_fAspect = 2.39f;
  video->m_iDuration = 30;
  video->m_strCodec = "h264";
  video->m_strStereoMode = "left_right";
  video->m_strLanguage = "eng";

  audio->m_iChannels = 2;
  audio->m_strCodec = "aac";
  audio->m_strLanguage = "eng";

  subtitle->m_strLanguage = "eng";

  a.AddStream(video);
  a.AddStream(audio);

  EXPECT_TRUE(a.HasItems());

  EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::VIDEO));
  EXPECT_EQ(1, a.GetVideoStreamCount());
  EXPECT_STREQ("", a.GetVideoCodec().c_str());
  EXPECT_EQ(0.0f, a.GetVideoAspect());
  EXPECT_EQ(0, a.GetVideoWidth());
  EXPECT_EQ(0, a.GetVideoHeight());
  EXPECT_EQ(0, a.GetVideoDuration());
  EXPECT_STREQ("", a.GetStereoMode().c_str());

  EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::AUDIO));
  EXPECT_EQ(1, a.GetAudioStreamCount());

  EXPECT_EQ(0, a.GetStreamCount(CStreamDetail::SUBTITLE));
  EXPECT_EQ(0, a.GetSubtitleStreamCount());

  a.AddStream(subtitle);
  EXPECT_EQ(1, a.GetStreamCount(CStreamDetail::SUBTITLE));
  EXPECT_EQ(1, a.GetSubtitleStreamCount());

  a.DetermineBestStreams();
  EXPECT_STREQ("h264", a.GetVideoCodec().c_str());
  EXPECT_EQ(2.39f, a.GetVideoAspect());
  EXPECT_EQ(1920, a.GetVideoWidth());
  EXPECT_EQ(1080, a.GetVideoHeight());
  EXPECT_EQ(30, a.GetVideoDuration());
  EXPECT_STREQ("left_right", a.GetStereoMode().c_str());
}
コード例 #2
0
ファイル: ThumbLoader.cpp プロジェクト: Kr0nZ/boxee
bool CVideoThumbLoader::LoadItem(CFileItem* pItem, bool bCanBlock)
{
  if (pItem->m_bIsShareOrDrive) return false;

  bool retVal = false;
  if (pItem->IsVideoDb() && pItem->HasVideoInfoTag() && !pItem->HasThumbnail())
  {
    if (pItem->m_bIsFolder && pItem->GetVideoInfoTag()->m_iSeason > -1)
      return false;
    CFileItem item(*pItem->GetVideoInfoTag());
    bool bResult = LoadItem(&item, bCanBlock);
    if (bResult)
    {
      pItem->SetProperty("HasAutoThumb",item.GetProperty("HasAutoThumb"));
      pItem->SetProperty("AutoThumbImage",item.GetProperty("AutoThumbImage"));
      pItem->SetProperty("fanart_image",item.GetProperty("fanart_image"));
      pItem->SetThumbnailImage(item.GetThumbnailImage());
      pItem->GetVideoInfoTag()->m_streamDetails = item.GetVideoInfoTag()->m_streamDetails;
    }
    return bResult;
  }

  CStdString cachedThumb(pItem->GetCachedVideoThumb());

  CLog::Log(LOGDEBUG, "CVideoThumbLoader::LoadItem, strItemPath = %s, cachedThumb = %s (thumb)", pItem->m_strPath.c_str(), cachedThumb.c_str());

  if (!pItem->HasThumbnail())
  {
    if (CFile::Exists(cachedThumb))
    {
      CLog::Log(LOGDEBUG, "CVideoThumbLoader::LoadItem, EXISTS, strItemPath = %s, cachedThumb = %s (thumb)", pItem->m_strPath.c_str(), cachedThumb.c_str());
      pItem->SetCachedVideoThumb();
    }
    else if (pItem->m_bIsFolder)
      pItem->SetUserVideoThumb();
    else
    {
      CStdString strPath, strFileName;
      CUtil::Split(cachedThumb, strPath, strFileName);

      // create unique thumb for auto generated thumbs
      cachedThumb = strPath + "auto-" + strFileName;
      if (pItem->IsVideo() && !pItem->IsInternetStream() && !pItem->IsPlayList() && !CFile::Exists(cachedThumb) && !pItem->m_bIsFolder)
      {
        if (!bCanBlock) 
        {
          // we should not retreive remote (e.g. SMB) thumbs if requested not to block
          return false;
        }
        
        CStreamDetails details;
        if (pItem->IsStack())
        {
          CStackDirectory stack;
          CVideoThumbLoader::ExtractThumb(stack.GetFirstStackedFile(pItem->m_strPath), cachedThumb, &details);
        }
        else
        {
          CVideoThumbLoader::ExtractThumb(pItem->m_strPath, cachedThumb, &details);
        }

        if (details.HasItems() && m_pStreamDetailsObs)
          m_pStreamDetailsObs->OnStreamDetails(details, pItem->m_strPath, -1);
      }

      if (CFile::Exists(cachedThumb))
      {
        pItem->SetProperty("HasAutoThumb", "1");
        pItem->SetProperty("AutoThumbImage", cachedThumb);
        pItem->SetThumbnailImage(cachedThumb);
        retVal = true;
      }
      else
        pItem->SetThumbnailImage("");
    }
  }
  else
  {
    // look for remote thumbs
    CStdString thumb(pItem->GetThumbnailImage());
    if (!CURI::IsFileOnly(thumb) && !CUtil::IsHD(thumb))
    {
      if (pItem->GetProperty("OriginalThumb").IsEmpty())
      {
        //when the item is loaded from the database we don't want to overwrite the original thumb by mistake because the user might have his own thumb
        //related to http://jira.boxee.tv/browse/BOXEE-8488
        pItem->SetProperty("OriginalThumb", thumb);
      }

      if(CFile::Exists(cachedThumb))
      {
        pItem->SetThumbnailImage(cachedThumb);
        retVal = true;
      }
      else
      {
        if (!bCanBlock) 
        {
          // we should not retreive remote thumbs if requested not to block
          return false;
        }
        
        if(CPicture::CreateThumbnail(thumb, cachedThumb))
          pItem->SetThumbnailImage(cachedThumb);
        else
          pItem->SetThumbnailImage("");
      }
    }
    else
    {
      if (!CFile::Exists(cachedThumb))
      {
        // Thumb can not be found. Going to create the thumb by fetching the original thumb and save it in cache
        if (!bCanBlock) 
        {
          if (pItem->GetProperty("OriginalThumb").IsEmpty())
          {
            pItem->SetProperty("OriginalThumb", thumb);
          }
          return false;
        }

        CStdString originalThumb = pItem->GetProperty("OriginalThumb");

        if (!pItem->GetThumbnailImage().IsEmpty() && (CUtil::IsHD(pItem->GetThumbnailImage()) || CUtil::IsSmb(pItem->GetThumbnailImage()) || CUtil::IsUPnP(pItem->GetThumbnailImage())) && CFile::Exists(pItem->GetThumbnailImage()))
        {
          //if the user has the thumb locally, use it
          originalThumb = pItem->GetThumbnailImage();
        }

        CStdString newCachedThumb = pItem->GetCachedPictureThumb();

        if(CPicture::CreateThumbnail(originalThumb, newCachedThumb,true ))
        {
          pItem->SetThumbnailImage(newCachedThumb);
        }
        else
        {
          pItem->SetThumbnailImage("");
        }
      }
    }
  }

  if (!pItem->HasProperty("fanart_image") && bCanBlock)
  {
    pItem->CacheFanart();
    if (CFile::Exists(pItem->GetCachedFanart()))
    {
      pItem->SetProperty("fanart_image",pItem->GetCachedFanart());
      retVal = true;
  }                          
  }

  if (!pItem->m_bIsFolder && !pItem->IsInternetStream() && 
       pItem->HasVideoInfoTag() && 
       g_guiSettings.GetBool("myvideos.extractflags")   &&
       !pItem->GetVideoInfoTag()->HasStreamDetails())
  {
    if (CDVDFileInfo::GetFileStreamDetails(pItem) && m_pStreamDetailsObs)
    {
      CVideoInfoTag *info = pItem->GetVideoInfoTag();
      m_pStreamDetailsObs->OnStreamDetails(info->m_streamDetails, "", info->m_iFileId);
      pItem->SetInvalid();
      retVal = true;
    }
  }

//  if (pItem->IsVideo() && !pItem->IsInternetStream())
//    CDVDPlayer::GetFileMetaData(pItem->m_strPath, pItem);

  return retVal;
}