sout.c
上传用户:riyaled888
上传日期:2009-03-27
资源大小:7338k
文件大小:7k
源码类别:

多媒体

开发平台:

MultiPlatform

  1. /*****************************************************************************
  2.  * sout.c :
  3.  *****************************************************************************
  4.  * Copyright (C) 2000, 2001 VideoLAN
  5.  * $Id: sout.c 6961 2004-03-05 17:34:23Z sam $
  6.  *
  7.  * Authors: Laurent Aimar <fenrir@via.ecp.fr>
  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., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  22.  *****************************************************************************/
  23. /*****************************************************************************
  24.  * Preamble
  25.  *****************************************************************************/
  26. #include <sys/types.h>                                              /* off_t */
  27. #include <stdlib.h>
  28. #include <vlc/vlc.h>
  29. #include <vlc/intf.h>
  30. #ifdef MODULE_NAME_IS_gnome
  31. #   include <gnome.h>
  32. #else
  33. #   include <gtk/gtk.h>
  34. #endif
  35. #include <string.h>
  36. #include "gtk_callbacks.h"
  37. #include "gtk_interface.h"
  38. #include "gtk_support.h"
  39. #include "playlist.h"
  40. #include "common.h"
  41. void GtkSoutSettings ( GtkButton       *button,
  42.                        gpointer         user_data );
  43. void GtkSoutSettingsChanged  ( GtkWidget *button, gpointer user_data);
  44. void GtkSoutSettingsAccessFile              (GtkToggleButton *togglebutton,
  45.                                                 gpointer         user_data)
  46. {
  47.     GtkWidget *     p_sout;
  48.     p_sout = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
  49.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  50.                     "sout_file_path_label" ),
  51.                     gtk_toggle_button_get_active( togglebutton ) );
  52.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  53.                     "sout_file_path" ),
  54.                     gtk_toggle_button_get_active( togglebutton ) );
  55.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  56.                     "sout_mux_ts" ), TRUE );
  57.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  58.                     "sout_mux_ps" ), TRUE );
  59.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  60.                     "sout_mux_avi" ), TRUE );
  61.     GtkSoutSettingsChanged( GTK_WIDGET( togglebutton ), user_data );
  62. }
  63. void GtkSoutSettingsAccessUdp               (GtkToggleButton *togglebutton,
  64.                                                 gpointer         user_data)
  65. {
  66.     GtkWidget *     p_sout;
  67.     p_sout = gtk_widget_get_toplevel( GTK_WIDGET (togglebutton) );
  68.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  69.                     "sout_udp_address_label" ),
  70.                     gtk_toggle_button_get_active( togglebutton ) );
  71.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  72.                     "sout_udp_address_combo" ),
  73.                     gtk_toggle_button_get_active( togglebutton ) );
  74.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  75.                     "sout_udp_port_label" ),
  76.                     gtk_toggle_button_get_active( togglebutton ) );
  77.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  78.                     "sout_udp_port" ),
  79.                     gtk_toggle_button_get_active( togglebutton ) );
  80.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  81.                     "sout_mux_ts" ), TRUE );
  82.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  83.                     "sout_mux_ps" ), FALSE );
  84.     gtk_widget_set_sensitive( gtk_object_get_data( GTK_OBJECT( p_sout ),
  85.                     "sout_mux_avi" ), FALSE );
  86.     gtk_toggle_button_set_active(  gtk_object_get_data( GTK_OBJECT( p_sout ),
  87.                                    "sout_mux_ts" ), TRUE );
  88.     GtkSoutSettingsChanged( GTK_WIDGET( togglebutton ), user_data );
  89. }
  90. void GtkSoutSettingsChanged  ( GtkWidget *button,
  91.                                gpointer         user_data)
  92. {
  93. #define SELECTED( s ) GTK_TOGGLE_BUTTON( lookup_widget( GTK_WIDGET(button), 
  94.                                    (s) ) )->active
  95.     //intf_thread_t * p_intf = GtkGetIntf( button );
  96.     GString *       p_target;
  97.     p_target = g_string_new( "" );
  98.     /* first set access */
  99.     if( SELECTED( "sout_access_file" ) )
  100.     {
  101.         g_string_append( p_target, "file/" );
  102.     }
  103.     else if( SELECTED( "sout_access_udp" ) )
  104.     {
  105.         g_string_append( p_target, "udp/" );
  106.     }
  107.     else if( SELECTED( "sout_access_rtp" ) )
  108.     {
  109.         g_string_append( p_target, "rtp/" );
  110.     }
  111.     /* then set muxer */
  112.     if( SELECTED( "sout_mux_ts" ) )
  113.     {
  114.         g_string_append( p_target, "ts://" );
  115.     }
  116.     else if( SELECTED( "sout_mux_ps" ) )
  117.     {
  118.         g_string_append( p_target, "ps://" );
  119.     }
  120.     else if( SELECTED( "sout_mux_avi" ) )
  121.     {
  122.         g_string_append( p_target, "avi://" );
  123.     }
  124.     /* last part of the url */
  125.     if( SELECTED( "sout_access_file" ) )
  126.     {
  127.         g_string_append( p_target,
  128.                          gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  129.                                              GTK_WIDGET(button), "sout_file_path" ) ) ) );
  130.     }
  131.     else if( SELECTED( "sout_access_udp" ) || SELECTED( "sout_access_rtp" ) )
  132.     {
  133.         g_string_append( p_target,
  134.                          gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  135.                                              GTK_WIDGET(button), "sout_udp_address" ) ) ) );
  136.         g_string_append( p_target, ":" );
  137.         g_string_sprintfa( p_target, "%i",
  138.                          gtk_spin_button_get_value_as_int( GTK_SPIN_BUTTON( lookup_widget(
  139.                                                            GTK_WIDGET(button), "sout_udp_port" ) ) ) );
  140.     }
  141.     gtk_entry_set_text( GTK_ENTRY( lookup_widget(
  142.                                    GTK_WIDGET(button), "sout_entry_target" ) ),
  143.                         p_target->str );
  144.     g_string_free( p_target, TRUE );
  145. }
  146. /****************************************************************************/
  147. void GtkSoutSettingsOk     ( GtkButton       *button,
  148.                              gpointer         user_data)
  149. {
  150.     /* Hide the dialog box */
  151.     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
  152.     /* set sout */
  153. #if 0
  154.     psz_target = gtk_entry_get_text( GTK_ENTRY( lookup_widget(
  155.                                        GTK_WIDGET(button), "sout_entry_target" ) ) );
  156.     config_PutPsz( p_intf, "sout", psz_target );
  157. #endif
  158. }
  159. void GtkSoutSettingsCancel ( GtkButton      *button,
  160.                              gpointer        user_data)
  161. {
  162.     /* Hide the dialog box */
  163.     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
  164. }
  165. void GtkSoutSettings ( GtkButton       *button,
  166.                        gpointer         user_data )
  167. {
  168.     intf_thread_t * p_intf = GtkGetIntf( button );
  169.     gtk_widget_show( p_intf->p_sys->p_sout );
  170.     gdk_window_raise( p_intf->p_sys->p_sout->window );
  171. }