1
0

flv_mp3_decoder.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #pragma once
  2. #include "../Plugins/Input/in_flv/svc_flvdecoder.h"
  3. #include "../Plugins/Input/in_flv/FLVAudioHeader.h"
  4. #include "../Plugins/Input/in_flv/ifc_flvaudiodecoder.h"
  5. #include <mpg123.h>
  6. // {5CAED3F6-ED5F-4801-921E-9BF86A483016}
  7. static const GUID flv_mp3_guid =
  8. { 0x5caed3f6, 0xed5f, 0x4801, { 0x92, 0x1e, 0x9b, 0xf8, 0x6a, 0x48, 0x30, 0x16 } };
  9. class FLVDecoderCreator : public svc_flvdecoder
  10. {
  11. public:
  12. static const char *getServiceName() { return "MP3 FLV Decoder"; }
  13. static GUID getServiceGuid() { return flv_mp3_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 FLVMP3 : public ifc_flvaudiodecoder
  20. {
  21. public:
  22. FLVMP3(mpg123_handle *mp3);
  23. ~FLVMP3();
  24. int GetOutputFormat(unsigned int *sample_rate, unsigned int *channels, unsigned int *bits);
  25. int DecodeSample(const void *input_buffer, size_t input_buffer_bytes, void *samples, size_t *samples_size_bytes, double *bitrate);
  26. void Flush();
  27. void Close();
  28. void SetPreferences(unsigned int max_channels, unsigned int preferred_bits);
  29. private:
  30. mpg123_handle *mp3;
  31. unsigned int bits;
  32. int pregap;
  33. unsigned int max_channels;
  34. unsigned int channels;
  35. float *decode_buffer;
  36. size_t decode_buffer_length;
  37. protected:
  38. RECVS_DISPATCH;
  39. };