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

Hybrid/vtkVideoSource.h

Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    $RCSfile: vtkVideoSource.h,v $
00005   Language:  C++
00006 
00007   Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen 
00008   All rights reserved.
00009   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00010 
00011      This software is distributed WITHOUT ANY WARRANTY; without even 
00012      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
00013      PURPOSE.  See the above copyright notice for more information.
00014 
00015 =========================================================================*/
00045 #ifndef __vtkVideoSource_h
00046 #define __vtkVideoSource_h
00047 
00048 #include "vtkImageSource.h"
00049 
00050 class vtkTimerLog;
00051 class vtkCriticalSection;
00052 class vtkMultiThreader;
00053 class vtkScalarsToColors;
00054 
00055 class VTK_HYBRID_EXPORT vtkVideoSource : public vtkImageSource
00056 {
00057 public:
00058   static vtkVideoSource *New();
00059   vtkTypeRevisionMacro(vtkVideoSource,vtkImageSource);
00060   void PrintSelf(ostream& os, vtkIndent indent);   
00061 
00064   virtual void Record();
00065 
00068   virtual void Play();
00069 
00071   virtual void Stop();
00072 
00077   virtual void Rewind();
00078 
00081   virtual void FastForward();
00082 
00085   virtual void Seek(int n); 
00086 
00088   virtual void Grab();
00089 
00091 
00093   vtkGetMacro(Recording,int);
00095 
00097 
00099   vtkGetMacro(Playing,int);
00101 
00103 
00108   virtual void SetFrameSize(int x, int y, int z);
00109   virtual void SetFrameSize(int dim[3]) { 
00110     this->SetFrameSize(dim[0], dim[1], dim[2]); };
00111   vtkGetVector3Macro(FrameSize,int);
00113 
00115 
00116   virtual void SetFrameRate(float rate);
00117   vtkGetMacro(FrameRate,float);
00119 
00121 
00123   virtual void SetOutputFormat(int format);
00124   void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
00125   void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
00126   void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
00127   vtkGetMacro(OutputFormat,int);
00129 
00131 
00133   virtual void SetFrameBufferSize(int FrameBufferSize);
00134   vtkGetMacro(FrameBufferSize,int);
00136 
00138 
00141   vtkSetMacro(NumberOfOutputFrames,int);
00142   vtkGetMacro(NumberOfOutputFrames,int);
00144 
00146 
00148   vtkBooleanMacro(AutoAdvance,int);
00149   vtkSetMacro(AutoAdvance,int)
00150   vtkGetMacro(AutoAdvance,int);
00152 
00154 
00158   virtual void SetClipRegion(int r[6]) { 
00159     this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
00160   virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
00161   vtkGetVector6Macro(ClipRegion,int);
00163 
00165 
00172   vtkSetVector6Macro(OutputWholeExtent,int);
00173   vtkGetVector6Macro(OutputWholeExtent,int);
00175   
00177 
00178   vtkSetVector3Macro(DataSpacing,float);
00179   vtkGetVector3Macro(DataSpacing,float);
00181   
00183 
00185   vtkSetVector3Macro(DataOrigin,float);
00186   vtkGetVector3Macro(DataOrigin,float);
00188 
00190 
00193   vtkSetMacro(Opacity,float);
00194   vtkGetMacro(Opacity,float);  
00196 
00198 
00200   vtkGetMacro(FrameCount, int);
00201   vtkSetMacro(FrameCount, int);
00203 
00205 
00207   vtkGetMacro(FrameIndex, int);
00209 
00214   virtual double GetFrameTimeStamp(int frame);
00215 
00219   double GetFrameTimeStamp() { return this->FrameTimeStamp; };
00220 
00222 
00224   virtual void Initialize();
00225   virtual int GetInitialized() { return this->Initialized; };
00227 
00230   virtual void ReleaseSystemResources();
00231 
00235   virtual void InternalGrab();
00236 
00238 
00240   void SetStartTimeStamp(double t) { this->StartTimeStamp = t; };
00241   double GetStartTimeStamp() { return this->StartTimeStamp; };
00243 
00244 protected:
00245   vtkVideoSource();
00246   ~vtkVideoSource();
00247   void ExecuteInformation();
00248 
00249   int Initialized;
00250 
00251   int FrameSize[3];
00252   int ClipRegion[6];
00253   int OutputWholeExtent[6];
00254   float DataSpacing[3];
00255   float DataOrigin[3];
00256   int OutputFormat;
00257   // set according to the OutputFormat
00258   int NumberOfScalarComponents;
00259   // The FrameOutputExtent is the WholeExtent for a single output frame.
00260   // It is initialized in ExecuteInformation. 
00261   int FrameOutputExtent[6];
00262 
00263   // save this information from the output so that we can see if the
00264   // output scalars have changed
00265   int LastNumberOfScalarComponents;
00266   int LastOutputExtent[6];
00267 
00268   int Recording;
00269   int Playing;
00270   float FrameRate;
00271   int FrameCount;
00272   int FrameIndex;
00273   double StartTimeStamp;
00274   double FrameTimeStamp;
00275 
00276   int AutoAdvance;
00277   int NumberOfOutputFrames;
00278 
00279   float Opacity;
00280 
00281   // true if Execute() must apply a vertical flip to each frame
00282   int FlipFrames;
00283 
00284   // set if output needs to be cleared to be cleared before being written
00285   int OutputNeedsInitialization;
00286 
00287   // An example of asynchrony
00288   vtkMultiThreader *PlayerThreader;
00289   int PlayerThreadId;
00290 
00291   // A mutex for the frame buffer: must be applied when any of the
00292   // below data is modified.
00293   vtkCriticalSection *FrameBufferMutex;
00294 
00295   // set according to the needs of the hardware:
00296   // number of bits per framebuffer pixel
00297   int FrameBufferBitsPerPixel;
00298   // byte alignment of each row in the framebuffer
00299   int FrameBufferRowAlignment;
00300   // FrameBufferExtent is the extent of frame after it has been clipped 
00301   // with ClipRegion.  It is initialized in CheckBuffer().
00302   int FrameBufferExtent[6];
00303 
00304   int FrameBufferSize;
00305   int FrameBufferIndex;
00306   void **FrameBuffer;
00307   double *FrameBufferTimeStamps;
00308 
00310 
00311   virtual void UpdateFrameBuffer();
00312   virtual void AdvanceFrameBuffer(int n);
00313   virtual void ExecuteData(vtkDataObject *data);
00314   // if some component conversion is required, it is done here:
00315   virtual void UnpackRasterLine(char *outPtr, char *rowPtr, 
00316                                 int start, int count);
00318 
00319 private:
00320   vtkVideoSource(const vtkVideoSource&);  // Not implemented.
00321   void operator=(const vtkVideoSource&);  // Not implemented.
00322 };
00323 
00324 #endif
00325 
00326 
00327 
00328 
00329