MythTV  0.27pre
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Groups Pages
bdringbuffer.h
Go to the documentation of this file.
1 #ifndef BD_RING_BUFFER_H_
2 #define BD_RING_BUFFER_H_
3 
4 #define BD_BLOCK_SIZE 6144LL
5 
6 #include <QString>
7 #include <QRect>
8 #include <QHash>
9 
10 // external/libmythbluray
11 #include "bluray.h"
12 #include "keys.h" // Likely to cause collisions?
13 
14 #include "ringbuffer.h"
15 #include "mythdate.h"
16 
23 class BDOverlay
24 {
25  public:
26  static void DeleteOverlay(BDOverlay *overlay)
27  {
28  if (!overlay)
29  return;
30  if (overlay->m_data)
31  av_free(overlay->m_data);
32  if (overlay->m_palette)
33  av_free(overlay->m_palette);
34  delete overlay;
35  overlay = NULL;
36  }
37 
38  BDOverlay(uint8_t *data, uint8_t *palette, QRect position, int plane,
39  int64_t pts)
40  : m_data(data), m_palette(palette), m_position(position),
41  m_plane(plane), m_pts(pts) { }
42 
43  uint8_t *m_data;
44  uint8_t *m_palette;
45  QRect m_position;
46  int m_plane;
47  int64_t m_pts;
48 };
49 
50 class MTV_PUBLIC BDRingBuffer : public RingBuffer
51 {
52  public:
53  BDRingBuffer(const QString &lfilename);
54  virtual ~BDRingBuffer();
55 
56  virtual bool IsStreamed(void) { return true; }
57 
58  void ProgressUpdate(void);
59 
60  // Player interaction
61  bool BDWaitingForPlayer(void) { return m_playerWait; }
62  void SkipBDWaitingForPlayer(void) { m_playerWait = false; }
63  virtual void IgnoreWaitStates(bool ignore) { m_ignorePlayerWait = ignore; }
64  virtual bool StartFromBeginning(void);
65  bool GetNameAndSerialNum(QString& _name, QString& _serialnum);
66 
67  void ClearOverlays(void);
68  BDOverlay* GetOverlay(void);
69  void SubmitOverlay(const bd_overlay_s * const overlay);
70 
71  uint32_t GetNumTitles(void) const { return m_numTitles; }
72  int GetCurrentTitle(void);
73  uint64_t GetCurrentAngle(void) const { return m_currentAngle; }
74  int GetTitleDuration(int title);
75  // Get the size in bytes of the current title (playlist item).
76  uint64_t GetTitleSize(void) const { return m_titlesize; }
77  // Get The total duration of the current title in 90Khz ticks.
78  uint64_t GetTotalTimeOfTitle(void) const { return (m_currentTitleLength / 90000); }
79  uint64_t GetCurrentTime(void) { return (m_currentTime / 90000); }
80  virtual long long GetReadPosition(void) const; // RingBuffer
81  uint64_t GetTotalReadPosition(void);
82  uint32_t GetNumChapters(void);
83  uint32_t GetCurrentChapter(void);
84  uint64_t GetNumAngles(void) { return m_currentTitleAngleCount; }
85  uint64_t GetChapterStartTime(uint32_t chapter);
86  uint64_t GetChapterStartFrame(uint32_t chapter);
87  bool IsOpen(void) const { return bdnav; }
88  bool IsHDMVNavigation(void) const { return m_isHDMVNavigation; }
89  virtual bool IsInMenu(void) const { return m_inMenu; }
90  virtual bool IsInStillFrame(void) const;
91  bool TitleChanged(void);
92 
93  void GetDescForPos(QString &desc);
94  double GetFrameRate(void);
95 
96  int GetAudioLanguage(uint streamID);
97  int GetSubtitleLanguage(uint streamID);
98 
99  // commands
100  virtual bool HandleAction(const QStringList &actions, int64_t pts);
101  virtual bool OpenFile(const QString &filename,
102  uint retry_ms = kDefaultOpenTimeout);
103  void close(void);
104 
105  bool GoToMenu(const QString str, int64_t pts);
106  bool SwitchTitle(uint32_t index);
107  bool SwitchPlaylist(uint32_t index);
108  bool SwitchAngle(uint angle);
109 
110  virtual int safe_read(void *data, uint sz);
111  virtual long long Seek(long long pos, int whence, bool has_lock);
112  uint64_t Seek(uint64_t pos);
113 
114  private:
115 
116  // private player interaction
117  void WaitForPlayer(void);
118 
119  // private title handling
120  bool UpdateTitleInfo(void);
121  BLURAY_TITLE_INFO* GetTitleInfo(uint32_t index);
122  BLURAY_TITLE_INFO* GetPlaylistInfo(uint32_t index);
123 
124  // private menu handling methods
125  void PressButton(int32_t key, int64_t pts); // Keyboard
126  void ClickButton(int64_t pts, uint16_t x, uint16_t y); // Mouse
127 
128  // private bluray event handling
129  bool HandleBDEvents(void);
130  void HandleBDEvent(BD_EVENT &event);
131 
132  BLURAY *bdnav;
137 
138  uint32_t m_numTitles;
139  uint32_t m_mainTitle; // Index number of main title
140  uint64_t m_currentTitleLength; // Selected title's duration, in ticks (90Khz)
141  BLURAY_TITLE_INFO *m_currentTitleInfo; // Selected title info from struct in bluray.h
142  uint64_t m_titlesize;
144  uint64_t m_currentTime;
145 
151 
157 
162 
164 
167 
169  QList<BDOverlay*> m_overlayImages;
170 
171  uint8_t m_stillTime;
172  uint8_t m_stillMode;
173  volatile bool m_inMenu;
174 
175  QHash<uint32_t,BLURAY_TITLE_INFO*> m_cachedTitleInfo;
176  QHash<uint32_t,BLURAY_TITLE_INFO*> m_cachedPlaylistInfo;
177  QMutex m_infoLock;
178 
179  QThread *m_mainThread;
180 };
181 #endif