1 /* 2 * Copyright (C) 2001,2002,2003,2004,2005 Bastien Nocera <hadess@hadess.net> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 17 * 18 * The Totem project hereby grant permission for non-gpl compatible GStreamer 19 * plugins to be used and distributed together with GStreamer and Totem. This 20 * permission are above and beyond the permissions granted by the GPL license 21 * Totem is covered by. 22 * 23 * Monday 7th February 2005: Christian Schaller: Add exception clause. 24 * See license_change file for details. 25 * 26 */ 27 28 #pragma once 29 30 #include <clutter-gtk/clutter-gtk.h> 31 32 #ifndef glib_autoptr_clear_GtkClutterEmbed 33 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkClutterEmbed, g_object_unref) 34 #endif 35 36 #define BACON_TYPE_VIDEO_WIDGET (bacon_video_widget_get_type ()) 37 G_DECLARE_FINAL_TYPE(BaconVideoWidget, bacon_video_widget, BACON, VIDEO_WIDGET, GtkClutterEmbed) 38 #define BVW_ERROR bacon_video_widget_error_quark () 39 40 /** 41 * BvwError: 42 * @BVW_ERROR_NO_PLUGIN_FOR_FILE: A required GStreamer plugin is missing. 43 * @BVW_ERROR_BROKEN_FILE: The movie file is broken and cannot be decoded. 44 * @BVW_ERROR_FILE_GENERIC: A generic error for problems with movie files. 45 * @BVW_ERROR_FILE_PERMISSION: Permission was refused to access the stream, or authentication was required. 46 * @BVW_ERROR_FILE_ENCRYPTED: The stream is encrypted and cannot be played. 47 * @BVW_ERROR_FILE_NOT_FOUND: The stream cannot be found. 48 * @BVW_ERROR_DVD_ENCRYPTED: The DVD is encrypted and libdvdcss is not installed. 49 * @BVW_ERROR_INVALID_DEVICE: The device given in an MRL (e.g. DVD drive or DVB tuner) did not exist. 50 * @BVW_ERROR_UNKNOWN_HOST: The host for a given stream could not be resolved. 51 * @BVW_ERROR_NETWORK_UNREACHABLE: The host for a given stream could not be reached. 52 * @BVW_ERROR_CONNECTION_REFUSED: The server for a given stream refused the connection. 53 * @BVW_ERROR_INVALID_LOCATION: An MRL was malformed, or CDDB playback was attempted (which is now unsupported). 54 * @BVW_ERROR_GENERIC: A generic error occurred. 55 * @BVW_ERROR_CODEC_NOT_HANDLED: The audio or video codec required by the stream is not supported. 56 * @BVW_ERROR_CANNOT_CAPTURE: Error determining frame capture support for a video with bacon_video_widget_can_get_frames(). 57 * @BVW_ERROR_READ_ERROR: A generic error for problems reading streams. 58 * @BVW_ERROR_PLUGIN_LOAD: A library or plugin could not be loaded. 59 * @BVW_ERROR_EMPTY_FILE: A movie file was empty. 60 * 61 * Error codes for #BaconVideoWidget operations. 62 **/ 63 typedef enum { 64 /* Plugins */ 65 BVW_ERROR_NO_PLUGIN_FOR_FILE, 66 /* File */ 67 BVW_ERROR_BROKEN_FILE, 68 BVW_ERROR_FILE_GENERIC, 69 BVW_ERROR_FILE_PERMISSION, 70 BVW_ERROR_FILE_ENCRYPTED, 71 BVW_ERROR_FILE_NOT_FOUND, 72 /* Devices */ 73 BVW_ERROR_DVD_ENCRYPTED, 74 BVW_ERROR_INVALID_DEVICE, 75 /* Network */ 76 BVW_ERROR_UNKNOWN_HOST, 77 BVW_ERROR_NETWORK_UNREACHABLE, 78 BVW_ERROR_CONNECTION_REFUSED, 79 /* Generic */ 80 BVW_ERROR_INVALID_LOCATION, 81 BVW_ERROR_GENERIC, 82 BVW_ERROR_CODEC_NOT_HANDLED, 83 BVW_ERROR_CANNOT_CAPTURE, 84 BVW_ERROR_READ_ERROR, 85 BVW_ERROR_PLUGIN_LOAD, 86 BVW_ERROR_EMPTY_FILE 87 } BvwError; 88 89 GQuark bacon_video_widget_error_quark (void) G_GNUC_CONST; 90 GType bacon_video_widget_get_type (void); 91 GOptionGroup* bacon_video_widget_get_option_group (void); 92 93 GtkWidget *bacon_video_widget_new (GError **error); 94 95 /* Actions */ 96 void bacon_video_widget_open (BaconVideoWidget *bvw, 97 const char *mrl); 98 gboolean bacon_video_widget_play (BaconVideoWidget *bvw, 99 GError **error); 100 void bacon_video_widget_pause (BaconVideoWidget *bvw); 101 gboolean bacon_video_widget_is_playing (BaconVideoWidget *bvw); 102 103 /* Seeking and length */ 104 gboolean bacon_video_widget_is_seekable (BaconVideoWidget *bvw); 105 gboolean bacon_video_widget_seek (BaconVideoWidget *bvw, 106 double position, 107 GError **error); 108 gboolean bacon_video_widget_seek_time (BaconVideoWidget *bvw, 109 gint64 _time, 110 gboolean accurate, 111 GError **error); 112 gboolean bacon_video_widget_step (BaconVideoWidget *bvw, 113 gboolean forward, 114 GError **error); 115 gboolean bacon_video_widget_can_direct_seek (BaconVideoWidget *bvw); 116 double bacon_video_widget_get_position (BaconVideoWidget *bvw); 117 gint64 bacon_video_widget_get_current_time (BaconVideoWidget *bvw); 118 gint64 bacon_video_widget_get_stream_length (BaconVideoWidget *bvw); 119 120 void bacon_video_widget_stop (BaconVideoWidget *bvw); 121 void bacon_video_widget_close (BaconVideoWidget *bvw); 122 123 /* Audio volume */ 124 gboolean bacon_video_widget_can_set_volume (BaconVideoWidget *bvw); 125 void bacon_video_widget_set_volume (BaconVideoWidget *bvw, 126 double volume); 127 double bacon_video_widget_get_volume (BaconVideoWidget *bvw); 128 129 /* Properties */ 130 void bacon_video_widget_set_text_subtitle (BaconVideoWidget * bvw, 131 const gchar * subtitle_uri); 132 void bacon_video_widget_set_logo (BaconVideoWidget *bvw, 133 const char *name); 134 void bacon_video_widget_set_logo_mode (BaconVideoWidget *bvw, 135 gboolean logo_mode); 136 gboolean bacon_video_widget_get_logo_mode (BaconVideoWidget *bvw); 137 138 void bacon_video_widget_set_subtitle_font (BaconVideoWidget *bvw, 139 const char *font); 140 void bacon_video_widget_set_subtitle_encoding (BaconVideoWidget *bvw, 141 const char *encoding); 142 143 void bacon_video_widget_set_user_agent (BaconVideoWidget *bvw, 144 const char *user_agent); 145 146 void bacon_video_widget_set_referrer (BaconVideoWidget *bvw, 147 const char *referrer); 148 149 gboolean bacon_video_widget_set_rate (BaconVideoWidget *bvw, 150 gfloat new_rate); 151 gfloat bacon_video_widget_get_rate (BaconVideoWidget *bvw); 152 153 void bacon_video_widget_set_fullscreen (BaconVideoWidget *bvw, 154 gboolean fullscreen); 155 156 /* Metadata */ 157 /** 158 * BvwMetadataType: 159 * @BVW_INFO_TITLE: the stream's title 160 * @BVW_INFO_ARTIST: the artist who created the work 161 * @BVW_INFO_YEAR: the year in which the work was created 162 * @BVW_INFO_COMMENT: a comment attached to the stream 163 * @BVW_INFO_ALBUM: the album in which the work was released 164 * @BVW_INFO_DURATION: the stream's duration, in seconds 165 * @BVW_INFO_TRACK_NUMBER: the track number of the work on the album 166 * @BVW_INFO_COVER: a #GdkPixbuf of the cover artwork 167 * @BVW_INFO_CONTAINER: the type of stream container 168 * @BVW_INFO_HAS_VIDEO: whether the stream has video 169 * @BVW_INFO_DIMENSION_X: the video's width, in pixels 170 * @BVW_INFO_DIMENSION_Y: the video's height, in pixels 171 * @BVW_INFO_VIDEO_BITRATE: the video's bitrate, in kilobits per second 172 * @BVW_INFO_VIDEO_CODEC: the video's codec 173 * @BVW_INFO_FPS: the number of frames per second in the video 174 * @BVW_INFO_HAS_AUDIO: whether the stream has audio 175 * @BVW_INFO_AUDIO_BITRATE: the audio's bitrate, in kilobits per second 176 * @BVW_INFO_AUDIO_CODEC: the audio's codec 177 * @BVW_INFO_AUDIO_SAMPLE_RATE: the audio sample rate, in bits per second 178 * @BVW_INFO_AUDIO_CHANNELS: a string describing the number of audio channels in the stream 179 * 180 * The different metadata available for querying from a #BaconVideoWidget 181 * stream with bacon_video_widget_get_metadata(). 182 **/ 183 typedef enum { 184 BVW_INFO_TITLE, 185 BVW_INFO_ARTIST, 186 BVW_INFO_YEAR, 187 BVW_INFO_COMMENT, 188 BVW_INFO_ALBUM, 189 BVW_INFO_DURATION, 190 BVW_INFO_TRACK_NUMBER, 191 BVW_INFO_COVER, 192 BVW_INFO_CONTAINER, 193 /* Video */ 194 BVW_INFO_HAS_VIDEO, 195 BVW_INFO_DIMENSION_X, 196 BVW_INFO_DIMENSION_Y, 197 BVW_INFO_VIDEO_BITRATE, 198 BVW_INFO_VIDEO_CODEC, 199 BVW_INFO_FPS, 200 /* Audio */ 201 BVW_INFO_HAS_AUDIO, 202 BVW_INFO_AUDIO_BITRATE, 203 BVW_INFO_AUDIO_CODEC, 204 BVW_INFO_AUDIO_SAMPLE_RATE, 205 BVW_INFO_AUDIO_CHANNELS 206 } BvwMetadataType; 207 208 void bacon_video_widget_get_metadata (BaconVideoWidget *bvw, 209 BvwMetadataType type, 210 GValue *value); 211 212 /* Picture settings */ 213 /** 214 * BvwVideoProperty: 215 * @BVW_VIDEO_BRIGHTNESS: the video brightness 216 * @BVW_VIDEO_CONTRAST: the video contrast 217 * @BVW_VIDEO_SATURATION: the video saturation 218 * @BVW_VIDEO_HUE: the video hue 219 * 220 * The video properties queryable with bacon_video_widget_get_video_property(), 221 * and settable with bacon_video_widget_set_video_property(). 222 **/ 223 typedef enum { 224 BVW_VIDEO_BRIGHTNESS, 225 BVW_VIDEO_CONTRAST, 226 BVW_VIDEO_SATURATION, 227 BVW_VIDEO_HUE 228 } BvwVideoProperty; 229 230 /** 231 * BvwAspectRatio: 232 * @BVW_RATIO_AUTO: automatic 233 * @BVW_RATIO_SQUARE: square (1:1) 234 * @BVW_RATIO_FOURBYTHREE: four-by-three (4:3) 235 * @BVW_RATIO_ANAMORPHIC: anamorphic (16:9) 236 * @BVW_RATIO_DVB: DVB (20:9) 237 * 238 * The pixel aspect ratios available in which to display videos using 239 * @bacon_video_widget_set_aspect_ratio(). 240 **/ 241 typedef enum { 242 BVW_RATIO_AUTO = 0, 243 BVW_RATIO_SQUARE = 1, 244 BVW_RATIO_FOURBYTHREE = 2, 245 BVW_RATIO_ANAMORPHIC = 3, 246 BVW_RATIO_DVB = 4 247 } BvwAspectRatio; 248 249 /** 250 * BvwZoomMode: 251 * @BVW_ZOOM_NONE: No video zooming/cropping 252 * @BVW_ZOOM_EXPAND: Fill area with video, and crop the excess 253 * 254 * The zoom mode used by the video widget, as set by 255 * bacon_video_widget_set_zoom(). 256 **/ 257 typedef enum { 258 BVW_ZOOM_NONE = 0, 259 BVW_ZOOM_EXPAND = 1 260 } BvwZoomMode; 261 262 /** 263 * BvwRotation: 264 * @BVW_ROTATION_R_ZERO: No rotation 265 * @BVW_ROTATION_R_90R: Rotate 90 degrees to the right 266 * @BVW_ROTATION_R_180: Rotate 180 degrees 267 * @BVW_ROTATION_R_90L: Rotate 90 degrees to the left 268 * 269 * The rotation is used by the video widget, as set by 270 * bacon_video_widget_set_rotation(). 271 **/ 272 typedef enum { 273 BVW_ROTATION_R_ZERO = 0, 274 BVW_ROTATION_R_90R = 1, 275 BVW_ROTATION_R_180 = 2, 276 BVW_ROTATION_R_90L = 3 277 } BvwRotation; 278 279 void bacon_video_widget_set_deinterlacing (BaconVideoWidget *bvw, 280 gboolean deinterlace); 281 gboolean bacon_video_widget_get_deinterlacing (BaconVideoWidget *bvw); 282 283 void bacon_video_widget_set_aspect_ratio (BaconVideoWidget *bvw, 284 BvwAspectRatio ratio); 285 BvwAspectRatio bacon_video_widget_get_aspect_ratio 286 (BaconVideoWidget *bvw); 287 288 void bacon_video_widget_set_zoom (BaconVideoWidget *bvw, 289 BvwZoomMode mode); 290 BvwZoomMode bacon_video_widget_get_zoom (BaconVideoWidget *bvw); 291 292 void bacon_video_widget_set_rotation (BaconVideoWidget *bvw, 293 BvwRotation rotation); 294 BvwRotation bacon_video_widget_get_rotation (BaconVideoWidget *bvw); 295 296 int bacon_video_widget_get_video_property (BaconVideoWidget *bvw, 297 BvwVideoProperty type); 298 void bacon_video_widget_set_video_property (BaconVideoWidget *bvw, 299 BvwVideoProperty type, 300 int value); 301 302 void bacon_video_widget_set_next_angle (BaconVideoWidget *bvw); 303 304 gboolean bacon_video_widget_has_menus (BaconVideoWidget *bvw); 305 gboolean bacon_video_widget_has_angles (BaconVideoWidget *bvw); 306 307 /* DVD functions */ 308 /** 309 * BvwDVDEvent: 310 * @BVW_DVD_ROOT_MENU: root menu 311 * @BVW_DVD_TITLE_MENU: title menu 312 * @BVW_DVD_SUBPICTURE_MENU: subpicture menu (if available) 313 * @BVW_DVD_AUDIO_MENU: audio menu (if available) 314 * @BVW_DVD_ANGLE_MENU: angle menu (if available) 315 * @BVW_DVD_CHAPTER_MENU: chapter menu 316 * @BVW_DVD_NEXT_CHAPTER: the next chapter 317 * @BVW_DVD_PREV_CHAPTER: the previous chapter 318 * @BVW_DVD_NEXT_TITLE: the next title in the current chapter 319 * @BVW_DVD_PREV_TITLE: the previous title in the current chapter 320 * @BVW_DVD_ROOT_MENU_UP: go up in the menu 321 * @BVW_DVD_ROOT_MENU_DOWN: go down in the menu 322 * @BVW_DVD_ROOT_MENU_LEFT: go left in the menu 323 * @BVW_DVD_ROOT_MENU_RIGHT: go right in the menu 324 * @BVW_DVD_ROOT_MENU_SELECT: select the current menu entry 325 * 326 * The DVD navigation actions available to fire as DVD events to 327 * the #BaconVideoWidget. 328 **/ 329 typedef enum { 330 BVW_DVD_ROOT_MENU, 331 BVW_DVD_TITLE_MENU, 332 BVW_DVD_SUBPICTURE_MENU, 333 BVW_DVD_AUDIO_MENU, 334 BVW_DVD_ANGLE_MENU, 335 BVW_DVD_CHAPTER_MENU, 336 BVW_DVD_NEXT_CHAPTER, 337 BVW_DVD_PREV_CHAPTER, 338 BVW_DVD_NEXT_TITLE, 339 BVW_DVD_PREV_TITLE, 340 BVW_DVD_ROOT_MENU_UP, 341 BVW_DVD_ROOT_MENU_DOWN, 342 BVW_DVD_ROOT_MENU_LEFT, 343 BVW_DVD_ROOT_MENU_RIGHT, 344 BVW_DVD_ROOT_MENU_SELECT 345 } BvwDVDEvent; 346 347 void bacon_video_widget_dvd_event (BaconVideoWidget *bvw, 348 BvwDVDEvent type); 349 350 /** 351 * BvwLangInfo: 352 * @language: the ISO-639 language code for the track, or "und" if unknown. 353 * Can never be %NULL. 354 * @codec: the codec for the track, or %NULL if unknown or unset. 355 * 356 * #BvwLangInfo holds the language code and codec for each subtitle 357 * or audio track for a media, which would allow the front-ends to 358 * present appropriate information to the user. 359 */ 360 typedef struct { 361 char *language; 362 char *codec; 363 } BvwLangInfo; 364 365 /** 366 * BvwTrackType: 367 * @BVW_TRACK_TYPE_AUDIO: an audio track 368 * @BVW_TRACK_TYPE_SUBTITLE: a subtitle track 369 * @BVW_TRACK_TYPE_VIDEO: a video track 370 * 371 * A type of media track. 372 */ 373 typedef enum { 374 BVW_TRACK_TYPE_AUDIO, 375 BVW_TRACK_TYPE_SUBTITLE, 376 BVW_TRACK_TYPE_VIDEO 377 } BvwTrackType; 378 379 void bacon_video_widget_lang_info_free (BvwLangInfo *info); 380 381 GList *bacon_video_widget_get_languages (BaconVideoWidget *bvw); 382 int bacon_video_widget_get_language (BaconVideoWidget *bvw); 383 void bacon_video_widget_set_language (BaconVideoWidget *bvw, 384 int language); 385 void bacon_video_widget_set_next_language (BaconVideoWidget *bvw); 386 387 GList *bacon_video_widget_get_subtitles (BaconVideoWidget *bvw); 388 int bacon_video_widget_get_subtitle (BaconVideoWidget *bvw); 389 void bacon_video_widget_set_subtitle (BaconVideoWidget *bvw, 390 int subtitle); 391 void bacon_video_widget_set_next_subtitle (BaconVideoWidget *bvw); 392 393 gboolean bacon_video_widget_has_next_track (BaconVideoWidget *bvw); 394 gboolean bacon_video_widget_has_previous_track (BaconVideoWidget *bvw); 395 396 /* Screenshot functions */ 397 gboolean bacon_video_widget_can_get_frames (BaconVideoWidget *bvw, 398 GError **error); 399 GdkPixbuf *bacon_video_widget_get_current_frame (BaconVideoWidget *bvw); 400 401 /* Audio-out functions */ 402 /** 403 * BvwAudioOutputType: 404 * @BVW_AUDIO_SOUND_STEREO: stereo output 405 * @BVW_AUDIO_SOUND_4CHANNEL: 4-channel output 406 * @BVW_AUDIO_SOUND_41CHANNEL: 4.1-channel output 407 * @BVW_AUDIO_SOUND_5CHANNEL: 5-channel output 408 * @BVW_AUDIO_SOUND_51CHANNEL: 5.1-channel output 409 * @BVW_AUDIO_SOUND_AC3PASSTHRU: AC3 passthrough output 410 * 411 * The audio output types available for use with bacon_video_widget_set_audio_output_type(). 412 **/ 413 typedef enum { 414 BVW_AUDIO_SOUND_STEREO, 415 BVW_AUDIO_SOUND_4CHANNEL, 416 BVW_AUDIO_SOUND_41CHANNEL, 417 BVW_AUDIO_SOUND_5CHANNEL, 418 BVW_AUDIO_SOUND_51CHANNEL, 419 BVW_AUDIO_SOUND_AC3PASSTHRU 420 } BvwAudioOutputType; 421 422 BvwAudioOutputType bacon_video_widget_get_audio_output_type 423 (BaconVideoWidget *bvw); 424 void bacon_video_widget_set_audio_output_type (BaconVideoWidget *bvw, 425 BvwAudioOutputType type); 426 427 /* OSD */ 428 void bacon_video_widget_show_popup (BaconVideoWidget *bvw); 429 void bacon_video_widget_mark_popup_busy (BaconVideoWidget *bvw, 430 const char *reason); 431 void bacon_video_widget_unmark_popup_busy (BaconVideoWidget *bvw, 432 const char *reason); 433 434 GObject * bacon_video_widget_get_controls_object (BaconVideoWidget *bvw); 435 GObject * bacon_video_widget_get_header_controls_object (BaconVideoWidget *bvw); 436