1 /***************************************************************** 2 * gmerlin - a general purpose multimedia framework and applications 3 * 4 * Copyright (c) 2001 - 2011 Members of the Gmerlin project 5 * gmerlin-general@lists.sourceforge.net 6 * http://gmerlin.sourceforge.net 7 * 8 * This program is free software: you can redistribute it and/or modify 9 * it under the terms of the GNU General Public License as published by 10 * the Free Software Foundation, either version 2 of the License, or 11 * (at your option) any later version. 12 * 13 * This program is distributed in the hope that it will be useful, 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 * GNU General Public License for more details. 17 * 18 * You should have received a copy of the GNU General Public License 19 * along with this program. If not, see <http://www.gnu.org/licenses/>. 20 * *****************************************************************/ 21 22 #include <gtk/gtk.h> 23 24 #include <gmerlin/player.h> 25 #include <gmerlin/cfg_registry.h> 26 #include <gmerlin/pluginregistry.h> 27 #include <gmerlin/tree.h> 28 #include <gui_gtk/tree.h> 29 #include <gui_gtk/infowindow.h> 30 #include <gui_gtk/logwindow.h> 31 #include <gmerlin/lcdproc.h> 32 33 #include <gmerlin/cfg_dialog.h> 34 35 #include <gmerlin/remote.h> 36 37 typedef struct gmerlin_s gmerlin_t; 38 39 #include "display.h" 40 #include "playerwindow.h" 41 42 /* Class hints */ 43 44 #define WINDOW_NAME "Gmerlin" 45 #define WINDOW_CLASS "gmerlin" 46 #define WINDOW_ICON "player_icon.png" 47 48 /* Repeat mode */ 49 50 typedef enum 51 { 52 REPEAT_MODE_NONE = 0, 53 REPEAT_MODE_1 = 1, 54 REPEAT_MODE_ALL = 2, 55 NUM_REPEAT_MODES = 3, 56 } repeat_mode_t; 57 58 /* Accelerators */ 59 60 #define ACCEL_VOLUME_DOWN 1 61 #define ACCEL_VOLUME_UP 2 62 #define ACCEL_SEEK_BACKWARD 3 63 #define ACCEL_SEEK_FORWARD 4 64 #define ACCEL_SEEK_START 5 65 #define ACCEL_PAUSE 6 66 #define ACCEL_MUTE 7 67 #define ACCEL_NEXT_CHAPTER 8 68 #define ACCEL_PREV_CHAPTER 9 69 70 #define ACCEL_NEXT 10 71 #define ACCEL_PREV 11 72 #define ACCEL_QUIT 12 73 #define ACCEL_OPTIONS 13 74 #define ACCEL_GOTO_CURRENT 15 75 #define ACCEL_CURRENT_TO_FAVOURITES 16 76 77 typedef struct 78 { 79 char * directory; 80 81 player_window_skin_t playerwindow; 82 } gmerlin_skin_t; 83 84 void gmerlin_skin_destroy(gmerlin_skin_t * s); 85 86 typedef struct gmerlin_skin_browser_s gmerlin_skin_browser_t; 87 88 #define PLAYBACK_SKIP_ERROR (1<<0) 89 #define PLAYBACK_NOADVANCE (1<<1) 90 91 struct gmerlin_s 92 { 93 int playback_flags; 94 95 repeat_mode_t repeat_mode; 96 bg_shuffle_mode_t shuffle_mode; 97 98 /* Core stuff */ 99 100 bg_cfg_registry_t * cfg_reg; 101 bg_plugin_registry_t * plugin_reg; 102 bg_player_t * player; 103 bg_media_tree_t * tree; 104 105 /* GUI */ 106 107 bg_dialog_t * cfg_dialog; 108 bg_dialog_t * audio_dialog; 109 bg_dialog_t * audio_filter_dialog; 110 111 bg_dialog_t * video_dialog; 112 bg_dialog_t * video_filter_dialog; 113 114 bg_dialog_t * subtitle_dialog; 115 116 bg_dialog_t * visualization_dialog; 117 118 bg_gtk_tree_window_t * tree_window; 119 120 player_window_t * player_window; 121 bg_gtk_info_window_t * info_window; 122 bg_gtk_log_window_t * log_window; 123 124 gmerlin_skin_t skin; 125 char * skin_dir; 126 127 gmerlin_skin_browser_t * skin_browser; 128 129 int tree_error; 130 131 /* Configuration stuff */ 132 133 bg_cfg_section_t * display_section; 134 bg_cfg_section_t * tree_section; 135 bg_cfg_section_t * general_section; 136 bg_cfg_section_t * audio_section; 137 bg_cfg_section_t * audio_filter_section; 138 bg_cfg_section_t * video_section; 139 bg_cfg_section_t * video_filter_section; 140 bg_cfg_section_t * subtitle_section; 141 bg_cfg_section_t * osd_section; 142 bg_cfg_section_t * input_section; 143 bg_cfg_section_t * lcdproc_section; 144 bg_cfg_section_t * remote_section; 145 bg_cfg_section_t * logwindow_section; 146 bg_cfg_section_t * infowindow_section; 147 bg_cfg_section_t * visualization_section; 148 149 bg_parameter_info_t * input_plugin_parameters; 150 bg_parameter_info_t * image_reader_parameters; 151 152 int show_info_window; 153 int show_log_window; 154 int show_tree_window; 155 156 bg_lcdproc_t * lcdproc; 157 158 /* Remote control */ 159 bg_remote_server_t * remote; 160 161 int player_state; 162 163 /* For all windows */ 164 GtkAccelGroup *accel_group; 165 166 /* The following can be queried remotely */ 167 168 struct 169 { 170 gavl_metadata_t metadata; 171 char * name; 172 gavl_time_t time; 173 gavl_time_t duration; 174 } remote_data; 175 176 }; 177 178 gmerlin_t * gmerlin_create(bg_cfg_registry_t * cfg_reg); 179 180 /* Right after creating, urls can be added */ 181 182 void gmerlin_add_locations(gmerlin_t * g, char ** locations); 183 void gmerlin_play_locations(gmerlin_t * g, char ** locations); 184 185 void gmerlin_open_device(gmerlin_t * g, char * device); 186 void gmerlin_play_device(gmerlin_t * g, char * device); 187 188 void gmerlin_destroy(gmerlin_t*); 189 190 void gmerlin_run(gmerlin_t*, char ** locations); 191 192 /* Skin stuff */ 193 194 /* Load a skin from directory. Return the default dierectory if the 195 skin could not be found */ 196 197 char * gmerlin_skin_load(gmerlin_skin_t *, char * directory); 198 199 200 void gmerlin_skin_set(gmerlin_t*); 201 void gmerlin_skin_free(gmerlin_skin_t*); 202 203 /* Skin browser */ 204 205 gmerlin_skin_browser_t * gmerlin_skin_browser_create(gmerlin_t *); 206 void gmerlin_skin_browser_destroy(gmerlin_skin_browser_t *); 207 void gmerlin_skin_browser_show(gmerlin_skin_browser_t *); 208 209 /* Run the main config dialog */ 210 211 void gmerlin_create_dialog(gmerlin_t * g); 212 213 void gmerlin_configure(gmerlin_t * g); 214 215 int gmerlin_play(gmerlin_t * g, int ignore_flags); 216 void gmerlin_pause(gmerlin_t * g); 217 218 /* This is called when the player signals that it wants a new 219 track */ 220 221 void gmerlin_next_track(gmerlin_t * g); 222 223 /* Check if the next track in the tree has the index 224 specified by track */ 225 226 void gmerlin_check_next_track(gmerlin_t * g, int track); 227 228 229 void gmerlin_tree_close_callback(bg_gtk_tree_window_t * win, 230 void * data); 231 232 const bg_parameter_info_t * gmerlin_get_parameters(gmerlin_t * g); 233 234 void gmerlin_set_parameter(void * data, const char * name, 235 const bg_parameter_value_t * val); 236 237 int gmerlin_get_parameter(void * data, const char * name, 238 bg_parameter_value_t * val); 239 240 241 /* Handle remote command */ 242 243 void gmerlin_handle_remote(gmerlin_t * g, bg_msg_t * msg); 244