mirror of
https://github.com/ZLMediaKit/ZLMediaKit.git
synced 2024-11-25 20:27:34 +08:00
完善webrtc对象追踪相关日志
This commit is contained in:
parent
7f3f47abbb
commit
82b78f4544
@ -24,7 +24,6 @@ WebRtcPlayer::Ptr WebRtcPlayer::create(const EventPoller::Ptr &poller,
|
||||
WebRtcPlayer::WebRtcPlayer(const EventPoller::Ptr &poller,
|
||||
const RtspMediaSource::Ptr &src,
|
||||
const MediaInfo &info) : WebRtcTransportImp(poller) {
|
||||
InfoL << this;
|
||||
_media_info = info;
|
||||
_play_src = src;
|
||||
CHECK(_play_src);
|
||||
|
@ -24,7 +24,6 @@ WebRtcPusher::Ptr WebRtcPusher::create(const EventPoller::Ptr &poller,
|
||||
WebRtcPusher::WebRtcPusher(const EventPoller::Ptr &poller,
|
||||
const RtspMediaSource::Ptr &src,
|
||||
const MediaInfo &info) : WebRtcTransportImp(poller) {
|
||||
InfoL << this;
|
||||
_media_info = info;
|
||||
_push_src = src;
|
||||
CHECK(_push_src);
|
||||
|
@ -14,7 +14,6 @@
|
||||
WebRtcSession::WebRtcSession(const Socket::Ptr &sock) : UdpSession(sock) {
|
||||
socklen_t addr_len = sizeof(_peer_addr);
|
||||
getpeername(sock->rawFD(), &_peer_addr, &addr_len);
|
||||
InfoP(this);
|
||||
}
|
||||
|
||||
WebRtcSession::~WebRtcSession() {
|
||||
@ -61,9 +60,12 @@ void WebRtcSession::onRecv_l(const Buffer::Ptr &buffer) {
|
||||
if (_find_transport) {
|
||||
//只允许寻找一次transport
|
||||
_find_transport = false;
|
||||
_transport = WebRtcTransportImp::move(getUserName(buffer));
|
||||
auto user_name = getUserName(buffer);
|
||||
_identifier = user_name + '-' + to_string(reinterpret_cast<uint64_t>(this));
|
||||
_transport = WebRtcTransportImp::move(user_name);
|
||||
CHECK(_transport && _transport->getPoller()->isCurrentThread());
|
||||
_transport->setSession(shared_from_this());
|
||||
InfoP(this);
|
||||
}
|
||||
_ticker.resetTime();
|
||||
CHECK(_transport);
|
||||
@ -96,3 +98,8 @@ void WebRtcSession::onManager() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
std::string WebRtcSession::getIdentifier() const {
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
|
@ -28,11 +28,13 @@ public:
|
||||
void onRecv(const Buffer::Ptr &) override;
|
||||
void onError(const SockException &err) override;
|
||||
void onManager() override;
|
||||
std::string getIdentifier() const override;
|
||||
|
||||
private:
|
||||
void onRecv_l(const Buffer::Ptr &);
|
||||
|
||||
private:
|
||||
std::string _identifier;
|
||||
bool _find_transport = true;
|
||||
Ticker _ticker;
|
||||
struct sockaddr _peer_addr;
|
||||
|
@ -45,12 +45,12 @@ static onceToken token([]() {
|
||||
|
||||
WebRtcTransport::WebRtcTransport(const EventPoller::Ptr &poller) {
|
||||
_poller = poller;
|
||||
_identifier = to_string(reinterpret_cast<uint64_t>(this));
|
||||
}
|
||||
|
||||
void WebRtcTransport::onCreate(){
|
||||
_key = to_string(reinterpret_cast<uint64_t>(this));
|
||||
_dtls_transport = std::make_shared<RTC::DtlsTransport>(_poller, this);
|
||||
_ice_server = std::make_shared<RTC::IceServer>(this, _key, makeRandStr(24));
|
||||
_ice_server = std::make_shared<RTC::IceServer>(this, _identifier, makeRandStr(24));
|
||||
}
|
||||
|
||||
void WebRtcTransport::onDestory(){
|
||||
@ -62,8 +62,8 @@ const EventPoller::Ptr& WebRtcTransport::getPoller() const{
|
||||
return _poller;
|
||||
}
|
||||
|
||||
const string &WebRtcTransport::getKey() const {
|
||||
return _key;
|
||||
const string &WebRtcTransport::getIdentifier() const {
|
||||
return _identifier;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@ -310,11 +310,11 @@ void WebRtcTransportImp::onCreate(){
|
||||
}
|
||||
|
||||
WebRtcTransportImp::WebRtcTransportImp(const EventPoller::Ptr &poller) : WebRtcTransport(poller) {
|
||||
InfoL << this;
|
||||
InfoL << getIdentifier();
|
||||
}
|
||||
|
||||
WebRtcTransportImp::~WebRtcTransportImp() {
|
||||
InfoL << this;
|
||||
InfoL << getIdentifier();
|
||||
}
|
||||
|
||||
void WebRtcTransportImp::onDestory() {
|
||||
@ -889,7 +889,7 @@ public:
|
||||
|
||||
void WebRtcTransportImp::registerSelf() {
|
||||
_self = static_pointer_cast<WebRtcTransportImp>(shared_from_this());
|
||||
WebRtcTransportManager::instance().addItem(getKey(), _self);
|
||||
WebRtcTransportManager::instance().addItem(getIdentifier(), _self);
|
||||
}
|
||||
|
||||
void WebRtcTransportImp::unrefSelf() {
|
||||
@ -898,7 +898,7 @@ void WebRtcTransportImp::unrefSelf() {
|
||||
|
||||
void WebRtcTransportImp::unregisterSelf() {
|
||||
unrefSelf();
|
||||
WebRtcTransportManager::instance().removeItem(getKey());
|
||||
WebRtcTransportManager::instance().removeItem(getIdentifier());
|
||||
}
|
||||
|
||||
WebRtcTransportImp::Ptr WebRtcTransportImp::get(const string &key) {
|
||||
|
@ -77,7 +77,7 @@ public:
|
||||
void sendRtcpPacket(const char *buf, int len, bool flush, void *ctx = nullptr);
|
||||
|
||||
const EventPoller::Ptr& getPoller() const;
|
||||
const string& getKey() const;
|
||||
const string& getIdentifier() const;
|
||||
|
||||
protected:
|
||||
//// dtls相关的回调 ////
|
||||
@ -130,7 +130,7 @@ protected:
|
||||
|
||||
private:
|
||||
uint8_t _srtp_buf[2000];
|
||||
string _key;
|
||||
string _identifier;
|
||||
EventPoller::Ptr _poller;
|
||||
std::shared_ptr<RTC::IceServer> _ice_server;
|
||||
std::shared_ptr<RTC::DtlsTransport> _dtls_transport;
|
||||
|
Loading…
Reference in New Issue
Block a user