-
Notifications
You must be signed in to change notification settings - Fork 141
/
mpegAudioStreamReader.cpp
43 lines (36 loc) · 1.33 KB
/
mpegAudioStreamReader.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "mpegAudioStreamReader.h"
#include <sstream>
int MpegAudioStreamReader::getTSDescriptor(uint8_t* dstBuff, bool blurayMode, bool hdmvDescriptors)
{
uint8_t* frame = findFrame(m_buffer, m_bufEnd);
if (frame == 0)
return 0;
int skipBytes = 0;
int skipBeforeBytes = 0;
int len = decodeFrame(frame, m_bufEnd, skipBytes, skipBeforeBytes);
return 0;
}
uint8_t* MpegAudioStreamReader::findFrame(uint8_t* buff, uint8_t* end) { return mp3FindFrame(buff, end); }
int MpegAudioStreamReader::decodeFrame(uint8_t* buff, uint8_t* end, int& skipBytes, int& skipBeforeBytes)
{
skipBytes = 0;
skipBeforeBytes = 0;
return mp3DecodeFrame(buff, end);
}
double MpegAudioStreamReader::getFrameDurationNano()
{
// return (INTERNAL_PTS_FREQ * m_samples) / m_sample_rate;
double rez = (INTERNAL_PTS_FREQ * m_samples) / m_sample_rate;
if (m_layer == 3 && m_nb_channels == 1)
rez /= 2; // todo: what is that? I myself don't understand why it's necessary to leave it here.
return rez;
}
const std::string MpegAudioStreamReader::getStreamInfo()
{
std::ostringstream str;
str << "Bitrate: " << m_bit_rate / 1000 << "Kbps ";
str << "Sample Rate: " << m_sample_rate / 1000 << "KHz ";
str << "Channels: " << (int)m_nb_channels << " ";
str << "Layer: " << m_layer;
return str.str();
}