MPEG2TransportStreamFramer.hh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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-2020 Live Networks, Inc. All rights reserved.
  16. // A filter that passes through (unchanged) chunks that contain an integral number
  17. // of MPEG-2 Transport Stream packets, but returning (in "fDurationInMicroseconds")
  18. // an updated estimate of the time gap between chunks.
  19. // C++ header
  20. #ifndef _MPEG2_TRANSPORT_STREAM_FRAMER_HH
  21. #define _MPEG2_TRANSPORT_STREAM_FRAMER_HH
  22. #ifndef _FRAMED_FILTER_HH
  23. #include "FramedFilter.hh"
  24. #endif
  25. #ifndef _HASH_TABLE_HH
  26. #include "HashTable.hh"
  27. #endif
  28. class MPEG2TransportStreamFramer: public FramedFilter {
  29. public:
  30. static MPEG2TransportStreamFramer*
  31. createNew(UsageEnvironment& env, FramedSource* inputSource);
  32. u_int64_t tsPacketCount() const { return fTSPacketCount; }
  33. void changeInputSource(FramedSource* newInputSource) { fInputSource = newInputSource; }
  34. void clearPIDStatusTable();
  35. void setNumTSPacketsToStream(unsigned long numTSRecordsToStream);
  36. void setPCRLimit(float pcrLimit);
  37. protected:
  38. MPEG2TransportStreamFramer(UsageEnvironment& env, FramedSource* inputSource);
  39. // called only by createNew()
  40. virtual ~MPEG2TransportStreamFramer();
  41. private:
  42. // Redefined virtual functions:
  43. virtual void doGetNextFrame();
  44. virtual void doStopGettingFrames();
  45. private:
  46. static void afterGettingFrame(void* clientData, unsigned frameSize,
  47. unsigned numTruncatedBytes,
  48. struct timeval presentationTime,
  49. unsigned durationInMicroseconds);
  50. void afterGettingFrame1(unsigned frameSize,
  51. struct timeval presentationTime);
  52. Boolean updateTSPacketDurationEstimate(unsigned char* pkt, double timeNow);
  53. private:
  54. u_int64_t fTSPacketCount;
  55. double fTSPacketDurationEstimate;
  56. HashTable* fPIDStatusTable;
  57. u_int64_t fTSPCRCount;
  58. Boolean fLimitNumTSPacketsToStream;
  59. unsigned long fNumTSPacketsToStream; // used iff "fLimitNumTSPacketsToStream" is True
  60. Boolean fLimitTSPacketsToStreamByPCR;
  61. float fPCRLimit; // used iff "fLimitTSPacketsToStreamByPCR" is True
  62. };
  63. #endif