IWriter.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*******************************************************************************
  2. * Copyright 2009-2016 Jörg Müller
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. ******************************************************************************/
  16. #pragma once
  17. /**
  18. * @file IWriter.h
  19. * @ingroup file
  20. * Defines the IWriter interface as well as Container and Codec types.
  21. */
  22. #include "respec/Specification.h"
  23. AUD_NAMESPACE_BEGIN
  24. /// Container formats for writers.
  25. enum Container
  26. {
  27. CONTAINER_INVALID = 0,
  28. CONTAINER_AC3,
  29. CONTAINER_FLAC,
  30. CONTAINER_MATROSKA,
  31. CONTAINER_MP2,
  32. CONTAINER_MP3,
  33. CONTAINER_OGG,
  34. CONTAINER_WAV
  35. };
  36. /// Audio codecs for writers.
  37. enum Codec
  38. {
  39. CODEC_INVALID = 0,
  40. CODEC_AAC,
  41. CODEC_AC3,
  42. CODEC_FLAC,
  43. CODEC_MP2,
  44. CODEC_MP3,
  45. CODEC_PCM,
  46. CODEC_VORBIS,
  47. CODEC_OPUS
  48. };
  49. /**
  50. * @interface IWriter
  51. * This class represents a sound sink where audio data can be written to.
  52. */
  53. class AUD_API IWriter
  54. {
  55. public:
  56. /**
  57. * Destroys the writer.
  58. */
  59. virtual ~IWriter() {}
  60. /**
  61. * Returns how many samples have been written so far.
  62. * \return The writing position as sample count. May be negative if unknown.
  63. */
  64. virtual int getPosition() const=0;
  65. /**
  66. * Returns the specification of the audio data being written into the sink.
  67. * \return The DeviceSpecs structure.
  68. * \note Regardless of the format the input still has to be float!
  69. */
  70. virtual DeviceSpecs getSpecs() const=0;
  71. /**
  72. * Request to write the next length samples out into the sink.
  73. * \param length The count of samples to write.
  74. * \param buffer The pointer to the buffer containing the data.
  75. */
  76. virtual void write(unsigned int length, sample_t* buffer)=0;
  77. };
  78. AUD_NAMESPACE_END