#ifdef HAS_AVC_SUPPORT
#ifndef _IEEE1394IO_H
#define _IEEE1394IO_H 1
#include <libraw1394/raw1394.h>
#include <libraw1394/csr.h>
#include <libiec61883/iec61883.h>
#include <string>
using std::string;
#include <deque>
using std::deque;
namespace avcap
{
class Frame;
class IEEE1394Reader
{
protected:
int droppedFrames;
int incompleteFrames;
Frame *currentFrame;
deque < Frame* > inFrames;
deque < Frame* > outFrames;
public:
IEEE1394Reader( int channel = 63, int frames = 5 );
virtual ~IEEE1394Reader();
virtual bool StartThread( void ) = 0;
virtual void StopThread( void ) = 0;
Frame* GetFrame( void );
void DoneWithFrame( Frame* );
int GetDroppedFrames( void );
int GetIncompleteFrames( void );
int GetOutQueueSize( void )
{
return outFrames.size();
}
int GetInQueueSize( void )
{
return inFrames.size();
}
virtual bool Open( void ) = 0;
virtual void Close( void ) = 0;
bool WaitForAction( int seconds = 0 );
virtual void TriggerAction( );
virtual bool StartReceive( void ) = 0;
virtual void StopReceive( void ) = 0;
protected:
int channel;
pthread_t thread;
pthread_mutex_t mutex;
pthread_mutex_t condition_mutex;
pthread_cond_t condition;
bool isRunning;
void Flush( void );
};
typedef void (*BusResetHandler)( void* );
typedef void* BusResetHandlerData;
class CaptureHandler;
class iec61883Reader: public IEEE1394Reader
{
private:
int m_port;
raw1394handle_t m_handle;
iec61883_dv_fb_t m_iec61883dv;
BusResetHandler m_resetHandler;
const void* m_resetHandlerData;
CaptureHandler* m_captureHandler;
public:
iec61883Reader( int port = 0, int channel = 63, int buffers = 5,
BusResetHandler = 0, BusResetHandlerData = 0 );
~iec61883Reader();
bool Open( void );
void Close( void );
bool StartReceive( void );
void StopReceive( void );
bool StartThread( void );
void StopThread( void );
int Handler( int length, int complete, unsigned char *data );
void *Thread();
void ResetHandler( void );
private:
static int ResetHandlerProxy( raw1394handle_t handle, unsigned int generation );
static int HandlerProxy( unsigned char *data, int length, int complete,
void *callback_data );
static void* ThreadProxy( void *arg );
};
class iec61883Connection
{
private:
raw1394handle_t m_handle;
nodeid_t m_node;
int m_channel;
int m_bandwidth;
int m_outputPort;
int m_inputPort;
public:
iec61883Connection( int port, int node );
~iec61883Connection();
static void CheckConsistency( int port, int node );
int GetChannel( void ) const
{
return m_channel;
}
int Reconnect( void );
};
}
#endif
#endif