* Bitrate options for PVR
authorMohammed Adnène Trojette <adn@videolan.org>
Wed, 20 Aug 2003 19:17:29 +0000 (19:17 +0000)
committerMohammed Adnène Trojette <adn@videolan.org>
Wed, 20 Aug 2003 19:17:29 +0000 (19:17 +0000)
* fix for win32 compilation

modules/gui/wxwindows/v4l.cpp
modules/gui/wxwindows/wxwindows.h

index f54d5df..2e6b018 100644 (file)
@@ -2,7 +2,7 @@
  * v4l.cpp : wxWindows plugin for vlc
  *****************************************************************************
  * Copyright (C) 2000-2001 VideoLAN
- * $Id: v4l.cpp,v 1.1 2003/08/19 21:16:09 adn Exp $
+ * $Id: v4l.cpp,v 1.2 2003/08/20 19:17:29 adn Exp $
  *
  * Authors: Mohammed Adnène Trojette <adn@via.ecp.fr>
  *
 #   define wxRB_SINGLE 0
 #endif
 
-enum
-{
-    AUDIO_DEV=0,
-    AUDIO_CHAN,
-    SIZE,
-    NORM,
-    FREQUENCY
-};
-
 /*****************************************************************************
  * Event Table.
  *****************************************************************************/
@@ -73,11 +64,13 @@ enum
 {
     MRL_Event,
 
-    AudioDevice_Event, ADevLocation, AudioChannel_Event,
-
     Size_Event,
     Norm_Event,
-    Frequency_Event
+    Frequency_Event,
+
+    AudioDevice_Event, ADevLocation, AudioChannel_Event,
+
+    Bitrate_Event, MaxBitrate_Event
 };
 
 BEGIN_EVENT_TABLE(V4LDialog, wxDialog)
@@ -85,12 +78,7 @@ BEGIN_EVENT_TABLE(V4LDialog, wxDialog)
     EVT_BUTTON(wxID_OK, V4LDialog::OnOk)
     EVT_BUTTON(wxID_CANCEL, V4LDialog::OnCancel)
 
-    /* Events generated by the audio panel */
-    EVT_CHECKBOX(AudioDevice_Event, V4LDialog::OnAudioEnable)
-    EVT_TEXT(ADevLocation, V4LDialog::OnAudioEnable)
-    EVT_SPINCTRL(AudioChannel_Event, V4LDialog::OnAudioChannel)
-
-    /* Events generated by the audio panel */
+    /* Events generated by the common panel */
     EVT_CHECKBOX(Size_Event, V4LDialog::OnSizeEnable)
     EVT_COMBOBOX(Size_Event, V4LDialog::OnSize)
     EVT_CHECKBOX(Norm_Event, V4LDialog::OnNormEnable)
@@ -98,6 +86,17 @@ BEGIN_EVENT_TABLE(V4LDialog, wxDialog)
     EVT_CHECKBOX(Frequency_Event, V4LDialog::OnFrequencyEnable)
     EVT_COMBOBOX(Frequency_Event, V4LDialog::OnFrequency)
 
+   /* Events generated by the audio panel */
+    EVT_CHECKBOX(AudioDevice_Event, V4LDialog::OnAudioEnable)
+    EVT_TEXT(ADevLocation, V4LDialog::OnAudioEnable)
+    EVT_SPINCTRL(AudioChannel_Event, V4LDialog::OnAudioChannel)
+
+    /* Events generated by the bitrate panel */
+    EVT_CHECKBOX(Bitrate_Event, V4LDialog::OnBitrateEnable)
+    EVT_SPINCTRL(Bitrate_Event, V4LDialog::OnBitrate)
+    EVT_CHECKBOX(MaxBitrate_Event, V4LDialog::OnMaxBitrateEnable)
+    EVT_SPINCTRL(MaxBitrate_Event, V4LDialog::OnMaxBitrate)
+
 END_EVENT_TABLE()
 
 /*****************************************************************************
@@ -134,11 +133,14 @@ V4LDialog::V4LDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     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 size panel */
-    wxPanel *common_panel = CommonPanel( panel );
+    /* Create the bitrate panel */
+    wxPanel *bitrate_panel = BitratePanel( panel );
 
     /* Separation */
     wxStaticLine *static_line = new wxStaticLine( panel, wxID_OK );
