整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
149
video/core/Demuxer.h
Normal file
149
video/core/Demuxer.h
Normal file
|
|
@ -0,0 +1,149 @@
|
|||
#ifndef ADECE10E_B193_46F7_B377_651677F4AD89
|
||||
#define ADECE10E_B193_46F7_B377_651677F4AD89
|
||||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Component.h"
|
||||
#include "util/FactoryManager.h"
|
||||
#include "util/SimpleFactory.h"
|
||||
#include "VideoEncoder.h"
|
||||
#include "AudioEncoder.h"
|
||||
#include "util/Task.h"
|
||||
#include "util/ClassAssistant.h"
|
||||
#include <Poco/BasicEvent.h>
|
||||
#include <Poco/SharedPtr.h>
|
||||
#include <Poco/URI.h>
|
||||
#include <vector>
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class DemuxHandlerSelector
|
||||
{
|
||||
public:
|
||||
static const std::string select(const std::string& uri)
|
||||
{
|
||||
return Poco::URI(uri).getScheme();
|
||||
}
|
||||
};
|
||||
|
||||
class DemuxHandler
|
||||
: public ::Util::FactoryManager<DemuxHandler, const std::string, DemuxHandlerSelector, const std::string&>
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::SharedPtr<DemuxHandler>;
|
||||
using Post = std::function<void(Packet::Ptr, MediaType)>;
|
||||
using ShouldWait = std::function<bool(void)>;
|
||||
|
||||
public:
|
||||
DemuxHandler(const std::string& name, const std::string& uri);
|
||||
virtual ~DemuxHandler();
|
||||
|
||||
public:
|
||||
virtual void run(VideoEncoder::Ptr pVideoEncoder, AudioEncoder::Ptr pAudioEncoder, const Post& post,
|
||||
std::atomic<bool>& isCancelled) = 0;
|
||||
|
||||
const std::string& name() const;
|
||||
const std::string& uri() const;
|
||||
const std::string& scheme() const;
|
||||
|
||||
virtual void seek(uint64_t ts) = 0;
|
||||
|
||||
PROPERTY_DECLARE(UsingTCPTransport, bool, false, public, public)
|
||||
PROPERTY_DECLARE(Baseline, uint64_t, 0, public, public)
|
||||
PROPERTY_DECLARE(Timeline, uint64_t, 0, public, public)
|
||||
PROPERTY_DECLARE(Position, int64_t, 0, protected, public)
|
||||
|
||||
protected:
|
||||
int64_t getTimeDrift(uint64_t ts);
|
||||
void resetTimeDrift();
|
||||
|
||||
private:
|
||||
const std::string _name;
|
||||
const std::string _uri;
|
||||
const std::string _scheme;
|
||||
int64_t _timeDrift;
|
||||
};
|
||||
|
||||
inline const std::string& DemuxHandler::name() const
|
||||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
inline const std::string& DemuxHandler::uri() const
|
||||
{
|
||||
return _uri;
|
||||
}
|
||||
|
||||
inline const std::string& DemuxHandler::scheme() const
|
||||
{
|
||||
return _scheme;
|
||||
}
|
||||
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DECLARE
|
||||
*******************************************************************************
|
||||
*/
|
||||
class Demuxer: public Component, public ::Util::SimpleFactory<Demuxer, const std::string&>
|
||||
{
|
||||
public:
|
||||
using Ptr = Poco::AutoPtr<Demuxer>;
|
||||
using URICollection = std::vector<std::string>;
|
||||
|
||||
public:
|
||||
Demuxer(const std::string& name);
|
||||
~Demuxer();
|
||||
|
||||
public:
|
||||
CONFIGURABLE_DECLARE_PARAMETER(UsingTCPTransport, bool)
|
||||
CONFIGURABLE_DECLARE_PARAMETER(URICollection, URICollection&)
|
||||
|
||||
Poco::BasicEvent<void> PlayIndexChanged;
|
||||
Poco::BasicEvent<void> PlayPositionChanged;
|
||||
|
||||
const int playIndex() const;
|
||||
VideoEncoder::Ptr videoEncoder();
|
||||
AudioEncoder::Ptr audioEncoder();
|
||||
|
||||
protected:
|
||||
void start() override;
|
||||
void stop() override;
|
||||
void onLink(Component::Ptr pPrevious) override;
|
||||
void onUnlink(Component::Ptr pPrevious) override;
|
||||
void onConfigChanged(ParameterNames& names) override;
|
||||
|
||||
READONLY_PROPERTY_DECLARE(playIndex, int)
|
||||
READONLY_PROPERTY_DECLARE(playPosition, int64_t)
|
||||
|
||||
private:
|
||||
Util::Task _task;
|
||||
VideoEncoder::Ptr _pVideoEncoder;
|
||||
AudioEncoder::Ptr _pAudioEncoder;
|
||||
};
|
||||
|
||||
inline const int Demuxer::playIndex() const
|
||||
{
|
||||
return _playIndex;
|
||||
}
|
||||
|
||||
inline VideoEncoder::Ptr Demuxer::videoEncoder()
|
||||
{
|
||||
return _pVideoEncoder;
|
||||
}
|
||||
|
||||
inline AudioEncoder::Ptr Demuxer::audioEncoder()
|
||||
{
|
||||
return _pAudioEncoder;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue