Permalink
Browse files

[IPlayer] Add struct SPlayerVideoStreamInfo and GetAudioStreamInfo(SP…

…layerVideoStreamInfo &info).

[Players/GUI] Remove
    GetVideoBitrate()
    GetVideoCodecName()
    GetVideoAspectRatio(float& fAR)
    GetVideoRect(CRect& SrcRect, CRect& DestRect)

from all players and replace the calls to them with calls to GetVideoStreamInfo(int iStream, SPlayerAudioStreamInfo &info).
  • Loading branch information...
ace20022 committed Feb 23, 2013
1 parent 6b61a06 commit 2cd39f64858758880a12bcf749c5cfb0654e6d38
View
@@ -1452,7 +1452,11 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
break;
case VIDEOPLAYER_VIDEO_CODEC:
if(g_application.IsPlaying() && g_application.m_pPlayer)
- strLabel = g_application.m_pPlayer->GetVideoCodecName();
+ {
+ SPlayerVideoStreamInfo info;
+ g_application.m_pPlayer->GetVideoStreamInfo(info);
+ strLabel = info.videoCodecName;
+ }
break;
case VIDEOPLAYER_VIDEO_RESOLUTION:
if(g_application.IsPlaying() && g_application.m_pPlayer)
@@ -1469,9 +1473,9 @@ CStdString CGUIInfoManager::GetLabel(int info, int contextWindow, CStdString *fa
case VIDEOPLAYER_VIDEO_ASPECT:
if (g_application.IsPlaying() && g_application.m_pPlayer)
{
- float aspect;
- g_application.m_pPlayer->GetVideoAspectRatio(aspect);
- strLabel = CStreamDetails::VideoAspectToAspectDescription(aspect);
+ SPlayerVideoStreamInfo info;
+ g_application.m_pPlayer->GetVideoStreamInfo(info);
+ strLabel = CStreamDetails::VideoAspectToAspectDescription(info.videoAspectRatio);
}
break;
case VIDEOPLAYER_AUDIO_CHANNELS:
View
@@ -110,6 +110,23 @@ struct SPlayerSubtitleStreamInfo
std::string name;
};
+struct SPlayerVideoStreamInfo
+{
+ int bitrate;
+ float videoAspectRatio;
+ std::string language;
+ std::string name;
+ std::string videoCodecName;
+ CRect SrcRect;
+ CRect DestRect;
+
+ SPlayerVideoStreamInfo()
+ {
+ bitrate = 0;
+ videoAspectRatio = 1.0f;
+ }
+};
+
class IPlayer
{
public:
@@ -143,8 +160,6 @@ class IPlayer
virtual void GetVideoInfo( CStdString& strVideoInfo) = 0;
virtual void GetGeneralInfo( CStdString& strVideoInfo) = 0;
virtual void Update(bool bPauseDrawing = false) = 0;
- virtual void GetVideoRect(CRect& SrcRect, CRect& DestRect) {}
- virtual void GetVideoAspectRatio(float& fAR) { fAR = 1.0f; }
virtual bool CanRecord() { return false;};
virtual bool IsRecording() { return false;};
virtual bool Record(bool bOnOff) { return false;};
@@ -186,11 +201,10 @@ class IPlayer
\brief total time in milliseconds
*/
virtual int64_t GetTotalTime() { return 0; }
- virtual int GetVideoBitrate(){ return 0;}
+ virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info){};
virtual int GetSourceBitrate(){ return 0;}
virtual int GetBitsPerSample(){ return 0;};
virtual int GetSampleRate(){ return 0;};
- virtual CStdString GetVideoCodecName(){ return "";}
virtual int GetPictureWidth(){ return 0;}
virtual int GetPictureHeight(){ return 0;}
virtual bool GetStreamDetails(CStreamDetails &details){ return false;}
@@ -995,16 +995,6 @@ void CAMLPlayer::Update(bool bPauseDrawing)
g_renderManager.Update(bPauseDrawing);
}
-void CAMLPlayer::GetVideoRect(CRect& SrcRect, CRect& DestRect)
-{
- g_renderManager.GetVideoRect(SrcRect, DestRect);
-}
-
-void CAMLPlayer::GetVideoAspectRatio(float &fAR)
-{
- fAR = g_renderManager.GetAspectRatio();
-}
-
int CAMLPlayer::GetChapterCount()
{
return m_chapter_count;
@@ -1132,13 +1122,16 @@ void CAMLPlayer::GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info)
}
}
-int CAMLPlayer::GetVideoBitrate()
+void CAMLPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
{
CSingleLock lock(m_aml_csection);
if (m_video_streams.size() == 0 || m_video_index > (int)(m_video_streams.size() - 1))
- return 0;
+ return;
- return m_video_streams[m_video_index]->bit_rate;
+ info.bitrate = m_video_streams[m_video_index]->bit_rate;
+ info.videoCodecName = VideoCodecName(m_video_streams[m_video_index]->format);
+ info.videoAspectRatio = g_renderManager.GetAspectRatio();
+ g_renderManager.GetVideoRect(info.SrcRect, info.DestRect);
}
int CAMLPlayer::GetSourceBitrate()
@@ -1162,17 +1155,6 @@ int CAMLPlayer::GetSampleRate()
return m_audio_streams[m_audio_index]->sample_rate;
}
-CStdString CAMLPlayer::GetVideoCodecName()
-{
- CStdString strVideoCodec = "";
- if (m_video_streams.size() == 0 || m_video_index > (int)(m_video_streams.size() - 1))
- return strVideoCodec;
-
- strVideoCodec = VideoCodecName(m_video_streams[m_video_index]->format);
-
- return strVideoCodec;
-}
-
int CAMLPlayer::GetPictureWidth()
{
//CLog::Log(LOGDEBUG, "CAMLPlayer::GetPictureWidth(%d)", m_video_width);
@@ -88,8 +88,6 @@ class CAMLPlayer : public IPlayer, public CThread
virtual void GetVideoInfo(CStdString &strVideoInfo);
virtual void GetGeneralInfo(CStdString &strVideoInfo) {};
virtual void Update(bool bPauseDrawing);
- virtual void GetVideoRect(CRect& SrcRect, CRect& DestRect);
- virtual void GetVideoAspectRatio(float &fAR);
virtual bool CanRecord() {return false;};
virtual bool IsRecording() {return false;};
virtual bool Record(bool bOnOff) {return false;};
@@ -124,11 +122,10 @@ class CAMLPlayer : public IPlayer, public CThread
virtual __int64 GetTime();
virtual __int64 GetTotalTime();
virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
- virtual int GetVideoBitrate();
+ virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
virtual int GetSourceBitrate();
virtual int GetBitsPerSample();
virtual int GetSampleRate();
- virtual CStdString GetVideoCodecName();
virtual int GetPictureWidth();
virtual int GetPictureHeight();
virtual bool GetStreamDetails(CStreamDetails &details);
@@ -3558,7 +3558,7 @@ bool CDVDPlayer::OnAction(const CAction &action)
case ACTION_MOUSE_LEFT_CLICK:
{
CRect rs, rd;
- GetVideoRect(rs, rd);
+ m_dvdPlayerVideo.GetVideoRect(rs, rd);
CPoint pt(action.GetAmount(), action.GetAmount(1));
if (!rd.PtInRect(pt))
return false; // out of bounds
@@ -3783,9 +3783,16 @@ double CDVDPlayer::GetQueueTime()
return max(a, v) * 8000.0 / 100;
}
-int CDVDPlayer::GetVideoBitrate()
+void CDVDPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
{
- return m_dvdPlayerVideo.GetVideoBitrate();
+ info.bitrate = m_dvdPlayerVideo.GetVideoBitrate();
+
+ CStdString retVal;
+ if (m_pDemuxer && (m_CurrentVideo.id != -1))
+ m_pDemuxer->GetStreamCodecName(m_CurrentVideo.id, retVal);
+ info.videoCodecName = retVal;
+ info.videoAspectRatio = m_dvdPlayerVideo.GetAspectRatio();
+ m_dvdPlayerVideo.GetVideoRect(info.SrcRect, info.DestRect);
}
int CDVDPlayer::GetSourceBitrate()
@@ -4045,14 +4052,6 @@ bool CDVDPlayer::Record(bool bOnOff)
return false;
}
-CStdString CDVDPlayer::GetVideoCodecName()
-{
- CStdString retVal;
- if (m_pDemuxer && (m_CurrentVideo.id != -1))
- m_pDemuxer->GetStreamCodecName(m_CurrentVideo.id, retVal);
- return retVal;
-}
-
int CDVDPlayer::GetPictureWidth()
{
if (m_pDemuxer && (m_CurrentVideo.id != -1))
@@ -4082,7 +4081,7 @@ bool CDVDPlayer::GetStreamDetails(CStreamDetails &details)
bool result=CDVDFileInfo::DemuxerToStreamDetails(m_pInputStream, m_pDemuxer, details);
if (result && details.GetStreamCount(CStreamDetail::VIDEO) > 0) // this is more correct (dvds in particular)
{
- GetVideoAspectRatio(((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect);
+ ((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect = m_dvdPlayerVideo.GetAspectRatio();
((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_iDuration = GetTotalTime() / 1000;
}
return result;
@@ -193,8 +193,6 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
virtual void GetVideoInfo(CStdString& strVideoInfo);
virtual void GetGeneralInfo( CStdString& strVideoInfo);
virtual void Update(bool bPauseDrawing) { m_dvdPlayerVideo.Update(bPauseDrawing); }
- virtual void GetVideoRect(CRect& SrcRect, CRect& DestRect) { m_dvdPlayerVideo.GetVideoRect(SrcRect, DestRect); }
- virtual void GetVideoAspectRatio(float& fAR) { fAR = m_dvdPlayerVideo.GetAspectRatio(); }
virtual bool CanRecord();
virtual bool IsRecording();
virtual bool CanPause();
@@ -231,9 +229,8 @@ class CDVDPlayer : public IPlayer, public CThread, public IDVDPlayer
virtual bool OnAction(const CAction &action);
virtual bool HasMenu();
- virtual int GetVideoBitrate();
virtual int GetSourceBitrate();
- virtual CStdString GetVideoCodecName();
+ virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
virtual int GetPictureWidth();
virtual int GetPictureHeight();
virtual bool GetStreamDetails(CStreamDetails &details);
@@ -3554,7 +3554,7 @@ bool COMXPlayer::OnAction(const CAction &action)
case ACTION_MOUSE_LEFT_CLICK:
{
CRect rs, rd;
- GetVideoRect(rs, rd);
+ g_renderManager.GetVideoRect(rs, rd);
CPoint pt(action.GetAmount(), action.GetAmount(1));
if (!rd.PtInRect(pt))
return false; // out of bounds
@@ -3814,9 +3814,16 @@ void COMXPlayer::GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info)
}
}
-int COMXPlayer::GetVideoBitrate()
+void COMXPlayer::GetVideoStreamInfo(SPlayerVideoStreamInfo &info)
{
- return m_player_video.GetVideoBitrate();
+ info.bitrate = m_player_video.GetVideoBitrate();
+
+ CStdString retVal;
+ if (m_pDemuxer && (m_CurrentVideo.id != -1))
+ m_pDemuxer->GetStreamCodecName(m_CurrentVideo.id, retVal);
+ info.videoCodecName = retVal;
+ info.videoAspectRatio = g_renderManager.GetAspectRatio();
+ g_renderManager.GetVideoRect(info.SrcRect, info.DestRect);
}
int COMXPlayer::GetSourceBitrate()
@@ -4037,14 +4044,6 @@ bool COMXPlayer::Record(bool bOnOff)
return false;
}
-CStdString COMXPlayer::GetVideoCodecName()
-{
- CStdString retVal;
- if (m_pDemuxer && (m_CurrentVideo.id != -1))
- m_pDemuxer->GetStreamCodecName(m_CurrentVideo.id, retVal);
- return retVal;
-}
-
int COMXPlayer::GetPictureWidth()
{
if (m_pDemuxer && (m_CurrentVideo.id != -1))
@@ -4074,7 +4073,7 @@ bool COMXPlayer::GetStreamDetails(CStreamDetails &details)
bool result=CDVDFileInfo::DemuxerToStreamDetails(m_pInputStream, m_pDemuxer, details);
if (result && details.GetStreamCount(CStreamDetail::VIDEO) > 0) // this is more correct (dvds in particular)
{
- GetVideoAspectRatio(((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect);
+ ((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_fAspect = g_renderManager.GetAspectRatio();
((CStreamDetailVideo*)details.GetNthStream(CStreamDetail::VIDEO,0))->m_iDuration = GetTotalTime() / 1000;
}
return result;
@@ -4123,11 +4122,6 @@ bool COMXPlayer::CachePVRStream(void) const
g_advancedSettings.m_bPVRCacheInDvdPlayer;
}
-void COMXPlayer::GetVideoRect(CRect& SrcRect, CRect& DestRect)
-{
- g_renderManager.GetVideoRect(SrcRect, DestRect);
-}
-
void COMXPlayer::SetMute(bool bOnOff)
{
m_current_mute = bOnOff;
@@ -4162,11 +4156,6 @@ void COMXPlayer::Update(bool bPauseDrawing)
g_renderManager.Update(bPauseDrawing);
}
-void COMXPlayer::GetVideoAspectRatio(float &fAR)
-{
- fAR = g_renderManager.GetAspectRatio();
-}
-
void COMXPlayer::GetRenderFeatures(std::vector<int> &renderFeatures)
{
renderFeatures.push_back(RENDERFEATURE_STRETCH);
@@ -235,8 +235,6 @@ class COMXPlayer : public IPlayer, public CThread, public IDVDPlayer
virtual void GetVideoInfo(CStdString &strVideoInfo);
virtual void GetGeneralInfo(CStdString &strVideoInfo);
virtual void Update(bool bPauseDrawing);
- virtual void GetVideoRect(CRect& SrcRect, CRect& DestRect);
- virtual void GetVideoAspectRatio(float &fAR);
virtual void UpdateApplication(double timeout);
virtual bool CanRecord();
virtual bool IsRecording();
@@ -273,9 +271,8 @@ class COMXPlayer : public IPlayer, public CThread, public IDVDPlayer
virtual int64_t GetTotalTime();
virtual void ToFFRW(int iSpeed = 0);
virtual void GetAudioStreamInfo(int index, SPlayerAudioStreamInfo &info);
- virtual int GetVideoBitrate();
+ virtual void GetVideoStreamInfo(SPlayerVideoStreamInfo &info);
virtual int GetSourceBitrate();
- virtual CStdString GetVideoCodecName();
virtual int GetPictureWidth();
virtual int GetPictureHeight();
virtual bool GetStreamDetails(CStreamDetails &details);
@@ -951,10 +951,8 @@ void CGUIWindowFullScreen::FrameMove()
OnMessage(msg);
}
// show sizing information
- CRect SrcRect, DestRect;
- float fAR;
- g_application.m_pPlayer->GetVideoRect(SrcRect, DestRect);
- g_application.m_pPlayer->GetVideoAspectRatio(fAR);
+ SPlayerVideoStreamInfo info;
+ g_application.m_pPlayer->GetVideoStreamInfo(info);
{
// Splitres scaling factor
RESOLUTION res = g_graphicsContext.GetVideoResolution();
@@ -963,9 +961,9 @@ void CGUIWindowFullScreen::FrameMove()
CStdString strSizing;
strSizing.Format(g_localizeStrings.Get(245),
- (int)SrcRect.Width(), (int)SrcRect.Height(),
- (int)(DestRect.Width() * xscale), (int)(DestRect.Height() * yscale),
- g_settings.m_fZoomAmount, fAR*g_settings.m_fPixelRatio,
+ (int)info.SrcRect.Width(), (int)info.SrcRect.Height(),
+ (int)(info.DestRect.Width() * xscale), (int)(info.DestRect.Height() * yscale),
+ g_settings.m_fZoomAmount, info.videoAspectRatio*g_settings.m_fPixelRatio,
g_settings.m_fPixelRatio, g_settings.m_fVerticalShift);
CGUIMessage msg(GUI_MSG_LABEL_SET, GetID(), LABEL_ROW2);
msg.SetLabel(strSizing);
@@ -1122,13 +1120,13 @@ void CGUIWindowFullScreen::RenderTTFSubtitles()
y = (float) g_settings.m_ResInfo[res].iSubtitles - textHeight;
else
{
- CRect SrcRect, DestRect;
- g_application.m_pPlayer->GetVideoRect(SrcRect, DestRect);
+ SPlayerVideoStreamInfo info;
+ g_application.m_pPlayer->GetVideoStreamInfo(info);
if ((subalign == SUBTITLE_ALIGN_TOP_INSIDE) || (subalign == SUBTITLE_ALIGN_TOP_OUTSIDE))
- y = DestRect.y1;
+ y = info.DestRect.y1;
else
- y = DestRect.y2;
+ y = info.DestRect.y2;
// use the manual distance to the screenbottom as an offset to the automatic location
if ((subalign == SUBTITLE_ALIGN_BOTTOM_INSIDE) || (subalign == SUBTITLE_ALIGN_TOP_OUTSIDE))

0 comments on commit 2cd39f6

Please sign in to comment.