]> git.sesse.net Git - vlc/blobdiff - modules/gui/wxwindows/streamwizard.cpp
* modules/gui/wxwindows/*: new --wxwin-keep-size option to remember the size of the...
[vlc] / modules / gui / wxwindows / streamwizard.cpp
index 6a9371c3a00a36c019c086f44ac5810dd180fa3a..8e0b7c5601a6831c0e6e47b51c671f49745897b7 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
  * stream.cpp : wxWindows plugin for vlc
  *****************************************************************************
- * Copyright (C) 2000-2001 VideoLAN
- * $Id: streamwizard.cpp,v 1.2 2003/12/04 16:49:43 sam Exp $
+ * Copyright (C) 2000-2004 VideoLAN
+ * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
  *
 
 #include <wx/statline.h>
 
-
-#define STREAM_INTRO N_( "Stream with VLC in three steps" )
-#define STREAM_STEP1 N_( "Step 1: Select what to stream" )
-#define STREAM_STEP2 N_( "Step 2: Define streaming method" )
-#define STREAM_STEP3 N_( "Step 3: Start streaming" )
-
+#define STREAM_INTRO N_( "Stream with VLC in three steps." )
+#define STREAM_STEP1 N_( "Step 1: Select what to stream." )
+#define STREAM_STEP2 N_( "Step 2: Define streaming method." )
+#define STREAM_STEP3 N_( "Step 3: Start streaming." )
 
 /*****************************************************************************
  * Event Table.
@@ -108,8 +106,7 @@ StreamDialog::StreamDialog( intf_thread_t *_p_intf, wxWindow *p_parent ):
                    Sout_Event, wxU(_("Choose...")));
 
     start_button = new wxButton( panel,
-                   Start_Event, wxU(_("Start !")));
-
+                   Start_Event, wxU(_("Start!")));
 
     step2_label->Disable();
     step3_label->Disable();
@@ -167,13 +164,14 @@ void StreamDialog::OnOpen( wxCommandEvent& event )
 {
     if( !p_open_dialog )
     {
-        p_open_dialog = new OpenDialog(
-                    p_intf, this, FILE_ACCESS, 1 , OPEN_STREAM );
+        p_open_dialog =
+            new OpenDialog( p_intf, this, FILE_ACCESS, 1 , OPEN_STREAM );
     }
 
     if( p_open_dialog)
     {
        p_open_dialog->Show();
+       p_open_dialog->Enable();
        mrl = p_open_dialog->mrl;
        sout_button->Enable();
        step2_label->Enable();
@@ -204,8 +202,10 @@ void StreamDialog::OnStart( wxCommandEvent& event )
 
     for( int i = 0; i < (int)p_open_dialog->mrl.GetCount(); i++ )
     {
-        int i_options = 0, i_total_options;
-        char **ppsz_options = NULL;
+        playlist_item_t *p_item = playlist_ItemNew( p_intf,
+                      (const char *)p_open_dialog->mrl[i].mb_str(),
+                      (const char *)p_open_dialog->mrl[i].mb_str() );
+        int i_options = 0;
 
         /* Count the input options */
         while( i + i_options + 1 < (int)p_open_dialog->mrl.GetCount() &&
@@ -215,49 +215,36 @@ void StreamDialog::OnStart( wxCommandEvent& event )
             i_options++;
         }
 
-        /* Allocate ppsz_options */
+        /* Insert options */
         for( int j = 0; j < i_options; j++ )
         {
-            if( !ppsz_options )
-                ppsz_options = (char **)malloc( sizeof(char *) * i_options );
-
-            ppsz_options[j] = strdup( p_open_dialog->mrl[i + j  + 1].mb_str() );
+            playlist_ItemAddOption( p_item ,
+                                p_open_dialog->mrl[i + j  + 1].mb_str() );
         }
 
-        i_total_options = i_options;
-
         /* Get the options from the stream output dialog */
         if( sout_mrl.GetCount() )
         {
-            ppsz_options = (char **)realloc( ppsz_options, sizeof(char *) *
-                               (i_total_options + sout_mrl.GetCount()) );
-
             for( int j = 0; j < (int)sout_mrl.GetCount(); j++ )
             {
-                ppsz_options[i_total_options + j] =
-                    strdup( sout_mrl[j].mb_str() );
+                playlist_ItemAddOption( p_item , sout_mrl[j].mb_str() );
             }
+        }
 
-            i_total_options += sout_mrl.GetCount();
+        playlist_AddItem( p_playlist, p_item,
+                          PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO),
+                          PLAYLIST_END );
 
-        }
-        msg_Dbg(p_intf,"playings %s",(const char *)p_open_dialog->mrl[i].mb_str());
-        playlist_Add( p_playlist, (const char *)p_open_dialog->mrl[i].mb_str(),
-                      (const char **)ppsz_options, i_total_options,
-                      PLAYLIST_APPEND | (i ? 0 : PLAYLIST_GO), PLAYLIST_END );
-        /* clean up */
-        for( int j = 0; j < i_total_options; j++ )
-            free( ppsz_options[j] );
-        if( ppsz_options ) free( ppsz_options );
+        msg_Dbg( p_intf,"playings %s",
+                 (const char *)p_open_dialog->mrl[i].mb_str() );
 
         i += i_options;
-   }
- vlc_object_release( p_playlist );
+    }
   vlc_object_release( p_playlist );
 
-  Hide();
+    Hide();
 }
 
-
 void StreamDialog::OnClose( wxCommandEvent& event )
 {
     Hide();