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
50 //---------------------------------------------------------------------------
\r
51 void __fastcall TNetworkDlg::FormShow( TObject *Sender )
\r
53 p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = true;
\r
54 p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = true;
\r
56 //---------------------------------------------------------------------------
\r
57 void __fastcall TNetworkDlg::FormHide( TObject *Sender )
\r
59 p_intfGlobal->p_sys->p_window->MenuNetworkStream->Checked = false;
\r
60 p_intfGlobal->p_sys->p_window->PopupNetworkStream->Checked = false;
\r
62 //---------------------------------------------------------------------------
\r
63 void __fastcall TNetworkDlg::BitBtnCancelClick( TObject *Sender )
\r
67 //---------------------------------------------------------------------------
\r
68 void __fastcall TNetworkDlg::CheckBoxBroadcastClick( TObject *Sender )
\r
70 ComboBoxBroadcast->Enabled = NOT( ComboBoxBroadcast->Enabled );
\r
72 //---------------------------------------------------------------------------
\r
73 void __fastcall TNetworkDlg::CheckBoxChannelClick( TObject *Sender )
\r
75 LabelAddress->Enabled = NOT( LabelAddress->Enabled );
\r
76 ComboBoxAddress->Enabled = NOT( ComboBoxAddress->Enabled );
\r
77 LabelPort->Enabled = NOT( LabelPort->Enabled );
\r
78 EditPort->Enabled = NOT( EditPort->Enabled );
\r
79 UpDownPort->Enabled = NOT( UpDownPort->Enabled );
\r
80 CheckBoxBroadcast->Enabled = NOT( CheckBoxBroadcast->Enabled );
\r
81 ComboBoxBroadcast->Enabled = ( NOT( ComboBoxBroadcast->Enabled ) &&
\r
82 CheckBoxBroadcast->Checked );
\r
83 ComboBoxChannel->Enabled = NOT( ComboBoxChannel->Enabled );
\r
84 LabelPortCS->Enabled = NOT( LabelPortCS->Enabled );
\r
85 EditPortCS->Enabled = NOT( EditPortCS->Enabled );
\r
86 UpDownPortCS->Enabled = NOT( UpDownPortCS->Enabled );
\r
88 //---------------------------------------------------------------------------
\r
89 void __fastcall TNetworkDlg::BitBtnOkClick( TObject *Sender )
\r
91 AnsiString Source, Protocol, Server;
\r
92 boolean_t b_channel;
\r
93 boolean_t b_broadcast;
\r
94 unsigned int i_port;
\r
95 int i_end = p_main->p_playlist->i_size;
\r
98 Server = ComboBoxAddress->Text;
\r
100 /* select added item */
\r
101 if( p_input_bank->pp_input[0] != NULL )
\r
103 p_input_bank->pp_input[0]->b_eof = 1;
\r
106 /* Check which protocol was activated */
\r
107 switch( RadioGroupProtocol->ItemIndex )
\r
113 intf_ErrMsg( "intf error: rtp protocol not yet implemented" );
\r
120 /* Manage channel server */
\r
121 b_channel = CheckBoxChannel->Checked ? TRUE : FALSE;
\r
122 config_PutIntVariable( "network_channel", b_channel );
\r
125 AnsiString Channel = ComboBoxChannel->Text;
\r
126 unsigned int i_channel_port = UpDownPortCS->Position;
\r
128 if( p_main->p_channel == NULL )
\r
130 network_ChannelCreate();
\r
133 config_PutPszVariable( "channel_server", Channel.c_str() );
\r
134 if( i_channel_port < 65536 )
\r
136 config_PutIntVariable( "channel_port", i_channel_port );
\r
139 p_intfGlobal->p_sys->b_playing = 1;
\r
143 /* Get the port number and make sure it will not
\r
144 * overflow 5 characters */
\r
145 i_port = UpDownPort->Position;
\r
146 if( i_port > 65535 )
\r
148 intf_ErrMsg( "intf error: invalid port %i", i_port );
\r
151 /* do we have a broadcast address */
\r
152 b_broadcast = CheckBoxBroadcast->Checked ? TRUE : FALSE;
\r
155 AnsiString Broadcast = ComboBoxBroadcast->Text;
\r
157 /* Build source name */
\r
158 Source = Protocol + "://" + Server + "@:" + IntToStr( i_port )
\r
163 /* Build source name */
\r
164 Source = Protocol + "://" + Server + "@:" + IntToStr( i_port );
\r
167 intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END, Source.c_str() );
\r
169 /* update the display */
\r
170 p_intfGlobal->p_sys->p_playlist->UpdateGrid( p_main->p_playlist );
\r
172 intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
\r
175 //---------------------------------------------------------------------------
\r