00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00031 #if ! defined ( STORYBASE_HH )
00032 #define STORYBASE_HH
00033
00034
00035 #include <iostream>
00036 #include <string>
00037
00038
00039 #include "piave_base.hh"
00040 #include "avstream.hh"
00041 #include "frame.hh"
00042 #include "property.hh"
00043
00044 namespace PIAVE {
00045
00046 class UnaryOp;
00047 class BinaryOp;
00048
00052 class StoryElement : public TimeInterval
00053 {
00054 public:
00056 StoryElement( const std::string &name = std::string(), Time start = 0, Time length = 0 );
00058 virtual ~StoryElement() {};
00059
00061 const std::string & name() const { return _name; }
00063 const std::string & setName( const std::string &name ) {
00064 _name = name; return _name; }
00066 const std::string & comment() const { return _comment; }
00068 const std::string & setComment( const std::string &comment ) {
00069 _comment = comment; return _comment; }
00070
00082 virtual int fixMe( int fix_lvl=0 ) {
00083 WARN( "ABSTRACT! OVERRIDE ME! StoryElement::fixMe "<<name() ); return 0; };
00084
00085 private:
00087 std::string _name;
00089 std::string _comment;
00090 };
00091
00092
00097 class MediaElement : public StoryElement , public PluginBase
00098 {
00099 public:
00101 MediaElement( const std::string &name = std::string(),
00102 Time start = 0, Time length = 0 );
00104 virtual ~MediaElement() {};
00105
00112 virtual Frame getFrame( Time t ) = 0;
00113 };
00114
00128 class StoryBNode : public MediaElement
00129 {
00130 public:
00131 StoryBNode( MediaElement * A,
00132 MediaElement * B,
00133 BinaryOp * videoOp = 0,
00134 BinaryOp * audioOp = 0 );
00135
00136
00137 virtual Frame getFrame( Time t );
00138 virtual PropertyNode * getProperties( PropertyNode *p = 0 ) const { return p; }
00139 virtual int fixMe( int fix_lvl=0 );
00140
00141 virtual void print( std::ostream & o, int indent ) const;
00142
00143 private:
00144 MediaElement * _A;
00145 MediaElement * _B;
00146 BinaryOp * _videoOp;
00147 BinaryOp * _audioOp;
00148
00149 };
00150
00157 class StoryUNode : public MediaElement
00158 {
00159 public:
00160 StoryUNode( MediaElement * A,
00161 UnaryOp * videoOp = 0,
00162 UnaryOp * audioOp = 0 );
00163
00164
00165 virtual Frame getFrame( Time t );
00166 virtual PropertyNode * getProperties( PropertyNode *p = 0 ) const { return p; }
00167 virtual int fixMe( int fix_lvl=0 );
00168
00169 virtual void print( std::ostream & o, int indent ) const;
00170
00171 private:
00172 MediaElement * _A;
00173 UnaryOp * _videoOp;
00174 UnaryOp * _audioOp;
00175 };
00176
00177
00184 class StorySeqNode : public MediaElement
00185 {
00186 public:
00187 StorySeqNode( );
00188 virtual ~StorySeqNode( );
00189
00190
00191 void setEmptyFrame( MediaElement * m ) { _emptyFrame=m; }
00192 void addElement( MediaElement * m );
00193
00194
00195 virtual Frame getFrame( Time t );
00196 virtual PropertyNode * getProperties( PropertyNode *p = 0 ) const { return p; }
00197 virtual int fixMe( int fix_lvl=0 );
00198 virtual void print( std::ostream & o, int indent ) const;
00199
00200 private:
00201 std::vector< MediaElement* > _elements;
00202 MediaElement * _emptyFrame;
00203
00204 };
00205
00206
00210 class StoryBoard : public MediaElement
00211 {
00212 public:
00213 StoryBoard( const std::string name );
00214 virtual ~StoryBoard();
00215
00216 MediaElement * getEmptyFrame() const { return _emptyFrame; }
00217
00218 virtual Frame getFrame( Time t );
00219
00220 virtual PropertyNode * getProperties( PropertyNode * p = 0 ) const;
00221
00223 virtual int fixMe( int fix_lvl=0 ) { return 0; };
00224
00225 virtual void print( std::ostream & o, int indent ) const;
00226
00227 void setHead( MediaElement * s );
00228
00229 void printStats();
00230
00231 private:
00232 MediaElement * _head;
00233 MediaElement * _emptyFrame;
00234
00235 int _nMeasuredFrames;
00236 double _sumMean;
00237 double _sumSquares;
00238 double _fastestFrame;
00239 double _slowestFrame;
00240 };
00241
00242 };
00243
00244 #endif