Codec¶
Audio file reader and writer.
Detailed Description¶
The Codec class is used to implement an audio file reader and writer. This is the base class for all audio codecs, each implementation should allow building decoders and encoders.
The Codec class follows the plugin architecture, and thus, you are able to create your own codecs and register them to the Engine by inheriting from this class and by implementing the necessary dependencies.
Classes¶
| Type | Name |
|---|---|
| class | Decoder Audio file reader. |
| class | Encoder Audio file writer. |
Public Functions¶
| Type | Name |
|---|---|
| virtual bool | CanHandleFile (std::shared_ptr< File > file) const = 0 Checks whether this codec can handle the file at the given path. |
| Codec (AmString name) Create a new codec instance. | |
| virtual std::shared_ptr< Decoder > | CreateDecoder () = 0 Creates a new instance of the decoder associated with this codec. |
| virtual std::shared_ptr< Encoder > | CreateEncoder () = 0 Creates a new instance of the encoder associated with this codec. |
| const AmString & | GetName () const Gets the name of this codec. |
| virtual | ~Codec () Default destructor. |
Public Static Functions¶
| Type | Name |
|---|---|
| std::shared_ptr< Codec > | Find (const AmString & name) Look up a codec by name. |
| std::shared_ptr< Codec > | FindForFile (std::shared_ptr< File > file) Finds the codec which can handle the given file. |
| const std::map< AmString, std::shared_ptr< Codec > > & | GetRegistry () Gets the list of registered codecs. |
| void | LockRegistry () Locks the codecs' registry. |
| void | Register (std::shared_ptr< Codec > codec) Registers a new audio codec. |
| void | UnlockRegistry () Unlocks the codecs' registry. |
| void | Unregister (std::shared_ptr< const Codec > codec) Unregisters a audio codec. |
Protected Attributes¶
| Type | Name |
|---|---|
| AmString | m_name The name of this codec. |
Public Functions Documentation¶
CanHandleFile
Checks whether this codec can handle the file at the given path.
Parameters:
-
fileThe file to check.
Returns:
true if the codec can handle the file, false otherwise.
Codec
Create a new codec instance.
Parameters:
nameThe codec name. Recommended names are "FILE_EXTENSION", e.g., "WAV" or "OGG".
CreateDecoder
Creates a new instance of the decoder associated with this codec.
Returns:
A Decoder instance.
CreateEncoder
Creates a new instance of the encoder associated with this codec.
Returns:
An Encoder instance.
GetName
Gets the name of this codec.
Returns:
The name of this codec.
Public Static Functions Documentation¶
Find
Look up a codec by name.
Parameters:
-
nameThe name of the codec to find.
Returns:
The codec with the given name, or nullptr if not found.
FindForFile
Finds the codec which can handle the given file.
Parameters:
-
fileThe file to find the codec for.
Returns:
The codec which can handle the given file, or nullptr if not found.
GetRegistry
Gets the list of registered codecs.
Returns:
The registry of codecs.
LockRegistry
Locks the codecs' registry.
Warning:
This function is mainly used for internal purposes. It's called before the Engine initialization, to discard the registration of new codecs after the engine is fully loaded.
Register
Registers a new audio codec.
Note:
This method does nothing if the registry is locked.
Parameters:
-
codecThe audio codec to add in the registry.
See also: LockRegistry, UnlockRegistry
UnlockRegistry
Unlocks the codecs' registry.
Warning:
This function is mainly used for internal purposes. It's called after the Engine deinitialization, to allow the registration of new codecs after the engine is fully unloaded.
Unregister
Unregisters a audio codec.
Note:
This method does nothing if the registry is locked.
Parameters:
-
codecThe audio codec to remove from the registry.
See also: LockRegistry, UnlockRegistry
Protected Attributes Documentation¶
The documentation for this class was generated from the following file: include/SparkyStudios/Audio/Amplitude/Core/Codec.h