Skip to content

Commit

Permalink
VideoPlayer: register ProcessInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jul 9, 2017
1 parent 7b23d5f commit d69e474
Show file tree
Hide file tree
Showing 13 changed files with 82 additions and 64 deletions.
1 change: 1 addition & 0 deletions cmake/treedata/optional/common/X.txt
@@ -1 +1,2 @@
xbmc/windowing/X11 windowing/X11 # X
xbmc/cores/VideoPlayer/Process/X11 cores/VideoPlayer/Process/X11 # X
1 change: 1 addition & 0 deletions cmake/treedata/osx/subdirs.txt
Expand Up @@ -10,3 +10,4 @@ xbmc/platform/darwin/osx platform_osx
xbmc/filesystem/posix filesystem/posix
xbmc/utils/posix utils_posix
xbmc/windowing/osx windowing/osx
xbmc/cores/VideoPlayer/Process/osx cores/VideoPlayer/Process/osx
14 changes: 3 additions & 11 deletions xbmc/cores/VideoPlayer/Process/CMakeLists.txt
@@ -1,15 +1,7 @@
file(GLOB OVERRIDES_CPP overrides/${CORE_SYSTEM_NAME}/*.cpp)
file(GLOB OVERRIDES_H overrides/${CORE_SYSTEM_NAME}/*.h)

set(SOURCES ProcessInfo.cpp
VideoBuffer.cpp
${OVERRIDES_CPP})

VideoBuffer.cpp)

set(HEADERS ProcessInfo.h
VideoBuffer.h
${OVERRIDES_H})
VideoBuffer.h)

core_add_library(process)
if(OVERRIDES_CPP)
target_compile_definitions(${CORE_LIBRARY} PRIVATE -DPLATFORM_OVERRIDE_VP_PROCESSINFO)
endif()
30 changes: 18 additions & 12 deletions xbmc/cores/VideoPlayer/Process/ProcessInfo.cpp
Expand Up @@ -22,24 +22,30 @@
#include "cores/DataCacheCore.h"
#include "threads/SingleLock.h"

// Override for platform ports
#if !defined(PLATFORM_OVERRIDE_VP_PROCESSINFO)
CCriticalSection createSection;
std::map<std::string, CreateProcessControl> CProcessInfo::m_processControls;

CProcessInfo* CProcessInfo::CreateInstance()
void CProcessInfo::RegisterProcessControl(std::string id, CreateProcessControl createFunc)
{
return new CProcessInfo();
}

#endif

CSingleLock lock(createSection);

// base class definitions
CProcessInfo::CProcessInfo()
{
m_processControls.clear();
m_processControls[id] = createFunc;
}

CProcessInfo::~CProcessInfo()
CProcessInfo* CProcessInfo::CreateInstance()
{
CSingleLock lock(createSection);

CProcessInfo *ret = nullptr;
for (auto &info : m_processControls)
{
ret = info.second();
if (ret)
return ret;
}
if (!ret)
return new CProcessInfo();
}

void CProcessInfo::SetDataCache(CDataCacheCore *cache)
Expand Down
10 changes: 8 additions & 2 deletions xbmc/cores/VideoPlayer/Process/ProcessInfo.h
Expand Up @@ -25,15 +25,20 @@
#include "threads/CriticalSection.h"
#include <atomic>
#include <list>
#include <map>
#include <string>

class CProcessInfo;
class CDataCacheCore;

using CreateProcessControl = CProcessInfo* (*)();

class CProcessInfo
{
public:
static CProcessInfo* CreateInstance();
virtual ~CProcessInfo();
static void RegisterProcessControl(std::string id, CreateProcessControl createFunc);
virtual ~CProcessInfo() = default;
void SetDataCache(CDataCacheCore *cache);

// player video
Expand Down Expand Up @@ -91,7 +96,8 @@ class CProcessInfo
bool GetVideoRender();

protected:
CProcessInfo();
CProcessInfo() = default;
static std::map<std::string, CreateProcessControl> m_processControls;
CDataCacheCore *m_dataCache = nullptr;

// player video info
Expand Down
5 changes: 5 additions & 0 deletions xbmc/cores/VideoPlayer/Process/X11/CMakeLists.txt
@@ -0,0 +1,5 @@
set(SOURCES ProcessInfoX11.cpp)

set(HEADERS ProcessInfoX11.h)

core_add_library(processX11)
Expand Up @@ -18,24 +18,22 @@
*
*/

#include "ProcessInfoLinux.h"
#include "ProcessInfoX11.h"
#include "threads/SingleLock.h"

// Override for platform ports
#if defined(TARGET_LINUX)
using namespace VIDEOPLAYER;

CProcessInfo* CProcessInfo::CreateInstance()
CProcessInfo* CProcessInfoX11::Create()
{
return new CProcessInfoLinux();
return new CProcessInfoX11();
}

void CProcessInfoX11::Register()
{
CProcessInfo::RegisterProcessControl("X11", CProcessInfoX11::Create);
}

// base class definitions
CProcessInfoLinux::CProcessInfoLinux() = default;

CProcessInfoLinux::~CProcessInfoLinux() = default;

void CProcessInfoLinux::SetSwDeinterlacingMethods()
void CProcessInfoX11::SetSwDeinterlacingMethods()
{
// first populate with the defaults from base implementation
CProcessInfo::SetSwDeinterlacingMethods();
Expand All @@ -54,7 +52,7 @@ void CProcessInfoLinux::SetSwDeinterlacingMethods()
UpdateDeinterlacingMethods(methods);
}

std::vector<AVPixelFormat> CProcessInfoLinux::GetRenderFormats()
std::vector<AVPixelFormat> CProcessInfoX11::GetRenderFormats()
{
std::vector<AVPixelFormat> formats;
formats.push_back(AV_PIX_FMT_YUV420P);
Expand All @@ -66,5 +64,3 @@ std::vector<AVPixelFormat> CProcessInfoLinux::GetRenderFormats()

return formats;
}
#endif

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2016 Team XBMC
* Copyright (C) 2005-2017 Team XBMC
* http://xbmc.org
*
* This Program is free software; you can redistribute it and/or modify
Expand All @@ -19,14 +19,19 @@
*/
#pragma once

#include "cores/IPlayer.h"
#include "../../ProcessInfo.h"
#include "../ProcessInfo.h"

class CProcessInfoLinux : public CProcessInfo
namespace VIDEOPLAYER
{

class CProcessInfoX11 : public CProcessInfo
{
public:
CProcessInfoLinux();
virtual ~CProcessInfoLinux();
static CProcessInfo* Create();
static void Register();

void SetSwDeinterlacingMethods() override;
std::vector<AVPixelFormat> GetRenderFormats() override;
};

}
5 changes: 5 additions & 0 deletions xbmc/cores/VideoPlayer/Process/osx/CMakeLists.txt
@@ -0,0 +1,5 @@
set(SOURCES ProcessInfoOSX.cpp)

set(HEADERS ProcessInfoOSX.h)

core_add_library(processosx)
Expand Up @@ -19,33 +19,26 @@
*/

#include "ProcessInfoOSX.h"
#include "cores/VideoPlayer/Process/ProcessInfo.h"
#include "threads/SingleLock.h"

// Override for platform ports
#if defined(TARGET_DARWIN_OSX)
using namespace VIDEOPLAYER;

CProcessInfo* CProcessInfo::CreateInstance()
CProcessInfo* CProcessInfoOSX::Create()
{
return new CProcessInfoOSX();
}


// base class definitions
CProcessInfoOSX::CProcessInfoOSX()
{

}

CProcessInfoOSX::~CProcessInfoOSX()
void CProcessInfoOSX::Register()
{

CProcessInfo::RegisterProcessControl("osx", CProcessInfoOSX::Create);
}

void CProcessInfoOSX::SetSwDeinterlacingMethods()
{
// first populate with the defaults from base implementation
CProcessInfo::SetSwDeinterlacingMethods();

std::list<EINTERLACEMETHOD> methods;
{
// get the current methods
Expand All @@ -55,7 +48,7 @@ void CProcessInfoOSX::SetSwDeinterlacingMethods()
// add bob and blend deinterlacer for osx
methods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_RENDER_BOB);
methods.push_back(EINTERLACEMETHOD::VS_INTERLACEMETHOD_RENDER_BLEND);

// update with the new methods list
UpdateDeinterlacingMethods(methods);
}
Expand All @@ -73,5 +66,3 @@ std::vector<AVPixelFormat> CProcessInfoOSX::GetRenderFormats()
return formats;
}

