Merge pull request #1612 from xialixin/develop

Fix disconnect RTSP connection has assertion, resulting in program exit
pull/1633/head
winlin 5 years ago committed by GitHub
commit 12a74326e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -240,6 +240,11 @@ srs_error_t SrsRtspConn::serve()
return err;
}
std::string SrsRtspConn::remote_ip()
{
return "";
}
srs_error_t SrsRtspConn::do_cycle()
{
srs_error_t err = srs_success;
@ -684,6 +689,7 @@ SrsRtspCaster::SrsRtspCaster(SrsConfDirective* c)
output = _srs_config->get_stream_caster_output(c);
local_port_min = _srs_config->get_stream_caster_rtp_port_min(c);
local_port_max = _srs_config->get_stream_caster_rtp_port_max(c);
manager = new SrsCoroutineManager();
}
SrsRtspCaster::~SrsRtspCaster()
@ -691,10 +697,20 @@ SrsRtspCaster::~SrsRtspCaster()
std::vector<SrsRtspConn*>::iterator it;
for (it = clients.begin(); it != clients.end(); ++it) {
SrsRtspConn* conn = *it;
srs_freep(conn);
manager->remove(conn);
}
clients.clear();
used_ports.clear();
srs_freep(manager);
}
srs_error_t SrsRtspCaster::initialize()
{
srs_error_t err = srs_success;
if ((err = manager->start()) != srs_success) {
return srs_error_wrap(err, "start manager");
}
}
srs_error_t SrsRtspCaster::alloc_port(int* pport)
@ -747,6 +763,6 @@ void SrsRtspCaster::remove(SrsRtspConn* conn)
}
srs_info("rtsp: remove connection from caster.");
srs_freep(conn);
manager->remove(conn);
}

@ -100,7 +100,7 @@ public:
};
// The rtsp connection serve the fd.
class SrsRtspConn : public ISrsCoroutineHandler
class SrsRtspConn : public ISrsCoroutineHandler, public ISrsConnection
{
private:
std::string output_template;
@ -143,6 +143,7 @@ public:
virtual ~SrsRtspConn();
public:
virtual srs_error_t serve();
virtual std::string remote_ip();
private:
virtual srs_error_t do_cycle();
// internal methods
@ -179,6 +180,7 @@ private:
std::map<int, bool> used_ports;
private:
std::vector<SrsRtspConn*> clients;
SrsCoroutineManager* manager;
public:
SrsRtspCaster(SrsConfDirective* c);
virtual ~SrsRtspCaster();
@ -188,6 +190,7 @@ public:
virtual srs_error_t alloc_port(int* pport);
// Free the alloced rtp port.
virtual void free_port(int lpmin, int lpmax);
virtual srs_error_t initialize();
// Interface ISrsTcpHandler
public:
virtual srs_error_t on_tcp_client(srs_netfd_t stfd);

@ -179,6 +179,7 @@ SrsRtspListener::SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirec
srs_assert(type == SrsListenerRtsp);
if (type == SrsListenerRtsp) {
caster = new SrsRtspCaster(c);
caster->initialize();
}
}

@ -50,6 +50,7 @@ class ISrsUdpHandler;
class SrsUdpListener;
class SrsTcpListener;
class SrsAppCasterFlv;
class SrsRtspCaster;
class SrsCoroutineManager;
// The listener type for server to identify the connection,
@ -107,7 +108,7 @@ class SrsRtspListener : virtual public SrsListener, virtual public ISrsTcpHandle
{
private:
SrsTcpListener* listener;
ISrsTcpHandler* caster;
SrsRtspCaster* caster;
public:
SrsRtspListener(SrsServer* svr, SrsListenerType t, SrsConfDirective* c);
virtual ~SrsRtspListener();

Loading…
Cancel
Save