Wireshark-dev: Re: [Wireshark-dev] Play media streams in real time
From: Miguel Angel Cabrera Moya <madmac2501@xxxxxxxxx>
Date: Sun, 23 May 2010 21:08:33 +0200
I received an email asking about the state of what i proposed a few months ago and here is a patch. Actually i did very few work, just integrating GStreamer in wireshark build process and very little coding, but it is better than nothing. At the moment this is stopped as i have enough coding in my life because of my full time job. On Sun, Aug 9, 2009 at 7:43 PM, Miguel Angel Cabrera Moya <madmac2501@xxxxxxxxx> wrote: > I have researched and there are no legal issues in using a LGPLv2 > library (GStreamer) with a GPLv2 application (Wireshark). > > On Sun, Aug 9, 2009 at 7:25 PM, Stephen Fisher<steve@xxxxxxxxxxxxxxxxxx> wrote: >> >> On Aug 9, 2009, at 5:28 AM, Abhik Sarkar wrote: >> >>> - WS is distributed under GPL, and Gstreamer seems to be LGPL. I am >>> not a 100% sure, but as far as I know, the two aren't compatible. >>> >> >> That is always a good thing to verify. It looks like it is compatible >> with GPLv2 and GPLv3: >> >> http://www.gnu.org/philosophy/license-list.html#LGPLv2.1 >> http://www.gnu.org/philosophy/license-list.html#LGPL >> >> >> Steve >> >> ___________________________________________________________________________ >> Sent via: Wireshark-dev mailing list <wireshark-dev@xxxxxxxxxxxxx> >> Archives: http://www.wireshark.org/lists/wireshark-dev >> Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev >> mailto:wireshark-dev-request@xxxxxxxxxxxxx?subject=unsubscribe >> >
Index: configure.in =================================================================== --- configure.in (revision 30846) +++ configure.in (working copy) @@ -1168,7 +1168,82 @@ fi AM_CONDITIONAL(HAVE_LIBPORTAUDIO, test x$want_portaudio = xyes) +dnl libxml2 check +AC_MSG_CHECKING(whether to use libxml2 for gstreamer for the media_player) +AC_ARG_WITH(xml2, + AC_HELP_STRING( [--with-xml2@<:@=DIR@:>@], + [use libxml2 (located in directory DIR, if supplied) for gstreamer for the media_player. @<:@default=yes, if available@:>@]), +[ + if test $withval = no + then + want_xml2=no + elif test $withval = yes + then + want_xml2=yes + else + want_xml2=yes + xml2_dir=$withval + fi +],[ + # + # Use libxml2 by default + # + want_xml2=ifavailable + xml2_dir= +]) +if test "x$want_xml2" = "xno" ; then + AC_MSG_RESULT(no) +else + AC_MSG_RESULT(yes) + AC_WIRESHARK_LIBXML2_CHECK + if test "x$want_xml2" = "xno" ; then + AC_MSG_RESULT(libxml2 not found - disabling support for gstreamer for the media_player) + fi +fi +AM_CONDITIONAL(HAVE_LIBXML2, test x$want_xml2 = xyes) + +dnl libgstreamer-plugins-base check + +dnl libgstreamer check +AC_MSG_CHECKING(whether to use libgstreamer for the media_player) + +AC_ARG_WITH(gstreamer, + AC_HELP_STRING( [--with-gstreamer@<:@=DIR@:>@], + [use libgstreamer (located in directory DIR, if supplied) for the media_player. @<:@default=yes, if available@:>@]), +[ + if test $withval = no + then + want_gstreamer=no + elif test $withval = yes + then + want_gstreamer=yes + else + want_gstreamer=yes + gstreamer_dir=$withval + fi +],[ + # + # Use gstreamer by default + # + want_gstreamer=ifavailable + gstreamer_dir= +]) +if test "x$want_gstreamer" = "xno" ; then + AC_MSG_RESULT(no) +else + if test "x$want_xml2" = "xno" ; then + AC_MSG_RESULT(libxml2 is necessary for libgstreamer - disabling support for the media_player) + else + AC_MSG_RESULT(yes) + AC_WIRESHARK_LIBGSTREAMER_CHECK + if test "x$want_gstreamer" = "xno" ; then + AC_MSG_RESULT(libgstreamer not found - disabling support for the media_player) + fi + fi +fi +AM_CONDITIONAL(HAVE_LIBGSTREAMER, test x$want_gstreamer = xyes) + dnl ipv6 check AC_ARG_ENABLE(ipv6, AC_HELP_STRING( [--enable-ipv6], @@ -1817,6 +1892,12 @@ portaudio_message="no" fi +if test "x$want_gstreamer" = "xyes" ; then + gstreamer_message="yes" +else + gstreamer_message="no" +fi + if test "x$want_ssl" = "xno" ; then ssl_message="no" else @@ -1872,6 +1953,7 @@ echo " Use lua library : $lua_message" echo " Use python binding : $python_message" echo " Build rtp_player : $portaudio_message" +echo " Build media_player : $gstreamer_message" echo " Use threads : $enable_threads" echo " Build profile binaries : $enable_profile_build" echo " Use pcap library : $want_pcap" Index: acinclude.m4 =================================================================== --- acinclude.m4 (revision 30846) +++ acinclude.m4 (working copy) @@ -1228,6 +1228,413 @@ ]) # +# AC_WIRESHARK_LIBXML2_CHECK +# +AC_DEFUN([AC_WIRESHARK_LIBXML2_CHECK],[ + + if test "x$xml2_dir" != "x" + then + # + # The user specified a directory in which libxml2 + # resides, so add the "include" subdirectory of that directory to + # the include file search path and the "lib" subdirectory + # of that directory to the library search path. + # + # XXX - if there's also a libxml2 in a directory that's + # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't + # make us find the version in the specified directory, + # as the compiler and/or linker will search that other + # directory before it searches the specified directory. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I$xml2_dir/include/libxml2" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$xml2_dir/include/libxml2" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -L$xml2_dir/lib -lxml2" + wireshark_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$xml2_dir/lib" + else + # + # The user specified no directory in which libxml2 resides, + # so just add "-lxml2" to the used libs. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I/usr/include/libxml2" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I/usr/include/libxml2" + wireshark_save_LDFLAGS="$LDFLAGS" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -lxml2" + fi + + # + # Make sure we have "libxml/parser.h". If we don't, it means we probably + # don't have libxml2, so don't use it. + # + AC_CHECK_HEADERS(libxml/parser.h,, + [ + if test "x$xml2_dir" != "x" + then + # + # The user used "--with-xml2=" to specify a directory + # containing libxml2, but we didn't find the header file + # there; that either means they didn't specify the + # right directory or are confused about whether libxml2 + # is, in fact, installed. Report the error and give up. + # + AC_MSG_ERROR([libxml2 header not found in directory specified in --with-xml2]) + else + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + if test "x$want_xml2" = "xyes" + then + # + # The user tried to force us to use the library, but we + # couldn't find the header file; report an error. + # + AC_MSG_ERROR(Header file libxml/parser.h not found.) + else + # + # We couldn't find the header file; don't use the + # library, as it's probably not present. + # + want_xml2=no + fi + fi + ]) + + if test "x$want_xml2" != "xno" + then + # + # Well, we at least have the libxml2 header file. + # + # let's check if the libs are there + # + + AC_CHECK_LIB(xml2, xmlNewParserCtxt, + [ + if test "x$xml2_dir" != "x" + then + # + # Put the "-I" and "-L" flags for libxml2 at + # the beginning of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS. + # + XML2_LIBS="-L$xml2_dir/lib -lxml2" + XML2_INCLUDES="-I$xml2_dir/include/libxml2" + else + XML2_LIBS="-lxml2" + XML2_INCLUDES="-I/usr/include/libxml2" + fi + AC_DEFINE(HAVE_LIBXML2, 1, [Define to use libxml2 library]) + want_xml2=yes + ],[ + # + # Restore the versions of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS before we added the + # "--with-xml2=" directory, as we didn't + # actually find libxml2 there. + # + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + XML2_LIBS="" + XML2_INCLUDES="" + # User requested --with-xml2 but it isn't available + if test "x$want_xml2" = "xyes" + then + AC_MSG_ERROR(Linking with libxml2 failed.) + fi + want_xml2=no + ]) + + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + AC_SUBST(XML2_LIBS) + AC_SUBST(XML2_INCLUDES) + + fi +]) + +# +# AC_WIRESHARK_LIBGSTREAMER_CHECK +# +AC_DEFUN([AC_WIRESHARK_LIBGSTREAMER_CHECK],[ + + if test "x$gstreamer_dir" != "x" + then + # + # The user specified a directory in which libgstreamer + # resides, so add the "include" subdirectory of that directory to + # the include file search path and the "lib" subdirectory + # of that directory to the library search path. + # + # XXX - if there's also a libgstreamer in a directory that's + # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't + # make us find the version in the specified directory, + # as the compiler and/or linker will search that other + # directory before it searches the specified directory. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I$gstreamer_dir/include/gstreamer-0.10 $XML2_INCLUDES" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$gstreamer_dir/include/gstreamer-0.10 $XML2_INCLUDES $GLIB_CFLAGS" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -lgstreamer-0.10 $XML2_LIBS $GLIB_LIBS" + wireshark_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$gstreamer_dir/lib" + else + # + # The user specified no directory in which libgstreamer resides, + # so just add libgstreamer include directory and "-lgstreamer-0.10" + # to the used libs. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I/usr/include/gstreamer-0.10 $XML2_INCLUDES" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I/usr/include/gstreamer-0.10 $XML2_INCLUDES $GLIB_CFLAGS" + wireshark_save_LDFLAGS="$LDFLAGS" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -lgstreamer-0.10 $XML2_LIBS $GLIB_LIBS" + fi + + # + # Make sure we have "gst/gst.h". If we don't, it means we probably + # don't have gstreamer, so don't use it. + # + AC_CHECK_HEADERS(gst/gst.h,, + [ + if test "x$gstreamer_dir" != "x" + then + # + # The user used "--with-gstreamer=" to specify a directory + # containing libgstreamer, but we didn't find the header file + # there; that either means they didn't specify the + # right directory or are confused about whether libgstreamer + # is, in fact, installed. Report the error and give up. + # + AC_MSG_ERROR([libgstreamer header not found in directory specified in --with-gstreamer]) + else + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + if test "x$want_gstreamer" = "xyes" + then + # + # The user tried to force us to use the library, but we + # couldn't find the header file; report an error. + # + AC_MSG_ERROR(Header file gst/gst.h not found.) + else + # + # We couldn't find the header file; don't use the + # library, as it's probably not present. + # + want_gstreamer=no + fi + fi + ]) + + if test "x$want_gstreamer" != "xno" + then + # + # Well, we at least have the libgstreamer header file. + # + # let's check if the libs are there + # + + AC_CHECK_LIB(gstreamer-0.10, gst_init, + [ + if test "x$gstreamer_dir" != "x" + then + # + # Put the "-I" and "-L" flags for libgstreamer at + # the beginning of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS. + # + GSTREAMER_LIBS="-L$gstreamer_dir/lib -lgstreamer-0.10" + GSTREAMER_INCLUDES="-I$gstreamer_dir/include/gstreamer-0.10" + else + GSTREAMER_LIBS="-lgstreamer-0.10" + GSTREAMER_INCLUDES="-I/usr/include/gstreamer-0.10" + fi + AC_DEFINE(HAVE_LIBGSTREAMER, 1, [Define to use libgstreamer library]) + want_gstreamer=yes + ],[ + # + # Restore the versions of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS before we added the + # "--with-gstreamer=" directory, as we didn't + # actually find gstreamer there. + # + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + GSTREAMER_LIBS="" + GSTREAMER_INCLUDES="" + # User requested --with-gstreamer but it isn't available + if test "x$want_gstreamer" = "xyes" + then + AC_MSG_ERROR(Linking with libgstreamer failed.) + fi + want_gstreamer=no + ]) + + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + AC_SUBST(GSTREAMER_LIBS) + AC_SUBST(GSTREAMER_INCLUDES) + + fi +]) + +# +## AC_WIRESHARK_LIBGSTREAMER_PLUGINS_BASE_CHECK +# +AC_DEFUN([AC_WIRESHARK_LIBGSTREAMER_PLUGINS_BASE_CHECK],[ + + if test "x$gstreamer_plugins_base_dir" != "x" + then + # + # The user specified a directory in which libgstreamer-plugins-base + # resides, so add the "include" subdirectory of that directory to + # the include file search path and the "lib" subdirectory + # of that directory to the library search path. + # + # XXX - if there's also a libgstreamer-plugins-base in a directory that's + # already in CFLAGS, CPPFLAGS, or LDFLAGS, this won't + # make us find the version in the specified directory, + # as the compiler and/or linker will search that other + # directory before it searches the specified directory. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I$gstreamer_plugins_base_dir/include/gstreamer-0.10 $GSTREAMER_INCLUDES $XML2_INCLUDES" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I$gstreamer_plugins_base_dir/include/gstreamer-0.10 $GSTREAMER_INCLUDES $XML2_INCLUDES $GLIB_CFLAGS" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -lgstbase-0.10 $GSTREAMER_LIBS $XML2_LIBS $GLIB_LIBS" + wireshark_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$gstreamer_plugins_base_dir/lib" + else + # + # The user specified no directory in which libgstreamer resides, + # so just add libgstreamer-plugins-base include directory and "-lgstbase-0.10" + # to the used libs. + # + wireshark_save_CFLAGS="$CFLAGS" + CFLAGS="$CFLAGS -I/usr/include/gstreamer-0.10 $XML2_INCLUDES" + wireshark_save_CPPFLAGS="$CPPFLAGS" + CPPFLAGS="$CPPFLAGS -I/usr/include/gstreamer-0.10 $XML2_INCLUDES $GLIB_CFLAGS" + wireshark_save_LDFLAGS="$LDFLAGS" + wireshark_save_LIBS="$LIBS" + LIBS="$LIBS -lgstbase-0.10 $GSTREAMER_LIBS $XML2_LIBS $GLIB_LIBS" + fi + + # + # Make sure we have "gst/base/gstbasesrc.h". If we don't, it means we probably + # don't have gstreamer plugins base, so don't use it. + # + AC_CHECK_HEADERS(gst/base/gstbasesrc.h,, + [ + if test "x$gstreamer_dir" != "x" + then + # + # The user used "--with-gstreamer=" to specify a directory + # containing libgstreamer, but we didn't find the header file + # there; that either means they didn't specify the + # right directory or are confused about whether libgstreamer + # is, in fact, installed. Report the error and give up. + # + AC_MSG_ERROR([libgstreamer header not found in directory specified in --with-gstreamer]) + else + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + if test "x$want_gstreamer" = "xyes" + then + # + # The user tried to force us to use the library, but we + # couldn't find the header file; report an error. + # + AC_MSG_ERROR(Header file gst/gst.h not found.) + else + # + # We couldn't find the header file; don't use the + # library, as it's probably not present. + # + want_gstreamer=no + fi + fi + ]) + + if test "x$want_gstreamer" != "xno" + then + # + # Well, we at least have the libgstreamer header file. + # + # let's check if the libs are there + # + + AC_CHECK_LIB(gstbase-0.10, gst_base_src_set_live, + [ + if test "x$gstreamer_dir" != "x" + then + # + # Put the "-I" and "-L" flags for libgstreamer at + # the beginning of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS. + # + GSTREAMER_LIBS="-L$gstreamer_dir/lib -lgstreamer-0.10" + GSTREAMER_INCLUDES="-I$gstreamer_dir/include/gstreamer-0.10" + else + GSTREAMER_LIBS="-lgstreamer-0.10" + GSTREAMER_INCLUDES="-I/usr/include/gstreamer-0.10" + fi + AC_DEFINE(HAVE_LIBGSTREAMER, 1, [Define to use libgstreamer library]) + want_gstreamer=yes + ],[ + # + # Restore the versions of CFLAGS, CPPFLAGS, + # LDFLAGS, and LIBS before we added the + # "--with-gstreamer=" directory, as we didn't + # actually find gstreamer there. + # + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + GSTREAMER_LIBS="" + GSTREAMER_INCLUDES="" + # User requested --with-gstreamer but it isn't available + if test "x$want_gstreamer" = "xyes" + then + AC_MSG_ERROR(Linking with libgstreamer failed.) + fi + want_gstreamer=no + ]) + + CFLAGS="$wireshark_save_CFLAGS" + CPPFLAGS="$wireshark_save_CPPFLAGS" + LDFLAGS="$wireshark_save_LDFLAGS" + LIBS="$wireshark_save_LIBS" + AC_SUBST(GSTREAMER_LIBS) + AC_SUBST(GSTREAMER_INCLUDES) + + fi +]) + +# # AC_WIRESHARK_RPM_CHECK # Looks for the rpm program, and checks to see if we can redefine "_topdir". # Index: Makefile.am =================================================================== --- Makefile.am (revision 30846) +++ Makefile.am (working copy) @@ -338,7 +338,9 @@ @LIBGCRYPT_LIBS@ \ @LIBGNUTLS_LIBS@ \ @LIBSMI_LDFLAGS@ \ - @PORTAUDIO_LIBS@ + @PORTAUDIO_LIBS@ \ + @XML2_LIBS@ \ + @GSTREAMER_LIBS@ wireshark_CFLAGS = $(AM_CLEAN_CFLAGS) $(py_dissectors_dir) if ENABLE_STATIC Index: gtk/media_player_dlg.c =================================================================== --- gtk/media_player_dlg.c (revision 0) +++ gtk/media_player_dlg.c (revision 0) @@ -0,0 +1,122 @@ +#ifdef HAVE_CONFIG_H +# include <config.h> +#endif + +#include <gtk/gtk.h> + +#include <epan/epan.h> + +#include "media_player.h" +#include "../globals.h" +#include "../simple_dialog.h" +#include "../stat_menu.h" + +#include "gtk/dlg_utils.h" +#include "gtk/gui_stat_menu.h" +#include "gtk/gui_utils.h" + +/****************************************************************************/ +/* pointer to the one and only dialog window */ +static GtkWidget *media_player_dlg = NULL; + +/* Display constants */ +#define VIEW_MEDIA_PLAYER_WIDTH 400 +#define VIEW_MEDIA_PLAYER_HEIGHT 50 +#define VIEW_BORDER_SIZE 2 +#define VIEW_STREAM_WIDTH 500 + + +/****************************************************************************/ +static void +media_player_on_destroy(GtkObject *object _U_, gpointer user_data _U_) +{ + //media_player_stop(); + + gtk_widget_destroy(media_player_dlg); + media_player_dlg = NULL; +} + +/****************************************************************************/ +static void +media_player_dlg_create(void) +{ + const gchar *title_name_ptr; + gchar *window_name; + GtkWidget *main_vb; + GtkWidget *streams_scrolled_window; + GtkWidget *streams_vb; + + title_name_ptr = cf_get_display_name(&cfile); + window_name = g_strdup_printf("%s - Media Player", title_name_ptr); + + media_player_dlg = dlg_window_new(window_name); + gtk_window_set_destroy_with_parent(GTK_WINDOW(media_player_dlg), TRUE); + gtk_window_set_position(GTK_WINDOW(media_player_dlg), GTK_WIN_POS_NONE); + gtk_window_set_default_size(GTK_WINDOW(media_player_dlg), VIEW_MEDIA_PLAYER_WIDTH, VIEW_MEDIA_PLAYER_HEIGHT); + g_signal_connect(media_player_dlg, "delete_event", G_CALLBACK(window_delete_event_cb), NULL); + g_signal_connect(media_player_dlg, "destroy", G_CALLBACK(media_player_on_destroy), NULL); + g_free(window_name); + + main_vb = gtk_vbox_new(TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(main_vb), VIEW_BORDER_SIZE); + gtk_container_add(GTK_CONTAINER(media_player_dlg), main_vb); + + streams_scrolled_window = gtk_scrolled_window_new(NULL, NULL); + gtk_container_set_border_width(GTK_CONTAINER(streams_scrolled_window), VIEW_BORDER_SIZE); + gtk_widget_set_size_request(streams_scrolled_window, VIEW_STREAM_WIDTH, 0); + gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(streams_scrolled_window), GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); + gtk_container_add(GTK_CONTAINER(main_vb), streams_scrolled_window); + + streams_vb = gtk_vbox_new(TRUE, 0); + gtk_container_set_border_width(GTK_CONTAINER(streams_vb), VIEW_BORDER_SIZE); + gtk_scrolled_window_add_with_viewport((GtkScrolledWindow *) streams_scrolled_window, streams_vb); + +/*TODO: meter mas cosas */ + gtk_widget_show_all(media_player_dlg); + + /* Force gtk to redraw the window before start playing */ + while (g_main_context_iteration(NULL, FALSE)); +} + +/****************************************************************************/ +/* TODO */ +/* aqui es donde se hace el procesamiento gordo de cada paquete */ +void +media_player_draw_cb(void *tapdata _U_) +{ + //media_player_state_t *media_player_state = tapdata; +} + +/****************************************************************************/ +/* entry point when called via the GTK menu */ +static void +media_player_launch(GtkWidget *w _U_, gpointer data _U_) +{ + if (media_player_dlg == NULL) { + /* Init media player and create dialog box if it is necessary */ + GString *err_string; + + err_string = media_player_init(); + + if (err_string != NULL) + { + simple_dialog(ESD_TYPE_ERROR, ESD_BTN_OK, + "%s", err_string->str); + g_string_free(err_string, TRUE); + exit(1); + } + + media_player_dlg_create(); + } else { + /* There's already a dialog box; reactivate it. */ + reactivate_window(media_player_dlg); + } +} + +/****************************************************************************/ +void +register_tap_listener_media_player_dlg(void) +{ + register_stat_menu_item("_Media Player", REGISTER_TOOLS_GROUP_UNSORTED, + media_player_launch, NULL, NULL, NULL); +} Index: gtk/media_player_dlg.h =================================================================== --- gtk/media_player_dlg.h (revision 0) +++ gtk/media_player_dlg.h (revision 0) @@ -0,0 +1,5 @@ +#ifdef HAVE_LIBGSTREAMER + +void media_player_draw_cb(void *tapdata _U_); + +#endif /* HAVE_LIBGSTREAMER */ Index: gtk/Makefile.am =================================================================== --- gtk/Makefile.am (revision 30846) +++ gtk/Makefile.am (working copy) @@ -50,7 +50,7 @@ libui_a_DEPENDENCIES = # Common headers -AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap $(LIBGCRYPT_CFLAGS) $(LIBGNUTLS_CFLAGS) $(PORTAUDIO_INCLUDES) +AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/wiretap $(LIBGCRYPT_CFLAGS) $(LIBGNUTLS_CFLAGS) $(PORTAUDIO_INCLUDES) $(XML2_INCLUDES) $(GSTREAMER_INCLUDES) doxygen: Index: gtk/Makefile.common.orig =================================================================== --- gtk/Makefile.common.orig (revision 0) +++ gtk/Makefile.common.orig (revision 0) @@ -0,0 +1,326 @@ +# Makefile.common +# Contains the stuff from Makefile.am and Makefile.nmake that is +# a) common to both files and +# b) portable between both files +# +# $Id: Makefile.common 30825 2009-11-04 21:16:38Z gerald $ +# +# Wireshark - Network traffic analyzer +# By Gerald Combs <gerald@xxxxxxxxxxxxx> +# Copyright 1998 Gerald Combs +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +# Generated header files that we want in the distribution. +# (None, so far.) +GENERATED_HEADER_FILES = + +# Generated C source files that we want in the distribution. +GENERATED_C_FILES = \ + wireshark-tap-register.c + +# All the generated files we want in the distribution. +GENERATED_FILES = $(GENERATED_HEADER_FILES) $(GENERATED_C_FILES) + +WIRESHARK_GTK_SRC = \ + about_dlg.c \ + airpcap_dlg.c \ + airpcap_gui_utils.c \ + capture_dlg.c \ + capture_file_dlg.c \ + capture_if_dlg.c \ + capture_info_dlg.c \ + cfilter_combo_utils.c \ + color_dlg.c \ + color_edit_dlg.c \ + color_utils.c \ + conversations_table.c \ + decode_as_ber.c \ + decode_as_dcerpc.c \ + decode_as_dlg.c \ + dfilter_expr_dlg.c \ + dlg_utils.c \ + drag_and_drop.c \ + expert_comp_table.c \ + export_object.c \ + export_object_dicom.c \ + export_object_http.c \ + filter_autocomplete.c \ + file_dlg.c \ + fileset_dlg.c \ + filter_dlg.c \ + filter_utils.c \ + find_dlg.c \ + firewall_dlg.c \ + follow_ssl.c \ + follow_stream.c \ + follow_tcp.c \ + follow_udp.c \ + font_utils.c \ + goto_dlg.c \ + graph_analysis.c \ + gtkvumeter.c \ + gui_stat_util.c \ + gui_utils.c \ + help_dlg.c \ + hostlist_table.c \ + macros_dlg.c \ + main.c \ + main_airpcap_toolbar.c \ + main_filter_toolbar.c \ + menus.c \ + main_packet_list.c \ + main_proto_draw.c \ + main_statusbar.c \ + main_toolbar.c \ + main_welcome.c \ + mcast_stream.c \ + new_packet_list.c \ + packet_history.c \ + packet_list_store.c \ + packet_win.c \ + pixmap_save.c \ + plugins_dlg.c \ + prefs_capture.c \ + prefs_column.c \ + prefs_dlg.c \ + prefs_gui.c \ + prefs_layout.c \ + prefs_nameres.c \ + prefs_print.c \ + prefs_protocols.c \ + prefs_taps.c \ + prefs_stream.c \ + print_dlg.c \ + profile_dlg.c \ + progress_dlg.c \ + proto_dlg.c \ + proto_hier_stats_dlg.c \ + range_utils.c \ + recent.c \ + rtp_player.c \ + rtp_stream.c \ + sctp_byte_graph_dlg.c \ + sctp_error_dlg.c \ + sctp_graph_dlg.c \ + sctp_stat.c \ + service_response_time_table.c \ + simple_dialog.c \ + stock_icons.c \ + summary_dlg.c \ + supported_protos_dlg.c \ + tap_dfilter_dlg.c \ + text_page_utils.c \ + u3.c \ + uat_gui.c \ + voip_calls.c \ + webbrowser.c + +about_dlg.c main_welcome.c: ../image/wssplash.xpm ../image/wssplash-dev.xpm +main_statusbar.c: ../image/expert_chat.h ../image/expert_error.h ../image/expert_none.h ../image/expert_note.h ../image/expert_warn.h + +WIRESHARK_TAP_SRC = \ + afp_stat.c \ + ansi_a_stat.c \ + ansi_map_stat.c \ + bootp_stat.c \ + camel_counter.c \ + camel_srt.c \ + compare_stat.c \ + conversations_eth.c \ + conversations_fc.c \ + conversations_fddi.c \ + conversations_ip.c \ + conversations_ipx.c \ + conversations_jxta.c \ + conversations_ncp.c \ + conversations_rsvp.c \ + conversations_sctp.c \ + conversations_tcpip.c \ + conversations_tr.c \ + conversations_udpip.c \ + conversations_usb.c \ + conversations_wlan.c \ + dcerpc_stat.c \ + diameter_stat.c \ + expert_comp_dlg.c \ + expert_dlg.c \ + fc_stat.c \ + flow_graph.c \ + funnel_stat.c \ + gsm_a_stat.c \ + gsm_map_stat.c \ + gsm_map_summary.c \ + gtp_stat.c \ + h225_counter.c \ + h225_ras_srt.c \ + hostlist_eth.c \ + hostlist_fc.c \ + hostlist_fddi.c \ + hostlist_ip.c \ + hostlist_ipx.c \ + hostlist_jxta.c \ + hostlist_ncp.c \ + hostlist_rsvp.c \ + hostlist_sctp.c \ + hostlist_tcpip.c \ + hostlist_tr.c \ + hostlist_udpip.c \ + hostlist_usb.c \ + hostlist_wlan.c \ + iax2_analysis.c \ + io_stat.c \ + ldap_stat.c \ + mac_lte_stat_dlg.c \ + mcast_stream_dlg.c \ + megaco_stat.c \ + mgcp_stat.c \ + mtp3_stat.c \ + mtp3_summary.c \ + ncp_stat.c \ + radius_stat.c \ + rpc_progs.c \ + rpc_stat.c \ + rtp_analysis.c \ + rtp_stream_dlg.c \ + scsi_stat.c \ + sctp_assoc_analyse.c \ + sctp_chunk_stat.c \ + sctp_chunk_stat_dlg.c \ + sctp_stat_dlg.c \ + sip_stat.c \ + smb_stat.c \ + smb2_stat.c \ + stats_tree_stat.c \ + t38_analysis.c \ + tcp_graph.c \ + voip_calls_dlg.c \ + wlan_stat_dlg.c \ + wsp_stat.c + +noinst_HEADERS = \ + about_dlg.h \ + airpcap_dlg.h \ + airpcap_gui_utils.h \ + capture_dlg.h \ + capture_file_dlg.h \ + capture_globals.h \ + capture_if_dlg.h \ + cfilter_combo_utils.h \ + color_dlg.h \ + color_edit_dlg.h \ + color_utils.h \ + conversations_table.h \ + decode_as_ber.h \ + decode_as_dlg.h \ + decode_as_dcerpc.h \ + dfilter_expr_dlg.h \ + dlg_utils.h \ + drag_and_drop.h \ + expert_comp_dlg.h \ + expert_comp_table.h \ + expert_dlg.h \ + export_object.h \ + file_dlg.h \ + fileset_dlg.h \ + filter_autocomplete.h \ + filter_dlg.h \ + filter_utils.h \ + find_dlg.h \ + firewall_dlg.h \ + follow_ssl.h \ + follow_stream.h \ + follow_tcp.h \ + follow_udp.h \ + font_utils.h \ + goto_dlg.h \ + graph_analysis.h \ + gsm_map_stat.h \ + gtkglobals.h \ + gtkvumeter.h \ + gui_stat_menu.h \ + gui_stat_util.h \ + gui_utils.h \ + help_dlg.h \ + hostlist_table.h \ + iax2_analysis.h \ + keys.h \ + macros_dlg.h \ + main.h \ + main_airpcap_toolbar.h \ + main_filter_toolbar.h \ + menus.h \ + main_packet_list.h \ + main_proto_draw.h \ + main_statusbar.h \ + main_statusbar_private.h \ + main_toolbar.h \ + main_welcome.h \ + mcast_stream.h \ + mcast_stream_dlg.h \ + mtp3_stat.h \ + new_packet_list.h \ + packet_history.h \ + packet_list_store.h \ + packet_win.h \ + pixmap_save.h \ + plugins_dlg.h \ + prefs_capture.h \ + prefs_column.h \ + prefs_dlg.h \ + prefs_gui.h \ + prefs_layout.h \ + prefs_nameres.h \ + prefs_print.h \ + prefs_protocols.h \ + prefs_taps.h \ + prefs_stream.h \ + profile_dlg.h \ + proto_dlg.h \ + proto_hier_stats_dlg.h \ + range_utils.h \ + recent.h \ + rtp_analysis.h \ + rtp_player.h \ + rtp_stream.h \ + rtp_stream_dlg.h \ + sat.h \ + sctp_stat.h \ + service_response_time_table.h \ + stock_icons.h \ + summary_dlg.h \ + supported_protos_dlg.h \ + tap_dfilter_dlg.h \ + text_page_utils.h \ + u3.h \ + uat_gui.h \ + voip_calls.h \ + voip_calls_dlg.h \ + webbrowser.h + +EXTRA_DIST = \ + airpcap_dlg.c \ + airpcap_gui_utils.c \ + capture_if_details_dlg_win32.c \ + capture_if_details_dlg_win32.h \ + doxygen.cfg.in \ + file_dlg_win32.c \ + file_dlg_win32.h \ + main_airpcap_toolbar.c \ + Makefile.common \ + Makefile.nmake \ + print_win32.c \ + print_win32.h + Index: gtk/media_player.c =================================================================== --- gtk/media_player.c (revision 0) +++ gtk/media_player.c (revision 0) @@ -0,0 +1,257 @@ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#ifdef HAVE_LIBGSTREAMER +#include <string.h> + +#include <gtk/gtk.h> + +#include <gst/gst.h> +#include <gst/app/gstappsrc.h> + +#include <epan/addr_resolv.h> +#include <epan/epan_dissect.h> +#include <epan/packet_info.h> +#include <epan/tap.h> + +/* RTP specific */ +#include <epan/dissectors/packet-rtp.h> +#include <epan/rtp_pt.h> + +#include "media_player_dlg.h" + +/* Defines a media stream */ +typedef struct _media_stream_info { + address src_addr; + guint16 src_port; + address dest_addr; + guint16 dest_port; + GList* media_packets_list; + guint32 num_packets; + guint32 last_played_packet; + /* GStreamer specific */ + char *sink_caps; + GstElement *pipeline; + GstElement *appsrc; +} media_stream_info_t; + + +/* Defines a media packet */ +typedef struct _media_packet { + guint8* data; + guint16 length; +} media_packet_t; + +typedef struct _media_player_state_t { + GHashTable* media_streams_hash; /* Hash table with all the media streams */ +} media_player_state_t; + +static media_player_state_t media_player_state = { NULL }; + +/****************************************************************************/ +static void +media_stream_key_destroy(gpointer key) +{ + g_free(key); + key = NULL; +} + +/****************************************************************************/ +static void +media_stream_value_destroy(gpointer data) +{ + media_stream_info_t *msi = data; + GList* media_packets_list; + media_packet_t *mp; + + media_packets_list = g_list_first(msi->media_packets_list); + while (media_packets_list) + { + mp = media_packets_list->data; + + g_free(mp->data); + g_free(mp); + mp = NULL; + + media_packets_list = g_list_next(media_packets_list); + } + g_free((void *)(msi->src_addr.data)); + g_free((void *)(msi->dest_addr.data)); + g_free(msi); + msi = NULL; +} + +/****************************************************************************/ +static void +media_player_reset_cb(void *tapdata) +{ + media_player_state_t *media_player_state = tapdata; + + if (media_player_state->media_streams_hash) { + g_hash_table_destroy(media_player_state->media_streams_hash); + + media_player_state->media_streams_hash = NULL; + } +} + +/****************************************************************************/ +static media_stream_info_t * +media_player_common_packet(media_player_state_t *media_player_state, packet_info *pinfo) +{ + media_stream_info_t *stream_info; + GString *key_str = NULL; + + /* Create the streams hash if it doesn't exist */ + if (!media_player_state->media_streams_hash) { + media_player_state->media_streams_hash = g_hash_table_new_full(g_str_hash, g_str_equal, media_stream_key_destroy, media_stream_value_destroy); + } + + /* Create a hash key to lookup in the media streams hash table + * uses: src_ip:src_port dst_ip:dst_port + */ + key_str = g_string_new(""); + g_string_printf(key_str, "%s:%d %s:%d", get_addr_name(&(pinfo->src)), + pinfo->srcport, get_addr_name(&(pinfo->dst)), + pinfo->destport); + + /* Lookup for this media packet in the stream hash table*/ + stream_info = g_hash_table_lookup(media_player_state->media_streams_hash, key_str->str); + + /* If it is not in the hash table, create a new stream */ + if (stream_info == NULL) { + stream_info = g_malloc(sizeof(media_stream_info_t)); + COPY_ADDRESS(&(stream_info->src_addr), &(pinfo->src)); + stream_info->src_port = pinfo->srcport; + COPY_ADDRESS(&(stream_info->dest_addr), &(pinfo->dst)); + stream_info->dest_port = pinfo->destport; + stream_info->media_packets_list = NULL; + stream_info->num_packets = 0; + stream_info->last_played_packet = 0; + stream_info->sink_caps = NULL; + stream_info->pipeline = NULL; + stream_info->appsrc = NULL; + + g_hash_table_insert(media_player_state->media_streams_hash, g_strdup(key_str->str), stream_info); + } + + g_string_free(key_str, TRUE); + + /* Increment the number of packets in this stream for the progress bar and statistics*/ + stream_info->num_packets++; + + return stream_info; +} + +static void +gst_audio_cb_newpad(GstElement *decodebin _U_, GstPad *pad, gboolean islast _U_, gpointer user_data) +{ + GstElement *audiosink; + GstPad *audiopad; + + audiosink = user_data; + + audiopad = gst_element_get_pad (audiosink, "sink"); + + gst_pad_link (pad, audiopad); +} + +static GstElement* +gst_new_audio_pipeline(media_stream_info_t *stream_info, const char *caps_string) +{ + GstElement *pipeline; + GstElement *src, *dec, *sink; + GstCaps *caps; + + pipeline = gst_pipeline_new ("pipeline"); +/* + bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); + gst_bus_add_watch (bus, my_bus_callback, loop); + gst_object_unref (bus); +*/ + src = gst_element_factory_make ("appsrc", NULL); + caps = gst_caps_from_string(caps_string); + gst_app_src_set_caps(GST_APP_SRC (src), caps); + gst_caps_unref(caps); + + dec = gst_element_factory_make ("decodebin", NULL); + sink = gst_element_factory_make ("autoaudiosink", NULL); + + g_signal_connect (dec, "new-decoded-pad", G_CALLBACK(gst_audio_cb_newpad), sink); + gst_bin_add_many (GST_BIN (pipeline), src, dec, sink, NULL); + gst_element_link (src, dec); + + /* run */ + gst_element_set_state (pipeline, GST_STATE_PLAYING); + + stream_info->appsrc = src; + + return pipeline; +} + +/****************************************************************************/ +static gboolean +media_player_rtp_packet_cb(void *tapdata, packet_info *pinfo, epan_dissect_t *edt _U_, const void *data) +{ + media_stream_info_t *stream_info = NULL; + media_packet_t *new_media_packet; + const struct _rtp_info *rtp_info = data; + + GstBuffer *buffer; + + stream_info = media_player_common_packet(tapdata, pinfo); + + /* Add the media packet to the list */ + new_media_packet = g_malloc(sizeof(media_packet_t)); + + if (stream_info->sink_caps == NULL) { + switch (rtp_info->info_payload_type) { + case PT_PCMU: +// stream_info->sink_caps = "application/x-rtp, media: audio, payload: 0, clock-rate: 8000"; + stream_info->pipeline = gst_new_audio_pipeline(stream_info, "application/x-rtp, media: audio, payload: 0, clock-rate: 8000"); + break; + case PT_PCMA: +// stream_info->sink_caps = "application/x-rtp, media: audio, payload: 8, clock-rate: 8000"; + stream_info->pipeline = gst_new_audio_pipeline(stream_info, "application/x-rtp, media: audio, payload: 8, clock-rate: 8000"); + break; + default: + g_print("media_player.c:media_player_rtp_packet_cb YOU SHOULD NOT BE HERE\n"); + break; + } + } + + /* Copy the RTP raw data */ + if (rtp_info->info_data_len) { + new_media_packet->data = g_malloc(rtp_info->info_data_len); + memcpy(new_media_packet->data, rtp_info->info_data, rtp_info->info_data_len); + new_media_packet->length = rtp_info->info_data_len; + } else { + new_media_packet->data = NULL; + } + + stream_info->media_packets_list = g_list_append(stream_info->media_packets_list, new_media_packet); + + /* feed data */ + buffer = gst_buffer_new(); + GST_BUFFER_DATA (buffer) = new_media_packet->data; + GST_BUFFER_SIZE (buffer) = new_media_packet->length; + gst_app_src_push_buffer(GST_APP_SRC (stream_info->appsrc), buffer); + + return TRUE; +} + +/****************************************************************************/ +GString * +media_player_init(void) +{ + GString *err_string; + + err_string = register_tap_listener("rtp", &media_player_state, NULL, 0, + media_player_reset_cb, + media_player_rtp_packet_cb, + media_player_draw_cb); + + return err_string; +} + +#endif /* HAVE_LIBGSTREAMER */ Index: gtk/media_player.h =================================================================== --- gtk/media_player.h (revision 0) +++ gtk/media_player.h (revision 0) @@ -0,0 +1,5 @@ +#ifdef HAVE_LIBGSTREAMER + +GString *media_player_init(void); + +#endif /* HAVE_LIBGSTREAMER */ Index: gtk/Makefile.common =================================================================== --- gtk/Makefile.common (revision 30846) +++ gtk/Makefile.common (working copy) @@ -87,6 +87,7 @@ main_toolbar.c \ main_welcome.c \ mcast_stream.c \ + media_player.c \ new_packet_list.c \ packet_history.c \ packet_list_store.c \ @@ -185,6 +186,7 @@ ldap_stat.c \ mac_lte_stat_dlg.c \ mcast_stream_dlg.c \ + media_player_dlg.c \ megaco_stat.c \ mgcp_stat.c \ mtp3_stat.c \ @@ -262,6 +264,7 @@ main_airpcap_toolbar.h \ main_filter_toolbar.h \ menus.h \ + media_player.h \ main_packet_list.h \ main_proto_draw.h \ main_statusbar.h \ Index: gtk/main.c =================================================================== --- gtk/main.c (revision 30846) +++ gtk/main.c (working copy) @@ -60,6 +60,10 @@ #include <portaudio.h> #endif /* HAVE_LIBPORTAUDIO */ +#ifdef HAVE_LIBGSTREAMER +#include <gst/gst.h> +#endif /* HAVE_LIBGSTREAMER */ + #include <epan/epan.h> #include <epan/filesystem.h> #include <wsutil/privileges.h> @@ -2075,6 +2079,10 @@ /* Let GTK get its args (will need an X server, so do this after command line only commands handled) */ gtk_init (&argc, &argv); +#ifdef HAVE_LIBGSTREAMER + gst_init(&argc, &argv); +#endif + cf_callback_add(main_cf_callback, NULL); #ifdef HAVE_LIBPCAP capture_callback_add(main_capture_callback, NULL);
- Follow-Ups:
- Re: [Wireshark-dev] Play media streams in real time
- From: Stephen Fisher
- Re: [Wireshark-dev] Play media streams in real time
- Prev by Date: Re: [Wireshark-dev] MacOSX snow leo integration
- Next by Date: Re: [Wireshark-dev] Play media streams in real time
- Previous by thread: Re: [Wireshark-dev] reduce the size of packet_info
- Next by thread: Re: [Wireshark-dev] Play media streams in real time
- Index(es):