2021-03-02 05:42:31 +08:00
|
|
|
/* ---------------------------------------------------------------------------
|
|
|
|
**
|
|
|
|
** ADTS_FifoSource.cpp
|
|
|
|
**
|
|
|
|
** ADTS Live555 source
|
|
|
|
**
|
|
|
|
** -------------------------------------------------------------------------*/
|
|
|
|
|
|
|
|
#include "zm_rtsp_server_fifo_audio_source.h"
|
|
|
|
|
|
|
|
#if HAVE_RTSP_SERVER
|
|
|
|
|
2021-03-11 00:01:04 +08:00
|
|
|
static const int samplingFrequencyTable[16] = {
|
2021-03-02 05:42:31 +08:00
|
|
|
96000, 88200, 64000, 48000,
|
|
|
|
44100, 32000, 24000, 22050,
|
|
|
|
16000, 12000, 11025, 8000,
|
|
|
|
7350, 0, 0, 0
|
|
|
|
};
|
|
|
|
// ---------------------------------
|
|
|
|
// ADTS ZoneMinder FramedSource
|
|
|
|
// ---------------------------------
|
|
|
|
//
|
|
|
|
ZoneMinderFifoAudioSource::ZoneMinderFifoAudioSource(
|
2021-03-11 00:01:04 +08:00
|
|
|
std::shared_ptr<xop::RtspServer>& rtspServer,
|
|
|
|
xop::MediaSessionId sessionId,
|
|
|
|
xop::MediaChannelId channelId,
|
|
|
|
std::string fifo
|
2021-03-02 05:42:31 +08:00
|
|
|
)
|
|
|
|
:
|
2021-03-11 00:01:04 +08:00
|
|
|
ZoneMinderFifoSource(rtspServer, sessionId, channelId, fifo),
|
2021-03-02 05:42:31 +08:00
|
|
|
samplingFrequencyIndex(-1),
|
|
|
|
frequency(-1),
|
|
|
|
channels(1)
|
|
|
|
{
|
|
|
|
}
|
2021-03-05 02:24:26 +08:00
|
|
|
int ZoneMinderFifoAudioSource::getFrequencyIndex() {
|
|
|
|
for (int i=0; i<16; i++)
|
|
|
|
if (samplingFrequencyTable[i] == frequency) return i;
|
|
|
|
return -1;
|
|
|
|
}
|
2021-03-11 00:01:04 +08:00
|
|
|
|
|
|
|
void ZoneMinderFifoAudioSource::PushFrame(const uint8_t *data, size_t size, int64_t pts) {
|
|
|
|
xop::AVFrame frame = {0};
|
|
|
|
frame.type = xop::AUDIO_FRAME;
|
|
|
|
frame.size = size;
|
|
|
|
frame.timestamp = av_rescale_q(pts, AV_TIME_BASE_Q, m_timeBase);
|
|
|
|
frame.buffer.reset(new uint8_t[size]);
|
|
|
|
memcpy(frame.buffer.get(), data, size);
|
|
|
|
m_rtspServer->PushFrame(m_sessionId, m_channelId, frame);
|
|
|
|
}
|
2021-03-02 05:42:31 +08:00
|
|
|
#endif // HAVE_RTSP_SERVER
|