mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2026-06-26 20:02:21 +08:00
startSendRtp接口支持同时接收流:#2109,#2149
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
|
||||
#if defined(ENABLE_RTPPROXY)
|
||||
#include "RtpSender.h"
|
||||
#include "RtpSession.h"
|
||||
#include "Rtsp/RtspSession.h"
|
||||
#include "Thread/WorkThreadPool.h"
|
||||
#include "Util/uv_errno.h"
|
||||
@@ -213,6 +214,25 @@ void RtpSender::onConnect(){
|
||||
}
|
||||
//连接建立成功事件
|
||||
weak_ptr<RtpSender> weak_self = shared_from_this();
|
||||
if (!_args.recv_stream_id.empty()) {
|
||||
mINI ini;
|
||||
ini[RtpSession::kStreamID] = _args.recv_stream_id;
|
||||
_rtp_session = std::make_shared<RtpSession>(_socket_rtp);
|
||||
_rtp_session->setParams(ini);
|
||||
|
||||
_socket_rtp->setOnRead([weak_self](const Buffer::Ptr &buf, struct sockaddr *addr, int addr_len) {
|
||||
auto strong_self = weak_self.lock();
|
||||
if (!strong_self) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
strong_self->_rtp_session->onRecv(buf);
|
||||
} catch (std::exception &ex){
|
||||
SockException err(toolkit::Err_shutdown, ex.what());
|
||||
strong_self->_rtp_session->shutdown(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
_socket_rtp->setOnErr([weak_self](const SockException &err) {
|
||||
auto strong_self = weak_self.lock();
|
||||
if (strong_self) {
|
||||
|
||||
Reference in New Issue
Block a user