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