title: QT-C++ errors implementing live555 in qt application
body: <p>I'm using QT5.02 on ubuntu 12.04 and the last release of live555.</p>
  
  <p>This is my class (CameraStream.cpp) that will read the rtsp stream:</p>
  
  <pre><code>#include "CameraStream.h"
  #include &lt;DummySink.h&gt;
  #include &lt;ourRTSPClient.h&gt;
  #include "liveMedia.hh"
  #include "BasicUsageEnvironment.hh"
  
  CameraStream::CameraStream(){
      eventLoopWatchVariable = 0;
  
      // Begin by setting up our usage environment:
      TaskScheduler* scheduler = BasicTaskScheduler::createNew();
      UsageEnvironment* env = BasicUsageEnvironment::createNew(*scheduler);
  
      openURL(*env, "argv[0]", "rtsp://admin@192.168.1.99:1234/file.sdp");
  
      // All subsequent activity takes place within the event loop:
      env-&gt;taskScheduler().doEventLoop(&amp;eventLoopWatchVariable);
  
  }
  
  #define RTSP_CLIENT_VERBOSITY_LEVEL 1 
  
  static unsigned rtspClientCount = 0; 
  
  void CameraStream::openURL(UsageEnvironment&amp; env, char const* progName, char const* rtspURL) {
  
      RTSPClient* rtspClient = ourRTSPClient::createNew(env, rtspURL, RTSP_CLIENT_VERBOSITY_LEVEL, progName);
      if (rtspClient == NULL) {
          env &lt;&lt; "Failed to create a RTSP client for URL \"" &lt;&lt; rtspURL &lt;&lt; "\": " &lt;&lt; env.getResultMsg() &lt;&lt; "\n";
          return;
      }
  
      ++rtspClientCount;
  
      rtspClient-&gt;sendDescribeCommand(continueAfterDESCRIBE);
  }
  
  
  // Implementation of the RTSP 'response handlers':
  
  void CameraStream::continueAfterDESCRIBE(RTSPClient* rtspClient, int resultCode, char* resultString) {
      do {
          UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
          StreamClientState&amp; scs = ((ourRTSPClient*)rtspClient)-&gt;scs; // alias
  
          if (resultCode != 0) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to get a SDP description: " &lt;&lt; resultString &lt;&lt; "\n";
              delete[] resultString;
              break;
          }
  
           char* const sdpDescription = resultString;
           env &lt;&lt; *rtspClient &lt;&lt; "Got a SDP description:\n" &lt;&lt; sdpDescription &lt;&lt; "\n";
  
          // Create a media session object from this SDP description:
          scs.session = MediaSession::createNew(env, sdpDescription);
          delete[] sdpDescription; // because we don't need it anymore
          if (scs.session == NULL) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to create a MediaSession object from the SDP description: " &lt;&lt; env.getResultMsg() &lt;&lt; "\n";
              break;
          } else if (!scs.session-&gt;hasSubsessions()) {
              env &lt;&lt; *rtspClient &lt;&lt; "This session has no media subsessions (i.e., no \"m=\" lines)\n";
              break;
           }
  
           scs.iter = new MediaSubsessionIterator(*scs.session);
           setupNextSubsession(rtspClient);
           return;
      } while (0);
  
      // An unrecoverable error occurred with this stream.
      shutdownStream(rtspClient);
  }
  
  // By default, we request that the server stream its data using RTP/UDP.
  // If, instead, you want to request that the server stream via RTP-over-TCP, change the following to True:
  #define REQUEST_STREAMING_OVER_TCP False
  
  void CameraStream::setupNextSubsession(RTSPClient* rtspClient) {
      UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
      StreamClientState&amp; scs = ((ourRTSPClient*)rtspClient)-&gt;scs; // alias
  
      scs.subsession = scs.iter-&gt;next();
      if (scs.subsession != NULL) {
          if (!scs.subsession-&gt;initiate()) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to initiate the \"" &lt;&lt; *scs.subsession &lt;&lt; "\" subsession: " &lt;&lt; env.getResultMsg() &lt;&lt; "\n";
              setupNextSubsession(rtspClient); // give up on this subsession; go to the next one
          } else {
              env &lt;&lt; *rtspClient &lt;&lt; "Initiated the \"" &lt;&lt; *scs.subsession
              &lt;&lt; "\" subsession (client ports " &lt;&lt; scs.subsession-&gt;clientPortNum() &lt;&lt; "-" &lt;&lt; scs.subsession-&gt;clientPortNum()+1 &lt;&lt; ")\n";
  
              // Continue setting up this subsession, by sending a RTSP "SETUP" command:
              rtspClient-&gt;sendSetupCommand(*scs.subsession, continueAfterSETUP, False, REQUEST_STREAMING_OVER_TCP);
          }
          return;
      }
  
      // We've finished setting up all of the subsessions.  Now, send a RTSP "PLAY" command to start the streaming:
      if (scs.session-&gt;absStartTime() != NULL) {
          // Special case: The stream is indexed by 'absolute' time, so send an appropriate "PLAY" command:
          rtspClient-&gt;sendPlayCommand(*scs.session, continueAfterPLAY, scs.session-&gt;absStartTime(), scs.session-&gt;absEndTime());
      } else {
          scs.duration = scs.session-&gt;playEndTime() - scs.session-&gt;playStartTime();
          rtspClient-&gt;sendPlayCommand(*scs.session, continueAfterPLAY);
      }
  }
  
  void CameraStream::continueAfterSETUP(RTSPClient* rtspClient, int resultCode, char* resultString) {
      do {
          UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
          StreamClientState&amp; scs = ((ourRTSPClient*)rtspClient)-&gt;scs; // alias
  
          if (resultCode != 0) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to set up the \"" &lt;&lt; *scs.subsession &lt;&lt; "\" subsession: " &lt;&lt; resultString &lt;&lt; "\n";
              break;
          }
  
          env &lt;&lt; *rtspClient &lt;&lt; "Set up the \"" &lt;&lt; *scs.subsession
          &lt;&lt; "\" subsession (client ports " &lt;&lt; scs.subsession-&gt;clientPortNum() &lt;&lt; "-" &lt;&lt; scs.subsession-&gt;clientPortNum()+1 &lt;&lt; ")\n";
  
          // Having successfully setup the subsession, create a data sink for it, and call "startPlaying()" on it.
          // (This will prepare the data sink to receive data; the actual flow of data from the client won't start happening until later,
          // after we've sent a RTSP "PLAY" command.)
  
          scs.subsession-&gt;sink = DummySink::createNew(env, *scs.subsession, rtspClient-&gt;url());
          // perhaps use your own custom "MediaSink" subclass instead
          if (scs.subsession-&gt;sink == NULL) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to create a data sink for the \"" &lt;&lt; *scs.subsession
              &lt;&lt; "\" subsession: " &lt;&lt; env.getResultMsg() &lt;&lt; "\n";
              break;
          }
  
          env &lt;&lt; *rtspClient &lt;&lt; "Created a data sink for the \"" &lt;&lt; *scs.subsession &lt;&lt; "\" subsession\n";
          scs.subsession-&gt;miscPtr = rtspClient; // a hack to let subsession handle functions get the "RTSPClient" from the subsession
          scs.subsession-&gt;sink-&gt;startPlaying(*(scs.subsession-&gt;readSource()),
                                         subsessionAfterPlaying, scs.subsession);
      // Also set a handler to be called if a RTCP "BYE" arrives for this subsession:
          if (scs.subsession-&gt;rtcpInstance() != NULL) {
              scs.subsession-&gt;rtcpInstance()-&gt;setByeHandler(subsessionByeHandler, scs.subsession);
          }
      } while (0);
      delete[] resultString;
  
      // Set up the next subsession, if any:
      setupNextSubsession(rtspClient);
  }
  
  void CameraStream::continueAfterPLAY(RTSPClient* rtspClient, int resultCode, char* resultString) {
      Boolean success = False;
  
      do {
          UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
          StreamClientState&amp; scs = ((ourRTSPClient*)rtspClient)-&gt;scs; // alias
  
          if (resultCode != 0) {
              env &lt;&lt; *rtspClient &lt;&lt; "Failed to start playing session: " &lt;&lt; resultString &lt;&lt; "\n";
              break;
          }
  
          // Set a timer to be handled at the end of the stream's expected duration (if the stream does not already signal its end
          // using a RTCP "BYE").  This is optional.  If, instead, you want to keep the stream active - e.g., so you can later
          // 'seek' back within it and do another RTSP "PLAY" - then you can omit this code.
          // (Alternatively, if you don't want to receive the entire stream, you could set this timer for some shorter value.)
          if (scs.duration &gt; 0) {
              unsigned const delaySlop = 2; // number of seconds extra to delay, after the stream's expected duration.  (This is optional.)
              scs.duration += delaySlop;
              unsigned uSecsToDelay = (unsigned)(scs.duration*1000000);
              scs.streamTimerTask = env.taskScheduler().scheduleDelayedTask(uSecsToDelay, (TaskFunc*)streamTimerHandler, rtspClient);
          }
  
          env &lt;&lt; *rtspClient &lt;&lt; "Started playing session";
          if (scs.duration &gt; 0) {
              env &lt;&lt; " (for up to " &lt;&lt; scs.duration &lt;&lt; " seconds)";
          }
          env &lt;&lt; "...\n";
  
          success = True;
      } while (0);
      delete[] resultString;
  
      if (!success) {
          // An unrecoverable error occurred with this stream.
          shutdownStream(rtspClient);
      }
  }
  
  
  // Implementation of the other event handlers:
  
  void CameraStream::subsessionAfterPlaying(void* clientData) {
      MediaSubsession* subsession = (MediaSubsession*)clientData;
      RTSPClient* rtspClient = (RTSPClient*)(subsession-&gt;miscPtr);
  
      // Begin by closing this subsession's stream:
      Medium::close(subsession-&gt;sink);
      subsession-&gt;sink = NULL;
  
      // Next, check whether *all* subsessions' streams have now been closed:
      MediaSession&amp; session = subsession-&gt;parentSession();
      MediaSubsessionIterator iter(session);
      while ((subsession = iter.next()) != NULL) {
          if (subsession-&gt;sink != NULL) return; // this subsession is still active
      }
  
      // All subsessions' streams have now been closed, so shutdown the client:
      shutdownStream(rtspClient);
  }
  
  void CameraStream::subsessionByeHandler(void* clientData) {
      MediaSubsession* subsession = (MediaSubsession*)clientData;
      RTSPClient* rtspClient = (RTSPClient*)subsession-&gt;miscPtr;
      UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
  
      env &lt;&lt; *rtspClient &lt;&lt; "Received RTCP \"BYE\" on \"" &lt;&lt; *subsession &lt;&lt; "\" subsession\n";
  
      // Now act as if the subsession had closed:
      subsessionAfterPlaying(subsession);
  }
  
  void CameraStream::streamTimerHandler(void* clientData) {
      ourRTSPClient* rtspClient = (ourRTSPClient*)clientData;
      StreamClientState&amp; scs = rtspClient-&gt;scs; // alias
  
      scs.streamTimerTask = NULL;
  
      // Shut down the stream:
      shutdownStream(rtspClient);
  }
  
  void CameraStream::shutdownStream(RTSPClient* rtspClient, int exitCode) {
      UsageEnvironment&amp; env = rtspClient-&gt;envir(); // alias
      StreamClientState&amp; scs = ((ourRTSPClient*)rtspClient)-&gt;scs; // alias
  
      // First, check whether any subsessions have still to be closed:
      if (scs.session != NULL) {
          Boolean someSubsessionsWereActive = False;
          MediaSubsessionIterator iter(*scs.session);
          MediaSubsession* subsession;
  
          while ((subsession = iter.next()) != NULL) {
              if (subsession-&gt;sink != NULL) {
                  Medium::close(subsession-&gt;sink);
                  subsession-&gt;sink = NULL;
  
                  if (subsession-&gt;rtcpInstance() != NULL) {
                      subsession-&gt;rtcpInstance()-&gt;setByeHandler(NULL, NULL); // in case the server sends a RTCP "BYE" while handling "TEARDOWN"
                  }
  
                  someSubsessionsWereActive = True;
              }
          }
  
          if (someSubsessionsWereActive) {
              // Send a RTSP "TEARDOWN" command, to tell the server to shutdown the stream.
              // Don't bother handling the response to the "TEARDOWN".
              rtspClient-&gt;sendTeardownCommand(*scs.session, NULL);
          }
      }
  
      env &lt;&lt; *rtspClient &lt;&lt; "Closing the stream.\n";
      Medium::close(rtspClient);
      // Note that this will also cause this stream's "StreamClientState" structure to get reclaimed.
  
      if (--rtspClientCount == 0) {
          // The final stream has ended, so exit the application now.
          // (Of course, if you're embedding this code into your own application, you might want to comment this out,
          // and replace it with "eventLoopWatchVariable = 1;", so that we leave the LIVE555 event loop, and continue running "main()".)
          exit(exitCode);
      }
  }
  
  UsageEnvironment&amp; operator&lt;&lt;(UsageEnvironment&amp; env, const RTSPClient&amp; rtspClient) {
      return env &lt;&lt; "[URL:\"" &lt;&lt; rtspClient.url() &lt;&lt; "\"]: ";
  }
  
  UsageEnvironment&amp; operator&lt;&lt;(UsageEnvironment&amp; env, const MediaSubsession&amp; subsession) {
      return env &lt;&lt; subsession.mediumName() &lt;&lt; "/" &lt;&lt; subsession.codecName();
  }
  </code></pre>
  
  <p>And this is the file header (CameraStream.h):</p>
  
  <pre><code>#ifndef CAMERASTREAM_H
  #define CAMERASTREAM_H
  
  #include &lt;liveMedia.hh&gt;
  
  
  class CameraStream
  {
  public:
      CameraStream();
  
  private:
      // Forward function definitions:
  
      // RTSP 'response handlers':
      void continueAfterDESCRIBE(RTSPClient* rtspClient, int resultCode, char* resultString);
      void continueAfterSETUP(RTSPClient* rtspClient, int resultCode, char* resultString);
      void continueAfterPLAY(RTSPClient* rtspClient, int resultCode, char* resultString);
  
      // Other event handler functions:
      void subsessionAfterPlaying(void* clientData); // called when a stream's subsession (e.g., audio or video substream) ends
      void subsessionByeHandler(void* clientData); // called when a RTCP "BYE" is received for a subsession
      void streamTimerHandler(void* clientData);
      // called at the end of a stream's expected duration (if the stream has not already signaled its end using a RTCP "BYE")
  
      // The main streaming routine (for each "rtsp://" URL):
      void openURL(UsageEnvironment&amp; env, char const* progName, char const* rtspURL);
  
      // Used to iterate through each stream's 'subsessions', setting up each one:
      void setupNextSubsession(RTSPClient* rtspClient);
  
      // Used to shut down and close a stream (including its "RTSPClient" object):
      void shutdownStream(RTSPClient* rtspClient, int exitCode = 1);
  
      char eventLoopWatchVariable;
  };
  // A function that outputs a string that identifies each stream (for debugging output).  Modify this if you wish:
  UsageEnvironment&amp; operator&lt;&lt;(UsageEnvironment&amp; env, const RTSPClient&amp; rtspClient) ;
  
  // A function that outputs a string that identifies each subsession (for debugging output).  Modify this if you wish:
  UsageEnvironment&amp; operator&lt;&lt;(UsageEnvironment&amp; env, const MediaSubsession&amp; subsession);
  
  
  #endif // CAMERASTREAM_H
  </code></pre>
  
  <p>when i try to compile i get the following error:</p>
  
  <pre><code>../CameraProva/CameraStream.cpp: In member function 'void CameraStream::setupNextSubsession(RTSPClient*)':
  ../CameraProva/CameraStream.cpp:110:112: error: no matching function for call to 'RTSPClient::sendSetupCommand(MediaSubsession&amp;, &lt;unresolved overloaded function type&gt;, const Boolean&amp;, const Boolean&amp;)'
  
  ../CameraProva/CameraStream.cpp:110:112: note: candidate is:
  ../include/RTSPClient.hh:85:12: note: unsigned int RTSPClient::sendSetupCommand(MediaSubsession&amp;, void (*)(RTSPClient*, int, char*), Boolean, Boolean, Boolean, Authenticator*)
  
  ../include/RTSPClient.hh:85:12: note:   no known conversion for argument 2 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(RTSPClient*, int, char*)'
  ../CameraProva/CameraStream.cpp:118:124: error: no matching function for call to 'RTSPClient::sendPlayCommand(MediaSession&amp;, &lt;unresolved overloaded function type&gt;, char*, char*)'
  
  ../CameraProva/CameraStream.cpp:118:124: note: candidates are:
  ../include/RTSPClient.hh:93:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSession&amp;, void (*)(RTSPClient*, int, char*), double, double, float, Authenticator*)
  
  ../include/RTSPClient.hh:93:12: note:   no known conversion for argument 2 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(RTSPClient*, int, char*)'
  ../include/RTSPClient.hh:99:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSubsession&amp;, void (*)(RTSPClient*, int, char*), double, double, float, Authenticator*)
  
  ../include/RTSPClient.hh:99:12: note:   no known conversion for argument 1 from 'MediaSession' to 'MediaSubsession&amp;'
  ../include/RTSPClient.hh:109:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSession&amp;, void (*)(RTSPClient*, int, char*), const char*, const char*, float, Authenticator*)
  
  ../include/RTSPClient.hh:109:12: note:   no known conversion for argument 2 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(RTSPClient*, int, char*)'
  ../include/RTSPClient.hh:112:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSubsession&amp;, void (*)(RTSPClient*, int, char*), const char*, const char*, float, Authenticator*)
  
  ../include/RTSPClient.hh:112:12: note:   no known conversion for argument 1 from 'MediaSession' to 'MediaSubsession&amp;'
  ../CameraProva/CameraStream.cpp:121:68: error: no matching function for call to 'RTSPClient::sendPlayCommand(MediaSession&amp;, &lt;unresolved overloaded function type&gt;)'
  ../CameraProva/CameraStream.cpp:121:68: note: candidates are:
  ../include/RTSPClient.hh:93:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSession&amp;, void (*)(RTSPClient*, int, char*), double, double, float, Authenticator*)
  
  ../include/RTSPClient.hh:93:12: note:   no known conversion for argument 2 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(RTSPClient*, int, char*)'
  ../include/RTSPClient.hh:99:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSubsession&amp;, void (*)(RTSPClient*, int, char*), double, double, float, Authenticator*)
  
  ../include/RTSPClient.hh:99:12: note:   no known conversion for argument 1 from 'MediaSession' to 'MediaSubsession&amp;'
  ../include/RTSPClient.hh:109:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSession&amp;, void (*)(RTSPClient*, int, char*), const char*, const char*, float, Authenticator*)
  
  ../include/RTSPClient.hh:109:12: note:   candidate expects 6 arguments, 2 provided
  ../include/RTSPClient.hh:112:12: note: unsigned int RTSPClient::sendPlayCommand(MediaSubsession&amp;, void (*)(RTSPClient*, int, char*), const char*, const char*, float, Authenticator*)
  
  ../include/RTSPClient.hh:112:12: note:   candidate expects 6 arguments, 2 provided
  ../CameraProva/CameraStream.cpp: In member function 'void CameraStream::continueAfterSETUP(RTSPClient*, int, char*)':
  ../CameraProva/CameraStream.cpp:153:82: error: no matching function for call to 'MediaSink::startPlaying(FramedSource&amp;, &lt;unresolved overloaded function type&gt;, MediaSubsession*&amp;)'
  
  ../CameraProva/CameraStream.cpp:153:82: note: candidate is:
  ../include/MediaSink.hh:34:11: note: Boolean MediaSink::startPlaying(MediaSource&amp;, void (*)(void*), void*)
  ../include/MediaSink.hh:34:11: note:   no known conversion for argument 2 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(void*)'
  
  ../CameraProva/CameraStream.cpp:156:95: error: no matching function for call to 'RTCPInstance::setByeHandler(&lt;unresolved overloaded function type&gt;, MediaSubsession*&amp;)'
  ../CameraProva/CameraStream.cpp:156:95: note: candidate is:
  ../include/RTCP.hh:59:8: note: void RTCPInstance::setByeHandler(void (*)(void*), void*, Boolean)
  
  ../include/RTCP.hh:59:8: note:   no known conversion for argument 1 from '&lt;unresolved overloaded function type&gt;' to 'void (*)(void*)'
  ../CameraProva/CameraStream.cpp: In member function 'void CameraStream::continueAfterPLAY(RTSPClient*, int, char*)':
  ../CameraProva/CameraStream.cpp:185:100: error: invalid use of member (did you forget the '&amp;' ?)
  
  make: *** [CameraStream.o] Error 1
  </code></pre>
  
  <p>i copy the code from the example of the testRTSPClient in the source archive of live555. what i'm doing wrong? There is any examples of QT applications that use live555?</p>