core/vidl/vidl_dc1394_istream.h
Go to the documentation of this file.
00001 // This is core/vidl/vidl_dc1394_istream.h
00002 #ifndef vidl_dc1394_istream_h_
00003 #define vidl_dc1394_istream_h_
00004 #ifdef VCL_NEEDS_PRAGMA_INTERFACE
00005 #pragma interface
00006 #endif
00007 //:
00008 // \file
00009 // \brief A video input stream using libdc1394
00010 //
00011 // \author Matt Leotta
00012 // \date 6 Jan 2006
00013 //
00014 // \b WARNING this stream requires version 2 of the libdc1394 API.
00015 // if you are also using the ffmpeg streams make sure your libavcodec
00016 // and libavformat library are compiled without dc1394 support.
00017 // ffmpeg supplies limited 1394 support through the libdc1394
00018 // version 1 API.  Linking to both versions of libdc1394 will result
00019 // in linking errors.
00020 //
00021 // Currently this code works with libdc1394 version 2.0.0-rc9.
00022 // The authors note that the libdc1394 API is subject to change in
00023 // prerelease version.  As a result, the vidl_dc1394_istream is
00024 // is subject to change with it.
00025 
00026 #include "vidl_istream.h"
00027 #include "vidl_iidc1394_params.h"
00028 #include <vcl_string.h>
00029 
00030 
00031 //: A video input stream using libdc1394
00032 // This stream uses the dc1394 API (v2.0) to stream
00033 // video from an IEEE 1394 camera
00034 class vidl_dc1394_istream
00035   : public vidl_istream
00036 {
00037  public:
00038   //: Constructor - default
00039   vidl_dc1394_istream();
00040 
00041   //: Destructor
00042   virtual ~vidl_dc1394_istream();
00043 
00044   //: Open a new stream using a filename
00045   virtual bool open(unsigned int num_dma_buffers = 2,
00046                     bool drop_frames = false,
00047                     const vidl_iidc1394_params& params = vidl_iidc1394_params());
00048 
00049   //: Close the stream
00050   virtual void close();
00051 
00052   //: Probe the bus to determine the valid parameter options
00053   static bool valid_params(vidl_iidc1394_params::valid_options& options);
00054 
00055 
00056   //: Return true if the stream is open for reading
00057   virtual bool is_open() const;
00058 
00059   //: Return true if the stream is in a valid state
00060   virtual bool is_valid() const;
00061 
00062   //: Return true if the stream support seeking
00063   virtual bool is_seekable() const;
00064 
00065   //: Return the number of frames if known
00066   //  returns -1 for non-seekable streams
00067   virtual int num_frames() const;
00068 
00069   //: Return the current frame number
00070   virtual unsigned int frame_number() const;
00071 
00072   //: Return the width of each frame
00073   virtual unsigned int width() const;
00074 
00075   //: Return the height of each frame
00076   virtual unsigned int height() const;
00077 
00078   //: Return the pixel format
00079   virtual vidl_pixel_format format() const;
00080 
00081   //: Return the frame rate (FPS, 0.0 if unspecified)
00082   virtual double frame_rate() const;
00083 
00084   //: Return the duration in seconds (0.0 if unknown)
00085   virtual double duration() const;
00086 
00087   //: Advance to the next frame (but don't acquire an image)
00088   virtual bool advance();
00089 
00090   //: Read the next frame from the stream (advance and acquire)
00091   virtual vidl_frame_sptr read_frame();
00092 
00093   //: Return the current frame in the stream
00094   virtual vidl_frame_sptr current_frame();
00095 
00096   //: Seek to the given frame number
00097   // \returns true if successful
00098   virtual bool seek_frame(unsigned int frame_number);
00099 
00100  private:
00101   //: The private implementation (PIMPL) details.
00102   //  This isolates the clients from the ffmpeg details
00103   struct pimpl;
00104   pimpl* is_;
00105 };
00106 
00107 #endif // vidl_dc1394_istream_h_