56 lines
1.7 KiB
C++
56 lines
1.7 KiB
C++
#ifndef E2E4239C_C93E_478C_AD4C_D74AC3D4ED3E
|
|
#define E2E4239C_C93E_478C_AD4C_D74AC3D4ED3E
|
|
/*
|
|
*******************************************************************************
|
|
* INCLUDE
|
|
*******************************************************************************
|
|
*/
|
|
#include "AudioComponent.h"
|
|
#include "Frame.h"
|
|
#include "util/Task.h"
|
|
#include "util/Broadcast.h"
|
|
#include <atomic>
|
|
|
|
namespace Video
|
|
{
|
|
namespace Core
|
|
{
|
|
/*
|
|
*******************************************************************************
|
|
* CLASS DECLARE
|
|
*******************************************************************************
|
|
*/
|
|
class AbstractAudioInput: public AudioComponent
|
|
{
|
|
public:
|
|
AbstractAudioInput(const std::string& name);
|
|
~AbstractAudioInput();
|
|
void reset() override;
|
|
|
|
protected:
|
|
virtual Frame::Ptr readFrame() = 0;
|
|
void run();
|
|
void cancel();
|
|
void onConfigChanged(ParameterNames& names) override;
|
|
void applyGain(Frame::Ptr pFrame, int gain);
|
|
void applyPTSOffset(Frame::Ptr pFrame, int64_t ptsOffset);
|
|
|
|
private:
|
|
Frame::Ptr tryReadFrame(bool shuldLog = false);
|
|
Frame::Ptr readSilent(bool freezeChannel);
|
|
void updateSilentFrame();
|
|
|
|
private:
|
|
Util::Task _task;
|
|
Frame::Ptr _pSilentFrame;
|
|
Poco::SharedPtr<uint8_t> _pSilentData;
|
|
SerialCode _silentDataCode;
|
|
uint64_t _duration;
|
|
uint32_t _audioChannelId;
|
|
bool _isMute;
|
|
std::atomic<int> _gain{0};
|
|
std::atomic<int64_t> _ptsOffsetUs{0};
|
|
};
|
|
}
|
|
}
|
|
#endif
|