Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   Related Pages  

player.hh

Go to the documentation of this file.
00001 /*
00002  * PIAVE - PIAVE Is A Video Editor
00003  *
00004  * Copyright (C) 2002 Rolf Dubitzky, rolf@dubitzky.de
00005  *
00006  */
00007 
00008 /*
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software Foundation,
00021  * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00022  */
00023 
00024 
00030 #if ! defined( PLAYER_HH )
00031 #define PLAYER_HH
00032 
00033 // stdc
00034 #include <signal.h>
00035 #include <unistd.h>
00036 #include <fcntl.h>
00037 #include <sys/stat.h>
00038 #include <sys/time.h>
00039 
00040 // stdc++
00041 #include <string>
00042 
00043 // PIAVE
00044 #include "piave_base.hh"
00045 #include "storybase.hh"
00046 
00047 
00048 namespace PIAVE {
00049 
00050     /*
00051      *  \class Player implements a simple main loop and all
00052      * infrastructure to try to * run this main loop in the requested
00053      * speed.
00054      *
00055      * The Player does neither own tho storyboard, nor the out streams
00056      * it just uses the streams provided by the system. The only purpose is
00057      * to handle the timing of the play speed.
00058      * 
00059      * \todo  sound will only be played when speed == 1.0
00060      *
00061      */
00062 
00063     class Player
00064     {
00065       public:
00066         enum State { not_ready, stopped, paused, playing };
00067         
00068       public:
00069         Player();
00070         ~Player();
00071 
00073         double       getSpeed()       const { return _speed; }
00074         Time         getPos()         const { return _pos; }
00075         State        getState()       const { return _state; }
00076 
00078         void setStoryBoard( StoryBoard * s ) { _theStory = s; }
00079         void setVideoOut( OutAVStreamIFace * vo ) { _videoOut = vo; }
00080         void setAudioOut( OutAudioStreamIFace * ao ) { _audioOut = ao; }
00081         void setSpeed( double s ) { _speed = s; }
00082         void setStart( Time s ) { _start = s; }
00083         void setStop( Time s ) { _stop = s; }
00084 
00086         void switchToPlay();
00087         void switchToStop();
00088         void switchToPause();
00089 
00090         /* will play the next frame. this call will block as long as necessary
00091          * with respect to the last call to keep playing at the correct speed.
00092          */
00093         void playNextFrame();
00094 
00095       private:
00096         /*   r = x - y    
00097          * @return true if positive, flase if negative
00098          */
00099         bool diffTime( timespec * r, const timeval * x,  timeval * y );
00100 
00102         void addTime( timeval * r, const timeval * x, const timeval * y );
00103 
00104 
00105       private:
00107         State         _state;
00108 
00110         StoryBoard   * _theStory;
00111 
00113         OutAVStreamIFace * _videoOut;
00114 
00116         OutAudioStreamIFace * _audioOut;
00117 
00119         double        _speed;
00120 
00122         Time          _start;
00123 
00125         Time          _stop;
00126 
00128         Time          _pos;
00129 
00132         timeval _firstFlash;
00133 
00137         timeval _lastFlash;
00138     };
00139 
00140 };
00141 
00142 #endif

Generated on Tue Oct 14 20:45:37 2003 for piave by doxygen1.2.18