Commit 0fc00a79 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Qt4: fix handling of IPv6 literal for RTP and UDP

See http://forum.videolan.org/viewtopic.php?f=33&t=60477
(cherry picked from commit 5b00f5cf)
parent 2839bb5b
...@@ -550,12 +550,7 @@ void NetOpenPanel::updateProtocol( int idx_proto ) { ...@@ -550,12 +550,7 @@ void NetOpenPanel::updateProtocol( int idx_proto ) {
void NetOpenPanel::updateMRL() { void NetOpenPanel::updateMRL() {
QString mrl = ""; QString mrl = "";
QString addr = ui.addressText->text(); QString addr = ui.addressText->text();
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 */
...@@ -586,33 +581,40 @@ void NetOpenPanel::updateMRL() { ...@@ -586,33 +581,40 @@ void NetOpenPanel::updateMRL() {
mrl = "rtsp://" + addr; mrl = "rtsp://" + addr;
emit methodChanged("rtsp-caching"); emit methodChanged("rtsp-caching");
break; break;
case RTP_PROTO:
case UDP_PROTO: case UDP_PROTO:
if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 )) mrl = qfu(((idx_proto == RTP_PROTO) ? "rtp" : "udp"));
mrl = "udp://@"; mrl += qfu( "://" );
if( addr[0] == ':' ) /* Port number without address */
mrl += addr;
else else
mrl = "udp://";
/* Add [] to IPv6 */
if ( addr_is_ipv6 && !addr.contains('[') )
{ {
mrl += "[" + addr + "]"; mrl += qfu( "@" );
} switch( addr.count( ":" ) )
else mrl += addr; {
if(!addr_has_port) case 0: /* DNS or IPv4 literal, no port number */
mrl += addr;
mrl += QString(":%1").arg( ui.portSpin->value() ); mrl += QString(":%1").arg( ui.portSpin->value() );
emit methodChanged("udp-caching");
break; break;
case RTP_PROTO: case 1: /* DNS or IPv4 literal plus port number */
if(( addr_is_multicast ) || ( !addr_is_ipv4 && !addr_is_ipv6 )) mrl += addr;
mrl = "rtp://@"; break;
else default: /* IPv6 literal */
mrl = "rtp://"; if( !addr.contains( "]:" ) )
if ( addr_is_ipv6 && !addr.contains('[') ) {
mrl += "[" + addr + "]"; /* Add [] to IPv6 */ if( addr[0] != '[' ) /* Missing brackets */
mrl += qfu( "[" ) + addr + qfu( "]" );
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"); }
else /* Brackets present, port present */
mrl += addr;
break;
}
}
emit methodChanged(idx_proto == RTP_PROTO
? "rtp-caching" : "udp-caching");
break; break;
case RTMP_PROTO: case RTMP_PROTO:
mrl = "rtmp://" + addr; mrl = "rtmp://" + addr;
......
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