📄 v4l.cpp
字号:
/***************************************************************************** * v4l.cpp : wxWindows plugin for vlc ***************************************************************************** * Copyright (C) 2000-2003 VideoLAN * $Id: v4l.cpp,v 1.7 2004/01/25 03:29:02 hartman Exp $ * * Authors: Mohammed Adn鑞e Trojette <adn@via.ecp.fr> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. *****************************************************************************//***************************************************************************** * Preamble *****************************************************************************/#include <stdlib.h> /* malloc(), free() */#include <errno.h> /* ENOMEM */#include <string.h> /* strerror() */#include <stdio.h>#include <vlc/vlc.h>#ifdef WIN32 /* mingw32 hack */#undef Yield#undef CreateDialog#endif#include <wx/combobox.h>#include <wx/statline.h>#include <vlc/intf.h>#include "wxwindows.h"#ifndef wxRB_SINGLE# define wxRB_SINGLE 0#endif/***************************************************************************** * Event Table. *****************************************************************************//* IDs for the controls and the menu commands */enum{ MRL_Event, Size_Event, Norm_Event, FrequencyEnable_Event,Frequency_Event, AudioDevice_Event, ADevLocation, AudioChannel_Event, BitrateEnable_Event, MaxBitrateEnable_Event, Bitrate_Event, MaxBitrate_Event};BEGIN_EVENT_TABLE(V4LDialog, wxDialog) /* Button events */ EVT_BUTTON(wxID_OK, V4LDialog::OnOk) EVT_BUTTON(wxID_CANCEL, V4LDialog::OnCancel) /* Events generated by the common panel */ EVT_CHECKBOX(Size_Event, V4LDialog::OnSizeEnable) EVT_COMBOBOX(Size_Event, V4LDialog::OnSize) EVT_CHECKBOX(Norm_Event, V4LDialog::OnNormEnable) EVT_COMBOBOX(Norm_Event, V4LDialog::OnNorm) EVT_CHECKBOX(FrequencyEnable_Event, V4LDialog::OnFrequencyEnable) EVT_SPINCTRL(Frequency_Event, V4LDialog::OnFrequency) /* Events generated by the audio panel */ EVT_CHECKBOX(AudioDevice_Event, V4LDialog::OnAudioEnable) EVT_TEXT(ADevLocation, V4LDialog::OnAudioChange) EVT_SPINCTRL(AudioChannel_Event, V4LDialog::OnAudioChannel) /* Events generated by the bitrate panel */ EVT_CHECKBOX(BitrateEnable_Event, V4LDialog::OnBitrateEnable) EVT_SPINCTRL(Bitrate_Event, V4LDialog::OnBitrate) EVT_CHECKBOX(MaxBitrateEnable_Event, V4LDialog::OnMaxBitrateEnable) EVT_SPINCTRL(MaxBitrate_Event, V4LDialog::OnMaxBitrate)END_EVENT_TABLE()/***************************************************************************** * Constructor. *****************************************************************************/V4LDialog::V4LDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ): wxDialog( _p_parent, -1, wxU(_("Advanced video device options")), wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE ){ /* Initializations */ p_intf = _p_intf; p_parent = _p_parent; SetIcon( *p_intf->p_sys->p_icon ); /* Create a panel to put everything in */ wxPanel *panel = new wxPanel( this, -1 ); panel->SetAutoLayout( TRUE ); /* Create MRL combobox */ wxBoxSizer *mrl_sizer_sizer = new wxBoxSizer( wxHORIZONTAL ); wxStaticBox *mrl_box = new wxStaticBox( panel, -1, wxU(_("Video device MRL")) ); wxStaticBoxSizer *mrl_sizer = new wxStaticBoxSizer( mrl_box, wxHORIZONTAL ); wxStaticText *mrl_label = new wxStaticText( panel, -1, wxU(_("Destination target:"))); mrl_combo = new wxComboBox( panel, MRL_Event, wxT(""), wxPoint(20,25), wxSize(200, -1), 0, NULL ); mrl_combo->SetToolTip( wxU(_("You can use this field directly by typing " "the full MRL you want to open.\n Alternatively, the field will be " "filled automatically when you use the controls below")) ); mrl_sizer->Add( mrl_label, 0, wxALL | wxALIGN_CENTER, 5 ); mrl_sizer->Add( mrl_combo, 1, wxALL | wxALIGN_CENTER, 5 ); mrl_sizer_sizer->Add( mrl_sizer, 1, wxEXPAND | wxALL, 5 ); /* Create the common panel */ wxPanel *common_panel = CommonPanel( panel ); /* Create the audio panel */ wxPanel *audio_panel = AudioPanel( panel ); /* Create the bitrate panel */ wxPanel *bitrate_panel = BitratePanel( panel ); /* Separation */ wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK ); /* Create the buttons */ wxButton *ok_button = new wxButton( panel, wxID_OK, wxU(_("OK")) ); ok_button->SetDefault(); wxButton *cancel_button = new wxButton( panel, wxID_CANCEL, wxU(_("Cancel")) ); /* Place everything in sizers */ wxBoxSizer *button_sizer = new wxBoxSizer( wxHORIZONTAL ); button_sizer->Add( ok_button, 0, wxALL, 5 ); button_sizer->Add( cancel_button, 0, wxALL, 5 ); button_sizer->Layout(); wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *panel_sizer = new wxBoxSizer( wxVERTICAL ); panel_sizer->Add( mrl_sizer_sizer, 0, wxEXPAND, 5 ); panel_sizer->Add( common_panel, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Add( audio_panel, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Add( bitrate_panel, 1, wxEXPAND | wxALL, 5 ); panel_sizer->Add( static_line, 0, wxEXPAND | wxALL, 5 ); panel_sizer->Add( button_sizer, 0, wxALIGN_LEFT | wxALIGN_BOTTOM | wxALL, 5 ); panel_sizer->Layout(); panel->SetSizerAndFit( panel_sizer ); main_sizer->Add( panel, 1, wxGROW, 0 ); main_sizer->Layout(); SetSizerAndFit( main_sizer );}V4LDialog::~V4LDialog(){}wxArrayString V4LDialog::GetOptions(){ return SeparateEntries( mrl_combo->GetValue() );}/***************************************************************************** * Private methods. *****************************************************************************/void V4LDialog::UpdateMRL(){ wxString audio; if( audio_checkbox->IsChecked() ) { audio = wxT(":adev=") + audio_device->GetLineText(0) + wxString::Format( wxT(":audio=%d"), audio_channel->GetValue() ); } wxString common; { if( size_checkbox->IsChecked() ) { common += wxT(":size=") + size_combo->GetValue(); } if( norm_checkbox->IsChecked() ) { common += wxT(":norm=") + norm_combo->GetValue(); } if( frequency_checkbox->IsChecked() ) { common += wxString::Format( wxT(":frequency=%d"), frequency->GetValue() ); } } wxString rate; { if( bitrate_checkbox->IsChecked() ) { rate += wxString::Format( wxT(":bitrate=%d"), bitrate->GetValue() ); } if( maxbitrate_checkbox->IsChecked() ) { rate += wxString::Format( wxT(":maxbitrate=%d"), maxbitrate->GetValue() ); } } if( !audio.IsEmpty() || !common.IsEmpty() || !rate.IsEmpty() ) mrl_combo->SetValue( audio + common + rate); else mrl_combo->SetValue( wxT("") );}wxPanel *V4LDialog::CommonPanel( wxWindow* parent ){ wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition, wxSize(200, 200) ); wxStaticBox *panel_box = new wxStaticBox( panel, -1, wxU(_("Common options")) ); wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box, wxVERTICAL ); wxFlexGridSizer *subpanel_sizer; common_subpanel = new wxPanel( panel, -1 ); subpanel_sizer = new wxFlexGridSizer( 2, 3, 20 ); static const wxString size_array[] = { wxT("subqcif"), wxT("qsif"), wxT("qcif"), wxT("sif"), wxT("cif"), wxT("vga"), }; size_checkbox = new wxCheckBox( common_subpanel, Size_Event, wxU(_("Size")) ); size_combo = new wxComboBox( common_subpanel, Size_Event, wxT(""), wxPoint(20,25), wxSize( 120, -1), WXSIZEOF(size_array), size_array, wxCB_READONLY );
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -