Tag Parser  10.0.0
C++ library for reading and writing MP4 (iTunes), ID3, Vorbis, Opus, FLAC and Matroska tags
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 
9 using namespace std;
10 
11 namespace TagParser {
12 
18 void AdtsStream::internalParseHeader(Diagnostics &diag, AbortableProgressFeedback &progress)
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) {
25  throw NoDataFoundException();
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);
37  m_format = Mpeg4AudioObjectIds::idToMediaFormat(m_firstFrame.mpeg4AudioObjectId());
38  m_channelCount = Mpeg4ChannelConfigs::channelCount(m_channelConfig = m_firstFrame.mpeg4ChannelConfig());
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.
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:367
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:460
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
std::uint32_t mpeg4SamplingFrequencyTable[13]
Definition: mp4ids.cpp:423