MP3FileSource.hh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. // MP3 File Sources
  17. // C++ header
  18. #ifndef _MP3_FILE_SOURCE_HH
  19. #define _MP3_FILE_SOURCE_HH
  20. #ifndef _FRAMED_FILE_SOURCE_HH
  21. #include "FramedFileSource.hh"
  22. #endif
  23. class MP3StreamState; // forward
  24. class MP3FileSource: public FramedFileSource {
  25. public:
  26. static MP3FileSource* createNew(UsageEnvironment& env, char const* fileName);
  27. float filePlayTime() const;
  28. unsigned fileSize() const;
  29. void setPresentationTimeScale(unsigned scale);
  30. void seekWithinFile(double seekNPT, double streamDuration);
  31. // if "streamDuration" is >0.0, then we limit the stream to that duration, before treating it as EOF
  32. protected:
  33. MP3FileSource(UsageEnvironment& env, FILE* fid);
  34. // called only by createNew()
  35. virtual ~MP3FileSource();
  36. protected:
  37. void assignStream(FILE* fid, unsigned filesize);
  38. Boolean initializeStream();
  39. MP3StreamState* streamState() {return fStreamState;}
  40. private:
  41. // redefined virtual functions:
  42. virtual void doGetNextFrame();
  43. virtual char const* MIMEtype() const;
  44. virtual void getAttributes() const;
  45. private:
  46. virtual Boolean doGetNextFrame1();
  47. private:
  48. MP3StreamState* fStreamState;
  49. Boolean fHaveJustInitialized;
  50. struct timeval fFirstFramePresentationTime; // set on stream init
  51. Boolean fLimitNumBytesToStream;
  52. unsigned fNumBytesToStream; // used iff "fLimitNumBytesToStream" is True
  53. };
  54. #endif