⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pda_callbacks.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 3 页
字号:
    {        GtkTreeModel *p_model;        GtkTreeIter   iter;        int           i_row;        /* This might be a directory selection */        p_model = gtk_tree_view_get_model(treeview);        if (!p_model)        {            msg_Err(p_intf, "PDA: Playlist model contains a NULL pointer\n" );            return;        }        if (!gtk_tree_model_get_iter(p_model, &iter, path))        {            msg_Err( p_intf, "PDA: Playlist could not get iter from model" );            return;        }        gtk_tree_model_get(p_model, &iter, 2, &i_row, -1);        playlist_Goto( p_playlist, i_row );    }    vlc_object_release( p_playlist );}void onUpdatePlaylist(GtkButton *button, gpointer user_data){    intf_thread_t *  p_intf = GtkGetIntf( button );    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                                       FIND_ANYWHERE );    GtkTreeView *p_tvplaylist = NULL;    if( p_playlist == NULL )    {        return;    }    p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");    if (p_tvplaylist)    {        GtkListStore *p_model = NULL;        /* Rebuild the playlist then. */        p_model = gtk_list_store_new (3,                    G_TYPE_STRING, /* Filename */                    G_TYPE_STRING, /* Time */                    G_TYPE_UINT);  /* Hidden field */        if (p_model)        {            PlaylistRebuildListStore(p_model, p_playlist);            gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model));            g_object_unref(p_model);        }    }    vlc_object_release( p_playlist );}void deleteItemFromPlaylist(gpointer data, gpointer user_data){    gtk_tree_path_free((GtkTreePath*) data); // removing an item.}void onDeletePlaylist(GtkButton *button, gpointer user_data){    intf_thread_t *p_intf = GtkGetIntf( button );    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                                       FIND_ANYWHERE );    GtkTreeView    *p_tvplaylist;    /* Delete an arbitrary item from the playlist */    p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist" );    if (p_tvplaylist != NULL)    {        GList *p_rows = NULL;        GList *p_node;        GtkTreeModel *p_model = NULL;        GtkListStore *p_store = NULL;        GtkTreeSelection *p_selection = gtk_tree_view_get_selection(p_tvplaylist);        p_model = gtk_tree_view_get_model(p_tvplaylist);        if (p_model)        {            p_rows = gtk_tree_selection_get_selected_rows(p_selection, &p_model);            if( g_list_length( p_rows ) )            {                /* reverse-sort so that we can delete from the furthest                 * to the closest item to delete...                 */                p_rows = g_list_reverse( p_rows );            }            for (p_node=p_rows; p_node!=NULL; p_node = p_node->next)            {                GtkTreeIter iter;                GtkTreePath *p_path = NULL;                p_path = (GtkTreePath *)p_node->data;                if (p_path)                {                    if (gtk_tree_model_get_iter(p_model, &iter, p_path))                    {                        gint item;                        gtk_tree_model_get(p_model, &iter, 2, &item, -1);                        playlist_LockDelete(p_playlist, item);                    }                }            }#if 0             g_list_foreach (p_rows, (GFunc*)gtk_tree_path_free, NULL);#endif /* Testing the next line */            g_list_foreach (p_rows, deleteItemFromPlaylist, NULL);            g_list_free (p_rows);        }        /* Rebuild the playlist then. */        p_store = gtk_list_store_new (3,                    G_TYPE_STRING, /* Filename */                    G_TYPE_STRING, /* Time */                    G_TYPE_UINT);  /* Hidden field */        if (p_store)        {            PlaylistRebuildListStore(p_store, p_playlist);            gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store));            g_object_unref(p_store);        }    }    vlc_object_release( p_playlist );}void onClearPlaylist(GtkButton *button, gpointer user_data){    intf_thread_t *p_intf = GtkGetIntf( button );    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,                                                       FIND_ANYWHERE );    GtkTreeView    *p_tvplaylist;    int item;    if( p_playlist == NULL )    {        return;    }    for(item = p_playlist->i_size - 1; item >= 0 ;item-- )    {        playlist_LockDelete( p_playlist, item);    }    vlc_object_release( p_playlist );    // Remove all entries from the Playlist widget.    p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(button), "tvPlaylist");    if (p_tvplaylist)    {        GtkTreeModel *p_play_model;        p_play_model = gtk_tree_view_get_model(p_tvplaylist);        if (p_play_model)        {            gtk_list_store_clear(GTK_LIST_STORE(p_play_model));        }    }}void onPreferenceSave(GtkButton *button, gpointer user_data){#if 0    intf_thread_t *p_intf = GtkGetIntf( button );    msg_Dbg(p_intf, "Preferences Save" );    config_SaveConfigFile( p_intf, NULL );#endif}void onPreferenceApply(GtkButton *button, gpointer user_data){#if 0    intf_thread_t *p_intf = GtkGetIntf( button );    msg_Dbg(p_intf, "Preferences Apply" );#endif}void onPreferenceCancel(GtkButton *button, gpointer user_data){#if 0    intf_thread_t *p_intf = GtkGetIntf( button );    msg_Dbg(p_intf, "Preferences Cancel" );    config_ResetAll( p_intf );    /* Cancel interface changes. */    config_SaveConfigFile( p_intf, NULL );#endif}void onAddTranscodeToPlaylist(GtkButton *button, gpointer user_data){    intf_thread_t *p_intf = GtkGetIntf( button );    GtkEntry       *p_entryVideoCodec = NULL;    GtkSpinButton  *p_entryVideoBitrate = NULL;    GtkSpinButton  *p_entryVideoBitrateTolerance = NULL;    GtkSpinButton  *p_entryVideoKeyFrameInterval = NULL;    GtkCheckButton *p_checkVideoDeinterlace = NULL;    GtkEntry       *p_entryAudioCodec = NULL;    GtkSpinButton  *p_entryAudioBitrate = NULL;    const gchar    *p_video_codec;    gint            i_video_bitrate;    gint            i_video_bitrate_tolerance;    gint            i_video_keyframe_interval;    gboolean        b_video_deinterlace;    const gchar    *p_audio_codec;    gint            i_audio_bitrate;    GtkEntry       *p_entryStdAccess = NULL;    GtkEntry       *p_entryStdMuxer = NULL;    GtkEntry       *p_entryStdURL = NULL;    GtkEntry       *p_entryStdAnnounce = NULL;    GtkSpinButton  *p_entryStdTTL = NULL;    GtkCheckButton *p_checkSAP = NULL;    GtkCheckButton *p_checkSLP = NULL;    const gchar    *p_std_announce;    const gchar    *p_std_access;    const gchar    *p_std_muxer;    const gchar    *p_std_url;    gboolean        b_sap_announce;    gboolean        b_slp_announce;    gint            i_std_ttl;    char **ppsz_options = NULL; /* list of options */    int  i_options=0;    int  i;    gchar mrl[7];    int   i_pos;    ppsz_options = (char **) malloc(3 *sizeof(char*));    if (ppsz_options == NULL)    {        msg_Err(p_intf, "No memory to allocate for v4l options.");        return;    }    for (i=0; i<3; i++)    {        ppsz_options[i] = (char *) malloc(VLC_MAX_MRL * sizeof(char));        if (ppsz_options[i] == NULL)        {            msg_Err(p_intf, "No memory to allocate for v4l options string %i.", i);            for (i-=1; i>=0; i--)                free(ppsz_options[i]);            free(ppsz_options);            return;        }    }    /* Update the playlist */    playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );    if( p_playlist == NULL ) return;    /* Get all the options. */    i_pos = snprintf( &mrl[0], VLC_MAX_MRL, "sout");    mrl[6] = '\0';    /* option 1 */    i_pos = snprintf( &ppsz_options[i_options][0], VLC_MAX_MRL, "sout='#transcode{");    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    p_entryVideoCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryVideoCodec" );    p_entryVideoBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrate" );    p_entryVideoBitrateTolerance = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoBitrateTolerance" );    p_entryVideoKeyFrameInterval = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryVideoKeyFrameInterval" );        p_video_codec = gtk_entry_get_text(GTK_ENTRY(p_entryVideoCodec));    i_video_bitrate = gtk_spin_button_get_value_as_int(p_entryVideoBitrate);    i_video_bitrate_tolerance = gtk_spin_button_get_value_as_int(p_entryVideoBitrateTolerance);    i_video_keyframe_interval = gtk_spin_button_get_value_as_int(p_entryVideoKeyFrameInterval);        i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vcodec=%s,", (char*)p_video_codec );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vb=%d,", (int)i_video_bitrate );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "vt=%d,", (int)i_video_bitrate_tolerance );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "keyint=%d,", (int)i_video_keyframe_interval );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    p_checkVideoDeinterlace = (GtkCheckButton*) lookup_widget( GTK_WIDGET(button), "checkVideoDeinterlace" );    b_video_deinterlace = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkVideoDeinterlace));    if (b_video_deinterlace)    {        i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "deinterlace," );        if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    }    p_entryAudioCodec   = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAudioCodec" );    p_entryAudioBitrate = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryAudioBitrate" );    p_audio_codec = gtk_entry_get_text(GTK_ENTRY(p_entryAudioCodec));    i_audio_bitrate = gtk_spin_button_get_value_as_int(p_entryAudioBitrate);    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "acodec=%s,", (char*)p_audio_codec );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "ab=%d,", (int)i_audio_bitrate );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "channels=1}"/*, (int)i_audio_channels*/ );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    /* option 2 */    i_pos = 0;    i_pos = snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "#" );    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdAccess" );    p_entryStdMuxer  = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdMuxer" );    p_entryStdURL = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryStdURL" );    p_entryStdAnnounce = (GtkEntry*) lookup_widget( GTK_WIDGET(button), "entryAnnounceChannel" );    p_entryStdTTL = (GtkSpinButton*) lookup_widget( GTK_WIDGET(button), "entryStdTTL" );    p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));    p_std_muxer = gtk_entry_get_text(GTK_ENTRY(p_entryStdMuxer));    p_std_url = gtk_entry_get_text(GTK_ENTRY(p_entryStdURL));    p_std_announce = gtk_entry_get_text(GTK_ENTRY(p_entryStdAnnounce));    b_sap_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSAP));    b_slp_announce = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(p_checkSLP));    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "std{access=%s,", (char*)p_std_access);    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "mux=%s,", (char*)p_std_muxer);    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "url=%s", (char*)p_std_url);    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    if (strncasecmp( (const char*)p_std_access, "udp", 3)==0)    {        if (b_sap_announce)        {            i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "sap=%s", (char*)p_std_announce);            if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';        }        if (b_slp_announce)        {            i_pos += snprintf( &ppsz_options[i_options][i_pos], VLC_MAX_MRL - i_pos, "slp=%s", (char*)p_std_announce);            if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';        }    }    i_std_ttl = gtk_spin_button_get_value_as_int(p_entryStdTTL);    i_pos += snprintf( &ppsz_options[i_options++][i_pos], VLC_MAX_MRL - i_pos, "ttl=%d}", (int)i_std_ttl);    if (i_pos>=VLC_MAX_MRL) ppsz_options[i_options][VLC_MAX_MRL-1] = '\0';    if (user_data != NULL)    {      msg_Dbg(p_intf, "Adding transcoding options to playlist item." );    }    else    {      msg_Dbg(p_intf, "Adding --sout to playlist." );      PlaylistAddItem(GTK_WIDGET(button), (gchar*) &mrl, ppsz_options, i_options);    }}void onEntryStdAccessChanged(GtkEditable *editable, gpointer user_data){    intf_thread_t *p_intf = GtkGetIntf( editable );    GtkCheckButton *p_checkSAP = NULL;    GtkCheckButton *p_checkSLP = NULL;    GtkEntry       *p_entryStdAccess = NULL;    const gchar    *p_std_access = NULL;        gboolean        b_announce = FALSE;    p_entryStdAccess = (GtkEntry*) lookup_widget( GTK_WIDGET(editable), "entryStdAccess" );    p_checkSAP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSAP" );    p_checkSLP = (GtkCheckButton*) lookup_widget( GTK_WIDGET(editable), "checkSLP" );    if ( (p_std_access == NULL) || (p_checkSAP == NULL) || (p_checkSLP == NULL))    {        msg_Err( p_intf, "Access, SAP and SLP widgets not found." );        return;    }    p_std_access = gtk_entry_get_text(GTK_ENTRY(p_entryStdAccess));    b_announce = (strncasecmp( (const char*)p_std_access, "udp", 3) == 0);    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSAP), b_announce);    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(p_checkSLP), b_announce);}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -