FLVAACDecoder.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #pragma once
  2. #include "../in_flv/svc_flvdecoder.h"
  3. #include "../in_flv/FLVAudioHeader.h"
  4. #include "../in_flv/ifc_flvaudiodecoder.h"
  5. #include "incs/mp4AudioDecIfc.h"
  6. // {7FD8F2D0-7490-45fd-B741-BF3F9EEF0BE4}
  7. static const GUID flv_aac_guid =
  8. { 0x7fd8f2d0, 0x7490, 0x45fd, { 0xb7, 0x41, 0xbf, 0x3f, 0x9e, 0xef, 0xb, 0xe4 } };
  9. class FLVDecoder : public svc_flvdecoder
  10. {
  11. public:
  12. static const char *getServiceName() { return "AAC FLV Decoder"; }
  13. static GUID getServiceGuid() { return flv_aac_guid; }
  14. int CreateAudioDecoder(int stereo, int bits, int sample_rate, int format, ifc_flvaudiodecoder **decoder);
  15. int HandlesAudio(int format_type);
  16. protected:
  17. RECVS_DISPATCH;
  18. };
  19. class FLVAAC : public ifc_flvaudiodecoder
  20. {
  21. public:
  22. FLVAAC(CAccessUnitPtr access_unit);
  23. int GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits);
  24. int DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate);
  25. void Flush();
  26. void Close();
  27. int Ready();
  28. void SetPreferences(unsigned int max_channels, unsigned int preferred_bits);
  29. private:
  30. /* data */
  31. mp4AudioDecoderHandle decoder;
  32. CCompositionUnitPtr composition_unit; /* output */
  33. CAccessUnitPtr access_unit; /* input */
  34. unsigned int bps;
  35. size_t preDelay;
  36. bool got_decoder_config;
  37. protected:
  38. RECVS_DISPATCH;
  39. };