[vlc-commits] demux: adaptive: add Role

Francois Cartegnie git at videolan.org
Fri May 17 20:34:56 CEST 2019


vlc | branch: master | Francois Cartegnie <fcvlcdev at free.fr> | Tue May 14 21:11:26 2019 +0200| [e89ff9e9e1e10d84a77efe9d51bfb869fdda1db1] | committer: Francois Cartegnie

demux: adaptive: add Role

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

 modules/demux/Makefile.am                          |  2 +
 .../demux/adaptive/playlist/BaseAdaptationSet.cpp  | 10 +++++
 .../demux/adaptive/playlist/BaseAdaptationSet.h    |  4 ++
 modules/demux/adaptive/playlist/Role.cpp           | 50 ++++++++++++++++++++++
 modules/demux/adaptive/playlist/Role.hpp           | 48 +++++++++++++++++++++
 5 files changed, 114 insertions(+)

diff --git a/modules/demux/Makefile.am b/modules/demux/Makefile.am
index fa049f8675..536781d9a1 100644
--- a/modules/demux/Makefile.am
+++ b/modules/demux/Makefile.am
@@ -300,6 +300,8 @@ libadaptive_plugin_la_SOURCES = \
     demux/adaptive/playlist/ICanonicalUrl.hpp \
     demux/adaptive/playlist/Inheritables.hpp \
     demux/adaptive/playlist/Inheritables.cpp \
+    demux/adaptive/playlist/Role.hpp \
+    demux/adaptive/playlist/Role.cpp \
     demux/adaptive/playlist/Segment.cpp \
     demux/adaptive/playlist/Segment.h \
     demux/adaptive/playlist/SegmentBase.cpp \
diff --git a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
index 64e9cfbdab..228a90ae78 100644
--- a/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
+++ b/modules/demux/adaptive/playlist/BaseAdaptationSet.cpp
@@ -123,6 +123,16 @@ bool BaseAdaptationSet::isBitSwitchable() const
     return bitswitchAble == TRIBOOL_TRUE;
 }
 
+void BaseAdaptationSet::setRole(const Role &r)
+{
+    role = r;
+}
+
+const Role & BaseAdaptationSet::getRole() const
+{
+    return role;
+}
+
 void BaseAdaptationSet::debug(vlc_object_t *obj, int indent) const
 {
     std::string text(indent, ' ');
diff --git a/modules/demux/adaptive/playlist/BaseAdaptationSet.h b/modules/demux/adaptive/playlist/BaseAdaptationSet.h
index da795bac37..a3b1ca3b72 100644
--- a/modules/demux/adaptive/playlist/BaseAdaptationSet.h
+++ b/modules/demux/adaptive/playlist/BaseAdaptationSet.h
@@ -30,6 +30,7 @@
 
 #include "CommonAttributesElements.h"
 #include "SegmentInformation.hpp"
+#include "Role.hpp"
 #include "../StreamFormat.hpp"
 
 namespace adaptive
@@ -55,6 +56,8 @@ namespace adaptive
                 bool                            isSegmentAligned() const;
                 void                            setBitswitchAble(bool);
                 bool                            isBitSwitchable() const;
+                void                            setRole(const Role &);
+                const Role &                    getRole() const;
                 void                            addRepresentation( BaseRepresentation *rep );
                 const std::string&              getLang() const;
                 void                            setLang( const std::string &lang );
@@ -62,6 +65,7 @@ namespace adaptive
                 Property<std::string>           description;
 
             protected:
+                Role                            role;
                 std::vector<BaseRepresentation *>   representations;
                 std::string                     lang;
                 Tribool                         segmentAligned;
diff --git a/modules/demux/adaptive/playlist/Role.cpp b/modules/demux/adaptive/playlist/Role.cpp
new file mode 100644
index 0000000000..828455a571
--- /dev/null
+++ b/modules/demux/adaptive/playlist/Role.cpp
@@ -0,0 +1,50 @@
+/*****************************************************************************
+ * Role.cpp
+ *****************************************************************************
+ * Copyright (C) 2019 VideoLabs, VideoLAN and VLC Authors
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "Role.hpp"
+
+using namespace adaptive;
+using namespace adaptive::playlist;
+
+Role::Role(unsigned r)
+{
+    value = r;
+}
+
+bool Role::operator ==(const Role &other) const
+{
+    return value == other.value;
+}
+
+bool Role::isDefault() const
+{
+    return value == MAIN;
+}
+
+bool Role::autoSelectable() const
+{
+    return value == MAIN ||
+           value == ALTERNATE ||
+           value == SUBTITLE ||
+           value == CAPTION;
+}
diff --git a/modules/demux/adaptive/playlist/Role.hpp b/modules/demux/adaptive/playlist/Role.hpp
new file mode 100644
index 0000000000..6b703c7d85
--- /dev/null
+++ b/modules/demux/adaptive/playlist/Role.hpp
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Role.hpp
+ *****************************************************************************
+ * Copyright (C) 2019 VideoLabs, VideoLAN and VLC Authors
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+#ifndef ROLE_HPP_
+#define ROLE_HPP_
+
+namespace adaptive
+{
+    namespace playlist
+    {
+        class Role
+        {
+            public:
+                static const unsigned MAIN           = 0;
+                static const unsigned ALTERNATE      = 1;
+                static const unsigned SUPPLEMENTARY  = 2;
+                static const unsigned COMMENTARY     = 3;
+                static const unsigned DUB            = 4;
+                static const unsigned CAPTION        = 5;
+                static const unsigned SUBTITLE       = 6;
+                Role(unsigned = ALTERNATE);
+                bool operator==(const Role &) const;
+                bool isDefault() const;
+                bool autoSelectable() const;
+
+            private:
+                unsigned value;
+        };
+    }
+}
+
+#endif



More information about the vlc-commits mailing list