[vlc-commits] stream_filter: dash: fix byte range signedness and simplify

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


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Thu Nov 20 14:28:49 2014 +0100| [e50f11bb2b748fa74058f12a8921f580a31af28e] | committer: Francois Cartegnie

stream_filter: dash: fix byte range signedness and simplify

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

 modules/stream_filter/dash/http/Chunk.cpp            |   18 +++++++-----------
 modules/stream_filter/dash/http/Chunk.h              |   16 +++++++---------
 modules/stream_filter/dash/http/HTTPConnection.cpp   |    2 +-
 .../stream_filter/dash/http/PersistentConnection.cpp |    2 +-
 modules/stream_filter/dash/mpd/Segment.cpp           |   11 +++++------
 modules/stream_filter/dash/mpd/Segment.h             |    4 ++--
 6 files changed, 23 insertions(+), 30 deletions(-)

diff --git a/modules/stream_filter/dash/http/Chunk.cpp b/modules/stream_filter/dash/http/Chunk.cpp
index e3ada84..301a0c6 100644
--- a/modules/stream_filter/dash/http/Chunk.cpp
+++ b/modules/stream_filter/dash/http/Chunk.cpp
@@ -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;
diff --git a/modules/stream_filter/dash/http/Chunk.h b/modules/stream_filter/dash/http/Chunk.h
index 48dd450..cd722dd 100644
--- a/modules/stream_filter/dash/http/Chunk.h
+++ b/modules/stream_filter/dash/http/Chunk.h
@@ -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;
diff --git a/modules/stream_filter/dash/http/HTTPConnection.cpp b/modules/stream_filter/dash/http/HTTPConnection.cpp
index 98baa1b..30a6427 100644
--- a/modules/stream_filter/dash/http/HTTPConnection.cpp
+++ b/modules/stream_filter/dash/http/HTTPConnection.cpp
@@ -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" +
diff --git a/modules/stream_filter/dash/http/PersistentConnection.cpp b/modules/stream_filter/dash/http/PersistentConnection.cpp
index 4f1492c..689986e 100644
--- a/modules/stream_filter/dash/http/PersistentConnection.cpp
+++ b/modules/stream_filter/dash/http/PersistentConnection.cpp
@@ -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";
diff --git a/modules/stream_filter/dash/mpd/Segment.cpp b/modules/stream_filter/dash/mpd/Segment.cpp
index 7d3dcb1..1649108 100644
--- a/modules/stream_filter/dash/mpd/Segment.cpp
+++ b/modules/stream_filter/dash/mpd/Segment.cpp
@@ -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() );
diff --git a/modules/stream_filter/dash/mpd/Segment.h b/modules/stream_filter/dash/mpd/Segment.h
index 547fb28..65b8164 100644
--- a/modules/stream_filter/dash/mpd/Segment.h
+++ b/modules/stream_filter/dash/mpd/Segment.h
@@ -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;



More information about the vlc-commits mailing list