AudioResampler.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango.org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. /**@file AudioResampler.h
  23. * @brief Audio resampler
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango.org>
  26. */
  27. #ifndef TINYWRAP_AUDIO_RESAMPLER_H
  28. #define TINYWRAP_AUDIO_RESAMPLER_H
  29. #include "tinyWRAP_config.h"
  30. #include "tsk_common.h"
  31. class AudioResampler
  32. {
  33. public:
  34. AudioResampler(uint32_t nInFreq, uint32_t nOutFreq, uint32_t nFrameDuration, uint32_t nChannels, uint32_t nQuality);
  35. ~AudioResampler();
  36. public:
  37. inline bool isValid() {
  38. return (m_pWrappedResampler != tsk_null);
  39. }
  40. inline uint32_t getOutputRequiredSizeInShort() {
  41. return (m_nOutFreq * m_nFrameDuration)/1000;
  42. }
  43. inline uint32_t getInputRequiredSizeInShort() {
  44. return (m_nInFreq * m_nFrameDuration)/1000;
  45. }
  46. uint32_t process(const void* pInData, uint32_t nInSizeInBytes, void* pOutData, uint32_t nOutSizeInBytes);
  47. private:
  48. struct tmedia_resampler_s* m_pWrappedResampler;
  49. uint32_t m_nOutFreq;
  50. uint32_t m_nInFreq;
  51. uint32_t m_nFrameDuration;
  52. uint32_t m_nChannels;
  53. uint32_t m_nQuality;
  54. };
  55. #endif /* TINYWRAP_AUDIO_RESAMPLER_H */