DVVideoStreamFramer.hh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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 filter that parses a DV input stream into DV frames to deliver to the downstream object
  17. // C++ header
  18. #ifndef _DV_VIDEO_STREAM_FRAMER_HH
  19. #define _DV_VIDEO_STREAM_FRAMER_HH
  20. #ifndef _FRAMED_FILTER_HH
  21. #include "FramedFilter.hh"
  22. #endif
  23. #define DV_DIF_BLOCK_SIZE 80
  24. #define DV_NUM_BLOCKS_PER_SEQUENCE 150
  25. #define DV_SAVED_INITIAL_BLOCKS_SIZE ((DV_NUM_BLOCKS_PER_SEQUENCE+6-1)*DV_DIF_BLOCK_SIZE)
  26. /* enough data to ensure that it contains an intact 6-block header (which occurs at the start of a 150-block sequence) */
  27. class DVVideoStreamFramer: public FramedFilter {
  28. public:
  29. static DVVideoStreamFramer*
  30. createNew(UsageEnvironment& env, FramedSource* inputSource,
  31. Boolean sourceIsSeekable = False, Boolean leavePresentationTimesUnmodified = False);
  32. // Set "sourceIsSeekable" to True if the input source is a seekable object (e.g. a file), and the server that uses us
  33. // does a seek-to-zero on the source before reading from it. (Our RTSP server implementation does this.)
  34. char const* profileName();
  35. Boolean getFrameParameters(unsigned& frameSize/*bytes*/, double& frameDuration/*microseconds*/);
  36. protected:
  37. DVVideoStreamFramer(UsageEnvironment& env, FramedSource* inputSource,
  38. Boolean sourceIsSeekable, Boolean leavePresentationTimesUnmodified);
  39. // called only by createNew(), or by subclass constructors
  40. virtual ~DVVideoStreamFramer();
  41. protected:
  42. // redefined virtual functions:
  43. virtual Boolean isDVVideoStreamFramer() const;
  44. virtual void doGetNextFrame();
  45. protected:
  46. void getAndDeliverData(); // used to implement "doGetNextFrame()"
  47. static void afterGettingFrame(void* clientData, unsigned frameSize,
  48. unsigned numTruncatedBytes,
  49. struct timeval presentationTime,
  50. unsigned durationInMicroseconds);
  51. void afterGettingFrame(unsigned frameSize, unsigned numTruncatedBytes, struct timeval presentationTime);
  52. void getProfile();
  53. protected:
  54. Boolean fLeavePresentationTimesUnmodified;
  55. void const* fOurProfile;
  56. struct timeval fNextFramePresentationTime;
  57. unsigned char fSavedInitialBlocks[DV_SAVED_INITIAL_BLOCKS_SIZE];
  58. char fInitialBlocksPresent;
  59. Boolean fSourceIsSeekable;
  60. };
  61. #endif