[vlc-commits] demux: adaptive: have intheritance on commonattributes

Francois Cartegnie git at videolan.org
Thu Mar 4 13:47:35 UTC 2021


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue Feb 23 17:50:30 2021 +0100| [630f86677df6767162c86609d19ea01ad10ca46b] | committer: Francois Cartegnie

demux: adaptive: have intheritance on commonattributes

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

 .../demux/adaptive/playlist/BaseRepresentation.cpp |  1 +
 .../adaptive/playlist/CommonAttributesElements.cpp | 27 ++++++++++++++++------
 .../adaptive/playlist/CommonAttributesElements.h   |  5 +++-
 modules/demux/dash/mpd/Representation.cpp          |  5 +---
 modules/demux/smooth/playlist/SmoothParser.cpp     |  4 ++--
 5 files changed, 28 insertions(+), 14 deletions(-)

diff --git a/modules/demux/adaptive/playlist/BaseRepresentation.cpp b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
index 1cee48bf56..a103fab92d 100644
--- a/modules/demux/adaptive/playlist/BaseRepresentation.cpp
+++ b/modules/demux/adaptive/playlist/BaseRepresentation.cpp
@@ -43,6 +43,7 @@ using namespace adaptive;
 using namespace adaptive::playlist;
 
 BaseRepresentation::BaseRepresentation( BaseAdaptationSet *set ) :
+                CommonAttributesElements( set ),
                 SegmentInformation( set ),
                 adaptationSet   ( set ),
                 bandwidth       (0)
diff --git a/modules/demux/adaptive/playlist/CommonAttributesElements.cpp b/modules/demux/adaptive/playlist/CommonAttributesElements.cpp
index da629f30af..7001596c84 100644
--- a/modules/demux/adaptive/playlist/CommonAttributesElements.cpp
+++ b/modules/demux/adaptive/playlist/CommonAttributesElements.cpp
@@ -32,10 +32,11 @@
 
 using namespace adaptive::playlist;
 
-CommonAttributesElements::CommonAttributesElements() :
+CommonAttributesElements::CommonAttributesElements(CommonAttributesElements *p) :
     width( -1 ),
     height( -1 )
 {
+    parentCommonAttributes = p;
 }
 
 CommonAttributesElements::~CommonAttributesElements()
@@ -44,7 +45,9 @@ CommonAttributesElements::~CommonAttributesElements()
 
 const std::string& CommonAttributesElements::getMimeType() const
 {
-    return mimeType;
+    if(!mimeType.empty() || !parentCommonAttributes)
+        return mimeType;
+    return parentCommonAttributes->getMimeType();
 }
 
 void CommonAttributesElements::setMimeType( const std::string &mimeType )
@@ -54,7 +57,9 @@ void CommonAttributesElements::setMimeType( const std::string &mimeType )
 
 int     CommonAttributesElements::getWidth                () const
 {
-    return width;
+    if(width != -1 || !parentCommonAttributes)
+        return width;
+    return parentCommonAttributes->getWidth();
 }
 
 void    CommonAttributesElements::setWidth( int width )
@@ -65,7 +70,9 @@ void    CommonAttributesElements::setWidth( int width )
 
 int     CommonAttributesElements::getHeight               () const
 {
-    return height;
+    if(height != -1 || !parentCommonAttributes)
+        return height;
+    return parentCommonAttributes->getHeight();
 }
 
 void    CommonAttributesElements::setHeight( int height )
@@ -81,12 +88,16 @@ void CommonAttributesElements::setAspectRatio(const AspectRatio &r)
 
 const AspectRatio & CommonAttributesElements::getAspectRatio() const
 {
-    return aspectRatio;
+    if(aspectRatio.isValid() || !parentCommonAttributes)
+        return aspectRatio;
+    return parentCommonAttributes->getAspectRatio();
 }
 
 const Rate & CommonAttributesElements::getFrameRate() const
 {
-    return frameRate;
+    if(frameRate.isValid() || !parentCommonAttributes)
+        return frameRate;
+    return parentCommonAttributes->getFrameRate();
 }
 
 void CommonAttributesElements::setFrameRate(const Rate &r)
@@ -96,7 +107,9 @@ void CommonAttributesElements::setFrameRate(const Rate &r)
 
 const Rate & CommonAttributesElements::getSampleRate() const
 {
-    return sampleRate;
+    if(sampleRate.isValid() || !parentCommonAttributes)
+        return sampleRate;
+    return parentCommonAttributes->getSampleRate();
 }
 
 void CommonAttributesElements::setSampleRate(const Rate &r)
diff --git a/modules/demux/adaptive/playlist/CommonAttributesElements.h b/modules/demux/adaptive/playlist/CommonAttributesElements.h
index 94656a0148..b7f8330d00 100644
--- a/modules/demux/adaptive/playlist/CommonAttributesElements.h
+++ b/modules/demux/adaptive/playlist/CommonAttributesElements.h
@@ -34,7 +34,7 @@ namespace adaptive
         class CommonAttributesElements
         {
             public:
-                CommonAttributesElements();
+                CommonAttributesElements(CommonAttributesElements * = nullptr);
                 virtual ~CommonAttributesElements();
                 virtual const std::string&      getMimeType() const;
                 void                            setMimeType( const std::string &mimeType );
@@ -56,6 +56,9 @@ namespace adaptive
                 AspectRatio                         aspectRatio;
                 Rate                                frameRate;
                 Rate                                sampleRate;
+
+            private:
+                CommonAttributesElements           *parentCommonAttributes;
         };
     }
 }
diff --git a/modules/demux/dash/mpd/Representation.cpp b/modules/demux/dash/mpd/Representation.cpp
index e0026e3902..87a789adb5 100644
--- a/modules/demux/dash/mpd/Representation.cpp
+++ b/modules/demux/dash/mpd/Representation.cpp
@@ -47,10 +47,7 @@ Representation::~Representation ()
 
 StreamFormat Representation::getStreamFormat() const
 {
-    if(getMimeType().empty())
-        return StreamFormat(adaptationSet->getMimeType());
-    else
-        return StreamFormat(getMimeType());
+    return StreamFormat(getMimeType());
 }
 
 std::string Representation::contextualize(size_t number, const std::string &component,
diff --git a/modules/demux/smooth/playlist/SmoothParser.cpp b/modules/demux/smooth/playlist/SmoothParser.cpp
index 5d1a56759b..a945f7e642 100644
--- a/modules/demux/smooth/playlist/SmoothParser.cpp
+++ b/modules/demux/smooth/playlist/SmoothParser.cpp
@@ -196,6 +196,8 @@ static void ParseQualityLevel(BaseAdaptationSet *adaptSet, Node *qualNode, const
 
         rep->setCodecParameters(params);
 
+        adaptSet->addRepresentation(rep);
+
         ForgedInitSegment *initSegment = new (std::nothrow)
                 ForgedInitSegment(rep, type,
                                   timescale,
@@ -213,8 +215,6 @@ static void ParseQualityLevel(BaseAdaptationSet *adaptSet, Node *qualNode, const
             initSegment->setSourceUrl("forged://");
 
             rep->initialisationSegment.Set(initSegment);
-
-            adaptSet->addRepresentation(rep);
         }
     }
 }



More information about the vlc-commits mailing list