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

mxcpcStreamFile.h

00001 //           ///          //                                        Mx clientSDK
00002 //          /////        ////                    Mx Crossplatform Client Library
00003 //         /// XXX     XXX ///
00004 //        ///    XXX XXX    ///     $RCSfile: mxcpcStreamFile.h,v $
00005 //       ///       XXX       ///     $Revision: 1.9 $
00006 //      ///      XXX XXX      ///     $Date: 2006/01/16 15:37:00 $
00007 //     ////    XXX     XXX    ////     $Author: cvs-kai $
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //                                                                          //
00012 //  Copyright (C) 2005 - 2006, MOBOTIX AG, Germany                         //
00013 //  This software is made available under the BSD licence. Please refer   //
00014 //  to the file LICENCE.TXT contained in this distribution for details.  //
00015 //                                                                      //
00016 //  /////////////////////////////////////////////////////////////////////
00017 
00018 
00019 
00020 #ifndef __MXCPC_STREAMFILE_H__
00021 #define __MXCPC_STREAMFILE_H__
00022 
00023 
00024 
00025 #include <mxcpcStreamSource.h>
00026 
00027 
00028 
00029 //! File serving as stream source for stream decoding via mxcpcStreamDecoder.
00030 /*!
00031  *  \ingroup mxcpc_core
00032  * 
00033  *  If invoked by specifying a filename to the constructor, the respective file
00034  *  is automatically opened. It is also automatically closed again when the 
00035  *  stream file is deleted later.
00036  *
00037  *  If, on the other hand, the stream file is invoked by specifying a 
00038  *  <tt>POSIX</tt> file descriptor to the constructor, the file descriptor is 
00039  *  used instead. Note that in this case the corresponing file is <b>not 
00040  *  closed</b> upon stream file destruction.
00041  *
00042  *  The stream file sports a so-called <i>Timed Block Mode</i> that can be
00043  *  toggled at any time using the setTimedBlockModeEnabled() method. If enabled,
00044  *  a UNIX <tt>select()</tt> call is issued prior to read attempts on the
00045  *  encapsuled file descriptor using the specified timeout. This causes the
00046  *  fetchBytes() implementation to block in the kernel if no data is available,
00047  *  but at most for that many milliseconds as was specified to 
00048  *  setTimedBlockModeEnabled(). If such a blocking times out before any new data
00049  *  come in over the file descriptor, fetchBytes() returns with a return value 
00050  *  of <tt>0</tt>.  
00051  *
00052  *  As usual, with <tt>Microsoft</tt> happily adding non-<tt>POSIX</tt> flags to
00053  *  <tt>POSIX</tt> interfaces, we have to provide a modified implementation for
00054  *  the <tt>WINDOWS</tt> platform.
00055  */
00056 class mxcpcStreamFile : public mxcpcStreamSource {
00057 
00058  private:
00059   int InFile;
00060   bool StillUp;
00061   bool TimedBlockMode;
00062   long BlockTimeout;
00063   bool CloseFileUponDestruction;
00064   
00065  private:
00066   //! only used on WINDOWS
00067   int RestoreMode;
00068   long OSFHandle;
00069   
00070  public:
00071   mxcpcStreamFile(const char *filename);
00072   mxcpcStreamFile(int fd);
00073   ~mxcpcStreamFile();
00074 
00075  public:
00076   //! Toggles/configures the timed block mode, see mxcpcStreamFile.
00077   void setTimedBlockModeEnabled(bool enabled, long timeout = 1000);
00078   //! (Re)implemented.
00079   int fetchBytes(unsigned char *buffer, int num);
00080   //! (Re)implemented.
00081   bool stillUp(void);
00082 };
00083 
00084 
00085 
00086 #endif   // __MXCPC_STREAMFILE_H__

Generated on Mon Jan 30 15:52:44 2006 for mxcpc by  doxygen 1.4.4