contrib/brl/bbas/vidl2/vidl2_istream.h

Go to the documentation of this file.
00001 // This is brl/bbas/vidl2/vidl2_istream.h
00002 #ifndef vidl2_istream_h_
00003 #define vidl2_istream_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A base class for input video streams
00010 //
00011 // \author Matt Leotta
00012 // \date 19 Dec 2005
00013 
00014 #include "vidl2_frame_sptr.h"
00015 #include "vidl2_pixel_format.h"
00016 
00017 //: A base class for input video streams
00018 class vidl2_istream
00019 {
00020  public:
00021   //: Constructor
00022   vidl2_istream() : ref_count_(0) {}
00023   //: Destructor
00024   virtual ~vidl2_istream() {}
00025 
00026   //: Return true if the stream is open for reading
00027   virtual bool is_open() const = 0;
00028 
00029   //: Return true if the stream is in a valid state
00030   virtual bool is_valid() const = 0;
00031 
00032   //: Return true if the stream support seeking
00033   virtual bool is_seekable() const = 0;
00034 
00035   //: Return the number of frames if known
00036   //  returns -1 for non-seekable streams
00037   virtual int num_frames() const = 0;
00038 
00039   //: Return the current frame number
00040   virtual unsigned int frame_number() const = 0;
00041 
00042   //: Return the width of each frame
00043   virtual unsigned int width() const = 0;
00044 
00045   //: Return the height of each frame
00046   virtual unsigned int height() const = 0;
00047 
00048   //: Return the pixel format
00049   virtual vidl2_pixel_format format() const = 0;
00050 
00051   //: Return the frame rate (FPS, 0.0 if unspecified)
00052   virtual double frame_rate() const = 0;
00053 
00054   //: Close the stream
00055   virtual void close() = 0;
00056 
00057   //: Advance to the next frame (but don't acquire an image)
00058   virtual bool advance() = 0 ;
00059 
00060   //: Read the next frame from the stream (advance and acquire)
00061   virtual vidl2_frame_sptr read_frame() = 0;
00062 
00063   //: Return the current frame in the stream
00064   virtual vidl2_frame_sptr current_frame() = 0;
00065 
00066   //: Seek to the given frame number
00067   // \returns true if successful
00068   virtual bool seek_frame(unsigned int frame_number) = 0;
00069 
00070  private:
00071   //: prevent deep copying a stream
00072   vidl2_istream(const vidl2_istream& other):ref_count_(0){}
00073 
00074  //-------------------------------------------------------
00075  // reference counting
00076  public:
00077 
00078   //: Increment reference count
00079   void ref() { ref_count_++; }
00080 
00081   //: Decrement reference count
00082   void unref() { if (--ref_count_ <= 0) delete this; }
00083 
00084   //: Number of objects referring to this data
00085   int ref_count() const { return ref_count_; }
00086 
00087  private:
00088   int ref_count_;
00089 };
00090 
00091 #endif // vidl2_istream_h_

Generated on Fri Nov 21 05:20:57 2008 for contrib/brl/bbas/vidl2 by  doxygen 1.5.1