Tag Parser: wav/waveaudiostream.h Source File

Tag Parser 12.5.3 C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags

Loading...
Searching...
No Matches
waveaudiostream.h
Go to the documentation of this file.
1#ifndef TAG_PARSER_WAVEAUDIOSTREAM_H
2#define TAG_PARSER_WAVEAUDIOSTREAM_H
3
4#include "../abstracttrack.h"
5
6namespace TagParser {
7
8 class TAG_PARSER_EXPORT WaveFormatHeader {
9public:
10 constexpr WaveFormatHeader();
11
12 std::uint64_t parse(CppUtilities::BinaryReader &reader, std::uint64_t maxSize, Diagnostics &diag);
13 MediaFormat format() const;
14 constexpr std::uint32_t bitrate() const;
15
16 std::uint64_t guid1;
17 std::uint64_t guid2;
18 std::uint16_t formatTag;
19 std::uint16_t channelCount;
20 std::uint32_t sampleRate;
21 std::uint32_t bytesPerSecond;
22 std::uint16_t chunkSize;
23 std::uint16_t bitsPerSample;
24 std::uint32_t channelMask;
25};
26
30 constexpr WaveFormatHeader::WaveFormatHeader()
31 : guid1(0)
32 , guid2(0)
33 , formatTag(0)
34 , channelCount(0)
35 , sampleRate(0)
36 , bytesPerSecond(0)
37 , chunkSize(0)
38 , bitsPerSample(0)
39 , channelMask(0)
40{
41}
42
46 constexpr std::uint32_t WaveFormatHeader::bitrate() const
47{
48 return bitsPerSample * sampleRate * channelCount;
49}
50
51 class TAG_PARSER_EXPORT WaveAudioStream final : public AbstractTrack {
52public:
53 WaveAudioStream(std::iostream &stream, std::uint64_t startOffset);
54 ~WaveAudioStream() override;
55
56 TrackType type() const override;
57
58 static void addInfo(const WaveFormatHeader &waveHeader, AbstractTrack &track);
59
60protected:
61 void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override;
62
63private:
64 std::uint64_t m_dataOffset;
65};
66
67} // namespace TagParser
68
69#endif // TAG_PARSER_WAVEAUDIOSTREAM_H
abstracttrack.h
TagParser::AbortableProgressFeedback
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
Definition progressfeedback.h:186
TagParser::AbstractTrack::startOffset
std::uint64_t startOffset() const
Returns the start offset of the track in the associated stream.
Definition abstracttrack.h:316
TagParser::AbstractTrack::AbstractTrack
AbstractTrack(std::istream &inputStream, std::ostream &outputStream, std::uint64_t startOffset)
Constructs a new track.
Definition abstracttrack.cpp:33
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition diagnostics.h:156
TagParser::MediaFormat
The MediaFormat class specifies the format of media data.
Definition mediaformat.h:247
TagParser::WaveAudioStream::type
TrackType type() const override
Returns the type of the track if known; otherwise returns TrackType::Unspecified.
Definition waveaudiostream.cpp:127
TagParser::WaveAudioStream::addInfo
static void addInfo(const WaveFormatHeader &waveHeader, AbstractTrack &track)
Adds the information from the specified waveHeader to the specified track.
Definition waveaudiostream.cpp:135
TagParser::WaveAudioStream::WaveAudioStream
WaveAudioStream(std::iostream &stream, std::uint64_t startOffset)
Constructs a new track for the stream at the specified startOffset.
Definition waveaudiostream.cpp:113
TagParser::WaveAudioStream::internalParseHeader
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Definition waveaudiostream.cpp:147
TagParser::WaveFormatHeader
The WaveFormatHeader class parses the WAVEFORMATEX structure defined by MS.
Definition waveaudiostream.h:8
TagParser::WaveFormatHeader::bitsPerSample
std::uint16_t bitsPerSample
Definition waveaudiostream.h:23
TagParser::WaveFormatHeader::chunkSize
std::uint16_t chunkSize
Definition waveaudiostream.h:22
TagParser::WaveFormatHeader::guid1
std::uint64_t guid1
Definition waveaudiostream.h:16
TagParser::WaveFormatHeader::bytesPerSecond
std::uint32_t bytesPerSecond
Definition waveaudiostream.h:21
TagParser::WaveFormatHeader::guid2
std::uint64_t guid2
Definition waveaudiostream.h:17
TagParser::WaveFormatHeader::formatTag
std::uint16_t formatTag
Definition waveaudiostream.h:18
TagParser::WaveFormatHeader::format
MediaFormat format() const
Returns the media format denoted by the format tag.
Definition waveaudiostream.cpp:78
TagParser::WaveFormatHeader::channelCount
std::uint16_t channelCount
Definition waveaudiostream.h:19
TagParser::WaveFormatHeader::bitrate
constexpr std::uint32_t bitrate() const
Calculates the bitrate from the header data.
Definition waveaudiostream.h:46
TagParser::WaveFormatHeader::parse
std::uint64_t parse(CppUtilities::BinaryReader &reader, std::uint64_t maxSize, Diagnostics &diag)
Parses the WAVE "fmt " header segment using the specified reader.
Definition waveaudiostream.cpp:25
TagParser::WaveFormatHeader::sampleRate
std::uint32_t sampleRate
Definition waveaudiostream.h:20
TagParser::WaveFormatHeader::channelMask
std::uint32_t channelMask
Definition waveaudiostream.h:24
TagParser::WaveFormatHeader::WaveFormatHeader
constexpr WaveFormatHeader()
Constructs a new WaveFormatHeader.
Definition waveaudiostream.h:30
TAG_PARSER_EXPORT
#define TAG_PARSER_EXPORT
Marks the symbol to be exported by the tagparser library.
Definition global.h:14
TagParser
Contains all classes and functions of the TagInfo library.
Definition aaccodebook.h:10
TagParser::TrackType
TrackType
The TrackType enum specifies the underlying file type of a track and the concrete class of the track ...
Definition abstracttrack.h:32