Skip to content

Commit

Permalink
VideoPlayer: expose stream player info to GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
FernetMenta authored and popcornmix committed Jun 24, 2016
1 parent ca32db8 commit d2165e9
Show file tree
Hide file tree
Showing 26 changed files with 646 additions and 35 deletions.
60 changes: 60 additions & 0 deletions xbmc/GUIInfoManager.cpp
Expand Up @@ -2108,6 +2108,22 @@ const infomap videoplayer[] = {{ "title", VIDEOPLAYER_TITLE },
{ "episodename", VIDEOPLAYER_EPISODENAME }
};

const infomap player_process[] =
{
{ "videodecoder", PLAYER_PROCESS_VIDEODECODER },
{ "deintmethod", PLAYER_PROCESS_DEINTMETHOD },
{ "pixformat", PLAYER_PROCESS_PIXELFORMAT },
{ "videowidth", PLAYER_PROCESS_VIDEOWIDTH },
{ "videoheight", PLAYER_PROCESS_VIDEOHEIGHT },
{ "videofps", PLAYER_PROCESS_VIDEOFPS },
{ "videoaspectratio", PLAYER_PROCESS_VIDEOASPECTRATIO },
{ "videohwdecoder", PLAYER_PROCESS_VIDEOHWDECODER },
{ "audiodecoder", PLAYER_PROCESS_AUDIODECODER },
{ "audiochannels", PLAYER_PROCESS_AUDIOCHANNELS },
{ "audiosamplerate", PLAYER_PROCESS_AUDIOSAMPLERATE },
{ "audiobitspersample", PLAYER_PROCESS_AUDIOBITSPERSAMPLE }
};

/// \page modules__General__List_of_gui_access
/// \section modules__General__List_of_gui_access_Container Container
/// @{
Expand Down Expand Up @@ -5320,6 +5336,14 @@ int CGUIInfoManager::TranslateSingleString(const std::string &strCondition, bool
return videoplayer[i].val;
}
}
else if (cat.name == "player_process")
{
for (size_t i = 0; i < sizeof(player_process) / sizeof(infomap); i++)
{
if (prop.name == player_process[i].str)
return videoplayer[i].val;
}
}
else if (cat.name == "slideshow")
{
for (size_t i = 0; i < sizeof(slideshow) / sizeof(infomap); i++)
Expand Down Expand Up @@ -5993,6 +6017,27 @@ std::string CGUIInfoManager::GetLabel(int info, int contextWindow, std::string *
strLabel = info.language;
}
break;
case PLAYER_PROCESS_VIDEODECODER:
strLabel = g_dataCacheCore.GetVideoDecoderName();
break;
case PLAYER_PROCESS_DEINTMETHOD:
strLabel = g_dataCacheCore.GetVideoDeintMethod();
break;
case PLAYER_PROCESS_PIXELFORMAT:
strLabel = g_dataCacheCore.GetVideoPixelFormat();
break;
case PLAYER_PROCESS_VIDEOFPS:
strLabel = StringUtils::FormatNumber(g_dataCacheCore.GetVideoFps());
break;
case PLAYER_PROCESS_VIDEOASPECTRATIO:
strLabel = StringUtils::FormatNumber(CServiceBroker::GetDataCacheCore().GetVideoAspectRatio());
break;
case PLAYER_PROCESS_AUDIODECODER:
strLabel = g_dataCacheCore.GetAudioDecoderName();
break;
case PLAYER_PROCESS_AUDIOCHANNELS:
strLabel = g_dataCacheCore.GetAudioChannels();
break;
case RDS_AUDIO_LANG:
case RDS_CHANNEL_COUNTRY:
case RDS_TITLE:
Expand Down Expand Up @@ -6555,6 +6600,18 @@ bool CGUIInfoManager::GetInt(int &value, int info, int contextWindow, const CGUI
case SYSTEM_BATTERY_LEVEL:
value = g_powerManager.BatteryLevel();
return true;
case PLAYER_PROCESS_VIDEOWIDTH:
value = g_dataCacheCore.GetVideoWidth();
return true;
case PLAYER_PROCESS_VIDEOHEIGHT:
value = g_dataCacheCore.GetVideoHeight();
return true;
case PLAYER_PROCESS_AUDIOSAMPLERATE:
value = g_dataCacheCore.GetAudioSampleRate();
return true;
case PLAYER_PROCESS_AUDIOBITSPERSAMPLE:
value = g_dataCacheCore.GetAudioBitsPerSampe();
return true;
}
return false;
}
Expand Down Expand Up @@ -7090,6 +7147,9 @@ bool CGUIInfoManager::GetBool(int condition1, int contextWindow, const CGUIListI
!m_currentFile->GetPVRRadioRDSInfoTag()->GetSMSStudio().empty() ||
!m_currentFile->GetPVRRadioRDSInfoTag()->GetPhoneStudio().empty());
break;
case PLAYER_PROCESS_VIDEOHWDECODER:
bReturn = g_dataCacheCore.IsVideoHwDecoder();
break;
default: // default, use integer value different from 0 as true
{
int val;
Expand Down
166 changes: 165 additions & 1 deletion xbmc/cores/DataCacheCore.cpp
Expand Up @@ -19,6 +19,12 @@
*/

#include "cores/DataCacheCore.h"
#include "threads/SingleLock.h"

CDataCacheCore::CDataCacheCore()
{
m_hasAVInfoChanges = false;
}

bool CDataCacheCore::HasAVInfoChanges()
{
Expand All @@ -35,4 +41,162 @@ void CDataCacheCore::SignalVideoInfoChange()
void CDataCacheCore::SignalAudioInfoChange()
{
m_hasAVInfoChanges = true;
}
}

void CDataCacheCore::SetVideoDecoderName(std::string name, bool isHw)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.decoderName = name;
m_playerVideoInfo.isHwDecoder = isHw;
}

