[vlmc-devel] ITrack: Implement a hide function to replace setMute and setVideoEnabled

Yikai Lu git at videolan.org
Mon Aug 7 19:18:16 CEST 2017


vlmc | branch: master | Yikai Lu <luyikei.qmltu at gmail.com> | Tue Aug  8 00:43:43 2017 +0900| [e7b875f2e88754cadb6d92cc6626877e932d2c7f] | committer: Yikai Lu

ITrack: Implement a hide function to replace setMute and setVideoEnabled

> https://code.videolan.org/videolan/vlmc/commit/e7b875f2e88754cadb6d92cc6626877e932d2c7f
---

 src/Backend/ITrack.h              | 11 +++++++++--
 src/Backend/MLT/MLTTrack.cpp      | 36 ++----------------------------------
 src/Backend/MLT/MLTTrack.h        |  4 +---
 src/Workflow/SequenceWorkflow.cpp |  4 ++--
 4 files changed, 14 insertions(+), 41 deletions(-)

diff --git a/src/Backend/ITrack.h b/src/Backend/ITrack.h
index f9c9a463..196a6224 100644
--- a/src/Backend/ITrack.h
+++ b/src/Backend/ITrack.h
@@ -28,6 +28,14 @@
 
 namespace Backend
 {
+    enum class HideType
+    {
+        None,
+        Video,
+        Audio,
+        VideoAndAudio
+    };
+
     class ITrack : virtual public IInput
     {
     public:
@@ -45,8 +53,7 @@ namespace Backend
         virtual int         count() const = 0;
         virtual void        clear() = 0;
 
-        virtual void        setMute( bool muted ) = 0;
-        virtual void        setVideoEnabled( bool enabled ) = 0;
+        virtual void        hide( HideType hideType ) = 0;
     };
 }
 
diff --git a/src/Backend/MLT/MLTTrack.cpp b/src/Backend/MLT/MLTTrack.cpp
index b0ccd16a..90a81c63 100644
--- a/src/Backend/MLT/MLTTrack.cpp
+++ b/src/Backend/MLT/MLTTrack.cpp
@@ -35,14 +35,6 @@
 
 using namespace Backend::MLT;
 
-enum HideType
-{
-    None,
-    Video,
-    Audio,
-    VideoAndAudio
-};
-
 MLTTrack::MLTTrack()
     : MLTTrack( Backend::instance()->profile() )
 {
@@ -161,31 +153,7 @@ MLTTrack::clear()
 }
 
 void
-MLTTrack::setMute( bool muted )
+MLTTrack::hide( Backend::HideType hydeType )
 {
-    if ( muted == false )
-        if ( playlist()->get_int( "hide" ) == HideType::VideoAndAudio )
-            playlist()->set( "hide", HideType::Video );
-        else
-            playlist()->set( "hide", HideType::None );
-    else
-        if ( playlist()->get_int( "hide" ) == HideType::Video )
-            playlist()->set( "hide", HideType::VideoAndAudio );
-        else
-            playlist()->set( "hide", HideType::Audio );
-}
-
-void
-MLTTrack::setVideoEnabled( bool enabled )
-{
-    if ( enabled == true )
-        if ( playlist()->get_int( "hide" ) == HideType::VideoAndAudio )
-            playlist()->set( "hide", HideType::Audio );
-        else
-            playlist()->set( "hide", HideType::None );
-    else
-        if ( playlist()->get_int( "hide" ) == HideType::Audio )
-            playlist()->set( "hide", HideType::VideoAndAudio );
-        else
-            playlist()->set( "hide", HideType::Video );
+    playlist()->set( "hide", static_cast<int>( hydeType ) );
 }
diff --git a/src/Backend/MLT/MLTTrack.h b/src/Backend/MLT/MLTTrack.h
index abd6d751..b08f4880 100644
--- a/src/Backend/MLT/MLTTrack.h
+++ b/src/Backend/MLT/MLTTrack.h
@@ -61,9 +61,7 @@ class MLTTrack : public ITrack, public MLTInput
         virtual int         clipIndexAt( int64_t position ) override;
         virtual int         count() const override;
         virtual void        clear() override;
-
-        virtual void        setMute( bool muted ) override;
-        virtual void        setVideoEnabled( bool enabled ) override;
+        virtual void        hide( HideType hideType ) override;
 
     private:
         Mlt::Playlist*                  m_playlist;
diff --git a/src/Workflow/SequenceWorkflow.cpp b/src/Workflow/SequenceWorkflow.cpp
index 498fc731..dad9a1f8 100644
--- a/src/Workflow/SequenceWorkflow.cpp
+++ b/src/Workflow/SequenceWorkflow.cpp
@@ -42,11 +42,11 @@ SequenceWorkflow::SequenceWorkflow( size_t trackCount )
     for ( int i = 0; i < trackCount; ++i )
     {
         auto audioTrack = std::shared_ptr<Backend::ITrack>( new Backend::MLT::MLTTrack );
-        audioTrack->setVideoEnabled( false );
+        audioTrack->hide( Backend::HideType::Video );
         m_tracks[Workflow::AudioTrack] << audioTrack;
 
         auto videoTrack = std::shared_ptr<Backend::ITrack>( new Backend::MLT::MLTTrack );
-        videoTrack->setMute( true );
+        videoTrack->hide( Backend::HideType::Audio );
         m_tracks[Workflow::VideoTrack] << videoTrack;
 
         auto multitrack = std::shared_ptr<Backend::IMultiTrack>( new Backend::MLT::MLTMultiTrack );



More information about the Vlmc-devel mailing list