@@ -159,6 +161,7 @@ V4LDialog::V4LDialog( intf_thread_t *_p_intf, wxWindow* _p_parent ):
     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 );
@@ -196,7 +199,7 @@ void V4LDialog::UpdateMRL()
     {
         if( size_checkbox->IsChecked() )
         {
-        common += wxT(":size=")
+            common += wxT(":size=")
                 + size_combo->GetValue();
         }
 
@@ -214,8 +217,23 @@ void V4LDialog::UpdateMRL()
 
     }
 
-    if( !audio.IsEmpty() || !common.IsEmpty() )
-        mrl_combo->SetValue( audio + common );
+    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("") );
 }
@@ -243,7 +261,7 @@ wxPanel *V4LDialog::CommonPanel( wxWindow* parent )
         wxT("qcif"),
         wxT("sif"),
         wxT("cif"),
-        wxT("vga")
+        wxT("vga"),
     };
 
     size_checkbox = new wxCheckBox( common_subpanel,
@@ -357,6 +375,57 @@ wxPanel *V4LDialog::AudioPanel( wxWindow* parent )
     return panel;
 }
 
+wxPanel *V4LDialog::BitratePanel( wxWindow* parent )
+{
+    wxPanel *panel = new wxPanel( parent, -1, wxDefaultPosition,
+                                  wxSize(200, 200) );
+
+    wxStaticBox *panel_box = new wxStaticBox( panel, -1,
+                                   wxU(_("Bitrate Options")) );
+    wxStaticBoxSizer *panel_sizer = new wxStaticBoxSizer( panel_box,
+                                                          wxVERTICAL );
+
+    wxFlexGridSizer *subpanel_sizer;
+
+    bitrate_subpanel = new wxPanel( panel, -1 );
+
+    subpanel_sizer = new wxFlexGridSizer( 2, 2, 20 );
+
+    bitrate_checkbox = new wxCheckBox( bitrate_subpanel,
+                                       Bitrate_Event,
+                                       wxU(_("Bitrate")) );
+    bitrate = new wxSpinCtrl( bitrate_subpanel, Bitrate_Event );
+
+    subpanel_sizer->Add( bitrate_checkbox, 0, wxALIGN_LEFT |
+                         wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( bitrate, 0, wxALIGN_RIGHT |
+                         wxALIGN_CENTER_VERTICAL );
+
+    maxbitrate_checkbox = new wxCheckBox( bitrate_subpanel,
+                                          MaxBitrate_Event,
+                                          wxU(_("Maximum Bitrate")) );
+    maxbitrate = new wxSpinCtrl( bitrate_subpanel, MaxBitrate_Event );
+
+    subpanel_sizer->Add( maxbitrate_checkbox, 0, wxALIGN_LEFT |
+                         wxALIGN_CENTER_VERTICAL );
+    subpanel_sizer->Add( maxbitrate, 0, wxALIGN_RIGHT |
+                         wxALIGN_CENTER_VERTICAL );
+
+    bitrate_subpanel->SetSizerAndFit( subpanel_sizer );
+
+    /* Stuff everything into the main panel */
+    panel_sizer->Add( bitrate_subpanel, 1,
+                      wxALIGN_LEFT | wxALIGN_CENTER_VERTICAL | wxALL, 5 );
+
+    panel->SetSizerAndFit( panel_sizer );
+
+    /* Update panel */
+    bitrate->Disable();
+    maxbitrate->Disable();
+
+    return panel;
+}
+
 
 /*****************************************************************************
  * Events methods.
@@ -377,25 +446,6 @@ void V4LDialog::OnMRLChange( wxCommandEvent& event )
     //mrl = event.GetString();
 }
 
-/*****************************************************************************
- * Audio panel event methods.
- *****************************************************************************/
-void V4LDialog::OnAudioEnable( wxCommandEvent& event )
-{
-    audio_device->SetValue( wxU( "/dev/dsp" ) );
-    audio_channel->SetRange( 0, 255 );
-    audio_channel->SetValue( 0 );
-
-    audio_device->Enable( event.GetInt() );
-    audio_channel->Enable( event.GetInt() );
-    UpdateMRL();
-}
-
-void V4LDialog::OnAudioChannel( wxCommandEvent& event )
-{
-    UpdateMRL();
-}
-
 /******************************************************************************
  * Common panel event methods.
  ******************************************************************************/
@@ -423,8 +473,8 @@ void V4LDialog::OnNorm( wxCommandEvent& event )
 
 void V4LDialog::OnFrequencyEnable( wxCommandEvent& event )
 {
-    frequency->SetRange( 0, 42000 );
-    frequency->SetValue( 7668 );
+    frequency->SetRange( 0, 1200000 );
+    frequency->SetValue( 479250 );
     frequency->Enable( event.GetInt() );
     UpdateMRL();
 }
@@ -434,3 +484,50 @@ void V4LDialog::OnFrequency( wxCommandEvent& event )
     UpdateMRL();
 }
 