std::string CDataCacheCore::GetVideoDecoderName()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.decoderName;
}

bool CDataCacheCore::IsVideoHwDecoder()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.isHwDecoder;
}


void CDataCacheCore::SetVideoDeintMethod(std::string method)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.deintMethod = method;
}

std::string CDataCacheCore::GetVideoDeintMethod()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.deintMethod;
}

void CDataCacheCore::SetVideoPixelFormat(std::string pixFormat)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.pixFormat = pixFormat;
}

std::string CDataCacheCore::GetVideoPixelFormat()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.pixFormat;
}

void CDataCacheCore::SetVideoDimensions(int width, int height)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.width = width;
m_playerVideoInfo.height = height;
}

int CDataCacheCore::GetVideoWidth()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.width;
}

int CDataCacheCore::GetVideoHeight()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.height;
}

void CDataCacheCore::SetVideoFps(float fps)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.fps = fps;
}

float CDataCacheCore::GetVideoFps()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.fps;
}

void CDataCacheCore::SetVideoAspectRatio(float aspectRatio)
{
CSingleLock lock(m_videoPlayerSection);

m_playerVideoInfo.aspectRatio = aspectRatio;
}

float CDataCacheCore::GetVideoAspectRatio()
{
CSingleLock lock(m_videoPlayerSection);

return m_playerVideoInfo.aspectRatio;
}

// player audio info
void CDataCacheCore::SetAudioDecoderName(std::string name)
{
CSingleLock lock(m_audioPlayerSection);

m_playerAudioInfo.decoderName = name;
}

std::string CDataCacheCore::GetAudioDecoderName()
{
CSingleLock lock(m_audioPlayerSection);

return m_playerAudioInfo.decoderName;
}

void CDataCacheCore::SetAudioChannels(std::string channels)
{
CSingleLock lock(m_audioPlayerSection);

m_playerAudioInfo.channels = channels;
}

std::string CDataCacheCore::GetAudioChannels()
{
CSingleLock lock(m_audioPlayerSection);

return m_playerAudioInfo.channels;
}

void CDataCacheCore::SetAudioSampleRate(int sampleRate)
{
CSingleLock lock(m_audioPlayerSection);

m_playerAudioInfo.sampleRate = sampleRate;
}

int CDataCacheCore::GetAudioSampleRate()
{
CSingleLock lock(m_audioPlayerSection);

return m_playerAudioInfo.sampleRate;
}

void CDataCacheCore::SetAudioBitsPerSample(int bitsPerSample)
{
CSingleLock lock(m_audioPlayerSection);

m_playerAudioInfo.bitsPerSample = bitsPerSample;
}

