75595a65a1f6985e63fd51569fdfa004d9c78024
[metze/wireshark/wip.git] / gtk / rtp_stream_dlg.c
1 /* rtp_stream_dlg.c
2  * RTP streams summary addition for Wireshark
3  *
4  * $Id$
5  *
6  * Copyright 2003, Alcatel Business Systems
7  * By Lars Ruoff <lars.ruoff@gmx.net>
8  *
9  * Wireshark - Network traffic analyzer
10  * By Gerald Combs <gerald@wireshark.org>
11  * Copyright 1998 Gerald Combs
12  *
13  * This program is free software; you can redistribute it and/or
14  * modify it under the terms of the GNU General Public License
15  * as published by the Free Software Foundation; either version 2
16  * of the License, or (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21  * GNU General Public License for more details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program; if not, write to the Free Software
25  * Foundation,  Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
26  */
27
28 #ifdef HAVE_CONFIG_H
29 #  include <config.h>
30 #endif
31
32 #include <stdio.h>
33 #include <string.h>
34 #include <locale.h>
35
36 #include <epan/rtp_pt.h>
37 #include <epan/address.h>
38 #include <epan/addr_resolv.h>
39 #include <epan/strutil.h>
40 #include "epan/filesystem.h"
41
42 #include "../globals.h"
43 #include "../stat_menu.h"
44 #include "../simple_dialog.h"
45
46 #include "gtk/rtp_stream_dlg.h"
47 #include "gtk/gui_stat_menu.h"
48 #include "gtk/dlg_utils.h"
49 #include "gtk/file_dlg.h"
50 #include "gtk/gui_utils.h"
51 #include "gtk/gtkglobals.h"
52 #include "gtk/rtp_stream.h"
53 #include "gtk/rtp_analysis.h"
54 #include "gtk/stock_icons.h"
55
56 static const gchar FWD_LABEL_TEXT[] = "Select a forward stream with left mouse button, and then";
57 static const gchar FWD_ONLY_LABEL_TEXT[] = "Select a forward stream with Ctrl + left mouse button";
58 static const gchar REV_LABEL_TEXT[] = "Select a reverse stream with Ctrl + left mouse button";
59
60 /****************************************************************************/
61 /* pointer to the one and only dialog window */
62 static GtkWidget *rtp_stream_dlg = NULL;
63
64 /* save as dialog box */
65 static GtkWidget *rtpstream_save_dlg = NULL;
66 static GtkListStore *list_store = NULL;
67 static GtkTreeIter list_iter;
68 static GtkWidget *list = NULL;
69 static GtkWidget *top_label = NULL;
70 static GtkWidget *label_fwd = NULL;
71 static GtkWidget *label_rev = NULL;
72
73 static rtp_stream_info_t* selected_stream_fwd = NULL;  /* current selection */
74 static rtp_stream_info_t* selected_stream_rev = NULL;  /* current selection for reversed */
75 static GList *last_list = NULL;
76
77 static guint32 streams_nb = 0;     /* number of displayed streams */
78
79 enum
80 {
81    RTP_COL_SRC_ADDR,
82    RTP_COL_SRC_PORT,
83    RTP_COL_DST_ADDR,
84    RTP_COL_DST_PORT,
85    RTP_COL_SSRC,
86    RTP_COL_PAYLOAD,
87    RTP_COL_PACKETS,
88    RTP_COL_LOST,
89    RTP_COL_MAX_DELTA,
90    RTP_COL_MAX_JITTER,
91    RTP_COL_MEAN_JITTER,
92    RTP_COL_PROBLEM,
93    RTP_COL_DATA,
94    NUM_COLS /* The number of columns */
95 };
96
97
98 /****************************************************************************/
99 static void save_stream_destroy_cb(GtkWidget *win _U_, gpointer user_data _U_)
100 {
101         /* Note that we no longer have a Save voice info dialog box. */
102         rtpstream_save_dlg = NULL;
103 }
104
105 /****************************************************************************/
106 /* save in a file */
107 static gboolean save_stream_ok_cb(GtkWidget *ok_bt _U_, gpointer fs)
108 {
109         gchar *g_dest;
110
111         if (!selected_stream_fwd) {
112                 return TRUE;
113         }
114
115         g_dest = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(fs));
116
117         /* Perhaps the user specified a directory instead of a file.
118            Check whether they did. */
119         if (test_for_directory(g_dest) == EISDIR) {
120                 /* It's a directory - set the file selection box to display it. */
121                 set_last_open_dir(g_dest);
122                 g_free(g_dest);
123                 file_selection_set_current_folder(fs, get_last_open_dir());
124                 gtk_file_chooser_set_current_name(fs, "");
125                 return FALSE;
126         }
127
128 #if 0   /* GtkFileChooser/gtk_dialog_run currently being used.         */
129         /*  So: Leaving the dialog box displayed after popping-up an   */
130         /*  alert box won't work.                                      */
131         /*
132          * Don't dismiss the dialog box if the save operation fails.
133          */
134         if (!rtpstream_save(selected_stream_fwd, g_dest)) {
135                 g_free(g_dest);
136                 return;
137         }
138         g_free(g_dest);
139         window_destroy(GTK_WIDGET(rtpstream_save_dlg));
140         return;
141 #else
142         /*  Dialog box needs to be always destroyed. Return TRUE      */
143         /*  so that caller will destroy the dialog box.               */
144         /*  See comment under rtpstream_on_save.                      */
145         rtpstream_save(selected_stream_fwd, g_dest);
146         g_free(g_dest);
147         return TRUE;
148 #endif
149 }
150
151
152 /****************************************************************************/
153 /* CALLBACKS                                                                */
154 /****************************************************************************/
155 static void
156 rtpstream_on_destroy(GObject *object _U_, gpointer user_data _U_)
157 {
158         /* Remove the stream tap listener */
159         remove_tap_listener_rtp_stream();
160
161         /* Is there a save voice window open? */
162         if (rtpstream_save_dlg != NULL)
163                 window_destroy(rtpstream_save_dlg);
164
165         /* Clean up memory used by stream tap */
166         rtpstream_reset((rtpstream_tapinfo_t *)rtpstream_get_info());
167
168         /* Note that we no longer have a "RTP Streams" dialog box. */
169         rtp_stream_dlg = NULL;
170 }
171
172
173 /****************************************************************************/
174 static void
175 rtpstream_on_unselect(GtkButton *button _U_, gpointer user_data _U_)
176 {
177         GtkTreeSelection *selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
178         gtk_tree_selection_unselect_all(selection);
179
180         selected_stream_fwd = NULL;
181         selected_stream_rev = NULL;
182         gtk_label_set_text(GTK_LABEL(label_fwd), FWD_LABEL_TEXT);
183         gtk_label_set_text(GTK_LABEL(label_rev), REV_LABEL_TEXT);
184 }
185
186
187 /****************************************************************************/
188 static gint rtp_stream_info_cmp_reverse(gconstpointer aa, gconstpointer bb)
189 {
190         const struct _rtp_stream_info* a = aa;
191         const struct _rtp_stream_info* b = bb;
192
193         if (a==NULL || b==NULL)
194                 return 1;
195         if ((ADDRESSES_EQUAL(&(a->src_addr), &(b->dest_addr)))
196                 && (a->src_port == b->dest_port)
197                 && (ADDRESSES_EQUAL(&(a->dest_addr), &(b->src_addr)))
198                 && (a->dest_port == b->src_port))
199                 return 0;
200         else
201                 return 1;
202 }
203
204 /****************************************************************************/
205 static void
206 rtpstream_on_findrev(GtkButton  *button _U_, gpointer user_data _U_)
207 {
208         GtkTreeSelection *selection;
209         GList *path_list;
210         GList *path_list_item = NULL;
211         GtkTreePath *path = NULL;
212         GtkTreePath *path_fwd = NULL;
213         GtkTreePath *path_rev = NULL;
214         GtkTreeIter iter;
215         rtp_stream_info_t *stream = NULL;
216         gboolean found_it = FALSE;
217
218         if (selected_stream_fwd==NULL)
219                 return;
220
221         selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(list));
222         path_list = gtk_tree_selection_get_selected_rows(selection, NULL);
223
224         if (path_list) {
225                 path_list_item = g_list_first(path_list);
226                 path = (GtkTreePath *)(path_list_item->data);
227         }
228
229         if (path && gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path)) {
230                 gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, RTP_COL_DATA, &stream, -1);
231                 if (stream == selected_stream_fwd) {
232                         path_fwd = path;
233                 }
234                 if (stream == selected_stream_rev) {
235                         path_rev = path;
236                 }
237         }
238
239         path = NULL;
240         if (path_list_item) {
241                 path_list_item = g_list_next(path_list_item);
242                 if (path_list_item)
243                         path = (GtkTreePath *)(path_list_item->data);
244         }
245
246         if (path && gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path)) {
247                 gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, RTP_COL_DATA, &stream, -1);
248                 if (stream == selected_stream_fwd) {
249                         path_fwd = path;
250                 }
251                 if (stream == selected_stream_rev) {
252                         path_rev = path;
253                 }
254         }
255
256         /* Find it from the forward stream on */
257         gtk_tree_model_get_iter(GTK_TREE_MODEL(list_store), &iter, path_fwd);
258         while (gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter)) {
259                 gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, RTP_COL_DATA, &stream, -1);
260                 if (rtp_stream_info_cmp_reverse(selected_stream_fwd, stream) == 0) {
261                         found_it = TRUE;
262                         break;
263                 }
264         };
265
266         if (!found_it) {
267                 /* If we're not done yet, restart at the beginning */
268                 gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter);
269                 do {
270                         gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, RTP_COL_DATA, &stream, -1);
271                         if (rtp_stream_info_cmp_reverse(selected_stream_fwd, stream) == 0) {
272                                 found_it = TRUE;
273                                 break;
274                         }
275                         if (stream == selected_stream_fwd)
276                                 break;
277                 } while (gtk_tree_model_iter_next(GTK_TREE_MODEL(list_store), &iter));
278         }
279
280         if (found_it) {
281                 if (path_rev)
282                         gtk_tree_selection_unselect_path(selection, path_rev);
283                 gtk_tree_selection_select_iter(selection, &iter);
284         }
285
286         g_list_foreach(path_list, (GFunc)gtk_tree_path_free, NULL);
287         g_list_free(path_list);
288 }
289
290
291 /****************************************************************************/
292 /*
293 static void
294 rtpstream_on_goto                      (GtkButton       *button _U_,
295                                         gpointer         user_data _U_)
296 {
297         if (selected_stream_fwd)
298         {
299                 cf_goto_frame(&cfile, selected_stream_fwd->first_frame_num);
300         }
301 }
302 */
303
304
305 /****************************************************************************/
306 static void
307 rtpstream_on_save(GtkButton *button _U_, gpointer data _U_)
308 {
309 /* XX - not needed?
310         rtpstream_tapinfo_t* tapinfo = data;
311 */
312
313         if (!selected_stream_fwd) {
314                 simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK,
315                               "Please select a forward stream");
316                 return;
317         }
318
319 #if 0  /* XXX: GtkFileChooserDialog/gtk_dialog_run currently being used is effectively modal so this is not req'd */
320         if (rtpstream_save_dlg != NULL) {
321                 /* There's already a Save dialog box; reactivate it. */
322                 reactivate_window(rtpstream_save_dlg);
323                 return;
324         }
325 #endif
326
327         rtpstream_save_dlg = gtk_file_chooser_dialog_new(
328                 "Wireshark: Save selected stream in rtpdump ('-F dump') format",
329                 GTK_WINDOW(rtp_stream_dlg), GTK_FILE_CHOOSER_ACTION_SAVE,
330                 GTK_STOCK_OK, GTK_RESPONSE_ACCEPT,
331                 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
332                 NULL);
333         gtk_file_chooser_set_do_overwrite_confirmation(GTK_FILE_CHOOSER(rtpstream_save_dlg), TRUE);
334
335         g_signal_connect(rtpstream_save_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
336         g_signal_connect(rtpstream_save_dlg, "destroy", G_CALLBACK(save_stream_destroy_cb), NULL);
337
338         gtk_widget_show(rtpstream_save_dlg);
339         window_present(rtpstream_save_dlg);
340 #if 0
341         if (gtk_dialog_run(GTK_DIALOG(rtpstream_save_dlg)) == GTK_RESPONSE_ACCEPT){
342                 save_stream_ok_cb(rtpstream_save_dlg, rtpstream_save_dlg);
343         }else{
344                 window_destroy(rtpstream_save_dlg);
345         }
346 #endif
347         /* "Run" the GtkFileChooserDialog.                                              */
348         /* Upon exit: If "Accept" run the OK callback.                                  */
349         /*            If the OK callback returns with a FALSE status, re-run the dialog.*/
350         /*            If not accept (ie: cancel) destroy the window.                    */
351         /* XXX: If the OK callback pops up an alert box (eg: for an error) it *must*    */
352         /*      return with a TRUE status so that the dialog window will be destroyed.  */
353         /*      Trying to re-run the dialog after popping up an alert box will not work */
354         /*       since the user will not be able to dismiss the alert box.              */
355         /*      The (somewhat unfriendly) effect: the user must re-invoke the           */
356         /*      GtkFileChooserDialog whenever the OK callback pops up an alert box.     */
357         /*                                                                              */
358         /*      ToDo: use GtkFileChooserWidget in a dialog window instead of            */
359         /*            GtkFileChooserDialog.                                             */
360         while (gtk_dialog_run(GTK_DIALOG(rtpstream_save_dlg)) == GTK_RESPONSE_ACCEPT) {
361                 if (save_stream_ok_cb(NULL, rtpstream_save_dlg)) {
362                         break; /* we're done */
363                 }
364         }
365         window_destroy(rtpstream_save_dlg);
366 }
367
368
369 /****************************************************************************/
370 static void
371 rtpstream_on_mark(GtkButton *button _U_, gpointer user_data _U_)
372 {
373         if (selected_stream_fwd==NULL && selected_stream_rev==NULL)
374                 return;
375         rtpstream_mark(selected_stream_fwd, selected_stream_rev);
376 }
377
378
379 /****************************************************************************/
380 static void
381 rtpstream_on_filter(GtkButton *button _U_, gpointer user_data _U_)
382 {
383         gchar *filter_string = NULL;
384         gchar *filter_string_fwd = NULL;
385         gchar *filter_string_rev = NULL;
386         gchar ip_version[3];
387
388         if (selected_stream_fwd==NULL && selected_stream_rev==NULL)
389                 return;
390
391         if (selected_stream_fwd)
392         {
393                 if (selected_stream_fwd->src_addr.type==AT_IPv6) {
394                         g_strlcpy(ip_version,"v6",sizeof(ip_version));
395                 } else {
396                         ip_version[0] = '\0';
397                 }
398                 filter_string_fwd = g_strdup_printf(
399                         "(ip%s.src==%s && udp.srcport==%u && ip%s.dst==%s && udp.dstport==%u && rtp.ssrc==0x%X)",
400                         ip_version,
401                         ep_address_to_str(&(selected_stream_fwd->src_addr)),
402                         selected_stream_fwd->src_port,
403                         ip_version,
404                         ep_address_to_str(&(selected_stream_fwd->dest_addr)),
405                         selected_stream_fwd->dest_port,
406                         selected_stream_fwd->ssrc);
407
408                 filter_string = filter_string_fwd;
409         }
410
411         if (selected_stream_rev)
412         {
413                 if (selected_stream_rev->src_addr.type==AT_IPv6) {
414                         g_strlcpy(ip_version,"v6",sizeof(ip_version));
415                 } else {
416                         ip_version[0] = '\0';
417                 }
418                 filter_string_rev = g_strdup_printf(
419                         "(ip%s.src==%s && udp.srcport==%u && ip%s.dst==%s && udp.dstport==%u && rtp.ssrc==0x%X)",
420                         ip_version,
421                         ep_address_to_str(&(selected_stream_rev->src_addr)),
422                         selected_stream_rev->src_port,
423                         ip_version,
424                         ep_address_to_str(&(selected_stream_rev->dest_addr)),
425                         selected_stream_rev->dest_port,
426                         selected_stream_rev->ssrc);
427
428                 filter_string = filter_string_rev;
429         }
430
431         if ((selected_stream_fwd) && (selected_stream_rev))
432         {
433                 filter_string = g_strdup_printf("%s || %s", filter_string_fwd, filter_string_rev);
434                 g_free(filter_string_fwd);
435                 g_free(filter_string_rev);
436         }
437
438         gtk_entry_set_text(GTK_ENTRY(main_display_filter_widget), filter_string);
439         g_free(filter_string);
440
441 /*
442         main_filter_packets(&cfile, filter_string, FALSE);
443         rtpstream_dlg_update(rtpstream_get_info()->strinfo_list);
444 */
445 }
446
447
448 /****************************************************************************/
449 static void
450 rtpstream_on_copy_as_csv(GtkWindow *win _U_, gpointer data _U_)
451 {
452         GtkTreeViewColumn *column;
453         const gchar       *title;
454         GtkTreeIter       iter;
455         guint             i,j;
456         gchar             *table_entry;
457         guint             table_entry_uint;
458
459         GString           *CSV_str;
460         GtkClipboard      *cb;
461
462         CSV_str = g_string_sized_new(240*(1+streams_nb));
463         /* Add the column headers to the CSV data */
464         for (j=0; j<NUM_COLS-1; j++) {
465                 column = gtk_tree_view_get_column(GTK_TREE_VIEW(list), j);
466                 title = gtk_tree_view_column_get_title(column);
467                 g_string_append_printf(CSV_str, "\"%s\"", title);
468                 if (j<NUM_COLS-2) g_string_append(CSV_str, ",");
469         }
470         g_string_append(CSV_str,"\n");
471
472         /* Add the column values to the CSV data */
473         if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(list_store), &iter)) {
474                 for (i=0; i<streams_nb; i++) {
475                         for (j=0; j<NUM_COLS-1; j++) {
476                                 if (j == RTP_COL_SRC_PORT || j == RTP_COL_DST_PORT || j == RTP_COL_PACKETS) {
477                                         gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, j, &table_entry_uint, -1);
478                                         g_string_append_printf(CSV_str, "\"%u\"", table_entry_uint);
479                                 } else {
480                                         gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, j, &table_entry, -1);
481                                         g_string_append_printf(CSV_str, "\"%s\"", table_entry);
482                                         g_free(table_entry);
483                                 }
484                                 if (j<NUM_COLS-2) g_string_append(CSV_str,",");
485                         }
486                         g_string_append(CSV_str,"\n");
487                         gtk_tree_model_iter_next (GTK_TREE_MODEL(list_store),&iter);
488                 }
489         }
490
491         /* Now that we have the CSV data, copy it into the default clipboard */
492         cb = gtk_clipboard_get(GDK_SELECTION_CLIPBOARD);
493         gtk_clipboard_set_text(cb, CSV_str->str, (gint)CSV_str->len);
494         g_string_free(CSV_str, TRUE);
495 }
496
497 /****************************************************************************/
498 static void
499 rtpstream_on_analyse(GtkButton *button _U_, gpointer user_data _U_)
500 {
501         address ip_src_fwd;
502         guint16 port_src_fwd = 0;
503         address ip_dst_fwd;
504         guint16 port_dst_fwd = 0;
505         guint32 ssrc_fwd = 0;
506         address ip_src_rev;
507         guint16 port_src_rev = 0;
508         address ip_dst_rev;
509         guint16 port_dst_rev = 0;
510         guint32 ssrc_rev = 0;
511
512         if (!(selected_stream_fwd || selected_stream_rev))
513         {
514                 return;
515         }
516
517         SET_ADDRESS(&ip_src_fwd,AT_NONE,0,NULL);
518         SET_ADDRESS(&ip_dst_fwd,AT_NONE,0,NULL);
519         SET_ADDRESS(&ip_src_rev,AT_NONE,0,NULL);
520         SET_ADDRESS(&ip_dst_rev,AT_NONE,0,NULL);
521
522         if (selected_stream_fwd) {
523                 COPY_ADDRESS(&(ip_src_fwd), &(selected_stream_fwd->src_addr));
524                 port_src_fwd = selected_stream_fwd->src_port;
525                 COPY_ADDRESS(&(ip_dst_fwd), &(selected_stream_fwd->dest_addr));
526                 port_dst_fwd = selected_stream_fwd->dest_port;
527                 ssrc_fwd = selected_stream_fwd->ssrc;
528         }
529
530         if (selected_stream_rev) {
531                 COPY_ADDRESS(&(ip_src_rev), &(selected_stream_rev->src_addr));
532                 port_src_rev = selected_stream_rev->src_port;
533                 COPY_ADDRESS(&(ip_dst_rev), &(selected_stream_rev->dest_addr));
534                 port_dst_rev = selected_stream_rev->dest_port;
535                 ssrc_rev = selected_stream_rev->ssrc;
536         }
537
538         rtp_analysis(
539                 &ip_src_fwd,
540                 port_src_fwd,
541                 &ip_dst_fwd,
542                 port_dst_fwd,
543                 ssrc_fwd,
544                 &ip_src_rev,
545                 port_src_rev,
546                 &ip_dst_rev,
547                 port_dst_rev,
548                 ssrc_rev
549                 );
550
551 }
552
553
554 /****************************************************************************/
555 /* when the user selects a row in the stream list */
556 static gboolean
557 rtpstream_view_selection_func(GtkTreeSelection *selection, GtkTreeModel *model, GtkTreePath *path, gboolean path_currently_selected, gpointer userdata _U_)
558 {
559         GtkTreeIter iter;
560         gint nb_selected;
561         rtp_stream_info_t* selected_stream;
562         gboolean result = TRUE;
563         gchar label_text[80];
564
565         /* Logic
566          * nb_selected  path_currently_selected forward reverse  action           result
567          *      0            must be false       any     any     assign forward   true
568          *      1               true             match   any     delete forward   true
569          *      1               true             other   any     delete reverse   true
570          *      1               false            match   any     invalid          true
571          *      1               false            other   none    assign reverse   true
572          *      1               false            other   any     assign forward   true
573          *      2               true             match   any     delete forward   path_currently_selected
574          *      2               true             other   match   delete reverse   path_currently_selected
575          *      2               true             other   other   invalid          path_currently_selected
576          *      2               false            match   any     invalid          path_currently_selected
577          *      2               false            any     match   invalid          path_currently_selected
578          *      2               false            other   other   assign reverse   path_currently_selected
579          *     >2               any              any     any     invalid          path_currently_selected
580          */
581
582         nb_selected = gtk_tree_selection_count_selected_rows(selection);
583         if (gtk_tree_model_get_iter(model, &iter, path)) {
584                 gtk_tree_model_get(GTK_TREE_MODEL(list_store), &iter, RTP_COL_DATA, &selected_stream, -1);
585
586                 switch (nb_selected)
587                 {
588                         case 0:
589                         {
590                                 if (path_currently_selected)
591                                         g_print("Select: He, we've got a selected path while none is selected?\n");
592                                 else
593                                         selected_stream_fwd = selected_stream;
594                                 break;
595                         }
596                         case 1:
597                         {
598                                 if (path_currently_selected)
599                                         if (selected_stream == selected_stream_fwd)
600                                                 selected_stream_fwd = NULL;
601                                         else
602                                                 selected_stream_rev = NULL;
603                                 else
604                                         if (selected_stream == selected_stream_fwd)
605                                                 g_print("Select: He, this can't be. 1 not selected but equal to fwd\n");
606                                         else
607                                                 if (selected_stream_rev)
608                                                         selected_stream_fwd = selected_stream;
609                                                 else
610                                                         selected_stream_rev = selected_stream;
611                                 break;
612                         }
613                         case 2:
614                         {
615                                 if (path_currently_selected) {
616                                         if (selected_stream == selected_stream_fwd)
617                                                 selected_stream_fwd = NULL;
618                                         else if (selected_stream == selected_stream_rev)
619                                                 selected_stream_rev = NULL;
620                                         else
621                                                 g_print("Select: He, this can't be. 2 selected but not equal to fwd or rev\n");
622                                 }
623                                 result = path_currently_selected;
624                                 break;
625                         }
626                         default:
627                         {
628                                 g_print("Select: He, we're getting a too high selection count\n");
629                                 result = path_currently_selected;
630                         }
631                 }
632         }
633
634         if (selected_stream_fwd) {
635                 g_snprintf(label_text, sizeof(label_text), "Forward: %s:%u -> %s:%u, SSRC=0x%X",
636                         get_addr_name(&(selected_stream_fwd->src_addr)),
637                         selected_stream_fwd->src_port,
638                         get_addr_name(&(selected_stream_fwd->dest_addr)),
639                         selected_stream_fwd->dest_port,
640                         selected_stream_fwd->ssrc
641                 );
642                 gtk_label_set_text(GTK_LABEL(label_fwd), label_text);
643         } else {
644                 if (selected_stream_rev)
645                         gtk_label_set_text(GTK_LABEL(label_fwd), FWD_ONLY_LABEL_TEXT);
646                 else
647                         gtk_label_set_text(GTK_LABEL(label_fwd), FWD_LABEL_TEXT);
648         }
649
650         if (selected_stream_rev) {
651                 g_snprintf(label_text, sizeof(label_text), "Reverse: %s:%u -> %s:%u, SSRC=0x%X",
652                         get_addr_name(&(selected_stream_rev->src_addr)),
653                         selected_stream_rev->src_port,
654                         get_addr_name(&(selected_stream_rev->dest_addr)),
655                         selected_stream_rev->dest_port,
656                         selected_stream_rev->ssrc
657                 );
658                 gtk_label_set_text(GTK_LABEL(label_rev), label_text);
659         } else {
660                 gtk_label_set_text(GTK_LABEL(label_rev), REV_LABEL_TEXT);
661         }
662
663         return result;
664 }
665
666 /****************************************************************************/
667 /* INTERFACE                                                                */
668 /****************************************************************************/
669 /* append a line to list */
670 static void
671 add_to_list_store(rtp_stream_info_t* strinfo)
672 {
673         gchar label_text[256];
674         gchar *data[NUM_COLS];
675         guint32 expected;
676         gint32 lost;
677         double perc;
678         int i;
679         char *savelocale;
680
681         /* save the current locale */
682         savelocale = setlocale(LC_NUMERIC, NULL);
683         /* switch to "C" locale to avoid problems with localized decimal separators
684                 in g_snprintf("%f") functions */
685         setlocale(LC_NUMERIC, "C");
686
687         data[0] = g_strdup(get_addr_name(&(strinfo->src_addr)));
688         data[1] = NULL;
689         data[2] = g_strdup(get_addr_name(&(strinfo->dest_addr)));
690         data[3] = NULL;
691         data[4] = g_strdup_printf("0x%X", strinfo->ssrc);
692         if ((strinfo->pt > 95) && (strinfo->info_payload_type_str != NULL)) {
693                 data[5] = g_strdup(strinfo->info_payload_type_str);
694         } else {
695                 data[5] = g_strdup(val_to_str_ext(strinfo->pt, &rtp_payload_type_short_vals_ext,
696                         "Unknown (%u)"));
697         }
698         data[6] = NULL;
699
700         expected = (strinfo->rtp_stats.stop_seq_nr + strinfo->rtp_stats.cycles*65536)
701                 - strinfo->rtp_stats.start_seq_nr + 1;
702         lost = expected - strinfo->rtp_stats.total_nr;
703         if (expected) {
704                 perc = (double)(lost*100)/(double)expected;
705         } else {
706                 perc = 0;
707         }
708         data[7] = g_strdup_printf("%d (%.1f%%)", lost, perc);
709         data[8] = g_strdup_printf("%.2f", strinfo->rtp_stats.max_delta);
710         data[9] = g_strdup_printf("%.2f", strinfo->rtp_stats.max_jitter);
711         data[10] = g_strdup_printf("%.2f", strinfo->rtp_stats.mean_jitter);
712         if (strinfo->problem)
713                 data[11] = g_strdup("X");
714         else
715                 data[11] = g_strdup("");
716
717         /* restore previous locale setting */
718         setlocale(LC_NUMERIC, savelocale);
719
720         /* Acquire an iterator */
721         gtk_list_store_append(list_store, &list_iter);
722
723         /* Fill the new row */
724         gtk_list_store_set(list_store, &list_iter,
725                             RTP_COL_SRC_ADDR, data[0],
726                             RTP_COL_SRC_PORT, strinfo->src_port,
727                             RTP_COL_DST_ADDR, data[2],
728                             RTP_COL_DST_PORT, strinfo->dest_port,
729                             RTP_COL_SSRC, data[4],
730                             RTP_COL_PAYLOAD, data[5],
731                             RTP_COL_PACKETS, strinfo->npackets,
732                             RTP_COL_LOST, data[7],
733                             RTP_COL_MAX_DELTA, data[8],
734                             RTP_COL_MAX_JITTER, data[9],
735                             RTP_COL_MEAN_JITTER, data[10],
736                             RTP_COL_PROBLEM, data[11],
737                             RTP_COL_DATA, strinfo,
738                             -1);
739
740         for (i = 0; i < NUM_COLS-1; i++)
741                 g_free(data[i]);
742
743         /* Update the top label with the number of detected streams */
744         g_snprintf(label_text, sizeof(label_text),
745                 "Detected %d RTP streams. Choose one for forward and reverse direction for analysis",
746                 ++streams_nb);
747         gtk_label_set_text(GTK_LABEL(top_label), label_text);
748 }
749
750 /****************************************************************************/
751 /* Create list view */
752 static void
753 create_list_view(void)
754 {
755         GtkTreeViewColumn *column;
756         GtkCellRenderer   *renderer;
757         GtkTreeSortable   *sortable;
758         GtkTreeView       *list_view;
759         GtkTreeSelection  *selection;
760
761         /* Create the store */
762         list_store = gtk_list_store_new(NUM_COLS,       /* Total number of columns */
763                                         G_TYPE_STRING,  /* Source address */
764                                         G_TYPE_UINT,    /* Source port */
765                                         G_TYPE_STRING,  /* Destination address */
766                                         G_TYPE_UINT,    /* Destination port */
767                                         G_TYPE_STRING,  /* SSRC */
768                                         G_TYPE_STRING,  /* Payload */
769                                         G_TYPE_UINT,    /* Packets */
770                                         G_TYPE_STRING,  /* Lost */
771                                         G_TYPE_STRING,  /* Max. delta */
772                                         G_TYPE_STRING,  /* Max. jitter */
773                                         G_TYPE_STRING,  /* Mean jitter */
774                                         G_TYPE_STRING,  /* Problem */
775                                         G_TYPE_POINTER  /* Data */
776                                        );
777
778         /* Create a view */
779         list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(list_store));
780
781         list_view = GTK_TREE_VIEW(list);
782         sortable = GTK_TREE_SORTABLE(list_store);
783
784         /* Speed up the list display */
785         gtk_tree_view_set_fixed_height_mode(list_view, TRUE);
786
787         /* Setup the sortable columns */
788         gtk_tree_sortable_set_sort_column_id(sortable, RTP_COL_SRC_ADDR, GTK_SORT_ASCENDING);
789         gtk_tree_view_set_headers_clickable(list_view, FALSE);
790
791         /* The view now holds a reference.  We can get rid of our own reference */
792         g_object_unref(G_OBJECT(list_store));
793
794         /*
795          * Create the first column packet, associating the "text" attribute of the
796          * cell_renderer to the first column of the model
797          */
798         renderer = gtk_cell_renderer_text_new();
799         column = gtk_tree_view_column_new_with_attributes("Src IP addr", renderer,
800                 "text", RTP_COL_SRC_ADDR,
801                 NULL);
802         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_SRC_ADDR);
803         gtk_tree_view_column_set_resizable(column, TRUE);
804         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
805         gtk_tree_view_column_set_min_width(column, 60);
806         gtk_tree_view_column_set_fixed_width(column, 100);
807         /* Add the column to the view. */
808         gtk_tree_view_append_column(list_view, column);
809
810         /* Source port */
811         renderer = gtk_cell_renderer_text_new();
812         column = gtk_tree_view_column_new_with_attributes("Src port", renderer,
813                 "text", RTP_COL_SRC_PORT,
814                 NULL);
815         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_SRC_PORT);
816         gtk_tree_view_column_set_resizable(column, TRUE);
817         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
818         gtk_tree_view_column_set_min_width(column, 60);
819         gtk_tree_view_column_set_fixed_width(column, 80);
820         gtk_tree_view_append_column(list_view, column);
821
822         /* Destination address */
823         renderer = gtk_cell_renderer_text_new();
824         column = gtk_tree_view_column_new_with_attributes("Dst IP addr", renderer,
825                 "text", RTP_COL_DST_ADDR,
826                 NULL);
827         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_DST_ADDR);
828         gtk_tree_view_column_set_resizable(column, TRUE);
829         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
830         gtk_tree_view_column_set_min_width(column, 60);
831         gtk_tree_view_column_set_fixed_width(column, 100);
832         gtk_tree_view_append_column(list_view, column);
833
834         /* Destination port */
835         renderer = gtk_cell_renderer_text_new();
836         column = gtk_tree_view_column_new_with_attributes("Dst port", renderer,
837                 "text", RTP_COL_DST_PORT,
838                 NULL);
839         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_DST_PORT);
840         gtk_tree_view_column_set_resizable(column, TRUE);
841         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
842         gtk_tree_view_column_set_min_width(column, 60);
843         gtk_tree_view_column_set_fixed_width(column, 80);
844         gtk_tree_view_append_column(list_view, column);
845
846         /* SSRC */
847         renderer = gtk_cell_renderer_text_new();
848         column = gtk_tree_view_column_new_with_attributes("SSRC", renderer,
849                 "text", RTP_COL_SSRC,
850                 NULL);
851         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_SSRC);
852         gtk_tree_view_column_set_resizable(column, TRUE);
853         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
854         gtk_tree_view_column_set_min_width(column, 70);
855         gtk_tree_view_column_set_fixed_width(column, 90);
856         gtk_tree_view_append_column(list_view, column);
857
858         /* Payload */
859         renderer = gtk_cell_renderer_text_new();
860         column = gtk_tree_view_column_new_with_attributes("Payload", renderer,
861                 "text", RTP_COL_PAYLOAD,
862                 NULL);
863         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_PAYLOAD);
864         gtk_tree_view_column_set_resizable(column, TRUE);
865         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
866         gtk_tree_view_column_set_min_width(column, 80);
867         gtk_tree_view_column_set_fixed_width(column, 100);
868         gtk_tree_view_append_column(list_view, column);
869
870         /* Packets */
871         renderer = gtk_cell_renderer_text_new();
872         column = gtk_tree_view_column_new_with_attributes("Packets", renderer,
873                 "text", RTP_COL_PACKETS,
874                 NULL);
875         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_PACKETS);
876         gtk_tree_view_column_set_resizable(column, TRUE);
877         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
878         gtk_tree_view_column_set_min_width(column, 60);
879         gtk_tree_view_column_set_fixed_width(column, 70);
880         gtk_tree_view_append_column(list_view, column);
881
882         /* Lost */
883         renderer = gtk_cell_renderer_text_new();
884         column = gtk_tree_view_column_new_with_attributes("Lost", renderer,
885                 "text", RTP_COL_LOST,
886                 NULL);
887         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_LOST);
888         gtk_tree_view_column_set_resizable(column, TRUE);
889         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
890         gtk_tree_view_column_set_min_width(column, 60);
891         gtk_tree_view_column_set_fixed_width(column, 90);
892         gtk_tree_view_append_column(list_view, column);
893
894         /* Max Delta (ms) */
895         renderer = gtk_cell_renderer_text_new();
896         column = gtk_tree_view_column_new_with_attributes("Max Delta (ms)", renderer,
897                 "text", RTP_COL_MAX_DELTA,
898                 NULL);
899         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_MAX_DELTA);
900         gtk_tree_view_column_set_resizable(column, TRUE);
901         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
902         gtk_tree_view_column_set_min_width(column, 90);
903         gtk_tree_view_column_set_fixed_width(column, 130);
904         gtk_tree_view_append_column(list_view, column);
905
906         /* Max Jitter (ms) */
907         renderer = gtk_cell_renderer_text_new();
908         column = gtk_tree_view_column_new_with_attributes("Max Jitter (ms)", renderer,
909                 "text", RTP_COL_MAX_JITTER,
910                 NULL);
911         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_MAX_JITTER);
912         gtk_tree_view_column_set_resizable(column, TRUE);
913         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
914         gtk_tree_view_column_set_min_width(column, 50);
915         gtk_tree_view_column_set_fixed_width(column, 120);
916         gtk_tree_view_append_column(list_view, column);
917
918         /* Mean Jitter (ms) */
919         renderer = gtk_cell_renderer_text_new();
920         column = gtk_tree_view_column_new_with_attributes("Mean Jitter (ms)", renderer,
921                 "text", RTP_COL_MEAN_JITTER,
922                 NULL);
923         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_MEAN_JITTER);
924         gtk_tree_view_column_set_resizable(column, TRUE);
925         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
926         gtk_tree_view_column_set_min_width(column, 50);
927         gtk_tree_view_column_set_fixed_width(column, 130);
928         gtk_tree_view_append_column(list_view, column);
929
930         /* Problems? */
931         renderer = gtk_cell_renderer_text_new();
932         column = gtk_tree_view_column_new_with_attributes("Pb?", renderer,
933                 "text", RTP_COL_PROBLEM,
934                 NULL);
935         gtk_tree_view_column_set_sort_column_id(column, RTP_COL_PROBLEM);
936         gtk_tree_view_column_set_resizable(column, TRUE);
937         gtk_tree_view_column_set_sizing(column, GTK_TREE_VIEW_COLUMN_FIXED);
938         gtk_tree_view_column_set_min_width(column, 30);
939         gtk_tree_view_column_set_fixed_width(column, 50);
940         gtk_tree_view_append_column(list_view, column);
941
942         /* Now enable the sorting of each column */
943         gtk_tree_view_set_rules_hint(list_view, TRUE);
944         gtk_tree_view_set_headers_clickable(list_view, TRUE);
945
946         /* Setup the selection handler */
947         selection = gtk_tree_view_get_selection(list_view);
948
949         gtk_tree_selection_set_mode(selection, GTK_SELECTION_MULTIPLE);
950         gtk_tree_selection_set_select_function(selection, rtpstream_view_selection_func, NULL, NULL);
951 }
952
953
954 /****************************************************************************/
955 /* Create dialog */
956 static void
957 rtpstream_dlg_create (void)
958 {
959     GtkWidget *rtpstream_dlg_w;
960     GtkWidget *main_vb;
961     GtkWidget *scrolledwindow;
962     GtkWidget *hbuttonbox;
963 /*    GtkWidget *bt_goto;*/
964     GtkWidget *bt_unselect;
965     GtkWidget *bt_findrev;
966     GtkWidget *bt_save;
967     GtkWidget *bt_mark;
968     GtkWidget *bt_filter;
969     GtkWidget *bt_analyze;
970     GtkWidget *bt_close;
971     GtkWidget *bt_copy;
972
973     rtpstream_dlg_w = dlg_window_new("Wireshark: RTP Streams");
974     gtk_window_set_default_size(GTK_WINDOW(rtpstream_dlg_w), 620, 400);
975
976     main_vb = gtk_vbox_new (FALSE, 0);
977     gtk_container_add(GTK_CONTAINER(rtpstream_dlg_w), main_vb);
978     gtk_container_set_border_width (GTK_CONTAINER (main_vb), 12);
979
980     top_label = gtk_label_new ("Detected 0 RTP streams. Choose one for forward and reverse direction for analysis");
981     gtk_box_pack_start (GTK_BOX (main_vb), top_label, FALSE, FALSE, 8);
982
983     scrolledwindow = scrolled_window_new (NULL, NULL);
984     gtk_box_pack_start (GTK_BOX (main_vb), scrolledwindow, TRUE, TRUE, 0);
985
986     create_list_view();
987     gtk_container_add(GTK_CONTAINER(scrolledwindow), list);
988
989     gtk_widget_show(rtpstream_dlg_w);
990
991     label_fwd = gtk_label_new (FWD_LABEL_TEXT);
992     gtk_box_pack_start (GTK_BOX (main_vb), label_fwd, FALSE, FALSE, 0);
993
994     label_rev = gtk_label_new (REV_LABEL_TEXT);
995     gtk_box_pack_start (GTK_BOX (main_vb), label_rev, FALSE, FALSE, 0);
996
997     /* button row */
998     hbuttonbox = gtk_hbutton_box_new ();
999     gtk_box_pack_start (GTK_BOX (main_vb), hbuttonbox, FALSE, FALSE, 0);
1000     gtk_button_box_set_layout (GTK_BUTTON_BOX (hbuttonbox), GTK_BUTTONBOX_END);
1001     gtk_box_set_spacing (GTK_BOX (hbuttonbox), 0);
1002
1003     bt_unselect = gtk_button_new_with_label ("Unselect");
1004     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_unselect);
1005     gtk_widget_set_tooltip_text (bt_unselect, "Undo stream selection");
1006
1007     bt_findrev = gtk_button_new_with_label ("Find Reverse");
1008     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_findrev);
1009     gtk_widget_set_tooltip_text (bt_findrev, "Find the reverse stream matching the selected forward stream");
1010 /*
1011     bt_goto = gtk_button_new_from_stock(GTK_STOCK_JUMP_TO);
1012     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_goto);
1013 */
1014     bt_save = gtk_button_new_from_stock(GTK_STOCK_SAVE_AS);
1015     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_save);
1016     gtk_widget_set_tooltip_text (bt_save, "Save stream payload in rtpdump format");
1017
1018     bt_mark = gtk_button_new_with_label ("Mark Packets");
1019     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_mark);
1020     gtk_widget_set_tooltip_text (bt_mark, "Mark packets of the selected stream(s)");
1021
1022     bt_filter = gtk_button_new_from_stock(WIRESHARK_STOCK_PREPARE_FILTER);
1023     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_filter);
1024     gtk_widget_set_tooltip_text (bt_filter, "Prepare a display filter of the selected stream(s)");
1025
1026     /* XXX - maybe we want to have a "Copy as CSV" stock button here? */
1027     /*bt_copy = gtk_button_new_with_label ("Copy content to clipboard as CSV");*/
1028     bt_copy = gtk_button_new_from_stock(GTK_STOCK_COPY);
1029     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_copy);
1030     gtk_widget_set_tooltip_text(bt_copy,
1031         "Copy all statistical values of this page to the clipboard in CSV (Comma Separated Values) format.");
1032
1033     bt_analyze = gtk_button_new_from_stock(WIRESHARK_STOCK_ANALYZE);
1034     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_analyze);
1035     gtk_widget_set_tooltip_text (bt_analyze, "Open an analyze window of the selected stream(s)");
1036
1037     bt_close = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
1038     gtk_container_add (GTK_CONTAINER (hbuttonbox), bt_close);
1039     gtk_widget_set_tooltip_text (bt_close, "Close this dialog");
1040 #if GTK_CHECK_VERSION(2,18,0)
1041     gtk_widget_set_can_default(bt_close, TRUE);
1042 #else
1043     GTK_WIDGET_SET_FLAGS(bt_close, GTK_CAN_DEFAULT);
1044 #endif
1045
1046     g_signal_connect(bt_unselect, "clicked", G_CALLBACK(rtpstream_on_unselect), NULL);
1047     g_signal_connect(bt_findrev, "clicked", G_CALLBACK(rtpstream_on_findrev), NULL);
1048 /*
1049     g_signal_connect(bt_goto, "clicked", G_CALLBACK(rtpstream_on_goto), NULL);
1050 */
1051     g_signal_connect(bt_save, "clicked", G_CALLBACK(rtpstream_on_save), NULL);
1052     g_signal_connect(bt_mark, "clicked", G_CALLBACK(rtpstream_on_mark), NULL);
1053     g_signal_connect(bt_filter, "clicked", G_CALLBACK(rtpstream_on_filter), NULL);
1054     g_signal_connect(bt_copy, "clicked", G_CALLBACK(rtpstream_on_copy_as_csv), NULL);
1055     g_signal_connect(bt_analyze, "clicked", G_CALLBACK(rtpstream_on_analyse), NULL);
1056
1057     window_set_cancel_button(rtpstream_dlg_w, bt_close, window_cancel_button_cb);
1058
1059     g_signal_connect(rtpstream_dlg_w, "delete_event", G_CALLBACK(window_delete_event_cb), NULL);
1060     g_signal_connect(rtpstream_dlg_w, "destroy", G_CALLBACK(rtpstream_on_destroy), NULL);
1061
1062     gtk_widget_show_all(rtpstream_dlg_w);
1063     window_present(rtpstream_dlg_w);
1064
1065     rtpstream_on_unselect(NULL, NULL);
1066
1067     rtp_stream_dlg = rtpstream_dlg_w;
1068 }
1069
1070
1071 /****************************************************************************/
1072 /* PUBLIC                                                                   */
1073 /****************************************************************************/
1074
1075 /****************************************************************************/
1076 /* update the contents of the dialog box list_store */
1077 /* list: pointer to list of rtp_stream_info_t* */
1078 void rtpstream_dlg_update(GList *list_lcl)
1079 {
1080         if (rtp_stream_dlg != NULL) {
1081                 gtk_list_store_clear(list_store);
1082                 streams_nb = 0;
1083
1084                 list_lcl = g_list_first(list_lcl);
1085                 while (list_lcl)
1086                 {
1087                         add_to_list_store((rtp_stream_info_t*)(list_lcl->data));
1088                         list_lcl = g_list_next(list_lcl);
1089                 }
1090
1091                 rtpstream_on_unselect(NULL, NULL);
1092         }
1093
1094         last_list = list_lcl;
1095 }
1096
1097
1098 /****************************************************************************/
1099 /* update the contents of the dialog box list_store */
1100 /* list: pointer to list of rtp_stream_info_t* */
1101 void rtpstream_dlg_show(GList *list_lcl)
1102 {
1103         if (rtp_stream_dlg != NULL) {
1104                 /* There's already a dialog box; reactivate it. */
1105                 reactivate_window(rtp_stream_dlg);
1106                 /* Another list since last call? */
1107                 if (list_lcl != last_list) {
1108                         rtpstream_dlg_update(list_lcl);
1109                 }
1110         }
1111         else {
1112                 /* Create and show the dialog box */
1113                 rtpstream_dlg_create();
1114                 rtpstream_dlg_update(list_lcl);
1115         }
1116 }
1117
1118
1119 /****************************************************************************/
1120 /* entry point when called via the GTK menu */
1121 void rtpstream_launch(GtkAction *action _U_, gpointer user_data _U_)
1122 {
1123         /* Register the tap listener */
1124         register_tap_listener_rtp_stream();
1125
1126         /* Scan for RTP streams (redissect all packets) */
1127         rtpstream_scan();
1128
1129         /* Show the dialog box with the list of streams */
1130         rtpstream_dlg_show(rtpstream_get_info()->strinfo_list);
1131
1132         /* Tap listener will be removed and cleaned up in rtpstream_on_destroy */
1133 }
1134
1135 /****************************************************************************/
1136 void
1137 register_tap_listener_rtp_stream_dlg(void)
1138 {
1139 }
1140