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