resample_pcm.h 641 B

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