MPEGVideoStreamFramer.hh 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**********
  2. This library is free software; you can redistribute it and/or modify it under
  3. the terms of the GNU Lesser General Public License as published by the
  4. Free Software Foundation; either version 3 of the License, or (at your
  5. option) any later version. (See <http://www.gnu.org/copyleft/lesser.html>.)
  6. This library is distributed in the hope that it will be useful, but WITHOUT
  7. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  8. FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
  9. more details.
  10. You should have received a copy of the GNU Lesser General Public License
  11. along with this library; if not, write to the Free Software Foundation, Inc.,
  12. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  13. **********/
  14. // "liveMedia"
  15. // Copyright (c) 1996-2019 Live Networks, Inc. All rights reserved.
  16. // A filter that breaks up an MPEG video elementary stream into
  17. // headers and frames
  18. // C++ header
  19. #ifndef _MPEG_VIDEO_STREAM_FRAMER_HH
  20. #define _MPEG_VIDEO_STREAM_FRAMER_HH
  21. #ifndef _FRAMED_FILTER_HH
  22. #include "FramedFilter.hh"
  23. #endif
  24. class TimeCode {
  25. public:
  26. TimeCode();
  27. virtual ~TimeCode();
  28. int operator==(TimeCode const& arg2);
  29. unsigned days, hours, minutes, seconds, pictures;
  30. };
  31. class MPEGVideoStreamFramer: public FramedFilter {
  32. public:
  33. Boolean& pictureEndMarker() { return fPictureEndMarker; }
  34. // a hack for implementing the RTP 'M' bit
  35. void flushInput(); // called if there is a discontinuity (seeking) in the input
  36. protected:
  37. MPEGVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource);
  38. // we're an abstract base class
  39. virtual ~MPEGVideoStreamFramer();
  40. void computePresentationTime(unsigned numAdditionalPictures);
  41. // sets "fPresentationTime"
  42. void setTimeCode(unsigned hours, unsigned minutes, unsigned seconds,
  43. unsigned pictures, unsigned picturesSinceLastGOP);
  44. private: // redefined virtual functions
  45. virtual void doGetNextFrame();
  46. virtual void doStopGettingFrames();
  47. private:
  48. void reset();
  49. static void continueReadProcessing(void* clientData,
  50. unsigned char* ptr, unsigned size,
  51. struct timeval presentationTime);
  52. void continueReadProcessing();
  53. protected:
  54. double fFrameRate; // Note: For MPEG-4, this is really a 'tick rate'
  55. unsigned fPictureCount; // hack used to implement doGetNextFrame()
  56. Boolean fPictureEndMarker;
  57. struct timeval fPresentationTimeBase;
  58. // parsing state
  59. class MPEGVideoStreamParser* fParser;
  60. friend class MPEGVideoStreamParser; // hack
  61. private:
  62. TimeCode fCurGOPTimeCode, fPrevGOPTimeCode;
  63. unsigned fPicturesAdjustment;
  64. double fPictureTimeBase;
  65. unsigned fTcSecsBase;
  66. Boolean fHaveSeenFirstTimeCode;
  67. };
  68. #endif