整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
95
video/core/Muxer.cpp
Normal file
95
video/core/Muxer.cpp
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "Muxer.h"
|
||||
#include "AudioComponent.h"
|
||||
#include "VideoComponent.h"
|
||||
#include "Logger.h"
|
||||
|
||||
namespace Video
|
||||
{
|
||||
namespace Core
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DEFINE
|
||||
*******************************************************************************
|
||||
*/
|
||||
Muxer::Muxer(const std::string& name, const std::string& url): Component(name), _url(url)
|
||||
{
|
||||
}
|
||||
|
||||
Muxer::~Muxer()
|
||||
{
|
||||
}
|
||||
|
||||
void Muxer::start()
|
||||
{
|
||||
_task.run(
|
||||
[this](std::atomic<bool>& isCancelled) -> void
|
||||
{
|
||||
while (!isCancelled)
|
||||
{
|
||||
try
|
||||
{
|
||||
connect();
|
||||
while (!isCancelled)
|
||||
mux();
|
||||
}
|
||||
catch (Poco::Exception& e)
|
||||
{
|
||||
logger().error("%s(CONNECT/MUX): %s", name(), e.displayText());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
logger().error("%s(CONNECT/MUX): %s", name(), std::string(e.what()));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
disconnect();
|
||||
}
|
||||
catch (Poco::Exception& e)
|
||||
{
|
||||
logger().error("%s(DISCONNECT): %s", name(), e.displayText());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
logger().error("%s(DISCONNECT): %s", name(), std::string(e.what()));
|
||||
}
|
||||
|
||||
if (!isCancelled)
|
||||
Poco::Thread::sleep(1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void Muxer::stop()
|
||||
{
|
||||
_task.cancel();
|
||||
}
|
||||
|
||||
void Muxer::onLink(Component::Ptr pPrevious)
|
||||
{
|
||||
if (dynamic_cast<AudioComponent*>(pPrevious.get()))
|
||||
packetQueues().add(pPrevious, name(), MediaType::AUDIO);
|
||||
else if (dynamic_cast<VideoComponent*>(pPrevious.get()))
|
||||
packetQueues().add(pPrevious, name(), MediaType::VIDEO);
|
||||
else
|
||||
{
|
||||
logger().error("%s: Unsupport class '%s'", name(), std::string(typeid(*pPrevious).name()));
|
||||
}
|
||||
}
|
||||
|
||||
void Muxer::onUnlink(Component::Ptr pPrevious)
|
||||
{
|
||||
packetQueues().remove(pPrevious);
|
||||
}
|
||||
|
||||
void Muxer::onConfigChanged(ParameterNames& names)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue