[Live-devel] live555MediaServer refresh

Nadir Raimondo raimondo at ismb.it
Tue Jul 8 01:09:46 PDT 2014


Dear all,

we are trying to use the live555MediaServer to stream MPEG2 transport 
stream files which size grow continuously due to a separated process 
that appends data to both transport stream (.ts) and transport stream 
index files (.tsx).

After the first RTSP request (DESCRIBE or PLAY) the server seems to 
parse the tsx file and saves the transport stream duration (inside a 
Server Media Session?).  All the subsequent DESCRIBE requests return the 
saved time range even if the file duration is grown. If a PLAY request 
with npt > duration is generated the server seek only to the last saved 
duration ignoring the actual npt.

We know that this is the desired behavior but we need the media server 
to dynamically update the file duration. Does anyone know if this is 
possible?
In order to do so, we have tried to modify DynamicRTSPServer.cpp in 
function lookupServerMediaSession: instead of using pre existent Server 
Media Session we remove and recreate it at each incoming RTSP request.

The original code was:

    ServerMediaSession*
    DynamicRTSPServer::lookupServerMediaSession(char const* streamName) {
       // First, check whether the specified "streamName" exists as a
    local file:
       FILE* fid = fopen(streamName, "rb");
       Boolean fileExists = fid != NULL;

       // Next, check whether we already have a "ServerMediaSession" for
    this file:
       ServerMediaSession* sms =
    RTSPServer::lookupServerMediaSession(streamName);
       Boolean smsExists = sms != NULL;

       // Handle the four possibilities for "fileExists" and "smsExists":
       if (!fileExists) {
         if (smsExists) {
           // "sms" was created for a file that no longer exists. Remove
    it:
           removeServerMediaSession(sms);
         }
         return NULL;
       } else {
         if (!smsExists) {
           // Create a new "ServerMediaSession" object for streaming
    from the named file.
           sms = createNewSMS(envir(), streamName, fid);
           addServerMediaSession(sms);
         }
         fclose(fid);
         return sms;
       }
    }


Our modified version is:

    ServerMediaSession*
    DynamicRTSPServer::lookupServerMediaSession(char const* streamName) {
       // First, check whether the specified "streamName" exists as a
    local file:
       FILE* fid = fopen(streamName, "rb");
       Boolean fileExists = fid != NULL;

       // Next, check whether we already have a "ServerMediaSession" for
    this file:
       ServerMediaSession* sms =
    RTSPServer::lookupServerMediaSession(streamName);
       Boolean smsExists = sms != NULL;

       // Handle the four possibilities for "fileExists" and "smsExists":
       if (!fileExists) {
         if (smsExists) {
           // "sms" was created for a file that no longer exists. Remove
    it:
           removeServerMediaSession(sms);
         }
         return NULL;
       } else {
         if(smsExists) {
    removeServerMediaSession(sms);
             sms=NULL;
         }
         sms = createNewSMS(envir(), streamName, fid);
    addServerMediaSession(sms);
         fclose(fid);
         return sms;
       }
    }


This way it seems to work, but we are not sure if we did it in the right 
way. Actually we are worried about possible concurrency issues (e.g. 
what if a new request deleting a previous session that is still in 
use?). Do you think we can go on using this little hack or we should 
approach the problem in another way?

Thanks in advance
Nadir



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.live555.com/pipermail/live-devel/attachments/20140708/53df2d8a/attachment.html>


More information about the live-devel mailing list