Commit dcd1ba26 authored by Olivier Teulière's avatar Olivier Teulière

 * plugins/win32/network.*: new Network dialog box
parent 6f7d1706
...@@ -49,22 +49,25 @@ __fastcall TNetworkDlg::TNetworkDlg( TComponent* Owner ) ...@@ -49,22 +49,25 @@ __fastcall TNetworkDlg::TNetworkDlg( TComponent* Owner )
char *psz_channel_server; char *psz_channel_server;
/* server port */ /* server port */
UpDownPort->Position = config_GetIntVariable( "server-port" ); UpDownUDPPort->Position = config_GetIntVariable( "server-port" );
UpDownMulticastPort->Position = config_GetIntVariable( "server-port" );
/* channel server */ /* channel server */
if( config_GetIntVariable( "network-channel" ) ) if( config_GetIntVariable( "network-channel" ) )
{ {
CheckBoxChannel->Checked = true; RadioButtonCS->Checked = true;
} }
psz_channel_server = config_GetPszVariable( "channel-server" ); psz_channel_server = config_GetPszVariable( "channel-server" );
if( psz_channel_server ) if( psz_channel_server )
{ {
ComboBoxChannel->Text = psz_channel_server; ComboBoxCSAddress->Text = psz_channel_server;
free( psz_channel_server ); free( psz_channel_server );
} }
UpDownPortCS->Position = config_GetIntVariable( "channel-port" ); UpDownCSPort->Position = config_GetIntVariable( "channel-port" );
OldRadioValue = 0;
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TNetworkDlg::FormShow( TObject *Sender ) void __fastcall TNetworkDlg::FormShow( TObject *Sender )
...@@ -84,37 +87,15 @@ void __fastcall TNetworkDlg::BitBtnCancelClick( TObject *Sender ) ...@@ -84,37 +87,15 @@ void __fastcall TNetworkDlg::BitBtnCancelClick( TObject *Sender )
Hide(); Hide();
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TNetworkDlg::CheckBoxBroadcastClick( TObject *Sender )
{
ComboBoxBroadcast->Enabled = NOT( ComboBoxBroadcast->Enabled );
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::CheckBoxChannelClick( TObject *Sender )
{
LabelAddress->Enabled = NOT( LabelAddress->Enabled );
ComboBoxAddress->Enabled = NOT( ComboBoxAddress->Enabled );
LabelPort->Enabled = NOT( LabelPort->Enabled );
EditPort->Enabled = NOT( EditPort->Enabled );
UpDownPort->Enabled = NOT( UpDownPort->Enabled );
CheckBoxBroadcast->Enabled = NOT( CheckBoxBroadcast->Enabled );
ComboBoxBroadcast->Enabled = ( NOT( ComboBoxBroadcast->Enabled ) &&
CheckBoxBroadcast->Checked );
ComboBoxChannel->Enabled = NOT( ComboBoxChannel->Enabled );
LabelPortCS->Enabled = NOT( LabelPortCS->Enabled );
EditPortCS->Enabled = NOT( EditPortCS->Enabled );
UpDownPortCS->Enabled = NOT( UpDownPortCS->Enabled );
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender ) void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender )
{ {
AnsiString Source, Protocol, Server; AnsiString Source, Address;
boolean_t b_channel; AnsiString Channel = ComboBoxCSAddress->Text;
boolean_t b_broadcast; unsigned int i_channel_port = UpDownCSPort->Position;
unsigned int i_port; unsigned int i_port;
int i_end = p_main->p_playlist->i_size; int i_end = p_main->p_playlist->i_size;
Hide(); Hide();
Server = ComboBoxAddress->Text;
/* select added item */ /* select added item */
if( p_input_bank->pp_input[0] != NULL ) if( p_input_bank->pp_input[0] != NULL )
...@@ -122,74 +103,132 @@ void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender ) ...@@ -122,74 +103,132 @@ void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender )
p_input_bank->pp_input[0]->b_eof = 1; p_input_bank->pp_input[0]->b_eof = 1;
} }
/* Check which protocol was activated */ /* Check which option was chosen */
switch( RadioGroupProtocol->ItemIndex ) switch( OldRadioValue )
{ {
/* UDP */
case 0: case 0:
Protocol = "udp"; config_PutIntVariable( "network-channel", FALSE );
i_port = UpDownUDPPort->Position;
/* Build source name */
Source = "udp:@:" + IntToStr( i_port );
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
/* update the display */
p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
break; break;
/* UDP Multicast */
case 1: case 1:
intf_ErrMsg( "intf error: rtp protocol not yet implemented" ); config_PutIntVariable( "network-channel", FALSE );
return; Address = ComboBoxMulticastAddress->Text;
case 2: i_port = UpDownMulticastPort->Position;
Protocol = "http";
break;
}
/* Manage channel server */ /* Build source name */
b_channel = CheckBoxChannel->Checked ? TRUE : FALSE; Source = "udp:@" + Address + ":" + IntToStr( i_port );
config_PutIntVariable( "network-channel", b_channel );
if( b_channel )
{
AnsiString Channel = ComboBoxChannel->Text;
unsigned int i_channel_port = UpDownPortCS->Position;
if( p_main->p_channel == NULL ) intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
{
network_ChannelCreate();
}
config_PutPszVariable( "channel-server", Channel.c_str() ); /* update the display */
if( i_channel_port < 65536 ) p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
{
intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
break;
/* Channel server */
case 2:
config_PutIntVariable( "network-channel", TRUE );
config_PutPszVariable( "channel-server", Channel.c_str() );
config_PutIntVariable( "channel-port", i_channel_port ); config_PutIntVariable( "channel-port", i_channel_port );
}
p_intfGlobal->p_sys->b_playing = 1; if( p_main->p_channel == NULL )
} {
else network_ChannelCreate();
{ }
/* Get the port number and make sure it will not
* overflow 5 characters */
i_port = UpDownPort->Position;
if( i_port > 65535 )
{
intf_ErrMsg( "intf error: invalid port %i", i_port );
}
/* do we have a broadcast address */ p_intfGlobal->p_sys->b_playing = 1;
b_broadcast = CheckBoxBroadcast->Checked ? TRUE : FALSE; break;
if( b_broadcast )
{ /* HTTP */
AnsiString Broadcast = ComboBoxBroadcast->Text; case 3:
config_PutIntVariable( "network-channel", FALSE );
Address = EditHTTPURL->Text;
/* Build source name */ /* Build source name */
Source = Protocol + "://" + Server + "@:" + IntToStr( i_port ) Source = "http:" + Address;
+ "/" + Broadcast;
} intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
else
{
/* Build source name */
Source = Protocol + "://" + Server + "@:" + IntToStr( i_port );
}
intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() ); /* update the display */
p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
/* update the display */
p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 ); intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
break;
} }
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
void __fastcall TNetworkDlg::ChangeEnabled( int i_selected )
{
switch( i_selected )
{
case 0:
LabelUDPPort->Enabled = NOT( LabelUDPPort->Enabled );
EditUDPPort->Enabled = NOT( EditUDPPort->Enabled );
UpDownUDPPort->Enabled = NOT( UpDownUDPPort->Enabled );
break;
case 1:
LabelMulticastAddress->Enabled =
NOT( LabelMulticastAddress->Enabled );
ComboBoxMulticastAddress->Enabled =
NOT( ComboBoxMulticastAddress->Enabled );
LabelMulticastPort->Enabled = NOT( LabelMulticastPort->Enabled );
EditMulticastPort->Enabled = NOT( EditMulticastPort->Enabled );
UpDownMulticastPort->Enabled = NOT( UpDownMulticastPort->Enabled );
break;
case 2:
LabelCSAddress->Enabled = NOT( LabelCSAddress->Enabled );
ComboBoxCSAddress->Enabled = NOT( ComboBoxCSAddress->Enabled );
LabelCSPort->Enabled = NOT( LabelCSPort->Enabled );
EditCSPort->Enabled = NOT( EditCSPort->Enabled );
UpDownCSPort->Enabled = NOT( UpDownCSPort->Enabled );
break;
case 3:
LabelHTTPURL->Enabled = NOT( LabelHTTPURL->Enabled );
EditHTTPURL->Enabled = NOT( EditHTTPURL->Enabled );
break;
}
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::RadioButtonUDPClick( TObject *Sender )
{
ChangeEnabled( OldRadioValue );
OldRadioValue = 0;
ChangeEnabled( OldRadioValue );
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::RadioButtonMulticastClick( TObject *Sender )
{
ChangeEnabled( OldRadioValue );
OldRadioValue = 1;
ChangeEnabled( OldRadioValue );
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::RadioButtonCSClick( TObject *Sender )
{
ChangeEnabled( OldRadioValue );
OldRadioValue = 2;
ChangeEnabled( OldRadioValue );
}
//---------------------------------------------------------------------------
void __fastcall TNetworkDlg::RadioButtonHTTPClick( TObject *Sender )
{
ChangeEnabled( OldRadioValue );
OldRadioValue = 3;
ChangeEnabled( OldRadioValue );
}
//---------------------------------------------------------------------------
object NetworkDlg: TNetworkDlg object NetworkDlg: TNetworkDlg
Left = 419 Left = 353
Top = 281 Top = 273
BorderStyle = bsDialog BorderStyle = bsDialog
Caption = 'Open network' Caption = 'Open network'
ClientHeight = 209 ClientHeight = 222
ClientWidth = 386 ClientWidth = 482
Color = clBtnFace Color = clBtnFace
Font.Charset = DEFAULT_CHARSET Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText Font.Color = clWindowText
...@@ -247,172 +247,211 @@ object NetworkDlg: TNetworkDlg ...@@ -247,172 +247,211 @@ object NetworkDlg: TNetworkDlg
OnShow = FormShow OnShow = FormShow
PixelsPerInch = 96 PixelsPerInch = 96
TextHeight = 13 TextHeight = 13
object RadioGroupProtocol: TRadioGroup object BitBtnOk: TBitBtn
Left = 8 Left = 40
Top = 8 Top = 184
Width = 89 Width = 177
Height = 97 Height = 25
Caption = 'Protocol'
ItemIndex = 0
Items.Strings = (
'TS'
'RTP'
'HTTP')
TabOrder = 0 TabOrder = 0
OnClick = BitBtnOkClick
Kind = bkOK
end end
object GroupBoxServer: TGroupBox object BitBtnCancel: TBitBtn
Left = 104 Left = 256
Top = 8 Top = 184
Width = 273 Width = 177
Height = 97 Height = 25
Caption = 'Server'
TabOrder = 1 TabOrder = 1
object LabelAddress: TLabel OnClick = BitBtnCancelClick
Left = 16 Kind = bkCancel
Top = 20 end
Width = 38 object GroupBoxMode: TGroupBox
Left = 8
Top = 8
Width = 465
Height = 161
Caption = 'Network mode'
TabOrder = 2
object LabelUDPPort: TLabel
Left = 148
Top = 34
Width = 22
Height = 13 Height = 13
Caption = 'Address' Caption = 'Port:'
end end
object LabelPort: TLabel object LabelMulticastPort: TLabel
Left = 16 Left = 364
Top = 46 Top = 66
Width = 19 Width = 22
Height = 13 Height = 13
Caption = 'Port' Caption = 'Port:'
Enabled = False
end
object LabelCSPort: TLabel
Left = 364
Top = 98
Width = 22
Height = 13
Caption = 'Port:'
Enabled = False
end end
object CheckBoxBroadcast: TCheckBox object LabelMulticastAddress: TLabel
Left = 139
Top = 66
Width = 41
Height = 13
Caption = 'Address:'
Enabled = False
end
object LabelCSAddress: TLabel
Left = 139
Top = 98
Width = 41
Height = 13
Caption = 'Address:'
Enabled = False
end
object LabelHTTPURL: TLabel
Left = 147
Top = 130
Width = 25
Height = 13
Caption = 'URL:'
Enabled = False
end
object RadioButtonUDP: TRadioButton
Left = 16 Left = 16
Top = 72 Top = 32
Width = 73 Width = 97
Height = 17 Height = 17
Caption = 'Broadcast' Caption = 'UDP'
Checked = True
TabOrder = 0 TabOrder = 0
OnClick = CheckBoxBroadcastClick TabStop = True
OnClick = RadioButtonUDPClick
end end
object EditPort: TEdit object RadioButtonMulticast: TRadioButton
Left = 96 Left = 16
Top = 42 Top = 64
Width = 145 Width = 97
Height = 21 Height = 17
Caption = 'UDP Multicast'
TabOrder = 1 TabOrder = 1
Text = '1234' OnClick = RadioButtonMulticastClick
end end
object ComboBoxAddress: TComboBox object RadioButtonCS: TRadioButton
Left = 96 Left = 16
Top = 16 Top = 96
Width = 161 Width = 97
Height = 21 Height = 17
ItemHeight = 13 Caption = 'Channel Server'
TabOrder = 2 TabOrder = 2
Text = '138.195.131.10' OnClick = RadioButtonCSClick
Items.Strings = (
'138.195.131.10')
end end
object ComboBoxBroadcast: TComboBox object RadioButtonHTTP: TRadioButton
Left = 96 Left = 16
Top = 70 Top = 128
Width = 161 Width = 97
Height = 21 Height = 17
Enabled = False Caption = 'HTTP'
ItemHeight = 13
TabOrder = 3 TabOrder = 3
Text = '138.195.143.255' OnClick = RadioButtonHTTPClick
Items.Strings = (
'138.195.143.255')
end end
object UpDownPort: TUpDown object EditUDPPort: TEdit
Left = 241 Left = 184
Top = 42 Top = 30
Width = 15 Width = 41
Height = 21 Height = 21
Associate = EditPort TabOrder = 4
Text = '1234'
end
object UpDownUDPPort: TUpDown
Left = 225
Top = 30
Width = 16
Height = 21
Associate = EditUDPPort
Min = 0 Min = 0
Max = 32767 Max = 32767
Position = 1234 Position = 1234
TabOrder = 4 TabOrder = 5
Thousands = False Thousands = False
Wrap = False Wrap = False
end end
end object EditMulticastPort: TEdit
object GroupBoxChannels: TGroupBox Left = 392
Left = 8 Top = 62
Top = 112 Width = 41
Width = 369 Height = 21
Height = 57
Caption = 'Channels'
TabOrder = 2
object LabelPortCS: TLabel
Left = 268
Top = 26
Width = 19
Height = 13
Caption = 'Port'
Enabled = False Enabled = False
TabOrder = 6
Text = '1234'
end end
object CheckBoxChannel: TCheckBox object UpDownMulticastPort: TUpDown
Left = 8 Left = 433
Top = 24 Top = 62
Width = 97 Width = 16
Height = 17
Caption = 'Channel server'
TabOrder = 0
OnClick = CheckBoxChannelClick
end
object ComboBoxChannel: TComboBox
Left = 112
Top = 22
Width = 137
Height = 21 Height = 21
Associate = EditMulticastPort
Enabled = False Enabled = False
ItemHeight = 13 Min = 0
TabOrder = 1 Max = 32767
Text = '138.195.156.232' Position = 1234
Items.Strings = ( TabOrder = 7
'138.195.156.232') Thousands = False
Wrap = False
end end
object EditPortCS: TEdit object EditCSPort: TEdit
Left = 296 Left = 392
Top = 22 Top = 94
Width = 41 Width = 41
Height = 21 Height = 21
Enabled = False Enabled = False
TabOrder = 2 TabOrder = 8
Text = '6010' Text = '6010'
end end
object UpDownPortCS: TUpDown object UpDownCSPort: TUpDown
Left = 337 Left = 433
Top = 22 Top = 94
Width = 15 Width = 16
Height = 21 Height = 21
Associate = EditPortCS Associate = EditCSPort
Enabled = False Enabled = False
Min = 0 Min = 0
Max = 32767 Max = 32767
Position = 6010 Position = 6010
TabOrder = 3 TabOrder = 9
Thousands = False
Wrap = False Wrap = False
end end
end object ComboBoxMulticastAddress: TComboBox
object BitBtnOk: TBitBtn Left = 184
Left = 8 Top = 62
Top = 176 Width = 161
Width = 177 Height = 21
Height = 25 Enabled = False
Caption = 'OK' ItemHeight = 13
Default = True TabOrder = 10
ModalResult = 1 end
TabOrder = 3 object ComboBoxCSAddress: TComboBox
OnClick = BitBtnOkClick Left = 184
end Top = 94
object BitBtnCancel: TBitBtn Width = 161
Left = 200 Height = 21
Top = 176 Enabled = False
Width = 177 ItemHeight = 13
Height = 25 TabOrder = 11
Caption = 'Cancel' Text = '138.195.156.230'
ModalResult = 2 Items.Strings = (
TabOrder = 4 '138.195.159.230')
OnClick = BitBtnCancelClick end
object EditHTTPURL: TEdit
Left = 184
Top = 126
Width = 265
Height = 21
Enabled = False
TabOrder = 12
end
end end
end end
...@@ -37,30 +37,39 @@ ...@@ -37,30 +37,39 @@
class TNetworkDlg : public TForm class TNetworkDlg : public TForm
{ {
__published: // IDE-managed Components __published: // IDE-managed Components
TRadioGroup *RadioGroupProtocol;
TGroupBox *GroupBoxServer;
TLabel *LabelAddress;
TLabel *LabelPort;
TCheckBox *CheckBoxBroadcast;
TEdit *EditPort;
TComboBox *ComboBoxAddress;
TComboBox *ComboBoxBroadcast;
TUpDown *UpDownPort;
TGroupBox *GroupBoxChannels;
TLabel *LabelPortCS;
TCheckBox *CheckBoxChannel;
TComboBox *ComboBoxChannel;
TEdit *EditPortCS;
TUpDown *UpDownPortCS;
TBitBtn *BitBtnOk; TBitBtn *BitBtnOk;
TBitBtn *BitBtnCancel; TBitBtn *BitBtnCancel;
TGroupBox *GroupBoxMode;
TRadioButton *RadioButtonUDP;
TRadioButton *RadioButtonMulticast;
TRadioButton *RadioButtonCS;
TRadioButton *RadioButtonHTTP;
TLabel *LabelUDPPort;
TEdit *EditUDPPort;
TUpDown *UpDownUDPPort;
TLabel *LabelMulticastPort;
TEdit *EditMulticastPort;
TUpDown *UpDownMulticastPort;
TLabel *LabelCSPort;
TEdit *EditCSPort;
TUpDown *UpDownCSPort;
TLabel *LabelMulticastAddress;
TComboBox *ComboBoxMulticastAddress;
TLabel *LabelCSAddress;
TComboBox *ComboBoxCSAddress;
TEdit *EditHTTPURL;
TLabel *LabelHTTPURL;
void __fastcall FormShow( TObject *Sender ); void __fastcall FormShow( TObject *Sender );
void __fastcall FormHide( TObject *Sender ); void __fastcall FormHide( TObject *Sender );
void __fastcall BitBtnCancelClick(TObject *Sender); void __fastcall BitBtnCancelClick( TObject *Sender );
void __fastcall CheckBoxBroadcastClick( TObject *Sender ); void __fastcall BitBtnOkClick( TObject *Sender );
void __fastcall CheckBoxChannelClick( TObject *Sender ); void __fastcall RadioButtonUDPClick( TObject *Sender );
void __fastcall BitBtnOkClick(TObject *Sender); void __fastcall RadioButtonMulticastClick( TObject *Sender );
void __fastcall RadioButtonCSClick( TObject *Sender );
void __fastcall RadioButtonHTTPClick( TObject *Sender );
private: // User declarations private: // User declarations
int OldRadioValue;
void __fastcall ChangeEnabled( int i_selected );
public: // User declarations public: // User declarations
__fastcall TNetworkDlg( TComponent* Owner ); __fastcall TNetworkDlg( TComponent* Owner );
}; };
......
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