SimpleRTPSink.hh 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 simple RTP sink that packs frames into each outgoing
  17. // packet, without any fragmentation or special headers.
  18. // C++ header
  19. #ifndef _SIMPLE_RTP_SINK_HH
  20. #define _SIMPLE_RTP_SINK_HH
  21. #ifndef _MULTI_FRAMED_RTP_SINK_HH
  22. #include "MultiFramedRTPSink.hh"
  23. #endif
  24. class SimpleRTPSink: public MultiFramedRTPSink {
  25. public:
  26. static SimpleRTPSink*
  27. createNew(UsageEnvironment& env, Groupsock* RTPgs,
  28. unsigned char rtpPayloadFormat,
  29. unsigned rtpTimestampFrequency,
  30. char const* sdpMediaTypeString,
  31. char const* rtpPayloadFormatName,
  32. unsigned numChannels = 1,
  33. Boolean allowMultipleFramesPerPacket = True,
  34. Boolean doNormalMBitRule = True);
  35. // "doNormalMBitRule" means: If the medium (i.e., "sdpMediaTypeString") is other than "audio", set the RTP "M" bit
  36. // on each outgoing packet iff it contains the last (or only) fragment of a frame.
  37. // Otherwise (i.e., if "doNormalMBitRule" is False, or the medium is "audio"), leave the "M" bit unset.
  38. void setMBitOnNextPacket() { fSetMBitOnNextPacket = True; } // hack for optionally setting the RTP 'M' bit from outside the class
  39. protected:
  40. SimpleRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
  41. unsigned char rtpPayloadFormat,
  42. unsigned rtpTimestampFrequency,
  43. char const* sdpMediaTypeString,
  44. char const* rtpPayloadFormatName,
  45. unsigned numChannels,
  46. Boolean allowMultipleFramesPerPacket,
  47. Boolean doNormalMBitRule);
  48. // called only by createNew()
  49. virtual ~SimpleRTPSink();
  50. protected: // redefined virtual functions
  51. virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
  52. unsigned char* frameStart,
  53. unsigned numBytesInFrame,
  54. struct timeval framePresentationTime,
  55. unsigned numRemainingBytes);
  56. virtual
  57. Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
  58. unsigned numBytesInFrame) const;
  59. virtual char const* sdpMediaType() const;
  60. private:
  61. char const* fSDPMediaTypeString;
  62. Boolean fAllowMultipleFramesPerPacket;
  63. Boolean fSetMBitOnLastFrames, fSetMBitOnNextPacket;
  64. };
  65. #endif