Tag Parser  9.4.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)
19 {
20  CPP_UTILITIES_UNUSED(diag)
21 
22  //static const string context("parsing ADTS frame header");
23  if (!m_istream) {
24  throw NoDataFoundException();
25  }
26  // get size
27  m_istream->seekg(-128, ios_base::end);
28  if (m_reader.readUInt24BE() == 0x544147) {
29  m_size = static_cast<std::uint64_t>(m_istream->tellg()) - 3u - m_startOffset;
30  } else {
31  m_size = static_cast<std::uint64_t>(m_istream->tellg()) + 125u - m_startOffset;
32  }
33  m_istream->seekg(static_cast<streamoff>(m_startOffset), ios_base::beg);
34  // parse frame header
35  m_firstFrame.parseHeader(m_reader);
36  m_format = Mpeg4AudioObjectIds::idToMediaFormat(m_firstFrame.mpeg4AudioObjectId());
37  m_channelCount = Mpeg4ChannelConfigs::channelCount(m_channelConfig = m_firstFrame.mpeg4ChannelConfig());
38  std::uint8_t sampleRateIndex = m_firstFrame.mpeg4SamplingFrequencyIndex();
39  m_samplingFrequency = sampleRateIndex < sizeof(mpeg4SamplingFrequencyTable) ? mpeg4SamplingFrequencyTable[sampleRateIndex] : 0;
40 }
41 
42 } // namespace TagParser
TagParser::Mpeg4AudioObjectIds::idToMediaFormat
TAG_PARSER_EXPORT MediaFormat idToMediaFormat(std::uint8_t mpeg4AudioObjectId, bool sbrPresent=false, bool psPresent=false)
Definition: mp4ids.cpp:367
adtsstream.h
TagParser::Diagnostics
The Diagnostics class is a container for DiagMessage.
Definition: diagnostics.h:156
TagParser
Contains all classes and functions of the TagInfo library.
Definition: aaccodebook.h:10
TagParser::mpeg4SamplingFrequencyTable
std::uint32_t mpeg4SamplingFrequencyTable[13]
Definition: mp4ids.cpp:423
TagParser::Mpeg4ChannelConfigs::channelCount
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
TagParser::NoDataFoundException
The exception that is thrown when the data to be parsed holds no parsable information (e....
Definition: exceptions.h:18