int CDataCacheCore::GetAudioBitsPerSampe()
{
CSingleLock lock(m_audioPlayerSection);

return m_playerAudioInfo.bitsPerSample;
}
57 changes: 54 additions & 3 deletions xbmc/cores/DataCacheCore.h
Expand Up @@ -20,15 +20,66 @@
*
*/

#include <atomic>
#include <string>
#include "threads/CriticalSection.h"

class CDataCacheCore
{
public:
CDataCacheCore();
bool HasAVInfoChanges();
void SignalVideoInfoChange();
void SignalAudioInfoChange();

// player video info
void SetVideoDecoderName(std::string name, bool isHw);
std::string GetVideoDecoderName();
bool IsVideoHwDecoder();
void SetVideoDeintMethod(std::string method);
std::string GetVideoDeintMethod();
void SetVideoPixelFormat(std::string pixFormat);
std::string GetVideoPixelFormat();
void SetVideoDimensions(int width, int height);
int GetVideoWidth();
int GetVideoHeight();
void SetVideoFps(float fps);
float GetVideoFps();
void SetVideoAspectRatio(float aspectRatio);
float GetVideoAspectRatio();

// player audio info
void SetAudioDecoderName(std::string name);
std::string GetAudioDecoderName();
void SetAudioChannels(std::string channels);
std::string GetAudioChannels();
void SetAudioSampleRate(int sampleRate);
int GetAudioSampleRate();
void SetAudioBitsPerSample(int bitsPerSample);
int GetAudioBitsPerSampe();

protected:
volatile bool m_hasAVInfoChanges;
};
std::atomic_bool m_hasAVInfoChanges;

extern CDataCacheCore g_dataCacheCore;
CCriticalSection m_videoPlayerSection;
struct SPlayerVideoInfo
{
std::string decoderName;
bool isHwDecoder;
std::string deintMethod;
std::string pixFormat;
int width;
int height;
float fps;
float aspectRatio;
} m_playerVideoInfo;

CCriticalSection m_audioPlayerSection;
struct SPlayerAudioInfo
{
std::string decoderName;
std::string channels;
int sampleRate;
int bitsPerSample;
} m_playerAudioInfo;
};
6 changes: 5 additions & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodec.h
Expand Up @@ -23,6 +23,7 @@
#include "system.h"
#include "cores/AudioEngine/Utils/AEAudioFormat.h"
#include "cores/AudioEngine/Utils/AEUtil.h"
#include "cores/VideoPlayer/Process/ProcessInfo.h"
#include "DVDClock.h"


Expand Down Expand Up @@ -64,7 +65,7 @@ class CDVDAudioCodec
{
public:

CDVDAudioCodec() {}
CDVDAudioCodec(CProcessInfo &processInfo) : m_processInfo(processInfo) {}
virtual ~CDVDAudioCodec() {}

/*
Expand Down Expand Up @@ -138,4 +139,7 @@ class CDVDAudioCodec
* should return the ffmpeg profile value
*/
virtual int GetProfile() { return 0; }

protected:
CProcessInfo &m_processInfo;
};
Expand Up @@ -35,7 +35,7 @@ extern "C" {
#include "cores/AudioEngine/Utils/AEUtil.h"
#endif

CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg() : CDVDAudioCodec()
CDVDAudioCodecFFmpeg::CDVDAudioCodecFFmpeg(CProcessInfo &processInfo) : CDVDAudioCodec(processInfo)
{
m_pCodecContext = NULL;

Expand Down Expand Up @@ -126,6 +126,7 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_iSampleFormat = AV_SAMPLE_FMT_NONE;
m_matrixEncoding = AV_MATRIX_ENCODING_NONE;

m_processInfo.SetAudioDecoderName(m_pCodecContext->codec->name);
return true;
}

Expand Down
4 changes: 3 additions & 1 deletion xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.h
Expand Up @@ -29,10 +29,12 @@ extern "C" {
#include "libswresample/swresample.h"
}

class CProcessInfo;

class CDVDAudioCodecFFmpeg : public CDVDAudioCodec
{
public:
CDVDAudioCodecFFmpeg();
CDVDAudioCodecFFmpeg(CProcessInfo &processInfo);
virtual ~CDVDAudioCodecFFmpeg();
virtual bool Open(CDVDStreamInfo &hints, CDVDCodecOptions &options);
virtual void Dispose();
Expand Down

0 comments on commit d2165e9

Please sign in to comment.