From fccce9d5bacbdcaf50e4caad91c7f7d2493cbff7 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <mingw.android@gmail.com>
Date: Wed, 17 Feb 2021 16:36:56 +0100
Subject: [PATCH 2/7] expose server_string

---
 liveMedia/RTSPClient.cpp        | 11 +++++++++--
 liveMedia/include/RTSPClient.hh |  5 +++++
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/liveMedia/RTSPClient.cpp b/liveMedia/RTSPClient.cpp
index 092e12e..18248bc 100644
--- a/liveMedia/RTSPClient.cpp
+++ b/liveMedia/RTSPClient.cpp
@@ -382,7 +382,7 @@ RTSPClient::RTSPClient(UsageEnvironment& env, char const* rtspURL,
     desiredMaxIncomingPacketSize(0), fVerbosityLevel(verbosityLevel), fCSeq(1),
     fAllowBasicAuthentication(True), fTunnelOverHTTPPortNum(tunnelOverHTTPPortNum),
     fUserAgentHeaderStr(NULL), fUserAgentHeaderStrLen(0),
-    fInputSocketNum(-1), fOutputSocketNum(-1), fBaseURL(NULL), fTCPStreamIdCount(0),
+    fInputSocketNum(-1), fOutputSocketNum(-1), fBaseURL(NULL), fserverString(NULL), fTCPStreamIdCount(0),
     fLastSessionId(NULL), fSessionTimeoutParameter(0), fSessionCookieCounter(0), fHTTPTunnelingConnectionIsPending(False),
     fTLS(*this) {
   setBaseURL(rtspURL);
@@ -431,6 +431,7 @@ void RTSPClient::reset() {
   fRequestsAwaitingResponse.reset();
 
   setBaseURL(NULL);
+  setServerString(NULL);
 
   fCurrentAuthenticator.reset();
 
@@ -441,6 +442,10 @@ void RTSPClient::setBaseURL(char const* url) {
   delete[] fBaseURL; fBaseURL = strDup(url);
 }
 
+void RTSPClient::setServerString(char const* str) {
+  delete[] fserverString; fserverString = strDup(str);
+}
+
 int RTSPClient::grabSocket() {
   int inputSocket = fInputSocketNum;
   RTPInterface::clearServerRequestAlternativeByteHandler(envir(), fInputSocketNum); // in case we were receiving RTP-over-TCP
@@ -1731,6 +1736,7 @@ void RTSPClient::handleResponseBytes(int newBytesRead) {
     char const* rtpInfoParamsStr = NULL;
     char const* wwwAuthenticateParamsStr = NULL;
     char const* publicParamsStr = NULL;
+    char const* serverStr = NULL;
     char* bodyStart = NULL;
     unsigned numBodyBytes = 0;
     responseSuccess = False;
@@ -1808,7 +1814,8 @@ void RTSPClient::handleResponseBytes(int newBytesRead) {
 // (see http://live555.com/liveMedia/faq.html#mailing-list-address for details),
 				  )) {
 // to check whether your proposed modification is appropriate/correct,
-	} else if (checkForHeader(lineStart, "Range:",
+        } else if (checkForHeader(lineStart, "Server:", 7, serverStr)) {
+          setServerString(serverStr);	} else if (checkForHeader(lineStart, "Range:",
 // and, if so, whether instead it could be included in
 				  6,
 // a future release of the "LIVE555 Streaming Media" software,
diff --git a/liveMedia/include/RTSPClient.hh b/liveMedia/include/RTSPClient.hh
index 7ca61d3..aceaff3 100644
--- a/liveMedia/include/RTSPClient.hh
+++ b/liveMedia/include/RTSPClient.hh
@@ -39,6 +39,8 @@ along with this library; if not, write to the Free Software Foundation, Inc.,
 #endif
 #endif
 
+#define VLC_PATCH_RTSPCLIENT_SERVERSTRING
+
 class RTSPClient: public Medium {
 public:
   static RTSPClient* createNew(UsageEnvironment& env, char const* rtspURL,
@@ -189,6 +191,7 @@ public:
   unsigned sessionTimeoutParameter() const { return fSessionTimeoutParameter; }
 
   char const* url() const { return fBaseURL; }
+  char const* serverString() const { return fserverString; }
 
   void useTLS() { fTLS.isNeeded = True; }
 
@@ -243,6 +246,7 @@ protected:
 
   void reset();
   void setBaseURL(char const* url);
+  void setServerString(char const* str);
   int grabSocket(); // allows a subclass to reuse our input socket, so that it won't get closed when we're deleted
   virtual unsigned sendRequest(RequestRecord* request);
   virtual Boolean setRequestFields(RequestRecord* request,
@@ -344,6 +348,7 @@ private:
   unsigned fUserAgentHeaderStrLen;
   int fInputSocketNum, fOutputSocketNum;
   char* fBaseURL;
+  char *fserverString;
   unsigned char fTCPStreamIdCount; // used for (optional) RTP/TCP
   char* fLastSessionId;
   unsigned fSessionTimeoutParameter; // optionally set in response "Session:" headers
-- 
2.30.1.windows.1

