liveMedia/include/FramedSource.hh

Go to the documentation of this file.
00001 /**********
00002 This library is free software; you can redistribute it and/or modify it under
00003 the terms of the GNU Lesser General Public License as published by the
00004 Free Software Foundation; either version 2.1 of the License, or (at your
00005 option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
00006 
00007 This library is distributed in the hope that it will be useful, but WITHOUT
00008 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00009 FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License for
00010 more details.
00011 
00012 You should have received a copy of the GNU Lesser General Public License
00013 along with this library; if not, write to the Free Software Foundation, Inc.,
00014 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
00015 **********/
00016 // "liveMedia"
00017 // Copyright (c) 1996-2012 Live Networks, Inc.  All rights reserved.
00018 // Framed Sources
00019 // C++ header
00020 
00021 #ifndef _FRAMED_SOURCE_HH
00022 #define _FRAMED_SOURCE_HH
00023 
00024 #ifndef _NET_COMMON_H
00025 #include "NetCommon.h"
00026 #endif
00027 #ifndef _MEDIA_SOURCE_HH
00028 #include "MediaSource.hh"
00029 #endif
00030 
00031 class FramedSource: public MediaSource {
00032 public:
00033   static Boolean lookupByName(UsageEnvironment& env, char const* sourceName,
00034                               FramedSource*& resultSource);
00035 
00036   typedef void (afterGettingFunc)(void* clientData, unsigned frameSize,
00037                                   unsigned numTruncatedBytes,
00038                                   struct timeval presentationTime,
00039                                   unsigned durationInMicroseconds);
00040   typedef void (onCloseFunc)(void* clientData);
00041   void getNextFrame(unsigned char* to, unsigned maxSize,
00042                     afterGettingFunc* afterGettingFunc,
00043                     void* afterGettingClientData,
00044                     onCloseFunc* onCloseFunc,
00045                     void* onCloseClientData);
00046 
00047   static void handleClosure(void* clientData);
00048       // This should be called (on ourself) if the source is discovered
00049       // to be closed (i.e., no longer readable)
00050 
00051   void stopGettingFrames();
00052 
00053   virtual unsigned maxFrameSize() const;
00054       // size of the largest possible frame that we may serve, or 0
00055       // if no such maximum is known (default)
00056 
00057   virtual void doGetNextFrame() = 0;
00058       // called by getNextFrame()
00059 
00060   Boolean isCurrentlyAwaitingData() const {return fIsCurrentlyAwaitingData;}
00061 
00062   static void afterGetting(FramedSource* source);
00063       // doGetNextFrame() should arrange for this to be called after the
00064       // frame has been read (*iff* it is read successfully)
00065 
00066 protected:
00067   FramedSource(UsageEnvironment& env); // abstract base class
00068   virtual ~FramedSource();
00069 
00070   virtual void doStopGettingFrames();
00071 
00072 protected:
00073   // The following variables are typically accessed/set by doGetNextFrame()
00074   unsigned char* fTo; // in
00075   unsigned fMaxSize; // in
00076   unsigned fFrameSize; // out
00077   unsigned fNumTruncatedBytes; // out
00078   struct timeval fPresentationTime; // out
00079   unsigned fDurationInMicroseconds; // out
00080 
00081 private:
00082   // redefined virtual functions:
00083   virtual Boolean isFramedSource() const;
00084 
00085 private:
00086   afterGettingFunc* fAfterGettingFunc;
00087   void* fAfterGettingClientData;
00088   onCloseFunc* fOnCloseFunc;
00089   void* fOnCloseClientData;
00090 
00091   Boolean fIsCurrentlyAwaitingData;
00092 };
00093 
00094 #endif

Generated on Thu Feb 2 23:51:30 2012 for live by  doxygen 1.5.2