diff options
Diffstat (limited to 'extern/audaspace/include/file')
-rw-r--r-- | extern/audaspace/include/file/File.h | 23 | ||||
-rw-r--r-- | extern/audaspace/include/file/FileInfo.h | 42 | ||||
-rw-r--r-- | extern/audaspace/include/file/FileManager.h | 24 | ||||
-rw-r--r-- | extern/audaspace/include/file/IFileInput.h | 24 |
4 files changed, 107 insertions, 6 deletions
diff --git a/extern/audaspace/include/file/File.h b/extern/audaspace/include/file/File.h index 24745a757e8..ac490acba38 100644 --- a/extern/audaspace/include/file/File.h +++ b/extern/audaspace/include/file/File.h @@ -23,9 +23,11 @@ */ #include "ISound.h" +#include "FileInfo.h" #include <string> #include <memory> +#include <vector> AUD_NAMESPACE_BEGIN @@ -48,6 +50,14 @@ private: */ std::shared_ptr<Buffer> m_buffer; + /** + * The index of the stream within the file if it contains multiple. + * The first audio stream in the file has index 0 and the index increments by one + * for every other audio stream in the file. Other types of streams in the file + * do not count. + */ + int m_stream; + // delete copy constructor and operator= File(const File&) = delete; File& operator=(const File&) = delete; @@ -57,16 +67,25 @@ public: * Creates a new sound. * The file is read from the file system using the given path. * \param filename The sound file path. + * \param stream The index of the audio stream within the file if it contains multiple audio streams. */ - File(std::string filename); + File(std::string filename, int stream = 0); /** * Creates a new sound. * The file is read from memory using the supplied buffer. * \param buffer The buffer to read from. * \param size The size of the buffer. + * \param stream The index of the audio stream within the file if it contains multiple audio streams. + */ + File(const data_t* buffer, int size, int stream = 0); + + /** + * Queries the streams of the file. + * \return A vector with as many streams as there are in the file. + * \exception Exception Thrown if the file specified cannot be read. */ - File(const data_t* buffer, int size); + std::vector<StreamInfo> queryStreams(); virtual std::shared_ptr<IReader> createReader(); }; diff --git a/extern/audaspace/include/file/FileInfo.h b/extern/audaspace/include/file/FileInfo.h new file mode 100644 index 00000000000..53ba99a5f67 --- /dev/null +++ b/extern/audaspace/include/file/FileInfo.h @@ -0,0 +1,42 @@ +/******************************************************************************* + * 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 FileInfo.h + * @ingroup file + * The FileInfo data structures. + */ + +#include "respec/Specification.h" + +AUD_NAMESPACE_BEGIN + +/// Specification of a sound source. +struct StreamInfo +{ + /// Start time in seconds. + double start; + + /// Duration in seconds. May be estimated or 0 if unknown. + double duration; + + /// Audio data parameters. + DeviceSpecs specs; +}; + +AUD_NAMESPACE_END diff --git a/extern/audaspace/include/file/FileManager.h b/extern/audaspace/include/file/FileManager.h index 56708607ea6..e19eef65b1c 100644 --- a/extern/audaspace/include/file/FileManager.h +++ b/extern/audaspace/include/file/FileManager.h @@ -22,12 +22,14 @@ * The FileManager class. */ +#include "FileInfo.h" #include "respec/Specification.h" #include "IWriter.h" #include <list> #include <memory> #include <string> +#include <vector> AUD_NAMESPACE_BEGIN @@ -66,18 +68,36 @@ public: /** * Creates a file reader for the given filename if a registed IFileInput is able to read it. * @param filename The path to the file. + * @param stream The index of the audio stream within the file if it contains multiple audio streams. * @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); + static std::shared_ptr<IReader> createReader(std::string filename, int stream = 0); /** * 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. + * @param stream The index of the audio stream within the file if it contains multiple audio streams. * @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); + static std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer, int stream = 0); + + /** + * Queries the streams of a sound file. + * \param filename Path to the file to be read. + * \return A vector with as many streams as there are in the file. + * \exception Exception Thrown if the file specified cannot be read. + */ + static std::vector<StreamInfo> queryStreams(std::string filename); + + /** + * Queries the streams of a sound file. + * \param buffer The in-memory file buffer. + * \return A vector with as many streams as there are in the file. + * \exception Exception Thrown if the file specified cannot be read. + */ + static std::vector<StreamInfo> queryStreams(std::shared_ptr<Buffer> buffer); /** * Creates a file writer that writes a sound to the given file path. diff --git a/extern/audaspace/include/file/IFileInput.h b/extern/audaspace/include/file/IFileInput.h index 64074910d13..4a3fe446852 100644 --- a/extern/audaspace/include/file/IFileInput.h +++ b/extern/audaspace/include/file/IFileInput.h @@ -23,9 +23,11 @@ */ #include "Audaspace.h" +#include "FileInfo.h" #include <memory> #include <string> +#include <vector> AUD_NAMESPACE_BEGIN @@ -48,18 +50,36 @@ public: /** * Creates a reader for a file to be read. * \param filename Path to the file to be read. + * \param stream The index of the audio stream within the file if it contains multiple audio streams. * \return The reader that reads the file. * \exception Exception Thrown if the file specified cannot be read. */ - virtual std::shared_ptr<IReader> createReader(std::string filename)=0; + virtual std::shared_ptr<IReader> createReader(std::string filename, int stream = 0)=0; /** * Creates a reader for a file to be read from memory. * \param buffer The in-memory file buffer. + * \param stream The index of the audio stream within the file if it contains multiple audio streams. * \return The reader that reads the file. * \exception Exception Thrown if the file specified cannot be read. */ - virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer)=0; + virtual std::shared_ptr<IReader> createReader(std::shared_ptr<Buffer> buffer, int stream = 0)=0; + + /** + * Queries the streams of a sound file. + * \param filename Path to the file to be read. + * \return A vector with as many streams as there are in the file. + * \exception Exception Thrown if the file specified cannot be read. + */ + virtual std::vector<StreamInfo> queryStreams(std::string filename)=0; + + /** + * Queries the streams of a sound file. + * \param buffer The in-memory file buffer. + * \return A vector with as many streams as there are in the file. + * \exception Exception Thrown if the file specified cannot be read. + */ + virtual std::vector<StreamInfo> queryStreams(std::shared_ptr<Buffer> buffer)=0; }; AUD_NAMESPACE_END |