[Live-devel] All client termination

Звягинцев Антон zvyagintsev at atlantis.ru
Tue Sep 11 00:09:09 PDT 2012


Hello.

I am looking for safe code to terminate all active RTSPClient (and their
connections) without stopping main Live555 loop.

Right now Live555 loop run in separate thread. The clean up function can be
called from the another thread and looks like this:

 

void RTSPSession::cleanup()

{

       HashTable const& objects =
MediaLookupTable::ourMedia(*m_pliveenvironment)->getTable();

 

       HashTable::Iterator* piterator =
HashTable::Iterator::create(objects);

 

       MediaSession* pmediasession;

       vector<MediaSession*> clients;

       char const* key;

 

       while ( (pmediasession = (MediaSession*)piterator->next(key)) != NULL
)

             if (pmediasession->isRTSPClient())
clients.push_back(pmediasession);

 

       delete piterator;

 

       for_each(clients.begin(), clients.end(),
bind1st(mem_fun(&RTSPSession::delete_client), this));

}

 

void RTSPSession::delete_client(MediaSession* medium)

{

       ((myRTSPClient*)medium)->shutdown();

}

 

void myRTSPClient::shutdown()

{

       MediaSubsession* psubsession;

       unsigned int total = 0;

 

       if (m_pmediasession)

       {

             MediaSubsessionIterator iterator(*m_pmediasession);

 

             while((psubsession = iterator.next()) != 0)

                    total += shutdown(psubsession);

 

             if (total) sendTeardownCommand(*m_pmediasession, 0);

       }

 

       Medium::close(this);

}

 

...

 

virtual myRTSPClient::~myRTSPClient()

{

...

       if (m_pmediasession) Medium::close(m_pmediasession);

...

}

 

But i am not sure - maybe the safest and more easiest way (without direct
interaction with underlying hashtable) exist to do forcibly disconnection
and cleaning up of all existed clients?

 

ps Again, I don't want to stop Live555 loop so it is possible the data can
arrive at any moment so I also need to guard this and prevent any client
code if cleanup procedure is started.

 

WBR,

Anton

 

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20120911/9d68c93f/attachment-0001.html>


More information about the live-devel mailing list