[vlc-commits] [Git][videolan/vlc][master] 2 commits: demux: adaptive: return string reference for ContentType

François Cartegnie (@fcartegnie) gitlab at videolan.org
Mon May 19 06:17:32 UTC 2025



François Cartegnie pushed to branch master at VideoLAN / VLC


Commits:
05e6bc4a by François Cartegnie at 2025-05-19T05:53:40+00:00
demux: adaptive: return string reference for ContentType

- - - - -
ac37bcc8 by François Cartegnie at 2025-05-19T05:53:40+00:00
xml: Node: remove unneeded includes

- - - - -


4 changed files:

- modules/demux/adaptive/http/Chunk.cpp
- modules/demux/adaptive/http/Chunk.h
- modules/demux/adaptive/test/SegmentTracker.cpp
- modules/demux/adaptive/xml/Node.cpp


Changes:

=====================================
modules/demux/adaptive/http/Chunk.cpp
=====================================
@@ -38,6 +38,8 @@
 using namespace adaptive::http;
 using vlc::threads::mutex_locker;
 
+static std::string EmptyStr = "";
+
 AbstractChunkSource::AbstractChunkSource(ChunkType t, const BytesRange &range)
 {
     type = t;
@@ -58,9 +60,9 @@ const BytesRange & AbstractChunkSource::getBytesRange() const
     return bytesRange;
 }
 
-std::string AbstractChunkSource::getContentType() const
+const std::string & AbstractChunkSource::getContentType() const
 {
-    return std::string();
+    return EmptyStr;
 }
 
 RequestStatus AbstractChunkSource::getRequestStatus() const
@@ -89,7 +91,7 @@ AbstractChunk::~AbstractChunk()
     source->recycle();
 }
 
-std::string AbstractChunk::getContentType() const
+const std::string & AbstractChunk::getContentType() const
 {
     return source->getContentType();
 }
@@ -263,13 +265,13 @@ StorageID HTTPChunkSource::makeStorageID(const std::string &s, const BytesRange
     return std::to_string(r.getStartByte())+ std::to_string(r.getEndByte()) + '@' + s;
 }
 
-std::string HTTPChunkSource::getContentType() const
+const std::string & HTTPChunkSource::getContentType() const
 {
     mutex_locker locker {lock};
     if(connection)
         return connection->getContentType();
     else
-        return std::string();
+        return EmptyStr;
 }
 
 void HTTPChunkSource::setIdentifier(const std::string &s, const BytesRange &r)
@@ -565,7 +567,7 @@ ProbeableChunk::~ProbeableChunk()
     delete source;
 }
 
-std::string ProbeableChunk::getContentType() const
+const std::string & ProbeableChunk::getContentType() const
 {
     return source->getContentType();
 }


=====================================
modules/demux/adaptive/http/Chunk.h
=====================================
@@ -57,7 +57,7 @@ namespace adaptive
         {
             public:
                 virtual ~ChunkInterface() {}
-                virtual std::string getContentType  () const = 0;
+                virtual const std::string & getContentType  () const = 0;
                 virtual RequestStatus getRequestStatus() const = 0;
 
                 virtual block_t *   readBlock       () = 0;
@@ -76,7 +76,7 @@ namespace adaptive
                 const BytesRange &  getBytesRange   () const;
                 ChunkType           getChunkType    () const;
                 const StorageID &   getStorageID    () const;
-                std::string getContentType  () const override;
+                const std::string & getContentType  () const override;
                 RequestStatus getRequestStatus() const override;
                 virtual void        recycle() = 0;
 
@@ -95,7 +95,7 @@ namespace adaptive
             public:
                 virtual ~AbstractChunk();
 
-                std::string   getContentType        () const override;
+                const std::string & getContentType  () const override;
                 RequestStatus getRequestStatus      () const override;
                 size_t        getBytesRead          () const override;
                 bool          hasMoreData           () const override;
@@ -126,7 +126,7 @@ namespace adaptive
                 block_t *   read            (size_t)  override;
                 bool        hasMoreData     () const  override;
                 size_t      getBytesRead    () const  override;
-                std::string getContentType  () const  override;
+                const std::string & getContentType() const override;
                 void        recycle() override;
 
                 static const size_t CHUNK_SIZE = 32768;
@@ -205,7 +205,7 @@ namespace adaptive
                 ProbeableChunk(ChunkInterface *);
                 virtual ~ProbeableChunk();
 
-                std::string getContentType  () const override;
+                const std::string & getContentType  () const override;
                 RequestStatus getRequestStatus() const override;
 
                 block_t *   readBlock       () override;


=====================================
modules/demux/adaptive/test/SegmentTracker.cpp
=====================================
@@ -73,7 +73,7 @@ class DummyChunkSource : public AbstractChunkSource
             : AbstractChunkSource(t, range), data(v), offset(0), contentType(content) {}
         virtual ~DummyChunkSource() = default;
         void recycle() override { delete this; }
-        std::string getContentType  () const override
+        const std::string & getContentType  () const override
         {
             return contentType;
         }


=====================================
modules/demux/adaptive/xml/Node.cpp
=====================================
@@ -29,8 +29,6 @@
 
 #include <cassert>
 #include <algorithm>
-#include <vlc_common.h>
-#include <vlc_xml.h>
 
 using namespace adaptive::xml;
 



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5f508b12fa5cd1d02a59a4c72b012360b0659d66...ac37bcc89d6a0b7293168350f7c2c022b37bcd9d

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/5f508b12fa5cd1d02a59a4c72b012360b0659d66...ac37bcc89d6a0b7293168350f7c2c022b37bcd9d
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list