]> git.sesse.net Git - vlc/blob - modules/gui/pda/pda_callbacks.c
No need to add a '\n' at the end of messages passed to msg_*
[vlc] / modules / gui / pda / pda_callbacks.c
1 /*****************************************************************************
2  * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
3  *****************************************************************************
4  * Copyright (C) 2000, 2001 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Jean-Paul Saman <jpsaman _at_ videolan _dot_ org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24 /*****************************************************************************
25  * Preamble
26  *****************************************************************************/
27 #include <sys/types.h>                                              /* off_t */
28
29 #ifdef HAVE_CONFIG_H
30 # include "config.h"
31 #endif
32
33 #include <vlc_common.h>
34 #include <vlc_input.h>
35 #include <vlc_interface.h>
36 #include <vlc_playlist.h>
37 #include <vlc_vout.h>
38
39 #include <dirent.h>
40 #include <sys/stat.h>
41 #include <unistd.h>
42 #include <pwd.h>
43 #include <grp.h>
44
45 #include <gtk/gtk.h>
46
47 #include "pda_callbacks.h"
48 #include "pda_interface.h"
49 #include "pda_support.h"
50 #include "pda.h"
51
52 #define VLC_MAX_MRL     256
53
54 static char *get_file_perms(struct stat st);
55
56 /*****************************************************************************
57  * Useful function to retrieve p_intf
58  ****************************************************************************/
59 void * __GtkGetIntf( GtkWidget * widget )
60 {
61     void *p_data;
62
63     if( GTK_IS_MENU_ITEM( widget ) )
64     {
65         /* Look for a GTK_MENU */
66         while( widget->parent && !GTK_IS_MENU( widget ) )
67         {
68             widget = widget->parent;
69         }
70
71         /* Maybe this one has the data */
72         p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
73         if( p_data )
74         {
75             return p_data;
76         }
77
78         /* Otherwise, the parent widget has it */
79         widget = gtk_menu_get_attach_widget( GTK_MENU( widget ) );
80     }
81
82     /* We look for the top widget */
83     widget = gtk_widget_get_toplevel( GTK_WIDGET( widget ) );
84
85     p_data = gtk_object_get_data( GTK_OBJECT( widget ), "p_intf" );
86
87     return p_data;
88 }
89
90 static void PlaylistAddItem(GtkWidget *widget, gchar *name, char **ppsz_options, int i_size)
91 {
92     intf_thread_t *p_intf = GtkGetIntf( widget );
93     playlist_t    *p_playlist;
94     int           i_id , i_pos=0;
95     GtkTreeView   *p_tvplaylist = NULL;
96
97     p_playlist = pl_Hold( p_intf );
98
99     if( p_playlist ==  NULL)
100     {   /* Bail out when VLC's playlist object is not found. */
101         return;
102     }
103
104     /* Add to playlist object. */
105     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(widget), "tvPlaylist");
106     if (p_tvplaylist)
107     {
108         GtkTreeModel *p_play_model;
109         GtkTreeIter   p_play_iter;
110
111         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
112  
113         if (p_play_model)
114         {
115             int i;
116
117             /* Add a new row to the playlist treeview model */
118             gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
119             gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
120                                     0, name,   /* Add path to it !!! */
121                                     1, "no info",
122                                     2, playlist_CurrentSize(p_playlist), /* Hidden index. */
123                                     -1 );
124
125             /* Add to VLC's playlist */
126 #if 0
127             if (p_intf->p_sys->b_autoplayfile)
128             {
129                 playlist_Add( p_playlist, (const char*)name, (const char**)ppsz_options, i_size,
130                               PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END);
131             }
132             else
133 #endif
134             {
135                 i_id = playlist_AddExt( p_playlist, (const char*)name,
136                               (const char*)name,
137                               PLAYLIST_APPEND, PLAYLIST_END,
138                               (mtime_t) 0,
139                               i_options, (const char **) ppsz_options, VLC_INPUT_OPTION_TRUSTED,
140                               true, pl_Unlocked );
141             }
142
143             /* Cleanup memory */
144             for (i=0; i<i_size; i++)
145                 free(ppsz_options[i]);
146             free(ppsz_options);
147         }
148     }
149     pl_Release( p_intf );
150 }
151
152 void PlaylistRebuildListStore( intf_thread_t *p_intf,
153     GtkListStore * p_list, playlist_t * p_playlist )
154 {
155     GtkTreeIter iter;
156     int         i_dummy;
157     gchar *     ppsz_text[2];
158 #if 0
159     GdkColor    red;
160     red.red     = 65535;
161     red.blue    = 0;
162     red.green   = 0;
163 #endif
164     PL_LOCK;
165     for( i_dummy = 0; i_dummy < playlist_CurrentSize(p_playlist) ; i_dummy++ )
166     {
167         playlist_item_t *p_item = playlist_ItemGetById( p_playlist, i_dummy );
168         if( p_item )
169         {
170             ppsz_text[0] = p_item->p_input->psz_name;
171             ppsz_text[1] = "no info";
172             gtk_list_store_append (p_list, &iter);
173             gtk_list_store_set (p_list, &iter,
174                                 0, ppsz_text[0],
175                                 1, ppsz_text[1],
176                                 2, i_dummy, /* Hidden index */
177                                 -1);
178         }
179     }
180     PL_UNLOCK;
181 }
182
183 /*****************************************************************
184  * Read directory helper function.
185  ****************************************************************/
186 void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
187 {
188     GtkTreeIter    iter;
189     struct dirent **pp_namelist;
190     struct passwd *p_pw;
191     struct group  *p_grp;
192     struct stat    st;
193     int n=-1, status=-1;
194
195     msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
196     if (psz_dir)
197     {
198        status = chdir(psz_dir);
199        if (status<0)
200           msg_Dbg(p_intf, "permision denied" );
201     }
202     n = scandir(".", &pp_namelist, 0, alphasort);
203
204     if (n<0)
205         perror("scandir");
206     else
207     {
208         int i;
209         gchar *ppsz_text[4];
210
211         if (lstat("..", &st)==0)
212         {
213             /* user, group  */
214             p_pw  = getpwuid(st.st_uid);
215             p_grp = getgrgid(st.st_gid);
216
217             /* XXX : kludge temporaire pour yopy */
218             ppsz_text[0] = "..";
219             ppsz_text[1] = get_file_perms(st);
220             ppsz_text[2] = p_pw->pw_name;
221             ppsz_text[3] = p_grp->gr_name;
222
223             /* Add a new row to the model */
224             gtk_list_store_append (p_list, &iter);
225             gtk_list_store_set (p_list, &iter,
226                                 0, ppsz_text[0],
227                                 1, ppsz_text[1],
228                                 2, st.st_size,
229                                 3, ppsz_text[2],
230                                 4, ppsz_text[3],
231                                 -1);
232
233             free(ppsz_text[1]);
234         }
235             /* kludge */
236         for (i=0; i<n; i++)
237         {
238             if ((pp_namelist[i]->d_name[0] != '.') &&
239                 (lstat(pp_namelist[i]->d_name, &st)==0))
240             {
241                 /* user, group  */
242                 p_pw  = getpwuid(st.st_uid);
243                 p_grp = getgrgid(st.st_gid);
244
245                 /* This is a list of strings. */
246                 ppsz_text[0] = pp_namelist[i]->d_name;
247                 ppsz_text[1] = get_file_perms(st);
248                 ppsz_text[2] = p_pw->pw_name;
249                 ppsz_text[3] = p_grp->gr_name;
250 #if 0
251                 msg_Dbg(p_intf, "(%d) file: %s permission: %s user: %s group: %s", i, ppsz_text[0], ppsz_text[1], ppsz_text[2], ppsz_text[3] );
252 #endif
253                 gtk_list_store_append (p_list, &iter);
254                 gtk_list_store_set (p_list, &iter,
255                                     0, ppsz_text[0],
256                                     1, ppsz_text[1],
257                                     2, st.st_size,
258                                     3, ppsz_text[2],
259                                     4, ppsz_text[3],
260                                     -1);
261
262                 free(ppsz_text[1]);
263             }
264         }
265         free(pp_namelist);
266     }
267 }
268
269 static char *get_file_perms(const struct stat st)
270 {
271     char  *psz_perm;
272
273     psz_perm = (char *) malloc(10);
274     strncpy( psz_perm, "----------", sizeof("----------"));
275
276     /* determine permission modes */
277     if (S_ISLNK(st.st_mode))
278         psz_perm[0]= 'l';
279     else if (S_ISDIR(st.st_mode))
280         psz_perm[0]= 'd';
281     else if (S_ISCHR(st.st_mode))
282         psz_perm[0]= 'c';
283     else if (S_ISBLK(st.st_mode))
284         psz_perm[0]= 'b';
285     else if (S_ISFIFO(st.st_mode))
286         psz_perm[0]= 'f';
287     else if (S_ISSOCK(st.st_mode))
288         psz_perm[0]= 's';
289     else if (S_ISREG(st.st_mode))
290         psz_perm[0]= '-';
291     else /* Unknown type is an error */
292         psz_perm[0]= '?';
293     /* Get file permissions */
294     /* User */
295     if (st.st_mode & S_IRUSR)
296         psz_perm[1]= 'r';
297     if (st.st_mode & S_IWUSR)
298         psz_perm[2]= 'w';
299     if (st.st_mode & S_IXUSR)
300     {
301         if (st.st_mode & S_ISUID)
302             psz_perm[3] = 's';
303         else
304             psz_perm[3]= 'x';
305     }
306     else if (st.st_mode & S_ISUID)
307         psz_perm[3] = 'S';
308     /* Group */
309     if (st.st_mode & S_IRGRP)
310         psz_perm[4]= 'r';
311     if (st.st_mode & S_IWGRP)
312         psz_perm[5]= 'w';
313     if (st.st_mode & S_IXGRP)
314     {
315         if (st.st_mode & S_ISGID)
316             psz_perm[6] = 's';
317         else
318             psz_perm[6]= 'x';
319     }
320     else if (st.st_mode & S_ISGID)
321         psz_perm[6] = 'S';
322     /* Other */
323     if (st.st_mode & S_IROTH)
324         psz_perm[7]= 'r';
325     if (st.st_mode & S_IWOTH)
326         psz_perm[8]= 'w';
327     if (st.st_mode & S_IXOTH)
328     {
329         /* 'sticky' bit */
330         if (st.st_mode &S_ISVTX)
331             psz_perm[9] = 't';
332         else
333             psz_perm[9]= 'x';
334     }
335     else if (st.st_mode &S_ISVTX)
336         psz_perm[9]= 'T';
337
338     return psz_perm;
339 }
340
341 /*
342  * Main interface callbacks
343  */
344
345 gboolean onPDADeleteEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
346 {
347     intf_thread_t *p_intf = GtkGetIntf( widget );
348
349     vlc_mutex_lock( &p_intf->change_lock );
350     libvlc_Quit( p_intf->p_libvlc );
351     vlc_mutex_unlock( &p_intf->change_lock );
352     msg_Dbg( p_intf, "about to exit vlc ... signaled" );
353
354     return TRUE;
355 }
356
357 void onRewind(GtkButton *button, gpointer user_data)
358 {
359     intf_thread_t *p_intf = GtkGetIntf( button );
360
361     if (p_intf->p_sys->p_input != NULL)
362     {
363         var_SetVoid( p_intf->p_sys->p_input, "rate-slower" );
364     }
365 }
366
367 void onPause(GtkButton *button, gpointer user_data)
368 {
369     intf_thread_t *p_intf = GtkGetIntf( button );
370
371     if (p_intf->p_sys->p_input != NULL)
372     {
373         var_SetInteger( p_intf->p_sys->p_input, "state", PAUSE_S );
374     }
375 }
376
377
378 void onPlay(GtkButton *button, gpointer user_data)
379 {
380     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
381     playlist_t *p_playlist = pl_Hold( p_intf );
382
383     if (p_playlist)
384     {
385         int s;
386
387         PL_LOCK;
388         s = playlist_CurrentSize(p_playlist);
389         PL_UNLOCK;
390         /* FIXME: This is racy... */
391         if (s)
392         {
393             playlist_Play( p_playlist );
394             gdk_window_lower( p_intf->p_sys->p_window->window );
395         }
396         pl_Release( p_intf );
397     }
398 }
399
400 void onStop(GtkButton *button, gpointer user_data)
401 {
402     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
403     playlist_t *p_playlist = pl_Hold( p_intf );
404     if (p_playlist)
405     {
406         playlist_Stop( p_playlist );
407         pl_Release( p_intf );
408         gdk_window_raise( p_intf->p_sys->p_window->window );
409     }
410 }
411
412 void onForward(GtkButton *button, gpointer user_data)
413 {
414     intf_thread_t *p_intf = GtkGetIntf( button );
415
416     if (p_intf->p_sys->p_input != NULL)
417     {
418         var_SetVoid( p_intf->p_sys->p_input, "rate-faster" );
419     }
420 }
421
422
423 void onAbout(GtkButton *button, gpointer user_data)
424 {
425     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(button) );
426
427     /* Toggle notebook */
428     if (p_intf->p_sys->p_notebook)
429     {
430         gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
431         gtk_notebook_set_page(p_intf->p_sys->p_notebook,6);
432     }
433 }
434
435 gboolean SliderRelease(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
436 {
437     intf_thread_t *p_intf = GtkGetIntf( widget );
438
439     msg_Dbg( p_intf, "SliderButton Release" );
440     vlc_mutex_lock( &p_intf->change_lock );
441     p_intf->p_sys->b_slider_free = 1;
442     vlc_mutex_unlock( &p_intf->change_lock );
443
444     return TRUE;
445 }
446
447 gboolean SliderPress(GtkWidget *widget, GdkEventButton *event, gpointer user_data)
448 {
449     intf_thread_t *p_intf = GtkGetIntf( widget );
450
451     msg_Dbg( p_intf, "SliderButton Press" );
452     vlc_mutex_lock( &p_intf->change_lock );
453     p_intf->p_sys->b_slider_free = 0;
454     vlc_mutex_unlock( &p_intf->change_lock );
455
456     return FALSE;
457 }
458
459 void SliderMove(GtkRange *range, GtkScrollType scroll, gpointer user_data)
460 {
461     intf_thread_t *p_intf = GtkGetIntf( range );
462     msg_Dbg( p_intf, "SliderButton Move" );
463 }
464
465
466 static void addSelectedToPlaylist(GtkTreeModel *model, GtkTreePath *path,
467                            GtkTreeIter *iter, gpointer *userdata)
468 {
469     gchar *psz_filename;
470
471     gtk_tree_model_get(model, iter, 0, &psz_filename, -1);
472
473     PlaylistAddItem(GTK_WIDGET(userdata), psz_filename, 0, 0);
474 }
475
476 void onFileListRow(GtkTreeView *treeview, GtkTreePath *path,
477                    GtkTreeViewColumn *column, gpointer user_data)
478 {
479     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
480     GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
481
482     if (gtk_tree_selection_count_selected_rows(p_selection) == 1)
483     {
484         struct stat   st;
485         GtkTreeModel *p_model;
486         GtkTreeIter   iter;
487         char         *psz_filename;
488
489         /* This might be a directory selection */
490         p_model = gtk_tree_view_get_model(treeview);
491         if (!p_model)
492         {
493             msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer" );
494             return;
495         }
496         if (!gtk_tree_model_get_iter(p_model, &iter, path))
497         {
498             msg_Err( p_intf, "PDA: Could not get iter from model" );
499             return;
500         }
501
502         gtk_tree_model_get(p_model, &iter, 0, &psz_filename, -1);
503         if (stat((char*)psz_filename, &st)==0)
504         {
505             if (S_ISDIR(st.st_mode))
506             {
507                 GtkListStore *p_store = NULL;
508
509                 /* Get new directory listing */
510                 p_store = gtk_list_store_new (5,
511                                            G_TYPE_STRING,
512                                            G_TYPE_STRING,
513                                            G_TYPE_UINT64,
514                                            G_TYPE_STRING,
515                                            G_TYPE_STRING);
516                 if (p_store)
517                 {
518                     ReadDirectory(p_intf, p_store, psz_filename);
519
520                     /* Update TreeView with new model */
521                     gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_store);
522                     g_object_unref(p_store);
523                 }
524             }
525         }
526     }
527 }
528
529 void onAddFileToPlaylist(GtkButton *button, gpointer user_data)
530 {
531     GtkTreeView       *p_treeview = NULL;
532
533     p_treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
534     if (p_treeview)
535     {
536         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_treeview);
537
538         gtk_tree_selection_selected_foreach(p_selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) p_treeview);
539     }
540 }
541
542
543 void NetworkBuildMRL(GtkEditable *editable, gpointer user_data)
544 {
545     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(editable) );
546     GtkSpinButton *p_networkPort = NULL;
547     GtkEntry      *p_entryMRL = NULL;
548     GtkEntry      *p_networkType = NULL;
549     GtkEntry      *p_networkAddress = NULL;
550     GtkEntry      *p_networkProtocol = NULL;
551     const gchar   *psz_mrlNetworkType;
552     const gchar   *psz_mrlAddress;
553     const gchar   *psz_mrlProtocol;
554     gint           i_mrlPort;
555     char           text[VLC_MAX_MRL];
556     int            i_pos = 0;
557
558     p_entryMRL = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryMRL" );
559
560     p_networkType     = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkType" );
561     p_networkAddress  = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkAddress" );
562     p_networkPort     = (GtkSpinButton*) lookup_widget( GTK_WIDGET(editable), "entryNetworkPort" );
563     p_networkProtocol = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryNetworkProtocolType" );
564
565     psz_mrlNetworkType = gtk_entry_get_text(GTK_ENTRY(p_networkType));
566     psz_mrlAddress     = gtk_entry_get_text(GTK_ENTRY(p_networkAddress));
567     i_mrlPort          = gtk_spin_button_get_value_as_int(p_networkPort);
568     psz_mrlProtocol    = gtk_entry_get_text(GTK_ENTRY(p_networkProtocol));
569
570     /* Build MRL from parts ;-) */
571     i_pos = snprintf( &text[0], VLC_MAX_MRL, "%s://", (char*)psz_mrlProtocol);
572     if (strncasecmp( (char*)psz_mrlNetworkType, "multicast",9)==0)
573     {
574         i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "@" );
575     }
576     i_pos += snprintf( &text[i_pos], VLC_MAX_MRL - i_pos, "%s:%d", (char*)psz_mrlAddress, (int)i_mrlPort );
577
578     if (i_pos >= VLC_MAX_MRL)
579     {
580         text[VLC_MAX_MRL-1]='\0';
581         msg_Err( p_intf, "Media Resource Locator is truncated to: %s", text);
582     }
583
584     gtk_entry_set_text(p_entryMRL,text);
585 }
586
587 void onAddNetworkPlaylist(GtkButton *button, gpointer user_data)
588 {
589     intf_thread_t  *p_intf = GtkGetIntf( button );
590
591     GtkEntry       *p_mrl = NULL;
592     GtkCheckButton *p_network_transcode = NULL;
593     gboolean        b_network_transcode;
594     const gchar    *psz_mrl_name;
595
596     p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"entryMRL" );
597     psz_mrl_name = gtk_entry_get_text(p_mrl);
598
599     p_network_transcode = (GtkCheckButton*) lookup_widget(GTK_WIDGET(button), "checkNetworkTranscode" );
600     b_network_transcode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_network_transcode));
601     if (b_network_transcode)
602     {
603         msg_Dbg( p_intf, "Network transcode option selected." );
604         onAddTranscodeToPlaylist(button, (gchar *)psz_mrl_name);
605     }
606     else
607     {
608         msg_Dbg( p_intf, "Network receiving selected." );
609         PlaylistAddItem(GTK_WIDGET(button), (gchar *)psz_mrl_name, 0, 0);
610     }
611 }
612
613
614 void onAddCameraToPlaylist(GtkButton *button, gpointer user_data)
615 {
616     intf_thread_t *p_intf = GtkGetIntf( button );
617
618     GtkSpinButton *entryV4LChannel = NULL;
619     GtkSpinButton *entryV4LFrequency = NULL;
620     GtkSpinButton *entryV4LSampleRate = NULL;
621     GtkSpinButton *entryV4LQuality = NULL;
622     GtkSpinButton *entryV4LTuner = NULL;
623     gint    i_v4l_channel;
624     gint    i_v4l_frequency;
625     gint    i_v4l_samplerate;
626     gint    i_v4l_quality;
627     gint    i_v4l_tuner;
628
629     GtkEntry      *entryV4LVideoDevice = NULL;
630     GtkEntry      *entryV4LAudioDevice = NULL;
631     GtkEntry      *entryV4LNorm = NULL;
632     GtkEntry      *entryV4LSize = NULL;
633     GtkEntry      *entryV4LSoundDirection = NULL;
634     const gchar   *p_v4l_video_device;
635     const gchar   *p_v4l_audio_device;
636     const gchar   *p_v4l_norm;
637     const gchar   *p_v4l_size;
638     const gchar   *p_v4l_sound_direction;
639
640     /* MJPEG only */
641     GtkCheckButton *checkV4LMJPEG = NULL;
642     GtkSpinButton  *entryV4LDecimation = NULL;
643     gboolean        b_v4l_mjpeg;
644     gint            i_v4l_decimation;
645     /* end MJPEG only */
646
647     GtkCheckButton  *p_check_v4l_transcode = NULL;
648     gboolean         b_v4l_transcode;
649  
650     char **ppsz_options = NULL; /* list of options */
651     int  i_options=0;
652     char v4l_mrl[6];
653     int i_pos;
654     int i;
655
656     ppsz_options = (char **) malloc(11 *sizeof(char*));
657     if (ppsz_options == NULL)
658         return;
659     for (i=0; i<11; i++)
660     {
661         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL);
662         if (ppsz_options[i] == NULL)
663         {
664             for (i-=1; i>=0; i--)
665                 free(ppsz_options[i]);
666             free(ppsz_options);
667             return;
668         }
669     }
670
671     i_pos = snprintf( &v4l_mrl[0], 6, "v4l");
672     v4l_mrl[5]='\0';
673
674     entryV4LChannel    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LChannel" );
675     entryV4LFrequency  = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LFrequency" );
676     entryV4LSampleRate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LSampleRate" );
677     entryV4LQuality    = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LQuality" );
678     entryV4LTuner      = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LTuner" );
679
680     entryV4LVideoDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LVideoDevice" );
681     entryV4LAudioDevice  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LAudioDevice" );
682     entryV4LNorm  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LNorm" );
683     entryV4LSize  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSize" );
684     entryV4LSoundDirection  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryV4LSoundDirection" );
685
686     i_v4l_channel = gtk_spin_button_get_value_as_int(entryV4LChannel);
687     i_v4l_frequency = gtk_spin_button_get_value_as_int(entryV4LFrequency);
688     i_v4l_samplerate = gtk_spin_button_get_value_as_int(entryV4LSampleRate);
689     i_v4l_quality = gtk_spin_button_get_value_as_int(entryV4LQuality);
690     i_v4l_tuner = gtk_spin_button_get_value_as_int(entryV4LTuner);
691
692     p_v4l_video_device = gtk_entry_get_text(GTK_ENTRY(entryV4LVideoDevice));
693     p_v4l_audio_device = gtk_entry_get_text(GTK_ENTRY(entryV4LAudioDevice));
694     p_v4l_norm = gtk_entry_get_text(GTK_ENTRY(entryV4LNorm));
695     p_v4l_size  = gtk_entry_get_text(GTK_ENTRY(entryV4LSize));
696     p_v4l_sound_direction = gtk_entry_get_text(GTK_ENTRY(entryV4LSoundDirection));
697
698     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_video_device );
699     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
700     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "adev=%s", (char*)p_v4l_audio_device );
701     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
702     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "norm=%s", (char*)p_v4l_norm );
703     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
704     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "size=%s", (char*)p_v4l_size );
705     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
706     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "%s", (char*)p_v4l_sound_direction );
707     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
708
709     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "channel=%d", (int)i_v4l_channel );
710     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
711     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "frequency=%d", (int)i_v4l_frequency );
712     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
713     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "samplerate=%d", (int)i_v4l_samplerate );
714     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
715     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "quality=%d", (int)i_v4l_quality );
716     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
717     i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "tuner=%d", (int)i_v4l_tuner );
718     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
719
720     /* MJPEG only */
721     checkV4LMJPEG      = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkV4LMJPEG" );
722     b_v4l_mjpeg = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(checkV4LMJPEG));
723     if (b_v4l_mjpeg)
724     {
725         entryV4LDecimation = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryV4LDecimation" );
726         i_v4l_decimation = gtk_spin_button_get_value_as_int(entryV4LDecimation);
727
728         i_pos = snprintf( &ppsz_options[i_options++][0], VLC_MAX_MRL, "mjpeg:%d", (int)i_v4l_decimation );
729         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
730     }
731     /* end MJPEG only */
732
733     p_check_v4l_transcode = (GtkCheckButton*) lookup_widget(GTK_WIDGET(button), "checkV4LTranscode" );
734     b_v4l_transcode = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_check_v4l_transcode));
735     if (b_v4l_transcode)
736     {
737         msg_Dbg( p_intf, "Camera transcode option selected." );
738         onAddTranscodeToPlaylist(button, (gchar *)v4l_mrl);
739     }
740     else
741     {
742         msg_Dbg( p_intf, "Camera reception option selected." );
743         PlaylistAddItem(GTK_WIDGET(button), (gchar*) &v4l_mrl, ppsz_options, i_options);
744     }
745 }
746
747
748 gboolean PlaylistEvent(GtkWidget *widget, GdkEvent *event, gpointer user_data)
749 {
750     return FALSE;
751 }
752
753
754 void onPlaylistColumnsChanged(GtkTreeView *treeview, gpointer user_data)
755 {
756 }
757
758
759 gboolean onPlaylistRowSelected(GtkTreeView *treeview, gboolean start_editing, gpointer user_data)
760 {
761     return FALSE;
762 }
763
764
765 void onPlaylistRow(GtkTreeView *treeview, GtkTreePath *path,
766                    GtkTreeViewColumn *column, gpointer user_data)
767 {
768     intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
769     GtkTreeSelection *p_selection = gtk_tree_view_get_selection(treeview);
770     playlist_t * p_playlist = pl_Hold( p_intf );
771
772     if( p_playlist == NULL )
773     {
774         return; // FALSE;
775     }
776
777     if (gtk_tree_selection_count_selected_rows(p_selection) == 1)
778     {
779         GtkTreeModel *p_model;
780         GtkTreeIter   iter;
781         int           i_row;
782         int           i_skip;
783
784         /* This might be a directory selection */
785         p_model = gtk_tree_view_get_model(treeview);
786         if (!p_model)
787         {
788             msg_Err(p_intf, "PDA: Playlist model contains a NULL pointer" );
789             return;
790         }
791         if (!gtk_tree_model_get_iter(p_model, &iter, path))
792         {
793             msg_Err( p_intf, "PDA: Playlist could not get iter from model" );
794             return;
795         }
796
797         gtk_tree_model_get(p_model, &iter, 2, &i_row, -1);
798         i_skip = i_row - p_playlist->i_current_index;
799         playlist_Skip( p_playlist, i_skip );
800     }
801     pl_Release( p_intf );
802 }
803
804
805 void onUpdatePlaylist(GtkButton *button, gpointer user_data)
806 {
807     intf_thread_t *  p_intf = GtkGetIntf( button );
808     playlist_t * p_playlist = pl_Hold( p_intf );
809     GtkTreeView *p_tvplaylist = NULL;
810
811     if( p_playlist == NULL )
812     {
813         return;
814     }
815
816     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
817     if (p_tvplaylist)
818     {
819         GtkListStore *p_model = NULL;
820
821         /* Rebuild the playlist then. */
822         p_model = gtk_list_store_new (3,
823                     G_TYPE_STRING, /* Filename */
824                     G_TYPE_STRING, /* Time */
825                     G_TYPE_UINT);  /* Hidden field */
826         if (p_model)
827         {
828             PlaylistRebuildListStore(p_intf, p_model, p_playlist);
829             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));
830             g_object_unref(p_model);
831         }
832     }
833     pl_Release( p_intf );
834 }
835
836 static void deleteItemFromPlaylist(gpointer data, gpointer user_data)
837 {
838     gtk_tree_path_free((GtkTreePath*) data); // removing an item.
839 }
840
841 void onDeletePlaylist(GtkButton *button, gpointer user_data)
842 {
843     intf_thread_t *p_intf = GtkGetIntf( button );
844     playlist_t * p_playlist = pl_Hold( p_intf );
845     GtkTreeView    *p_tvplaylist;
846
847     /* Delete an arbitrary item from the playlist */
848     p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );
849     if (p_tvplaylist != NULL)
850     {
851         GList *p_rows = NULL;
852         GList *p_node;
853         GtkTreeModel *p_model = NULL;
854         GtkListStore *p_store = NULL;
855         GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);
856
857         p_model = gtk_tree_view_get_model(p_tvplaylist);
858         if (p_model)
859         {
860             p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);
861
862             if( g_list_length( p_rows ) )
863             {
864                 /* reverse-sort so that we can delete from the furthest
865                  * to the closest item to delete...
866                  */
867                 p_rows = g_list_reverse( p_rows );
868             }
869
870             for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)
871             {
872                 GtkTreeIter iter;
873                 GtkTreePath *p_path = NULL;
874
875                 p_path = (GtkTreePath *)p_node->data;
876                 if (p_path)
877                 {
878                     if (gtk_tree_model_get_iter(p_model, &iter, p_path))
879                     {
880                         gint item;
881
882                         gtk_tree_model_get(p_model, &iter, 2, &item, -1);
883                         msg_Err( p_playlist, "PDA delete broken");
884                     }
885                 }
886             }
887 #if 0
888             g_list_foreach (p_rows, (GFunc*)gtk_tree_path_free, NULL);
889 #endif /* Testing the next line */
890             g_list_foreach (p_rows, deleteItemFromPlaylist, NULL);
891             g_list_free (p_rows);
892         }
893
894         /* Rebuild the playlist then. */
895         p_store = gtk_list_store_new (3,
896                     G_TYPE_STRING, /* Filename */
897                     G_TYPE_STRING, /* Time */
898                     G_TYPE_UINT);  /* Hidden field */
899         if (p_store)
900         {
901             PlaylistRebuildListStore(p_intf, p_store, p_playlist);
902             gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));
903             g_object_unref(p_store);
904         }
905     }
906     pl_Release( p_intf );
907 }
908
909
910 void onClearPlaylist(GtkButton *button, gpointer user_data)
911 {
912     intf_thread_t *p_intf = GtkGetIntf( button );
913     playlist_t * p_playlist = pl_Hold( p_intf );
914     GtkTreeView    *p_tvplaylist;
915     int item;
916
917     if( p_playlist == NULL )
918     {
919         return;
920     }
921
922     for(item = playlist_CurrentSize(p_playlist) - 1; item >= 0 ;item-- )
923     {
924         msg_Err( p_playlist, "fix pda delete" );
925     }
926     pl_Release( p_intf );
927
928     // Remove all entries from the Playlist widget.
929     p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
930     if (p_tvplaylist)
931     {
932         GtkTreeModel *p_play_model;
933
934         p_play_model = gtk_tree_view_get_model(p_tvplaylist);
935         if (p_play_model)
936         {
937             gtk_list_store_clear(GTK_LIST_STORE(p_play_model));
938         }
939     }
940 }
941
942
943 void onPreferenceSave(GtkButton *button, gpointer user_data)
944 {
945 #if 0
946     intf_thread_t *p_intf = GtkGetIntf( button );
947
948     msg_Dbg(p_intf, "Preferences Save" );
949     config_SaveConfigFile( p_intf, NULL );
950 #endif
951 }
952
953
954 void onPreferenceApply(GtkButton *button, gpointer user_data)
955 {
956 #if 0
957     intf_thread_t *p_intf = GtkGetIntf( button );
958
959     msg_Dbg(p_intf, "Preferences Apply" );
960 #endif
961 }
962
963
964 void onPreferenceCancel(GtkButton *button, gpointer user_data)
965 {
966 #if 0
967     intf_thread_t *p_intf = GtkGetIntf( button );
968
969     msg_Dbg(p_intf, "Preferences Cancel" );
970     config_ResetAll( p_intf );
971     /* Cancel interface changes. */
972     config_SaveConfigFile( p_intf, NULL );
973 #endif
974 }
975
976
977 void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data)
978 {
979     intf_thread_t *p_intf = GtkGetIntf( button );
980
981     GtkEntry       *p_entryVideoCodec = NULL;
982     GtkSpinButton  *p_entryVideoBitrate = NULL;
983     GtkSpinButton  *p_entryVideoBitrateTolerance = NULL;
984     GtkSpinButton  *p_entryVideoKeyFrameInterval = NULL;
985     GtkCheckButton *p_checkVideoDeinterlace = NULL;
986     GtkEntry       *p_entryAudioCodec = NULL;
987     GtkSpinButton  *p_entryAudioBitrate = NULL;
988     const gchar    *p_video_codec;
989     gint            i_video_bitrate;
990     gint            i_video_bitrate_tolerance;
991     gint            i_video_keyframe_interval;
992     gboolean        b_video_deinterlace;
993     const gchar    *p_audio_codec;
994     gint            i_audio_bitrate;
995
996     GtkEntry       *p_entryStdAccess = NULL;
997     GtkEntry       *p_entryStdMuxer = NULL;
998     GtkEntry       *p_entryStdURL = NULL;
999     GtkEntry       *p_entryStdAnnounce = NULL;
1000     GtkSpinButton  *p_entryStdTTL = NULL;
1001     GtkCheckButton *p_checkSAP = NULL;
1002     GtkCheckButton *p_checkSLP = NULL;
1003     const gchar    *p_std_announce;
1004     const gchar    *p_std_access;
1005     const gchar    *p_std_muxer;
1006     const gchar    *p_std_url;
1007     gboolean        b_sap_announce;
1008     gboolean        b_slp_announce;
1009     gint            i_std_ttl;
1010
1011     char **ppsz_options = NULL; /* list of options */
1012     int  i_options=0;
1013     int  i;
1014
1015     gchar mrl[7];
1016     int   i_pos;
1017
1018     ppsz_options = (char **) malloc(3 *sizeof(char*));
1019     if (ppsz_options == NULL)
1020         return;
1021     for (i=0; i<3; i++)
1022     {
1023         ppsz_options[i] = (char *) malloc(VLC_MAX_MRL);
1024         if (ppsz_options[i] == NULL)
1025         {
1026             for (i-=1; i>=0; i--)
1027                 free(ppsz_options[i]);
1028             free(ppsz_options);
1029             return;
1030         }
1031     }
1032
1033     /* Update the playlist */
1034     playlist_t *p_playlist = pl_Hold( p_intf );
1035     if( p_playlist == NULL ) return;
1036
1037     /* Get all the options. */
1038     i_pos = snprintf( &mrl[0], VLC_MAX_MRL, "sout");
1039     mrl[6] = '\0';
1040     /* option 1 */
1041     i_pos = snprintf( &ppsz_options[i_options][0], VLC_MAX_MRL, "sout='#transcode{");
1042     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1043
1044     p_entryVideoCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );
1045     p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );
1046     p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );
1047     p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );
1048  
1049     p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec));
1050     i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate);
1051     i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance);
1052     i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval);
1053  
1054     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec );
1055     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1056     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate );
1057     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1058     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vt=%d,", (int)i_video_bitrate_tolerance );
1059     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1060     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "keyint=%d,", (int)i_video_keyframe_interval );
1061     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1062
1063     p_checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );
1064     b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkVideoDeinterlace));
1065     if (b_video_deinterlace)
1066     {
1067         i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "deinterlace," );
1068         if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1069     }
1070     p_entryAudioCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );
1071     p_entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );
1072
1073     p_audio_codec = gtk_entry_get_text(GTK_ENTRY(p_entryAudioCodec));
1074     i_audio_bitrate = gtk_spin_button_get_value_as_int(p_entryAudioBitrate);
1075
1076     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "acodec=%s,", (char*)p_audio_codec );
1077     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1078     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "ab=%d,", (int)i_audio_bitrate );
1079     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1080     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "channels=1}"/*, (int)i_audio_channels*/ );
1081     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1082
1083     /* option 2 */
1084     i_pos = 0;
1085     i_pos = snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "#" );
1086     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1087
1088     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );
1089     p_entryStdMuxer  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );
1090     p_entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );
1091     p_entryStdAnnounce = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAnnounceChannel" );
1092     p_entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );
1093
1094     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1095     p_std_muxer = gtk_entry_get_text(GTK_ENTRY(p_entryStdMuxer));
1096     p_std_url = gtk_entry_get_text(GTK_ENTRY(p_entryStdURL));
1097     p_std_announce = gtk_entry_get_text(GTK_ENTRY(p_entryStdAnnounce));
1098     b_sap_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSAP));
1099     b_slp_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSLP));
1100
1101     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "std{access=%s,", (char*)p_std_access);
1102     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1103     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "mux=%s,", (char*)p_std_muxer);
1104     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1105     i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "dst=%s", (char*)p_std_url);
1106     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1107
1108     if (strncasecmp( (const char*)p_std_access, "udp", 3)==0)
1109     {
1110         if (b_sap_announce)
1111         {
1112             i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "sap=%s", (char*)p_std_announce);
1113             if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1114         }
1115         if (b_slp_announce)
1116         {
1117             i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "slp=%s", (char*)p_std_announce);
1118             if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1119         }
1120     }
1121
1122     i_std_ttl = gtk_spin_button_get_value_as_int(p_entryStdTTL);
1123
1124     i_pos += snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "ttl=%d}", (int)i_std_ttl);
1125     if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';
1126
1127     if (user_data != NULL)
1128     {
1129       msg_Dbg(p_intf, "Adding transcoding options to playlist item." );
1130     }
1131     else
1132     {
1133       msg_Dbg(p_intf, "Adding --sout to playlist." );
1134       PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl, ppsz_options, i_options);
1135     }
1136 }
1137
1138 void onEntryStdAccessChanged(GtkEditable *editable, gpointer user_data)
1139 {
1140     intf_thread_t *p_intf = GtkGetIntf( editable );
1141
1142     GtkCheckButton *p_checkSAP = NULL;
1143     GtkCheckButton *p_checkSLP = NULL;
1144     GtkEntry       *p_entryStdAccess = NULL;
1145     const gchar    *p_std_access = NULL;
1146     gboolean        b_announce = FALSE;
1147
1148     p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryStdAccess" );
1149     p_checkSAP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSAP" );
1150     p_checkSLP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSLP" );
1151
1152     if ( (p_std_access == NULL) || (p_checkSAP == NULL) || (p_checkSLP == NULL))
1153     {
1154         msg_Err( p_intf, "Access, SAP and SLP widgets not found." );
1155         return;
1156     }
1157     p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));
1158
1159     b_announce = (strncasecmp( (const char*)p_std_access, "udp", 3) == 0);
1160     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSAP), b_announce);
1161     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSLP), b_announce);
1162 }
1163