mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-22 02:34:26 +08:00
精简rtp服务器相关代码
This commit is contained in:
parent
df14924a99
commit
255ccb4265
@ -1 +1 @@
|
||||
Subproject commit 21fdfe4a6553356f1b01f7dde326535ba23aef45
|
||||
Subproject commit 90ba564e9e39a120ed7b99260f2835a19811af30
|
@ -174,7 +174,6 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_
|
||||
//创建tcp服务器
|
||||
tcp_server = std::make_shared<TcpServer>(rtp_socket->getPoller());
|
||||
(*tcp_server)[RtpSession::kStreamID] = stream_id;
|
||||
(*tcp_server)[RtpSession::kIsUDP] = 0;
|
||||
(*tcp_server)[RtpSession::kSSRC] = ssrc;
|
||||
if (tcp_mode == PASSIVE) {
|
||||
tcp_server->start<RtpSession>(rtp_socket->get_local_port(), local_ip);
|
||||
@ -205,7 +204,6 @@ void RtpServer::start(uint16_t local_port, const string &stream_id, TcpMode tcp_
|
||||
#if 1
|
||||
//单端口多线程接收多个流,根据ssrc区分流
|
||||
udp_server = std::make_shared<UdpServer>(rtp_socket->getPoller());
|
||||
(*udp_server)[RtpSession::kIsUDP] = 1;
|
||||
udp_server->start<RtpSession>(rtp_socket->get_local_port(), local_ip);
|
||||
rtp_socket = nullptr;
|
||||
#else
|
||||
|
@ -20,27 +20,22 @@ using namespace toolkit;
|
||||
namespace mediakit{
|
||||
|
||||
const string RtpSession::kStreamID = "stream_id";
|
||||
const string RtpSession::kIsUDP = "is_udp";
|
||||
const string RtpSession::kSSRC = "ssrc";
|
||||
|
||||
void RtpSession::attachServer(const Server &server) {
|
||||
_stream_id = const_cast<Server &>(server)[kStreamID];
|
||||
_is_udp = const_cast<Server &>(server)[kIsUDP];
|
||||
_ssrc = const_cast<Server &>(server)[kSSRC];
|
||||
|
||||
if (_is_udp) {
|
||||
//设置udp socket读缓存
|
||||
SockUtil::setRecvBuf(getSock()->rawFD(), 4 * 1024 * 1024);
|
||||
_statistic_udp = std::make_shared<ObjectStatistic<UdpSession> >();
|
||||
} else {
|
||||
_statistic_tcp = std::make_shared<ObjectStatistic<TcpSession> >();
|
||||
}
|
||||
}
|
||||
|
||||
RtpSession::RtpSession(const Socket::Ptr &sock) : Session(sock) {
|
||||
DebugP(this);
|
||||
socklen_t addr_len = sizeof(_addr);
|
||||
getpeername(sock->rawFD(), (struct sockaddr *)&_addr, &addr_len);
|
||||
_is_udp = sock->sockType() == SockNum::Sock_UDP;
|
||||
if (_is_udp) {
|
||||
// 设置udp socket读缓存
|
||||
SockUtil::setRecvBuf(getSock()->rawFD(), 4 * 1024 * 1024);
|
||||
}
|
||||
}
|
||||
|
||||
RtpSession::~RtpSession() {
|
||||
|
@ -23,7 +23,6 @@ namespace mediakit{
|
||||
class RtpSession : public toolkit::Session, public RtpSplitter, public MediaSourceEvent {
|
||||
public:
|
||||
static const std::string kStreamID;
|
||||
static const std::string kIsUDP;
|
||||
static const std::string kSSRC;
|
||||
|
||||
RtpSession(const toolkit::Socket::Ptr &sock);
|
||||
@ -50,8 +49,6 @@ private:
|
||||
std::string _stream_id;
|
||||
struct sockaddr_storage _addr;
|
||||
RtpProcess::Ptr _process;
|
||||
std::shared_ptr<toolkit::ObjectStatistic<toolkit::TcpSession> > _statistic_tcp;
|
||||
std::shared_ptr<toolkit::ObjectStatistic<toolkit::UdpSession> > _statistic_udp;
|
||||
};
|
||||
|
||||
}//namespace mediakit
|
||||
|
Loading…
Reference in New Issue
Block a user