PageRenderTime 60ms CodeModel.GetById 19ms app.highlight 36ms RepoModel.GetById 1ms app.codeStats 0ms

/xbmc/cores/dvdplayer/DVDMessage.h

http://github.com/xbmc/xbmc
C++ Header | 307 lines | 196 code | 54 blank | 57 comment | 3 complexity | a69ed314c21e9ff7549a9c1f3ff23907 MD5 | raw file
  1/*
  2 *      Copyright (C) 2005-2013 Team XBMC
  3 *      http://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
 22#pragma once
 23
 24#ifdef __GNUC__
 25// under gcc, inline will only take place if optimizations are applied (-O). this will force inline even whith optimizations.
 26#define XBMC_FORCE_INLINE __attribute__((always_inline))
 27#else
 28#define XBMC_FORCE_INLINE
 29#endif
 30
 31// include as less is possible to prevent dependencies
 32#include "system.h"
 33#include "DVDDemuxers/DVDDemux.h"
 34#include "DVDMessageTracker.h"
 35#include "DVDResource.h"
 36
 37#include <assert.h>
 38
 39class CDVDMsg : public IDVDResourceCounted<CDVDMsg>
 40{
 41public:
 42  enum Message
 43  {
 44    NONE = 1000,
 45
 46
 47    // messages used in the whole system
 48
 49    GENERAL_RESYNC,                 //
 50    GENERAL_FLUSH,                  // flush all buffers
 51    GENERAL_RESET,                  // reset codecs for new data
 52    GENERAL_STREAMCHANGE,           //
 53    GENERAL_SYNCHRONIZE,            //
 54    GENERAL_DELAY,                  //
 55    GENERAL_GUI_ACTION,             // gui action of some sort
 56    GENERAL_EOF,                    // eof of stream
 57
 58
 59    // player core related messages (cdvdplayer.cpp)
 60
 61    PLAYER_SET_AUDIOSTREAM,         //
 62    PLAYER_SET_SUBTITLESTREAM,      //
 63    PLAYER_SET_SUBTITLESTREAM_VISIBLE, //
 64    PLAYER_SET_STATE,               // restore the dvdplayer to a certain state
 65    PLAYER_SET_RECORD,              // set record state
 66    PLAYER_SEEK,                    //
 67    PLAYER_SEEK_CHAPTER,            //
 68    PLAYER_SETSPEED,                // set the playback speed
 69
 70    PLAYER_CHANNEL_NEXT,            // switches to next playback channel
 71    PLAYER_CHANNEL_PREV,            // switches to previous playback channel
 72    PLAYER_CHANNEL_SELECT_NUMBER,   // switches to the channel with the provided channel number
 73    PLAYER_CHANNEL_SELECT,          // switches to the provided channel
 74    PLAYER_STARTED,                 // sent whenever a sub player has finished it's first frame after open
 75
 76    PLAYER_DISPLAYTIME,             // display time struct from av players
 77
 78    // demuxer related messages
 79
 80    DEMUXER_PACKET,                 // data packet
 81    DEMUXER_RESET,                  // reset the demuxer
 82
 83
 84    // video related messages
 85
 86    VIDEO_NOSKIP,                   // next pictures is not to be skipped by the video renderer
 87    VIDEO_SET_ASPECT,               // set aspectratio of video
 88
 89    // audio related messages
 90
 91    AUDIO_SILENCE,
 92
 93    // subtitle related messages
 94    SUBTITLE_CLUTCHANGE
 95  };
 96
 97  CDVDMsg(Message msg)
 98  {
 99    m_message = msg;
100
101#ifdef DVDDEBUG_MESSAGE_TRACKER
102    g_dvdMessageTracker.Register(this);
103#endif
104  }
105
106  virtual ~CDVDMsg()
107  {
108#ifdef DVDDEBUG_MESSAGE_TRACKER
109    g_dvdMessageTracker.UnRegister(this);
110#endif
111  }
112
113  /**
114   * checks for message type
115   */
116  inline bool IsType(Message msg) XBMC_FORCE_INLINE
117  {
118    return (m_message == msg);
119  }
120
121  inline Message GetMessageType() XBMC_FORCE_INLINE
122  {
123    return m_message;
124  }
125
126  long GetNrOfReferences()
127  {
128    return m_refs;
129  }
130
131private:
132  Message m_message;
133};
134
135////////////////////////////////////////////////////////////////////////////////
136//////
137////// GENERAL_ Messages
138//////
139////////////////////////////////////////////////////////////////////////////////
140
141class CDVDMsgGeneralResync : public CDVDMsg
142{
143public:
144  CDVDMsgGeneralResync(double timestamp, bool clock) : CDVDMsg(GENERAL_RESYNC)  { m_timestamp = timestamp; m_clock = clock; }
145  double m_timestamp;
146  bool m_clock;
147};
148
149#define SYNCSOURCE_AUDIO  0x00000001
150#define SYNCSOURCE_VIDEO  0x00000002
151#define SYNCSOURCE_SUB    0x00000004
152#define SYNCSOURCE_OWNER  0x80000000 /* only allowed for the constructor of the object */
153#define SYNCSOURCE_ALL    (SYNCSOURCE_AUDIO | SYNCSOURCE_VIDEO | SYNCSOURCE_SUB | SYNCSOURCE_OWNER)
154
155class CDVDMsgGeneralSynchronizePriv;
156class CDVDMsgGeneralSynchronize : public CDVDMsg
157{
158public:
159  CDVDMsgGeneralSynchronize(unsigned int timeout, unsigned int sources);
160 ~CDVDMsgGeneralSynchronize();
161  virtual long Release();
162
163  // waits until all threads waiting, released the object
164  // if abort is set somehow
165  bool Wait(unsigned int   ms   , unsigned int source);
166  void Wait(volatile bool *abort, unsigned int source);
167private:
168  class CDVDMsgGeneralSynchronizePriv* m_p;
169};
170
171template <typename T>
172class CDVDMsgType : public CDVDMsg
173{
174public:
175  CDVDMsgType(Message type, T value)
176    : CDVDMsg(type)
177    , m_value(value)
178  {}
179  operator T() { return m_value; }
180  T m_value;
181};
182
183typedef CDVDMsgType<bool>   CDVDMsgBool;
184typedef CDVDMsgType<int>    CDVDMsgInt;
185typedef CDVDMsgType<double> CDVDMsgDouble;
186
187////////////////////////////////////////////////////////////////////////////////
188//////
189////// PLAYER_ Messages
190//////
191////////////////////////////////////////////////////////////////////////////////
192
193class CDVDMsgPlayerSetAudioStream : public CDVDMsg
194{
195public:
196  CDVDMsgPlayerSetAudioStream(int streamId) : CDVDMsg(PLAYER_SET_AUDIOSTREAM) { m_streamId = streamId; }
197  int GetStreamId()                     { return m_streamId; }
198private:
199  int m_streamId;
200};
201
202class CDVDMsgPlayerSetSubtitleStream : public CDVDMsg
203{
204public:
205  CDVDMsgPlayerSetSubtitleStream(int streamId) : CDVDMsg(PLAYER_SET_SUBTITLESTREAM) { m_streamId = streamId; }
206  int GetStreamId()                     { return m_streamId; }
207private:
208  int m_streamId;
209};
210
211class CDVDMsgPlayerSetState : public CDVDMsg
212{
213public:
214  CDVDMsgPlayerSetState(std::string& state) : CDVDMsg(PLAYER_SET_STATE), m_state(state) {}
215  std::string GetState()                { return m_state; }
216private:
217  std::string m_state;
218};
219
220class CDVDMsgPlayerSeek : public CDVDMsg
221{
222public:
223  CDVDMsgPlayerSeek(int time, bool backward, bool flush = true, bool accurate = true, bool restore = true, bool trickplay = false)
224    : CDVDMsg(PLAYER_SEEK)
225    , m_time(time)
226    , m_backward(backward)
227    , m_flush(flush)
228    , m_accurate(accurate)
229    , m_restore(restore)
230    , m_trickplay(trickplay)
231  {}
232  int  GetTime()              { return m_time; }
233  bool GetBackward()          { return m_backward; }
234  bool GetFlush()             { return m_flush; }
235  bool GetAccurate()          { return m_accurate; }
236  bool GetRestore()           { return m_restore; }
237  bool GetTrickPlay()         { return m_trickplay; }
238private:
239  int  m_time;
240  bool m_backward;
241  bool m_flush;
242  bool m_accurate;
243  bool m_restore; // whether to restore any EDL cut time
244  bool m_trickplay;
245};
246
247class CDVDMsgPlayerSeekChapter : public CDVDMsg
248{
249  public:
250    CDVDMsgPlayerSeekChapter(int iChapter)
251      : CDVDMsg(PLAYER_SEEK_CHAPTER)
252      , m_iChapter(iChapter)
253    {}
254
255    int GetChapter() const { return m_iChapter; }
256
257  private:
258
259    int m_iChapter;
260};
261
262////////////////////////////////////////////////////////////////////////////////
263//////
264////// DEMUXER_ Messages
265//////
266////////////////////////////////////////////////////////////////////////////////
267
268class CDVDMsgDemuxerPacket : public CDVDMsg
269{
270public:
271  CDVDMsgDemuxerPacket(DemuxPacket* packet, bool drop = false);
272  virtual ~CDVDMsgDemuxerPacket();
273  DemuxPacket* GetPacket()      { return m_packet; }
274  unsigned int GetPacketSize()  { if(m_packet) return m_packet->iSize; else return 0; }
275  bool         GetPacketDrop()  { return m_drop; }
276  DemuxPacket* m_packet;
277  bool         m_drop;
278};
279
280class CDVDMsgDemuxerReset : public CDVDMsg
281{
282public:
283  CDVDMsgDemuxerReset() : CDVDMsg(DEMUXER_RESET)  {}
284};
285
286
287
288////////////////////////////////////////////////////////////////////////////////
289//////
290////// VIDEO_ Messages
291//////
292////////////////////////////////////////////////////////////////////////////////
293
294
295////////////////////////////////////////////////////////////////////////////////
296//////
297////// SUBTITLE_ Messages
298//////
299////////////////////////////////////////////////////////////////////////////////
300
301class CDVDMsgSubtitleClutChange : public CDVDMsg
302{
303public:
304  CDVDMsgSubtitleClutChange(uint8_t* data) : CDVDMsg(SUBTITLE_CLUTCHANGE) { memcpy(m_data, data, 16*4); }
305  uint8_t m_data[16][4];
306private:
307};