[vlc-devel] [PATCH 4/9] dash: added byte count methods to chunk

Christopher at mailsrv.uni-klu.ac.at Christopher at mailsrv.uni-klu.ac.at
Fri Mar 9 19:05:22 CET 2012


From: Christopher Mueller <christopher.mueller at itec.aau.at>

---
 modules/stream_filter/dash/http/Chunk.cpp |   58 +++++++++++++++++++++--------
 modules/stream_filter/dash/http/Chunk.h   |   22 +++++++---
 2 files changed, 57 insertions(+), 23 deletions(-)

diff --git a/modules/stream_filter/dash/http/Chunk.cpp b/modules/stream_filter/dash/http/Chunk.cpp
index a3ecf7e..56ce1aa 100644
--- a/modules/stream_filter/dash/http/Chunk.cpp
+++ b/modules/stream_filter/dash/http/Chunk.cpp
@@ -34,31 +34,33 @@ Chunk::Chunk        () :
        endByte      (0),
        hasByteRange (false),
        port         (0),
-       isHostname   (false)
+       isHostname   (false),
+       length       (0),
+       bytesRead    (0)
 {
 }
 
-int                 Chunk::getEndByte       () const
+int                 Chunk::getEndByte           () const
 {
     return endByte;
 }
-int                 Chunk::getStartByte     () const
+int                 Chunk::getStartByte         () const
 {
     return startByte;
 }
-const std::string&  Chunk::getUrl           () const
+const std::string&  Chunk::getUrl               () const
 {
     return url;
 }
-void                Chunk::setEndByte       (int endByte)
+void                Chunk::setEndByte           (int endByte)
 {
     this->endByte = endByte;
 }
-void                Chunk::setStartByte     (int startByte)
+void                Chunk::setStartByte         (int startByte)
 {
     this->startByte = startByte;
 }
-void                Chunk::setUrl           (const std::string& url )
+void                Chunk::setUrl               (const std::string& url )
 {
     this->url = url;
 
@@ -76,39 +78,63 @@ void                Chunk::setUrl           (const std::string& url )
     this->hostname      = url_components.psz_host;
     this->isHostname    = true;
 }
-void                Chunk::addOptionalUrl   (const std::string& url)
+void                Chunk::addOptionalUrl       (const std::string& url)
 {
     this->optionalUrls.push_back(url);
 }
-bool                Chunk::useByteRange     ()
+bool                Chunk::useByteRange         ()
 {
     return this->hasByteRange;
 }
-void                Chunk::setUseByteRange  (bool value)
+void                Chunk::setUseByteRange      (bool value)
 {
     this->hasByteRange = value;
 }
-void                Chunk::setBitrate       (uint64_t bitrate)
+void                Chunk::setBitrate           (uint64_t bitrate)
 {
     this->bitrate = bitrate;
 }
-int                 Chunk::getBitrate       ()
+int                 Chunk::getBitrate           ()
 {
     return this->bitrate;
 }
-bool                Chunk::hasHostname     () const
+bool                Chunk::hasHostname          () const
 {
     return this->isHostname;
 }
-const std::string&  Chunk::getHostname     () const
+const std::string&  Chunk::getHostname          () const
 {
     return this->hostname;
 }
-const std::string&  Chunk::getPath         () const
+const std::string&  Chunk::getPath              () const
 {
     return this->path;
 }
-int                 Chunk::getPort         () const
+int                 Chunk::getPort              () const
 {
     return this->port;
 }
+uint64_t            Chunk::getLength            () const
+{
+    return this->length;
+}
+void                Chunk::setLength            (uint64_t length)
+{
+    this->length = length;
+}
+uint64_t            Chunk::getBytesRead         () const
+{
+    return this->bytesRead;
+}
+void                Chunk::setBytesRead         (uint64_t bytes)
+{
+    this->bytesRead = bytes;
+}
+uint64_t            Chunk::getBytesToRead       () const
+{
+    return this->length - this->bytesRead;
+}
+size_t              Chunk::getPercentDownloaded () const
+{
+    return (size_t)(((float)this->bytesRead / this->length) * 100);
+}
diff --git a/modules/stream_filter/dash/http/Chunk.h b/modules/stream_filter/dash/http/Chunk.h
index a4b41f1..4deec4b 100644
--- a/modules/stream_filter/dash/http/Chunk.h
+++ b/modules/stream_filter/dash/http/Chunk.h
@@ -44,14 +44,20 @@ namespace dash
             public:
                 Chunk           ();
 
-                int                 getEndByte      () const;
-                int                 getStartByte    () const;
-                const std::string&  getUrl          () const;
-                bool                hasHostname     () const;
-                const std::string&  getHostname     () const;
-                const std::string&  getPath         () const;
-                int                 getPort         () const;
+                int                 getEndByte              () const;
+                int                 getStartByte            () const;
+                const std::string&  getUrl                  () const;
+                bool                hasHostname             () const;
+                const std::string&  getHostname             () const;
+                const std::string&  getPath                 () const;
+                int                 getPort                 () const;
+                uint64_t            getLength               () const;
+                uint64_t            getBytesRead            () const;
+                uint64_t            getBytesToRead          () const;
+                size_t              getPercentDownloaded    () const;
 
+                void                setBytesRead    (uint64_t bytes);
+                void                setLength       (uint64_t length);
                 void                setEndByte      (int endByte);
                 void                setStartByte    (int startByte);
                 void                setUrl          (const std::string& url);
@@ -72,6 +78,8 @@ namespace dash
                 int                         bitrate;
                 int                         port;
                 bool                        isHostname;
+                size_t                      length;
+                uint64_t                    bytesRead;
         };
     }
 }
-- 
1.7.0.4




More information about the vlc-devel mailing list