audio-converter.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /* GStreamer
  2. * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net>
  3. * (C) 2015 Wim Taymans <wim.taymans@gmail.com>
  4. *
  5. * audioconverter.h: audio format conversion library
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Library General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Library General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Library General Public
  18. * License along with this library; if not, write to the
  19. * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
  20. * Boston, MA 02110-1301, USA.
  21. */
  22. #ifndef __GST_AUDIO_CONVERTER_H__
  23. #define __GST_AUDIO_CONVERTER_H__
  24. #include <gst/gst.h>
  25. #include <gst/audio/audio.h>
  26. typedef struct _GstAudioConverter GstAudioConverter;
  27. /**
  28. * GST_AUDIO_CONVERTER_OPT_DITHER_METHOD:
  29. *
  30. * #GST_TYPE_AUDIO_DITHER_METHOD, The dither method to use when
  31. * changing bit depth.
  32. * Default is #GST_AUDIO_DITHER_NONE.
  33. */
  34. #define GST_AUDIO_CONVERTER_OPT_DITHER_METHOD "GstAudioConverter.dither-method"
  35. /**
  36. * GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD:
  37. *
  38. * #GST_TYPE_AUDIO_NOISE_SHAPING_METHOD, The noise shaping method to use
  39. * to mask noise from quantization errors.
  40. * Default is #GST_AUDIO_NOISE_SHAPING_NONE.
  41. */
  42. #define GST_AUDIO_CONVERTER_OPT_NOISE_SHAPING_METHOD "GstAudioConverter.noise-shaping-method"
  43. /**
  44. * GST_AUDIO_CONVERTER_OPT_QUANTIZATION:
  45. *
  46. * #G_TYPE_UINT, The quantization amount. Components will be
  47. * quantized to multiples of this value.
  48. * Default is 1
  49. */
  50. #define GST_AUDIO_CONVERTER_OPT_QUANTIZATION "GstAudioConverter.quantization"
  51. /**
  52. * GstAudioConverterFlags:
  53. * @GST_AUDIO_CONVERTER_FLAG_NONE: no flag
  54. * @GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE: the input sample arrays are writable and can be
  55. * used as temporary storage during conversion.
  56. * @GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE: allow arbitrary rate updates with
  57. * gst_audio_converter_update_config().
  58. *
  59. * Extra flags passed to gst_audio_converter_new() and gst_audio_converter_samples().
  60. */
  61. typedef enum {
  62. GST_AUDIO_CONVERTER_FLAG_NONE = 0,
  63. GST_AUDIO_CONVERTER_FLAG_IN_WRITABLE = (1 << 0),
  64. GST_AUDIO_CONVERTER_FLAG_VARIABLE_RATE = (1 << 1)
  65. } GstAudioConverterFlags;
  66. GstAudioConverter * gst_audio_converter_new (GstAudioConverterFlags flags,
  67. GstAudioInfo *in_info,
  68. GstAudioInfo *out_info,
  69. GstStructure *config);
  70. void gst_audio_converter_free (GstAudioConverter * convert);
  71. void gst_audio_converter_reset (GstAudioConverter * convert);
  72. gboolean gst_audio_converter_update_config (GstAudioConverter * convert,
  73. gint in_rate, gint out_rate,
  74. GstStructure *config);
  75. const GstStructure * gst_audio_converter_get_config (GstAudioConverter * convert,
  76. gint *in_rate, gint *out_rate);
  77. gsize gst_audio_converter_get_out_frames (GstAudioConverter *convert,
  78. gsize in_frames);
  79. gsize gst_audio_converter_get_in_frames (GstAudioConverter *convert,
  80. gsize out_frames);
  81. gsize gst_audio_converter_get_max_latency (GstAudioConverter *convert);
  82. gboolean gst_audio_converter_samples (GstAudioConverter * convert,
  83. GstAudioConverterFlags flags,
  84. gpointer in[], gsize in_frames,
  85. gpointer out[], gsize out_frames);
  86. #endif /* __GST_AUDIO_CONVERTER_H__ */