bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
  CVideoDatabase videoDatabase;
  CBookmark bookmark;
  bookmark.timeInSeconds = (int)g_application.GetTime();
  bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();

  if( g_application.m_pPlayer->HasPlayer() )
    bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
  else
    bookmark.playerState.clear();

  bookmark.player = CPlayerCoreFactory::GetInstance().GetPlayerName(g_application.GetCurrentPlayer());

  // create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
  float aspectRatio = g_renderManager.GetAspectRatio();
#else
  float aspectRatio = 1.0f;
#endif
  int width = BOOKMARK_THUMB_WIDTH;
  int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
  if (height > (int)BOOKMARK_THUMB_WIDTH)
  {
    height = BOOKMARK_THUMB_WIDTH;
    width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
  }
  {
#ifdef HAS_VIDEO_PLAYBACK
    CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();

    if (thumbnail)
    {
      g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);

#if !defined(HAS_LIBAMCODEC)
      if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
      {
#else//HAS_LIBAMCODEC
      {
        CScreenshotAML::CaptureVideoFrame(thumbnail->GetPixels(), width, height, false);
#endif
        Crc32 crc;
        crc.ComputeFromLowerCase(g_application.CurrentFile());
        bookmark.thumbNailImage = StringUtils::Format("%08x_%i.jpg", (unsigned __int32) crc, (int)bookmark.timeInSeconds);
        bookmark.thumbNailImage = URIUtils::AddFileToFolder(CProfilesManager::GetInstance().GetBookmarksThumbFolder(), bookmark.thumbNailImage);
        if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
                                            bookmark.thumbNailImage))
          bookmark.thumbNailImage.clear();
      }
#if !defined(HAS_LIBAMCODEC)
      else
        CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");
#endif

      g_renderManager.ReleaseRenderCapture(thumbnail);
    }
void CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
  CVideoDatabase videoDatabase;
  CBookmark bookmark;
  bookmark.timeInSeconds = (int)g_application.GetTime();
  bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();

  if( g_application.m_pPlayer )
    bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
  else
    bookmark.playerState.Empty();

  bookmark.player = CPlayerCoreFactory::GetPlayerName(g_application.GetCurrentPlayer());

  // create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
  float aspectRatio = g_renderManager.GetAspectRatio();
#else
  float aspectRatio = 1.0f;
#endif
  int width = BOOKMARK_THUMB_WIDTH;
  int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
  if (height > BOOKMARK_THUMB_WIDTH)
  {
    height = BOOKMARK_THUMB_WIDTH;
    width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
  }
  {
#ifdef HAS_VIDEO_PLAYBACK
    CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();
    g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);
    if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
    {
      Crc32 crc;
      crc.ComputeFromLowerCase(g_application.CurrentFile());
      bookmark.thumbNailImage.Format("%08x_%i.jpg", (unsigned __int32) crc, m_vecItems->Size() + 1);
      bookmark.thumbNailImage = URIUtils::AddFileToFolder(g_settings.GetBookmarksThumbFolder(), bookmark.thumbNailImage);
      if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
                                          bookmark.thumbNailImage))
        bookmark.thumbNailImage.Empty();
    }
    else
      CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");

    g_renderManager.ReleaseRenderCapture(thumbnail);
