Tag Parser 11.5.1
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
Loading...
Searching...
No Matches
adtsstream.cpp
Go to the documentation of this file.
1#include "./adtsstream.h"
2
3#include "../mp4/mp4ids.h"
4
5#include "../exceptions.h"
6
7#include <string>
8
9using namespace std;
10
11namespace TagParser {
12
19{
20 CPP_UTILITIES_UNUSED(diag)
21 CPP_UTILITIES_UNUSED(progress)
22
23 //static const string context("parsing ADTS frame header");
24 if (!m_istream) {
26 }
27 // get size
28 m_istream->seekg(-128, ios_base::end);
29 if (m_reader.readUInt24BE() == 0x544147) {
30 m_size = static_cast<std::uint64_t>(m_istream->tellg()) - 3u - m_startOffset;
31 } else {
32 m_size = static_cast<std::uint64_t>(m_istream->tellg()) + 125u - m_startOffset;
33 }
34 m_istream->seekg(static_cast<streamoff>(m_startOffset), ios_base::beg);
35 // parse frame header
36 m_firstFrame.parseHeader(m_reader);
39 std::uint8_t sampleRateIndex = m_firstFrame.mpeg4SamplingFrequencyIndex();
40 m_samplingFrequency = sampleRateIndex < sizeof(mpeg4SamplingFrequencyTable) ? mpeg4SamplingFrequencyTable[sampleRateIndex] : 0;
41}
42
43} // namespace TagParser
The AbortableProgressFeedback class provides feedback about an ongoing operation via callbacks.
std::uint16_t m_channelCount
std::uint8_t m_channelConfig
CppUtilities::BinaryReader m_reader
std::uint64_t m_startOffset
std::istream * m_istream
std::uint32_t m_samplingFrequency
constexpr std::uint8_t mpeg4ChannelConfig() const
Returns the MPEG-4 channel configuration.
Definition: adtsframe.h:95
void parseHeader(CppUtilities::BinaryReader &reader)
Parses the header read using the specified reader.
Definition: adtsframe.cpp:21
constexpr std::uint8_t mpeg4AudioObjectId() const
Returns the MPEG-4 audio object type ID.
Definition: adtsframe.h:76
constexpr std::uint8_t mpeg4SamplingFrequencyIndex() const
Returns the MPEG-4 sample rate index.
Definition: adtsframe.h:85
void internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress) override
This method is internally called to parse header information.
Definition: adtsstream.cpp:18
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
The exception that is thrown when the data to be parsed holds no parsable information (e....
Definition: exceptions.h:18
TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent=false, bool psPresent=false)
Definition: mp4ids.cpp:368
TAG_PARSER_EXPORT std::uint8_t channelCount(std::uint8_t config)
Returns the channel count for the specified MPEG-4 channel config.
Definition: mp4ids.cpp:461
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
std::uint32_t mpeg4SamplingFrequencyTable[13]
Definition: mp4ids.cpp:424