MPEG1or2VideoStreamDiscreteFramer.hh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 simplified version of "MPEG1or2VideoStreamFramer" that takes only
  17. // complete, discrete frames (rather than an arbitrary byte stream) as input.
  18. // This avoids the parsing and data copying overhead of the full
  19. // "MPEG1or2VideoStreamFramer".
  20. // C++ header
  21. #ifndef _MPEG1or2_VIDEO_STREAM_DISCRETE_FRAMER_HH
  22. #define _MPEG1or2_VIDEO_STREAM_DISCRETE_FRAMER_HH
  23. #ifndef _MPEG1or2_VIDEO_STREAM_FRAMER_HH
  24. #include "MPEG1or2VideoStreamFramer.hh"
  25. #endif
  26. #define VSH_MAX_SIZE 1000
  27. class MPEG1or2VideoStreamDiscreteFramer: public MPEG1or2VideoStreamFramer {
  28. public:
  29. static MPEG1or2VideoStreamDiscreteFramer*
  30. createNew(UsageEnvironment& env, FramedSource* inputSource,
  31. Boolean iFramesOnly = False, // see MPEG1or2VideoStreamFramer.hh
  32. double vshPeriod = 5.0, // see MPEG1or2VideoStreamFramer.hh
  33. Boolean leavePresentationTimesUnmodified = False);
  34. protected:
  35. MPEG1or2VideoStreamDiscreteFramer(UsageEnvironment& env,
  36. FramedSource* inputSource,
  37. Boolean iFramesOnly, double vshPeriod, Boolean leavePresentationTimesUnmodified);
  38. // called only by createNew()
  39. virtual ~MPEG1or2VideoStreamDiscreteFramer();
  40. protected:
  41. // redefined virtual functions:
  42. virtual void doGetNextFrame();
  43. protected:
  44. static void afterGettingFrame(void* clientData, unsigned frameSize,
  45. unsigned numTruncatedBytes,
  46. struct timeval presentationTime,
  47. unsigned durationInMicroseconds);
  48. void afterGettingFrame1(unsigned frameSize,
  49. unsigned numTruncatedBytes,
  50. struct timeval presentationTime,
  51. unsigned durationInMicroseconds);
  52. protected:
  53. Boolean fLeavePresentationTimesUnmodified;
  54. struct timeval fLastNonBFramePresentationTime;
  55. unsigned fLastNonBFrameTemporal_reference;
  56. // A saved copy of the most recently seen 'video_sequence_header',
  57. // in case we need to insert it into the stream periodically:
  58. unsigned char fSavedVSHBuffer[VSH_MAX_SIZE];
  59. unsigned fSavedVSHSize;
  60. double fSavedVSHTimestamp;
  61. Boolean fIFramesOnly;
  62. double fVSHPeriod;
  63. };
  64. #endif