#endif

Expand Up @@ -20,13 +20,19 @@
#pragma once

#include "cores/IPlayer.h"
#include "../../ProcessInfo.h"
#include "../ProcessInfo.h"

namespace VIDEOPLAYER
{

class CProcessInfoOSX : public CProcessInfo
{
public:
CProcessInfoOSX();
virtual ~CProcessInfoOSX();
static CProcessInfo* Create();
static void Register();

void SetSwDeinterlacingMethods() override;
std::vector<AVPixelFormat> GetRenderFormats() override;
};

}
2 changes: 2 additions & 0 deletions xbmc/windowing/X11/WinSystemX11GLContext.cpp
Expand Up @@ -35,6 +35,7 @@
#include "VideoSyncDRM.h"
#include "VideoSyncGLX.h"
#include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h"
#include "cores/VideoPlayer/Process/X11/ProcessInfoX11.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFactory.h"

CWinSystemX11GLContext::CWinSystemX11GLContext() = default;
Expand Down Expand Up @@ -208,6 +209,7 @@ bool CWinSystemX11GLContext::RefreshGLContext(bool force)
return success;
}

VIDEOPLAYER::CProcessInfoX11::Register();
CDVDFactoryCodec::ClearHWAccels();
VIDEOPLAYER::CRendererFactory::ClearRenderer();
CLinuxRendererGL::Register();
Expand Down
2 changes: 2 additions & 0 deletions xbmc/windowing/osx/WinSystemOSX.mm
Expand Up @@ -28,6 +28,7 @@
#include "CompileInfo.h"
#include "cores/VideoPlayer/DVDCodecs/DVDFactoryCodec.h"
#include "cores/VideoPlayer/DVDCodecs/Video/VTB.h"
#include "cores/VideoPlayer/Process/osx/ProcessInfoOSX.h"
#include "cores/VideoPlayer/VideoRenderers/RenderFactory.h"
#include "cores/VideoPlayer/VideoRenderers/LinuxRendererGL.h"
#include "cores/VideoPlayer/VideoRenderers/HwDecRender/RendererVTBGL.h"
Expand Down Expand Up @@ -785,6 +786,7 @@ static void DisplayReconfigured(CGDirectDisplayID display,
VIDEOPLAYER::CRendererFactory::ClearRenderer();
CLinuxRendererGL::Register();
CRendererVTB::Register();
VIDEOPLAYER::CProcessInfoOSX::Register();

return true;
}
Expand Down

0 comments on commit d69e474

Please sign in to comment.