[vlmc-devel] Backend: Implement transitionInfo

Yikai Lu git at videolan.org
Tue Jun 27 18:09:09 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Wed Jun 28 01:07:39 2017 +0900| [1ea522ad6b27e8a5c7591e7cc46cca5af93f4bdb] | committer: Yikai Lu

Backend: Implement transitionInfo

> https://code.videolan.org/videolan/vlmc/commit/1ea522ad6b27e8a5c7591e7cc46cca5af93f4bdb
---

 src/Backend/IBackend.h         |  2 ++
 src/Backend/MLT/MLTBackend.cpp | 28 ++++++++++++++++++++++++++++
 src/Backend/MLT/MLTBackend.h   |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/src/Backend/IBackend.h b/src/Backend/IBackend.h
index 6ec991ac..99285a12 100644
--- a/src/Backend/IBackend.h
+++ b/src/Backend/IBackend.h
@@ -51,7 +51,9 @@ class IBackend
         virtual ~IBackend() = default;
         virtual IProfile&                   profile() = 0;
         virtual const std::map<std::string, IInfo*>&          availableFilters() const = 0;
+        virtual const std::map<std::string, IInfo*>&          availableTransitions() const = 0;
         virtual IInfo*                                        filterInfo( const std::string& id ) const = 0;
+        virtual IInfo*                                        transitionInfo( const std::string& id ) const = 0;
 
         virtual void                        setLogHandler( LogHandler logHandler ) = 0;
 };
diff --git a/src/Backend/MLT/MLTBackend.cpp b/src/Backend/MLT/MLTBackend.cpp
index 651083f7..479327b5 100644
--- a/src/Backend/MLT/MLTBackend.cpp
+++ b/src/Backend/MLT/MLTBackend.cpp
@@ -72,6 +72,19 @@ MLTBackend::MLTBackend()
         }
         m_availableFilters[ filterInfo->identifier() ] = filterInfo;
     }
+
+    for ( int i = 0; i < m_mltRepo->transitions()->count(); ++i )
+    {
+        auto pro = std::unique_ptr<Mlt::Properties>( m_mltRepo->metadata( transition_type, m_mltRepo->transitions()->get_name( i ) ) );
+        auto transitionInfo = new MLTServiceInfo;
+        transitionInfo->setProperties( pro.get() );
+        if ( transitionInfo->identifier().empty() == true )
+        {
+            delete transitionInfo;
+            continue;
+        }
+        m_availableTransitions[ transitionInfo->identifier() ] = transitionInfo;
+    }
 }
 
 MLTBackend::~MLTBackend()
@@ -94,6 +107,12 @@ MLTBackend::availableFilters() const
     return m_availableFilters;
 }
 
+const std::map<std::string, IInfo *>&
+MLTBackend::availableTransitions() const
+{
+    return m_availableTransitions;
+}
+
 IInfo*
 MLTBackend::filterInfo( const std::string& id ) const
 {
@@ -103,6 +122,15 @@ MLTBackend::filterInfo( const std::string& id ) const
     return nullptr;
 }
 
+IInfo*
+MLTBackend::transitionInfo( const std::string& id ) const
+{
+    auto it = m_availableTransitions.find( id );
+    if ( it != m_availableTransitions.end() )
+        return (*it).second;
+    return nullptr;
+}
+
 void
 MLTBackend::setLogHandler( IBackend::LogHandler logHandler )
 {
diff --git a/src/Backend/MLT/MLTBackend.h b/src/Backend/MLT/MLTBackend.h
index f0fa40fa..6a2304f7 100644
--- a/src/Backend/MLT/MLTBackend.h
+++ b/src/Backend/MLT/MLTBackend.h
@@ -54,7 +54,9 @@ class MLTBackend : public IBackend, public Singleton<MLTBackend>
 
 
         virtual const std::map<std::string, IInfo*>&         availableFilters() const override;
+        virtual const std::map<std::string, IInfo*>&         availableTransitions() const override;
         virtual IInfo*                                       filterInfo( const std::string& id ) const override;
+        virtual IInfo*                                       transitionInfo( const std::string& id ) const override;
 
         virtual void            setLogHandler( LogHandler logHandler ) override;
 
@@ -65,6 +67,7 @@ class MLTBackend : public IBackend, public Singleton<MLTBackend>
         MLTProfile           m_profile;
 
         std::map<std::string, IInfo*>    m_availableFilters;
+        std::map<std::string, IInfo*>    m_availableTransitions;
 
     friend Singleton_t::AllowInstantiation;
 };



More information about the Vlmc-devel mailing list