<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none"><!-- p { margin-top: 0px; margin-bottom: 0px; }--></style>
</head>
<body dir="ltr" style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>Ross,<br>
</p>
<p><br>
</p>
<p>We are wanting to know when a session is cleaned up. I found the livenessTimoutTask is called when the reclaim timer expires, but I can not get to it from a sub-class. I also see the new noteLiveness() override in the ServerMediaSession. Instead of me
tracking my own liveness, I added an livenessTimeouTask() to the ServerMediaSession (just like the noteLiveness) so I can be informed of the session that was cleaned up. So in the GenericMediaServer I added a call to the livenesstimeoutTask() in the ServerMediaSession
(just like you did for noteLiveness). I pass the session id and streamname. Is there a different way to do this? If not would it be possible to get this in to future source?<br>
</p>
<p><br>
</p>
<p>Here is my patch:<br>
</p>
<p><br>
</p>
<div><span style="font-family: 'Courier New', monospace;">diff -r 9e993be31201 liveMedia/GenericMediaServer.cpp</span></div>
<div><span style="font-family: 'Courier New', monospace;">--- a/liveMedia/GenericMediaServer.cpp</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Wed Aug 17 13:52:57 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">+++ b/liveMedia/GenericMediaServer.cpp</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Fri Aug 19 11:26:39 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">@@ -302,12 +302,17 @@</span></div>
<div> </div>
<div><span style="font-family: 'Courier New', monospace;"> void GenericMediaServer::ClientSession::livenessTimeoutTask(ClientSession* clientSession) {</span></div>
<div><span style="font-family: 'Courier New', monospace;"> // If this gets called, the client session is assumed to have timed out, so delete it:</span></div>
<div><span style="font-family: 'Courier New', monospace;">-#ifdef DEBUG</span></div>
<div><span style="font-family: 'Courier New', monospace;"> char const* streamName</span></div>
<div><span style="font-family: 'Courier New', monospace;"> = (clientSession->fOurServerMediaSession == NULL) ? "???" : clientSession->fOurServerMediaSession->streamName();</span></div>
<div><span style="font-family: 'Courier New', monospace;">+#ifdef DEBUG</span></div>
<div><span style="font-family: 'Courier New', monospace;"> fprintf(stderr, "Client session (id \"%08X\", stream name \"%s\") has timed out (due to inactivity)\n",</span></div>
<div><span style="font-family: 'Courier New', monospace;"> </span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;"> clientSession->fOurSessionId, streamName);</span></div>
<div><span style="font-family: 'Courier New', monospace;"> #endif</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // If we have a media session we can call the livenessTimeoutTask for that media session</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // This is similar to the noteLiveness()</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ if (clientSession->fOurServerMediaSession != NULL) {</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ clientSession->fOurServerMediaSession->livenessTimeoutTask(clientSession->fOurSessionId, streamName);</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ }</span></div>
<div><span style="font-family: 'Courier New', monospace;"> delete clientSession;</span></div>
<div><span style="font-family: 'Courier New', monospace;"> }</span></div>
<div> </div>
<div><span style="font-family: 'Courier New', monospace;">diff -r 9e993be31201 liveMedia/ServerMediaSession.cpp</span></div>
<div><span style="font-family: 'Courier New', monospace;">--- a/liveMedia/ServerMediaSession.cpp</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Wed Aug 17 13:52:57 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">+++ b/liveMedia/ServerMediaSession.cpp</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Fri Aug 19 11:26:39 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">@@ -198,6 +198,11 @@</span></div>
<div><span style="font-family: 'Courier New', monospace;"> // default implementation: do nothing</span></div>
<div><span style="font-family: 'Courier New', monospace;"> }</span></div>
<div> </div>
<div><span style="font-family: 'Courier New', monospace;">+void ServerMediaSession::livenessTimeoutTask(u_int32_t sessionId, char const *streamName) {</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // default implementation: do nothing</span></div>
<div><span style="font-family: 'Courier New', monospace;">+}</span></div>
<div><span style="font-family: 'Courier New', monospace;">+</span></div>
<div><span style="font-family: 'Courier New', monospace;">+</span></div>
<div><span style="font-family: 'Courier New', monospace;"> void ServerMediaSession::deleteAllSubsessions() {</span></div>
<div><span style="font-family: 'Courier New', monospace;"> Medium::close(fSubsessionsHead);</span></div>
<div><span style="font-family: 'Courier New', monospace;"> fSubsessionsHead = fSubsessionsTail = NULL;</span></div>
<div><span style="font-family: 'Courier New', monospace;">diff -r 9e993be31201 liveMedia/include/ServerMediaSession.hh</span></div>
<div><span style="font-family: 'Courier New', monospace;">--- a/liveMedia/include/ServerMediaSession.hh</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Wed Aug 17 13:52:57 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">+++ b/liveMedia/include/ServerMediaSession.hh</span><span class="Apple-tab-span" style="white-space: pre; font-family: 'Courier New', monospace;">
</span><span style="font-family: 'Courier New', monospace;">Fri Aug 19 11:26:39 2016 -0600</span></div>
<div><span style="font-family: 'Courier New', monospace;">@@ -62,6 +62,11 @@</span></div>
<div><span style="font-family: 'Courier New', monospace;"> // The default implementation does nothing, but subclasses can redefine this - e.g., if you</span></div>
<div><span style="font-family: 'Courier New', monospace;"> // want to remove long-unused "ServerMediaSession"s from the server.</span></div>
<div> </div>
<div><span style="font-family: 'Courier New', monospace;">+ virtual void livenessTimeoutTask(u_int32_t sessionId, char const *streamName);</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // called when a client is cleaned up due to the timeout expiring</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // The default implementation does nothing, but subclasses can redefine this - e.g., if you</span></div>
<div><span style="font-family: 'Courier New', monospace;">+ // want to know if long-unused "ServerMediaSession"s is removed sub-class this method.</span></div>
<div><span style="font-family: 'Courier New', monospace;">+</span></div>
<div><span style="font-family: 'Courier New', monospace;"> unsigned referenceCount() const { return fReferenceCount; }</span></div>
<div><span style="font-family: 'Courier New', monospace;"> void incrementReferenceCount() { ++fReferenceCount; }</span></div>
<div><span style="font-family: 'Courier New', monospace;"> void decrementReferenceCount() { if (fReferenceCount > 0) --fReferenceCount; }</span></div>
<div><br>
<br>
</div>
<div>Thanks,<br>
</div>
<div>Craig<br>
</div>
<div><br>
</div>
<p><br>
</p>
</body>
</html>