2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_OPUSIDENTIFICATIONHEADER_H
|
|
|
|
#define TAG_PARSER_OPUSIDENTIFICATIONHEADER_H
|
2016-01-17 21:32:57 +01:00
|
|
|
|
2016-08-29 15:43:05 +02:00
|
|
|
#include "../global.h"
|
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
#include <cstdint>
|
2016-01-17 21:32:57 +01:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
namespace TagParser {
|
2016-01-17 21:32:57 +01:00
|
|
|
|
|
|
|
class OggIterator;
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT OpusIdentificationHeader {
|
2016-01-17 21:32:57 +01:00
|
|
|
public:
|
2018-07-10 14:11:11 +02:00
|
|
|
constexpr OpusIdentificationHeader();
|
2016-01-17 21:32:57 +01:00
|
|
|
|
|
|
|
void parseHeader(OggIterator &iterator);
|
|
|
|
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint8_t version() const;
|
|
|
|
constexpr std::uint8_t channels() const;
|
|
|
|
constexpr std::uint16_t preSkip() const;
|
|
|
|
constexpr std::uint32_t sampleRate() const;
|
|
|
|
constexpr std::uint16_t outputGain() const;
|
|
|
|
constexpr std::uint8_t channelMap() const;
|
2016-01-17 21:32:57 +01:00
|
|
|
|
|
|
|
private:
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint8_t m_version;
|
|
|
|
std::uint8_t m_channels;
|
|
|
|
std::uint16_t m_preSkip;
|
|
|
|
std::uint32_t m_sampleRate;
|
|
|
|
std::uint16_t m_outputGain;
|
|
|
|
std::uint8_t m_channelMap;
|
2016-01-17 21:32:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
2016-05-14 00:24:01 +02:00
|
|
|
* \brief Constructs a new Opus identification header.
|
2016-01-17 21:32:57 +01:00
|
|
|
*/
|
2018-07-10 14:11:11 +02:00
|
|
|
constexpr OpusIdentificationHeader::OpusIdentificationHeader()
|
2018-03-07 01:17:50 +01:00
|
|
|
: m_version(0)
|
|
|
|
, m_channels(0)
|
2018-07-10 14:11:11 +02:00
|
|
|
, m_preSkip(0)
|
2018-03-07 01:17:50 +01:00
|
|
|
, m_sampleRate(0)
|
|
|
|
, m_outputGain(0)
|
|
|
|
, m_channelMap(0)
|
|
|
|
{
|
|
|
|
}
|
2016-01-17 21:32:57 +01:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the version (which should be 1 currently).
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint8_t OpusIdentificationHeader::version() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_version;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the number of channels for the Opus stream.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint8_t OpusIdentificationHeader::channels() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_channels;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns "pre-skip" value for the Opus stream.
|
|
|
|
*
|
|
|
|
* This is the number of samples (at 48 kHz) to discard from the decoder
|
|
|
|
* output when starting playback, and also the number to subtract from a
|
|
|
|
* page's granule position to calculate its PCM sample position.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint16_t OpusIdentificationHeader::preSkip() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_preSkip;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the INPUT sample rate.
|
|
|
|
* \remarks This is not the sample rate to use for playback of the encoded data.
|
|
|
|
* \sa https://wiki.xiph.org/OggOpus
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t OpusIdentificationHeader::sampleRate() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_sampleRate;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the output gain.
|
|
|
|
*
|
|
|
|
* This is a gain to be applied by the decoder. Virtually all players and media frameworks
|
|
|
|
* should apply it by default.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint16_t OpusIdentificationHeader::outputGain() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_outputGain;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Returns the channel mapping family.
|
|
|
|
*
|
|
|
|
* The channel mapping family indicates the order and semantic meaning of the various channels
|
|
|
|
* encoded in each Opus packet.
|
|
|
|
* \sa https://wiki.xiph.org/OggOpus
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint8_t OpusIdentificationHeader::channelMap() const
|
2016-01-17 21:32:57 +01:00
|
|
|
{
|
|
|
|
return m_channelMap;
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2016-01-17 21:32:57 +01:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_OPUSIDENTIFICATIONHEADER_H
|