VTK
dox/IO/Video/vtkVideoSource.h
Go to the documentation of this file.
00001 /*=========================================================================
00002 
00003   Program:   Visualization Toolkit
00004   Module:    vtkVideoSource.h
00005 
00006   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
00007   All rights reserved.
00008   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
00009 
00010      This software is distributed WITHOUT ANY WARRANTY; without even
00011      the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
00012      PURPOSE.  See the above copyright notice for more information.
00013 
00014 =========================================================================*/
00031 #ifndef __vtkVideoSource_h
00032 #define __vtkVideoSource_h
00033 
00034 #include "vtkIOVideoModule.h" // For export macro
00035 #include "vtkImageAlgorithm.h"
00036 
00037 class vtkTimerLog;
00038 class vtkCriticalSection;
00039 class vtkMultiThreader;
00040 class vtkScalarsToColors;
00041 
00042 class VTKIOVIDEO_EXPORT vtkVideoSource : public vtkImageAlgorithm
00043 {
00044 public:
00045   static vtkVideoSource *New();
00046   vtkTypeMacro(vtkVideoSource,vtkImageAlgorithm);
00047   void PrintSelf(ostream& os, vtkIndent indent);
00048 
00051   virtual void Record();
00052 
00055   virtual void Play();
00056 
00058   virtual void Stop();
00059 
00064   virtual void Rewind();
00065 
00068   virtual void FastForward();
00069 
00072   virtual void Seek(int n);
00073 
00075   virtual void Grab();
00076 
00078 
00080   vtkGetMacro(Recording,int);
00082 
00084 
00086   vtkGetMacro(Playing,int);
00088 
00090 
00095   virtual void SetFrameSize(int x, int y, int z);
00096   virtual void SetFrameSize(int dim[3]) {
00097     this->SetFrameSize(dim[0], dim[1], dim[2]); };
00098   vtkGetVector3Macro(FrameSize,int);
00100 
00102 
00103   virtual void SetFrameRate(float rate);
00104   vtkGetMacro(FrameRate,float);
00106 
00108 
00110   virtual void SetOutputFormat(int format);
00111   void SetOutputFormatToLuminance() { this->SetOutputFormat(VTK_LUMINANCE); };
00112   void SetOutputFormatToRGB() { this->SetOutputFormat(VTK_RGB); };
00113   void SetOutputFormatToRGBA() { this->SetOutputFormat(VTK_RGBA); };
00114   vtkGetMacro(OutputFormat,int);
00116 
00118 
00120   virtual void SetFrameBufferSize(int FrameBufferSize);
00121   vtkGetMacro(FrameBufferSize,int);
00123 
00125 
00128   vtkSetMacro(NumberOfOutputFrames,int);
00129   vtkGetMacro(NumberOfOutputFrames,int);
00131 
00133 
00135   vtkBooleanMacro(AutoAdvance,int);
00136   vtkSetMacro(AutoAdvance,int)
00137   vtkGetMacro(AutoAdvance,int);
00139 
00141 
00145   virtual void SetClipRegion(int r[6]) {
00146     this->SetClipRegion(r[0],r[1],r[2],r[3],r[4],r[5]); };
00147   virtual void SetClipRegion(int x0, int x1, int y0, int y1, int z0, int z1);
00148   vtkGetVector6Macro(ClipRegion,int);
00150 
00152 
00159   vtkSetVector6Macro(OutputWholeExtent,int);
00160   vtkGetVector6Macro(OutputWholeExtent,int);
00162 
00164 
00165   vtkSetVector3Macro(DataSpacing,double);
00166   vtkGetVector3Macro(DataSpacing,double);
00168 
00170 
00172   vtkSetVector3Macro(DataOrigin,double);
00173   vtkGetVector3Macro(DataOrigin,double);
00175 
00177 
00180   vtkSetMacro(Opacity,float);
00181   vtkGetMacro(Opacity,float);
00183 
00185 
00187   vtkGetMacro(FrameCount, int);
00188   vtkSetMacro(FrameCount, int);
00190 
00192 
00194   vtkGetMacro(FrameIndex, int);
00196 
00201   virtual double GetFrameTimeStamp(int frame);
00202 
00206   double GetFrameTimeStamp() { return this->FrameTimeStamp; };
00207 
00209 
00211   virtual void Initialize();
00212   virtual int GetInitialized() { return this->Initialized; };
00214 
00217   virtual void ReleaseSystemResources();
00218 
00222   virtual void InternalGrab();
00223 
00225 
00227   void SetStartTimeStamp(double t) { this->StartTimeStamp = t; };
00228   double GetStartTimeStamp() { return this->StartTimeStamp; };
00230 
00231 protected:
00232   vtkVideoSource();
00233   ~vtkVideoSource();
00234   virtual int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00235 
00236   int Initialized;
00237 
00238   int FrameSize[3];
00239   int ClipRegion[6];
00240   int OutputWholeExtent[6];
00241   double DataSpacing[3];
00242   double DataOrigin[3];
00243   int OutputFormat;
00244   // set according to the OutputFormat
00245   int NumberOfScalarComponents;
00246   // The FrameOutputExtent is the WholeExtent for a single output frame.
00247   // It is initialized in ExecuteInformation.
00248   int FrameOutputExtent[6];
00249 
00250   // save this information from the output so that we can see if the
00251   // output scalars have changed
00252   int LastNumberOfScalarComponents;
00253   int LastOutputExtent[6];
00254 
00255   int Recording;
00256   int Playing;
00257   float FrameRate;
00258   int FrameCount;
00259   int FrameIndex;
00260   double StartTimeStamp;
00261   double FrameTimeStamp;
00262 
00263   int AutoAdvance;
00264   int NumberOfOutputFrames;
00265 
00266   float Opacity;
00267 
00268   // true if Execute() must apply a vertical flip to each frame
00269   int FlipFrames;
00270 
00271   // set if output needs to be cleared to be cleared before being written
00272   int OutputNeedsInitialization;
00273 
00274   // An example of asynchrony
00275   vtkMultiThreader *PlayerThreader;
00276   int PlayerThreadId;
00277 
00278   // A mutex for the frame buffer: must be applied when any of the
00279   // below data is modified.
00280   vtkCriticalSection *FrameBufferMutex;
00281 
00282   // set according to the needs of the hardware:
00283   // number of bits per framebuffer pixel
00284   int FrameBufferBitsPerPixel;
00285   // byte alignment of each row in the framebuffer
00286   int FrameBufferRowAlignment;
00287   // FrameBufferExtent is the extent of frame after it has been clipped
00288   // with ClipRegion.  It is initialized in CheckBuffer().
00289   int FrameBufferExtent[6];
00290 
00291   int FrameBufferSize;
00292   int FrameBufferIndex;
00293   void **FrameBuffer;
00294   double *FrameBufferTimeStamps;
00295 
00297 
00298   virtual void UpdateFrameBuffer();
00299   virtual void AdvanceFrameBuffer(int n);
00300   virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *);
00301   // if some component conversion is required, it is done here:
00302   virtual void UnpackRasterLine(char *outPtr, char *rowPtr,
00303                                 int start, int count);
00305 
00306 private:
00307   vtkVideoSource(const vtkVideoSource&);  // Not implemented.
00308   void operator=(const vtkVideoSource&);  // Not implemented.
00309 };
00310 
00311 #endif
00312 
00313 
00314 
00315 
00316