MPEG4LATMAudioRTPSource.hh 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. // MPEG-4 audio, using LATM multiplexing
  17. // C++ header
  18. #ifndef _MPEG4_LATM_AUDIO_RTP_SOURCE_HH
  19. #define _MPEG4_LATM_AUDIO_RTP_SOURCE_HH
  20. #ifndef _MULTI_FRAMED_RTP_SOURCE_HH
  21. #include "MultiFramedRTPSource.hh"
  22. #endif
  23. class MPEG4LATMAudioRTPSource: public MultiFramedRTPSource {
  24. public:
  25. static MPEG4LATMAudioRTPSource*
  26. createNew(UsageEnvironment& env, Groupsock* RTPgs,
  27. unsigned char rtpPayloadFormat,
  28. unsigned rtpTimestampFrequency);
  29. // By default, the LATM data length field is included at the beginning of each
  30. // returned frame. To omit this field, call the following:
  31. void omitLATMDataLengthField();
  32. Boolean returnedFrameIncludesLATMDataLengthField() const { return fIncludeLATMDataLengthField; }
  33. protected:
  34. virtual ~MPEG4LATMAudioRTPSource();
  35. private:
  36. MPEG4LATMAudioRTPSource(UsageEnvironment& env, Groupsock* RTPgs,
  37. unsigned char rtpPayloadFormat,
  38. unsigned rtpTimestampFrequency);
  39. // called only by createNew()
  40. private:
  41. // redefined virtual functions:
  42. virtual Boolean processSpecialHeader(BufferedPacket* packet,
  43. unsigned& resultSpecialHeaderSize);
  44. virtual char const* MIMEtype() const;
  45. private:
  46. Boolean fIncludeLATMDataLengthField;
  47. };
  48. // A utility for parsing a "StreamMuxConfig" string
  49. Boolean
  50. parseStreamMuxConfigStr(char const* configStr,
  51. // result parameters:
  52. Boolean& audioMuxVersion,
  53. Boolean& allStreamsSameTimeFraming,
  54. unsigned char& numSubFrames,
  55. unsigned char& numProgram,
  56. unsigned char& numLayer,
  57. unsigned char*& audioSpecificConfig,
  58. unsigned& audioSpecificConfigSize);
  59. // Parses "configStr" as a sequence of hexadecimal digits, representing
  60. // a "StreamMuxConfig" (as defined in ISO.IEC 14496-3, table 1.21).
  61. // Returns, in "audioSpecificConfig", a binary representation of
  62. // the enclosed "AudioSpecificConfig" structure (of size
  63. // "audioSpecificConfigSize" bytes). The memory for this is allocated
  64. // dynamically by this function; the caller is responsible for
  65. // freeing it. Other values, that precede "AudioSpecificConfig",
  66. // are returned in the other parameters.
  67. // Returns True iff the parsing succeeds.
  68. // IMPORTANT NOTE: The implementation of this function currently assumes
  69. // that everything after the first "numLayer" field is an
  70. // "AudioSpecificConfig". Therefore, it will not work properly if
  71. // "audioMuxVersion" != 0, "numProgram" > 0, or "numLayer" > 0.
  72. // Also, any 'other data' or CRC info will be included at
  73. // the end of "audioSpecificConfig".
  74. unsigned char* parseStreamMuxConfigStr(char const* configStr,
  75. // result parameter:
  76. unsigned& audioSpecificConfigSize);
  77. // A variant of the above that returns just the "AudioSpecificConfig" data
  78. // (or NULL) if the parsing failed, without bothering with the other
  79. // result parameters.
  80. unsigned char* parseGeneralConfigStr(char const* configStr,
  81. // result parameter:
  82. unsigned& configSize);
  83. // A routine that parses an arbitrary config string, returning
  84. // the result in binary form.
  85. #endif