整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
119
video/core/AudioDecoder.h
Normal file
119
video/core/AudioDecoder.h
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#ifndef D60BD16B_B6AC_40EF_9E0E_D70A203EA49C
|
||||
#define D60BD16B_B6AC_40EF_9E0E_D70A203EA49C
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "AbstractAudioInput.h"
|
||||
#include "util/FactoryManager.h"
|
||||
#include "util/Task.h"
|
||||
#include "System.h"
|
||||
#include "FrameSynchronizer.h"
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class AudioDecodeHandlerSelector
|
||||
{
|
||||
public:
|
||||
static CodecID select(CodecID codec, AudioComponent::Ptr)
|
||||
{
|
||||
return codec;
|
||||
}
|
||||
};
|
||||
|
||||
class AudioDecodeHandler: public ::Util::FactoryManager<AudioDecodeHandler, CodecID, AudioDecodeHandlerSelector,
|
||||
CodecID, AudioComponent::Ptr>
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::SharedPtr<AudioDecodeHandler>;
|
||||
|
||||
public:
|
||||
AudioDecodeHandler(const std::string& name, CodecID codecID, AudioComponent::Ptr pPrevious);
|
||||
virtual ~AudioDecodeHandler();
|
||||
|
||||
public:
|
||||
const std::string& name() const;
|
||||
AudioComponent::Ptr previous() const;
|
||||
|
||||
virtual void write(Packet::Ptr pPacket) = 0;
|
||||
virtual Frame::Ptr read() = 0;
|
||||
|
||||
virtual void conceal(Packet::Ptr pPacket);
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
AudioComponent::Ptr _pPrevious;
|
||||
};
|
||||
|
||||
inline const std::string& AudioDecodeHandler::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
inline AudioComponent::Ptr AudioDecodeHandler::previous() const
|
||||
{
|
||||
return _pPrevious;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class AudioDecoderSelector
|
||||
{
|
||||
public:
|
||||
static int select(const std::string&)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
class AudioDecoder: public AbstractAudioInput,
|
||||
public ::Util::FactoryManager<AudioDecoder, int, AudioDecoderSelector, const std::string&>
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::AutoPtr<AudioDecoder>;
|
||||
|
||||
public:
|
||||
AudioDecoder(const std::string& name);
|
||||
virtual ~AudioDecoder();
|
||||
|
||||
protected:
|
||||
void start() override;
|
||||
void stop() override;
|
||||
|
||||
Frame::Ptr readFrame() override;
|
||||
|
||||
void onLink(Core::Component::Ptr pPrevious) override;
|
||||
void onUnlink(Core::Component::Ptr pPrevious) override;
|
||||
|
||||
void syncFrame(Frame::Ptr pFrame, bool isCatchingUp = false);
|
||||
|
||||
PROPERTY_DECLARE(Timeline, uint64_t, 0, public, public)
|
||||
|
||||
private:
|
||||
void updateCatchUpState();
|
||||
|
||||
bool shouldDropPacket();
|
||||
|
||||
AudioDecodeHandler::Ptr _pHandler;
|
||||
FrameSynchronizer _synchronizer;
|
||||
|
||||
bool _catchUpEnabled;
|
||||
|
||||
bool _isCatchingUp;
|
||||
|
||||
uint32_t _dropPhase;
|
||||
};
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue