[vlc-commits] [Git][videolan/vlc][master] 5 commits: qt: fix transcode wizard mrl

François Cartegnie (@fcartegnie) gitlab at videolan.org
Thu Jun 2 08:34:39 UTC 2022



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


Commits:
1bcd4e83 by Francois Cartegnie at 2022-06-02T08:18:53+00:00
qt: fix transcode wizard mrl

- - - - -
663b56b8 by Francois Cartegnie at 2022-06-02T08:18:53+00:00
qt: soutchain: escape and quote strings at value level

- - - - -
6dd7f461 by Francois Cartegnie at 2022-06-02T08:18:53+00:00
qt: sout: don't set quotes or escape filename as value

- - - - -
c4219dd4 by Francois Cartegnie at 2022-06-02T08:18:53+00:00
qt: sout: add missing global option prefix

- - - - -
3e419fb3 by Francois Cartegnie at 2022-06-02T08:18:53+00:00
qt: sout: fix double escaping with chains as value

- - - - -


5 changed files:

- modules/gui/qt/dialogs/dialogs_provider.cpp
- modules/gui/qt/dialogs/sout/convert.cpp
- modules/gui/qt/dialogs/sout/sout.cpp
- modules/gui/qt/util/soutchain.cpp
- modules/gui/qt/util/soutchain.hpp


Changes:

=====================================
modules/gui/qt/dialogs/dialogs_provider.cpp
=====================================
@@ -780,15 +780,17 @@ void DialogsProvider::streamingDialog( QWindow *parent,
     }
 
     /* Get SoutChain(s) */
-    if( !outputMRLs.isEmpty() )
+    QVector<vlc::playlist::Media> outputMedias;
+
+    for( auto it = outputMRLs.cbegin(); it != outputMRLs.cend(); ++it )
     {
-        QVector<vlc::playlist::Media> outputMedias;
-        std::transform(outputMRLs.cbegin(), outputMRLs.cend(), std::back_inserter(outputMedias), [&](const QString& mrl) {
-            QString title = "Converting " + mrl;
-            return vlc::playlist::Media(mrl, title, options);
-        });
-        THEMPL->append(outputMedias, true);
+        const QString &mrl = mrls[std::distance(outputMRLs.cbegin(), it)];
+        QString title = "Converting " + mrl;
+        outputMedias.append(vlc::playlist::Media(mrl, title, options + (*it).split(" :")));
     }
+
+    if( !outputMedias.empty() )
+        THEMPL->append(outputMedias, true);
 }
 
 void DialogsProvider::streamingDialog(const QList<QUrl> &urls, bool b_stream )