#endif
  }
  videoDatabase.Open();
  if (tag)
    videoDatabase.AddBookMarkForEpisode(*tag, bookmark);
  else
    videoDatabase.AddBookMarkToFile(g_application.CurrentFile(), bookmark, CBookmark::STANDARD);
  videoDatabase.Close();
  Update();
}
Exemple #3
0
void CLightEffectServices::Process()
{
  if (InitConnection())
  {
    ApplyUserSettings();
    m_lighteffect->SetScanRange(m_width, m_height);

    SetBling();

    int priority = -1;
    CRenderCapture *capture = nullptr;
    while (!m_bStop)
    {
      if (g_application.m_pPlayer->IsPlayingVideo())
      {
        // if starting, alloc a rendercapture and start capturing
        if (capture == nullptr)
        {
          capture = g_renderManager.AllocRenderCapture();
          g_renderManager.Capture(capture, m_width, m_height, CAPTUREFLAG_CONTINUOUS);
        }

        // reset static bool for later
        m_staticON = false;
        m_lightsON = true;
        if (priority != 128)
        {
          priority = 128;
          m_lighteffect->SetPriority(priority);
        }
        
        capture->GetEvent().WaitMSec(1000);
        if (capture->GetUserState() == CAPTURESTATE_DONE)
        {
          //read out the pixels
          unsigned char *pixels = capture->GetPixels();
          for (int y = 0; y < m_height; ++y)
          {
            int row = m_width * y * 4;
            for (int x = 0; x < m_width; ++x)
            {
              int pixel = row + (x * 4);
              int rgb[3] = {
                pixels[pixel + 2],
                pixels[pixel + 1],
                pixels[pixel]
              };
              m_lighteffect->SetPixel(rgb, x, y);
            }
          }
          m_lighteffect->SendLights(true);
        }
      }
      else
      {
        if (capture != nullptr)
        {
          g_renderManager.ReleaseRenderCapture(capture);
          capture = nullptr;
        }
        // set static if its enabled
        if (CSettings::GetInstance().GetBool(CSettings::SETTING_SERVICES_LIGHTEFFECTSSTATICON))
        {
          // only set static colour once, no point doing it over and over again
          if (!m_staticON)
          {
            m_staticON = true;
            m_lightsON = true;
            SetAllLightsToStaticRGB();
          }
        }
        // or kill the lights
        else
        {
          if (m_lightsON)
          {
            m_lightsON = false;
            if (priority != 255)
            {
              priority = 255;
              m_lighteffect->SetPriority(priority);
            }
          }
        }
        usleep(50 * 1000);
      }
    }

    // have to check this in case we go
    // right from playing to death.
    if (capture != nullptr)
    {
      g_renderManager.ReleaseRenderCapture(capture);
      capture = nullptr;
    }
    m_lighteffect->SetPriority(255);
    SAFE_DELETE(m_lighteffect);
  }
}
bool CGUIDialogVideoBookmarks::AddBookmark(CVideoInfoTag* tag)
{
  CVideoDatabase videoDatabase;
  CBookmark bookmark;
  bookmark.timeInSeconds = (int)g_application.GetTime();
  bookmark.totalTimeInSeconds = (int)g_application.GetTotalTime();

  if( g_application.m_pPlayer->HasPlayer() )
    bookmark.playerState = g_application.m_pPlayer->GetPlayerState();
  else
    bookmark.playerState.clear();

  bookmark.player = CPlayerCoreFactory::Get().GetPlayerName(g_application.GetCurrentPlayer());

  // create the thumbnail image
#ifdef HAS_VIDEO_PLAYBACK
  float aspectRatio = g_renderManager.GetAspectRatio();
#else
  float aspectRatio = 1.0f;
#endif
  int width = BOOKMARK_THUMB_WIDTH;
  int height = (int)(BOOKMARK_THUMB_WIDTH / aspectRatio);
  if (height > (int)BOOKMARK_THUMB_WIDTH)
  {
    height = BOOKMARK_THUMB_WIDTH;
    width = (int)(BOOKMARK_THUMB_WIDTH * aspectRatio);
  }
  {
#ifdef HAS_VIDEO_PLAYBACK
    CRenderCapture* thumbnail = g_renderManager.AllocRenderCapture();

    if (thumbnail)
    {
      g_renderManager.Capture(thumbnail, width, height, CAPTUREFLAG_IMMEDIATELY);

      if (thumbnail->GetUserState() == CAPTURESTATE_DONE)
      {
        Crc32 crc;
        crc.ComputeFromLowerCase(g_application.CurrentFile());
        bookmark.thumbNailImage = StringUtils::Format("%08x_%i.jpg", (unsigned __int32) crc, (int)bookmark.timeInSeconds);
        bookmark.thumbNailImage = URIUtils::AddFileToFolder(CProfilesManager::Get().GetBookmarksThumbFolder(), bookmark.thumbNailImage);
        if (!CPicture::CreateThumbnailFromSurface(thumbnail->GetPixels(), width, height, thumbnail->GetWidth() * 4,
                                            bookmark.thumbNailImage))
          bookmark.thumbNailImage.clear();
      }
      else
        CLog::Log(LOGERROR,"CGUIDialogVideoBookmarks: failed to create thumbnail");

      g_renderManager.ReleaseRenderCapture(thumbnail);
    }
#endif
  }
  videoDatabase.Open();
  if (tag)
    videoDatabase.AddBookMarkForEpisode(*tag, bookmark);
  else
  {
    std::string path = g_application.CurrentFile();
    if (g_application.CurrentFileItem().HasProperty("original_listitem_url") && 
       !URIUtils::IsVideoDb(g_application.CurrentFileItem().GetProperty("original_listitem_url").asString()))
      path = g_application.CurrentFileItem().GetProperty("original_listitem_url").asString();
    videoDatabase.AddBookMarkToFile(path, bookmark, CBookmark::STANDARD);
  }
  videoDatabase.Close();
  return true;
}