MP3ADU.hh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. // 'ADU' MP3 streams (for improved loss-tolerance)
  17. // C++ header
  18. #ifndef _MP3_ADU_HH
  19. #define _MP3_ADU_HH
  20. #ifndef _FRAMED_FILTER_HH
  21. #include "FramedFilter.hh"
  22. #endif
  23. class ADUFromMP3Source: public FramedFilter {
  24. public:
  25. static ADUFromMP3Source* createNew(UsageEnvironment& env,
  26. FramedSource* inputSource,
  27. Boolean includeADUdescriptors = True);
  28. void resetInput();
  29. // This is called whenever there's a discontinuity in the input MP3 source
  30. // (e.g., due to seeking within the source). It causes any still-unprocessed
  31. // MP3 frame data within our queue to be discarded, so that it does not
  32. // erroneously get used by backpointers from the new MP3 frames.
  33. Boolean setScaleFactor(int scale);
  34. protected:
  35. ADUFromMP3Source(UsageEnvironment& env,
  36. FramedSource* inputSource,
  37. Boolean includeADUdescriptors);
  38. // called only by createNew()
  39. virtual ~ADUFromMP3Source();
  40. private:
  41. // Redefined virtual functions:
  42. virtual void doGetNextFrame();
  43. virtual char const* MIMEtype() const;
  44. private:
  45. Boolean doGetNextFrame1();
  46. private:
  47. Boolean fAreEnqueueingMP3Frame;
  48. class SegmentQueue* fSegments;
  49. Boolean fIncludeADUdescriptors;
  50. unsigned fTotalDataSizeBeforePreviousRead;
  51. int fScale;
  52. unsigned fFrameCounter;
  53. };
  54. class MP3FromADUSource: public FramedFilter {
  55. public:
  56. static MP3FromADUSource* createNew(UsageEnvironment& env,
  57. FramedSource* inputSource,
  58. Boolean includeADUdescriptors = True);
  59. protected:
  60. MP3FromADUSource(UsageEnvironment& env,
  61. FramedSource* inputSource,
  62. Boolean includeADUdescriptors);
  63. // called only by createNew()
  64. virtual ~MP3FromADUSource();
  65. private:
  66. // Redefined virtual functions:
  67. virtual void doGetNextFrame();
  68. virtual char const* MIMEtype() const;
  69. private:
  70. Boolean needToGetAnADU();
  71. void insertDummyADUsIfNecessary();
  72. Boolean generateFrameFromHeadADU();
  73. private:
  74. Boolean fAreEnqueueingADU;
  75. class SegmentQueue* fSegments;
  76. };
  77. // Definitions of external C functions that implement various MP3 operations:
  78. extern "C" int mp3ZeroOutSideInfo(unsigned char*, unsigned, unsigned);
  79. #endif