2018-03-06 23:09:15 +01:00
|
|
|
#ifndef TAG_PARSER_WAVEAUDIOSTREAM_H
|
|
|
|
#define TAG_PARSER_WAVEAUDIOSTREAM_H
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../abstracttrack.h"
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
namespace TagParser {
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT WaveFormatHeader {
|
2015-06-12 02:35:50 +02:00
|
|
|
public:
|
2018-07-10 14:11:11 +02:00
|
|
|
constexpr WaveFormatHeader();
|
2015-06-12 02:35:50 +02:00
|
|
|
|
2019-06-16 18:06:31 +02:00
|
|
|
std::uint64_t parse(CppUtilities::BinaryReader &reader, std::uint64_t maxSize, Diagnostics &diag);
|
2015-06-12 02:35:50 +02:00
|
|
|
MediaFormat format() const;
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t bitrate() const;
|
2015-06-12 02:35:50 +02:00
|
|
|
|
2019-06-16 18:06:31 +02:00
|
|
|
std::uint64_t guid1;
|
|
|
|
std::uint64_t guid2;
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint16_t formatTag;
|
|
|
|
std::uint16_t channelCount;
|
2019-06-16 18:06:31 +02:00
|
|
|
std::uint32_t sampleRate;
|
|
|
|
std::uint32_t bytesPerSecond;
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint16_t chunkSize;
|
|
|
|
std::uint16_t bitsPerSample;
|
2019-06-16 18:06:31 +02:00
|
|
|
std::uint32_t channelMask;
|
2015-06-12 02:35:50 +02:00
|
|
|
};
|
|
|
|
|
2018-07-10 14:11:11 +02:00
|
|
|
/*!
|
|
|
|
* \brief Constructs a new WaveFormatHeader.
|
|
|
|
*/
|
|
|
|
constexpr WaveFormatHeader::WaveFormatHeader()
|
2019-06-16 18:06:31 +02:00
|
|
|
: guid1(0)
|
|
|
|
, guid2(0)
|
|
|
|
, formatTag(0)
|
2018-07-10 14:11:11 +02:00
|
|
|
, channelCount(0)
|
|
|
|
, sampleRate(0)
|
|
|
|
, bytesPerSecond(0)
|
|
|
|
, chunkSize(0)
|
|
|
|
, bitsPerSample(0)
|
2019-06-16 18:06:31 +02:00
|
|
|
, channelMask(0)
|
2018-07-10 14:11:11 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-06-12 02:35:50 +02:00
|
|
|
/*!
|
|
|
|
* \brief Calculates the bitrate from the header data.
|
|
|
|
*/
|
2019-03-13 19:06:42 +01:00
|
|
|
constexpr std::uint32_t WaveFormatHeader::bitrate() const
|
2015-06-12 02:35:50 +02:00
|
|
|
{
|
|
|
|
return bitsPerSample * sampleRate * channelCount;
|
|
|
|
}
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
class TAG_PARSER_EXPORT WaveAudioStream : public AbstractTrack {
|
2015-04-22 19:22:01 +02:00
|
|
|
public:
|
2019-03-13 19:06:42 +01:00
|
|
|
WaveAudioStream(std::iostream &stream, std::uint64_t startOffset);
|
2018-03-05 17:49:29 +01:00
|
|
|
~WaveAudioStream() override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
TrackType type() const override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2015-06-12 02:35:50 +02:00
|
|
|
static void addInfo(const WaveFormatHeader &waveHeader, AbstractTrack &track);
|
|
|
|
|
2015-04-22 19:22:01 +02:00
|
|
|
protected:
|
2018-03-05 17:49:29 +01:00
|
|
|
void internalParseHeader(Diagnostics &diag) override;
|
2015-04-22 19:22:01 +02:00
|
|
|
|
|
|
|
private:
|
2019-03-13 19:06:42 +01:00
|
|
|
std::uint64_t m_dataOffset;
|
2015-04-22 19:22:01 +02:00
|
|
|
};
|
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
} // namespace TagParser
|
2015-04-22 19:22:01 +02:00
|
|
|
|
2018-03-06 23:09:15 +01:00
|
|
|
#endif // TAG_PARSER_WAVEAUDIOSTREAM_H
|