mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
整理WebRtcSession代码
This commit is contained in:
parent
8c1caeff50
commit
85fec6da0b
@ -274,7 +274,7 @@ int start_main(int argc,char *argv[]) {
|
||||
if (!buf) {
|
||||
return Socket::createSocket(poller, false);
|
||||
}
|
||||
auto new_poller = QueryPollerByBuffer(buf);
|
||||
auto new_poller = WebRtcSession::queryPoller(buf);
|
||||
if (!new_poller) {
|
||||
//该数据对应的webrtc对象未找到,丢弃之
|
||||
return Socket::Ptr();
|
||||
|
@ -11,15 +11,6 @@
|
||||
#include "WebRtcSession.h"
|
||||
#include "Util/util.h"
|
||||
|
||||
WebRtcSession::WebRtcSession(const Socket::Ptr &sock) : UdpSession(sock) {
|
||||
socklen_t addr_len = sizeof(_peer_addr);
|
||||
getpeername(sock->rawFD(), &_peer_addr, &addr_len);
|
||||
}
|
||||
|
||||
WebRtcSession::~WebRtcSession() {
|
||||
InfoP(this);
|
||||
}
|
||||
|
||||
static string getUserName(const Buffer::Ptr &buffer) {
|
||||
auto buf = buffer->data();
|
||||
auto len = buffer->size();
|
||||
@ -39,7 +30,7 @@ static string getUserName(const Buffer::Ptr &buffer) {
|
||||
return vec[0];
|
||||
}
|
||||
|
||||
EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer) {
|
||||
EventPoller::Ptr WebRtcSession::queryPoller(const Buffer::Ptr &buffer) {
|
||||
auto user_name = getUserName(buffer);
|
||||
if (user_name.empty()) {
|
||||
return nullptr;
|
||||
@ -48,6 +39,17 @@ EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer) {
|
||||
return ret ? ret->getPoller() : nullptr;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
WebRtcSession::WebRtcSession(const Socket::Ptr &sock) : UdpSession(sock) {
|
||||
socklen_t addr_len = sizeof(_peer_addr);
|
||||
getpeername(sock->rawFD(), &_peer_addr, &addr_len);
|
||||
}
|
||||
|
||||
WebRtcSession::~WebRtcSession() {
|
||||
InfoP(this);
|
||||
}
|
||||
|
||||
void WebRtcSession::onRecv(const Buffer::Ptr &buffer) {
|
||||
try {
|
||||
onRecv_l(buffer);
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
using namespace toolkit;
|
||||
|
||||
EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer);
|
||||
|
||||
class WebRtcSession : public UdpSession {
|
||||
public:
|
||||
WebRtcSession(const Socket::Ptr &sock);
|
||||
@ -30,6 +28,8 @@ public:
|
||||
void onManager() override;
|
||||
std::string getIdentifier() const override;
|
||||
|
||||
static EventPoller::Ptr queryPoller(const Buffer::Ptr &buffer);
|
||||
|
||||
private:
|
||||
void onRecv_l(const Buffer::Ptr &);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user