liveMedia/include/H264VideoStreamFramer.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 // A filter that breaks up a H.264 Video Elementary Stream into NAL units.
00019 // C++ header
00020 
00021 #ifndef _H264_VIDEO_STREAM_FRAMER_HH
00022 #define _H264_VIDEO_STREAM_FRAMER_HH
00023 
00024 #ifndef _MPEG_VIDEO_STREAM_FRAMER_HH
00025 #include "MPEGVideoStreamFramer.hh"
00026 #endif
00027 
00028 class H264VideoStreamFramer: public MPEGVideoStreamFramer {
00029 public:
00030   static H264VideoStreamFramer* createNew(UsageEnvironment& env, FramedSource* inputSource,
00031                                           Boolean includeStartCodeInOutput = False);
00032 
00033   void getSPSandPPS(u_int8_t*& sps, unsigned& spsSize, u_int8_t*& pps, unsigned& ppsSize) const{
00034     // Returns pointers to copies of the most recently seen SPS (sequence parameter set) and PPS (picture parameter set) NAL unit.
00035     // (NULL pointers are returned if the NAL units have not yet been seen.)
00036     sps = fLastSeenSPS; spsSize = fLastSeenSPSSize;
00037     pps = fLastSeenPPS; ppsSize = fLastSeenPPSSize;
00038   }
00039 
00040   void setSPSandPPS(u_int8_t* sps, unsigned spsSize, u_int8_t* pps, unsigned ppsSize) {
00041     // Assigns copies of the SPS and PPS NAL units.  If this function is not called, then these NAL units are assigned
00042     // only if/when they appear in the input stream.  
00043     saveCopyOfSPS(sps, spsSize);
00044     saveCopyOfPPS(pps, ppsSize);
00045   }
00046   void setSPSandPPS(char const* sPropParameterSetsStr);
00047     // As above, except that the SPS and PPS NAL units are decoded from the input string, which must be a Base-64 encoding of
00048     // these NAL units (in either order), separated by a comma.  (This string is typically found in a SDP description, and
00049     // accessed using "MediaSubsession::fmtp_spropparametersets()".
00050 
00051 protected:
00052   H264VideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource, Boolean createParser, Boolean includeStartCodeInOutput);
00053   virtual ~H264VideoStreamFramer();
00054 
00055   void saveCopyOfSPS(u_int8_t* from, unsigned size);
00056   void saveCopyOfPPS(u_int8_t* from, unsigned size);
00057 
00058   // redefined virtual functions:
00059   virtual Boolean isH264VideoStreamFramer() const;
00060 
00061 private:
00062   void setPresentationTime() { fPresentationTime = fNextPresentationTime; }
00063 
00064 private:
00065   Boolean fIncludeStartCodeInOutput;
00066   u_int8_t* fLastSeenSPS;
00067   unsigned fLastSeenSPSSize;
00068   u_int8_t* fLastSeenPPS;
00069   unsigned fLastSeenPPSSize;
00070   struct timeval fNextPresentationTime; // the presentation time to be used for the next NAL unit to be parsed/delivered after this
00071   friend class H264VideoStreamParser; // hack
00072 };
00073 
00074 #endif

Generated on Thu May 10 20:25:11 2012 for live by  doxygen 1.5.2