[vlc-commits] stream_filter: dash: don't store http reply as member

Francois Cartegnie git at videolan.org
Thu Dec 18 22:39:50 CET 2014


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Mon Nov 24 12:58:58 2014 +0100| [6a8ddb3478064f4fe96c63c368e9684ecf0c1b6f] | committer: Francois Cartegnie

stream_filter: dash: don't store http reply as member

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6a8ddb3478064f4fe96c63c368e9684ecf0c1b6f
---

 modules/stream_filter/dash/http/HTTPConnection.cpp       |   12 +++++++-----
 modules/stream_filter/dash/http/HTTPConnection.h         |   10 ++++++++--
 modules/stream_filter/dash/http/PersistentConnection.cpp |   11 ++++++-----
 3 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/modules/stream_filter/dash/http/HTTPConnection.cpp b/modules/stream_filter/dash/http/HTTPConnection.cpp
index 0804ada..75b1310 100644
--- a/modules/stream_filter/dash/http/HTTPConnection.cpp
+++ b/modules/stream_filter/dash/http/HTTPConnection.cpp
@@ -34,8 +34,7 @@ using namespace dash::http;
 
 HTTPConnection::HTTPConnection  (stream_t *stream) :
                 IHTTPConnection (stream),
-                peekBufferLen   (0),
-                contentLength   (0)
+                peekBufferLen   (0)
 {
     this->peekBuffer = new uint8_t[PEEKBUFFER];
 }
@@ -84,12 +83,15 @@ std::string     HTTPConnection::getRequestHeader  (const Chunk *chunk) const
 bool            HTTPConnection::init            (Chunk *chunk)
 {
     if (IHTTPConnection::init(chunk))
-        return parseHeader();
+    {
+        HeaderReply reply;
+        return parseHeader(&reply);
+    }
     else
         return false;
 }
 
-bool            HTTPConnection::parseHeader     ()
+bool            HTTPConnection::parseHeader     (HeaderReply *reply)
 {
     std::string line = this->readLine();
 
@@ -99,7 +101,7 @@ bool            HTTPConnection::parseHeader     ()
     while(line.compare("\r\n"))
     {
         if(!strncasecmp(line.c_str(), "Content-Length", 14))
-            this->contentLength = atoi(line.substr(15,line.size()).c_str());
+            reply->contentLength = atoi(line.substr(15,line.size()).c_str());
 
         line = this->readLine();
 
diff --git a/modules/stream_filter/dash/http/HTTPConnection.h b/modules/stream_filter/dash/http/HTTPConnection.h
index 97301ac..45bcb3c 100644
--- a/modules/stream_filter/dash/http/HTTPConnection.h
+++ b/modules/stream_filter/dash/http/HTTPConnection.h
@@ -49,12 +49,18 @@ namespace dash
                 virtual int     peek        (const uint8_t **pp_peek, size_t i_peek);
 
             protected:
+
+                class HeaderReply
+                {
+                    public:
+                        int contentLength;
+                };
+
                 uint8_t     *peekBuffer;
                 size_t      peekBufferLen;
-                int         contentLength;
 
                 virtual bool        send        (const std::string& data);
-                bool                parseHeader     ();
+                bool                parseHeader     (HeaderReply *);
                 std::string         readLine        ();
                 virtual std::string getRequestHeader(const Chunk *chunk) const; /* reimpl */
         };
diff --git a/modules/stream_filter/dash/http/PersistentConnection.cpp b/modules/stream_filter/dash/http/PersistentConnection.cpp
index 79ba500..72cb0cc 100644
--- a/modules/stream_filter/dash/http/PersistentConnection.cpp
+++ b/modules/stream_filter/dash/http/PersistentConnection.cpp
@@ -130,18 +130,19 @@ bool                PersistentConnection::addChunk          (Chunk *chunk)
 }
 bool                PersistentConnection::initChunk         (Chunk *chunk)
 {
-    if(this->parseHeader())
+    HeaderReply reply;
+    if(parseHeader(&reply))
     {
-        chunk->setLength(this->contentLength);
+        chunk->setLength(reply.contentLength);
         return true;
     }
 
-    if(!this->reconnect(chunk))
+    if(!reconnect(chunk))
         return false;
 
-    if(this->parseHeader())
+    if(parseHeader(&reply))
     {
-        chunk->setLength(this->contentLength);
+        chunk->setLength(reply.contentLength);
         return true;
     }
 



More information about the vlc-commits mailing list