| | |
| | | #include "PL_RTSPServer.h"
|
| | | #include "PL_RTSPServer2.h"
|
| | | #include "MaterialBuffer.h"
|
| | | #include "logger.h"
|
| | |
|
| | |
| | | #include "PreAllocBufferQueue.h"
|
| | | #include "MediaHelper.h"
|
| | |
|
| | | struct RTSPServer_Internal
|
| | | struct RTSPServer2_Internal
|
| | | {
|
| | | RTSPServerConfig config;
|
| | | RTSPServer2Config config;
|
| | |
|
| | | pthread_t live_daemon_thid;
|
| | | bool live_daemon_running;
|
| | |
| | |
|
| | | bool auxLineSet;
|
| | |
|
| | | RTSPServer_Internal() : |
| | | RTSPServer2_Internal() : |
| | | config(),
|
| | | live_daemon_thid(0), live_daemon_running(false),
|
| | | server(nullptr),
|
| | |
| | | pthread_mutex_init(queue_mutex, NULL);
|
| | | }
|
| | |
|
| | | ~RTSPServer_Internal()
|
| | | ~RTSPServer2_Internal()
|
| | | {
|
| | | reset();
|
| | | }
|
| | |
|
| | | void reset()
|
| | | {
|
| | | RTSPServerConfig _config;
|
| | | RTSPServer2Config _config;
|
| | | config =_config;
|
| | |
|
| | | if (frameQueue != nullptr)
|
| | |
| | | }
|
| | | };
|
| | |
|
| | | PipeLineElem* create_PL_RTSPServer()
|
| | | PipeLineElem* create_PL_RTSPServer2()
|
| | | {
|
| | | return new PL_RTSPServer;
|
| | | return new PL_RTSPServer2;
|
| | | }
|
| | |
|
| | | PL_RTSPServer::PL_RTSPServer() : internal(new RTSPServer_Internal)
|
| | | PL_RTSPServer2::PL_RTSPServer2() : internal(new RTSPServer2_Internal)
|
| | | {
|
| | | }
|
| | |
|
| | | PL_RTSPServer::~PL_RTSPServer()
|
| | | PL_RTSPServer2::~PL_RTSPServer2()
|
| | | {
|
| | | delete (RTSPServer_Internal*)internal;
|
| | | delete (RTSPServer2_Internal*)internal;
|
| | | internal = nullptr;
|
| | | }
|
| | |
|
| | | struct DeliverFrameCallback
|
| | | {
|
| | | RTSPServer_Internal* in;
|
| | | RTSPServer2_Internal* in;
|
| | | PreAllocBufferQueue::Buffer* lastBuffer;
|
| | |
|
| | | DeliverFrameCallback(RTSPServer_Internal* _in)
|
| | | DeliverFrameCallback(RTSPServer2_Internal* _in)
|
| | | : in(_in) , lastBuffer(nullptr)
|
| | | {
|
| | | }
|
| | |
| | |
|
| | | static void* live_daemon_thd(void* arg)
|
| | | {
|
| | | RTSPServer_Internal* in = (RTSPServer_Internal*)arg;
|
| | | RTSPServer2_Internal* in = (RTSPServer2_Internal*)arg;
|
| | |
|
| | | in->server = new MESAI::LiveRTSPServer(nullptr, 8554, 8080);
|
| | |
|
| | |
| | | in->live_daemon_running = false;
|
| | | }
|
| | |
|
| | | bool PL_RTSPServer::init(void* args)
|
| | | bool PL_RTSPServer2::init(void* args)
|
| | | {
|
| | | RTSPServer_Internal* in = (RTSPServer_Internal*)internal;
|
| | | RTSPServer2_Internal* in = (RTSPServer2_Internal*)internal;
|
| | |
|
| | | if (args)
|
| | | {
|
| | | RTSPServerConfig* config = (RTSPServerConfig*)args;
|
| | | RTSPServer2Config* config = (RTSPServer2Config*)args;
|
| | | in->config = *config;
|
| | | }
|
| | |
|
| | |
| | | return true;
|
| | | }
|
| | |
|
| | | void PL_RTSPServer::finit()
|
| | | void PL_RTSPServer2::finit()
|
| | | {
|
| | | RTSPServer_Internal* in = (RTSPServer_Internal*)internal;
|
| | | RTSPServer2_Internal* in = (RTSPServer2_Internal*)internal;
|
| | |
|
| | | pthread_join(in->live_daemon_thid, NULL);
|
| | | }
|
| | |
|
| | | bool PL_RTSPServer::pay(const PipeMaterial& pm)
|
| | | bool PL_RTSPServer2::pay(const PipeMaterial& pm)
|
| | | {
|
| | | RTSPServer_Internal* in = (RTSPServer_Internal*)internal;
|
| | | RTSPServer2_Internal* in = (RTSPServer2_Internal*)internal;
|
| | |
|
| | | if (pm.buffer == nullptr)
|
| | | return false;
|
| | |
|
| | | if (pm.type != PipeMaterial::PMT_FRAME)
|
| | | {
|
| | | LOG_ERROR << "PL_RTSPServer::pay only support PMT_FRAME" << std::endl;
|
| | | LOG_ERROR << "PL_RTSPServer2::pay only support PMT_FRAME" << std::endl;
|
| | | return false;
|
| | | }
|
| | |
|
| | |
| | |
|
| | | ScopeLocker<pthread_mutex_t>(in->queue_mutex);
|
| | | //if (in->frameQueue->Full())
|
| | | // LOG_WARN << "PL_RTSPServer::pay may lost data" << std::endl;
|
| | | // LOG_WARN << "PL_RTSPServer2::pay may lost data" << std::endl;
|
| | |
|
| | | PreAllocBufferQueue::Buffer* qbuff = in->frameQueue->Enqueue();
|
| | | if (qbuff == nullptr)
|
| | | {
|
| | | LOG_WARN << "PL_RTSPServer::pay may lost data size=" << frame->buffSize << std::endl;
|
| | | LOG_WARN << "PL_RTSPServer2::pay may lost data size=" << frame->buffSize << std::endl;
|
| | | int ret = pthread_mutex_unlock(in->queue_empty_mutex);
|
| | | if (ret != 0)
|
| | | {
|
| | |
| | | int ret = pthread_mutex_unlock(in->queue_empty_mutex);
|
| | | if (ret != 0)
|
| | | {
|
| | | LOG_WARN << "pthread_mutex_unlock queue_empty_mutex, ret=" << ret << std::endl;
|
| | | //LOG_WARN << "pthread_mutex_unlock queue_empty_mutex, ret=" << ret << std::endl;
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
|
| | | bool PL_RTSPServer::gain(PipeMaterial& pm)
|
| | | bool PL_RTSPServer2::gain(PipeMaterial& pm)
|
| | | {
|
| | | RTSPServer_Internal* in = (RTSPServer_Internal*)internal;
|
| | | RTSPServer2_Internal* in = (RTSPServer2_Internal*)internal;
|
| | |
|
| | | pm.type = PipeMaterial::PMT_NONE;
|
| | | pm.buffer = nullptr;
|