FileWriter.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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 FileWriter.h
  19. * @ingroup file
  20. * The FileWriter class.
  21. */
  22. #include "respec/Specification.h"
  23. #include "file/IWriter.h"
  24. #include <string>
  25. #include <vector>
  26. #include <memory>
  27. AUD_NAMESPACE_BEGIN
  28. class IReader;
  29. /**
  30. * The FileWriter class is able to create IWriter classes as well as write readers to them.
  31. */
  32. class AUD_API FileWriter
  33. {
  34. private:
  35. // hide default constructor, copy constructor and operator=
  36. FileWriter() = delete;
  37. FileWriter(const FileWriter&) = delete;
  38. FileWriter& operator=(const FileWriter&) = delete;
  39. public:
  40. /**
  41. * Creates a new IWriter.
  42. * \param filename The file to write to.
  43. * \param specs The file's audio specification.
  44. * \param format The file's container format.
  45. * \param codec The codec used for encoding the audio data.
  46. * \param bitrate The bitrate for encoding.
  47. * \return The writer to write data to.
  48. */
  49. static std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
  50. /**
  51. * Writes a reader to a writer.
  52. * \param reader The reader to read from.
  53. * \param writer The writer to write to.
  54. * \param length How many samples should be transferred.
  55. * \param buffersize How many samples should be transferred at once.
  56. */
  57. static void writeReader(std::shared_ptr<IReader> reader, std::shared_ptr<IWriter> writer, unsigned int length, unsigned int buffersize);
  58. /**
  59. * Writes a reader to several writers.
  60. * \param reader The reader to read from.
  61. * \param writers The writers to write to.
  62. * \param length How many samples should be transferred.
  63. * \param buffersize How many samples should be transferred at once.
  64. */
  65. static void writeReader(std::shared_ptr<IReader> reader, std::vector<std::shared_ptr<IWriter> >& writers, unsigned int length, unsigned int buffersize);
  66. };
  67. AUD_NAMESPACE_END