=====================================
modules/gui/qt/dialogs/sout/convert.cpp
=====================================
@@ -181,12 +181,12 @@ void ConvertDialog::close()
 
         if( dumpRadio->isChecked() )
         {
-            mrl.header("demux=dump :demuxdump-file=" + fileLine->text());
+            mrl.header(" :demux=dump :demuxdump-file=" + fileLine->text());
         }
         else
         {
             mrl = profile->getTranscode();
-            mrl.header( "sout=#" + mrl.getHeader() );
+            mrl.header( " :sout=#" + mrl.getHeader() );
             if( deinterBox->isChecked() )
             {
                 mrl.option("deinterlace");
@@ -227,16 +227,13 @@ void ConvertDialog::close()
                 newFileName = newFileName.append(fileExtension);
             }
 
-            newFileName.replace( QChar('\''), "\\\'" );
-
-
             mrl.end();
             SoutModule dstModule("std");
             SoutModule file("file");
             file.option("no-overwrite");
             dstModule.option("access", file);
             dstModule.option("mux", profile->getMux());
-            dstModule.option("dst", "'" + newFileName + "'");
+            dstModule.option("dst", newFileName);
 
             if( displayBox->isChecked() )
             {


=====================================
modules/gui/qt/dialogs/sout/sout.cpp
=====================================
@@ -197,7 +197,7 @@ void SoutDialog::updateChain()
         if( tempMRL.isEmpty() ) continue;
 
         if( multi )
-            smrl.option( "dst", tempMRL );
+            smrl.option( "dst", tempMRL, true );
         else
         {
             smrl.begin( tempMRL);


=====================================
modules/gui/qt/util/soutchain.cpp
=====================================
@@ -22,6 +22,34 @@
 
 #include "soutchain.hpp"
 
+QString SoutOption::to_string() const
+{
+    if( kind == EscapedString )
+    {
+        return stringValue;
+    }
+    if( kind == String )
+    {
+        QString ret = "";
+        if( !stringValue.isEmpty() )
+        {
+            QString quotes = stringValue.toStdString().find_first_of("=, \t")
+                           != std::string::npos ? "'" : "";
+            char *psz = config_StringEscape( qtu(stringValue) );
+            if( psz )
+            {
+                ret = quotes + qfu( psz ) + quotes;
+                free( psz );
+            }
+        }
+        return ret;
+    }
+    else
+    {
+        return nestedModule.to_string();
+    }
+}
+
 QString SoutModule::to_string() const
 {
     QString s = moduleName;
@@ -34,15 +62,9 @@ QString SoutModule::to_string() const
     for( it=options.begin(); it!=options.end(); )
     {
         s += it->first;
-        if( it->second.to_string().compare("") != 0 )
-        {
-            char *psz = config_StringEscape( qtu(it->second.to_string()) );
-            if( psz )
-            {
-                s += "=" + qfu( psz );
-                free( psz );
-            }
-        }
+        QString value = it->second.to_string();
+        if( !value.isEmpty() )
+            s += "=" + value;
         ++it;
         if( it != options.end() )
         {
@@ -60,6 +82,12 @@ void SoutModule::option( const QString& option, const SoutOption& value )
 {
     options.append( OptionPairType( option, value ) );
 }
+
+void SoutModule::option( const QString& option, const QString& value, bool escaped )
+{
+    options.append( OptionPairType( option, SoutOption(value, escaped) ) );
+}
+
 void SoutModule::option( const QString& option )
 {
     options.append( OptionPairType( option, "" ) );
@@ -85,11 +113,11 @@ QString SoutChain::to_string() const
     return chain;
 }
 
-void SoutChain::option( const QString& name, const QString& value )
+void SoutChain::option( const QString& name, const QString& value, bool escaped )
 {
     if( modules.size() > 0 )
     {
-        modules.back().option( name, value );
+        modules.back().option( name, value, escaped );
     }
 }
 void SoutChain::option( const QString& name, const int i_value, const int i_precision )


=====================================
modules/gui/qt/util/soutchain.hpp
=====================================
@@ -38,8 +38,9 @@ public:
     {
     }
 
-    void option( const QString& option, const SoutOption& value );
-    void option( const QString& option );
+    void option( const QString& name, const SoutOption& value );
+    void option( const QString& name, const QString& value, bool escaped );
+    void option( const QString& name );
     QString to_string() const;
 
 private:
@@ -53,14 +54,14 @@ private:
 class SoutOption
 {
 public:
-    SoutOption( const QString& value ) :
-        kind( String ),
+    SoutOption( const QString& value, bool escaped = false ) :
+        kind( escaped ? EscapedString : String ),
         stringValue( value ),
         nestedModule("")
     {}
 
-    SoutOption( const char* s ) :
-        SoutOption( QString(s) )
+    SoutOption( const char* s, bool escaped = false ) :
+        SoutOption( QString(s), escaped )
     {}
 
     SoutOption( const SoutModule& module ) :
@@ -68,19 +69,10 @@ public:
         nestedModule(module)
     {}
 
-    QString to_string() const{
-        if( kind == String )
-        {
-            return stringValue;
-        }
-        else
-        {
-            return nestedModule.to_string();
-        }
-    }
+    QString to_string() const;
 
 private:
-    enum Kind{ String, Nested };
+    enum Kind{ String, EscapedString, Nested };
     Kind kind;
     QString stringValue;
     SoutModule nestedModule;
@@ -133,7 +125,7 @@ public:
     }
 
     // These should be only in SoutModule, but they are kept in this parent class for compatibility with an older API
-    void option( const QString& name, const QString& value = "" );
+    void option( const QString& name, const QString& value = "", bool escaped = false );
     void option( const QString& name, const int i_value, const int i_precision = 10 );
     void option( const QString& name, const double f_value );
     void option( const QString& name, const QString& base, const int i_value, const int i_precision = 10 );



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/56ab65e9ea5415ea8c1b4fd2685126d9b95107cf...3e419fb3af3bd759ddb9155b86a79274677d2ddd

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/56ab65e9ea5415ea8c1b4fd2685126d9b95107cf...3e419fb3af3bd759ddb9155b86a79274677d2ddd
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