?? pda_callbacks.c
字號:
GtkTreeModel *p_model; GtkTreeIter iter; int i_row; int i_skip; /* 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); i_skip = i_row - p_playlist->i_current_index; playlist_Skip( p_playlist, i_skip ); } pl_Release( p_intf );}void onUpdatePlaylist(GtkButton *button, gpointer user_data){ intf_thread_t * p_intf = GtkGetIntf( button ); playlist_t * p_playlist = pl_Yield( p_intf ); 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_intf, p_model, p_playlist); gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_model)); g_object_unref(p_model); } } pl_Release( p_intf );}static 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 = pl_Yield( p_intf ); 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); msg_Err( p_playlist, "PDA delete broken"); } } }#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_intf, p_store, p_playlist); gtk_tree_view_set_model(GTK_TREE_VIEW(p_tvplaylist), GTK_TREE_MODEL(p_store)); g_object_unref(p_store); } } pl_Release( p_intf );}void onClearPlaylist(GtkButton *button, gpointer user_data){ intf_thread_t *p_intf = GtkGetIntf( button ); playlist_t * p_playlist = pl_Yield( p_intf ); GtkTreeView *p_tvplaylist; int item; if( p_playlist == NULL ) { return; } for(item = playlist_CurrentSize(p_playlist) - 1; item >= 0 ;item-- ) { msg_Err( p_playlist, "fix pda delete" ); } pl_Release( p_intf ); // 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 = pl_Yield( p_intf ); 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, "dst=%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 + -