Older/MediaServer/MediaServer.cpp

31 lines
797 B
C++
Raw Normal View History

2024-09-28 23:55:00 +08:00
#include "MediaServer.h"
#include "BoostLog.h"
#include "Network/TcpServer.h"
#include "Rtsp/RtspSession.h"
class MediaServerPrivate {
public:
toolkit::TcpServer::Ptr rtsp_server[2];
};
MediaServer::MediaServer(uint16_t port, bool ssl) : m_d(new MediaServerPrivate()) {
try {
m_d->rtsp_server[ssl] = std::make_shared<toolkit::TcpServer>();
if (ssl) {
m_d->rtsp_server[ssl]->start<toolkit::SessionWithSSL<mediakit::RtspSession>>(port);
} else {
m_d->rtsp_server[ssl]->start<mediakit::RtspSession>(port);
}
} catch (std::exception &ex) {
m_d->rtsp_server[ssl] = nullptr;
WarnL << ex.what();
}
}
MediaServer::~MediaServer() {
// mk_stop_all_server();
if (m_d != nullptr) {
delete m_d;
}
}