]> git.sesse.net Git - vlc/commitdiff
stream_filter: dash: fix byte range signedness and simplify
authorFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 20 Nov 2014 13:28:49 +0000 (14:28 +0100)
committerFrancois Cartegnie <fcvlcdev@free.fr>
Thu, 18 Dec 2014 20:23:49 +0000 (21:23 +0100)
modules/stream_filter/dash/http/Chunk.cpp
modules/stream_filter/dash/http/Chunk.h
modules/stream_filter/dash/http/HTTPConnection.cpp
modules/stream_filter/dash/http/PersistentConnection.cpp
modules/stream_filter/dash/mpd/Segment.cpp
modules/stream_filter/dash/mpd/Segment.h

index e3ada84991be60d5e24f706a2da055c41da186fc..301a0c689348fce75e8c8f712db6e3dd4966409d 100644 (file)
@@ -32,7 +32,6 @@ using namespace dash::http;
 Chunk::Chunk        () :
        startByte    (0),
        endByte      (0),
-       hasByteRange (false),
        port         (0),
        isHostname   (false),
        length       (0),
@@ -41,11 +40,11 @@ Chunk::Chunk        () :
 {
 }
 
-int                 Chunk::getEndByte           () const
+size_t              Chunk::getEndByte           () const
 {
     return endByte;
 }
-int                 Chunk::getStartByte         () const
+size_t              Chunk::getStartByte         () const
 {
     return startByte;
 }
@@ -53,11 +52,11 @@ const std::string&  Chunk::getUrl               () const
 {
     return url;
 }
-void                Chunk::setEndByte           (int endByte)
+void                Chunk::setEndByte           (size_t endByte)
 {
     this->endByte = endByte;
 }
-void                Chunk::setStartByte         (int startByte)
+void                Chunk::setStartByte         (size_t startByte)
 {
     this->startByte = startByte;
 }
@@ -85,14 +84,11 @@ void                Chunk::addOptionalUrl       (const std::string& url)
 {
     this->optionalUrls.push_back(url);
 }
-bool                Chunk::useByteRange         ()
+bool                Chunk::usesByteRange        () const
 {
-    return this->hasByteRange;
-}
-void                Chunk::setUseByteRange      (bool value)
-{
-    this->hasByteRange = value;
+    return (startByte != endByte);
 }
+
 void                Chunk::setBitrate           (uint64_t bitrate)
 {
     this->bitrate = bitrate;
index 48dd450bc1a290d64c087715435048b2dda61c7e..cd722ddb598275f2f7031ac0ebcb0a3251cdcad2 100644 (file)
@@ -47,8 +47,8 @@ namespace dash
             public:
                 Chunk           ();
 
-                int                 getEndByte              () const;
-                int                 getStartByte            () const;
+                size_t              getEndByte              () const;
+                size_t              getStartByte            () const;
                 const std::string&  getUrl                  () const;
                 bool                hasHostname             () const;
                 const std::string&  getHostname             () const;
@@ -63,12 +63,11 @@ namespace dash
                 void                setConnection   (IHTTPConnection *connection);
                 void                setBytesRead    (uint64_t bytes);
                 void                setLength       (uint64_t length);
-                void                setEndByte      (int endByte);
-                void                setStartByte    (int startByte);
+                void                setEndByte      (size_t endByte);
+                void                setStartByte    (size_t startByte);
                 void                setUrl          (const std::string& url);
                 void                addOptionalUrl  (const std::string& url);
-                bool                useByteRange    ();
-                void                setUseByteRange (bool value);
+                bool                usesByteRange   () const;
                 void                setBitrate      (uint64_t bitrate);
                 int                 getBitrate      ();
 
@@ -77,9 +76,8 @@ namespace dash
                 std::string                 path;
                 std::string                 hostname;
                 std::vector<std::string>    optionalUrls;
-                int                         startByte;
-                int                         endByte;
-                bool                        hasByteRange;
+                size_t                      startByte;
+                size_t                      endByte;
                 int                         bitrate;
                 int                         port;
                 bool                        isHostname;
index 98baa1bab02faffa29a2d79f4e86aa37c3f592f7..30a6427028691dd3774f1da8c4f0120b9c5f6f94 100644 (file)
@@ -76,7 +76,7 @@ std::string     HTTPConnection::prepareRequest  (Chunk *chunk)
 {
     std::string request;
 
-    if(!chunk->useByteRange())
+    if(!chunk->usesByteRange())
     {
         request = "GET "    + chunk->getPath()    + " HTTP/1.1" + "\r\n" +
                   "Host: "  + chunk->getHostname() + "\r\n" +
index 4f1492cfc9e32a95868f94881e8691e488f52221..689986e8614e194d851be84f6ce4cbac2400f58e 100644 (file)
@@ -88,7 +88,7 @@ int                 PersistentConnection::read              (void *p_buffer, siz
 std::string         PersistentConnection::prepareRequest    (Chunk *chunk)
 {
     std::string request;
-    if(!chunk->useByteRange())
+    if(!chunk->usesByteRange())
     {
         request = "GET "    + chunk->getPath()     + " HTTP/1.1" + "\r\n" +
                   "Host: "  + chunk->getHostname() + "\r\n\r\n";
index 7d3dcb1aadac0c9995f063a813ef6638a9eed503..1649108533c77eb9c505f1c04901625339c60564 100644 (file)
@@ -35,8 +35,8 @@ using namespace dash::http;
 
 Segment::Segment(const Representation *parent, bool isinit) :
         ICanonicalUrl( parent ),
-        startByte  (-1),
-        endByte    (-1),
+        startByte  (0),
+        endByte    (0),
         parentRepresentation( parent ),
         init( isinit )
 {
@@ -71,11 +71,10 @@ dash::http::Chunk*      Segment::toChunk        ()
 {
     Chunk *chunk = new Chunk();
 
-    if(this->startByte != -1 && this->endByte != -1)
+    if(startByte != endByte)
     {
-        chunk->setUseByteRange(true);
-        chunk->setStartByte(this->startByte);
-        chunk->setEndByte(this->endByte);
+        chunk->setStartByte(startByte);
+        chunk->setEndByte(endByte);
     }
 
     chunk->setUrl( getUrlSegment() );
index 547fb287b6efa571ebbd66219d24065bdbeec809..65b81643da63f52d31da30dd682183a4281775e0 100644 (file)
@@ -58,8 +58,8 @@ namespace dash
 
             protected:
                 std::string             sourceUrl;
-                int                     startByte;
-                int                     endByte;
+                size_t                  startByte;
+                size_t                  endByte;
                 const Representation*   parentRepresentation;
                 int                     size;
                 bool                    init;