RawVideoRTPSink.hh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. // RTP sink for Raw video
  17. // C++ header
  18. #ifndef _RAW_VIDEO_RTP_SINK_HH
  19. #define _RAW_VIDEO_RTP_SINK_HH
  20. #ifndef _VIDEO_RTP_SINK_HH
  21. #include "VideoRTPSink.hh"
  22. #endif
  23. ////////// FrameParameters //////////
  24. struct FrameParameters {
  25. u_int16_t pGroupSize;
  26. u_int16_t nbOfPixelInPGroup;
  27. u_int32_t scanLineSize ;
  28. u_int32_t frameSize;
  29. u_int16_t scanLineIterationStep;
  30. };
  31. class RawVideoRTPSink: public VideoRTPSink {
  32. public:
  33. static RawVideoRTPSink*
  34. createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat,
  35. // The following headers provide the 'configuration' information, for the SDP description:
  36. unsigned height, unsigned width, unsigned depth,
  37. char const* sampling, char const* colorimetry = "BT709-2");
  38. protected:
  39. RawVideoRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
  40. u_int8_t rtpPayloadFormat,
  41. unsigned height, unsigned width, unsigned depth,
  42. char const* sampling, char const* colorimetry = "BT709-2");
  43. // called only by createNew()
  44. virtual ~RawVideoRTPSink();
  45. private: // redefined virtual functions:
  46. virtual char const* auxSDPLine(); // for the "a=fmtp:" SDP line
  47. virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
  48. unsigned char* frameStart,
  49. unsigned numBytesInFrame,
  50. struct timeval framePresentationTime,
  51. unsigned numRemainingBytes);
  52. virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
  53. unsigned numBytesInFrame) const;
  54. virtual unsigned specialHeaderSize() const;
  55. virtual unsigned computeOverflowForNewFrame(unsigned newFrameSize) const;
  56. private:
  57. char* fFmtpSDPLine;
  58. char* fSampling;
  59. unsigned fWidth;
  60. unsigned fHeight;
  61. unsigned fDepth;
  62. char* fColorimetry;
  63. unsigned fLineindex;
  64. FrameParameters fFrameParameters;
  65. unsigned getNbLineInPacket(unsigned fragOffset, unsigned*& lengths, unsigned*& offsets) const;
  66. // return the number of lines, their lengths and offsets from the fragmentation offset of the whole frame.
  67. // call delete[] on lengths and offsets after use of the function
  68. void setFrameParameters();
  69. };
  70. #endif