Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix rtc over tcp crash when stop rtc publish. #4222

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions trunk/src/app/srs_app_rtc_network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,12 @@ SrsRtcTcpConn::SrsRtcTcpConn(ISrsProtocolReadWriter* skt, std::string cip, int p
delta_->set_io(skt_, skt_);
session_ = NULL;
pkt_ = new char[SRS_RTC_TCP_PACKET_MAX];
_srs_rtc_manager->subscribe(this);
}

SrsRtcTcpConn::~SrsRtcTcpConn()
{
_srs_rtc_manager->unsubscribe(this);
srs_freepa(pkt_);
srs_freep(delta_);
srs_freep(skt_);
Expand Down Expand Up @@ -808,6 +810,23 @@ srs_error_t SrsRtcTcpConn::cycle()
return srs_success;
}

void SrsRtcTcpConn::on_before_dispose(ISrsResource* c)
{
SrsRtcConnection* session = dynamic_cast<SrsRtcConnection*>(c);
if (session && session == session_) {
if (session_->tcp()->is_establelished()) {
session_->tcp()->set_state(SrsRtcNetworkStateClosed);
session_->expire();
}

session_ = NULL;
}
}

void SrsRtcTcpConn::on_disposing(ISrsResource* c)
{
}

srs_error_t SrsRtcTcpConn::do_cycle()
{
srs_error_t err = srs_success;
Expand Down
6 changes: 5 additions & 1 deletion trunk/src/app/srs_app_rtc_network.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class SrsRtcTcpNetwork: public ISrsRtcNetwork
};

// For WebRTC over TCP.
class SrsRtcTcpConn : public ISrsConnection, public ISrsCoroutineHandler, public ISrsExecutorHandler
class SrsRtcTcpConn : public ISrsConnection, public ISrsCoroutineHandler, public ISrsExecutorHandler, public ISrsDisposingHandler
{
private:
// Because session references to this object, so we should directly use the session ptr.
Expand Down Expand Up @@ -277,6 +277,10 @@ class SrsRtcTcpConn : public ISrsConnection, public ISrsCoroutineHandler, public
// Interface ISrsCoroutineHandler
public:
virtual srs_error_t cycle();
// Interface ISrsDisposingHandler
public:
virtual void on_before_dispose(ISrsResource* c);
virtual void on_disposing(ISrsResource* c);
private:
virtual srs_error_t do_cycle();
srs_error_t handshake();
Expand Down
Loading