core/vidl/vidl_ffmpeg_istream.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_ffmpeg_istream.h
00002 #ifndef vidl_ffmpeg_istream_h_
00003 #define vidl_ffmpeg_istream_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A video input stream using FFMPEG to decoded files
00010 //
00011 // \author Matt Leotta
00012 // \date 21 Dec 2005
00013 //
00014 // \verbatim
00015 //  Modifications
00016 //    Matt Leotta   21 Dec 2005   Adapted from code by Amitha Perera
00017 // \endverbatim
00018 
00019 #include "vidl_istream.h"
00020 #include <vcl_string.h>
00021 
00022 
00023 //: A video input stream using FFMPEG to decoded files
00024 class vidl_ffmpeg_istream
00025   : public vidl_istream
00026 {
00027  public:
00028   //: Constructor - default
00029   vidl_ffmpeg_istream();
00030 
00031   //: Constructor - from a filename
00032   vidl_ffmpeg_istream(const vcl_string& filename);
00033 
00034   //: Destructor
00035   virtual ~vidl_ffmpeg_istream();
00036 
00037   //: Open a new stream using a filename
00038   virtual bool open(const vcl_string& filename);
00039 
00040   //: Close the stream
00041   virtual void close();
00042 
00043   //: Return true if the stream is open for reading
00044   virtual bool is_open() const;
00045 
00046   //: Return true if the stream is in a valid state
00047   virtual bool is_valid() const;
00048 
00049   //: Return true if the stream support seeking
00050   virtual bool is_seekable() const;
00051 
00052   //: Return the number of frames if known
00053   //  returns -1 for non-seekable streams
00054   virtual int num_frames() const;
00055 
00056   //: Return the current frame number
00057   virtual unsigned int frame_number() const;
00058 
00059   //: Return the width of each frame
00060   virtual unsigned int width() const;
00061 
00062   //: Return the height of each frame
00063   virtual unsigned int height() const;
00064 
00065   //: Return the pixel format
00066   virtual vidl_pixel_format format() const;
00067 
00068   //: Return the frame rate (FPS, 0.0 if unspecified)
00069   virtual double frame_rate() const;
00070   
00071   //: Return the duration in seconds (0.0 if unknown)
00072   virtual double duration() const;
00073 
00074   //: Advance to the next frame (but don't acquire an image)
00075   virtual bool advance();
00076 
00077   //: Read the next frame from the stream (advance and acquire)
00078   virtual vidl_frame_sptr read_frame();
00079 
00080   //: Return the current frame in the stream
00081   virtual vidl_frame_sptr current_frame();
00082 
00083   //: Seek to the given frame number
00084   // \returns true if successful
00085   virtual bool seek_frame(unsigned int frame_number);
00086 
00087  private:
00088   //: The private implementation (PIMPL) details.
00089   //  This isolates the clients from the ffmpeg details
00090   struct pimpl;
00091   pimpl* is_;
00092 };
00093 
00094 #endif // vidl_ffmpeg_istream_h_