/xbmc/cores/dvdplayer/DVDPlayerVideo.h

http://github.com/xbmc/xbmc · C Header · 186 lines · 121 code · 41 blank · 24 comment · 0 complexity · 5fcf09a6529c5ec0a4b37de0a21c9b4f MD5 · raw file

  1. #pragma once
  2. /*
  3. * Copyright (C) 2005-2013 Team XBMC
  4. * http://xbmc.org
  5. *
  6. * This Program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2, or (at your option)
  9. * any later version.
  10. *
  11. * This Program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with XBMC; see the file COPYING. If not, see
  18. * <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. #include "threads/Thread.h"
  22. #include "DVDMessageQueue.h"
  23. #include "DVDDemuxers/DVDDemuxUtils.h"
  24. #include "DVDCodecs/Video/DVDVideoCodec.h"
  25. #include "DVDClock.h"
  26. #include "DVDOverlayContainer.h"
  27. #include "DVDTSCorrection.h"
  28. #ifdef HAS_VIDEO_PLAYBACK
  29. #include "cores/VideoRenderers/RenderManager.h"
  30. #endif
  31. class CDemuxStreamVideo;
  32. class CDVDOverlayCodecCC;
  33. #define VIDEO_PICTURE_QUEUE_SIZE 1
  34. class CDVDPlayerVideo : public CThread
  35. {
  36. public:
  37. CDVDPlayerVideo( CDVDClock* pClock
  38. , CDVDOverlayContainer* pOverlayContainer
  39. , CDVDMessageQueue& parent);
  40. virtual ~CDVDPlayerVideo();
  41. bool OpenStream(CDVDStreamInfo &hint);
  42. void OpenStream(CDVDStreamInfo &hint, CDVDVideoCodec* codec);
  43. void CloseStream(bool bWaitForBuffers);
  44. void StepFrame();
  45. void Flush();
  46. // waits until all available data has been rendered
  47. // just waiting for packetqueue should be enough for video
  48. void WaitForBuffers() { m_messageQueue.WaitUntilEmpty(); }
  49. bool AcceptsData() const { return !m_messageQueue.IsFull(); }
  50. bool HasData() const { return m_messageQueue.GetDataSize() > 0; }
  51. int GetLevel();
  52. bool IsInited() const { return m_messageQueue.IsInited(); }
  53. void SendMessage(CDVDMsg* pMsg, int priority = 0) { m_messageQueue.Put(pMsg, priority); }
  54. void EnableSubtitle(bool bEnable) { m_bRenderSubs = bEnable; }
  55. bool IsSubtitleEnabled() { return m_bRenderSubs; }
  56. void EnableFullscreen(bool bEnable) { m_bAllowFullscreen = bEnable; }
  57. #ifdef HAS_VIDEO_PLAYBACK
  58. void GetVideoRect(CRect& SrcRect, CRect& DestRect) { g_renderManager.GetVideoRect(SrcRect, DestRect); }
  59. float GetAspectRatio() { return g_renderManager.GetAspectRatio(); }
  60. #endif
  61. double GetDelay() { return m_iVideoDelay; }
  62. void SetDelay(double delay) { m_iVideoDelay = delay; }
  63. double GetSubtitleDelay() { return m_iSubtitleDelay; }
  64. void SetSubtitleDelay(double delay) { m_iSubtitleDelay = delay; }
  65. bool IsStalled() { return m_stalled; }
  66. int GetNrOfDroppedFrames() { return m_iDroppedFrames; }
  67. bool InitializedOutputDevice();
  68. double GetCurrentPts() { return m_iCurrentPts; }
  69. int GetPullupCorrection() { return m_pullupCorrection.GetPatternLength(); }
  70. double GetOutputDelay(); /* returns the expected delay, from that a packet is put in queue */
  71. std::string GetPlayerInfo();
  72. int GetVideoBitrate();
  73. std::string GetStereoMode();
  74. void SetSpeed(int iSpeed);
  75. // classes
  76. CDVDOverlayContainer* m_pOverlayContainer;
  77. CDVDClock* m_pClock;
  78. protected:
  79. virtual void OnStartup();
  80. virtual void OnExit();
  81. virtual void Process();
  82. #define EOS_ABORT 1
  83. #define EOS_DROPPED 2
  84. #define EOS_VERYLATE 4
  85. void AutoCrop(DVDVideoPicture* pPicture);
  86. void AutoCrop(DVDVideoPicture *pPicture, RECT &crop);
  87. CRect m_crop;
  88. int OutputPicture(const DVDVideoPicture* src, double pts);
  89. #ifdef HAS_VIDEO_PLAYBACK
  90. void ProcessOverlays(DVDVideoPicture* pSource, double pts);
  91. #endif
  92. void ProcessVideoUserData(DVDVideoUserData* pVideoUserData, double pts);
  93. CDVDMessageQueue m_messageQueue;
  94. CDVDMessageQueue& m_messageParent;
  95. double m_iCurrentPts; // last pts displayed
  96. double m_iVideoDelay;
  97. double m_iSubtitleDelay;
  98. double m_FlipTimeStamp; // time stamp of last flippage. used to play at a forced framerate
  99. int m_iLateFrames;
  100. int m_iDroppedFrames;
  101. int m_iDroppedRequest;
  102. void ResetFrameRateCalc();
  103. void CalcFrameRate();
  104. double m_fFrameRate; //framerate of the video currently playing
  105. bool m_bCalcFrameRate; //if we should calculate the framerate from the timestamps
  106. double m_fStableFrameRate; //place to store calculated framerates
  107. int m_iFrameRateCount; //how many calculated framerates we stored in m_fStableFrameRate
  108. bool m_bAllowDrop; //we can't drop frames until we've calculated the framerate
  109. int m_iFrameRateErr; //how many frames we couldn't calculate the framerate, we give up after a while
  110. int m_iFrameRateLength; //how many seconds we should measure the framerate
  111. //this is increased exponentially from CDVDPlayerVideo::CalcFrameRate()
  112. bool m_bFpsInvalid; // needed to ignore fps (e.g. dvd stills)
  113. struct SOutputConfiguration
  114. {
  115. unsigned int width;
  116. unsigned int height;
  117. unsigned int dwidth;
  118. unsigned int dheight;
  119. unsigned int color_format;
  120. unsigned int extended_format;
  121. unsigned int color_matrix : 4;
  122. unsigned int color_range : 1;
  123. unsigned int chroma_position;
  124. unsigned int color_primaries;
  125. unsigned int color_transfer;
  126. unsigned int stereo_flags;
  127. double framerate;
  128. } m_output; //holds currently configured output
  129. bool m_bAllowFullscreen;
  130. bool m_bRenderSubs;
  131. float m_fForcedAspectRatio;
  132. int m_iNrOfPicturesNotToSkip;
  133. int m_speed;
  134. bool m_stalled;
  135. bool m_started;
  136. std::string m_codecname;
  137. BitstreamStats m_videoStats;
  138. // classes
  139. CDVDStreamInfo m_hints;
  140. CDVDVideoCodec* m_pVideoCodec;
  141. CDVDOverlayCodecCC* m_pOverlayCodecCC;
  142. DVDVideoPicture* m_pTempOverlayPicture;
  143. CPullupCorrection m_pullupCorrection;
  144. std::list<DVDMessageListItem> m_packets;
  145. };