mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-26 12:37:09 +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) {
|
if (!buf) {
|
||||||
return Socket::createSocket(poller, false);
|
return Socket::createSocket(poller, false);
|
||||||
}
|
}
|
||||||
auto new_poller = QueryPollerByBuffer(buf);
|
auto new_poller = WebRtcSession::queryPoller(buf);
|
||||||
if (!new_poller) {
|
if (!new_poller) {
|
||||||
//该数据对应的webrtc对象未找到,丢弃之
|
//该数据对应的webrtc对象未找到,丢弃之
|
||||||
return Socket::Ptr();
|
return Socket::Ptr();
|
||||||
|
@ -11,15 +11,6 @@
|
|||||||
#include "WebRtcSession.h"
|
#include "WebRtcSession.h"
|
||||||
#include "Util/util.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) {
|
static string getUserName(const Buffer::Ptr &buffer) {
|
||||||
auto buf = buffer->data();
|
auto buf = buffer->data();
|
||||||
auto len = buffer->size();
|
auto len = buffer->size();
|
||||||
@ -39,7 +30,7 @@ static string getUserName(const Buffer::Ptr &buffer) {
|
|||||||
return vec[0];
|
return vec[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer) {
|
EventPoller::Ptr WebRtcSession::queryPoller(const Buffer::Ptr &buffer) {
|
||||||
auto user_name = getUserName(buffer);
|
auto user_name = getUserName(buffer);
|
||||||
if (user_name.empty()) {
|
if (user_name.empty()) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -48,6 +39,17 @@ EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer) {
|
|||||||
return ret ? ret->getPoller() : nullptr;
|
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) {
|
void WebRtcSession::onRecv(const Buffer::Ptr &buffer) {
|
||||||
try {
|
try {
|
||||||
onRecv_l(buffer);
|
onRecv_l(buffer);
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
|
|
||||||
using namespace toolkit;
|
using namespace toolkit;
|
||||||
|
|
||||||
EventPoller::Ptr QueryPollerByBuffer(const Buffer::Ptr &buffer);
|
|
||||||
|
|
||||||
class WebRtcSession : public UdpSession {
|
class WebRtcSession : public UdpSession {
|
||||||
public:
|
public:
|
||||||
WebRtcSession(const Socket::Ptr &sock);
|
WebRtcSession(const Socket::Ptr &sock);
|
||||||
@ -30,6 +28,8 @@ public:
|
|||||||
void onManager() override;
|
void onManager() override;
|
||||||
std::string getIdentifier() const override;
|
std::string getIdentifier() const override;
|
||||||
|
|
||||||
|
static EventPoller::Ptr queryPoller(const Buffer::Ptr &buffer);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void onRecv_l(const Buffer::Ptr &);
|
void onRecv_l(const Buffer::Ptr &);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user