Gnash  0.8.11dev
PlayHead.h
Go to the documentation of this file.
1 // PlayHead.h: media playback controller
2 //
3 // Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
4 // Free Software Foundation, Inc
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 3 of the License, or
9 // (at your option) 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 this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 
20 
21 #ifndef GNASH_PLAYHEAD_H
22 #define GNASH_PLAYHEAD_H
23 
24 #include <boost/cstdint.hpp> // For C99 int types
25 
26 // Forward declarations
27 namespace gnash {
28  class VirtualClock;
29 }
30 
31 namespace gnash {
32 
34 class PlayHead {
35 
36 public:
37 
42  };
43 
46  //
54  PlayHead(VirtualClock* clockSource);
55 
57  //
62  {
63  _availableConsumers |= CONSUMER_VIDEO;
64  }
65 
67  //
72  {
73  _availableConsumers |= CONSUMER_AUDIO;
74  }
75 
77  boost::uint64_t getPosition() const { return _position; }
78 
80  PlaybackStatus getState() const { return _state; }
81 
84 
87 
89  bool isVideoConsumed() const
90  {
91  return (_positionConsumers & CONSUMER_VIDEO);
92  }
93 
96  {
97  _positionConsumers |= CONSUMER_VIDEO;
98  }
99 
101  bool isAudioConsumed() const
102  {
103  return (_positionConsumers & CONSUMER_AUDIO);
104  }
105 
108  {
109  _positionConsumers |= CONSUMER_AUDIO;
110  }
111 
113  //
124  void seekTo(boost::uint64_t position);
125 
127  //
137  void advanceIfConsumed();
138 
139 
140 private:
141 
143  enum ConsumerFlag {
144  CONSUMER_VIDEO = 1,
145  CONSUMER_AUDIO = 2
146  };
147 
149  boost::uint64_t _position;
150 
152  PlaybackStatus _state;
153 
156  int _availableConsumers;
157 
160  int _positionConsumers;
161 
163  VirtualClock* _clockSource;
164 
167  //
169  boost::uint64_t _clockOffset;
170 
171 };
172 
173 } // end of gnash namespace
174 
175 // __PLAYHEAD_H__
176 #endif
177