]> git.sesse.net Git - vlc/commitdiff
dash: segment added byterange and tochunk
authorChristopher Mueller <christopher.mueller@itec.aau.at>
Mon, 30 Jan 2012 13:48:24 +0000 (14:48 +0100)
committerHugo Beauzée-Luyssen <beauze.h@gmail.com>
Thu, 2 Feb 2012 11:27:27 +0000 (12:27 +0100)
Signed-off-by: Hugo Beauzée-Luyssen <beauze.h@gmail.com>
modules/stream_filter/dash/mpd/Segment.cpp
modules/stream_filter/dash/mpd/Segment.h

index 5ac7f03d4bdc9b51070b97b230c0334ed8b887df..44d4d744fbaf2b6ec5ae47749fa6e0589a9845d2 100644 (file)
 #include "Segment.h"
 
 using namespace dash::mpd;
+using namespace dash::http;
 
-std::string Segment::getSourceUrl() const
+Segment::Segment    () :
+         startByte  (-1),
+         endByte    (-1)
+{
+
+}
+
+std::string             Segment::getSourceUrl   () const
 {
     return this->sourceUrl;
 }
 
-void        Segment::setSourceUrl( const std::string &url )
+void                    Segment::setSourceUrl   ( const std::string &url )
 {
     if ( url.empty() == false )
         this->sourceUrl = url;
 }
-
-bool        Segment::isSingleShot() const
+bool                    Segment::isSingleShot   () const
 {
     return true;
 }
-
-void Segment::done()
+void                    Segment::done           ()
 {
     //Only used for a SegmentTemplate.
 }
+void                    Segment::addBaseUrl     (BaseUrl *url)
+{
+    this->baseUrls.push_back(url);
+}
+const std::vector<BaseUrl *>&  Segment::getBaseUrls    () const
+{
+    return this->baseUrls;
+}
+void                    Segment::setByteRange   (int start, int end)
+{
+    this->startByte = start;
+    this->endByte   = end;
+}
+int                     Segment::getStartByte   () const
+{
+    return this->startByte;
+}
+int                     Segment::getEndByte     () const
+{
+    return this->endByte;
+}
+dash::http::Chunk*      Segment::toChunk        ()
+{
+    Chunk *chunk = new Chunk();
+
+    if(this->startByte != -1 && this->endByte != -1)
+    {
+        chunk->setStartByte(this->startByte);
+        chunk->setEndByte(this->endByte);
+    }
+
+    if(this->baseUrls.size() > 0)
+    {
+        std::stringstream ss;
+        ss << this->baseUrls.at(0)->getUrl() << this->sourceUrl;
+        chunk->setUrl(ss.str());
+        ss.clear();
+
+        for(size_t i = 1; i < this->baseUrls.size(); i++)
+        {
+            ss << this->baseUrls.at(i)->getUrl() << this->sourceUrl;
+            chunk->addOptionalUrl(ss.str());
+            ss.clear();
+        }
+
+    }
+    else
+    {
+        chunk->setUrl(this->sourceUrl);
+    }
+
+    return chunk;
+}
index 9c2dd7eae16546daf91fe309e448a55e148ff782..55ac6ef2fad63d5373894a0c160b6e1f91d91131 100644 (file)
 #define SEGMENT_H_
 
 #include <string>
+#include <sstream>
+#include <vector>
+#include "mpd/BaseUrl.h"
+#include "http/Chunk.h"
 
 namespace dash
 {
@@ -34,6 +38,7 @@ namespace dash
         class Segment
         {
             public:
+                Segment();
                 virtual ~Segment(){}
                 virtual std::string getSourceUrl() const;
                 virtual void        setSourceUrl( const std::string &url );
@@ -42,11 +47,20 @@ namespace dash
                  *          That is basically true when using an Url, and false
                  *          when using an UrlTemplate
                  */
-                virtual bool        isSingleShot() const;
-                virtual void        done();
+                virtual bool                            isSingleShot    () const;
+                virtual void                            done            ();
+                virtual void                            addBaseUrl      (BaseUrl *url);
+                virtual const std::vector<BaseUrl *>&   getBaseUrls     () const;
+                virtual void                            setByteRange    (int start, int end);
+                virtual int                             getStartByte    () const;
+                virtual int                             getEndByte      () const;
+                virtual dash::http::Chunk*              toChunk         ();
 
             protected:
-                std::string         sourceUrl;
+                std::string             sourceUrl;
+                std::vector<BaseUrl *>  baseUrls;
+                int                     startByte;
+                int                     endByte;
         };
     }
 }