+/*****************************************************************************
+ * Audio panel event methods.
+ *****************************************************************************/
+void V4LDialog::OnAudioEnable( wxCommandEvent& event )
+{
+    audio_device->SetValue( wxU( "/dev/dsp" ) );
+    audio_channel->SetRange( 0, 255 );
+    audio_channel->SetValue( 0 );
+
+    audio_device->Enable( event.GetInt() );
+    audio_channel->Enable( event.GetInt() );
+    UpdateMRL();
+}
+
+void V4LDialog::OnAudioChannel( wxCommandEvent& event )
+{
+    UpdateMRL();
+}
+
+/******************************************************************************
+ * Bitrate panel event methods.
+ ******************************************************************************/
+void V4LDialog::OnBitrateEnable( wxCommandEvent& event )
+{
+    bitrate->SetRange( 0, 10000 );
+    bitrate->SetValue( 3000 );
+    bitrate->Enable( event.GetInt() );
+    UpdateMRL();
+}
+
+void V4LDialog::OnBitrate( wxCommandEvent& event )
+{
+    UpdateMRL();
+}
+
+void V4LDialog::OnMaxBitrateEnable( wxCommandEvent& event )
+{
+    maxbitrate->SetRange( 0, 10000 );
+    maxbitrate->SetValue( 3000 );
+    maxbitrate->Enable( event.GetInt() );
+    UpdateMRL();
+}
+
+void V4LDialog::OnMaxBitrate( wxCommandEvent& event )
+{
+    UpdateMRL();
+}
index 1664e82..f513159 100644 (file)
@@ -2,7 +2,7 @@
  * wxwindows.h: private wxWindows interface description
  *****************************************************************************
  * Copyright (C) 1999, 2000 VideoLAN
- * $Id: wxwindows.h,v 1.54 2003/08/19 21:16:09 adn Exp $
+ * $Id: wxwindows.h,v 1.55 2003/08/20 19:17:29 adn Exp $
  *
  * Authors: Gildas Bazin <gbazin@netcourrier.com>
  *
@@ -379,6 +379,7 @@ private:
     void UpdateMRL();
     wxPanel *AudioPanel( wxWindow* parent );
     wxPanel *CommonPanel( wxWindow* parent );
+    wxPanel *BitratePanel( wxWindow* parent );
     void    ParseMRL();
 
     /* Event handlers (these functions should _not_ be virtual) */
@@ -393,6 +394,10 @@ private:
     void OnNorm( wxCommandEvent& event );
     void OnFrequencyEnable( wxCommandEvent& event );
     void OnFrequency( wxCommandEvent& event );
+    void OnBitrateEnable( wxCommandEvent& event );
+    void OnBitrate( wxCommandEvent& event );
+    void OnMaxBitrateEnable( wxCommandEvent& event );
+    void OnMaxBitrate( wxCommandEvent& event );
 
     DECLARE_EVENT_TABLE();
 
@@ -419,6 +424,13 @@ private:
     wxTextCtrl *audio_device;
     wxSpinCtrl *audio_channel;
 
+    wxPanel *bitrate_subpanel;
+    wxPanel *bitrate_panel;
+    wxCheckBox *bitrate_checkbox;
+    wxSpinCtrl *bitrate;
+    wxCheckBox *maxbitrate_checkbox;
+    wxSpinCtrl *maxbitrate;
+
 };
 
 /* Stream output Dialog */