1 /*****************************************************************************
\r
2 * network.cpp: the "network" dialog box
\r
3 *****************************************************************************
\r
4 * Copyright (C) 2002 VideoLAN
\r
6 * Authors: Olivier Teuliere <ipkiss@via.ecp.fr>
\r
8 * This program is free software; you can redistribute it and/or modify
\r
9 * it under the terms of the GNU General Public License as published by
\r
10 * the Free Software Foundation; either version 2 of the License, or
\r
11 * (at your option) any later version.
\r
13 * This program is distributed in the hope that it will be useful,
\r
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
16 * GNU General Public License for more details.
\r
18 * You should have received a copy of the GNU General Public License
\r
19 * along with this program; if not, write to the Free Software
\r
20 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
\r
21 *****************************************************************************/
\r
26 #include <videolan/vlc.h>
\r
28 #include "stream_control.h"
\r
29 #include "input_ext-intf.h"
\r
31 #include "interface.h"
\r
32 #include "intf_playlist.h"
\r
34 #include "network.h"
\r
35 #include "win32_common.h"
\r
37 #include "netutils.h"
\r
39 //---------------------------------------------------------------------------
\r
40 //#pragma package(smart_init)
\r
41 #pragma resource "*.dfm"
\r
43 extern struct intf_thread_s *p_intfGlobal;
\r
45 //---------------------------------------------------------------------------
\r
46 __fastcall TNetworkDlg::TNetworkDlg( TComponent* Owner )
\r
49 char *psz_channel_server;
\r
54 UpDownUDPPort->Position = config_GetIntVariable( "server-port" );
\r
55 UpDownMulticastPort->Position = config_GetIntVariable( "server-port" );
\r
57 /* channel server */
\r
58 if( config_GetIntVariable( "network-channel" ) )
\r
60 RadioButtonCS->Checked = true;
\r
61 RadioButtonCSEnter( RadioButtonCS );
\r
64 psz_channel_server = config_GetPszVariable( "channel-server" );
\r
65 if( psz_channel_server )
\r
67 ComboBoxCSAddress->Text = psz_channel_server;
\r
68 free( psz_channel_server );
\r
71 UpDownCSPort->Position = config_GetIntVariable( "channel-port" );
\r
73 //---------------------------------------------------------------------------
\r
74 void __fastcall TNetworkDlg::FormShow( TObject *Sender )
\r
76 p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = true;
\r
77 p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = true;
\r
79 //---------------------------------------------------------------------------
\r
80 void __fastcall TNetworkDlg::FormHide( TObject *Sender )
\r
82 p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = false;
\r
83 p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = false;
\r
85 //---------------------------------------------------------------------------
\r
86 void __fastcall TNetworkDlg::BitBtnCancelClick( TObject *Sender )
\r
90 //---------------------------------------------------------------------------
\r
91 void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender )
\r
93 AnsiString Source, Address;
\r
94 AnsiString Channel = ComboBoxCSAddress->Text;
\r
95 unsigned int i_channel_port = UpDownCSPort->Position;
\r
96 unsigned int i_port;
\r
97 int i_end = p_main->p_playlist->i_size;
\r
101 /* select added item */
\r
102 if( p_input_bank->pp_input[0] != NULL )
\r
104 p_input_bank->pp_input[0]->b_eof = 1;
\r
107 /* Check which option was chosen */
\r
108 switch( OldRadioValue )
\r
112 config_PutIntVariable( "network-channel", FALSE );
\r
113 i_port = UpDownUDPPort->Position;
\r
115 /* Build source name */
\r
116 Source = "udp:@:" + IntToStr( i_port );
\r
118 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
\r
120 /* update the display */
\r
121 p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
\r
123 intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
\r
126 /* UDP Multicast */
\r
128 config_PutIntVariable( "network-channel", FALSE );
\r
129 Address = ComboBoxMulticastAddress->Text;
\r
130 i_port = UpDownMulticastPort->Position;
\r
132 /* Build source name */
\r
133 Source = "udp:@" + Address + ":" + IntToStr( i_port );
\r
135 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
\r
137 /* update the display */
\r
138 p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
\r
140 intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
\r
143 /* Channel server */
\r
145 config_PutIntVariable( "network-channel", TRUE );
\r
146 config_PutPszVariable( "channel-server", Channel.c_str() );
\r
147 config_PutIntVariable( "channel-port", i_channel_port );
\r
149 if( p_main->p_channel == NULL )
\r
151 network_ChannelCreate();
\r
154 p_intfGlobal->p_sys->b_playing = 1;
\r
159 config_PutIntVariable( "network-channel", FALSE );
\r
160 Address = EditHTTPURL->Text;
\r
162 /* Build source name */
\r
163 Source = "http:" + Address;
\r
165 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
\r
167 /* update the display */
\r
168 p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
\r
170 intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
\r
174 //---------------------------------------------------------------------------
\r
175 void __fastcall TNetworkDlg::ChangeEnabled( int i_selected )
\r
177 switch( i_selected )
\r
180 LabelUDPPort->Enabled = NOT( LabelUDPPort->Enabled );
\r
181 EditUDPPort->Enabled = NOT( EditUDPPort->Enabled );
\r
182 UpDownUDPPort->Enabled = NOT( UpDownUDPPort->Enabled );
\r
185 LabelMulticastAddress->Enabled =
\r
186 NOT( LabelMulticastAddress->Enabled );
\r
187 ComboBoxMulticastAddress->Enabled =
\r
188 NOT( ComboBoxMulticastAddress->Enabled );
\r
189 LabelMulticastPort->Enabled = NOT( LabelMulticastPort->Enabled );
\r
190 EditMulticastPort->Enabled = NOT( EditMulticastPort->Enabled );
\r
191 UpDownMulticastPort->Enabled = NOT( UpDownMulticastPort->Enabled );
\r
194 LabelCSAddress->Enabled = NOT( LabelCSAddress->Enabled );
\r
195 ComboBoxCSAddress->Enabled = NOT( ComboBoxCSAddress->Enabled );
\r
196 LabelCSPort->Enabled = NOT( LabelCSPort->Enabled );
\r
197 EditCSPort->Enabled = NOT( EditCSPort->Enabled );
\r
198 UpDownCSPort->Enabled = NOT( UpDownCSPort->Enabled );
\r
201 LabelHTTPURL->Enabled = NOT( LabelHTTPURL->Enabled );
\r
202 EditHTTPURL->Enabled = NOT( EditHTTPURL->Enabled );
\r
206 //---------------------------------------------------------------------------
\r
207 void __fastcall TNetworkDlg::RadioButtonUDPEnter( TObject *Sender )
\r
209 ChangeEnabled( OldRadioValue );
\r
211 ChangeEnabled( OldRadioValue );
\r
213 //---------------------------------------------------------------------------
\r
214 void __fastcall TNetworkDlg::RadioButtonMulticastEnter( TObject *Sender )
\r
216 ChangeEnabled( OldRadioValue );
\r
218 ChangeEnabled( OldRadioValue );
\r
220 //---------------------------------------------------------------------------
\r
221 void __fastcall TNetworkDlg::RadioButtonCSEnter( TObject *Sender )
\r
223 ChangeEnabled( OldRadioValue );
\r
225 ChangeEnabled( OldRadioValue );
\r
227 //---------------------------------------------------------------------------
\r
228 void __fastcall TNetworkDlg::RadioButtonHTTPEnter( TObject *Sender )
\r
230 ChangeEnabled( OldRadioValue );
\r
232 ChangeEnabled( OldRadioValue );
\r
234 //---------------------------------------------------------------------------
\r