Hello All,

   I have a server here that sends me SET_PARAMETER requests while the
client is waiting for a DESCRIBE response. The RFC states in appendix
D.1 that "A client implementation MUST be able to do the following : *
Expect and respond to asynchronous requests from the server". And also
that RTSP is a symmetric protocol (compared to asymmetric HTTP).
   So I guess we have to deal with these situations. Attached is a
patch that tries to fix this.

Best Regards,

---
Martin
diff -u -r ../live.old/liveMedia/RTSPClient.cpp ./liveMedia/RTSPClient.cpp
--- ../live.old/liveMedia/RTSPClient.cpp	2008-12-16 09:35:12.000000000 +0100
+++ ./liveMedia/RTSPClient.cpp	2008-12-16 09:40:21.000000000 +0100
@@ -2095,13 +2095,39 @@
 				unsigned& bytesRead, unsigned& responseCode,
 				char*& firstLine, char*& nextLineStart,
 				Boolean checkFor200Response) {
-  do {
+
+  int response_found = 0;
+  int retries = 100;
+
+  while(!response_found && retries-- ){
     char* readBuf = fResponseBuffer;
     bytesRead = getResponse1(readBuf, fResponseBufferSize);
     if (bytesRead == 0) {
       envir().setResultErrMsg("Failed to read response: ");
       break;
     }
+    if( strncmp(readBuf, "RTSP", 4) ){
+      envir() << "Request received while waiting a response " << readBuf << "\n";
+      // Parse the request string into command name and 'CSeq',
+      // then handle the command:
+      char cmdName[RTSP_PARAM_STRING_MAX];
+      char urlPreSuffix[RTSP_PARAM_STRING_MAX];
+      char urlSuffix[RTSP_PARAM_STRING_MAX];
+      char cseq[RTSP_PARAM_STRING_MAX];
+      if (!parseRTSPRequestString((char*)readBuf, bytesRead,
+			      cmdName, sizeof cmdName,
+			      urlPreSuffix, sizeof urlPreSuffix,
+			      urlSuffix, sizeof urlSuffix,
+			      cseq, sizeof cseq)) {
+        continue;
+      } else {
+        handleCmd_notSupported(cseq);
+      }
+      continue;
+    }
+
+    response_found = 1;
+
     if (fVerbosityLevel >= 1) {
       envir() << "Received " << tag << " response: " << readBuf << "\n";
     }
_______________________________________________
live-devel mailing list
live-devel@lists.live555.com
http://lists.live555.com/mailman/listinfo/live-devel

Reply via email to