ADTSAudioStreamDiscreteFramer.hh 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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-2020 Live Networks, Inc. All rights reserved.
  16. // A filter that reads (discrete) AAC audio frames, and outputs each frame with
  17. // a preceding ADTS header.
  18. // C++ header
  19. #ifndef _ADTS_AUDIO_STREAM_DISCRETE_FRAMER_HH
  20. #define _ADTS_AUDIO_STREAM_DISCRETE_FRAMER_HH
  21. #ifndef _FRAMED_FILTER_HH
  22. #include "FramedFilter.hh"
  23. #endif
  24. #define ADTS_HEADER_SIZE 7 // we don't include a checksum
  25. class ADTSAudioStreamDiscreteFramer: public FramedFilter {
  26. public:
  27. static ADTSAudioStreamDiscreteFramer*
  28. createNew(UsageEnvironment& env, FramedSource* inputSource, char const* configStr);
  29. // "configStr" should be a 4-character hexadecimal string for a 2-byte value
  30. protected:
  31. ADTSAudioStreamDiscreteFramer(UsageEnvironment& env, FramedSource* inputSource,
  32. u_int8_t profile, u_int8_t samplingFrequencyIndex, u_int8_t channelConfiguration);
  33. // called only by createNew()
  34. virtual ~ADTSAudioStreamDiscreteFramer();
  35. protected:
  36. // redefined virtual functions:
  37. virtual void doGetNextFrame();
  38. protected:
  39. static void afterGettingFrame(void* clientData, unsigned frameSize,
  40. unsigned numTruncatedBytes,
  41. struct timeval presentationTime,
  42. unsigned durationInMicroseconds);
  43. void afterGettingFrame1(unsigned frameSize,
  44. unsigned numTruncatedBytes,
  45. struct timeval presentationTime,
  46. unsigned durationInMicroseconds);
  47. private:
  48. u_int8_t fADTSHeader[ADTS_HEADER_SIZE];
  49. };
  50. #endif