ByteStreamMultiFileSource.hh 2.5 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. // A source that consists of multiple byte-stream files, read sequentially.
  17. // (The input is an array of file names, with a terminating 'file name' of NULL.)
  18. // C++ header
  19. #ifndef _BYTE_STREAM_MULTI_FILE_SOURCE_HH
  20. #define _BYTE_STREAM_MULTI_FILE_SOURCE_HH
  21. #ifndef _BYTE_STREAM_FILE_SOURCE_HH
  22. #include "ByteStreamFileSource.hh"
  23. #endif
  24. class ByteStreamMultiFileSource: public FramedSource {
  25. public:
  26. static ByteStreamMultiFileSource*
  27. createNew(UsageEnvironment& env, char const** fileNameArray,
  28. unsigned preferredFrameSize = 0, unsigned playTimePerFrame = 0);
  29. // "fileNameArray" is a pointer to an array of (char const*) file names, with
  30. // A 'file name' of NULL indicating the end of the array
  31. Boolean haveStartedNewFile() const { return fHaveStartedNewFile; }
  32. // True iff the most recently delivered frame was the first from a newly-opened file
  33. protected:
  34. ByteStreamMultiFileSource(UsageEnvironment& env, char const** fileNameArray,
  35. unsigned preferredFrameSize, unsigned playTimePerFrame);
  36. // called only by createNew()
  37. virtual ~ByteStreamMultiFileSource();
  38. private:
  39. // redefined virtual functions:
  40. virtual void doGetNextFrame();
  41. private:
  42. static void onSourceClosure(void* clientData);
  43. void onSourceClosure1();
  44. static void afterGettingFrame(void* clientData,
  45. unsigned frameSize, unsigned numTruncatedBytes,
  46. struct timeval presentationTime,
  47. unsigned durationInMicroseconds);
  48. private:
  49. unsigned fPreferredFrameSize;
  50. unsigned fPlayTimePerFrame;
  51. unsigned fNumSources;
  52. unsigned fCurrentlyReadSourceNumber;
  53. Boolean fHaveStartedNewFile;
  54. char const** fFileNameArray;
  55. ByteStreamFileSource** fSourceArray;
  56. };
  57. #endif