liveMedia/include/H264VideoRTPSink.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-2008 Live Networks, Inc.  All rights reserved.
00018 // RTP sink for H.264 video (RFC 3984)
00019 // C++ header
00020 
00021 #ifndef _H264_VIDEO_RTP_SINK_HH
00022 #define _H264_VIDEO_RTP_SINK_HH
00023 
00024 #ifndef _VIDEO_RTP_SINK_HH
00025 #include "VideoRTPSink.hh"
00026 #endif
00027 #ifndef _FRAMED_FILTER_HH
00028 #include "FramedFilter.hh"
00029 #endif
00030 
00031 class H264FUAFragmenter;
00032 
00033 class H264VideoRTPSink: public VideoRTPSink {
00034 public:
00035   static H264VideoRTPSink* createNew(UsageEnvironment& env,
00036                                      Groupsock* RTPgs,
00037                                      unsigned char rtpPayloadFormat,
00038                                      unsigned profile_level_id,
00039                                      char const* sprop_parameter_sets_str);
00040 
00041 protected:
00042   H264VideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
00043                    unsigned char rtpPayloadFormat,
00044                    unsigned profile_level_id,
00045                    char const* sprop_parameter_sets_str);
00046         // called only by createNew()
00047 
00048   virtual ~H264VideoRTPSink();
00049 
00050 private: // redefined virtual functions:
00051   virtual Boolean sourceIsCompatibleWithUs(MediaSource& source);
00052   virtual Boolean continuePlaying();
00053   virtual void stopPlaying();
00054   virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
00055                                       unsigned char* frameStart,
00056                                       unsigned numBytesInFrame,
00057                                       struct timeval frameTimestamp,
00058                                       unsigned numRemainingBytes);
00059   virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
00060                                                  unsigned numBytesInFrame) const;
00061   virtual char const* auxSDPLine();
00062 
00063 protected:
00064   H264FUAFragmenter* fOurFragmenter;
00065 
00066 private:
00067   char* fFmtpSDPLine;
00068 };
00069 
00070 
00072 
00073 // Because of the ideosyncracies of the H.264 RTP payload format, we implement
00074 // "H264VideoRTPSink" using a separate "H264FUAFragmenter" class that delivers,
00075 // to the "H264VideoRTPSink", only fragments that will fit within an outgoing
00076 // RTP packet.  I.e., we implement fragmentation in this separate "H264FUAFragmenter"
00077 // class, rather than in "H264VideoRTPSink".
00078 // (Note: This class should be used only by "H264VideoRTPSink", or a subclass.)
00079 
00080 class H264FUAFragmenter: public FramedFilter {
00081 public:
00082   H264FUAFragmenter(UsageEnvironment& env, FramedSource* inputSource,
00083                     unsigned inputBufferMax, unsigned maxOutputPacketSize);
00084   virtual ~H264FUAFragmenter();
00085 
00086   Boolean lastFragmentCompletedNALUnit() const { return fLastFragmentCompletedNALUnit; }
00087 
00088 private: // redefined virtual functions:
00089   virtual void doGetNextFrame();
00090 
00091 private:
00092   static void afterGettingFrame(void* clientData, unsigned frameSize,
00093                                 unsigned numTruncatedBytes,
00094                                 struct timeval presentationTime,
00095                                 unsigned durationInMicroseconds);
00096   void afterGettingFrame1(unsigned frameSize,
00097                           unsigned numTruncatedBytes,
00098                           struct timeval presentationTime,
00099                           unsigned durationInMicroseconds);
00100 
00101 private:
00102   unsigned fInputBufferSize;
00103   unsigned fMaxOutputPacketSize;
00104   unsigned char* fInputBuffer;
00105   unsigned fNumValidDataBytes;
00106   unsigned fCurDataOffset;
00107   unsigned fSaveNumTruncatedBytes;
00108   Boolean fLastFragmentCompletedNALUnit;
00109 };
00110 
00111 
00112 #endif

Generated on Fri Dec 19 21:58:18 2008 for live by  doxygen 1.5.2