Gnash  0.8.10
PlayHead.h
Go to the documentation of this file.
00001 // PlayHead.h: media playback controller 
00002 // 
00003 //   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
00004 //   Free Software Foundation, Inc
00005 // 
00006 // This program is free software; you can redistribute it and/or modify
00007 // it under the terms of the GNU General Public License as published by
00008 // the Free Software Foundation; either version 3 of the License, or
00009 // (at your option) any later version.
00010 // 
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00019 
00020 
00021 #ifndef GNASH_PLAYHEAD_H
00022 #define GNASH_PLAYHEAD_H
00023 
00024 #include <boost/cstdint.hpp> // For C99 int types
00025 
00026 // Forward declarations
00027 namespace gnash {
00028     class VirtualClock;
00029 }
00030 
00031 namespace gnash {
00032 
00034 class PlayHead {
00035 
00036 public:
00037 
00039     enum PlaybackStatus {
00040         PLAY_PLAYING = 1,
00041         PLAY_PAUSED = 2
00042     };
00043 
00046     //
00054     PlayHead(VirtualClock* clockSource);
00055 
00057     //
00061     void setVideoConsumerAvailable()
00062     {
00063         _availableConsumers |= CONSUMER_VIDEO;
00064     }
00065 
00067     //
00071     void setAudioConsumerAvailable()
00072     {
00073         _availableConsumers |= CONSUMER_AUDIO;
00074     }
00075 
00077     boost::uint64_t getPosition() const { return _position; }
00078 
00080     PlaybackStatus getState() const { return _state; }
00081 
00083     PlaybackStatus setState(PlaybackStatus newState);
00084 
00086     PlaybackStatus toggleState();
00087 
00089     bool isVideoConsumed() const
00090     {
00091         return (_positionConsumers & CONSUMER_VIDEO);
00092     }
00093 
00095     void setVideoConsumed()
00096     {
00097         _positionConsumers |= CONSUMER_VIDEO;
00098     }
00099 
00101     bool isAudioConsumed() const
00102     {
00103         return (_positionConsumers & CONSUMER_AUDIO);
00104     }
00105 
00107     void setAudioConsumed()
00108     {
00109         _positionConsumers |= CONSUMER_AUDIO;
00110     }
00111 
00113     //
00124     void seekTo(boost::uint64_t position);
00125 
00127     //
00137     void advanceIfConsumed();
00138         
00139 
00140 private:
00141 
00143     enum ConsumerFlag {
00144         CONSUMER_VIDEO = 1,
00145         CONSUMER_AUDIO = 2
00146     };
00147 
00149     boost::uint64_t _position;
00150 
00152     PlaybackStatus _state;
00153 
00156     int _availableConsumers;
00157 
00160     int _positionConsumers;
00161 
00163     VirtualClock* _clockSource;
00164 
00167     //
00169     boost::uint64_t _clockOffset; 
00170 
00171 };
00172 
00173 } // end of gnash namespace
00174 
00175 // __PLAYHEAD_H__
00176 #endif
00177