#ifndef IMAGE_DC1394INPUT_H
#define IMAGE_DC1394INPUT_H

#include <libraw1394/raw1394.h>
#include <libdc1394/dc1394_control.h>
#include "image_input.h"

namespace mimas {

/** @addtogroup imageIO
    @{ */
/** @addtogroup imageInput
    @{ */
/** Image input from firewire digital camera (video1394).
    At the moment only grabbing of grayscale and YUV422-encoded images is
    supported.
    Grabbing has been tested with the following device:
    \li Basler A302fc

    See <A HREF="http://www.rmatsumoto.org/camera/dc1394-ohphone-old.html">Ryutaroh Matsumoto's</A>
    page for more information.

    Here is an example on how to use this class:
    \include dc1394/minimal.cc

    @author Jan Wedekind (jan@wedesoft.de) 
    @date Wed Aug  4 13:53:59 GMT 2005 */
template< typename T >
class image_dc1394input: public image_input< T >
{
 public:
  ///
  typedef enum { Unknown = 0, UYVY, RGB24, Grey8 } ColourSpace;
  ///
  image_dc1394input( const char *device = "",
                     int node = 0,
                     int channel = 0,
                     int preferredFormat = -1,
                     int preferredMode = -1,
                     int preferredFormat7Colour = -1,
                     int speed = SPEED_400 ) throw (mimasexception);
  ///
  virtual ~image_dc1394input(void);
  ///
  virtual void close(void);
  ///
  virtual void read( image<T> &img ) throw (mimasexception);
  ///
  dc1394_feature_info get_feature( int _id ) throw (mimasexception);
  ///
  void set_feature_value( int _id, unsigned int _value ) throw (mimasexception);
  ///
  unsigned int get_feature_value( int _id ) throw (mimasexception);
 protected:
  ///
  void selectFormat( int preferredFormat ) throw (mimasexception);
  ///
  void selectMode( int preferredMode ) throw (mimasexception);
  ///
  void selectFrameRate( int preferredFrameRate ) throw (mimasexception);
  ///
  void selectFormat7Colour( int preferredFormat7Colour ) throw (mimasexception);
  ///
  std::string m_device;
  ///
  nodeid_t *m_cameraNode;
  ///
  int m_node;
  ///
  raw1394handle_t m_handle;
  ///
  dc1394_cameracapture m_camera;
  ///
  int m_format;
  ///
  int m_mode;
  ///
  int m_format7Colour;
  ///
  ColourSpace m_colourSpace;
  ///
  int m_frameRate;
  ///
  bool m_bufferUsed;
};

///@}

///@}

};

#include "image_dc1394input.tcc"
#endif