VorbisAudioRTPSink.hh 3.7 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 Vorbis audio
  17. // C++ header
  18. #ifndef _VORBIS_AUDIO_RTP_SINK_HH
  19. #define _VORBIS_AUDIO_RTP_SINK_HH
  20. #ifndef _AUDIO_RTP_SINK_HH
  21. #include "AudioRTPSink.hh"
  22. #endif
  23. class VorbisAudioRTPSink: public AudioRTPSink {
  24. public:
  25. static VorbisAudioRTPSink*
  26. createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat,
  27. u_int32_t rtpTimestampFrequency, unsigned numChannels,
  28. // The following headers provide the 'configuration' information, for the SDP description:
  29. u_int8_t* identificationHeader, unsigned identificationHeaderSize,
  30. u_int8_t* commentHeader, unsigned commentHeaderSize,
  31. u_int8_t* setupHeader, unsigned setupHeaderSize,
  32. u_int32_t identField = 0xFACADE);
  33. static VorbisAudioRTPSink*
  34. createNew(UsageEnvironment& env, Groupsock* RTPgs, u_int8_t rtpPayloadFormat,
  35. u_int32_t rtpTimestampFrequency, unsigned numChannels,
  36. char const* configStr);
  37. // an optional variant of "createNew()" that takes a Base-64-encoded 'configuration' string,
  38. // rather than the raw configuration headers as parameter.
  39. protected:
  40. VorbisAudioRTPSink(UsageEnvironment& env, Groupsock* RTPgs,
  41. u_int8_t rtpPayloadFormat, u_int32_t rtpTimestampFrequency, unsigned numChannels,
  42. u_int8_t* identificationHeader, unsigned identificationHeaderSize,
  43. u_int8_t* commentHeader, unsigned commentHeaderSize,
  44. u_int8_t* setupHeader, unsigned setupHeaderSize,
  45. u_int32_t identField);
  46. // called only by createNew()
  47. virtual ~VorbisAudioRTPSink();
  48. private: // redefined virtual functions:
  49. virtual char const* auxSDPLine(); // for the "a=fmtp:" SDP line
  50. virtual void doSpecialFrameHandling(unsigned fragmentationOffset,
  51. unsigned char* frameStart,
  52. unsigned numBytesInFrame,
  53. struct timeval framePresentationTime,
  54. unsigned numRemainingBytes);
  55. virtual Boolean frameCanAppearAfterPacketStart(unsigned char const* frameStart,
  56. unsigned numBytesInFrame) const;
  57. virtual unsigned specialHeaderSize() const;
  58. virtual unsigned frameSpecificHeaderSize() const;
  59. private:
  60. u_int32_t fIdent; // "Ident" field used by this stream. (Only the low 24 bits of this are used.)
  61. char* fFmtpSDPLine;
  62. };
  63. // A general function used by both "VorbisAudioRTPSink" and "TheoraVideoRTPSink" to construct
  64. // a Base64-encoded 'config' string (for SDP) from "identification", "comment", "setup" headers.
  65. // (Note: The result string was heap-allocated, and the caller should delete[] it afterwards.)
  66. char* generateVorbisOrTheoraConfigStr(u_int8_t* identificationHeader, unsigned identificationHeaderSize,
  67. u_int8_t* commentHeader, unsigned commentHeaderSize,
  68. u_int8_t* setupHeader, unsigned setupHeaderSize,
  69. u_int32_t identField);
  70. #endif