tagparser/wav/waveaudiostream.h

65 lines
1.5 KiB
C
Raw Normal View History

#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-10 22:49:11 +02:00
void parse(CppUtilities::BinaryReader &reader);
std::pair<MediaFormat, std::uint64_t> parseExt(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-03-13 19:06:42 +01:00
std::uint16_t formatTag;
std::uint16_t channelCount;
std::uint16_t sampleRate;
std::uint16_t bytesPerSecond;
std::uint16_t chunkSize;
std::uint16_t bitsPerSample;
2015-06-12 02:35:50 +02:00
};
2018-07-10 14:11:11 +02:00
/*!
* \brief Constructs a new WaveFormatHeader.
*/
constexpr WaveFormatHeader::WaveFormatHeader()
: formatTag(0)
, channelCount(0)
, sampleRate(0)
, bytesPerSecond(0)
, chunkSize(0)
, bitsPerSample(0)
{
}
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);
~WaveAudioStream() override;
2015-04-22 19:22:01 +02: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:
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
#endif // TAG_PARSER_WAVEAUDIOSTREAM_H