QuartzQuickTimeDecoder.H

Go to the documentation of this file.
00001 /*!@file Media/QuartzQuickTimeDecoder.H */
00002 
00003 // //////////////////////////////////////////////////////////////////// //
00004 // The iLab Neuromorphic Vision C++ Toolkit - Copyright (C) 2000-2005   //
00005 // by the University of Southern California (USC) and the iLab at USC.  //
00006 // See http://iLab.usc.edu for information about this project.          //
00007 // //////////////////////////////////////////////////////////////////// //
00008 // Major portions of the iLab Neuromorphic Vision Toolkit are protected //
00009 // under the U.S. patent ``Computation of Intrinsic Perceptual Saliency //
00010 // in Visual Environments, and Applications'' by Christof Koch and      //
00011 // Laurent Itti, California Institute of Technology, 2001 (patent       //
00012 // pending; application number 09/912,225 filed July 23, 2001; see      //
00013 // http://pair.uspto.gov/cgi-bin/final/home.pl for current status).     //
00014 // //////////////////////////////////////////////////////////////////// //
00015 // This file is part of the iLab Neuromorphic Vision C++ Toolkit.       //
00016 //                                                                      //
00017 // The iLab Neuromorphic Vision C++ Toolkit is free software; you can   //
00018 // redistribute it and/or modify it under the terms of the GNU General  //
00019 // Public License as published by the Free Software Foundation; either  //
00020 // version 2 of the License, or (at your option) any later version.     //
00021 //                                                                      //
00022 // The iLab Neuromorphic Vision C++ Toolkit is distributed in the hope  //
00023 // that it will be useful, but WITHOUT ANY WARRANTY; without even the   //
00024 // implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      //
00025 // PURPOSE.  See the GNU General Public License for more details.       //
00026 //                                                                      //
00027 // You should have received a copy of the GNU General Public License    //
00028 // along with the iLab Neuromorphic Vision C++ Toolkit; if not, write   //
00029 // to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,   //
00030 // Boston, MA 02111-1307 USA.                                           //
00031 // //////////////////////////////////////////////////////////////////// //
00032 //
00033 // Primary maintainer for this file: Rob Peters <rjpeters at usc dot edu>
00034 // $HeadURL: svn://isvn.usc.edu/software/invt/trunk/saliency/src/Media/QuartzQuickTimeDecoder.H $
00035 // $Id: QuartzQuickTimeDecoder.H 7959 2007-02-20 23:37:25Z rjpeters $
00036 //
00037 
00038 #ifndef MEDIA_QUARTZQUICKTIMEDECODER_H_DEFINED
00039 #define MEDIA_QUARTZQUICKTIMEDECODER_H_DEFINED
00040 
00041 #ifdef HAVE_QUICKTIME_QUICKTIME_H
00042 
00043 #include "Image/Image.H"
00044 #include "Image/Pixels.H"
00045 #include "Media/MovieDecoder.H"
00046 #include "Raster/GenericFrame.H"
00047 #include "Util/Janitor.H"
00048 
00049 #include <QuickTime/QuickTime.h>
00050 #include <string>
00051 
00052 /// Decode movie streams with QuickTime and using Quartz 2D for offscreen rendering
00053 /** The older, now-deprecated, approach was to use QuickDraw (GWorld,
00054     etc.) for offscreen rendering, which can be found in QuickTimeDecoder */
00055 class QuartzQuickTimeDecoder : public MovieDecoder
00056 {
00057 public:
00058   /// Construct a quartz quicktime movie from a filename, codec name, etc.
00059   QuartzQuickTimeDecoder(const char* fname);
00060 
00061   /// Destructor
00062   ~QuartzQuickTimeDecoder();
00063 
00064   /// Get the "apparent" frame number
00065   /** This function takes into account whether or not the next frame
00066       will be a push-back frame */
00067   virtual int apparentFrameNumber() const;
00068 
00069   /// Get the specifications of the movie frames
00070   virtual GenericFrameSpec peekFrameSpec();
00071 
00072   /// Get the next raw VideoFrame from the stream
00073   virtual VideoFrame readVideoFrame();
00074 
00075   /// Read an RGB image from the stream
00076   virtual Image<PixRGB<byte> > readRGB();
00077 
00078   /// Read a frame from the stream and discard it
00079   /** If you know you are going to discard the frame (e.g. to skip
00080       ahead to a certain frame number, or to count the frame), then it
00081       is more efficient to call readAndDiscardFrame() than to call
00082       readVideoFrame() or readRGB() but ignore the result. */
00083   virtual bool readAndDiscardFrame();
00084 
00085   GenericFrame readFrame();
00086 
00087 private:
00088   QuartzQuickTimeDecoder(const QuartzQuickTimeDecoder&);
00089   QuartzQuickTimeDecoder& operator=(const QuartzQuickTimeDecoder&);
00090 
00091   static void imageAvailableCallback(QTVisualContextRef visualContext,
00092                                      const CVTimeStamp* timeStamp, void* refCon);
00093 
00094   Janitor<Movie>               itsMovie;
00095   Janitor<QTVisualContextRef>  itsVisualContext;
00096   Dims                         itsDims;
00097   GenericFrame                 itsFrame;
00098   int                          itsFrameNumber;
00099   TimeValue                    itsNextTime;
00100   bool                         itsNextFramePushback; // whether to re-use the current frame
00101   bool                         itsFirstFrame; // if we've read frame #1, then dims are valid
00102   std::string                  itsCallbackError;
00103 };
00104 
00105 #endif // HAVE_QUICKTIME_QUICKTIME_H
00106 
00107 // ######################################################################
00108 /* So things look consistent in everyone's emacs... */
00109 /* Local Variables: */
00110 /* mode: c++ */
00111 /* indent-tabs-mode: nil */
00112 /* End: */
00113 
00114 #endif // MEDIA_QUARTZQUICKTIMEDECODER_H_DEFINED
Generated on Sun May 8 08:05:20 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3