tagparser/wav/waveaudiostream.h

65 lines
1.4 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
void parse(IoUtilities::BinaryReader &reader);
2019-01-01 23:39:40 +01:00
std::pair<MediaFormat, uint64> parseExt(IoUtilities::BinaryReader &reader, uint64 maxSize, Diagnostics &diag);
2015-06-12 02:35:50 +02:00
MediaFormat format() const;
2018-07-10 14:11:11 +02:00
constexpr uint32 bitrate() const;
2015-06-12 02:35:50 +02:00
uint16 formatTag;
uint16 channelCount;
uint16 sampleRate;
uint16 bytesPerSecond;
uint16 chunkSize;
uint16 bitsPerSample;
};
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.
*/
2018-07-10 14:11:11 +02:00
constexpr uint32 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:
WaveAudioStream(std::iostream &stream, uint64 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:
uint64 m_dataOffset;
};
2018-03-07 01:17:50 +01:00
} // namespace TagParser
2015-04-22 19:22:01 +02:00
#endif // TAG_PARSER_WAVEAUDIOSTREAM_H