2015-09-06 19:57:33 +02:00
|
|
|
#include "./adtsstream.h"
|
2015-07-15 00:10:24 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../mp4/mp4ids.h"
|
2015-09-06 15:42:18 +02:00
|
|
|
|
2015-09-06 19:57:33 +02:00
|
|
|
#include "../exceptions.h"
|
2015-07-15 00:10:24 +02:00
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \class Media::AdtsStream
|
|
|
|
* \brief Implementation of Media::AbstractTrack for ADTS streams.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void AdtsStream::internalParseHeader()
|
|
|
|
{
|
|
|
|
//static const string context("parsing ADTS frame header");
|
|
|
|
if(!m_istream) {
|
|
|
|
throw NoDataFoundException();
|
|
|
|
}
|
|
|
|
// get size
|
|
|
|
m_istream->seekg(-128, ios_base::end);
|
|
|
|
if(m_reader.readUInt24BE() == 0x544147) {
|
|
|
|
m_size = static_cast<uint64>(m_istream->tellg()) - 3u - m_startOffset;
|
|
|
|
} else {
|
|
|
|
m_size = static_cast<uint64>(m_istream->tellg()) + 125u - m_startOffset;
|
|
|
|
}
|
|
|
|
m_istream->seekg(m_startOffset, ios_base::beg);
|
|
|
|
// parse frame header
|
|
|
|
m_firstFrame.parseHeader(m_reader);
|
|
|
|
m_format = Mpeg4AudioObjectIds::idToMediaFormat(m_firstFrame.mpeg4AudioObjectId());
|
2015-07-31 01:09:41 +02:00
|
|
|
m_channelCount = Mpeg4ChannelConfigs::channelCount(m_channelConfig = m_firstFrame.mpeg4ChannelConfig());
|
|
|
|
byte sampleRateIndex = m_firstFrame.mpeg4SamplingFrequencyIndex();
|
2015-08-13 03:23:28 +02:00
|
|
|
m_samplingFrequency = sampleRateIndex < sizeof(mpeg4SamplingFrequencyTable) ? mpeg4SamplingFrequencyTable[sampleRateIndex] : 0;
|
2015-07-15 00:10:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace Media
|
|
|
|
|