Hi Ross,

Thanks for the suggestion. I have tried to solve this according to your advice, but no (complete) success yet.

* It works .. almost.
* I am receiving frames .. then I cut the internet connection and put it on again .. restart tasks are working ok, rtsp negotiation starts and I start getting frames again .. * .. however, when the program starts receiving frames again, I get each frame twice !
* It seems as if I had not closed down the media streams.
* .. however, I am doing exacly this as you can see from the code below
* I think I should be calling "Medium::close" also to the client instance, but if I try to do this (see the sectios marked with "program breaks"), the task functions seem to break


Details follow.  Any tip highly appreciated!

Regards,

Sampsa


1) I have a scheduled watchdog process (that reschedules itself to get a periodic checking) that checks if frames have arrived. If no frame has arrived in x time, the watchdog launches:

env.taskScheduler().scheduleDelayedTask(1*1000*1000,(TaskFunc*)restartMeTask,(void*)client); [here client is a pointer of the type MyRTSPClient]

2) In "continueAfterDESCRIBE" I do the following (please note that here we are using "restartMeTask0" instead of "restartMeTask" .. these are declared below):

-------------------
void continueAfterDESCRIBE(RTSPClient* client, int resultCode, char* resultString) {
  ...
  if (resultCode!=0) {
      env << "could not get SDP info.. lets do this again\n";
((MyRTSPClient*)client)->mytask=env.taskScheduler().scheduleDelayedTask(5*1000*1000,(TaskFunc*)restartMeTask0,(void*)client);
      return;
    }
  ...
  session=MediaSession::createNew(env, resultString);
  ...
  if (session==NULL) {
    env << "Empty media session!  Let's do this again\n";
((MyRTSPClient*)client)->mytask=env.taskScheduler().scheduleDelayedTask(5*1000*1000,(TaskFunc*)restartMeTask0,(void*)client);
    return;
  }
  ...
-----------------

3) The restart tasks look as follows:

-----------------


void restartMeTask0(void* cdata) { // this is for cases when no MediaSession could be created (called from continueAfterDESCRIBE)
  MyRTSPClient* oldclient;
  MyRTSPClient* newclient;

  std::cout << "\nrestartMeTask0!\n";
  oldclient=(MyRTSPClient*)cdata;

  std::cout << "\nrestartMeTask0: re-creating client\n";
newclient=MyRTSPClient::createNew(oldclient->envir(),oldclient->url(),oldclient->po,1,"restarted");

  /* // program breaks
  std::cout << "closing client..\n";
  Medium::close(oldclient); // here? nope ..
  std::cout << ".. client closed \n";
  */

  std::cout << "\nrestartMeTask0: starting client\n";
  newclient->sendDescribeCommand(continueAfterDESCRIBE);
}


void restartMeTask(void* cdata) { // in this version, we shut down subsession sinks (i.e. we got frames at some instant, but then they stopped coming)
  MyRTSPClient* oldclient;
  MyRTSPClient* newclient;
  MediaSubsession* subsession;

  std::cout << "\nrestartMeTask!\n";
  oldclient=(MyRTSPClient*)cdata;

  std::cout << "\nrestartMeTask 2!\n";
  if (oldclient->currentsession != NULL) {
    std::cout << "\nFound MediaSession\n";
MediaSubsessionIterator iter(*(oldclient->currentsession)); // crashes here if there was no decent MediaSession
    std::cout << "\nGot iterator\n";
    while ((subsession = iter.next()) != NULL) {
      std::cout << "closing subsession..\n";
Medium::close(subsession->sink); // we're closing the sinks here, so we should not be receiving frames from them anymore, right?
      subsession->sink=NULL;
      std::cout << "..closed subsession\n";
      }
  }

  std::cout << "\nrestartMeTask: re-creating client\n";
newclient=MyRTSPClient::createNew(oldclient->envir(),oldclient->url(),oldclient->po,1,"restarted");

  /* // program breaks
  std::cout << "closing client..\n";
  Medium::close(oldclient);
  std::cout << ".. client closed \n";
  */

  std::cout << "\nrestartMeTask: starting client\n";
  newclient->sendDescribeCommand(continueAfterDESCRIBE);

  /* // program breaks
  std::cout << "closing client..\n";
  Medium::close(oldclient);
  std::cout << ".. client closed \n";
  */
}


On 04.08.2016 17:59, Ross Finlayson wrote:
If an error occurs when sending a RTSP command, the “RTSPClient” object gets 
reset - which includes setting its “rtsp://“ URL to NULL.  The only way to then 
send another command is to do so using a *new* “RTSPClient” object.  I.e.,
        - call Medlium::close() on the existing “RTSPClient” object, then
        - create a new “RTSPClient” object (with the proper “rtsp://“ URL), then
        - call “sendDescribeCommand()” on the new “RTSPClient” object


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/


_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to