Commit 2849bcdd authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

[Qt] Fix Network Open Tab

Network Open Tab assumes all rtp/udp addresses are multicast #2221
Please review.
parent 2e1619c2
...@@ -471,8 +471,13 @@ void NetOpenPanel::updateProtocol( int idx_proto ) { ...@@ -471,8 +471,13 @@ void NetOpenPanel::updateProtocol( int idx_proto ) {
{ {
if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO ) if( idx_proto != UDP_PROTO && idx_proto != RTP_PROTO )
addr.replace( QRegExp("^.*://@*"), proto + "://"); addr.replace( QRegExp("^.*://@*"), proto + "://");
else else if ( ( addr.contains(QRegExp("://((22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:))"))) ||
( !addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}")) &&
!addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:")) ) )
addr.replace( QRegExp("^.*://"), proto + "://@"); addr.replace( QRegExp("^.*://"), proto + "://@");
else
addr.replace( QRegExp("^.*://"), proto + "://");
addr.replace( QRegExp("@+"), "@");
ui.addressText->setText( addr ); ui.addressText->setText( addr );
} }
updateMRL(); updateMRL();
...@@ -483,14 +488,15 @@ void NetOpenPanel::updateMRL() { ...@@ -483,14 +488,15 @@ void NetOpenPanel::updateMRL() {
QString addr = ui.addressText->text(); QString addr = ui.addressText->text();
addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" ); addr = QUrl::toPercentEncoding( addr, ":/?#@!$&'()*+,;=" );
int idx_proto = ui.protocolCombo->currentIndex(); int idx_proto = ui.protocolCombo->currentIndex();
int addr_is_multicast = addr.contains(QRegExp("^(22[4-9])|(23\\d)|(\\[?[fF]{2}[0-9a-fA-F]{2}:)"))?1:0;
int addr_is_ipv4 = addr.contains(QRegExp("^\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}[.]\\d{1,3}"))?1:0;
int addr_is_ipv6 = addr.contains(QRegExp(":[a-fA-F0-9]{1,4}:"))?1:0;
int addr_has_port = addr.contains(QRegExp("[^:]{5}:\\d{1,5}$"))?1:0;
if( addr.contains( "://")) if( addr.contains( "://"))
{ {
/* Match the correct item in the comboBox */ /* Match the correct item in the comboBox */
ui.protocolCombo->setCurrentIndex( ui.protocolCombo->setCurrentIndex(
ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) ); ui.protocolCombo->findData( addr.section( ':', 0, 0 ) ) );
if( idx_proto != UDP_PROTO || idx_proto != RTP_PROTO )
mrl = addr; mrl = addr;
} }
else else
...@@ -517,22 +523,30 @@ void NetOpenPanel::updateMRL() { ...@@ -517,22 +523,30 @@ void NetOpenPanel::updateMRL() {
emit methodChanged("rtsp-caching"); emit methodChanged("rtsp-caching");
break; break;
case UDP_PROTO: case UDP_PROTO:
if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
mrl = "udp://@"; mrl = "udp://@";
else
mrl = "udp://";
/* Add [] to IPv6 */ /* Add [] to IPv6 */
if ( addr.contains(':') && !addr.contains('[') ) if ( addr_is_ipv6 && !addr.contains('[') )
{ {
mrl += "[" + addr + "]"; mrl += "[" + addr + "]";
} }
else mrl += addr; else mrl += addr;
if(!addr_has_port)
mrl += QString(":%1").arg( ui.portSpin->value() ); mrl += QString(":%1").arg( ui.portSpin->value() );
emit methodChanged("udp-caching"); emit methodChanged("udp-caching");
break; break;
case RTP_PROTO: case RTP_PROTO:
if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 ))
mrl = "rtp://@"; mrl = "rtp://@";
if ( addr.contains(':') && !addr.contains('[') ) else
mrl = "rtp://";
if ( addr_is_ipv6 && !addr.contains('[') )
mrl += "[" + addr + "]"; /* Add [] to IPv6 */ mrl += "[" + addr + "]"; /* Add [] to IPv6 */
else else
mrl += addr; mrl += addr;
if(!addr_has_port)
mrl += QString(":%1").arg( ui.portSpin->value() ); mrl += QString(":%1").arg( ui.portSpin->value() );
emit methodChanged("rtp-caching"); emit methodChanged("rtp-caching");
break; break;
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <QTabWidget> #include <QTabWidget>
#include <QGridLayout> #include <QGridLayout>
#include <QFileDialog>
#include <QRegExp> #include <QRegExp>
#include <QMenu> #include <QMenu>
......
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