resample_pcm.h 705 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef RESAMPLE_PCM
  2. #define RESAMPLE_PCM
  3. #include <stdint.h>
  4. #include "headers_ffmpeg.h"
  5. namespace am {
  6. typedef struct
  7. {
  8. int nb_samples;
  9. int64_t channel_layout;
  10. int nb_channels;
  11. AVSampleFormat fmt;
  12. int sample_rate;
  13. } SAMPLE_SETTING;
  14. class resample_pcm
  15. {
  16. public:
  17. resample_pcm();
  18. ~resample_pcm();
  19. int init(const SAMPLE_SETTING *sample_src,
  20. const SAMPLE_SETTING *sample_dst,
  21. __out int *resapmled_frame_size);
  22. int convert(const uint8_t *src, int src_len, uint8_t *dst, int dst_len);
  23. protected:
  24. void cleanup();
  25. private:
  26. SwrContext *_ctx;
  27. SAMPLE_SETTING *_sample_src;
  28. SAMPLE_SETTING *_sample_dst;
  29. };
  30. } // namespace am
  31. #endif