Welcome to mirror list, hosted at ThFree Co, Russian Federation.

FileManager.h « file « include « audaspace « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 03943ea8ae053c9197954cd9d4c29b8d2a09c59f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/*******************************************************************************
 * Copyright 2009-2016 Jörg Müller
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

#pragma once

/**
 * @file FileManager.h
 * @ingroup file
 * The FileManager class.
 */

#include "respec/Specification.h"
#include "IWriter.h"

#include <list>
#include <memory>

AUD_NAMESPACE_BEGIN

class IFileInput;
class IFileOutput;
class IReader;
class Buffer;

/**
 * The FileManager manages all file input and output plugins.
 */
class AUD_API FileManager
{
private:
	static std::list<std::shared_ptr<IFileInput>>& inputs();
	static std::list<std::shared_ptr<IFileOutput>>& outputs();

	// delete copy constructor and operator=
	FileManager(const FileManager&) = delete;
	FileManager& operator=(const FileManager&) = delete;
	FileManager() = delete;

public:
	/**
	 * Registers a file input used to create an IReader to read from a file.
	 * @param input The IFileInput to register.
	 */
	static void registerInput(std::shared_ptr<IFileInput> input);

	/**
	 * Registers a file output used to create an IWriter to write to a file.
	 * @param output The IFileOutput to register.
	 */
	static void registerOutput(std::shared_ptr<IFileOutput> output);

	/**
	 * Creates a file reader for the given filename if a registed IFileInput is able to read it.
	 * @param filename The path to the file.
	 * @return The reader created.
	 * @exception Exception If no file input can read the file an exception is thrown.
	 */
	static std::shared_ptr<IReader> createReader(std::string filename);

	/**
	 * Creates a file reader for the given buffer if a registed IFileInput is able to read it.
	 * @param buffer The buffer to read the file from.
	 * @return The reader created.
	 * @exception Exception If no file input can read the file an exception is thrown.
	 */
	static std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer);

	/**
	 * Creates a file writer that writes a sound to the given file path.
	 * Existing files will be overwritten.
	 * @param filename The file path to write to.
	 * @param specs The output specification.
	 * @param format The container format for the file.
	 * @param codec The codec used inside the container.
	 * @param bitrate The bitrate to write with.
	 * @return A writer that creates the file.
	 * @exception Exception If no file output can write the file with the given specification an exception is thrown.
	 */
	static std::shared_ptr<IWriter> createWriter(std::string filename, DeviceSpecs specs, Container format, Codec codec, unsigned int bitrate);
};

AUD_NAMESPACE_END