Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

l1394_dcciso.h

Go to the documentation of this file.
00001 /***************************************************************************
00002                           dcciso.h  -  description
00003                              -------------------
00004     begin                : Fri May 4 2001
00005     copyright            : (C) 2001-2004 by Michael Repplinger
00006     email                : repplix@studcs.uni-sb.de
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #ifndef L1394_DCCISO_H
00019 #define L1394_DCCISO_H
00020 
00021 #include "l1394_iso.h"
00022 
00023 #include <netinet/in.h>
00024 #include <sys/poll.h>
00025 #include <sys/types.h>
00026 #include <sys/time.h>
00027 #include <unistd.h>
00028 #include <string>
00029 #include "libraw1394/raw1394.h"
00030 #include "libraw1394/csr.h"
00031 #include <stdio.h>
00032 #include <fcntl.h>
00033 #include <sys/ioctl.h>
00034 #include <unistd.h>
00035 #include <sys/mman.h>
00036 #include "Thread.hpp"
00037 
00038 
00039 using std::string;
00040 
00041 namespace L1394{
00042 namespace internal{
00043 /**
00044   *@author Michael Repplinger
00045   */
00046 class DccIso : public Iso{
00047 public: 
00048   DccIso(const char *device);
00049   virtual ~DccIso();
00050   virtual void releaseFrame(Frame* );
00051   virtual Frame *getFrame();
00052   virtual void setFrameMode(bool b) {release_mode = b;}
00053   virtual bool getFrameMode() const {return release_mode;}
00054   virtual int  startIsoListen()     ;
00055   virtual int  stopIsoListen()      ;
00056 
00057   virtual int  setParameter(const int buffercount, const int channel, const int buffersize);
00058   virtual void flushQueue();
00059 private: //private structs and enums
00060 
00061 #define VIDEO1394_SYNC_FRAMES          0x00000001
00062 #define VIDEO1394_INCLUDE_ISO_HEADERS  0x00000002
00063 #define VIDEO1394_VARIABLE_PACKET_SIZE 0x00000004
00064 #define VIDEO1394_MAX_SIZE 0x4000000
00065 #define VIDEO1394_IOC_LISTEN_CHANNEL            \
00066         _IOWR('#', 0x10, struct video1394_mmap)
00067 #define VIDEO1394_IOC_UNLISTEN_CHANNEL          \
00068         _IOW ('#', 0x11, int)
00069 #define VIDEO1394_IOC_LISTEN_QUEUE_BUFFER       \
00070         _IOW ('#', 0x12, struct video1394_wait)
00071 #define VIDEO1394_IOC_LISTEN_WAIT_BUFFER        \
00072         _IOWR('#', 0x13, struct video1394_wait)
00073 #define VIDEO1394_IOC_TALK_CHANNEL              \
00074         _IOWR('#', 0x14, struct video1394_mmap)
00075 #define VIDEO1394_IOC_UNTALK_CHANNEL            \
00076         _IOW ('#', 0x15, int)
00077 #define VIDEO1394_IOC_TALK_QUEUE_BUFFER         \
00078         _IOW ('#', 0x16, size_t)
00079 #define VIDEO1394_IOC_TALK_WAIT_BUFFER          \
00080         _IOW ('#', 0x17, struct video1394_wait)
00081 #define VIDEO1394_IOC_LISTEN_POLL_BUFFER        \
00082         _IOWR('#', 0x18, struct video1394_wait)
00083 enum {
00084   VIDEO1394_BUFFER_FREE = 0,
00085   VIDEO1394_BUFFER_QUEUED,
00086   VIDEO1394_BUFFER_READY
00087 };
00088 
00089 enum {
00090   VIDEO1394_LISTEN_CHANNEL = 0,
00091   VIDEO1394_UNLISTEN_CHANNEL,
00092   VIDEO1394_LISTEN_QUEUE_BUFFER,
00093   VIDEO1394_LISTEN_WAIT_BUFFER,  // wait until buffer is ready
00094   VIDEO1394_TALK_CHANNEL,
00095   VIDEO1394_UNTALK_CHANNEL,
00096   VIDEO1394_TALK_QUEUE_BUFFER,
00097   VIDEO1394_TALK_WAIT_BUFFER,
00098   VIDEO1394_LISTEN_POLL_BUFFER   // return immediately with -EINTR if not ready
00099 };
00100 
00101 
00102 struct video1394_mmap {
00103   int channel;      /* -1 to find an open channel in LISTEN/TALK */
00104   unsigned int sync_tag;
00105   unsigned int nb_buffers;
00106   unsigned int buf_size;
00107   unsigned int packet_size; /* For VARIABLE_PACKET_SIZE:
00108              Maximum packet size */
00109   unsigned int fps;
00110   unsigned int syt_offset;
00111   unsigned int flags;
00112 };
00113 
00114 /* For TALK_QUEUE_BUFFER with VIDEO1394_VARIABLE_PACKET_SIZE use */
00115 struct video1394_queue_variable {
00116   unsigned int channel;
00117   unsigned int buffer;
00118   unsigned int* packet_sizes; /* Buffer of size:
00119                buf_size / packet_size  */
00120 };
00121 
00122 struct video1394_wait {
00123   unsigned int channel;
00124   unsigned int buffer;
00125   struct timeval filltime;  /* time of buffer full */
00126 };
00127 
00128 private:
00129   ThreadMutex* mutex;
00130 
00131   int  fd;
00132   int  old_buffer;
00133   int  new_buffer;
00134 
00135   bool release_mode;
00136   bool is_init;
00137   video1394_mmap video_mmap;
00138 
00139   unsigned char* map;
00140 
00141   Frame** frame_array;
00142   Frame** unreleased_buffer;
00143 
00144   string device;
00145 
00146   static ThreadMutex** mutex_array;
00147 private:
00148   void releaseBuffer(int i)  ;
00149   void listenFrame(Frame*)   ;
00150   void init(video1394_mmap* );
00151   void makeClean();
00152 
00153 };
00154 }
00155 }
00156 #endif

Generated on Wed Aug 24 00:36:40 2005 for L1394 by doxygen 1.4.2
L1394 library (NMM) grahics.cs.uni-sb.de/~repplix/l1394_home/