[bluray] Fix stream info/language retrieval for blurays in non-nav mode.
[vuplus_xbmc] / xbmc / linux / OMXClock.h
1 /*
2  *      Copyright (C) 2005-2013 Team XBMC
3  *      http://www.xbmc.org
4  *
5  *  This Program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2, or (at your option)
8  *  any later version.
9  *
10  *  This Program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with XBMC; see the file COPYING.  If not, see
17  *  <http://www.gnu.org/licenses/>.
18  *
19  */
20
21 #ifndef _AVCLOCK_H_
22 #define _AVCLOCK_H_
23
24 #if defined(HAVE_OMXLIB)
25
26 #include "OMXCore.h"
27 #include "DVDClock.h"
28 #include "linux/XTimeUtils.h"
29
30 #ifdef OMX_SKIP64BIT
31 static inline OMX_TICKS ToOMXTime(int64_t pts)
32 {
33   OMX_TICKS ticks;
34   ticks.nLowPart = pts;
35   ticks.nHighPart = pts >> 32;
36   return ticks;
37 }
38 static inline int64_t FromOMXTime(OMX_TICKS ticks)
39 {
40   int64_t pts = ticks.nLowPart | ((uint64_t)(ticks.nHighPart) << 32);
41   return pts;
42 }
43 #else
44 #define FromOMXTime(x) (x)
45 #define ToOMXTime(x) (x)
46 #endif
47
48 enum {
49   AV_SYNC_AUDIO_MASTER,
50   AV_SYNC_VIDEO_MASTER,
51   AV_SYNC_EXTERNAL_MASTER,
52 };
53
54 class OMXClock
55 {
56 protected:
57   bool              m_pause;
58   bool              m_has_video;
59   bool              m_has_audio;
60   int               m_play_speed;
61   pthread_mutex_t   m_lock;
62   double            m_fps;
63   int               m_omx_speed;
64   bool              m_video_start;
65   bool              m_audio_start;
66   CDVDClock         *m_clock;
67 private:
68   COMXCoreComponent m_omx_clock;
69 public:
70   OMXClock();
71   ~OMXClock();
72   void Lock();
73   void UnLock();
74   double GetAbsoluteClock(bool interpolated = true) { return m_clock ? m_clock->GetAbsoluteClock(interpolated):0; }
75   double GetClock(bool interpolated = true) { return m_clock ? m_clock->GetClock(interpolated):0; }
76   double GetClock(double& absolute, bool interpolated = true) { return m_clock ? m_clock->GetClock(absolute, interpolated):0; }
77   void Discontinuity(double currentPts = 0LL) { if (m_clock) m_clock->Discontinuity(currentPts); }
78   void OMXSetClockPorts(OMX_TIME_CONFIG_CLOCKSTATETYPE *clock);
79   bool OMXSetReferenceClock(bool lock = true);
80   bool OMXInitialize(CDVDClock *clock, bool has_video, bool has_audio);
81   void OMXDeinitialize();
82   bool OMXIsPaused() { return m_pause; };
83   bool OMXStop(bool lock = true);
84   bool OMXStep(int steps = 1, bool lock = true);
85   bool OMXReset(bool lock = true);
86   double OMXMediaTime(bool lock = true);
87   double OMXClockAdjustment(bool lock = true);
88   bool OMXMediaTime(double pts, bool lock = true);
89   bool OMXPause(bool lock = true);
90   bool OMXResume(bool lock = true);
91   bool OMXSetSpeed(int speed, bool lock = true, bool pause_resume = false);
92   int  OMXPlaySpeed() { return m_omx_speed; };
93   COMXCoreComponent *GetOMXClock();
94   bool OMXStateExecute(bool lock = true);
95   void OMXStateIdle(bool lock = true);
96   bool HDMIClockSync(bool lock = true);
97   static int64_t CurrentHostCounter(void);
98   static int64_t CurrentHostFrequency(void);
99   bool HasVideo() { return m_has_video; };
100   bool HasAudio() { return m_has_audio; };
101   void HasVideo(bool has_video) { m_has_video = has_video; };
102   void HasAudio(bool has_audio) { m_has_audio = has_audio; };
103
104   int     GetRefreshRate(double* interval = NULL);
105   void    SetRefreshRate(double fps) { m_fps = fps; };
106
107   static double NormalizeFrameduration(double frameduration);
108 };
109
110 #endif
111
112 #endif