liveMedia/include/T140TextRTPSink.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 // RTP sink for T.140 text (RFC 2793)
00019 // C++ header
00020 
00021 #ifndef _T140_TEXT_RTP_SINK_HH
00022 #define _T140_TEXT_RTP_SINK_HH
00023 
00024 #ifndef _TEXT_RTP_SINK_HH
00025 #include "TextRTPSink.hh"
00026 #endif
00027 #ifndef _FRAMED_FILTER_HH
00028 #include "FramedFilter.hh"
00029 #endif
00030 
00031 class T140IdleFilter;
00032 
00033 class T140TextRTPSink: public TextRTPSink {
00034 public:
00035   static T140TextRTPSink* createNew(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
00036 
00037 protected:
00038   T140TextRTPSink(UsageEnvironment& env, Groupsock* RTPgs, unsigned char rtpPayloadFormat);
00039         // called only by createNew()
00040 
00041   virtual ~T140TextRTPSink();
00042 
00043 protected: // redefined virtual functions:
00044   virtual Boolean continuePlaying();
00045   virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
00046                                       unsigned char* frameStart,
00047                                       unsigned numBytesInFrame,
00048                                       struct timeval framePresentationTime,
00049                                       unsigned numRemainingBytes);
00050   virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
00051                                                  unsigned numBytesInFrame) const;
00052 
00053 protected:
00054   T140IdleFilter* fOurIdleFilter;
00055   Boolean fAreInIdlePeriod;
00056 };
00057 
00058 
00060 
00061 // Because the T.140 text RTP payload format specification recommends that (empty) RTP packets be sent during 'idle periods'
00062 // when no new text is available, we implement "T140TextRTPSink" using a separate "T140IdleFilter" class - sitting in front
00063 // -  that delivers, to the "T140TextRTPSink", a continuous sequence of (possibly) empty frames.
00064 // (Note: This class should be used only by "T140TextRTPSink", or a subclass.)
00065 
00066 class T140IdleFilter: public FramedFilter {
00067 public:
00068   T140IdleFilter(UsageEnvironment& env, FramedSource* inputSource);
00069   virtual ~T140IdleFilter();
00070 
00071 private: // redefined virtual functions:
00072   virtual void doGetNextFrame();
00073   virtual void doStopGettingFrames();
00074 
00075 private:
00076   static void afterGettingFrame(void* clientData, unsigned frameSize,
00077                                 unsigned numTruncatedBytes,
00078                                 struct timeval presentationTime,
00079                                 unsigned durationInMicroseconds);
00080   void afterGettingFrame(unsigned frameSize,
00081                          unsigned numTruncatedBytes,
00082                          struct timeval presentationTime,
00083                          unsigned durationInMicroseconds);
00084 
00085   static void handleIdleTimeout(void* clientData);
00086   void handleIdleTimeout();
00087 
00088   void deliverFromBuffer();
00089   void deliverEmptyFrame();
00090 
00091   static void onSourceClosure(void* clientData);
00092   void onSourceClosure();
00093 
00094 private:
00095   TaskToken fIdleTimerTask;
00096   unsigned fBufferSize, fNumBufferedBytes;
00097   char* fBuffer;
00098   unsigned fBufferedNumTruncatedBytes; // a count of truncated bytes from the upstream
00099   struct timeval fBufferedDataPresentationTime;
00100   unsigned fBufferedDataDurationInMicroseconds;
00101 };
00102 
00103 #endif

Generated on Thu May 17 07:11:46 2012 for live by  doxygen 1.5.2