tmedia_resampler.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /*
  2. * Copyright (C) 2010-2011 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]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 tmedia_resampler.h
  23. * @brief Audio Resampler Plugin
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. */
  27. #ifndef TINYMEDIA_RESAMPLER_H
  28. #define TINYMEDIA_RESAMPLER_H
  29. #include "tinymedia_config.h"
  30. #include "tsk_object.h"
  31. #ifndef TMEDIA_RESAMPLER_QUALITY
  32. # define TMEDIA_RESAMPLER_QUALITY 5
  33. #endif
  34. TMEDIA_BEGIN_DECLS
  35. /** cast any pointer to @ref tmedia_resampler_t* object */
  36. #define TMEDIA_RESAMPLER(self) ((tmedia_resampler_t*)(self))
  37. /** Base object for all resamplers */
  38. typedef struct tmedia_resampler_s {
  39. TSK_DECLARE_OBJECT;
  40. tsk_bool_t opened;
  41. const struct tmedia_resampler_plugin_def_s* plugin;
  42. }
  43. tmedia_resampler_t;
  44. #define TMEDIA_DECLARE_RESAMPLER tmedia_resampler_t __resampler__
  45. /** Virtual table used to define a consumer plugin */
  46. typedef struct tmedia_resampler_plugin_def_s {
  47. //! object definition used to create an instance of the resamplerr
  48. const tsk_object_def_t* objdef;
  49. //! full description (usefull for debugging)
  50. const char* desc;
  51. // ! quality is from 0-10
  52. int (* open) (tmedia_resampler_t* self, uint32_t in_freq, uint32_t out_freq, uint32_t frame_duration, uint32_t in_channels, uint32_t out_channels, uint32_t quality, uint32_t bits_per_sample);
  53. tsk_size_t (* process) (tmedia_resampler_t*, const void* in_data, tsk_size_t in_size_in_sample, void* out_data, tsk_size_t out_size_in_sample);
  54. int (* close) (tmedia_resampler_t* );
  55. }
  56. tmedia_resampler_plugin_def_t;
  57. TINYMEDIA_API int tmedia_resampler_init(tmedia_resampler_t* self);
  58. TINYMEDIA_API int tmedia_resampler_open(tmedia_resampler_t* self, uint32_t in_freq, uint32_t out_freq, uint32_t frame_duration, uint32_t in_channels, uint32_t out_channels, uint32_t quality, uint32_t bits_per_sample);
  59. TINYMEDIA_API tsk_size_t tmedia_resampler_process(tmedia_resampler_t* self, const void* in_data, tsk_size_t in_size_in_sample, void* out_data, tsk_size_t out_size_in_sample);
  60. TINYMEDIA_API int tmedia_resampler_close(tmedia_resampler_t* self);
  61. TINYMEDIA_API int tmedia_resampler_deinit(tmedia_resampler_t* self);
  62. TINYMEDIA_API int tmedia_resampler_plugin_register(const tmedia_resampler_plugin_def_t* plugin);
  63. TINYMEDIA_API int tmedia_resampler_plugin_unregister(const tmedia_resampler_plugin_def_t* plugin);
  64. TINYMEDIA_API tmedia_resampler_t* tmedia_resampler_create();
  65. TMEDIA_END_DECLS
  66. #endif /* TINYMEDIA_RESAMPLER_H */