Commit 5e3d29c7 authored by Laurent Aimar's avatar Laurent Aimar

Implemented sout string escaping in QT.

parent ce1a1d96
...@@ -94,6 +94,78 @@ struct sout_gui_descr_t ...@@ -94,6 +94,78 @@ struct sout_gui_descr_t
struct streaming_account_t sa_icecast; /*< Icecast account information */ struct streaming_account_t sa_icecast; /*< Icecast account information */
}; };
class SoutMrl
{
public:
SoutMrl( const QString head = "")
{
mrl = head;
b_first = true;
b_has_bracket = false;
}
QString getMrl()
{
return mrl;
}
void begin( QString module )
{
if( !b_first )
mrl += ":";
b_first = false;
mrl += module;
b_has_bracket = false;
}
void end()
{
if( b_has_bracket )
mrl += "}";
}
void option( const QString option, const QString value = "" )
{
if( !b_has_bracket )
mrl += "{";
else
mrl += ",";
b_has_bracket = true;
mrl += option;
if( !value.isEmpty() )
{
char *psz = config_StringEscape( qta(value) );
if( psz )
{
QString v = QString( psz );
mrl += "=\"" + v + "\"";
free( psz );
}
}
}
void option( const QString name, const int i_value, const int i_precision = 10 )
{
option( name, QString::number( i_value, i_precision ) );
}
void option( const QString name, const double f_value )
{
option( name, QString::number( f_value ) );
}
void option( const QString name, const QString base, const int i_value, const int i_precision = 10 )
{
option( name, base + ":" + QString::number( i_value, i_precision ) );
}
private:
QString mrl;
bool b_has_bracket;
bool b_first;
};
SoutDialog* SoutDialog::instance = NULL; SoutDialog* SoutDialog::instance = NULL;
SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf, SoutDialog::SoutDialog( QWidget *parent, intf_thread_t *_p_intf,
...@@ -448,44 +520,32 @@ void SoutDialog::updateMRL() ...@@ -448,44 +520,32 @@ void SoutDialog::updateMRL()
bool trans = false; bool trans = false;
bool more = false; bool more = false;
SoutMrl smrl( ":sout=#" );
if ( ui.transcodeVideo->isChecked() || ui.transcodeAudio->isChecked() if ( ui.transcodeVideo->isChecked() || ui.transcodeAudio->isChecked()
&& !ui.rawInput->isChecked() /*demuxdump speciality*/ ) && !ui.rawInput->isChecked() /*demuxdump speciality*/ )
{ {
smrl.begin( "transcode" );
if ( ui.transcodeVideo->isChecked() ) if ( ui.transcodeVideo->isChecked() )
{ {
mrl = ":sout=#transcode{"; smrl.option( "vcodec", sout.psz_vcodec );
mrl.append( "vcodec=" ); smrl.option( "vb", sout.i_vb );
mrl.append( sout.psz_vcodec ); smrl.option( "scale", sout.f_scale );
mrl.append( "," );
mrl.append( "vb=" );
mrl.append( QString::number( sout.i_vb,10 ) );
mrl.append( "," );
mrl.append( "scale=" );
mrl.append( QString::number( sout.f_scale ) );
trans = true; trans = true;
} }
if ( ui.transcodeAudio->isChecked() ) if ( ui.transcodeAudio->isChecked() )
{ {
if ( trans ) smrl.option( "acodec", sout.psz_acodec );
{ smrl.option( "ab", sout.i_ab );
mrl.append( "," ); smrl.option( "channels", sout.i_channels );
}
else
{
mrl = ":sout=#transcode{";
}
mrl.append( "acodec=" );
mrl.append( sout.psz_acodec );
mrl.append( "," );
mrl.append( "ab=" );
mrl.append( QString::number( sout.i_ab,10 ) );
mrl.append( "," );
mrl.append( "channels=" );
mrl.append( QString::number( sout.i_channels,10 ) );
trans = true; trans = true;
} }
mrl.append( "}" );
smrl.end();
mrl = smrl.getMrl();
} }
/* Special case for demuxdump */ /* Special case for demuxdump */
...@@ -501,146 +561,137 @@ void SoutDialog::updateMRL() ...@@ -501,146 +561,137 @@ void SoutDialog::updateMRL()
if ( sout.b_local || sout.b_file || sout.b_http || if ( sout.b_local || sout.b_file || sout.b_http ||
sout.b_mms || sout.b_rtp || sout.b_udp || sout.b_icecast ) sout.b_mms || sout.b_rtp || sout.b_udp || sout.b_icecast )
{ {
if( counter > 1 )
smrl.begin( "duplicate" );
#define ISMORE() if ( more ) mrl.append( "," ) #define ADD(m) do { if( counter > 1 ) { \
#define ATLEASTONE() if ( counter ) mrl.append( "dst=" ) smrl.option( "dst", m.getMrl() ); \
} else { \
#define CHECKMUX() \ smrl.begin( m.getMrl() ); \
if( sout.psz_mux ) \ smrl.end(); \
{ \ } } while(0)
mrl.append( ",mux=");\
mrl.append( sout.psz_mux ); \
}
if ( trans )
mrl.append( ":" );
else
mrl = ":sout=#";
if ( counter )
mrl.append( "duplicate{" );
if ( sout.b_local ) if ( sout.b_local )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE(); m.begin( "display" );
mrl.append( "display" ); m.end();
ADD( m );
more = true; more = true;
} }
if ( sout.b_file ) if ( sout.b_file )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE();
mrl.append( "std{access=file" ); m.begin( "std" );
CHECKMUX(); m.option( "access", "file" );
mrl.append( ",dst=" ); if( sout.psz_mux )
mrl.append( sout.psz_file ); m.option( "mux", sout.psz_mux );
mrl.append( "}" ); m.option( "dst", sout.psz_file );
m.end();
ADD( m );
more = true; more = true;
} }
if ( sout.b_http ) if ( sout.b_http )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE();
mrl.append( "std{access=http" ); m.begin( "std" );
CHECKMUX(); m.option( "access", "http" );
mrl.append( ",dst=" ); if( sout.psz_mux )
mrl.append( sout.psz_http ); m.option( "mux", sout.psz_mux );
mrl.append( ":" ); m.option( "dst", sout.psz_http, sout.i_http );
mrl.append( QString::number( sout.i_http,10 ) ); m.end();
mrl.append( "}" );
ADD( m );
more = true; more = true;
} }
if ( sout.b_mms ) if ( sout.b_mms )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE();
mrl.append( "std{access=mmsh" ); m.begin( "std" );
CHECKMUX(); m.option( "access", "mmsh" );
mrl.append( ",dst=" ); m.option( "mux", "asfh" );
mrl.append( sout.psz_mms ); m.option( "dst", sout.psz_mms, sout.i_mms );
mrl.append( ":" ); m.end();
mrl.append( QString::number( sout.i_mms,10 ) );
mrl.append( "}" ); ADD( m );
more = true; more = true;
} }
if ( sout.b_rtp ) if ( sout.b_rtp )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE();
if ( sout.b_udp ) if ( sout.b_udp )
{ {
mrl.append( "std{access=udp" ); m.begin( "std" );
CHECKMUX(); m.option( "access", "udp" );
mrl.append( ",dst=" ); if( sout.psz_mux )
mrl.append( sout.psz_udp ); m.option( "mux", sout.psz_mux );
mrl.append( ":" ); m.option( "dst", sout.psz_udp, sout.i_udp );
mrl.append( QString::number( sout.i_udp,10 ) );
} }
else else
{ {
mrl.append( "rtp{" ); m.begin( "rtp" );
mrl.append( "dst=" );
mrl.append( sout.psz_rtp ); if( sout.psz_rtp && *sout.psz_rtp )
CHECKMUX(); m.option( "dst", sout.psz_rtp );
mrl.append( ",port=" ); if( sout.psz_mux )
mrl.append( QString::number( sout.i_rtp,10 ) ); m.option( "mux", sout.psz_mux );
m.option( "port", sout.i_rtp );
if( !sout.psz_mux || strncmp( sout.psz_mux, "ts", 2 ) ) if( !sout.psz_mux || strncmp( sout.psz_mux, "ts", 2 ) )
{ {
mrl.append( ",port-audio=" ); m.option( "port-audio", sout.i_rtp_audio );
mrl.append( QString::number( sout.i_rtp_audio, 10 ) ); m.option( "port-video", sout.i_rtp_video );
mrl.append( ",port-video=" );
mrl.append( QString::number( sout.i_rtp_video, 10 ) );
} }
} }
/* SAP */ /* SAP */
if ( sout.b_sap ) if ( sout.b_sap )
{ {
mrl.append( ",sap," ); m.option( "sap" );
mrl.append( "group=\"" ); m.option( "group", sout.psz_group );
mrl.append( sout.psz_group ); m.option( "name", sout.psz_name );
mrl.append( "\"," );
mrl.append( "name=\"" );
mrl.append( sout.psz_name );
mrl.append( "\"" );
} }
mrl.append( "}" ); m.end();
ADD( m );
more = true; more = true;
} }
if( sout.b_icecast ) if( sout.b_icecast )
{ {
ISMORE(); SoutMrl m;
ATLEASTONE(); QString url;
mrl.append( "std{access=shout,mux=ogg" );
mrl.append( ",dst=" ); url = QString(sout.sa_icecast.psz_username) + "@" + sout.psz_icecast + ":" +
mrl.append( sout.sa_icecast.psz_username ); QString::number( sout.i_icecast, 10 ) + "/" + sout.psz_icecast_mountpoint;
mrl.append( "@" );
mrl.append( sout.psz_icecast ); m.begin( "std" );
mrl.append( ":" ); m.option( "access", "shout" );
mrl.append( QString::number( sout.i_icecast, 10 ) ); m.option( "mux", "ogg" );
mrl.append( "/" ); m.option( "dst", url );
mrl.append( sout.psz_icecast_mountpoint ); m.end();
mrl.append( "}" );
ADD( m );
more = true; more = true;
} }
if ( counter ) if ( counter )
{ smrl.end();
mrl.append( "}" );
}
}
#undef CHECKMUX mrl = smrl.getMrl();
}
if ( sout.b_all_es ) if ( sout.b_all_es )
mrl.append( ":sout-all" ); mrl.append( " :sout-all" );
ui.mrlEdit->setText( mrl ); ui.mrlEdit->setText( mrl );
free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec ); free( sout.psz_acodec ); free( sout.psz_vcodec ); free( sout.psz_scodec );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment