diff options
Diffstat (limited to 'include')
42 files changed, 8082 insertions, 183 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index b0a7e6a91..e9bd4356a 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,32 +1,56 @@ -EXTRA_DIST = xine.h.in +include $(top_srcdir)/misc/Makefile.quiet +EXTRA_DIST = xine/version.h.in if GENERATED_INTTYPES_H inttypes_h = inttypes.h endif -include_HEADERS = xine.h +nobase_include_HEADERS = xine.h \ + xine/alphablend.h \ + xine/array.h \ + xine/attributes.h \ + xine/audio_decoder.h \ + xine/audio_out.h \ + xine/broadcaster.h \ + xine/buffer.h \ + xine/compat.h \ + xine/configfile.h \ + xine/demux.h \ + xine/info_helper.h \ + xine/input_plugin.h \ + xine/io_helper.h \ + xine/list.h \ + xine/metronom.h \ + xine/os_types.h \ + xine/osd.h \ + xine/plugin_catalog.h \ + xine/pool.h \ + xine/post.h \ + xine/refcounter.h \ + xine/resample.h \ + xine/ring_buffer.h \ + xine/scratch.h \ + xine/sorted_array.h \ + xine/spu.h \ + xine/spu_decoder.h \ + xine/vdr.h \ + xine/version.h \ + xine/video_decoder.h \ + xine/video_out.h \ + xine/video_overlay.h \ + xine/vo_scale.h \ + xine/xine_buffer.h \ + xine/xine_internal.h \ + xine/xine_plugin.h \ + xine/xineintl.h \ + xine/xineutils.h \ + xine/xmllexer.h \ + xine/xmlparser.h noinst_HEADERS = config.h nodist_noinst_HEADERS = configure.h -CONFIG_CLEAN_FILES = xine.h $(inttypes_h) +nodist_include_HEADERS = $(inttypes_h) -debug: - @$(MAKE) CFLAGS="$(DEBUG_CFLAGS)" - -install-debug: debug - @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am - -mostlyclean-generic: - -rm -f *~ \#* .*~ .\#* - -maintainer-clean-generic: - -@echo "This command is intended for maintainers to use;" - -@echo "it deletes files that may require special tools to rebuild." - -rm -f Makefile.in configure.h.in - -install-data-local: install-includeHEADERS - sed -e '/^\/\*_x_/d' xine.h > $(DESTDIR)$(includedir)/xine.h -if GENERATED_INTTYPES_H - $(INSTALL) inttypes.h $(DESTDIR)$(includedir) -endif +CONFIG_CLEAN_FILES = $(inttypes_h) +DISTCLEANFILES = xine/version.h diff --git a/include/xine.h.in b/include/xine.h index 422029754..19731e820 100644 --- a/include/xine.h.in +++ b/include/xine.h @@ -55,13 +55,9 @@ extern "C" { #include <windowsx.h> #endif -#ifdef XINE_COMPILE -#include <inttypes.h> -#include "attributes.h" -#else #include <xine/os_types.h> #include <xine/attributes.h> -#endif +#include <xine/version.h> /* This enables some experimental features. These are not part of the * official libxine API, so use them only, if you absolutely need them. @@ -87,13 +83,6 @@ typedef struct xine_stream_s xine_stream_t; typedef struct xine_audio_port_s xine_audio_port_t; typedef struct xine_video_port_s xine_video_port_t; -#ifndef XINE_DISABLE_DEPRECATED_FEATURES -/* convenience types: simple player UIs might want to call ports drivers */ -typedef xine_audio_port_t xine_ao_driver_t XINE_DEPRECATED; -typedef xine_video_port_t xine_vo_driver_t XINE_DEPRECATED; -#endif - - /********************************************************************* * global engine handling * *********************************************************************/ @@ -110,12 +99,6 @@ void xine_get_version (int *major, int *minor, int *sub) XINE_PROTECTED; return 1 if compatible, 0 otherwise */ int xine_check_version (int major, int minor, int sub) XINE_PROTECTED; -/* static info - which libxine release this header came from */ -#define XINE_MAJOR_VERSION @XINE_MAJOR@ -#define XINE_MINOR_VERSION @XINE_MINOR@ -#define XINE_SUB_VERSION @XINE_SUB@ -#define XINE_VERSION "@VERSION@" - /* * pre-init the xine engine * @@ -260,22 +243,6 @@ int xine_open (xine_stream_t *stream, const char *mrl) XINE_PROTECTED; int xine_play (xine_stream_t *stream, int start_pos, int start_time) XINE_PROTECTED; /* - * set xine to a trick mode for fast forward, backwards playback, - * low latency seeking. Please note that this works only with some - * input plugins. mode constants see below. - * - * returns 1 if OK, 0 on error (use xine_get_error for details) - */ -int xine_trick_mode (xine_stream_t *stream, int mode, int value) XINE_PROTECTED XINE_DEPRECATED; - -/* trick modes */ -#define XINE_TRICK_MODE_OFF 0 -#define XINE_TRICK_MODE_SEEK_TO_POSITION 1 -#define XINE_TRICK_MODE_SEEK_TO_TIME 2 -#define XINE_TRICK_MODE_FAST_FORWARD 3 -#define XINE_TRICK_MODE_FAST_REWIND 4 - -/* * stop stream playback * xine_stream_t stays valid for new xine_open or xine_play */ @@ -304,7 +271,7 @@ void xine_dispose (xine_stream_t *stream) XINE_PROTECTED; */ void xine_engine_set_param(xine_t *self, int param, int value) XINE_PROTECTED; int xine_engine_get_param(xine_t *self, int param) XINE_PROTECTED; - + #define XINE_ENGINE_PARAM_VERBOSITY 1 /* @@ -346,7 +313,7 @@ int xine_get_param (xine_stream_t *stream, int param) XINE_PROTECTED; #define XINE_PARAM_EQ_16000HZ 27 /* equalizer gains -100..100 */ #define XINE_PARAM_AUDIO_CLOSE_DEVICE 28 /* force closing audio device */ #define XINE_PARAM_AUDIO_AMP_MUTE 29 /* 1=>mute, 0=>unmute */ -#define XINE_PARAM_FINE_SPEED 30 /* 1.000.000 => normal speed */ +#define XINE_PARAM_FINE_SPEED 30 /* 1.000.000 => normal speed */ #define XINE_PARAM_EARLY_FINISHED_EVENT 31 /* send event when demux finish*/ #define XINE_PARAM_GAPLESS_SWITCH 32 /* next stream only gapless swi*/ #define XINE_PARAM_DELAY_FINISHED_EVENT 33 /* 1/10sec,0=>disable,-1=>forev*/ @@ -364,7 +331,7 @@ int xine_get_param (xine_stream_t *stream, int param) XINE_PROTECTED; #define XINE_SPEED_NORMAL 4 #define XINE_SPEED_FAST_2 8 #define XINE_SPEED_FAST_4 16 - + /* normal speed value for XINE_PARAM_FINE_SPEED parameter */ #define XINE_FINE_SPEED_NORMAL 1000000 @@ -382,12 +349,13 @@ int xine_get_param (xine_stream_t *stream, int param) XINE_PROTECTED; #define XINE_PARAM_VO_TVMODE 0x0100000a /* ??? */ #define XINE_PARAM_VO_WINDOW_WIDTH 0x0100000f /* readonly */ #define XINE_PARAM_VO_WINDOW_HEIGHT 0x01000010 /* readonly */ +#define XINE_PARAM_VO_SHARPNESS 0x01000018 /* 0..65535 */ +#define XINE_PARAM_VO_NOISE_REDUCTION 0x01000019 /* 0..65535 */ #define XINE_PARAM_VO_CROP_LEFT 0x01000020 /* crop frame pixels */ #define XINE_PARAM_VO_CROP_RIGHT 0x01000021 /* crop frame pixels */ #define XINE_PARAM_VO_CROP_TOP 0x01000022 /* crop frame pixels */ #define XINE_PARAM_VO_CROP_BOTTOM 0x01000023 /* crop frame pixels */ - #define XINE_VO_ZOOM_STEP 100 #define XINE_VO_ZOOM_MAX 400 #define XINE_VO_ZOOM_MIN -85 @@ -426,7 +394,7 @@ int xine_get_param (xine_stream_t *stream, int param) XINE_PROTECTED; * image format can be YUV 4:2:0 or 4:2:2 * will copy the image data into memory that <img> points to * (interleaved for yuv 4:2:2 or planary for 4:2:0) - * + * * xine_get_current_frame() requires that <img> must be able * to hold the image data. Use a NULL pointer to retrieve the * necessary parameters for calculating the buffer size. Be @@ -440,7 +408,7 @@ int xine_get_param (xine_stream_t *stream, int param) XINE_PROTECTED; * xine_get_current_frame_alloc() takes care of allocating * a buffer on its own, so image data can be retrieved by * a single call without the need to pause the stream. - * + * * xine_get_current_frame_data() passes the parameters of the * previously mentioned functions plus further information in * a structure and can work like the _s or _alloc function @@ -489,6 +457,7 @@ int xine_get_current_frame_data (xine_stream_t *stream, #define XINE_IMGFMT_YUY2 (('2'<<24)|('Y'<<16)|('U'<<8)|'Y') #define XINE_IMGFMT_XVMC (('C'<<24)|('M'<<16)|('v'<<8)|'X') #define XINE_IMGFMT_XXMC (('C'<<24)|('M'<<16)|('x'<<8)|'X') +#define XINE_IMGFMT_VDPAU (('A'<<24)|('P'<<16)|('D'<<8)|'V') /* get current xine's virtual presentation timestamp (1/90000 sec) * note: this is mostly internal data. @@ -497,6 +466,83 @@ int xine_get_current_frame_data (xine_stream_t *stream, int64_t xine_get_current_vpts(xine_stream_t *stream) XINE_PROTECTED; +/* + * Continuous video frame grabbing feature. + * + * In opposite to the 'xine_get_current_frame' based snapshot function this grabbing + * feature allow continuous grabbing of last or next displayed video frame. + * Grabbed video frames are returned in simple three byte RGB format. + * + * Depending on the capabilities of the used video output driver video image data is + * taken as close as possible at the end of the video processing chain. Thus a returned + * video image could contain the blended OSD data, is deinterlaced, cropped and scaled + * and video properties like hue, sat could be applied. + * If a video output driver does not have a decent grabbing implementation then there + * is a generic fallback feature that grabs the video frame as they are taken from the video + * display queue (like the xine_get_current_frame' function). + * In this case color correct conversation to a RGB image incorporating source cropping + * and scaling to the requested grab size is also supported. + * + * The caller must first request a new video grab frame using the public 'xine_new_grab_video_frame' + * function. Then the caller should populate the frame with the wanted source cropping, grab image + * size and control flags. After that grab requests could be done by calling the supplied grab() feature + * of the frame. At the end a call to the supplied dispose() feature of the frame releases all needed + * resources. + * The caller should have acquired a port ticket while calling these features. + * + */ +#define HAVE_XINE_GRAB_VIDEO_FRAME 1 + +/* + * frame structure used for grabbing video frames of format RGB. + */ +typedef struct xine_grab_video_frame_s xine_grab_video_frame_t; +struct xine_grab_video_frame_s { + /* + * grab last/next displayed image. + * returns 0 if grab is successful, 1 on timeout and -1 on error + */ + int (*grab) (xine_grab_video_frame_t *self); + + /* + * free all resources. + */ + void (*dispose) (xine_grab_video_frame_t *self); + + /* + * Cropping of source image. Has to be specified by caller. + */ + int crop_left; + int crop_right; + int crop_top; + int crop_bottom; + + /* + * Parameters of returned RGB image. + * Caller can specify wanted frame size giving width and/or height a value > 0. + * In this case the grabbed image is scaled to the requested size. + * Otherwise the grab function returns the actual size of the grabbed image + * in width/height without scaling the image. + */ + int width, height; /* requested/returned size of image */ + uint8_t *img; /* returned RGB image data taking three bytes per pixel */ + int64_t vpts; /* virtual presentation timestamp (1/90000 sec) of returned frame */ + + int timeout; /* Max. time to wait for next displayed frame in milliseconds */ + int flags; /* Controlling flags. See XINE_GRAB_VIDEO_FRAME_FLAGS_* definitions */ +}; + +#define XINE_GRAB_VIDEO_FRAME_FLAGS_CONTINUOUS 0x01 /* optimize resource allocation for continuous frame grabbing */ +#define XINE_GRAB_VIDEO_FRAME_FLAGS_WAIT_NEXT 0x02 /* wait for next display frame instead of using last displayed frame */ + +#define XINE_GRAB_VIDEO_FRAME_DEFAULT_TIMEOUT 500 + +/* + * Allocate new grab video frame. Returns NULL on error. + */ +xine_grab_video_frame_t* xine_new_grab_video_frame (xine_stream_t *stream) XINE_PROTECTED; + + /********************************************************************* * media processing * *********************************************************************/ @@ -522,17 +568,17 @@ typedef struct { int64_t vpts; /* timestamp 1/90000 sec for a/v sync */ int64_t duration; + double aspect_ratio; int width, height; int colorspace; /* XINE_IMGFMT_* */ - double aspect_ratio; int pos_stream; /* bytes from stream start */ int pos_time; /* milliseconds */ + int frame_number; /* frame number (may be unknown) */ + uint8_t *data; void *xine_frame; /* used internally by xine engine */ - - int frame_number; /* frame number (may be unknown) */ } xine_video_frame_t; int xine_get_next_video_frame (xine_video_port_t *port, @@ -550,11 +596,11 @@ typedef struct { int num_channels; int bits_per_sample; /* per channel */ - off_t pos_stream; /* bytes from stream start */ - int pos_time; /* milliseconds */ - uint8_t *data; void *xine_frame; /* used internally by xine engine */ + + off_t pos_stream; /* bytes from stream start */ + int pos_time; /* milliseconds */ } xine_audio_frame_t; int xine_get_next_audio_frame (xine_audio_port_t *port, @@ -562,20 +608,6 @@ int xine_get_next_audio_frame (xine_audio_port_t *port, void xine_free_audio_frame (xine_audio_port_t *port, xine_audio_frame_t *frame) XINE_PROTECTED; - /* - * maybe future aproach: - */ - -int xine_get_video_frame (xine_stream_t *stream, - int timestamp, /* msec */ - int *width, int *height, - int *ratio_code, - int *duration, /* msec */ - int *format, - uint8_t *img) XINE_PROTECTED XINE_DEPRECATED; - -/* TODO: xine_get_audio_frame */ - #endif @@ -600,18 +632,18 @@ struct xine_post_s { * pass them to the initialization of streams */ xine_audio_port_t **audio_input; - + /* a NULL-terminated array of video input ports this post plugin * provides; you can hand these to other post plugin's outputs or * pass them to the initialization of streams */ xine_video_port_t **video_input; - + /* the type of the post plugin * one of XINE_POST_TYPE_* can be used here */ int type; - + }; /* @@ -633,7 +665,7 @@ xine_post_t *xine_post_init(xine_t *xine, const char *name, const char *const *xine_list_post_plugins(xine_t *xine) XINE_PROTECTED; /* get a list of all post plugins of one type */ -const char *const *xine_list_post_plugins_typed(xine_t *xine, int type) XINE_PROTECTED; +const char *const *xine_list_post_plugins_typed(xine_t *xine, uint32_t type) XINE_PROTECTED; /* * post plugin input/output @@ -651,28 +683,25 @@ struct xine_post_in_s { /* the name identifying this input */ const char *name; - - /* the datatype of this input, use one of XINE_POST_DATA_* here */ - int type; - + /* the data pointer; input is directed to this memory location, * so you simply access the pointer to access the input data */ void *data; - + + /* the datatype of this input, use one of XINE_POST_DATA_* here */ + int type; + }; struct xine_post_out_s { /* the name identifying this output */ const char *name; - - /* the datatype of this output, use one of XINE_POST_DATA_* here */ - int type; - + /* the data pointer; output should be directed to this memory location, * so in the easy case you simply write through the pointer */ void *data; - + /* this function is called, when the output should be redirected * to another input, you sould set the data pointer to direct * any output to this new input; @@ -684,6 +713,9 @@ struct xine_post_out_s { * if you do not implement rewiring, set this to NULL */ int (*rewire) (xine_post_out_t *self, void *data); + /* the datatype of this output, use one of XINE_POST_DATA_* here */ + int type; + }; /* get a list of all inputs of a post plugin */ @@ -782,14 +814,14 @@ void xine_post_dispose(xine_t *xine, xine_post_t *self) XINE_PROTECTED; /* defines a single parameter entry. */ typedef struct { int type; /* POST_PARAM_TYPE_xxx */ - char *name; /* name of this parameter */ + const char *name; /* name of this parameter */ int size; /* sizeof(parameter) */ int offset; /* offset in bytes from struct ptr */ char **enum_values; /* enumeration (first=0) or NULL */ double range_min; /* minimum value */ double range_max; /* maximum value */ int readonly; /* 0 = read/write, 1=read-only */ - char *description; /* user-friendly description */ + const char *description; /* user-friendly description */ } xine_post_api_parameter_t; /* description of parameters struct (params). */ @@ -1035,8 +1067,8 @@ typedef struct { char *origin; /* file plugin: path */ char *mrl; /* <type>://<location> */ char *link; - uint32_t type; /* see below */ off_t size; /* size of this source, may be 0 */ + uint32_t type; /* see below */ } xine_mrl_t; /* mrl types */ @@ -1079,9 +1111,9 @@ xine_mrl_t **xine_get_browse_mrls (xine_t *self, const char *const *xine_get_autoplay_input_plugin_ids (xine_t *self) XINE_PROTECTED; /* get autoplay MRL list from input plugin named <plugin_id> */ -char **xine_get_autoplay_mrls (xine_t *self, - const char *plugin_id, - int *num_mrls) XINE_PROTECTED; +const char * const *xine_get_autoplay_mrls (xine_t *self, + const char *plugin_id, + int *num_mrls) XINE_PROTECTED; /* get a list of file extensions for file types supported by xine * the list is separated by spaces @@ -1145,12 +1177,6 @@ void xine_plugins_garbage_collector(xine_t *self) XINE_PROTECTED; * visual specific gui <-> xine engine communication * *********************************************************************/ -#ifndef XINE_DISABLE_DEPRECATED_FEATURES -/* talk to video output driver - old method */ -int xine_gui_send_vo_data (xine_stream_t *self, - int type, void *data) XINE_PROTECTED XINE_DEPRECATED; -#endif - /* new (preferred) method to talk to video driver. */ int xine_port_send_gui_data (xine_video_port_t *vo, int type, void *data) XINE_PROTECTED; @@ -1436,7 +1462,7 @@ typedef struct { HWND WndHnd; /* handle of window associated with primary surface */ HINSTANCE HInst; /* handle of windows application instance */ - RECT WndRect; /* rect of window client points translated to screen + RECT WndRect; /* rect of window client points translated to screen * cooridnates */ int FullScreen; /* is window fullscreen */ HBRUSH Brush; /* window brush for background color */ @@ -1500,12 +1526,12 @@ typedef struct { #define CHECK_XV 6 struct xine_health_check_s { - int status; const char* cdrom_dev; const char* dvd_dev; - char* msg; - char* title; - char* explanation; + const char* msg; + const char* title; + const char* explanation; + int status; }; typedef struct xine_health_check_s xine_health_check_t; @@ -1527,7 +1553,7 @@ xine_health_check_t* xine_health_check(xine_health_check_t*, int check_num) XINE #define XINE_CONFIG_TYPE_NUM 4 #define XINE_CONFIG_TYPE_BOOL 5 -/* For the string type (1.1.4 and later). These are stored in num_value. */ +/* For the string type (1.1.4 and later). These are stored in num_value. */ #define XINE_CONFIG_STRING_IS_STRING 0 #define XINE_CONFIG_STRING_IS_FILENAME 1 #define XINE_CONFIG_STRING_IS_DEVICE_NAME 2 @@ -1542,17 +1568,17 @@ struct xine_cfg_entry_s { int type; + /* user experience level */ + int exp_level; /* 0 => beginner, + 10 => advanced user, + 20 => expert */ + /* type unknown */ char *unknown_value; /* type string */ char *str_value; char *str_default; -#ifndef XINE_DISABLE_DEPRECATED_FEATURES - char *str_sticky; -#else - void *dummy; -#endif /* common to range, enum, num, bool; * num_value is also used by string to indicate what's required: @@ -1575,11 +1601,6 @@ struct xine_cfg_entry_s { const char *description; const char *help; - /* user experience level */ - int exp_level; /* 0 => beginner, - 10 => advanced user, - 20 => expert */ - /* callback function and data for live changeable values */ /* some config entries will take effect immediately, although they * do not have a callback registered; such values will have some @@ -1823,12 +1844,13 @@ void xine_config_reset (xine_t *self) XINE_PROTECTED; * xine event struct */ typedef struct { - int type; /* event type (constants see above) */ xine_stream_t *stream; /* stream this event belongs to */ void *data; /* contents depending on type */ int data_length; + int type; /* event type (constants see above) */ + /* you do not have to provide this, it will be filled in by xine_event_send() */ struct timeval tv; /* timestamp of event creation */ } xine_event_t; @@ -1933,8 +1955,8 @@ typedef struct { * mrl reference data is sent by demuxers when a reference stream is found. * this stream just contains pointers (urls) to the real data, which are * passed to frontend using this event type. (examples: .asx, .mov and .ram) - * - * ideally, frontends should add these mrls to a "hierarchical playlist". + * + * ideally, frontends should add these mrls to a "hierarchical playlist". * that is, instead of the original file, the ones provided here should be * played instead. on pratice, just using a simple playlist should work. * @@ -1950,7 +1972,7 @@ typedef struct { * 2) http://another/another.avi * * 1 and 2 are the original items on this playlist. 1a and 1b were received - * by events (they are the mrl references enclosed in 1). 1a is played after + * by events (they are the mrl references enclosed in 1). 1a is played after * receiving the finished event from 1. note: 1b is usually ignored, it should * only be used in case 1a fails to open. * @@ -1970,12 +1992,12 @@ typedef struct { /*const char title[]; ** immediately follows MRL's terminating NUL */ } xine_mrl_reference_data_ext_t; -/* +/* * configuration options for video4linux-like input plugins */ typedef struct { /* input selection */ - int input; /* select active input from card */ + int input; /* select active input from card */ int channel; /* channel number */ int radio; /* ask for a radio channel */ uint32_t frequency; /* frequency divided by 62.5KHz or 62.5 Hz */ @@ -1992,13 +2014,13 @@ typedef struct { int frame_height; /* scaled frame height */ /* let some spare space so we can add new fields without breaking - * binary api compatibility. + * binary api compatibility. */ uint32_t spare[20]; /* used by pvr plugin */ int32_t session_id; /* -1 stops pvr recording */ - + } xine_set_v4l2_data_t; /* @@ -2015,7 +2037,7 @@ typedef struct { int gop_closure; /* open/closed GOP */ int b_frames; /* number of B frames to use */ int aspect_ratio; /* XINE_VO_ASPECT_xxx */ - + /* let some spare space so we can add new fields without breaking * binary api compatibility. */ @@ -2030,7 +2052,7 @@ typedef struct { #ifdef XINE_ENABLE_EXPERIMENTAL_FEATURES -/* +/* * ask pvr to save (ie. do not discard) the current session * see comments on input_pvr.c to understand how it works. */ @@ -2041,7 +2063,7 @@ typedef struct { * 1 = save from last sync point * 2 = save everything on current session */ - int mode; + int mode; int id; char name[256]; /* name for saving, might be longer */ } xine_pvr_save_data_t; @@ -2051,7 +2073,7 @@ typedef struct { * 0 = non realtime * 1 = realtime */ - int mode; + int mode; } xine_pvr_realtime_t; typedef struct { @@ -2082,7 +2104,7 @@ typedef struct { * Defined message types for XINE_EVENT_UI_MESSAGE * This is the mechanism to report async errors from engine. * - * If frontend knows about the XINE_MSG_xxx type it may safely + * If frontend knows about the XINE_MSG_xxx type it may safely * ignore the 'explanation' field and provide its own custom * dialogue to the 'parameters'. * @@ -2103,6 +2125,7 @@ typedef struct { #define XINE_MSG_AUDIO_OUT_UNAVAILABLE 11 /* none */ #define XINE_MSG_PERMISSION_ERROR 12 /* (file name or mrl) */ #define XINE_MSG_FILE_EMPTY 13 /* file is empty */ +#define XINE_MSG_AUTHENTICATION_NEEDED 14 /* (mrl, likely http) */ /* opaque xine_event_queue_t */ typedef struct xine_event_queue_s xine_event_queue_t; @@ -2176,8 +2199,11 @@ void xine_event_send (xine_stream_t *stream, const xine_event_t *event) XINE_PRO /* yellow text, black border, transparent background */ #define XINE_TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3 -#define XINE_OSD_CAP_FREETYPE2 0x0001 /* freetype2 support compiled in */ -#define XINE_OSD_CAP_UNSCALED 0x0002 /* unscaled overlays supp. by vo drv */ +#define XINE_OSD_CAP_FREETYPE2 0x0001 /* freetype2 support compiled in */ +#define XINE_OSD_CAP_UNSCALED 0x0002 /* unscaled overlays supp. by vo drv */ +#define XINE_OSD_CAP_CUSTOM_EXTENT 0x0004 /* hardware scaled to match video output window */ +#define XINE_OSD_CAP_ARGB_LAYER 0x0008 /* supports ARGB true color pixmaps */ +#define XINE_OSD_CAP_VIDEO_WINDOW 0x0010 /* can scale video to an area within osd extent */ typedef struct xine_osd_s xine_osd_t; @@ -2205,7 +2231,7 @@ void xine_osd_get_text_size (xine_osd_t *self, const char *text, as 'fontname' here */ int xine_osd_set_font (xine_osd_t *self, const char *fontname, int size) XINE_PROTECTED; -/* +/* * specifying encoding of texts * "" ... means current locale encoding (default) * NULL ... means latin1 @@ -2242,56 +2268,40 @@ void xine_osd_get_palette (xine_osd_t *self, uint32_t *color, void xine_osd_set_palette (xine_osd_t *self, const uint32_t *const color, const uint8_t *const trans ) XINE_PROTECTED; + /* - * close osd rendering engine - * loaded fonts are unloaded - * osd objects are closed + * Set an ARGB buffer to be blended into video. + * The buffer must stay valid while the OSD is on screen. + * Pass a NULL pointer to safely remove the buffer from + * the OSD layer. Only the dirty area will be + * updated on screen. For convenience the whole + * OSD object will be considered dirty when setting + * a different buffer pointer. + * see also XINE_OSD_CAP_ARGB_LAYER */ -void xine_osd_free (xine_osd_t *self) XINE_PROTECTED; - - -#ifndef XINE_DISABLE_DEPRECATED_FEATURES - -/********************************************************************* - * TV-mode API, to make it possible to use nvtvd to view movies * - *********************************************************************/ - -/* These functions are just dummies to maintain API compatibility. - * You should use libnvtvsimple in your frontend instead. */ - -typedef enum { - XINE_TVSYSTEM_PAL = 0, - XINE_TVSYSTEM_NTSC -} xine_tvsystem XINE_DEPRECATED; - -/* connect to nvtvd server and save current TV and X settings */ -int xine_tvmode_init (xine_t *self) XINE_PROTECTED XINE_DEPRECATED; +void xine_osd_set_argb_buffer(xine_osd_t *self, uint32_t *argb_buffer, + int dirty_x, int dirty_y, int dirty_width, int dirty_height) XINE_PROTECTED; -/* Turn tvmode on/off (1/0)*/ -int xine_tvmode_use(xine_t *self, int use_tvmode) XINE_PROTECTED XINE_DEPRECATED; - -/* Set which tv system to use: XINE_TVSYSTEM_PAL or XINE_TVSYSTEM_NTSC */ -void xine_tvmode_set_tvsystem(xine_t *self, xine_tvsystem system) XINE_PROTECTED XINE_DEPRECATED; - -/* try to change TV state if enabled - * type select 'regular' (0) or 'TV' (1) state - * width frame width the mode should match best or 0 if unknown - * height frame height the mode should match best or 0 if unknown - * fps frame rate the mode should match best or 0 if unknown - * returns: finally selected state +/* + * define extent of reference coordinate system + * for video resolution independent osds. + * see also XINE_OSD_CAP_CUSTOM_EXTENT */ -int xine_tvmode_switch (xine_t *self, int type, int width, int height, double fps) XINE_PROTECTED XINE_DEPRECATED; +void xine_osd_set_extent(xine_osd_t *self, int extent_width, int extent_height) XINE_PROTECTED; -/* adapt (maximum) output size to visible area if necessary and return pixel - * aspect and real frame rate if available +/* + * define area within osd extent to output + * video to while osd is on screen + * see also XINE_OSD_CAP_VIDEO_WINDOW */ -void xine_tvmode_size (xine_t *self, int *width, int *height, - double *pixelratio, double *fps) XINE_PROTECTED XINE_DEPRECATED; +void xine_osd_set_video_window(xine_osd_t *self, int window_x, int window_y, int window_width, int window_height) XINE_PROTECTED; -/* restore old TV and X settings and close nvtvd connection */ -void xine_tvmode_exit (xine_t *self) XINE_PROTECTED XINE_DEPRECATED; - -#endif +/* + * close osd rendering engine + * loaded fonts are unloaded + * osd objects are closed + */ +void xine_osd_free (xine_osd_t *self) XINE_PROTECTED; #ifdef __cplusplus } diff --git a/include/xine/alphablend.h b/include/xine/alphablend.h new file mode 100644 index 000000000..6df5ad809 --- /dev/null +++ b/include/xine/alphablend.h @@ -0,0 +1,112 @@ +/* + * + * Copyright (C) 2000 Thomas Mirlacher + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. + * + * The author may be reached as <dent@linuxvideo.org> + * + *------------------------------------------------------------ + * + */ + +#ifndef __ALPHABLEND_H__ +#define __ALPHABLEND_H__ + +#include "video_out.h" + +typedef struct { + void *buffer; + int buffer_size; + + int disable_exact_blending; + + int offset_x, offset_y; +} alphablend_t; + +void _x_alphablend_init(alphablend_t *extra_data, xine_t *xine) XINE_PROTECTED; +void _x_alphablend_free(alphablend_t *extra_data) XINE_PROTECTED; + +typedef struct { /* CLUT == Color LookUp Table */ + uint8_t cb; + uint8_t cr; + uint8_t y; + uint8_t foo; +} XINE_PACKED clut_t; + +#define XX44_PALETTE_SIZE 32 + +typedef struct { + unsigned size; + unsigned max_used; + uint32_t cluts[XX44_PALETTE_SIZE]; + /* cache palette entries for both colors and hili_colors */ + int lookup_cache[OVL_PALETTE_SIZE*2]; +} xx44_palette_t; + + +void _x_blend_rgb16 (uint8_t * img, vo_overlay_t * img_overl, + int img_width, int img_height, + int dst_width, int dst_height, + alphablend_t *extra_data) XINE_PROTECTED; + +void _x_blend_rgb24 (uint8_t * img, vo_overlay_t * img_overl, + int img_width, int img_height, + int dst_width, int dst_height, + alphablend_t *extra_data) XINE_PROTECTED; + +void _x_blend_rgb32 (uint8_t * img, vo_overlay_t * img_overl, + int img_width, int img_height, + int dst_width, int dst_height, + alphablend_t *extra_data) XINE_PROTECTED; + +void _x_blend_yuv (uint8_t *dst_base[3], vo_overlay_t * img_overl, + int dst_width, int dst_height, int dst_pitches[3], + alphablend_t *extra_data) XINE_PROTECTED; + +void _x_blend_yuy2 (uint8_t * dst_img, vo_overlay_t * img_overl, + int dst_width, int dst_height, int dst_pitch, + alphablend_t *extra_data) XINE_PROTECTED; + +/* + * This function isn't too smart about blending. We want to avoid creating new + * colors in the palette as a result from two non-zero colors needed to be + * blended. Instead we choose the color with the highest alpha value to be + * visible. Some parts of the code taken from the "VeXP" project. + */ + +void _x_blend_xx44 (uint8_t *dst_img, vo_overlay_t *img_overl, + int dst_width, int dst_height, int dst_pitch, + alphablend_t *extra_data, + xx44_palette_t *palette,int ia44) XINE_PROTECTED; + +/* + * Functions to handle the xine-specific palette. + */ + +void _x_clear_xx44_palette(xx44_palette_t *p) XINE_PROTECTED; +void _x_init_xx44_palette(xx44_palette_t *p, unsigned num_entries) XINE_PROTECTED; +void _x_dispose_xx44_palette(xx44_palette_t *p) XINE_PROTECTED; + +/* + * Convert the xine-specific palette to something useful. + */ + +void _x_xx44_to_xvmc_palette(const xx44_palette_t *p,unsigned char *xvmc_palette, + unsigned first_xx44_entry, unsigned num_xx44_entries, + unsigned num_xvmc_components, char *xvmc_components) XINE_PROTECTED; + + +#endif diff --git a/include/xine/array.h b/include/xine/array.h new file mode 100644 index 000000000..cd0780e04 --- /dev/null +++ b/include/xine/array.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Array that can grow automatically when you add elements. + * Inserting an element in the middle of the array implies memory moves. + */ +#ifndef XINE_ARRAY_H +#define XINE_ARRAY_H + +/* Array type */ +typedef struct xine_array_s xine_array_t; + +/* Constructor */ +xine_array_t *xine_array_new(size_t initial_size) XINE_MALLOC XINE_PROTECTED; + +/* Destructor */ +void xine_array_delete(xine_array_t *array) XINE_PROTECTED; + +/* Returns the number of element stored in the array */ +size_t xine_array_size(const xine_array_t *array) XINE_PROTECTED; + +/* Removes all elements from an array */ +void xine_array_clear(xine_array_t *array) XINE_PROTECTED; + +/* Adds the element at the end of the array */ +void xine_array_add(xine_array_t *array, void *value) XINE_PROTECTED; + +/* Inserts an element into an array at the position specified */ +void xine_array_insert(xine_array_t *array, unsigned int position, void *value) XINE_PROTECTED; + +/* Removes one element from an array at the position specified */ +void xine_array_remove(xine_array_t *array, unsigned int position) XINE_PROTECTED; + +/* Get the element at the position specified */ +void *xine_array_get(const xine_array_t *array, unsigned int position) XINE_PROTECTED; + +/* Set the element at the position specified */ +void xine_array_set(xine_array_t *array, unsigned int position, void *value) XINE_PROTECTED; + +#endif + diff --git a/include/xine/attributes.h b/include/xine/attributes.h new file mode 100644 index 000000000..2326dab18 --- /dev/null +++ b/include/xine/attributes.h @@ -0,0 +1,121 @@ +/* + * attributes.h + * Copyright (C) 1999-2000 Aaron Holtzman <aholtzma@ess.engr.uvic.ca> + * Copyright (C) 2001-2008 xine developers + * + * This file was originally part of mpeg2dec, a free MPEG-2 video stream + * decoder. + * + * mpeg2dec is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * mpeg2dec is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +/* use gcc attribs to align critical data structures */ + +#ifndef ATTRIBUTE_H_ +#define ATTRIBUTE_H_ + +#ifdef ATTRIBUTE_ALIGNED_MAX +#define ATTR_ALIGN(align) __attribute__ ((__aligned__ ((ATTRIBUTE_ALIGNED_MAX < align) ? ATTRIBUTE_ALIGNED_MAX : align))) +#else +#define ATTR_ALIGN(align) +#endif + +#ifdef XINE_COMPILE +# include "configure.h" +#else +# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95 ) +# define SUPPORT_ATTRIBUTE_PACKED 1 +# endif + +# if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3 ) +# define SUPPORT_ATTRIBUTE_DEPRECATED 1 +# define SUPPORT_ATTRIBUTE_FORMAT 1 +# define SUPPORT_ATTRIBUTE_FORMAT_ARG 1 +# define SUPPORT_ATTRIBUTE_MALLOC 1 +# define SUPPORT_ATTRIBUTE_UNUSED 1 +# define SUPPORT_ATTRIBUTE_CONST 1 +# endif + +# if __GNUC__ >= 4 +# define SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT 1 +# if __ELF__ +# define SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED 1 +# endif +# define SUPPORT_ATTRIBUTE_SENTINEL 1 +# endif +#endif + +/* Export protected only for libxine functions */ +#if defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_PROTECTED) +# define XINE_PROTECTED __attribute__((__visibility__("protected"))) +#elif defined(XINE_LIBRARY_COMPILE) && defined(SUPPORT_ATTRIBUTE_VISIBILITY_DEFAULT) +# define XINE_PROTECTED __attribute__((__visibility__("default"))) +#else +# define XINE_PROTECTED +#endif + +#ifdef SUPPORT_ATTRIBUTE_SENTINEL +# define XINE_SENTINEL __attribute__((__sentinel__)) +#else +# define XINE_SENTINEL +#endif + +#if defined(SUPPORT_ATTRIBUTE_DEPRECATED) && !defined(XINE_COMPILE) +# define XINE_DEPRECATED __attribute__((__deprecated__)) +#else +# define XINE_DEPRECATED +#endif + +#ifndef __attr_unused +# ifdef SUPPORT_ATTRIBUTE_UNUSED +# define __attr_unused __attribute__((__unused__)) +# else +# define __attr_unused +# endif +#endif + +/* Format attributes */ +#ifdef SUPPORT_ATTRIBUTE_FORMAT +# define XINE_FORMAT_PRINTF(fmt,var) __attribute__((__format__(__printf__, fmt, var))) +# define XINE_FORMAT_SCANF(fmt,var) __attribute__((__format__(__scanf__, fmt, var))) +#else +# define XINE_FORMAT_PRINTF(fmt,var) +# define XINE_FORMAT_SCANF(fmt,var) +#endif +#ifdef SUPPORT_ATTRIBUTE_FORMAT_ARG +# define XINE_FORMAT_PRINTF_ARG(fmt) __attribute__((__format_arg__(fmt))) +#else +# define XINE_FORMAT_PRINTF_ARG(fmt) +#endif + +#ifdef SUPPORT_ATTRIBUTE_MALLOC +# define XINE_MALLOC __attribute__((__malloc__)) +#else +# define XINE_MALLOC +#endif + +#ifdef SUPPORT_ATTRIBUTE_PACKED +# define XINE_PACKED __attribute__((__packed__)) +#else +# define XINE_PACKED +#endif + +#ifdef SUPPORT_ATTRIBUTE_CONST +# define XINE_CONST __attribute__((__const__)) +#else +# define XINE_CONST +#endif + +#endif /* ATTRIBUTE_H_ */ diff --git a/include/xine/audio_decoder.h b/include/xine/audio_decoder.h new file mode 100644 index 000000000..a37967ea6 --- /dev/null +++ b/include/xine/audio_decoder.h @@ -0,0 +1,113 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * xine audio decoder plugin interface + */ + +#ifndef HAVE_AUDIO_DECODER_H +#define HAVE_AUDIO_DECODER_H + +#include <xine/os_types.h> +#include <xine/buffer.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define AUDIO_DECODER_IFACE_VERSION 16 + +/* + * generic xine audio decoder plugin interface + */ + +typedef struct audio_decoder_class_s audio_decoder_class_t; +typedef struct audio_decoder_s audio_decoder_t; + +struct audio_decoder_class_s { + + /* + * open a new instance of this plugin class + */ + audio_decoder_t* (*open_plugin) (audio_decoder_class_t *this, xine_stream_t *stream); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + + void (*dispose) (audio_decoder_class_t *this); +}; + +#define default_audio_decoder_class_dispose (void (*) (audio_decoder_class_t *this))free + +struct audio_decoder_s { + + /* + * decode data from buf and feed decoded samples to + * audio output + */ + void (*decode_data) (audio_decoder_t *this, buf_element_t *buf); + + /* + * reset decoder after engine flush (prepare for new + * audio data not related to recently decoded data) + */ + void (*reset) (audio_decoder_t *this); + + /* + * inform decoder that a time reference discontinuity has happened. + * that is, it must forget any currently held pts value + */ + void (*discontinuity) (audio_decoder_t *this); + + /* + * close down, free all resources + */ + void (*dispose) (audio_decoder_t *this); + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +}; + +#endif diff --git a/include/xine/audio_out.h b/include/xine/audio_out.h new file mode 100644 index 000000000..dd7d16a0d --- /dev/null +++ b/include/xine/audio_out.h @@ -0,0 +1,360 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ +#ifndef HAVE_AUDIO_OUT_H +#define HAVE_AUDIO_OUT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <xine/os_types.h> +#include <xine/metronom.h> +#include <xine/configfile.h> +#include <xine/xineutils.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define AUDIO_OUT_IFACE_VERSION 9 + +/* + * ao_driver_s contains the driver every audio output + * driver plugin has to implement. + */ + +typedef struct ao_driver_s ao_driver_t; + +struct ao_driver_s { + + /* + * + * find out what output modes + capatilities are supported by + * this plugin (constants for the bit vector to return see above) + * + * See AO_CAP_* bellow. + */ + uint32_t (*get_capabilities) (ao_driver_t *); + + /* + * open the driver and make it ready to receive audio data + * buffers may be flushed(!) + * + * return value: 0 : failure, >0 : output sample rate + */ + int (*open)(ao_driver_t *, uint32_t bits, uint32_t rate, int mode); + + /* return the number of audio channels + */ + int (*num_channels)(ao_driver_t *self_gen); + + /* return the number of bytes per frame. + * A frame is equivalent to one sample being output on every audio channel. + */ + int (*bytes_per_frame)(ao_driver_t *self_gen); + + /* return the delay is frames measured by + * looking at pending samples in the audio output device + */ + int (*delay)(ao_driver_t *self_gen); + + /* + * return gap tolerance (in pts) needed for this driver + */ + int (*get_gap_tolerance) (ao_driver_t *self_gen); + + /* + * write audio data to audio output device + * return value: + * >0 => audio samples were processed ok + * 0 => audio samples were not yet processed, + * call write_audio_data with the _same_ samples again + */ + int (*write)(ao_driver_t *, + int16_t* audio_data, uint32_t num_samples); + + /* + * this is called when the decoder no longer uses the audio + * output driver - the driver should get ready to get opened() again + */ + void (*close)(ao_driver_t *); + + /* + * shut down this audio output driver plugin and + * free all resources allocated + */ + void (*exit) (ao_driver_t *); + + /* + * Get, Set a property of audio driver. + * + * get_property() return 1 in success, 0 on failure. + * set_property() return value on success, ~value on failure. + * + * See AO_PROP_* below for available properties. + */ + int (*get_property) (ao_driver_t *, int property); + + int (*set_property) (ao_driver_t *, int property, int value); + + + /* + * misc control operations on the audio device. + * + * See AO_CTRL_* below. + */ + int (*control) (ao_driver_t *, int cmd, /* arg */ ...); + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +}; + +typedef struct ao_format_s ao_format_t; + +struct ao_format_s { + uint32_t bits; + uint32_t rate; + int mode; +}; + +typedef struct audio_fifo_s audio_fifo_t; + +typedef struct audio_buffer_s audio_buffer_t; + +struct audio_buffer_s { + + audio_buffer_t *next; + + int16_t *mem; + int mem_size; + int num_frames; + + int64_t vpts; + uint32_t frame_header_count; + uint32_t first_access_unit; + + /* extra info coming from input or demuxers */ + extra_info_t *extra_info; + + xine_stream_t *stream; /* stream that send that buffer */ + + ao_format_t format; /* let each buffer carry it's own format info */ +}; + +/* + * xine_audio_port_s contains the port every audio decoder talks to + * + * Remember that adding new functions to this structure requires + * adaption of the post plugin decoration layer. Be sure to look into + * src/xine-engine/post.[ch]. + */ + +struct xine_audio_port_s { + uint32_t (*get_capabilities) (xine_audio_port_t *); /* for constants see below */ + + /* * Get/Set audio property + * + * See AO_PROP_* bellow + */ + int (*get_property) (xine_audio_port_t *, int property); + int (*set_property) (xine_audio_port_t *, int property, int value); + + /* open audio driver for audio output + * return value: 0:failure, >0:output sample rate + */ + /* when you are not a full-blown stream, but still need to open the port + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ + int (*open) (xine_audio_port_t *, xine_stream_t *stream, + uint32_t bits, uint32_t rate, int mode); + + /* + * get a piece of memory for audio data + */ + audio_buffer_t * (*get_buffer) (xine_audio_port_t *); + + /* + * append a buffer filled with audio data to the audio fifo + * for output + */ + /* when the frame does not originate from a stream, it is legal to pass an anonymous stream */ + void (*put_buffer) (xine_audio_port_t *, audio_buffer_t *buf, xine_stream_t *stream); + + /* audio driver is no longer used by decoder => close */ + /* when you are not a full-blown stream, but still need to close the port + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ + void (*close) (xine_audio_port_t *self, xine_stream_t *stream); + + /* called on xine exit */ + void (*exit) (xine_audio_port_t *); + + /* + * misc control operations on the audio device. + * + * See AO_CTRL_* below. + */ + int (*control) (xine_audio_port_t *, int cmd, /* arg */ ...); + + /* + * Flush audio_out fifo. + */ + void (*flush) (xine_audio_port_t *); + + /* + * Check if port is opened for this stream and get parameters. + * The stream can be anonymous. + */ + int (*status) (xine_audio_port_t *, xine_stream_t *stream, + uint32_t *bits, uint32_t *rate, int *mode); + +}; + +typedef struct audio_driver_class_s audio_driver_class_t; + +struct audio_driver_class_s { + + /* + * open a new instance of this plugin class + */ + ao_driver_t* (*open_plugin) (audio_driver_class_t *, const void *data); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + + void (*dispose) (audio_driver_class_t *); +}; + +#define default_audio_driver_class_dispose (void (*) (audio_driver_class_t *this))free + +/** + * @brief Initialise the audio_out sync routines + * + * @internal + */ +xine_audio_port_t *_x_ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only) XINE_MALLOC; + +/* + * audio output modes + capabilities + */ + +#define AO_CAP_NOCAP 0x00000000 /* driver has no capabilities */ +#define AO_CAP_MODE_A52 0x00000001 /* driver supports A/52 output */ +#define AO_CAP_MODE_AC5 0x00000002 /* driver supports AC5 output */ +/* 1 sample == 2 bytes (C) */ +#define AO_CAP_MODE_MONO 0x00000004 /* driver supports mono output */ +/* 1 sample == 4 bytes (L,R) */ +#define AO_CAP_MODE_STEREO 0x00000008 /* driver supports stereo output */ +/* 1 sample == 8 bytes (L,R,LR,RR) */ +#define AO_CAP_MODE_4CHANNEL 0x00000010 /* driver supports 4 channels */ +/* + * Sound cards generally support, 1,2,4,6 channels, but rarely 5. + * So xine will take 4.1, 5 and 6 channel a52 streams and + * down or upmix it correctly to fill the 6 output channels. + * Are there any requests for 2.1 out there? + */ +/* 1 sample == 12 bytes (L,R,LR,RR,Null,LFE) */ +#define AO_CAP_MODE_4_1CHANNEL 0x00000020 /* driver supports 4.1 channels */ +/* 1 sample == 12 bytes (L,R,LR,RR,C, Null) */ +#define AO_CAP_MODE_5CHANNEL 0x00000040 /* driver supports 5 channels */ +/* 1 sample == 12 bytes (L,R,LR,RR,C,LFE) */ +#define AO_CAP_MODE_5_1CHANNEL 0x00000080 /* driver supports 5.1 channels */ + +/* + * converts the audio output mode into the number of channels + */ +int _x_ao_mode2channels( int mode ) XINE_PROTECTED; +/* + * converts the number of channels into the audio output mode + */ +int _x_ao_channels2mode( int channels ) XINE_PROTECTED; + +#define AO_CAP_MIXER_VOL 0x00000100 /* driver supports mixer control */ +#define AO_CAP_PCM_VOL 0x00000200 /* driver supports pcm control */ +#define AO_CAP_MUTE_VOL 0x00000400 /* driver can mute volume */ +#define AO_CAP_8BITS 0x00000800 /* driver support 8-bit samples */ +#define AO_CAP_16BITS 0x00001000 /* driver support 16-bit samples */ +#define AO_CAP_24BITS 0x00002000 /* driver support 24-bit samples */ +#define AO_CAP_FLOAT32 0x00004000 /* driver support 32-bit samples. i.e. Floats */ + +/* properties supported by get/set_property() */ +#define AO_PROP_MIXER_VOL 0 +#define AO_PROP_PCM_VOL 1 +#define AO_PROP_MUTE_VOL 2 +#define AO_PROP_COMPRESSOR 3 +#define AO_PROP_DISCARD_BUFFERS 4 +#define AO_PROP_BUFS_IN_FIFO 5 /* read-only */ +#define AO_PROP_AMP 6 /* amplifier */ +#define AO_PROP_EQ_30HZ 7 /* equalizer */ +#define AO_PROP_EQ_60HZ 8 /* equalizer */ +#define AO_PROP_EQ_125HZ 9 /* equalizer */ +#define AO_PROP_EQ_250HZ 10 /* equalizer */ +#define AO_PROP_EQ_500HZ 11 /* equalizer */ +#define AO_PROP_EQ_1000HZ 12 /* equalizer */ +#define AO_PROP_EQ_2000HZ 13 /* equalizer */ +#define AO_PROP_EQ_4000HZ 14 /* equalizer */ +#define AO_PROP_EQ_8000HZ 15 /* equalizer */ +#define AO_PROP_EQ_16000HZ 16 /* equalizer */ +#define AO_PROP_CLOSE_DEVICE 17 /* force closing audio device */ +#define AO_PROP_AMP_MUTE 18 /* amplifier mute */ +#define AO_PROP_NUM_STREAMS 19 /* read-only */ +#define AO_PROP_CLOCK_SPEED 20 /* inform audio_out that speed has changed */ +#define AO_PROP_BUFS_TOTAL 21 /* read-only */ +#define AO_PROP_BUFS_FREE 22 /* read-only */ +#define AO_NUM_PROPERTIES 23 + +/* audio device control ops */ +#define AO_CTRL_PLAY_PAUSE 0 +#define AO_CTRL_PLAY_RESUME 1 +#define AO_CTRL_FLUSH_BUFFERS 2 + +/* above that value audio frames are discarded */ +#define AO_MAX_GAP 15000 + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/broadcaster.h b/include/xine/broadcaster.h new file mode 100644 index 000000000..0cd416cac --- /dev/null +++ b/include/xine/broadcaster.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * broadcaster.h + */ + +#ifndef HAVE_BROADCASTER_H +#define HAVE_BROADCASTER_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct broadcaster_s broadcaster_t; + +broadcaster_t *_x_init_broadcaster(xine_stream_t *stream, int port) XINE_MALLOC XINE_PROTECTED; +void _x_close_broadcaster(broadcaster_t *this) XINE_PROTECTED; +int _x_get_broadcaster_port(broadcaster_t *this) XINE_PROTECTED; + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/xine/buffer.h b/include/xine/buffer.h new file mode 100644 index 000000000..cab9c8250 --- /dev/null +++ b/include/xine/buffer.h @@ -0,0 +1,734 @@ +/* + * Copyright (C) 2000-2008 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + * contents: + * + * buffer_entry structure - serves as a transport encapsulation + * of the mpeg audio/video data through xine + * + * free buffer pool management routines + * + * FIFO buffer structures/routines + */ + +#ifndef HAVE_BUFFER_H +#define HAVE_BUFFER_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <string.h> +#include <stdio.h> +#include <pthread.h> +#include <sys/types.h> + +#include <xine/os_types.h> +#include <xine/attributes.h> + +#define BUF_MAX_CALLBACKS 5 + +/** + * @defgroup buffer_types Buffer Types + * + * a buffer type ID describes the contents of a buffer + * it consists of three fields: + * + * buf_type = 0xMMDDCCCC + * + * MM : major buffer type (CONTROL, VIDEO, AUDIO, SPU) + * DD : decoder selection (e.g. MPEG, OPENDIVX ... for VIDEO) + * CCCC : channel number or other subtype information for the decoder + */ +/*@{*/ + +#define BUF_MAJOR_MASK 0xFF000000 +#define BUF_DECODER_MASK 0x00FF0000 + +/** + * @defgroup buffer_ctrl Control buffer types + */ +/*@{*/ +#define BUF_CONTROL_BASE 0x01000000 +#define BUF_CONTROL_START 0x01000000 +#define BUF_CONTROL_END 0x01010000 +#define BUF_CONTROL_QUIT 0x01020000 +#define BUF_CONTROL_DISCONTINUITY 0x01030000 /**< former AVSYNC_RESET */ +#define BUF_CONTROL_NOP 0x01040000 +#define BUF_CONTROL_AUDIO_CHANNEL 0x01050000 +#define BUF_CONTROL_SPU_CHANNEL 0x01060000 +#define BUF_CONTROL_NEWPTS 0x01070000 +#define BUF_CONTROL_RESET_DECODER 0x01080000 +#define BUF_CONTROL_HEADERS_DONE 0x01090000 +#define BUF_CONTROL_FLUSH_DECODER 0x010a0000 +#define BUF_CONTROL_RESET_TRACK_MAP 0x010b0000 +/*@}*/ + +/** + * @defgroup buffer_video Video buffer types + * @note (please keep in sync with buffer_types.c) + */ +/*@{*/ +#define BUF_VIDEO_BASE 0x02000000 +#define BUF_VIDEO_UNKNOWN 0x02ff0000 /**< no decoder should handle this one */ +#define BUF_VIDEO_MPEG 0x02000000 +#define BUF_VIDEO_MPEG4 0x02010000 +#define BUF_VIDEO_CINEPAK 0x02020000 +#define BUF_VIDEO_SORENSON_V1 0x02030000 +#define BUF_VIDEO_MSMPEG4_V2 0x02040000 +#define BUF_VIDEO_MSMPEG4_V3 0x02050000 +#define BUF_VIDEO_MJPEG 0x02060000 +#define BUF_VIDEO_IV50 0x02070000 +#define BUF_VIDEO_IV41 0x02080000 +#define BUF_VIDEO_IV32 0x02090000 +#define BUF_VIDEO_IV31 0x020a0000 +#define BUF_VIDEO_ATIVCR1 0x020b0000 +#define BUF_VIDEO_ATIVCR2 0x020c0000 +#define BUF_VIDEO_I263 0x020d0000 +#define BUF_VIDEO_RV10 0x020e0000 +#define BUF_VIDEO_RGB 0x02100000 +#define BUF_VIDEO_YUY2 0x02110000 +#define BUF_VIDEO_JPEG 0x02120000 +#define BUF_VIDEO_WMV7 0x02130000 +#define BUF_VIDEO_WMV8 0x02140000 +#define BUF_VIDEO_MSVC 0x02150000 +#define BUF_VIDEO_DV 0x02160000 +#define BUF_VIDEO_REAL 0x02170000 +#define BUF_VIDEO_VP31 0x02180000 +#define BUF_VIDEO_H263 0x02190000 +#define BUF_VIDEO_3IVX 0x021A0000 +#define BUF_VIDEO_CYUV 0x021B0000 +#define BUF_VIDEO_DIVX5 0x021C0000 +#define BUF_VIDEO_XVID 0x021D0000 +#define BUF_VIDEO_SMC 0x021E0000 +#define BUF_VIDEO_RPZA 0x021F0000 +#define BUF_VIDEO_QTRLE 0x02200000 +#define BUF_VIDEO_MSRLE 0x02210000 +#define BUF_VIDEO_DUCKTM1 0x02220000 +#define BUF_VIDEO_FLI 0x02230000 +#define BUF_VIDEO_ROQ 0x02240000 +#define BUF_VIDEO_SORENSON_V3 0x02250000 +#define BUF_VIDEO_MSMPEG4_V1 0x02260000 +#define BUF_VIDEO_MSS1 0x02270000 +#define BUF_VIDEO_IDCIN 0x02280000 +#define BUF_VIDEO_PGVV 0x02290000 +#define BUF_VIDEO_ZYGO 0x022A0000 +#define BUF_VIDEO_TSCC 0x022B0000 +#define BUF_VIDEO_YVU9 0x022C0000 +#define BUF_VIDEO_VQA 0x022D0000 +#define BUF_VIDEO_GREY 0x022E0000 +#define BUF_VIDEO_XXAN 0x022F0000 +#define BUF_VIDEO_WC3 0x02300000 +#define BUF_VIDEO_YV12 0x02310000 +#define BUF_VIDEO_SEGA 0x02320000 +#define BUF_VIDEO_RV20 0x02330000 +#define BUF_VIDEO_RV30 0x02340000 +#define BUF_VIDEO_MVI2 0x02350000 +#define BUF_VIDEO_UCOD 0x02360000 +#define BUF_VIDEO_WMV9 0x02370000 +#define BUF_VIDEO_INTERPLAY 0x02380000 +#define BUF_VIDEO_RV40 0x02390000 +#define BUF_VIDEO_PSX_MDEC 0x023A0000 +#define BUF_VIDEO_YUV_FRAMES 0x023B0000 /**< uncompressed YUV, delivered by v4l input plugin */ +#define BUF_VIDEO_HUFFYUV 0x023C0000 +#define BUF_VIDEO_IMAGE 0x023D0000 +#define BUF_VIDEO_THEORA 0x023E0000 +#define BUF_VIDEO_4XM 0x023F0000 +#define BUF_VIDEO_I420 0x02400000 +#define BUF_VIDEO_VP4 0x02410000 +#define BUF_VIDEO_VP5 0x02420000 +#define BUF_VIDEO_VP6 0x02430000 +#define BUF_VIDEO_VMD 0x02440000 +#define BUF_VIDEO_MSZH 0x02450000 +#define BUF_VIDEO_ZLIB 0x02460000 +#define BUF_VIDEO_8BPS 0x02470000 +#define BUF_VIDEO_ASV1 0x02480000 +#define BUF_VIDEO_ASV2 0x02490000 +#define BUF_VIDEO_BITPLANE 0x024A0000 /**< Amiga typical picture and animation format */ +#define BUF_VIDEO_BITPLANE_BR1 0x024B0000 /**< the same with Bytrun compression 1 */ +#define BUF_VIDEO_FLV1 0x024C0000 +#define BUF_VIDEO_H264 0x024D0000 +#define BUF_VIDEO_MJPEG_B 0x024E0000 +#define BUF_VIDEO_H261 0x024F0000 +#define BUF_VIDEO_AASC 0x02500000 +#define BUF_VIDEO_LOCO 0x02510000 +#define BUF_VIDEO_QDRW 0x02520000 +#define BUF_VIDEO_QPEG 0x02530000 +#define BUF_VIDEO_ULTI 0x02540000 +#define BUF_VIDEO_WNV1 0x02550000 +#define BUF_VIDEO_XL 0x02560000 +#define BUF_VIDEO_RT21 0x02570000 +#define BUF_VIDEO_FPS1 0x02580000 +#define BUF_VIDEO_DUCKTM2 0x02590000 +#define BUF_VIDEO_CSCD 0x025A0000 +#define BUF_VIDEO_ALGMM 0x025B0000 +#define BUF_VIDEO_ZMBV 0x025C0000 +#define BUF_VIDEO_AVS 0x025D0000 +#define BUF_VIDEO_SMACKER 0x025E0000 +#define BUF_VIDEO_NUV 0x025F0000 +#define BUF_VIDEO_KMVC 0x02600000 +#define BUF_VIDEO_FLASHSV 0x02610000 +#define BUF_VIDEO_CAVS 0x02620000 +#define BUF_VIDEO_VP6F 0x02630000 +#define BUF_VIDEO_THEORA_RAW 0x02640000 +#define BUF_VIDEO_VC1 0x02650000 +#define BUF_VIDEO_VMNC 0x02660000 +#define BUF_VIDEO_SNOW 0x02670000 +#define BUF_VIDEO_VP8 0x02680000 +/*@}*/ + +/** + * @defgroup buffer_audio Audio buffer types + * @note (please keep in sync with buffer_types.c) + */ +/*@{*/ +#define BUF_AUDIO_BASE 0x03000000 +#define BUF_AUDIO_UNKNOWN 0x03ff0000 /**< no decoder should handle this one */ +#define BUF_AUDIO_A52 0x03000000 +#define BUF_AUDIO_MPEG 0x03010000 +#define BUF_AUDIO_LPCM_BE 0x03020000 +#define BUF_AUDIO_LPCM_LE 0x03030000 +#define BUF_AUDIO_WMAV1 0x03040000 +#define BUF_AUDIO_DTS 0x03050000 +#define BUF_AUDIO_MSADPCM 0x03060000 +#define BUF_AUDIO_MSIMAADPCM 0x03070000 +#define BUF_AUDIO_MSGSM 0x03080000 +#define BUF_AUDIO_VORBIS 0x03090000 +#define BUF_AUDIO_IMC 0x030a0000 +#define BUF_AUDIO_LH 0x030b0000 +#define BUF_AUDIO_VOXWARE 0x030c0000 +#define BUF_AUDIO_ACELPNET 0x030d0000 +#define BUF_AUDIO_AAC 0x030e0000 +#define BUF_AUDIO_DNET 0x030f0000 +#define BUF_AUDIO_VIVOG723 0x03100000 +#define BUF_AUDIO_DK3ADPCM 0x03110000 +#define BUF_AUDIO_DK4ADPCM 0x03120000 +#define BUF_AUDIO_ROQ 0x03130000 +#define BUF_AUDIO_QTIMAADPCM 0x03140000 +#define BUF_AUDIO_MAC3 0x03150000 +#define BUF_AUDIO_MAC6 0x03160000 +#define BUF_AUDIO_QDESIGN1 0x03170000 +#define BUF_AUDIO_QDESIGN2 0x03180000 +#define BUF_AUDIO_QCLP 0x03190000 +#define BUF_AUDIO_SMJPEG_IMA 0x031A0000 +#define BUF_AUDIO_VQA_IMA 0x031B0000 +#define BUF_AUDIO_MULAW 0x031C0000 +#define BUF_AUDIO_ALAW 0x031D0000 +#define BUF_AUDIO_GSM610 0x031E0000 +#define BUF_AUDIO_EA_ADPCM 0x031F0000 +#define BUF_AUDIO_WMAV2 0x03200000 +#define BUF_AUDIO_COOK 0x03210000 +#define BUF_AUDIO_ATRK 0x03220000 +#define BUF_AUDIO_14_4 0x03230000 +#define BUF_AUDIO_28_8 0x03240000 +#define BUF_AUDIO_SIPRO 0x03250000 +#define BUF_AUDIO_WMAPRO 0x03260000 +#define BUF_AUDIO_WMAV3 BUF_AUDIO_WMAPRO +#define BUF_AUDIO_INTERPLAY 0x03270000 +#define BUF_AUDIO_XA_ADPCM 0x03280000 +#define BUF_AUDIO_WESTWOOD 0x03290000 +#define BUF_AUDIO_DIALOGIC_IMA 0x032A0000 +#define BUF_AUDIO_NSF 0x032B0000 +#define BUF_AUDIO_FLAC 0x032C0000 +#define BUF_AUDIO_DV 0x032D0000 +#define BUF_AUDIO_WMAV 0x032E0000 +#define BUF_AUDIO_SPEEX 0x032F0000 +#define BUF_AUDIO_RAWPCM 0x03300000 +#define BUF_AUDIO_4X_ADPCM 0x03310000 +#define BUF_AUDIO_VMD 0x03320000 +#define BUF_AUDIO_XAN_DPCM 0x03330000 +#define BUF_AUDIO_ALAC 0x03340000 +#define BUF_AUDIO_MPC 0x03350000 +#define BUF_AUDIO_SHORTEN 0x03360000 +#define BUF_AUDIO_WESTWOOD_SND1 0x03370000 +#define BUF_AUDIO_WMALL 0x03380000 +#define BUF_AUDIO_TRUESPEECH 0x03390000 +#define BUF_AUDIO_TTA 0x033A0000 +#define BUF_AUDIO_SMACKER 0x033B0000 +#define BUF_AUDIO_FLVADPCM 0x033C0000 +#define BUF_AUDIO_WAVPACK 0x033D0000 +#define BUF_AUDIO_MP3ADU 0x033E0000 +#define BUF_AUDIO_AMR_NB 0x033F0000 +#define BUF_AUDIO_AMR_WB 0x03400000 +#define BUF_AUDIO_EAC3 0x03410000 +#define BUF_AUDIO_AAC_LATM 0x03420000 +/*@}*/ + +/** + * @defgroup buffer_spu SPU buffer types + */ +/*@{*/ +#define BUF_SPU_BASE 0x04000000 +#define BUF_SPU_DVD 0x04000000 +#define BUF_SPU_TEXT 0x04010000 +#define BUF_SPU_CC 0x04020000 +#define BUF_SPU_DVB 0x04030000 +#define BUF_SPU_SVCD 0x04040000 +#define BUF_SPU_CVD 0x04050000 +#define BUF_SPU_OGM 0x04060000 +#define BUF_SPU_CMML 0x04070000 +#define BUF_SPU_HDMV 0x04080000 +/*@}*/ + +/** + * @defgroup buffer_demux Demuxer block types + */ +/*@{*/ +#define BUF_DEMUX_BLOCK 0x05000000 +/*@}*/ + +/*@}*/ + +typedef struct extra_info_s extra_info_t; + +/** + * @brief Structure to pass information from input or demuxer plugins + * to output frames (past decoder). + * + * New data must be added after the existing fields to not break ABI + * (backward compatibility). + */ + +struct extra_info_s { + + int input_normpos; /**< remember where this buf came from in + * the input source (0..65535). can be + * either time or offset based. */ + int input_time; /**< time offset in miliseconds from + * beginning of stream */ + uint32_t frame_number; /**< number of current frame if known */ + + int seek_count; /**< internal engine use */ + int64_t vpts; /**< set on output layers only */ + + int invalid; /**< do not use this extra info to update anything */ + int total_time; /**< duration in miliseconds of the stream */ +}; + + +#define BUF_NUM_DEC_INFO 5 + +typedef struct buf_element_s buf_element_t; +struct buf_element_s { + buf_element_t *next; + + unsigned char *mem; + unsigned char *content; /**< start of raw content in mem (without header etc) */ + + int32_t size ; /**< size of _content_ */ + int32_t max_size; /**< size of pre-allocated memory pointed to by "mem" */ + int64_t pts; /**< presentation time stamp, used for a/v sync */ + int64_t disc_off; /**< discontinuity offset */ + + extra_info_t *extra_info; /**< extra info will be passed to frames */ + + uint32_t decoder_flags; /**< stuff like keyframe, is_header ... see below */ + + /** additional decoder flags and other dec-spec. stuff */ + uint32_t decoder_info[BUF_NUM_DEC_INFO]; + /** pointers to dec-spec. stuff */ + void *decoder_info_ptr[BUF_NUM_DEC_INFO]; + + void (*free_buffer) (buf_element_t *buf); + + void *source; /**< pointer to source of this buffer for + * free_buffer */ + + uint32_t type; +} ; + +/** keyframe should be set whenever possible (that is, when demuxer + * knows about frames and keyframes). */ +#define BUF_FLAG_KEYFRAME 0x0001 + +/** frame start/end. BUF_FLAG_FRAME_END is sent on last buf of a frame */ +#define BUF_FLAG_FRAME_START 0x0002 +#define BUF_FLAG_FRAME_END 0x0004 + +/** any out-of-band data needed to initialize decoder must have + * this flag set. */ +#define BUF_FLAG_HEADER 0x0008 + +/** preview buffers are normal data buffers that must not produce any + * output in decoders (may be used to sneak details about the stream + * to come). */ +#define BUF_FLAG_PREVIEW 0x0010 + +/** set when user stop the playback */ +#define BUF_FLAG_END_USER 0x0020 + +/** set when stream finished naturaly */ +#define BUF_FLAG_END_STREAM 0x0040 + +/** decoder_info[0] carries the frame step (1/90000). */ +#define BUF_FLAG_FRAMERATE 0x0080 + +/** hint to metronom that seeking has occurred */ +#define BUF_FLAG_SEEK 0x0100 + +/** special information inside, see below. */ +#define BUF_FLAG_SPECIAL 0x0200 + +/** header use standard xine_bmiheader or xine_waveformatex structs. + * xine_waveformatex is actually optional since the most important + * information for audio init is available from decoder_info[]. + * note: BUF_FLAG_HEADER must also be set. */ +#define BUF_FLAG_STDHEADER 0x0400 + +/** decoder_info[1] carries numerator for display aspect ratio + * decoder_info[2] carries denominator for display aspect ratio */ +#define BUF_FLAG_ASPECT 0x0800 + +/* represent the state of gapless_switch at the time buf was enqueued */ +#define BUF_FLAG_GAPLESS_SW 0x1000 + +/* Amount of audio padding added by encoder (mp3, aac). These empty + * audio frames are causing a gap when switching between mp3 files. + * decoder_info[1] carries amount of audio frames padded at the + * beginning of the buffer + * decoder_info[2] carries amount of audio frames padded at the end of + * the buffer */ +#define BUF_FLAG_AUDIO_PADDING 0x2000 + +/** + * \defgroup buffer_special Special buffer types: + * Sometimes there is a need to relay special information from a demuxer + * to a video decoder. For example, some file types store palette data in + * the file header independant of the video data. The special buffer type + * offers a way to communicate this or any other custom, format-specific + * data to the decoder. + * + * The interface was designed in a way that did not require an API + * version bump. To send a special buffer type, set a buffer's flags field + * to BUF_FLAG_SPECIAL. Set the buffer's decoder_info[1] field to a + * number according to one of the special buffer subtypes defined below. + * The second and third decoder_info[] fields are defined according to + * your buffer type's requirements. + * + * Finally, remember to set the buffer's size to 0. This way, if a special + * buffer is sent to a decode that does not know how to handle it, the + * buffer will fall through to the case where the buffer's data content + * is accumulated and no harm will be done. + */ +/*@{*/ + +/** + * In a BUF_SPECIAL_PALETTE buffer: + * decoder_info[1] = BUF_SPECIAL_PALETTE + * decoder_info[2] = number of entries in palette table + * decoder_info_ptr[2] = pointer to palette table + * This buffer type is used to provide a file- and decoder-independent + * facility to transport RGB color palettes from demuxers to decoders. + * A palette table is an array of palette_entry_t structures. A decoder + * should not count on this array to exist for the duration of the + * program's execution and should copy, manipulate, and store the palette + * data privately if it needs the palette information. + */ +#define BUF_SPECIAL_PALETTE 1 + + +/* special buffer type 2 used to be defined but is now available for use */ + + +/** + * In a BUF_SPECIAL_ASPECT buffer: + * decoder_info[1] = BUF_SPECIAL_ASPECT + * decoder_info[2] = MPEG2 aspect ratio code + * decoder_info[3] = stream scale prohibitions + * This buffer is used to force mpeg decoders to use a certain aspect. + * Currently xine-dvdnav uses this, because it has more accurate information + * about the aspect from the dvd ifo-data. + * The stream scale prohibitions are also delivered, with bit 0 meaning + * "deny letterboxing" and bit 1 meaning "deny pan&scan" + */ +#define BUF_SPECIAL_ASPECT 3 + +/** + * In a BUF_SPECIAL_DECODER_CONFIG buffer: + * decoder_info[1] = BUF_SPECIAL_DECODER_CONFIG + * decoder_info[2] = data size + * decoder_info_ptr[2] = pointer to data + * This buffer is used to pass config information from .mp4 files + * (atom esds) to decoders. both mpeg4 and aac streams use that. + */ +#define BUF_SPECIAL_DECODER_CONFIG 4 + +/** + * In a BUF_SPECIAL_STSD_ATOM buffer: + * decoder_info[1] = BUF_SPECIAL_STSD_ATOM + * decoder_info[2] = size of the ImageDescription atom, minus the + * four length bytes at the beginning + * decoder_info_ptr[2] = pointer to ImageDescription atom, starting with + * the codec fourcc + * Some Quicktime decoders need information contained within the + * ImageDescription atom inside a Quicktime file's stsd atom. This + * special buffer carries the ImageDescription atom from the QT demuxer + * to an A/V decoder. + */ +#define BUF_SPECIAL_STSD_ATOM 5 + +/** + * In a BUF_SPECIAL_LPCM_CONFIG buffer: + * decoder_info[1] = BUF_SPECIAL_LPCM_CONFIG + * decoder_info[2] = config data + * lpcm data encoded into mpeg2 streams have a format configuration + * byte in every frame. this is used to detect the sample rate, + * number of bits and channels. + */ +#define BUF_SPECIAL_LPCM_CONFIG 6 + +/** + * In a BUF_SPECIAL_CHARSET_ENCODING buffer: + * decoder_info[1] = BUF_SPECIAL_CHARSET_ENCODING + * decoder_info[2] = size of charset encoding string + * decoder_info_ptr[2] = pointer to charset encoding string + * This is used mostly with subtitle buffers when encoding is + * known at demuxer level (take precedence over xine config + * settings such as subtitles.separate.src_encoding) + */ +#define BUF_SPECIAL_CHARSET_ENCODING 7 + + +/** + * In a BUF_SPECIAL_SPU_DVD_SUBTYPE: + * decoder_info[1] = BUF_SPECIAL_SPU_DVD_SUBTYPE + * decoder_info[2] = subtype + * decoder_info[3] = + * This buffer is pass SPU subtypes from DVDs + */ +#define BUF_SPECIAL_SPU_DVD_SUBTYPE 8 + + +#define SPU_DVD_SUBTYPE_CLUT 1 +#define SPU_DVD_SUBTYPE_PACKAGE 2 +#define SPU_DVD_SUBTYPE_VOBSUB_PACKAGE 3 +#define SPU_DVD_SUBTYPE_NAV 4 + +/** + * In a BUF_SPECIAL_SPU_DVB_DESCRIPTOR + * decoder_info[1] = BUF_SPECIAL_SPU_DVB_DESCRIPTOR + * decoder_info[2] = size of spu_dvb_descriptor_t + * decoder_info_ptr[2] = pointer to spu_dvb_descriptor_t, or NULL + * decoder_info[3] = + * + * This buffer is used to tell a DVBSUB decoder when the stream + * changes. For more information on how to write a DVBSUB decoder, + * see the comment at the top of src/demuxers/demux_ts.c + **/ +#define BUF_SPECIAL_SPU_DVB_DESCRIPTOR 9 + +/** + * In a BUF_SPECIAL_RV_CHUNK_TABLE: + * decoder_info[1] = BUF_SPECIAL_RV_CHUNK_TABLE + * decoder_info[2] = number of entries in chunk table + * decoder_info_ptr[2] = pointer to the chunk table + * + * This buffer transports the chunk table associated to each RealVideo frame. + */ +#define BUF_SPECIAL_RV_CHUNK_TABLE 10 +/*@}*/ + +typedef struct spu_dvb_descriptor_s spu_dvb_descriptor_t; +struct spu_dvb_descriptor_s +{ + char lang[4]; + long comp_page_id; + long aux_page_id; +} ; + +typedef struct palette_entry_s palette_entry_t; +struct palette_entry_s +{ + unsigned char r, g, b; +} ; + +typedef struct fifo_buffer_s fifo_buffer_t; +struct fifo_buffer_s +{ + buf_element_t *first, *last; + + int fifo_size; + uint32_t fifo_data_size; + void *fifo_empty_cb_data; + + pthread_mutex_t mutex; + pthread_cond_t not_empty; + + /* + * functions to access this fifo: + */ + + void (*put) (fifo_buffer_t *fifo, buf_element_t *buf); + + buf_element_t *(*get) (fifo_buffer_t *fifo); + + void (*clear) (fifo_buffer_t *fifo) ; + + int (*size) (fifo_buffer_t *fifo); + + int (*num_free) (fifo_buffer_t *fifo); + + uint32_t (*data_size) (fifo_buffer_t *fifo); + + void (*dispose) (fifo_buffer_t *fifo); + + /* + * alloc buffer for this fifo from global buf pool + * you don't have to use this function to allocate a buffer, + * an input plugin can decide to implement it's own + * buffer allocation functions + */ + + buf_element_t *(*buffer_pool_alloc) (fifo_buffer_t *self); + + + /* + * special functions, not used by demuxers + */ + + /* the same as buffer_pool_alloc but may fail if none is available */ + buf_element_t *(*buffer_pool_try_alloc) (fifo_buffer_t *self); + + /* the same as put but insert at the head of the fifo */ + void (*insert) (fifo_buffer_t *fifo, buf_element_t *buf); + + /* callbacks */ + void (*register_alloc_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, void *), void *cb_data); + void (*register_put_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *), void *cb_data); + void (*register_get_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *), void *cb_data); + void (*unregister_alloc_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, void *)); + void (*unregister_put_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *)); + void (*unregister_get_cb) (fifo_buffer_t *fifo, void (*cb)(fifo_buffer_t *fifo, buf_element_t *buf, void *)); + + /* + * private variables for buffer pool management + */ + buf_element_t *buffer_pool_top; /* a stack actually */ + pthread_mutex_t buffer_pool_mutex; + pthread_cond_t buffer_pool_cond_not_empty; + int buffer_pool_num_free; + int buffer_pool_capacity; + int buffer_pool_buf_size; + void *buffer_pool_base; /*used to free mem chunk */ + void (*alloc_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, void *data_cb); + void (*put_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, buf_element_t *buf, void *data_cb); + void (*get_cb[BUF_MAX_CALLBACKS])(fifo_buffer_t *fifo, buf_element_t *buf, void *data_cb); + void *alloc_cb_data[BUF_MAX_CALLBACKS]; + void *put_cb_data[BUF_MAX_CALLBACKS]; + void *get_cb_data[BUF_MAX_CALLBACKS]; +} ; + +/** + * @brief Allocate and initialise new (empty) FIFO buffers. + * @param num_buffer Number of buffers to allocate. + * @param buf_size Size of each buffer. + * @internal Only used by video and audio decoder loops. + */ +fifo_buffer_t *_x_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_MALLOC; + +/** + * @brief Allocate and initialise new dummy FIFO buffers. + * @param num_buffer Number of dummy buffers to allocate. + * @param buf_size Size of each buffer. + * @internal Only used by video and audio decoder loops. + */ +fifo_buffer_t *_x_dummy_fifo_buffer_new (int num_buffers, uint32_t buf_size) XINE_MALLOC; + + +/** + * @brief Returns the \ref buffer_video "BUF_VIDEO_xxx" for the given fourcc. + * @param fourcc_int 32-bit FOURCC value in machine endianness + * @sa _x_formattag_to_buf_audio + * + * example: fourcc_int = *(uint32_t *)fourcc_char; + */ +uint32_t _x_fourcc_to_buf_video( uint32_t fourcc_int ) XINE_PROTECTED; + +/** + * @brief Returns video codec name given the buffer type. + * @param buf_type One of the \ref buffer_video "BUF_VIDEO_xxx" values. + * @sa _x_buf_audio_name + */ +const char * _x_buf_video_name( uint32_t buf_type ) XINE_PROTECTED; + +/** + * @brief Returns the \ref buffer_audio "BUF_AUDIO_xxx" for the given formattag. + * @param formattagg 32-bit format tag value in machine endianness + * @sa _x_fourcc_to_buf_video + */ +uint32_t _x_formattag_to_buf_audio( uint32_t formattag ) XINE_PROTECTED; + +/** + * @brief Returns audio codec name given the buffer type. + * @param buf_type One of the \ref buffer_audio "BUF_AUDIO_xxx" values. + * @sa _x_buf_video_name + */ +const char * _x_buf_audio_name( uint32_t buf_type ) XINE_PROTECTED; + + +/** + * @brief xine version of BITMAPINFOHEADER. + * @note Should be safe to compile on 64bits machines. + * @note Will always use machine endian format, so demuxers reading + * stuff from win32 formats must use the function below. + */ +typedef struct XINE_PACKED { + int32_t biSize; + int32_t biWidth; + int32_t biHeight; + int16_t biPlanes; + int16_t biBitCount; + uint32_t biCompression; + int32_t biSizeImage; + int32_t biXPelsPerMeter; + int32_t biYPelsPerMeter; + int32_t biClrUsed; + int32_t biClrImportant; +} xine_bmiheader; + +/** + * @brief xine version of WAVEFORMATEX. + * @note The same comments from xine_bmiheader applies. + */ +typedef struct XINE_PACKED { + int16_t wFormatTag; + int16_t nChannels; + int32_t nSamplesPerSec; + int32_t nAvgBytesPerSec; + int16_t nBlockAlign; + int16_t wBitsPerSample; + int16_t cbSize; +} xine_waveformatex; + +/** Convert xine_bmiheader struct from little endian */ +void _x_bmiheader_le2me( xine_bmiheader *bih ) XINE_PROTECTED; + +/** Convert xine_waveformatex struct from little endian */ +void _x_waveformatex_le2me( xine_waveformatex *wavex ) XINE_PROTECTED; + +static __inline int _x_is_fourcc(const void *ptr, const void *tag) { + return memcmp(ptr, tag, 4) == 0; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/compat.h b/include/xine/compat.h new file mode 100644 index 000000000..0392b45fd --- /dev/null +++ b/include/xine/compat.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2000-2001 the xine project + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef XINE_COMPAT_H +#define XINE_COMPAT_H + +#include <limits.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#if defined _MSC_VER +#define __XINE_FUNCTION__ __FILE__ +#elif defined __GNUC__ +#define __XINE_FUNCTION__ __FUNCTION__ +#else +#define __XINE_FUNCTION__ __func__ +#endif + +#ifndef NAME_MAX +#define XINE_NAME_MAX 256 +#else +#define XINE_NAME_MAX NAME_MAX +#endif + +#ifndef PATH_MAX +#define XINE_PATH_MAX 768 +#else +#define XINE_PATH_MAX PATH_MAX +#endif + + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/configfile.h b/include/xine/configfile.h new file mode 100644 index 000000000..a0b9ad1fe --- /dev/null +++ b/include/xine/configfile.h @@ -0,0 +1,245 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * config file management + */ + +#ifndef HAVE_CONFIGFILE_H +#define HAVE_CONFIGFILE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <pthread.h> + +#include <xine.h> + +#define CONFIG_FILE_VERSION 2 + +/** + * config entries above this experience + * level must never be changed from MRL + */ +#define XINE_CONFIG_SECURITY 30 + + +typedef struct cfg_entry_s cfg_entry_t; +typedef struct config_values_s config_values_t; + +struct cfg_entry_s { + cfg_entry_t *next; + config_values_t *config; + + char *key; + int type; + + /** user experience level */ + int exp_level; + + /** type unknown */ + char *unknown_value; + + /** type string */ + char *str_value; + char *str_default; + + /** common to range, enum, num, bool: */ + int num_value; + int num_default; + + /** type range specific: */ + int range_min; + int range_max; + + /** type enum specific: */ + char **enum_values; + + /** help info for the user */ + char *description; + char *help; + + /** callback function and data for live changeable values */ + xine_config_cb_t callback; + void *callback_data; +}; + +struct config_values_s { + + /* + * register config values + * + * these functions return the current value of the + * registered item, i.e. the default value if it was + * not found in the config file or the current value + * from the config file otherwise + */ + + char* (*register_string) (config_values_t *self, + const char *key, + const char *def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + char* (*register_filename) (config_values_t *self, + const char *key, + const char *def_value, + int req_type, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + int (*register_range) (config_values_t *self, + const char *key, + int def_value, + int min, int max, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + int (*register_enum) (config_values_t *self, + const char *key, + int def_value, + char **values, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + int (*register_num) (config_values_t *self, + const char *key, + int def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + int (*register_bool) (config_values_t *self, + const char *key, + int def_value, + const char *description, + const char *help, + int exp_level, + xine_config_cb_t changed_cb, + void *cb_data); + + void (*register_entry) (config_values_t *self, cfg_entry_t* entry); + + /** convenience function to update range, enum, num and bool values */ + void (*update_num) (config_values_t *self, const char *key, int value); + + /** convenience function to update string values */ + void (*update_string) (config_values_t *self, const char *key, const char *value); + + /** small utility function for enum handling */ + int (*parse_enum) (const char *str, const char **values); + + /** + * @brief lookup config entries + * + * remember to call the changed_cb if it exists + * and you changed the value of this item + */ + + cfg_entry_t* (*lookup_entry) (config_values_t *self, const char *key); + + /** + * unregister entry callback function + */ + void (*unregister_callback) (config_values_t *self, const char *key); + + /** + * dispose of all config entries in memory + */ + void (*dispose) (config_values_t *self); + + /** + * callback called when a new config entry is registered + */ + void (*set_new_entry_callback) (config_values_t *self, xine_config_cb_t new_entry_cb, void *cb_data); + + /** + * unregister the callback + */ + void (*unset_new_entry_callback) (config_values_t *self); + + /** + * serialize a config entry. + * return a base64 null terminated string. + */ + char* (*get_serialized_entry) (config_values_t *self, const char *key); + + /** + * deserialize a config entry. + * value is a base 64 encoded string + * return the key of the serialized entry + */ + char* (*register_serialized_entry) (config_values_t *self, const char *value); + + /** + * config values are stored here: + */ + cfg_entry_t *first, *last, *cur; + + /** + * new entry callback + */ + xine_config_cb_t new_entry_cb; + void *new_entry_cbdata; + + /** + * mutex for modification to the config + */ + pthread_mutex_t config_lock; + + /** + * current config file's version number + */ + int current_version; +}; + +/** + * @brief allocate and init a new xine config object + * @internal + */ +config_values_t *_x_config_init (void) XINE_MALLOC; + +/** + * @brief interpret stream_setup part of mrls for config value changes + * @internal + */ + +int _x_config_change_opt(config_values_t *config, const char *opt); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/xine/demux.h b/include/xine/demux.h new file mode 100644 index 000000000..2803c30ed --- /dev/null +++ b/include/xine/demux.h @@ -0,0 +1,227 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef HAVE_DEMUX_H +#define HAVE_DEMUX_H + +#include <xine/input_plugin.h> +#include <xine/buffer.h> +#include <xine/xine_internal.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define DEMUXER_PLUGIN_IFACE_VERSION 27 + +#define DEMUX_OK 0 +#define DEMUX_FINISHED 1 + +#define DEMUX_CANNOT_HANDLE 0 +#define DEMUX_CAN_HANDLE 1 + +#define METHOD_BY_CONTENT 1 +#define METHOD_BY_MRL 2 +#define METHOD_EXPLICIT 3 + +typedef struct demux_class_s demux_class_t ; +typedef struct demux_plugin_s demux_plugin_t; + +struct demux_class_s { + + /* + * open a new instance of this plugin class + */ + demux_plugin_t* (*open_plugin) (demux_class_t *this, xine_stream_t *stream, input_plugin_t *input); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /** + * @brief MIME types supported for this plugin + */ + + const char* mimetypes; + + /** + * @brief space separated list of file extensions this demuxer is + * likely to handle + * + * (will be used to filter media files in file selection dialogs) + */ + const char* extensions; + + /* + * close down, free all resources + */ + void (*dispose) (demux_class_t *this); +}; + +#define default_demux_class_dispose (void (*) (demux_class_t *this))free + +/* + * any demux plugin must implement these functions + */ + +struct demux_plugin_s { + + /* + * send headers, followed by BUF_CONTROL_HEADERS_DONE down the + * fifos, then return. do not start demux thread (yet) + */ + + void (*send_headers) (demux_plugin_t *this); + + /* + * ask demux to seek + * + * for seekable streams, a start position can be specified + * + * start_pos : position in input source (0..65535) + * this is defined as most convenient to demuxer, can be + * either time or offset based. + * start_time : position measured in miliseconds from stream start + * playing : true if this is a new seek within an already playing stream + * false if playback of this stream has not started yet + * + * if both parameters are !=0 start_pos will be used + * for non-seekable streams both values will be ignored + * + * returns the demux status (like get_status, but immediately after + * starting the demuxer) + */ + + int (*seek) (demux_plugin_t *this, + off_t start_pos, int start_time, int playing ); + + /* + * send a chunk of data down to decoder fifos + * + * the meaning of "chunk" is specific to every demux, usually + * it involves parsing one unit of data from stream. + * + * this function will be called from demux loop and should return + * the demux current status + */ + + int (*send_chunk) (demux_plugin_t *this); + + /* + * free resources + */ + + void (*dispose) (demux_plugin_t *this) ; + + /* + * returns DEMUX_OK or DEMUX_FINISHED + */ + + int (*get_status) (demux_plugin_t *this) ; + + /* + * gets stream length in miliseconds (might be estimated) + * may return 0 for non-seekable streams + */ + + int (*get_stream_length) (demux_plugin_t *this); + + /* + * return capabilities of demuxed stream + */ + + uint32_t (*get_capabilities) (demux_plugin_t *this); + + /* + * request optional data from input plugin. + */ + int (*get_optional_data) (demux_plugin_t *this, void *data, int data_type); + + /* + * "backwards" link to plugin class + */ + + demux_class_t *demux_class; + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +} ; + +#define default_demux_plugin_dispose (void (*) (demux_plugin_t *this))free + +/* + * possible capabilites a demux plugin can have: + */ +#define DEMUX_CAP_NOCAP 0x00000000 + +/* + * DEMUX_CAP_AUDIOLANG: + * DEMUX_CAP_SPULANG: + * demux plugin knows something about audio/spu languages, + * e.g. knows that audio stream #0 is english, + * audio stream #1 is german, ... Same bits as INPUT + * capabilities . + */ + +#define DEMUX_CAP_AUDIOLANG 0x00000008 +#define DEMUX_CAP_SPULANG 0x00000010 + +/* + * DEMUX_CAP_CHAPTERS: + * The media streams provided by this plugin have an internal + * structure dividing it into segments usable for navigation. + * For those plugins, the behaviour of the skip button in UIs + * should be changed from "next MRL" to "next chapter" by + * sending XINE_EVENT_INPUT_NEXT. + * Same bits as INPUT capabilities. + */ + +#define DEMUX_CAP_CHAPTERS 0x00000080 + + +#define DEMUX_OPTIONAL_UNSUPPORTED 0 +#define DEMUX_OPTIONAL_SUCCESS 1 + +#define DEMUX_OPTIONAL_DATA_AUDIOLANG 2 +#define DEMUX_OPTIONAL_DATA_SPULANG 3 + +#endif diff --git a/include/xine/info_helper.h b/include/xine/info_helper.h new file mode 100644 index 000000000..666b94f08 --- /dev/null +++ b/include/xine/info_helper.h @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * stream metainfo helper functions + * hide some xine engine details from demuxers and reduce code duplication + * + * $id$ + */ + +#ifndef INFO_HELPER_H +#define INFO_HELPER_H + +#include <stdarg.h> +#include "xine_internal.h" + +/* + * set a stream info + * + * params: + * *stream the xine stream + * info stream info id (see xine.h, XINE_STREAM_INFO_*) + * value the value to assign + * + */ +void _x_stream_info_set(xine_stream_t *stream, int info, int value) XINE_PROTECTED; + +/* + * reset a stream info (internal ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_STREAM_INFO_*) + * + */ +void _x_stream_info_reset(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * reset a stream info (public ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_STREAM_INFO_*) + * + */ +void _x_stream_info_public_reset(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * retrieve stream info (internal ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_STREAM_INFO_*) + * + */ +uint32_t _x_stream_info_get(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * retrieve stream info (public ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_STREAM_INFO_*) + * + */ +uint32_t _x_stream_info_get_public(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * set a stream meta info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * *str null-terminated string (using current locale) + * + */ +void _x_meta_info_set(xine_stream_t *stream, int info, const char *str) XINE_PROTECTED; + +/* + * set a stream meta info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * *str null-terminated string (using utf8) + * + */ +void _x_meta_info_set_utf8(xine_stream_t *stream, int info, const char *str) XINE_PROTECTED; + +/* + * set a stream meta info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * *str null-terminated string (using encoding below) + * *enc charset encoding of the string + * + */ +void _x_meta_info_set_generic(xine_stream_t *stream, int info, const char *str, const char *enc) XINE_PROTECTED; + +/* + * set a stream meta multiple info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * ... one or more meta info, followed by a NULL pointer + * + */ +void _x_meta_info_set_multi(xine_stream_t *stream, int info, ...) XINE_SENTINEL XINE_PROTECTED; + +/* + * set a stream meta info + * + * params: + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * *buf char buffer (not a null-terminated string) + * len length of the metainfo + * + */ +void _x_meta_info_n_set(xine_stream_t *stream, int info, const char *buf, int len) XINE_PROTECTED; + +/* + * reset a stream meta info (internal ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * + */ +void _x_meta_info_reset(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * reset a stream meta info (public ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * + */ +void _x_meta_info_public_reset(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * retrieve stream meta info (internal ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * + */ +const char *_x_meta_info_get(xine_stream_t *stream, int info) XINE_PROTECTED; + +/* + * retrieve stream meta info (public ones only) + * + * params : + * *stream the xine stream + * info meta info id (see xine.h, XINE_META_INFO_*) + * + */ +const char *_x_meta_info_get_public(xine_stream_t *stream, int info) XINE_PROTECTED; + +#endif /* INFO_HELPER_H */ diff --git a/include/xine/input_plugin.h b/include/xine/input_plugin.h new file mode 100644 index 000000000..ca7ec73fa --- /dev/null +++ b/include/xine/input_plugin.h @@ -0,0 +1,407 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef HAVE_INPUT_PLUGIN_H +#define HAVE_INPUT_PLUGIN_H + +#include <sys/types.h> + +#include <xine/os_types.h> +#include <xine/xineutils.h> +#include <xine/buffer.h> +#include <xine/configfile.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define INPUT_PLUGIN_IFACE_VERSION 18 + +typedef struct input_class_s input_class_t ; +typedef struct input_plugin_s input_plugin_t; + +struct input_class_s { + + /* + * create a new instance of this plugin class + * return NULL if the plugin does'nt handle the given mrl + */ + input_plugin_t* (*get_instance) (input_class_t *this, xine_stream_t *stream, const char *mrl); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * ls function, optional: may be NULL + * return value: NULL => filename is a file, **char=> filename is a dir + */ + xine_mrl_t ** (*get_dir) (input_class_t *this, const char *filename, int *nFiles); + + /* + * generate autoplay list, optional: may be NULL + * return value: list of MRLs + */ + const char * const * (*get_autoplay_list) (input_class_t *this, int *num_files); + + /* + * close down, free all resources + */ + void (*dispose) (input_class_t *this); + + /* + * eject/load the media (if possible), optional: may be NULL + * + * returns 0 for temporary failures + */ + int (*eject_media) (input_class_t *this); +}; + +#define default_input_class_dispose (void (*) (input_class_t *this))free + +struct input_plugin_s { + + /* + * open the stream + * return 0 if an error occured + */ + int (*open) (input_plugin_t *this); + + /* + * return capabilities of the current playable entity. See + * get_current_pos below for a description of a "playable entity" + * Capabilities a created by "OR"ing a mask of constants listed + * below which start "INPUT_CAP". + * + * depending on the values set, some of the functions below + * will or will not get called or should (not) be able to + * do certain tasks. + * + * for example if INPUT_CAP_SEEKABLE is set, + * the seek() function is expected to work fully at any time. + * however, if the flag is not set, the seek() function should + * make a best-effort attempt to seek, e.g. at least + * relative forward seeking should work. + */ + uint32_t (*get_capabilities) (input_plugin_t *this); + + /* + * read nlen bytes, return number of bytes read + * Should block until some bytes available for read; + * a return value of 0 indicates no data available + */ + off_t (*read) (input_plugin_t *this, void *buf, off_t nlen); + + + /* + * read one block, return newly allocated block (or NULL on failure) + * for blocked input sources len must be == blocksize + * the fifo parameter is only used to get access to the buffer_pool_alloc function + */ + buf_element_t *(*read_block)(input_plugin_t *this, fifo_buffer_t *fifo, off_t len); + + + /* + * seek position, return new position + * + * if seeking failed, -1 is returned + */ + off_t (*seek) (input_plugin_t *this, off_t offset, int origin); + + + /* + * seek to time position, return new position + * time_offset is given in miliseconds + * + * if seeking failed, -1 is returned + * + * note: only SEEK_SET (0) is currently supported as origin + * note: may be NULL is not supported + */ + off_t (*seek_time) (input_plugin_t *this, int time_offset, int origin); + + + /* + * get current position in stream. + * + */ + off_t (*get_current_pos) (input_plugin_t *this); + + + /* + * get current time position in stream in miliseconds. + * + * note: may be NULL is not supported + */ + int (*get_current_time) (input_plugin_t *this); + + + /* + * return number of bytes in the next playable entity or -1 if the + * input is unlimited, as would be the case in a network stream. + * + * A "playable entity" tends to be the entities listed in a playback + * list or the units on which playback control generally works on. + * It might be the number of bytes in a VCD "segment" or "track" (if + * the track has no "entry" subdivisions), or the number of bytes in + * a PS (Program Segment or "Chapter") of a DVD. If there are no + * subdivisions of the input medium and it is considered one + * indivisible entity, it would be the byte count of that entity; + * for example, the length in bytes of an MPEG file. + + * This length information is used, for example when in setting the + * absolute or relative play position or possibly calculating the + * bit rate. + */ + off_t (*get_length) (input_plugin_t *this); + + + /* + * return block size in bytes of next complete playable entity (if + * supported, 0 otherwise). See the description above under + * get_length for a description of a "complete playable entity". + * + * this block size is only used for mpeg streams stored on + * a block oriented storage media, e.g. DVDs and VCDs, to speed + * up the demuxing process. only set this (and the INPUT_CAP_BLOCK + * flag) if this is the case for your input plugin. + * + * make this function simply return 0 if unsure. + */ + + uint32_t (*get_blocksize) (input_plugin_t *this); + + + /* + * return current MRL + */ + const char * (*get_mrl) (input_plugin_t *this); + + + /* + * request optional data from input plugin. + */ + int (*get_optional_data) (input_plugin_t *this, void *data, int data_type); + + + /* + * close stream, free instance resources + */ + void (*dispose) (input_plugin_t *this); + + /* + * "backward" link to input plugin class struct + */ + + input_class_t *input_class; + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif + +}; + +/* + * possible capabilites an input plugin can have: + */ +#define INPUT_CAP_NOCAP 0x00000000 + +/* + * INPUT_CAP_SEEKABLE: + * seek () works reliably. + * even for plugins that do not have this flag set + * it is a good idea to implement the seek() function + * in a "best effort" style anyway, so at least + * throw away data for network streams when seeking forward + */ + +#define INPUT_CAP_SEEKABLE 0x00000001 + +/* + * INPUT_CAP_BLOCK: + * means more or less that a block device sits behind + * this input plugin. get_blocksize must be implemented. + * will be used for fast and efficient demuxing of + * mpeg streams (demux_mpeg_block). + */ + +#define INPUT_CAP_BLOCK 0x00000002 + +/* + * INPUT_CAP_AUDIOLANG: + * INPUT_CAP_SPULANG: + * input plugin knows something about audio/spu languages, + * e.g. knows that audio stream #0 is english, + * audio stream #1 is german, ... + * *((int *)data) will provide the requested channel number + * and awaits the language back in (char *)data + */ + +#define INPUT_CAP_AUDIOLANG 0x00000008 +#define INPUT_CAP_SPULANG 0x00000010 + +/* + * INPUT_CAP_PREVIEW: + * get_optional_data can handle INPUT_OPTIONAL_DATA_PREVIEW + * so a non-seekable stream plugin can povide the first + * few bytes for demuxers to look at them and decide wheter + * they can handle the stream or not. the preview data must + * be buffered and delivered again through subsequent + * read() calls. + * caller must provide a buffer allocated with at least + * MAX_PREVIEW_SIZE bytes. + */ + +#define INPUT_CAP_PREVIEW 0x00000040 + +/* + * INPUT_CAP_CHAPTERS: + * The media streams provided by this plugin have an internal + * structure dividing it into segments usable for navigation. + * For those plugins, the behaviour of the skip button in UIs + * should be changed from "next MRL" to "next chapter" by + * sending XINE_EVENT_INPUT_NEXT. + */ + +#define INPUT_CAP_CHAPTERS 0x00000080 + +/* + * INPUT_CAP_RIP_FORBIDDEN: + * means that rip/disk saving must not be used. + * (probably at author's request) + */ + +#define INPUT_CAP_RIP_FORBIDDEN 0x00000100 + + +#define INPUT_IS_SEEKABLE(input) (((input)->get_capabilities(input) & INPUT_CAP_SEEKABLE) != 0) + +#define INPUT_OPTIONAL_UNSUPPORTED 0 +#define INPUT_OPTIONAL_SUCCESS 1 + +#define INPUT_OPTIONAL_DATA_AUDIOLANG 2 +#define INPUT_OPTIONAL_DATA_SPULANG 3 +#define INPUT_OPTIONAL_DATA_PREVIEW 7 + +/* buffer is a const char **; the string is freed by the input plugin. */ +#define INPUT_OPTIONAL_DATA_MIME_TYPE 8 +/* buffer is unused; true if the demuxer should be determined by the MIME type */ +#define INPUT_OPTIONAL_DATA_DEMUX_MIME_TYPE 9 +/* buffer is a const char **; the string is static or freed by the input plugin. */ +#define INPUT_OPTIONAL_DATA_DEMUXER 10 + +#define MAX_MRL_ENTRIES 255 +#define MAX_PREVIEW_SIZE 4096 + +/* Types of mrls returned by get_dir() */ +#define mrl_unknown (0 << 0) +#define mrl_dvd (1 << 0) +#define mrl_vcd (1 << 1) +#define mrl_net (1 << 2) +#define mrl_rtp (1 << 3) +#define mrl_stdin (1 << 4) +#define mrl_cda (1 << 5) +#define mrl_file (1 << 6) +#define mrl_file_fifo (1 << 7) +#define mrl_file_chardev (1 << 8) +#define mrl_file_directory (1 << 9) +#define mrl_file_blockdev (1 << 10) +#define mrl_file_normal (1 << 11) +#define mrl_file_symlink (1 << 12) +#define mrl_file_sock (1 << 13) +#define mrl_file_exec (1 << 14) +#define mrl_file_backup (1 << 15) +#define mrl_file_hidden (1 << 16) + +/* + * Freeing/zeroing all of entries of given mrl. + */ +#define MRL_ZERO(m) { \ + if((m)) { \ + free((m)->origin); \ + free((m)->mrl); \ + free((m)->link); \ + (m)->origin = NULL; \ + (m)->mrl = NULL; \ + (m)->link = NULL; \ + (m)->type = 0; \ + (m)->size = (off_t) 0; \ + } \ + } + +/* + * Duplicate two mrls entries (s = source, d = destination). + */ +#define MRL_DUPLICATE(s, d) { \ + _x_assert((s) != NULL); \ + _x_assert((d) != NULL); \ + \ + free((d)->origin); \ + (d)->origin = (s)->origin ? strdup((s)->origin) : NULL; \ + \ + free((d)->mrl); \ + (d)->mrl = (s)->mrl ? strdup((s)->mrl) : NULL; \ + \ + free((d)->link); \ + (d)->link = (s)->link ? strdup((s)->link) : NULL; \ + \ + (d)->type = (s)->type; \ + (d)->size = (s)->size; \ + } + +/* + * Duplicate two arrays of mrls (s = source, d = destination). + */ +#define MRLS_DUPLICATE(s, d) { \ + int i = 0; \ + \ + _x_assert((s) != NULL); \ + _x_assert((d) != NULL); \ + \ + while((s) != NULL) { \ + d[i] = (xine_mrl_t *) malloc(sizeof(xine_mrl_t)); \ + MRL_DUPLICATE(s[i], d[i]); \ + i++; \ + } \ +} + + +#endif diff --git a/include/xine/io_helper.h b/include/xine/io_helper.h new file mode 100644 index 000000000..0aac8fcfc --- /dev/null +++ b/include/xine/io_helper.h @@ -0,0 +1,141 @@ +/* + * Copyright (C) 2000-2003 the xine project, + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * abortable i/o helper functions + */ + +#ifndef IO_HELPER_H +#define IO_HELPER_H + +#include "xine_internal.h" + + +/* select states */ +#define XIO_READ_READY 1 +#define XIO_WRITE_READY 2 + +/* xine select return codes */ +#define XIO_READY 0 +#define XIO_ERROR 1 +#define XIO_ABORTED 2 +#define XIO_TIMEOUT 3 + + +/* + * Waits for a file descriptor/socket to change status. + * + * network input plugins should use this function in order to + * not freeze the engine. + * + * params : + * stream needed for aborting and reporting errors but may be NULL + * fd file/socket descriptor + * state XIO_READ_READY, XIO_WRITE_READY + * timeout_sec timeout in seconds + * + * An other thread can abort this function if stream != NULL by setting + * stream->demux_action_pending. + * + * return value : + * XIO_READY the file descriptor is ready for cmd + * XIO_ERROR an i/o error occured + * XIO_ABORTED command aborted by an other thread + * XIO_TIMEOUT the file descriptor is not ready after timeout_msec milliseconds + */ +int _x_io_select (xine_stream_t *stream, int fd, int state, int timeout_msec) XINE_PROTECTED; + + +/* + * open a tcp connection + * + * params : + * stream needed for reporting errors but may be NULL + * host address of target + * port port on target + * + * returns a socket descriptor or -1 if an error occured + */ +int _x_io_tcp_connect(xine_stream_t *stream, const char *host, int port) XINE_PROTECTED; + +/* + * wait for finish connection + * + * params : + * stream needed for aborting and reporting errors but may be NULL + * fd socket descriptor + * timeout_msec timeout in milliseconds + * + * return value: + * XIO_READY host respond, the socket is ready for cmd + * XIO_ERROR an i/o error occured + * XIO_ABORTED command aborted by an other thread + * XIO_TIMEOUT the file descriptor is not ready after timeout + */ +int _x_io_tcp_connect_finish(xine_stream_t *stream, int fd, int timeout_msec) XINE_PROTECTED; + +/* + * read from tcp socket checking demux_action_pending + * + * network input plugins should use this function in order to + * not freeze the engine. + * + * aborts with zero if no data is available and *abort is set + */ +off_t _x_io_tcp_read (xine_stream_t *stream, int s, void *buf, off_t todo) XINE_PROTECTED; + + +/* + * write to a tcp socket checking demux_action_pending + * + * network input plugins should use this function in order to + * not freeze the engine. + * + * aborts with zero if no data is available and *abort is set + */ +off_t _x_io_tcp_write (xine_stream_t *stream, int s, void *buf, off_t todo) XINE_PROTECTED; + +/* + * read from a file descriptor checking demux_action_pending + * + * the fifo input plugin should use this function in order to + * not freeze the engine. + * + * aborts with zero if no data is available and *abort is set + */ +off_t _x_io_file_read (xine_stream_t *stream, int fd, void *buf, off_t todo) XINE_PROTECTED; + + +/* + * write to a file descriptor checking demux_action_pending + * + * the fifo input plugin should use this function in order to + * not freeze the engine. + * + * aborts with zero if *abort is set + */ +off_t _x_io_file_write (xine_stream_t *stream, int fd, void *buf, off_t todo) XINE_PROTECTED; + +/* + * read a string from socket, return string length (same as strlen) + * the string is always '\0' terminated but given buffer size is never exceeded + * that is, _x_io_tcp_read_line(,,,X) <= (X-1) ; X > 0 + */ +int _x_io_tcp_read_line(xine_stream_t *stream, int sock, char *str, int size) XINE_PROTECTED; + +#endif diff --git a/include/xine/list.h b/include/xine/list.h new file mode 100644 index 000000000..4910f9982 --- /dev/null +++ b/include/xine/list.h @@ -0,0 +1,104 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Doubly-linked linked list. + * + * Exemples: + * + * Create a list: + * xine_list_t *list = xine_list_new(); + * + * Delete a list: + * xine_list_delete(list); + * + * Walk thru a list: + * xine_list_iterator_t ite = xine_list_front(list); + * while (ite) { + * _useful code here_ + * ite = xine_list_next(list, ite); + * } + * + * The list elements are managed using memory chunks and a free list. The first + * chunk contains 32 elements, each following chunk is two time as big as the + * previous one, with a limit of 64K elements. + */ +#ifndef XINE_LIST_H +#define XINE_LIST_H + +/* Doubly-linked list type */ +typedef struct xine_list_s xine_list_t; + +/* List iterator */ +typedef void* xine_list_iterator_t; + +/* Constructor */ +xine_list_t *xine_list_new(void) XINE_MALLOC XINE_PROTECTED; + +/* Destructor */ +void xine_list_delete(xine_list_t *list) XINE_PROTECTED; + +/* Returns the number of element stored in the list */ +unsigned int xine_list_size(xine_list_t *list) XINE_PROTECTED; + +/* Returns true if the number of elements is zero, false otherwise */ +unsigned int xine_list_empty(xine_list_t *list) XINE_PROTECTED; + +/* Adds the element at the beginning of the list */ +void xine_list_push_front(xine_list_t *list, void *value) XINE_PROTECTED; + +/* Adds the element at the end of the list */ +void xine_list_push_back(xine_list_t *list, void *value) XINE_PROTECTED; + +/* Remove all elements from a list */ +void xine_list_clear(xine_list_t *list) XINE_PROTECTED; + +/* Insert the element elem into the list at the position specified by the + iterator (before the element, if any, that was previously at the iterator's + position). The return value is an iterator that specifies the position of + the inserted element. */ +xine_list_iterator_t xine_list_insert(xine_list_t *list, + xine_list_iterator_t position, + void *value) XINE_PROTECTED; + +/* Remove one element from a list.*/ +void xine_list_remove(xine_list_t *list, xine_list_iterator_t position) XINE_PROTECTED; + +/* Returns an iterator that references the first element of the list */ +xine_list_iterator_t xine_list_front(xine_list_t *list) XINE_PROTECTED; + +/* Returns an iterator that references the last element of the list */ +xine_list_iterator_t xine_list_back(xine_list_t *list) XINE_PROTECTED; + +/* Perform a linear search of a given value, and returns an iterator that + references this value or NULL if not found */ +xine_list_iterator_t xine_list_find(xine_list_t *list, void *value) XINE_PROTECTED; + +/* Increments the iterator's value, so it specifies the next element in the list + or NULL at the end of the list */ +xine_list_iterator_t xine_list_next(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED; + +/* Increments the iterator's value, so it specifies the previous element in the list + or NULL at the beginning of the list */ +xine_list_iterator_t xine_list_prev(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED; + +/* Returns the value at the position specified by the iterator */ +void *xine_list_get_value(xine_list_t *list, xine_list_iterator_t ite) XINE_PROTECTED; + +#endif + diff --git a/include/xine/metronom.h b/include/xine/metronom.h new file mode 100644 index 000000000..4f4bb04eb --- /dev/null +++ b/include/xine/metronom.h @@ -0,0 +1,359 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * metronom: general pts => virtual calculation/assoc + * + * virtual pts: unit 1/90000 sec, always increasing + * can be used for synchronization + * video/audio frame with same pts also have same vpts + * but pts is likely to differ from vpts + * + * the basic idea is: + * video_pts + video_wrap_offset = video_vpts + * audio_pts + audio_wrap_offset = audio_vpts + * + * - video_wrap_offset should be equal to audio_wrap_offset as to have + * perfect audio and video sync. They will differ on brief periods due + * discontinuity correction. + * - metronom should also interpolate vpts values most of the time as + * video_pts and audio_vpts are not given for every frame. + * - corrections to the frame rate may be needed to cope with bad + * encoded streams. + */ + +#ifndef HAVE_METRONOM_H +#define HAVE_METRONOM_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <pthread.h> + +#include <xine/video_out.h> +#include <xine.h> + +typedef struct metronom_s metronom_t ; +typedef struct metronom_clock_s metronom_clock_t; +typedef struct scr_plugin_s scr_plugin_t; + +/* metronom prebuffer can be adjusted with XINE_PARAM_METRONOM_PREBUFFER. + * it sets how much the first video/audio frame should be delayed to + * have some prebuffering at the output layers. reducing this value (about + * 1/8 sec) may result in faster seeking (good to simulate play backwards, + * for example). + */ +#define PREBUFFER_PTS_OFFSET 12000 + + /* see below */ +#define DISC_STREAMSTART 0 +#define DISC_RELATIVE 1 +#define DISC_ABSOLUTE 2 +#define DISC_STREAMSEEK 3 + +struct metronom_s { + + /* + * called by audio output driver to inform metronom about current audio + * samplerate + * + * parameter pts_per_smpls : 1/90000 sec per 65536 samples + */ + void (*set_audio_rate) (metronom_t *self, int64_t pts_per_smpls); + + /* + * called by video output driver for *every* frame + * + * parameter frame containing pts, scr, ... information + * + * will set vpts field in frame + * + * this function will also update video_wrap_offset if a discontinuity + * is detected (read the comentaries below about discontinuities). + * + */ + + void (*got_video_frame) (metronom_t *self, vo_frame_t *frame); + + /* + * called by audio output driver whenever audio samples are delivered to it + * + * parameter pts : pts for audio data if known, 0 otherwise + * nsamples : number of samples delivered + * + * return value: virtual pts for audio data + * + * this function will also update audio_wrap_offset if a discontinuity + * is detected (read the comentaries below about discontinuities). + * + */ + + int64_t (*got_audio_samples) (metronom_t *self, int64_t pts, + int nsamples); + + /* + * called by SPU decoder whenever a packet is delivered to it + * + * parameter pts : pts for SPU packet if known, 0 otherwise + * + * return value: virtual pts for SPU packet + * (this is the only pts to vpts function that cannot update the wrap_offset + * due to the lack of regularity on spu packets) + */ + + int64_t (*got_spu_packet) (metronom_t *self, int64_t pts); + + /* + * tell metronom about discontinuities. + * + * these functions are called due to a discontinuity detected at + * demux stage. + * + * there are different types of discontinuities: + * + * DISC_STREAMSTART : new stream starts, expect pts values to start + * from zero immediately + * DISC_RELATIVE : typically a wrap-around, expect pts with + * a specified offset from the former ones soon + * DISC_ABSOLUTE : typically a new menu stream (nav packets) + * pts will start from given value soon + * DISC_STREAMSEEK : used by video and audio decoder loop, + * when a buffer with BUF_FLAG_SEEK set is encountered; + * applies the necessary vpts offset for the seek in + * metronom, but keeps the vpts difference between + * audio and video, so that metronom doesn't cough + */ + void (*handle_audio_discontinuity) (metronom_t *self, int type, int64_t disc_off); + void (*handle_video_discontinuity) (metronom_t *self, int type, int64_t disc_off); + + /* + * set/get options for metronom, constants see below + */ + void (*set_option) (metronom_t *self, int option, int64_t value); + int64_t (*get_option) (metronom_t *self, int option); + + /* + * set a master metronom + * this is currently useful to sync independently generated streams + * (e.g. by post plugins) to the discontinuity domain of another + * metronom + */ + void (*set_master) (metronom_t *self, metronom_t *master); + + void (*exit) (metronom_t *self); + +#ifdef METRONOM_INTERNAL + /* + * metronom internal stuff + */ + xine_t *xine; + + metronom_t *master; + + int64_t pts_per_smpls; + + int64_t video_vpts; + int64_t spu_vpts; + int64_t audio_vpts; + int64_t audio_vpts_rmndr; /* the remainder for integer division */ + + int64_t vpts_offset; + + int64_t video_drift; + int64_t video_drift_step; + + int audio_samples; + int64_t audio_drift_step; + + int64_t prebuffer; + int64_t av_offset; + int64_t spu_offset; + + pthread_mutex_t lock; + + int have_video; + int have_audio; + int video_discontinuity_count; + int audio_discontinuity_count; + int discontinuity_handled_count; + pthread_cond_t video_discontinuity_reached; + pthread_cond_t audio_discontinuity_reached; + + int force_video_jump; + int force_audio_jump; + + int64_t img_duration; + int img_cpt; + int64_t last_video_pts; + int64_t last_audio_pts; + + int video_mode; +#endif +}; + +/* + * metronom options + */ + +#define METRONOM_AV_OFFSET 2 +#define METRONOM_ADJ_VPTS_OFFSET 3 +#define METRONOM_FRAME_DURATION 4 +#define METRONOM_SPU_OFFSET 5 +#define METRONOM_VPTS_OFFSET 6 +#define METRONOM_PREBUFFER 7 + +metronom_t *_x_metronom_init (int have_video, int have_audio, xine_t *xine) XINE_MALLOC XINE_PROTECTED; + +/* FIXME: reorder this structure on the next cleanup to remove the dummies */ +struct metronom_clock_s { + + /* + * set/get options for clock, constants see below + */ + void (*set_option) (metronom_clock_t *self, int option, int64_t value); + int64_t (*get_option) (metronom_clock_t *self, int option); + + /* + * system clock reference (SCR) functions + */ + +#ifdef METRONOM_CLOCK_INTERNAL + /* + * start clock (no clock reset) + * at given pts + */ + void (*start_clock) (metronom_clock_t *self, int64_t pts); + + + /* + * stop metronom clock + */ + void (*stop_clock) (metronom_clock_t *self); + + + /* + * resume clock from where it was stopped + */ + void (*resume_clock) (metronom_clock_t *self); +#else + void *dummy1; + void *dummy2; + void *dummy3; +#endif + + + /* + * get current clock value in vpts + */ + int64_t (*get_current_time) (metronom_clock_t *self); + + + /* + * adjust master clock to external timer (e.g. audio hardware) + */ + void (*adjust_clock) (metronom_clock_t *self, int64_t desired_pts); + +#ifdef METRONOM_CLOCK_INTERNAL + /* + * set clock speed + * for constants see xine_internal.h + */ + + int (*set_fine_speed) (metronom_clock_t *self, int speed); +#else + void *dummy4; +#endif + + /* + * (un)register a System Clock Reference provider at the metronom + */ + int (*register_scr) (metronom_clock_t *self, scr_plugin_t *scr); + void (*unregister_scr) (metronom_clock_t *self, scr_plugin_t *scr); + +#ifdef METRONOM_CLOCK_INTERNAL + void (*exit) (metronom_clock_t *self); + + xine_t *xine; + + scr_plugin_t *scr_master; + scr_plugin_t **scr_list; + pthread_t sync_thread; + int thread_running; + int scr_adjustable; +#else + void *dummy5; + void *dummy6; + void *dummy7; + void *dummy8; + pthread_t dummy9; + int dummy10; + int dummy11; +#endif + + int speed; + +#ifdef METRONOM_CLOCK_INTERNAL + pthread_mutex_t lock; + pthread_cond_t cancel; +#endif +}; + +metronom_clock_t *_x_metronom_clock_init(xine_t *xine) XINE_MALLOC XINE_PROTECTED; + +/* + * clock options + */ + +#define CLOCK_SCR_ADJUSTABLE 1 + +/* + * SCR (system clock reference) plugins + */ + +struct scr_plugin_s +{ + int (*get_priority) (scr_plugin_t *self); + + /* + * set/get clock speed + * + * for speed constants see xine_internal.h + * returns actual speed + */ + + int (*set_fine_speed) (scr_plugin_t *self, int speed); + + void (*adjust) (scr_plugin_t *self, int64_t vpts); + + void (*start) (scr_plugin_t *self, int64_t start_vpts); + + int64_t (*get_current) (scr_plugin_t *self); + + void (*exit) (scr_plugin_t *self); + + metronom_clock_t *clock; + + int interface_version; +}; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/os_types.h b/include/xine/os_types.h new file mode 100644 index 000000000..aa6eddb00 --- /dev/null +++ b/include/xine/os_types.h @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2004-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Platform dependent types needed by public xine.h. + * Types not needed by xine.h are specified in os_internal.h. + * + * Heavily based on os_types.h from OggVorbis (BSD License), + * not tested on all platforms with xine. + */ + +#ifndef XINE_OS_TYPES_H +#define XINE_OS_TYPES_H + +#if defined(_WIN32) && !defined(__GNUC__) + + /* MSVC/Borland */ + typedef __int8 int8_t; + typedef unsigned __int8 uint8_t; + typedef __int16 int16_t; + typedef unsigned __int16 uint16_t; + typedef __int32 int32_t; + typedef unsigned __int32 uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; + +#elif defined(__MACOS__) + +# include <sys/types.h> + typedef SInt8 int8_t; + typedef UInt8 uint8_t; + typedef SInt16 int16_t; + typedef UInt16 uint16_t; + typedef SInt32 int32_t; + typedef UInt32 uint32_t; + typedef SInt64 int64_t; + typedef UInt64 uint64_t; + +#elif defined(__MACOSX__) /* MacOS X Framework build */ + +# include <sys/types.h> + typedef u_int8_t uint8_t; + typedef u_int16_t uint16_t; + typedef u_int32_t uint32_t; + typedef u_int64_t uint64_t; + +#elif defined (__EMX__) + + /* OS/2 GCC */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef long long int64_t; + typedef unsigned long long int64_t; + +#elif defined (DJGPP) + + /* DJGPP */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef long long int64_t; + typedef unsigned long long uint64_t; + +#elif defined(R5900) + + /* PS2 EE */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short int16_t; + typedef int int32_t; + typedef unsigned uint32_t; + typedef long int64_t; + typedef unsigned long int64_t; + +#else + + /* + * CygWin: _WIN32 & __GNUC__ + * BeOS: __BEOS__ + * Linux, Solaris, Mac and others + */ +# include <inttypes.h> + +#endif + +#endif /* XINE_OS_TYPES_H */ diff --git a/include/xine/osd.h b/include/xine/osd.h new file mode 100644 index 000000000..44471534b --- /dev/null +++ b/include/xine/osd.h @@ -0,0 +1,302 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * OSD stuff (text and graphic primitives) + */ + +#ifndef HAVE_OSD_H +#define HAVE_OSD_H + +#ifdef HAVE_ICONV +# include <iconv.h> +#endif + +#include <xine/video_overlay.h> + +typedef struct osd_object_s osd_object_t; +typedef struct osd_renderer_s osd_renderer_t; +typedef struct osd_font_s osd_font_t; +typedef struct osd_ft2context_s osd_ft2context_t; + +struct osd_object_s { + osd_object_t *next; + osd_renderer_t *renderer; + + int width, height; /* work area dimentions */ + uint8_t *area; /* work area */ + int area_touched; /* work area was used for painting */ + int display_x,display_y; /* where to display it in screen */ + + /* video output area within osd extent */ + int video_window_x, video_window_y; + int video_window_width, video_window_height; + + /* extent of reference coordinate system */ + int extent_width, extent_height; + + /* clipping box inside work area */ + int x1, y1; + int x2, y2; + + uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */ + uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */ + +#ifdef HAVE_ICONV + iconv_t cd; /* iconv handle of encoding */ + char *encoding; /* name of encoding */ +#endif + + osd_font_t *font; + osd_ft2context_t *ft2; + + + /* this holds an optional ARGB overlay, which + * is only be used by supported video_out modules. + * right now this is only vdpau */ + argb_layer_t *argb_layer; + + int32_t handle; +}; + +/* this one is public */ +struct xine_osd_s { + osd_object_t osd; +}; + +struct osd_renderer_s { + + xine_stream_t *stream; + + /* + * open a new osd object. this will allocated an empty (all zero) drawing + * area where graphic primitives may be used. + * It is ok to specify big width and height values. The render will keep + * track of the smallest changed area to not generate too big overlays. + * A default palette is initialized (i sugest keeping color 0 as transparent + * for the sake of simplicity) + */ + osd_object_t* (*new_object) (osd_renderer_t *this, int width, int height); + + /* + * free osd object + */ + void (*free_object) (osd_object_t *osd_to_close); + + + /* + * send the osd to be displayed at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ + int (*show) (osd_object_t *osd, int64_t vpts ); + + /* + * send event to hide osd at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + */ + int (*hide) (osd_object_t *osd, int64_t vpts ); + + /* + * draw point. + */ + void (*point) (osd_object_t *osd, int x, int y, int color); + + /* + * Bresenham line implementation on osd object + */ + void (*line) (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color ); + + /* + * filled rectangle + */ + void (*filled_rect) (osd_object_t *osd, + int x1, int y1, int x2, int y2, int color ); + + /* + * set palette (color and transparency) + */ + void (*set_palette) (osd_object_t *osd, const uint32_t *color, const uint8_t *trans ); + + /* + * set on existing text palette + * (-1 to set used specified palette) + * + * color_base specifies the first color index to use for this text + * palette. The OSD palette is then modified starting at this + * color index, up to the size of the text palette. + * + * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices. + */ + void (*set_text_palette) (osd_object_t *osd, int palette_number, + int color_base ); + + /* + * get palette (color and transparency) + */ + void (*get_palette) (osd_object_t *osd, uint32_t *color, + uint8_t *trans); + + /* + * set position were overlay will be blended + */ + void (*set_position) (osd_object_t *osd, int x, int y); + + /* + * set the font of osd object + */ + + int (*set_font) (osd_object_t *osd, const char *fontname, int size); + + /* + * set encoding of text + * + * NULL ... no conversion (iso-8859-1) + * "" ... locale encoding + */ + int (*set_encoding) (osd_object_t *osd, const char *encoding); + + /* + * render text in current encoding on x,y position + * no \n yet + * + * The text is assigned the colors starting at the index specified by + * color_base up to the size of the text palette. + * + * Use OSD_TEXT1, OSD_TEXT2, ... for some preasssigned color indices. + */ + int (*render_text) (osd_object_t *osd, int x1, int y1, + const char *text, int color_base); + + /* + * get width and height of how text will be renderized + */ + int (*get_text_size) (osd_object_t *osd, const char *text, + int *width, int *height); + + /* + * close osd rendering engine + * loaded fonts are unloaded + * osd objects are closed + */ + void (*close) (osd_renderer_t *this); + + /* + * clear an osd object (empty drawing area) + */ + void (*clear) (osd_object_t *osd ); + + /* + * paste a bitmap with optional palette mapping + */ + void (*draw_bitmap) (osd_object_t *osd, uint8_t *bitmap, + int x1, int y1, int width, int height, + uint8_t *palette_map); + + /* + * send the osd to be displayed (unscaled) at given pts (0=now) + * the object is not changed. there may be subsequent drawing on it. + * overlay is blended at output (screen) resolution. + */ + int (*show_unscaled) (osd_object_t *osd, int64_t vpts ); + + /* + * see xine.h for defined XINE_OSD_CAP_ values. + */ + uint32_t (*get_capabilities) (osd_object_t *osd); + + /* + * define extent of reference coordinate system for video + * resolution independent osds. both sizes must be > 0 to + * take effect. otherwise, video resolution will be used. + */ + void (*set_extent) (osd_object_t *osd, int extent_width, int extent_height); + + /* + * set an argb buffer to be blended into video + * the buffer must exactly match the osd dimensions + * and stay valid while the osd is on screen. pass + * a NULL pointer to safely remove the buffer from + * the osd layer. only the dirty area will be + * updated on screen. for convinience the whole + * osd object will be considered dirty when setting + * a different buffer pointer. + * see also XINE_OSD_CAP_ARGB_LAYER + */ + void (*set_argb_buffer) (osd_object_t *osd, uint32_t *argb_buffer, + int dirty_x, int dirty_y, int dirty_width, int dirty_height); + + /* + * osd video window defines an area withing osd extent where the + * video shall be scaled to while an osd is displayed on screen. + * both width and height must be > 0 to take effect. + */ + void (*set_video_window) (osd_object_t *osd, + int window_x, int window_y, int window_width, int window_height); + + /* private stuff */ + + pthread_mutex_t osd_mutex; + video_overlay_event_t event; + osd_object_t *osds; /* instances of osd */ + osd_font_t *fonts; /* loaded fonts */ + int textpalette; /* default textpalette */ + +}; + +/* + * initialize the osd rendering engine + */ +osd_renderer_t *_x_osd_renderer_init( xine_stream_t *stream ) XINE_MALLOC; + + +/* + * The size of a text palette + */ + +#define TEXT_PALETTE_SIZE 11 + +/* + * Preassigned color indices for rendering text + * (more can be added, not exceeding OVL_PALETTE_SIZE) + */ + +#define OSD_TEXT1 (0 * TEXT_PALETTE_SIZE) +#define OSD_TEXT2 (1 * TEXT_PALETTE_SIZE) +#define OSD_TEXT3 (2 * TEXT_PALETTE_SIZE) +#define OSD_TEXT4 (3 * TEXT_PALETTE_SIZE) +#define OSD_TEXT5 (4 * TEXT_PALETTE_SIZE) +#define OSD_TEXT6 (5 * TEXT_PALETTE_SIZE) +#define OSD_TEXT7 (6 * TEXT_PALETTE_SIZE) +#define OSD_TEXT8 (7 * TEXT_PALETTE_SIZE) +#define OSD_TEXT9 (8 * TEXT_PALETTE_SIZE) +#define OSD_TEXT10 (9 * TEXT_PALETTE_SIZE) + +/* + * Defined palettes for rendering osd text + * (more can be added later) + */ + +#define NUMBER_OF_TEXT_PALETTES 4 +#define TEXTPALETTE_WHITE_BLACK_TRANSPARENT 0 +#define TEXTPALETTE_WHITE_NONE_TRANSPARENT 1 +#define TEXTPALETTE_WHITE_NONE_TRANSLUCID 2 +#define TEXTPALETTE_YELLOW_BLACK_TRANSPARENT 3 + +#endif + diff --git a/include/xine/plugin_catalog.h b/include/xine/plugin_catalog.h new file mode 100644 index 000000000..0f4a464b3 --- /dev/null +++ b/include/xine/plugin_catalog.h @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * xine-internal header: Definitions for plugin lists + */ + +#ifndef _PLUGIN_CATALOG_H +#define _PLUGIN_CATALOG_H + +#include <xine/xine_plugin.h> +#include <xine/xineutils.h> + +#define DECODER_MAX 128 +#define PLUGIN_MAX 256 + +/* the engine takes this many plugins for one stream type */ +#define PLUGINS_PER_TYPE 10 + +typedef struct { + char *filename; + off_t filesize; + time_t filemtime; + void *lib_handle; + int ref; /* count number of classes */ + int no_unload; /* set if the file can't be unloaded */ +} plugin_file_t ; + +typedef struct { + plugin_file_t *file; + plugin_info_t *info; + void *plugin_class; + xine_list_t *config_entry_list; + int ref; /* count intances of plugins */ + int priority; +} plugin_node_t ; + +struct plugin_catalog_s { + xine_sarray_t *plugin_lists[PLUGIN_TYPE_MAX]; + + xine_sarray_t *cache_list; + xine_list_t *file_list; + + plugin_node_t *audio_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE]; + plugin_node_t *video_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE]; + plugin_node_t *spu_decoder_map[DECODER_MAX][PLUGINS_PER_TYPE]; + + const char *ids[PLUGIN_MAX]; + + /* memory block for the decoder priority config entry descriptions */ + char *prio_desc[DECODER_MAX]; + + pthread_mutex_t lock; + + int plugin_count; + int decoder_count; +}; +typedef struct plugin_catalog_s plugin_catalog_t; + +#endif diff --git a/include/xine/pool.h b/include/xine/pool.h new file mode 100644 index 000000000..37f60220c --- /dev/null +++ b/include/xine/pool.h @@ -0,0 +1,48 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Object Pool + */ + +#include <stdlib.h> +#include <inttypes.h> + +typedef struct xine_pool_s xine_pool_t; + +/* Creates a new pool + * object_size: sizeof(your struct) + * create_object: function called to create an object (can be NULL) + * prepare_object: function called to prepare an object to returned to the client (can be NULL) + * return_object: function called to prepare an object to returned to the pool (can be NULL) + * delete_object: function called to delete an object (can be NULL) + */ +xine_pool_t *xine_pool_new(size_t object_size, + void (create_object)(void *object), + void (prepare_object)(void *object), + void (return_object)(void *object), + void (delete_object)(void *object)) XINE_MALLOC XINE_PROTECTED; + +/* Deletes a pool */ +void xine_pool_delete(xine_pool_t *pool) XINE_PROTECTED; + +/* Get an object from the pool */ +void *xine_pool_get(xine_pool_t *pool) XINE_PROTECTED; + +/* Returns an object to the pool */ +void xine_pool_put(xine_pool_t *pool, void *object) XINE_PROTECTED; diff --git a/include/xine/post.h b/include/xine/post.h new file mode 100644 index 000000000..f0d0c9316 --- /dev/null +++ b/include/xine/post.h @@ -0,0 +1,410 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * post plugin definitions + */ + +#ifndef XINE_POST_H +#define XINE_POST_H + +#include <xine.h> +#include <xine/video_out.h> +#include <xine/audio_out.h> +#include <xine/xine_internal.h> +#include <xine/xineutils.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define POST_PLUGIN_IFACE_VERSION 10 + + +typedef struct post_class_s post_class_t; +typedef struct post_plugin_s post_plugin_t; +typedef struct post_in_s post_in_t; +typedef struct post_out_s post_out_t; + +struct post_class_s { + + /* + * open a new instance of this plugin class + */ + post_plugin_t* (*open_plugin) (post_class_t *this, int inputs, + xine_audio_port_t **audio_target, + xine_video_port_t **video_target); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + + void (*dispose) (post_class_t *this); +}; + +#define default_post_class_dispose (void (*) (post_class_t *this))free + +struct post_plugin_s { + + /* public part of the plugin */ + xine_post_t xine_post; + + /* + * the connections announced by the plugin + * the plugin must fill these with xine_post_{in,out}_t on init + */ + xine_list_t *input; + xine_list_t *output; + + /* + * close down, free all resources + */ + void (*dispose) (post_plugin_t *this); + + /* plugins don't have to init the stuff below */ + + /* + * the running ticket + * + * the plugin must assure to check for ticket revocation in + * intervals of finite length; this means that you must release + * the ticket before any operation that might block; + * note that all port functions are safe in this respect + * + * the running ticket is assigned to you by the engine + */ + xine_ticket_t *running_ticket; + + /* this is needed by the engine to decrement the reference counter + * on disposal of the plugin, but since this is useful, we expose it */ + xine_t *xine; + + /* used when the user requests a list of all inputs/outputs */ + const char **input_ids; + const char **output_ids; + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif + + /* has dispose been called */ + int dispose_pending; +}; + +/* helper function to initialize a post_plugin_t */ +void _x_post_init(post_plugin_t *post, int num_audio_inputs, int num_video_inputs) XINE_PROTECTED; + +struct post_in_s { + + /* public part of the input */ + xine_post_in_t xine_in; + + /* backward reference so that you have access to the post plugin */ + post_plugin_t *post; + + /* you can fill this to your liking */ + void *user_data; +}; + +struct post_out_s { + + /* public part of the output */ + xine_post_out_t xine_out; + + /* backward reference so that you have access to the post plugin */ + post_plugin_t *post; + + /* you can fill this to your liking */ + void *user_data; +}; + + +/* Post plugins work by intercepting calls to video or audio ports + * in the sense of the decorator design pattern. They reuse the + * functions of a given target port, but add own functionality in + * front of that port by creating a new port structure and filling in + * the function pointers with pointers to own functions that + * would do something and then call the original port function. + * + * Much the same is done with video frames which have their own + * set of functions attached that you might need to decorate. + */ + + +/* helper structure for intercepting video port calls */ +typedef struct post_video_port_s post_video_port_t; +struct post_video_port_s { + + /* the new public port with replaced function pointers */ + xine_video_port_t new_port; + + /* the original port to call its functions from inside yours */ + xine_video_port_t *original_port; + + /* if you want to decide yourself, whether a given frame should + * be intercepted, fill in this function; get_frame() acts as + * a template method and asks your function; return a boolean; + * the default is to intercept all frames */ + int (*intercept_frame)(post_video_port_t *self, vo_frame_t *frame); + + /* the new frame function pointers */ + vo_frame_t *new_frame; + + /* if you want to decide yourself, whether the preprocessing functions + * should still be routed when draw is intercepted, fill in this + * function; _x_post_intercept_video_frame() acts as a template method + * and asks your function; return a boolean; the default is _not_ to + * route preprocessing functions when draw is intercepted */ + int (*route_preprocessing_procs)(post_video_port_t *self, vo_frame_t *frame); + + /* if you want to decide yourself, whether the overlay manager should + * be intercepted, fill in this function; get_overlay_manager() acts as + * a template method and asks your function; return a boolean; + * the default is _not_ to intercept the overlay manager */ + int (*intercept_ovl)(post_video_port_t *self); + + /* the new public overlay manager with replaced function pointers */ + video_overlay_manager_t *new_manager; + + /* the original manager to call its functions from inside yours */ + video_overlay_manager_t *original_manager; + + /* usage counter: how many objects are floating around that need + * these pointers to exist */ + int usage_count; + pthread_mutex_t usage_lock; + + /* the stream we are being fed by; NULL means no stream is connected; + * this may be an anonymous stream */ + xine_stream_t *stream; + + /* point to a mutex here, if you need some synchronization */ + pthread_mutex_t *port_lock; + pthread_mutex_t *frame_lock; + pthread_mutex_t *manager_lock; + + /* backward reference so that you have access to the post plugin + * when the call only gives you the port */ + post_plugin_t *post; + + /* you can fill this to your liking */ + void *user_data; + +#ifdef POST_INTERNAL + /* some of the above members are to be directly included here, but + * adding the structures would mean that post_video_port_t becomes + * depended of the sizes of these structs; solution: we add pointers + * above and have them point into the memory provided here; + * note that the overlay manager needs to be first so that we can + * reconstruct the post_video_port_t* from overlay manager calls */ + + /* any change here requires a change in _x_post_ovl_manager_to_port() + * below! */ + + video_overlay_manager_t manager_storage; + vo_frame_t frame_storage; + + /* this is used to keep a linked list of free vo_frame_t's */ + vo_frame_t *free_frame_slots; + pthread_mutex_t free_frames_lock; +#endif +}; + +/* use this to create a new decorated video port in which + * port functions will be replaced with own implementations; + * for convenience, this can also create a related post_in_t and post_out_t */ +post_video_port_t *_x_post_intercept_video_port(post_plugin_t *post, xine_video_port_t *port, + post_in_t **input, post_out_t **output) XINE_PROTECTED; + +/* use this to decorate and to undecorate a frame so that its functions + * can be replaced with own implementations, decoration is usually done in + * get_frame(), undecoration in frame->free() */ +vo_frame_t *_x_post_intercept_video_frame(vo_frame_t *frame, post_video_port_t *port) XINE_PROTECTED; +vo_frame_t *_x_post_restore_video_frame(vo_frame_t *frame, post_video_port_t *port) XINE_PROTECTED; + +/* when you want to pass a frame call on to the original issuer of the frame, + * you need to propagate potential changes up and down the pipe, so the usual + * procedure for this situation would be: + * + * _x_post_frame_copy_down(frame, frame->next); + * frame->next->function(frame->next); + * _x_post_frame_copy_up(frame, frame->next); + */ +void _x_post_frame_copy_down(vo_frame_t *from, vo_frame_t *to) XINE_PROTECTED; +void _x_post_frame_copy_up(vo_frame_t *to, vo_frame_t *from) XINE_PROTECTED; + +/* when you shortcut a frames usual draw() travel so that it will never reach + * the draw() function of the original issuer, you still have to do some + * housekeeping on the frame, before returning control up the pipe */ +void _x_post_frame_u_turn(vo_frame_t *frame, xine_stream_t *stream) XINE_PROTECTED; + +/* use this to create a new, trivially decorated overlay manager in which + * port functions can be replaced with own implementations */ +void _x_post_intercept_overlay_manager(video_overlay_manager_t *manager, post_video_port_t *port) XINE_PROTECTED; + +/* pointer retrieval functions */ +static inline post_video_port_t *_x_post_video_frame_to_port(vo_frame_t *frame) { + return (post_video_port_t *)frame->port; +} + +static inline post_video_port_t *_x_post_ovl_manager_to_port(video_overlay_manager_t *manager) { +#ifdef POST_INTERNAL + return (post_video_port_t *)( (uint8_t *)manager - + (uint8_t*)&(((post_video_port_t *)NULL)->manager_storage) ); +#else + return (post_video_port_t *)( (uint8_t *)manager - sizeof(post_video_port_t) ); +#endif +} + + +/* helper structure for intercepting audio port calls */ +typedef struct post_audio_port_s post_audio_port_t; +struct post_audio_port_s { + + /* the new public port with replaced function pointers */ + xine_audio_port_t new_port; + + /* the original port to call its functions from inside yours */ + xine_audio_port_t *original_port; + + /* the stream we are being fed by; NULL means no stream is connected; + * this may be an anonymous stream */ + xine_stream_t *stream; + + pthread_mutex_t usage_lock; + /* usage counter: how many objects are floating around that need + * these pointers to exist */ + int usage_count; + + /* some values remembered by (port->open) () */ + uint32_t bits; + uint32_t rate; + uint32_t mode; + + /* point to a mutex here, if you need some synchronization */ + pthread_mutex_t *port_lock; + + /* backward reference so that you have access to the post plugin + * when the call only gives you the port */ + post_plugin_t *post; + + /* you can fill this to your liking */ + void *user_data; +}; + +/* use this to create a new decorated audio port in which + * port functions will be replaced with own implementations */ +post_audio_port_t *_x_post_intercept_audio_port(post_plugin_t *post, xine_audio_port_t *port, + post_in_t **input, post_out_t **output) XINE_PROTECTED; + + +/* this will allow pending rewire operations, calling this at the beginning + * of decoder-called functions like get_buffer() and open() is a good idea + * (if you do not intercept get_buffer() or open(), this will be done automatically) */ +static inline void _x_post_rewire(post_plugin_t *post) { + if (post->running_ticket->ticket_revoked) + post->running_ticket->renew(post->running_ticket, 1); +} + +/* with these functions you can switch interruptions like rewiring or engine pausing + * off for a block of code; use this only when really necessary */ +static inline void _x_post_lock(post_plugin_t *post) { + post->running_ticket->acquire(post->running_ticket, 1); +} +static inline void _x_post_unlock(post_plugin_t *post) { + post->running_ticket->release(post->running_ticket, 1); + _x_post_rewire(post); +} + +/* the standard disposal operation; returns 1 if the plugin is really + * disposed and you should free everything you malloc()ed yourself */ +int _x_post_dispose(post_plugin_t *post) XINE_PROTECTED; + + +/* macros to handle usage counter */ + +/* WARNING! + * note that _x_post_dec_usage() can call dispose, so be sure to + * not use any potentially already freed memory after this */ + +#define _x_post_inc_usage(port) \ +do { \ + pthread_mutex_lock(&(port)->usage_lock); \ + (port)->usage_count++; \ + pthread_mutex_unlock(&(port)->usage_lock); \ +} while(0) + +#define _x_post_dec_usage(port) \ +do { \ + pthread_mutex_lock(&(port)->usage_lock); \ + (port)->usage_count--; \ + if ((port)->usage_count == 0) { \ + if ((port)->post->dispose_pending) { \ + pthread_mutex_unlock(&(port)->usage_lock); \ + (port)->post->dispose((port)->post); \ + } else \ + pthread_mutex_unlock(&(port)->usage_lock); \ + } else \ + pthread_mutex_unlock(&(port)->usage_lock); \ +} while(0) + + +/* macros to create parameter descriptors */ + +#define START_PARAM_DESCR( param_t ) \ +static param_t temp_s; \ +static xine_post_api_parameter_t temp_p[] = { + +#define PARAM_ITEM( param_type, var, enumv, min, max, readonly, descr ) \ +{ param_type, #var, sizeof(temp_s.var), \ + (char*)&temp_s.var-(char*)&temp_s, enumv, min, max, readonly, descr }, + +#define END_PARAM_DESCR( name ) \ + { POST_PARAM_TYPE_LAST, NULL, 0, 0, NULL, 0, 0, 1, NULL } \ +}; \ +static xine_post_api_descr_t name = { \ + sizeof( temp_s ), \ + temp_p \ +}; + +#endif diff --git a/include/xine/refcounter.h b/include/xine/refcounter.h new file mode 100644 index 000000000..9e2a58f67 --- /dev/null +++ b/include/xine/refcounter.h @@ -0,0 +1,42 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ +#ifndef HAVE_REFCOUNTER_H +#define HAVE_REFCOUNTER_H + +#include <pthread.h> + +typedef struct { + pthread_mutex_t lock; + void* object; /* referenced object */ + void (*destructor)(void *); /* object destructor */ + int count; +} refcounter_t; + +typedef void (*refcounter_destructor)(void*); + +refcounter_t* _x_new_refcounter(void *object, refcounter_destructor destructor) XINE_MALLOC XINE_PROTECTED; + +int _x_refcounter_inc(refcounter_t *refcounter) XINE_PROTECTED; + +int _x_refcounter_dec(refcounter_t *refcounter) XINE_PROTECTED; + +void _x_refcounter_dispose(refcounter_t *refcounter) XINE_PROTECTED; + +#endif /* HAVE_REFCOUNTER_H */ diff --git a/include/xine/resample.h b/include/xine/resample.h new file mode 100644 index 000000000..842434cf0 --- /dev/null +++ b/include/xine/resample.h @@ -0,0 +1,62 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * utilitiy functions for audio drivers + * + * FIXME: not all of them are implemented yet + */ + +#ifndef HAVE_RESAMPLE_H +#define HAVE_RESAMPLE_H + +#define RESAMPLE_MAX_CHANNELS 6 + +void _x_audio_out_resample_stereo(int16_t* last_sample, + int16_t* input_samples, uint32_t in_samples, + int16_t* output_samples, uint32_t out_samples) XINE_PROTECTED; + +void _x_audio_out_resample_mono(int16_t* last_sample, + int16_t* input_samples, uint32_t in_samples, + int16_t* output_samples, uint32_t out_samples) XINE_PROTECTED; + +void _x_audio_out_resample_4channel(int16_t* last_sample, + int16_t* input_samples, uint32_t in_samples, + int16_t* output_samples, uint32_t out_samples) XINE_PROTECTED; + +void _x_audio_out_resample_5channel(int16_t* last_sample, + int16_t* input_samples, uint32_t in_samples, + int16_t* output_samples, uint32_t out_samples) XINE_PROTECTED; + +void _x_audio_out_resample_6channel(int16_t* last_sample, + int16_t* input_samples, uint32_t in_samples, + int16_t* output_samples, uint32_t out_samples) XINE_PROTECTED; + +void _x_audio_out_resample_8to16(int8_t* input_samples, + int16_t* output_samples, uint32_t samples) XINE_PROTECTED; + +void _x_audio_out_resample_16to8(int16_t* input_samples, + int8_t* output_samples, uint32_t samples) XINE_PROTECTED; + +void _x_audio_out_resample_monotostereo(int16_t* input_samples, + int16_t* output_samples, uint32_t frames) XINE_PROTECTED; + +void _x_audio_out_resample_stereotomono(int16_t* input_samples, + int16_t* output_samples, uint32_t frames) XINE_PROTECTED; + +#endif diff --git a/include/xine/ring_buffer.h b/include/xine/ring_buffer.h new file mode 100644 index 000000000..7678aa903 --- /dev/null +++ b/include/xine/ring_buffer.h @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Fifo + Ring Buffer + */ +typedef struct xine_ring_buffer_s xine_ring_buffer_t; + +/* Creates a new ring buffer */ +xine_ring_buffer_t *xine_ring_buffer_new(size_t size) XINE_MALLOC XINE_PROTECTED; + +/* Deletes a ring buffer */ +void xine_ring_buffer_delete(xine_ring_buffer_t *ring_buffer) XINE_PROTECTED; + +/* Returns a new chunk of the specified size */ +/* Might block if the ring buffer is full */ +void *xine_ring_buffer_alloc(xine_ring_buffer_t *ring_buffer, size_t size) XINE_PROTECTED; + +/* Put a chunk into the ring */ +void xine_ring_buffer_put(xine_ring_buffer_t *ring_buffer, void *chunk) XINE_PROTECTED; + +/* Get a chunk of a specified size from the ring buffer + * Might block if the ring buffer is empty + * param size: the desired size + * param rsize: the size of the chunk returned + * rsize is not equal to size at the end of stream, the caller MUST check + * rsize value. + */ +void *xine_ring_buffer_get(xine_ring_buffer_t *ring_buffer, size_t size, size_t *rsize) XINE_PROTECTED; + +/* Releases the chunk, makes memory available for the alloc function */ +void xine_ring_buffer_release(xine_ring_buffer_t *ring_buffer, void *chunk) XINE_PROTECTED; + +/* Closes the ring buffer + * The writer uses this function to signal the end of stream to the reader. + * The reader MUST check the rsize value returned by the get function. + */ +void xine_ring_buffer_close(xine_ring_buffer_t *ring_buffer) XINE_PROTECTED; + + diff --git a/include/xine/scratch.h b/include/xine/scratch.h new file mode 100644 index 000000000..c0c927b97 --- /dev/null +++ b/include/xine/scratch.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * scratch buffer for log output + */ + +#ifndef HAVE_SCRATCH_H +#define HAVE_SCRATCH_H + +#include <stdarg.h> +#include <pthread.h> + +typedef struct scratch_buffer_s scratch_buffer_t; + +#define SCRATCH_LINE_LEN_MAX 1024 + +struct scratch_buffer_s { + + void XINE_FORMAT_PRINTF(2, 0) + (*scratch_printf) (scratch_buffer_t *this, const char *format, va_list ap); + + char **(*get_content) (scratch_buffer_t *this); + + void (*dispose) (scratch_buffer_t *this); + + char **lines; + char **ordered; + + int num_lines; + int cur; + + pthread_mutex_t lock; +}; + +scratch_buffer_t *_x_new_scratch_buffer (int num_lines) XINE_MALLOC XINE_PROTECTED; + +#endif diff --git a/include/xine/sorted_array.h b/include/xine/sorted_array.h new file mode 100644 index 000000000..0d229199a --- /dev/null +++ b/include/xine/sorted_array.h @@ -0,0 +1,94 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * Sorted array which grows automatically when you add elements. + * A binary search is used to find the position of a new element. + * + * Example: + * Let's create de comparison method for integers: + * + * int int_comparator(void *a, void *b) { + * if ((int)a < (int)b) { + * return -1; + * } else if ((int)a == (int)b) { + * return 0; + * } else { + * return 1; + * } + * } + * + * Create a sorted array for integers: + * xine_sarray_t *sarray = xine_sarray_new(10, int_comparator); + * + * Add elements: + * xine_sarray_add(sarray, (void*)4); + * xine_sarray_add(sarray, (void*)28); + * xine_sarray_add(sarray, (void*)7); + * + * Find an element: + * int pos = xine_sarray_binary_search(sarray, (void*)7); + * if (pos >= 0) + * FOUND + * else + * NOT FOUND + * + * Delete the array: + * xine_sarray_delete(sarray); + */ +#ifndef XINE_SORTED_ARRAY_H +#define XINE_SORTED_ARRAY_H + +#include "array.h" + +/* Array type */ +typedef struct xine_sarray_s xine_sarray_t; + +/* Array element comparator */ +typedef int (*xine_sarray_comparator_t)(void*, void*); + +/* Constructor */ +xine_sarray_t *xine_sarray_new(size_t initial_size, xine_sarray_comparator_t comparator) XINE_MALLOC XINE_PROTECTED; + +/* Destructor */ +void xine_sarray_delete(xine_sarray_t *sarray) XINE_PROTECTED; + +/* Returns the number of element stored in the array */ +size_t xine_sarray_size(const xine_sarray_t *sarray) XINE_PROTECTED; + +/* Removes all elements from an array */ +void xine_sarray_clear(xine_sarray_t *sarray) XINE_PROTECTED; + +/* Adds the element into the array + Returns the insertion position */ +int xine_sarray_add(xine_sarray_t *sarray, void *value) XINE_PROTECTED; + +/* Removes one element from an array at the position specified */ +void xine_sarray_remove(xine_sarray_t *sarray, unsigned int position) XINE_PROTECTED; + +/* Get the element at the position specified */ +void *xine_sarray_get(xine_sarray_t *sarray, unsigned int position) XINE_PROTECTED; + +/* Returns the index of the search key, if it is contained in the list. + Otherwise, (-(insertion point) - 1) or ~(insertion point). + The insertion point is defined as the point at which the key would be + inserted into the array. */ +int xine_sarray_binary_search(xine_sarray_t *sarray, void *key) XINE_PROTECTED; + +#endif + diff --git a/include/xine/spu.h b/include/xine/spu.h new file mode 100644 index 000000000..e53462236 --- /dev/null +++ b/include/xine/spu.h @@ -0,0 +1,44 @@ +/* + * Copyright (C) 2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + */ + +#ifndef XINE_UTILS_SPU_H +#define XINE_UTILS_SPU_H + +#ifndef XINE_PROTECTED +#define XINE_PROTECTED +#endif + +typedef struct xine_spu_opacity_s xine_spu_opacity_t; + +struct xine_spu_opacity_s { + uint8_t black, colour; +}; + +void _x_spu_misc_init (xine_t *); + +void _x_spu_get_opacity (xine_t *, xine_spu_opacity_t *) XINE_PROTECTED; + +/* in: trans = 0..255, 0=opaque + * out: 0..255, 0=transparent + */ +int _x_spu_calculate_opacity (const clut_t *, uint8_t trans, const xine_spu_opacity_t *) XINE_PROTECTED; + +#endif diff --git a/include/xine/spu_decoder.h b/include/xine/spu_decoder.h new file mode 100644 index 000000000..9ab926bdf --- /dev/null +++ b/include/xine/spu_decoder.h @@ -0,0 +1,160 @@ +/* + * spu_decoder_api.h + * + * Copyright (C) James Courtier-Dutton James@superbug.demon.co.uk - July 2001 + * + * This file is part of xine, a unix video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Make; see the file COPYING. If not, write to + * the Free Software Foundation, + * + */ + +#ifndef HAVE_SPU_API_H +#define HAVE_SPU_API_H + +#include <xine/os_types.h> +#include <xine/buffer.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define SPU_DECODER_IFACE_VERSION 17 + +/* + * generic xine spu decoder plugin interface + */ + +typedef struct spu_decoder_class_s spu_decoder_class_t; +typedef struct spu_decoder_s spu_decoder_t; + +struct spu_decoder_class_s { + + /* + * open a new instance of this plugin class + */ + spu_decoder_t* (*open_plugin) (spu_decoder_class_t *this, xine_stream_t *stream); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + void (*dispose) (spu_decoder_class_t *this); +}; + +#define default_spu_decoder_class_dispose (void (*) (spu_decoder_class_t *this))free + +struct spu_decoder_s { + + /* + * decode data from buf and feed the overlay to overlay manager + */ + void (*decode_data) (spu_decoder_t *this, buf_element_t *buf); + + /* + * reset decoder after engine flush (prepare for new + * SPU data not related to recently decoded data) + */ + void (*reset) (spu_decoder_t *this); + + /* + * inform decoder that a time reference discontinuity has happened. + * that is, it must forget any currently held pts value + */ + void (*discontinuity) (spu_decoder_t *this); + + /* + * close down, free all resources + */ + void (*dispose) (spu_decoder_t *this); + + /* + * When the SPU decoder also handles data used in user interaction, + * you can query the related information here. The typical example + * for this is DVD NAV packets which are handled by the SPU decoder + * and can be received readily parsed from here. + * The caller and the decoder must agree on the structure which is + * passed here. + * This function pointer may be NULL, if the plugin does not have + * such functionality. + */ + int (*get_interact_info) (spu_decoder_t *this, void *data); + + /* + * When the SPU decoder also handles menu overlays for user inter- + * action, you can set a menu button here. The typical example for + * this is DVD menus. + * This function pointer may be NULL, if the plugin does not have + * such functionality. + */ + void (*set_button) (spu_decoder_t *this_gen, int32_t button, int32_t mode); + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +}; + + +/* SPU decoders differ from video and audio decoders in one significant + * way: unlike audio and video, SPU streams are not continuous; + * this results in another difference, programmers have to consider: + * while both audio and video decoders are automatically blocked in + * their get_buffer()/get_frame() methods when the output cannot take + * any more data, this does not work for SPU, because it could take + * minutes before the next free slot becomes available and we must not + * block the decoder thread for that long; + * therefore, we provide a convenience function for SPU decoders which + * implements a wait until a timestamp sufficiently close to the VPTS + * of the next SPU is reached, but the waiting will end before that, + * if some outside condition requires us to release the decoder thread + * to other tasks; + * if this functions returns with 1, noone needs the decoder thread and + * you may continue waiting; if it returns 0, finish whatever you are + * doing and return; + * the usual pattern for SPU decoders is this: + * + * do { + * spu = prepare_spu(); + * int thread_vacant = _x_spu_decoder_sleep(this->stream, spu->vpts); + * int success = process_spu(spu); + * } while (!success && thread_vacant); + */ +int _x_spu_decoder_sleep(xine_stream_t *, int64_t next_spu_vpts) XINE_PROTECTED; + +#endif /* HAVE_SPUDEC_H */ diff --git a/include/xine/vdr.h b/include/xine/vdr.h new file mode 100644 index 000000000..4093472d9 --- /dev/null +++ b/include/xine/vdr.h @@ -0,0 +1,666 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef __VDR_H +#define __VDR_H + + +#define XINE_VDR_VERSION 901 + + +enum funcs +{ + func_unknown = -1 + , func_nop + , func_osd_new + , func_osd_free + , func_osd_show + , func_osd_hide + , func_osd_set_position + , func_osd_draw_bitmap + , func_set_color + , func_clear + , func_mute + , func_set_volume + , func_set_speed + , func_set_prebuffer + , func_metronom + , func_start + , func_wait + , func_setup + , func_grab_image + , func_get_pts + , func_flush + , func_first_frame + , func_still_frame + , func_video_size + , func_set_video_window + , func_osd_flush + , func_play_external + , func_key + , func_frame_size + , func_reset_audio + , func_select_audio + , func_trick_speed_mode + , func_get_version + , func_discontinuity + , func_query_capabilities +}; + +enum keys +{ + key_none, + key_up, + key_down, + key_menu, + key_ok, + key_back, + key_left, + key_right, + key_red, + key_green, + key_yellow, + key_blue, + key_0, + key_1, + key_2, + key_3, + key_4, + key_5, + key_6, + key_7, + key_8, + key_9, + key_play, + key_pause, + key_stop, + key_record, + key_fast_fwd, + key_fast_rew, + key_power, + key_channel_plus, + key_channel_minus, + key_volume_plus, + key_volume_minus, + key_mute, + key_schedule, + key_channels, + key_timers, + key_recordings, + key_setup, + key_commands, + key_user1, + key_user2, + key_user3, + key_user4, + key_user5, + key_user6, + key_user7, + key_user8, + key_user9, + key_audio, + key_info, + key_channel_previous, + key_next, + key_previous, + key_subtitles, + key_user0, +}; + + + +typedef struct __attribute__((packed)) data_header_s +{ + uint32_t func:8; + uint32_t len:24; +} +data_header_t; + + + +typedef data_header_t result_header_t; +typedef data_header_t event_header_t; + + + +typedef struct __attribute__((packed)) data_nop_s +{ + data_header_t header; +} +data_nop_t; + + + +typedef struct __attribute__((packed)) data_osd_new_s +{ + data_header_t header; + + uint8_t window; + int16_t x; + int16_t y; + uint16_t width; + uint16_t height; + uint16_t w_ref; + uint16_t h_ref; +} +data_osd_new_t; + + + +typedef struct __attribute__((packed)) data_osd_free_s +{ + data_header_t header; + + uint8_t window; +} +data_osd_free_t; + + + +typedef struct __attribute__((packed)) data_osd_show_s +{ + data_header_t header; + + uint8_t window; +} +data_osd_show_t; + + + +typedef struct __attribute__((packed)) data_osd_hide_s +{ + data_header_t header; + + uint8_t window; +} +data_osd_hide_t; + + + +typedef struct __attribute__((packed)) data_osd_flush_s +{ + data_header_t header; +} +data_osd_flush_t; + + + +typedef struct __attribute__((packed)) data_play_external_s +{ + data_header_t header; +} +data_play_external_t; + + + +typedef struct __attribute__((packed)) data_osd_set_position_s +{ + data_header_t header; + + uint8_t window; + int16_t x; + int16_t y; +} +data_osd_set_position_t; + + + +typedef struct __attribute__((packed)) data_osd_draw_bitmap_s +{ + data_header_t header; + + uint8_t window; + int16_t x; + int16_t y; + uint16_t width; + uint16_t height; + uint8_t argb; +} +data_osd_draw_bitmap_t; + + + +typedef struct __attribute__((packed)) data_set_color_s +{ + data_header_t header; + + uint8_t window; + uint8_t index; + uint8_t num; +} +data_set_color_t; + + + +typedef struct __attribute__((packed)) data_flush_s +{ + data_header_t header; + + int32_t ms_timeout; + uint8_t just_wait; +} +data_flush_t; + + + +typedef struct __attribute__((packed)) result_flush_s +{ + result_header_t header; + + uint8_t timed_out; +} +result_flush_t; + + + +typedef struct __attribute__((packed)) data_clear_s +{ + data_header_t header; + + int32_t n; + int8_t s; + uint8_t i; +} +data_clear_t; + + + +typedef struct __attribute__((packed)) data_mute_s +{ + data_header_t header; + + uint8_t mute; +} +data_mute_t; + + + +typedef struct __attribute__((packed)) data_set_volume_s +{ + data_header_t header; + + uint8_t volume; +} +data_set_volume_t; + + + +typedef struct __attribute__((packed)) data_set_speed_s +{ + data_header_t header; + + int32_t speed; +} +data_set_speed_t; + + + +typedef struct __attribute__((packed)) data_set_prebuffer_s +{ + data_header_t header; + + uint32_t prebuffer; +} +data_set_prebuffer_t; + + + +typedef struct __attribute__((packed)) data_metronom_s +{ + data_header_t header; + + int64_t pts; + uint32_t flags; +} +data_metronom_t; + + + +typedef struct __attribute__((packed)) data_start_s +{ + data_header_t header; +} +data_start_t; + + + +typedef struct __attribute__((packed)) data_wait_s +{ + data_header_t header; + uint8_t id; +} +data_wait_t; + + + +typedef struct __attribute__((packed)) result_wait_s +{ + result_header_t header; +} +result_wait_t; + + + +#define XINE_VDR_VOLUME_IGNORE 0 +#define XINE_VDR_VOLUME_CHANGE_HW 1 +#define XINE_VDR_VOLUME_CHANGE_SW 2 + +#define XINE_VDR_MUTE_IGNORE 0 +#define XINE_VDR_MUTE_EXECUTE 1 +#define XINE_VDR_MUTE_SIMULATE 2 + +typedef struct __attribute__((packed)) data_setup_s +{ + data_header_t header; + + uint8_t osd_unscaled_blending; + uint8_t volume_mode; + uint8_t mute_mode; + uint16_t image4_3_zoom_x; + uint16_t image4_3_zoom_y; + uint16_t image16_9_zoom_x; + uint16_t image16_9_zoom_y; +} +data_setup_t; + + + +typedef struct __attribute__((packed)) data_first_frame_s +{ + data_header_t header; +} +data_first_frame_t; + + + +typedef struct __attribute__((packed)) data_still_frame_s +{ + data_header_t header; +} +data_still_frame_t; + + + +typedef struct __attribute__((packed)) data_set_video_window_s +{ + data_header_t header; + + uint32_t x; + uint32_t y; + uint32_t w; + uint32_t h; + uint32_t w_ref; + uint32_t h_ref; +} +data_set_video_window_t; + + + +typedef struct __attribute__((packed)) data_grab_image_s +{ + data_header_t header; +} +data_grab_image_t; + + + +typedef struct __attribute__((packed)) result_grab_image_s +{ + result_header_t header; + + int32_t width; + int32_t height; + int32_t ratio; + int32_t format; + int32_t interlaced; + int32_t crop_left; + int32_t crop_right; + int32_t crop_top; + int32_t crop_bottom; +} +result_grab_image_t; + + + +typedef struct __attribute__((packed)) data_get_pts_s +{ + data_header_t header; + int32_t ms_timeout; +} +data_get_pts_t; + + + +typedef struct __attribute__((packed)) result_get_pts_s +{ + result_header_t header; + + int64_t pts; + int8_t queued; +} +result_get_pts_t; + + + +typedef struct __attribute__((packed)) data_get_version_s +{ + data_header_t header; +} +data_get_version_t; + + + +typedef struct __attribute__((packed)) result_get_version_s +{ + result_header_t header; + + int32_t version; +} +result_get_version_t; + + + +typedef struct __attribute__((packed)) data_video_size_s +{ + data_header_t header; +} +data_video_size_t; + + + +typedef struct __attribute__((packed)) result_video_size_s +{ + result_header_t header; + + int32_t left; + int32_t top; + int32_t width; + int32_t height; + int32_t ratio; + int32_t zoom_x; + int32_t zoom_y; +} +result_video_size_t; + + + +typedef struct __attribute__((packed)) data_reset_audio_s +{ + data_header_t header; +} +data_reset_audio_t; + + + +typedef struct __attribute__((packed)) event_key_s +{ + event_header_t header; + + uint32_t key; +} +event_key_t; + + + +typedef struct __attribute__((packed)) event_frame_size_s +{ + event_header_t header; + + int32_t left; + int32_t top; + int32_t width; + int32_t height; + int32_t zoom_x; + int32_t zoom_y; +} +event_frame_size_t; + + + +typedef struct __attribute__((packed)) event_play_external_s +{ + event_header_t header; + + uint32_t key; +} +event_play_external_t; + + + +typedef struct __attribute__((packed)) data_select_audio_s +{ + data_header_t header; + + uint8_t channels; +} +data_select_audio_t; + + + +typedef struct __attribute__((packed)) data_trick_speed_mode_s +{ + data_header_t header; + + uint8_t on; +} +data_trick_speed_mode_t; + + + +typedef struct __attribute__((packed)) event_discontinuity_s +{ + event_header_t header; + + int32_t type; +} +event_discontinuity_t; + + + +typedef struct __attribute__((packed)) data_query_capabilities_s +{ + data_header_t header; +} +data_query_capabilities_t; + + + +typedef struct __attribute__((packed)) result_query_capabilities_s +{ + result_header_t header; + + uint8_t osd_max_num_windows; + uint8_t osd_palette_max_depth; + uint8_t osd_palette_is_shared; + uint8_t osd_supports_argb_layer; + uint8_t osd_supports_custom_extent; +} +result_query_capabilities_t; + + + +typedef union __attribute__((packed)) data_union_u +{ + data_header_t header; + data_nop_t nop; + data_osd_new_t osd_new; + data_osd_free_t osd_free; + data_osd_show_t osd_show; + data_osd_hide_t osd_hide; + data_osd_set_position_t osd_set_position; + data_osd_draw_bitmap_t osd_draw_bitmap; + data_set_color_t set_color; + data_flush_t flush; + data_clear_t clear; + data_mute_t mute; + data_set_volume_t set_volume; + data_set_speed_t set_speed; + data_set_prebuffer_t set_prebuffer; + data_metronom_t metronom; + data_start_t start; + data_wait_t wait; + data_setup_t setup; + data_grab_image_t grab_image; + data_get_pts_t get_pts; + data_first_frame_t first_frame; + data_still_frame_t still_frame; + data_video_size_t video_size; + data_set_video_window_t set_video_window; + data_osd_flush_t osd_flush; + data_play_external_t play_external; + data_reset_audio_t reset_audio; + data_select_audio_t select_audio; + data_trick_speed_mode_t trick_speed_mode; + data_get_version_t get_version; + data_query_capabilities_t query_capabilities; +} +data_union_t; + + + +typedef union __attribute__((packed)) result_union_u +{ + result_header_t header; + result_grab_image_t grab_image; + result_get_pts_t get_pts; + result_flush_t flush; + result_video_size_t video_size; + result_get_version_t get_version; + result_wait_t wait; + result_query_capabilities_t query_capabilities; +} +result_union_t; + + + +typedef union __attribute__((packed)) event_union_u +{ + event_header_t header; + event_key_t key; + event_frame_size_t frame_size; + event_play_external_t play_external; + event_discontinuity_t discontinuity; +} +event_union_t; + + + +#endif /* __VDR_H */ + diff --git a/include/xine/version.h.in b/include/xine/version.h.in new file mode 100644 index 000000000..75072708d --- /dev/null +++ b/include/xine/version.h.in @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2007 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +/* static info - which libxine release this header came from */ +#define XINE_MAJOR_VERSION @XINE_MAJOR@ +#define XINE_MINOR_VERSION @XINE_MINOR@ +#define XINE_SUB_VERSION @XINE_SUB@ +#define XINE_VERSION "@VERSION@" diff --git a/include/xine/video_decoder.h b/include/xine/video_decoder.h new file mode 100644 index 000000000..faf7eac51 --- /dev/null +++ b/include/xine/video_decoder.h @@ -0,0 +1,118 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * xine video decoder plugin interface + */ + +#ifndef HAVE_VIDEO_DECODER_H +#define HAVE_VIDEO_DECODER_H + +#include <xine/os_types.h> +#include <xine/buffer.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +#define VIDEO_DECODER_IFACE_VERSION 19 + + +/* + * generic xine video decoder plugin interface + */ + +typedef struct video_decoder_class_s video_decoder_class_t; +typedef struct video_decoder_s video_decoder_t; + +struct video_decoder_class_s { + + /* + * open a new instance of this plugin class + */ + video_decoder_t* (*open_plugin) (video_decoder_class_t *this, xine_stream_t *stream); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + void (*dispose) (video_decoder_class_t *this); +}; + +#define default_video_decoder_class_dispose (void (*) (video_decoder_class_t *this))free + +struct video_decoder_s { + + /* + * decode data from buf and feed decoded frames to + * video output + */ + void (*decode_data) (video_decoder_t *this, buf_element_t *buf); + + /* + * reset decoder after engine flush (prepare for new + * video data not related to recently decoded data) + */ + void (*reset) (video_decoder_t *this); + + /* + * inform decoder that a time reference discontinuity has happened. + * that is, it must forget any currently held pts value + */ + void (*discontinuity) (video_decoder_t *this); + + /* + * flush out any frames that are still stored in the decoder + */ + void (*flush) (video_decoder_t *this); + + /* + * close down, free all resources + */ + void (*dispose) (video_decoder_t *this); + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +}; + +#endif diff --git a/include/xine/video_out.h b/include/xine/video_out.h new file mode 100644 index 000000000..5a0401160 --- /dev/null +++ b/include/xine/video_out.h @@ -0,0 +1,538 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + * xine version of video_out.h + * + * vo_frame : frame containing yuv data and timing info, + * transferred between video_decoder and video_output + * + * vo_driver : lowlevel, platform-specific video output code + * + * vo_port : generic frame_handling code, uses + * a vo_driver for output + */ + +#ifndef HAVE_VIDEO_OUT_H +#define HAVE_VIDEO_OUT_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <pthread.h> + +#include <xine.h> +#include <xine/buffer.h> + +#ifdef XINE_COMPILE +# include <xine/plugin_catalog.h> +#endif + +typedef struct vo_frame_s vo_frame_t; +typedef struct vo_driver_s vo_driver_t; +typedef struct video_driver_class_s video_driver_class_t; +typedef struct vo_overlay_s vo_overlay_t; +typedef struct video_overlay_manager_s video_overlay_manager_t; + +/* public part, video drivers may add private fields + * + * Remember that adding new functions to this structure requires + * adaption of the post plugin decoration layer. Be sure to look into + * src/xine-engine/post.[ch]. + */ +struct vo_frame_s { + /* + * member functions + */ + + /* Provide a copy of the frame's image in an image format already known to xine. data's member */ + /* have already been intialized to frame's content on entry, so it's usually only necessary to */ + /* change format and img_size. In case img is set, it will point to a memory block of suitable */ + /* size (size has been determined by a previous call with img == NULL). img content and img_size */ + /* must adhere to the specification of _x_get_current_frame_data(). */ + /* Currently this is needed for all image formats except XINE_IMGFMT_YV12 and XINE_IMGFMT_YUY2. */ + void (*proc_provide_standard_frame_data) (vo_frame_t *vo_img, xine_current_frame_data_t *data); + + /* Duplicate picture data and acceleration specific data of a frame. */ + /* if the image format isn't already known by Xine. Currently this is needed */ + /* For all image formats except XINE_IMGFMT_YV12 and XINE_IMGFMT_YUY2 */ + void (*proc_duplicate_frame_data) (vo_frame_t *vo_img, vo_frame_t *src); + + /* tell video driver to copy/convert the whole of this frame, may be NULL */ + /* at least one of proc_frame() and proc_slice() MUST set the variable proc_called to 1 */ + void (*proc_frame) (vo_frame_t *vo_img); + + /* tell video driver to copy/convert a slice of this frame, may be NULL */ + /* at least one of proc_frame() and proc_slice() MUST set the variable proc_called to 1 */ + void (*proc_slice) (vo_frame_t *vo_img, uint8_t **src); + + /* tell video driver that the decoder starts a new field */ + void (*field) (vo_frame_t *vo_img, int which_field); + + /* append this frame to the display queue, + returns number of frames to skip if decoder is late */ + /* when the frame does not originate from a stream, it is legal to pass an anonymous stream */ + int (*draw) (vo_frame_t *vo_img, xine_stream_t *stream); + + /* lock frame as reference, must be paired with free. + * most decoders/drivers do not need to call this function since + * newly allocated frames are already locked once. + */ + void (*lock) (vo_frame_t *vo_img); + + /* this frame is no longer used by the decoder, video driver, etc */ + void (*free) (vo_frame_t *vo_img); + + /* free memory/resources for this frame */ + void (*dispose) (vo_frame_t *vo_img); + + /* + * public variables to decoders and vo drivers + * changing anything here will require recompiling them both + */ + int64_t pts; /* presentation time stamp (1/90000 sec) */ + int64_t vpts; /* virtual pts, generated by metronom */ + int bad_frame; /* e.g. frame skipped or based on skipped frame */ + int duration; /* frame length in time, in 1/90000 sec */ + + /* yv12 (planar) base[0]: y, base[1]: u, base[2]: v */ + /* yuy2 (interleaved) base[0]: yuyv..., base[1]: --, base[2]: -- */ + uint8_t *base[3]; + int pitches[3]; + + /* info that can be used for interlaced output (e.g. tv-out) */ + int top_field_first; + int repeat_first_field; + /* note: progressive_frame is set wrong on many mpeg2 streams. for + * that reason, this flag should be interpreted as a "hint". + */ + int progressive_frame; + int picture_coding_type; + + /* cropping to be done */ + int crop_left, crop_right, crop_top, crop_bottom; + + int lock_counter; + pthread_mutex_t mutex; /* protect access to lock_count */ + + /* extra info coming from input or demuxers */ + extra_info_t *extra_info; + + /* additional information to be able to duplicate frames: */ + int width, height; + double ratio; /* aspect ratio */ + int format; /* IMGFMT_YV12 or IMGFMT_YUY2 */ + + int drawn; /* used by decoder, frame has already been drawn */ + int flags; /* remember the frame flags */ + int proc_called; /* track use of proc_*() methods */ + + /* Used to carry private data for accelerated plugins.*/ + void *accel_data; + + /* "backward" references to where this frame originates from */ + xine_video_port_t *port; + vo_driver_t *driver; + xine_stream_t *stream; + + /* displacement for overlays */ + int overlay_offset_x, overlay_offset_y; + + /* pointer to the next frame in display order, used by some vo deint */ + struct vo_frame_s *future_frame; + + /* + * that part is used only by video_out.c for frame management + * obs: changing anything here will require recompiling vo drivers + */ + struct vo_frame_s *next; + + int id; /* debugging - track this frame */ + int is_first; +}; + + +/* + * Remember that adding new functions to this structure requires + * adaption of the post plugin decoration layer. Be sure to look into + * src/xine-engine/post.[ch]. + */ +struct xine_video_port_s { + + uint32_t (*get_capabilities) (xine_video_port_t *self); /* for constants see below */ + + /* open display driver for video output */ + /* when you are not a full-blown stream, but still need to open the port + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ + void (*open) (xine_video_port_t *self, xine_stream_t *stream); + + /* + * get_frame - allocate an image buffer from display driver + * + * params : width == width of video to display. + * height == height of video to display. + * ratio == aspect ration information + * format == FOURCC descriptor of image format + * flags == field/prediction flags + */ + vo_frame_t* (*get_frame) (xine_video_port_t *self, uint32_t width, + uint32_t height, double ratio, + int format, int flags); + + /* create a new grab video frame */ + xine_grab_video_frame_t* (*new_grab_video_frame) (xine_video_port_t *self); + + /* retrieves the last displayed frame (useful for taking snapshots) */ + vo_frame_t* (*get_last_frame) (xine_video_port_t *self); + + /* overlay stuff */ + void (*enable_ovl) (xine_video_port_t *self, int ovl_enable); + + /* get overlay manager */ + video_overlay_manager_t* (*get_overlay_manager) (xine_video_port_t *self); + + /* flush video_out fifo */ + void (*flush) (xine_video_port_t *self); + + /* trigger immediate drawing */ + void (*trigger_drawing) (xine_video_port_t *self); + + /* Get/Set video property + * + * See VO_PROP_* bellow + */ + int (*get_property) (xine_video_port_t *self, int property); + int (*set_property) (xine_video_port_t *self, int property, int value); + + /* return true if port is opened for this stream, stream can be anonymous */ + int (*status) (xine_video_port_t *self, xine_stream_t *stream, + int *width, int *height, int64_t *img_duration); + + /* video driver is no longer used by decoder => close */ + /* when you are not a full-blown stream, but still need to close the port + * (e.g. you are a post plugin) it is legal to pass an anonymous stream */ + void (*close) (xine_video_port_t *self, xine_stream_t *stream); + + /* called on xine exit */ + void (*exit) (xine_video_port_t *self); + + /* the driver in use */ + vo_driver_t *driver; + +}; + +/* constants for the get/set property functions */ +#define VO_PROP_INTERLACED 0 +#define VO_PROP_ASPECT_RATIO 1 +#define VO_PROP_HUE 2 +#define VO_PROP_SATURATION 3 +#define VO_PROP_CONTRAST 4 +#define VO_PROP_BRIGHTNESS 5 +#define VO_PROP_COLORKEY 6 +#define VO_PROP_AUTOPAINT_COLORKEY 7 +#define VO_PROP_ZOOM_X 8 +#define VO_PROP_PAN_SCAN 9 +#define VO_PROP_TVMODE 10 +#define VO_PROP_MAX_NUM_FRAMES 11 +#define VO_PROP_GAMMA 12 +#define VO_PROP_ZOOM_Y 13 +#define VO_PROP_DISCARD_FRAMES 14 /* not used by drivers */ +#define VO_PROP_WINDOW_WIDTH 15 /* read-only */ +#define VO_PROP_WINDOW_HEIGHT 16 /* read-only */ +#define VO_PROP_BUFS_IN_FIFO 17 /* read-only */ +#define VO_PROP_NUM_STREAMS 18 /* read-only */ +#define VO_PROP_OUTPUT_WIDTH 19 /* read-only */ +#define VO_PROP_OUTPUT_HEIGHT 20 /* read-only */ +#define VO_PROP_OUTPUT_XOFFSET 21 /* read-only */ +#define VO_PROP_OUTPUT_YOFFSET 22 /* read-only */ +#define VO_PROP_SHARPNESS 24 +#define VO_PROP_NOISE_REDUCTION 25 +#define VO_PROP_BUFS_TOTAL 26 /* read-only */ +#define VO_PROP_BUFS_FREE 27 /* read-only */ +#define VO_NUM_PROPERTIES 28 + +/* number of colors in the overlay palette. Currently limited to 256 + at most, because some alphablend functions use an 8-bit index into + the palette. This should probably be classified as a bug. */ +#define OVL_PALETTE_SIZE 256 + +#define OVL_MAX_OPACITY 0x0f + +/* number of recent frames to keep in memory + these frames are needed by some deinterlace algorithms + FIXME: we need a method to flush the recent frames (new stream) +*/ +#define VO_NUM_RECENT_FRAMES 2 + +/* get_frame flags */ +#define VO_TOP_FIELD 1 +#define VO_BOTTOM_FIELD 2 +#define VO_BOTH_FIELDS (VO_TOP_FIELD | VO_BOTTOM_FIELD) +#define VO_PAN_SCAN_FLAG 4 +#define VO_INTERLACED_FLAG 8 +#define VO_NEW_SEQUENCE_FLAG 16 /* set after MPEG2 Sequence Header Code (used by XvMC) */ +#define VO_CHROMA_422 32 /* used by VDPAU, default is chroma_420 */ +#define VO_STILL_IMAGE 64 + +/* video driver capabilities */ +#define VO_CAP_YV12 0x00000001 /* driver can handle YUV 4:2:0 pictures */ +#define VO_CAP_YUY2 0x00000002 /* driver can handle YUY2 pictures */ +#define VO_CAP_XVMC_MOCOMP 0x00000004 /* driver can use XvMC motion compensation */ +#define VO_CAP_XVMC_IDCT 0x00000008 /* driver can use XvMC idct acceleration */ +#define VO_CAP_UNSCALED_OVERLAY 0x00000010 /* driver can blend overlay at output resolution */ +#define VO_CAP_CROP 0x00000020 /* driver can crop */ +#define VO_CAP_XXMC 0x00000040 /* driver can use extended XvMC */ +#define VO_CAP_VDPAU_H264 0x00000080 /* driver can use VDPAU for H264 */ +#define VO_CAP_VDPAU_MPEG12 0x00000100 /* driver can use VDPAU for mpeg1/2 */ +#define VO_CAP_VDPAU_VC1 0x00000200 /* driver can use VDPAU for VC1 */ +#define VO_CAP_VDPAU_MPEG4 0x00000400 /* driver can use VDPAU for mpeg4-part2 */ +#define VO_CAP_HUE 0x00010000 +#define VO_CAP_SATURATION 0x00020000 +#define VO_CAP_CONTRAST 0x00040000 +#define VO_CAP_BRIGHTNESS 0x00080000 +#define VO_CAP_COLORKEY 0x00100000 +#define VO_CAP_AUTOPAINT_COLORKEY 0x00200000 +#define VO_CAP_ZOOM_X 0x00400000 +#define VO_CAP_ZOOM_Y 0x00800000 +#define VO_CAP_CUSTOM_EXTENT_OVERLAY 0x01000000 /* driver can blend custom extent overlay to output extent */ +#define VO_CAP_ARGB_LAYER_OVERLAY 0x02000000 /* driver supports true color overlay */ +#define VO_CAP_VIDEO_WINDOW_OVERLAY 0x04000000 /* driver can scale video to an area within overlay */ +#define VO_CAP_GAMMA 0x08000000 +#define VO_CAP_SHARPNESS 0x10000000 +#define VO_CAP_NOISE_REDUCTION 0x20000000 + + +/* + * vo_driver_s contains the functions every display driver + * has to implement. The vo_new_port function (see below) + * should then be used to construct a vo_port using this + * driver. Some of the function pointers will be copied + * directly into xine_video_port_s, others will be called + * from generic vo functions. + */ + +#define VIDEO_OUT_DRIVER_IFACE_VERSION 22 + +struct vo_driver_s { + + uint32_t (*get_capabilities) (vo_driver_t *self); /* for constants see above */ + + /* + * allocate an vo_frame_t struct, + * the driver must supply the copy, field and dispose functions + */ + vo_frame_t* (*alloc_frame) (vo_driver_t *self); + + /* + * check if the given image fullfills the format specified + * (re-)allocate memory if necessary + */ + void (*update_frame_format) (vo_driver_t *self, vo_frame_t *img, + uint32_t width, uint32_t height, + double ratio, int format, int flags); + + /* display a given frame */ + void (*display_frame) (vo_driver_t *self, vo_frame_t *vo_img); + + /* overlay_begin and overlay_end are used by drivers suporting + * persistent overlays. they can be optimized to update only when + * overlay image has changed. + * + * sequence of operation (pseudo-code): + * overlay_begin(this,img,true_if_something_changed_since_last_blend ); + * while(visible_overlays) + * overlay_blend(this,img,overlay[i]); + * overlay_end(this,img); + * + * any function pointer from this group may be set to NULL. + */ + void (*overlay_begin) (vo_driver_t *self, vo_frame_t *vo_img, int changed); + void (*overlay_blend) (vo_driver_t *self, vo_frame_t *vo_img, vo_overlay_t *overlay); + void (*overlay_end) (vo_driver_t *self, vo_frame_t *vo_img); + + /* + * these can be used by the gui directly: + */ + int (*get_property) (vo_driver_t *self, int property); + int (*set_property) (vo_driver_t *self, + int property, int value); + void (*get_property_min_max) (vo_driver_t *self, + int property, int *min, int *max); + + /* + * general purpose communication channel between gui and driver + * + * this should be used to propagate events, display data, window sizes + * etc. to the driver + */ + int (*gui_data_exchange) (vo_driver_t *self, int data_type, + void *data); + + /* check if a redraw is needed (due to resize) + * this is only used for still frames, normal video playback + * must call that inside display_frame() function. + */ + int (*redraw_needed) (vo_driver_t *self); + + /* Create a new grab video frame */ + xine_grab_video_frame_t* (*new_grab_video_frame)(vo_driver_t *self); + + /* + * free all resources, close driver + */ + void (*dispose) (vo_driver_t *self); + + /** + * @brief Pointer to the loaded plugin node. + * + * Used by the plugins loader. It's an opaque type when using the + * structure outside of xine's build. + */ +#ifdef XINE_COMPILE + plugin_node_t *node; +#else + void *node; +#endif +}; + +struct video_driver_class_s { + + /* + * open a new instance of this plugin class + */ + vo_driver_t* (*open_plugin) (video_driver_class_t *self, const void *visual); + + /** + * @brief short human readable identifier for this plugin class + */ + const char *identifier; + + /** + * @brief human readable (verbose = 1 line) description for this plugin class + * + * The description is passed to gettext() to internationalise. + */ + const char *description; + + /** + * @brief Optional non-standard catalog to use with dgettext() for description. + */ + const char *text_domain; + + /* + * free all class-related resources + */ + void (*dispose) (video_driver_class_t *self); +}; + +#define default_video_driver_class_dispose (void (*) (video_driver_class_t *this))free + +typedef struct rle_elem_s { + uint16_t len; + uint16_t color; +} rle_elem_t; + +typedef struct argb_layer_s { + pthread_mutex_t mutex; + uint32_t *buffer; + /* dirty area */ + int x1, y1; + int x2, y2; + int ref_count; +} argb_layer_t; + +struct vo_overlay_s { + + rle_elem_t *rle; /* rle code buffer */ + int data_size; /* useful for deciding realloc */ + int num_rle; /* number of active rle codes */ + int x; /* x start of subpicture area */ + int y; /* y start of subpicture area */ + int width; /* width of subpicture area */ + int height; /* height of subpicture area */ + + /* area within osd extent to scale video to */ + int video_window_x; + int video_window_y; + int video_window_width; + int video_window_height; + + /* extent of reference coordinate system */ + int extent_width; + int extent_height; + + uint32_t color[OVL_PALETTE_SIZE]; /* color lookup table */ + uint8_t trans[OVL_PALETTE_SIZE]; /* mixer key table */ + int rgb_clut; /* true if clut was converted to rgb */ + + /* define a highlight area with different colors */ + int hili_top; + int hili_bottom; + int hili_left; + int hili_right; + uint32_t hili_color[OVL_PALETTE_SIZE]; + uint8_t hili_trans[OVL_PALETTE_SIZE]; + int hili_rgb_clut; /* true if clut was converted to rgb */ + + int unscaled; /* true if it should be blended unscaled */ + + argb_layer_t *argb_layer; +}; + +void set_argb_layer_ptr(argb_layer_t **dst, argb_layer_t *src); + +/* API to video_overlay manager + * + * Remember that adding new functions to this structure requires + * adaption of the post plugin decoration layer. Be sure to look into + * src/xine-engine/post.[ch]. + */ +struct video_overlay_manager_s { + void (*init) (video_overlay_manager_t *this_gen); + + void (*dispose) (video_overlay_manager_t *this_gen); + + int32_t (*get_handle) (video_overlay_manager_t *this_gen, int object_type ); + + void (*free_handle) (video_overlay_manager_t *this_gen, int32_t handle); + + int32_t (*add_event) (video_overlay_manager_t *this_gen, void *event); + + void (*flush_events) (video_overlay_manager_t *this_gen ); + + int (*redraw_needed) (video_overlay_manager_t *this_gen, int64_t vpts ); + + void (*multiple_overlay_blend) (video_overlay_manager_t *this_gen, int64_t vpts, + vo_driver_t *output, vo_frame_t *vo_img, int enabled); +}; + +/** + * @brief Build a video output port from a given video driver. + * + * @internal + */ +xine_video_port_t *_x_vo_new_port (xine_t *xine, vo_driver_t *driver, int grabonly) XINE_MALLOC; + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/include/xine/video_overlay.h b/include/xine/video_overlay.h new file mode 100644 index 000000000..ba710c9c9 --- /dev/null +++ b/include/xine/video_overlay.h @@ -0,0 +1,64 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef HAVE_VIDEO_OVERLAY_H +#define HAVE_VIDEO_OVERLAY_H + +#include <xine/xine_internal.h> + +#ifdef __GNUC__ +#define CLUT_Y_CR_CB_INIT(_y,_cr,_cb) {y: (_y), cr: (_cr), cb: (_cb)} +#else +#define CLUT_Y_CR_CB_INIT(_y,_cr,_cb) { (_cb), (_cr), (_y) } +#endif + +#define MAX_OBJECTS 50 +#define MAX_EVENTS 50 +#define MAX_SHOWING (5 + 16) + +#define OVERLAY_EVENT_NULL 0 +#define OVERLAY_EVENT_SHOW 1 +#define OVERLAY_EVENT_HIDE 2 +#define OVERLAY_EVENT_MENU_BUTTON 3 +#define OVERLAY_EVENT_FREE_HANDLE 8 /* Frees a handle, previous allocated via get_handle */ + +typedef struct video_overlay_object_s { + int32_t handle; /* Used to match Show and Hide events. */ + uint32_t object_type; /* 0=Subtitle, 1=Menu */ + int64_t pts; /* Needed for Menu button compares */ + vo_overlay_t *overlay; /* The image data. */ + uint32_t *palette; /* If NULL, no palette contained in this event. */ + uint32_t palette_type; /* 1 Y'CrCB, 2 R'G'B' */ +} video_overlay_object_t; + +/* This will hold all details of an event item, needed for event queue to function */ +typedef struct video_overlay_event_s { + int64_t vpts; /* Time when event will action. 0 means action now */ +/* Once video_out blend_yuv etc. can take rle_elem_t with Colour, blend and length information. + * we can remove clut and blend from this structure. + * This will allow for many more colours for OSD. + */ + uint32_t event_type; /* Show SPU, Show OSD, Hide etc. */ + video_overlay_object_t object; /* The image data. */ +} video_overlay_event_t; + +video_overlay_manager_t *_x_video_overlay_new_manager(xine_t *) XINE_MALLOC XINE_PROTECTED; + +#endif diff --git a/include/xine/vo_scale.h b/include/xine/vo_scale.h new file mode 100644 index 000000000..31976329d --- /dev/null +++ b/include/xine/vo_scale.h @@ -0,0 +1,195 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * vo_scale.h + * + * keeps video scaling information + */ + +#ifndef HAVE_VO_SCALE_H +#define HAVE_VO_SCALE_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <xine/configfile.h> + +typedef struct { + int x, y; + int w, h; +} vo_scale_rect_t; + +struct vo_scale_s { + + /* true if driver supports frame zooming */ + int support_zoom; + + /* forces direct mapping between frame pixels and screen pixels */ + int scaling_disabled; + + /* size / aspect ratio calculations */ + + /* + * "delivered" size: + * frame dimension / aspect as delivered by the decoder + * used (among other things) to detect frame size changes + * units: frame pixels + */ + int delivered_width; + int delivered_height; + double delivered_ratio; + + /* + * required cropping: + * units: frame pixels + */ + int crop_left; + int crop_right; + int crop_top; + int crop_bottom; + + /* + * displayed part of delivered images, + * taking zoom into account + * units: frame pixels + */ + int displayed_xoffset; + int displayed_yoffset; + int displayed_width; + int displayed_height; + double zoom_factor_x, zoom_factor_y; + + /* + * user's aspect selection + */ + int user_ratio; + + /* + * "gui" size / offset: + * what gui told us about where to display the video + * units: screen pixels + */ + int gui_x, gui_y; + int gui_width, gui_height; + int gui_win_x, gui_win_y; + + /* */ + int force_redraw; + + /* + * video + display pixel aspect + * One pixel of height 1 has this width + * This may be corrected by the driver in order to fit the video seamlessly + */ + double gui_pixel_aspect; + double video_pixel_aspect; + + /* + * "output" size: + * + * this is finally the ideal size "fitted" into the + * gui size while maintaining the aspect ratio + * units: screen pixels + */ + int output_width; + int output_height; + int output_xoffset; + int output_yoffset; + + + /* gui callbacks */ + + void *user_data; + void (*frame_output_cb) (void *user_data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_x, int *dest_y, + int *dest_width, int *dest_height, + double *dest_pixel_aspect, + int *win_x, int *win_y); + + void (*dest_size_cb) (void *user_data, + int video_width, int video_height, + double video_pixel_aspect, + int *dest_width, int *dest_height, + double *dest_pixel_aspect); + + /* borders */ + vo_scale_rect_t border[4]; + + /* + * border ratios to determine image position in the + * viewport; these are set by user config + */ + double output_horizontal_position; + double output_vertical_position; + +}; + +typedef struct vo_scale_s vo_scale_t; + + +/* + * convert delivered height/width to ideal width/height + * taking into account aspect ratio and zoom factor + */ + +void _x_vo_scale_compute_ideal_size (vo_scale_t *self) XINE_PROTECTED; + + +/* + * make ideal width/height "fit" into the gui + */ + +void _x_vo_scale_compute_output_size (vo_scale_t *self) XINE_PROTECTED; + +/* + * return true if a redraw is needed due resizing, zooming, + * aspect ratio changing, etc. + */ + +int _x_vo_scale_redraw_needed (vo_scale_t *self) XINE_PROTECTED; + +/* + * + */ + +void _x_vo_scale_translate_gui2video(vo_scale_t *self, + int x, int y, + int *vid_x, int *vid_y) XINE_PROTECTED; + +/* + * Returns description of a given ratio code + */ + +extern const char _x_vo_scale_aspect_ratio_name_table[][8] XINE_PROTECTED; + +/* + * initialize rescaling struct + */ + +void _x_vo_scale_init(vo_scale_t *self, int support_zoom, + int scaling_disabled, config_values_t *config ) XINE_PROTECTED; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/xine_buffer.h b/include/xine/xine_buffer.h new file mode 100644 index 000000000..7f6a3921d --- /dev/null +++ b/include/xine/xine_buffer.h @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2000-2004 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * + * generic dynamic buffer functions. The goals + * of these functions are (in fact many of these points + * are todos): + * - dynamic allocation and reallocation depending + * on the size of data written to it. + * - fast and transparent access to the data. + * The user sees only the raw data chunk as it is + * returned by the well-known malloc function. + * This is necessary since not all data-accessing + * functions can be wrapped here. + * - some additional health checks are made during + * development (eg boundary checks after direct + * access to a buffer). This can be turned off in + * production state for higher performance. + * - A lot of convenient string and memory manipulation + * functions are implemented here, where the user + * do not have to care about memory chunk sizes. + * - Some garbage collention could be implemented as well; + * i think of a global structure containing infos + * about all allocated chunks. This must be implemented + * in a thread-save way... + * + * Here are some drawbacks (aka policies): + * - The user must not pass indexed buffers to xine_buffer_* + * functions. + * - The pointers passed to xine_buffer_* functions may change + * (eg during reallocation). The user must respect that. + */ + +#ifndef HAVE_XINE_BUFFER_H +#define HAVE_XINE_BUFFER_H + +#include <xine/os_types.h> + +/* + * returns an initialized pointer to a buffer. + * The buffer will be allocated in blocks of + * chunk_size bytes. This will prevent permanent + * reallocation on slow growing buffers. + */ +void *xine_buffer_init(int chunk_size) XINE_PROTECTED; + +/* + * frees a buffer, the macro ensures, that a freed + * buffer pointer is set to NULL + */ +#define xine_buffer_free(buf) buf=_xine_buffer_free(buf) +void *_xine_buffer_free(void *buf) XINE_PROTECTED; + +/* + * duplicates a buffer + */ +void *xine_buffer_dup(const void *buf) XINE_PROTECTED; + +/* + * will copy len bytes of data into buf at position index. + */ +#define xine_buffer_copyin(buf,i,data,len) \ + buf=_xine_buffer_copyin(buf,i,data,len) +void *_xine_buffer_copyin(void *buf, int index, const void *data, int len) XINE_PROTECTED; + +/* + * will copy len bytes out of buf+index into data. + * no checks are made in data. It is treated as an ordinary + * user-malloced data chunk. + */ +void xine_buffer_copyout(const void *buf, int index, void *data, int len) XINE_PROTECTED; + +/* + * set len bytes in buf+index to b. + */ +#define xine_buffer_set(buf,i,b,len) \ + buf=_xine_buffer_set(buf,i,b,len) +void *_xine_buffer_set(void *buf, int index, uint8_t b, int len) XINE_PROTECTED; + +/* + * concatenates given buf (which should contain a null terminated string) + * with another string. + */ +#define xine_buffer_strcat(buf,data) \ + buf=_xine_buffer_strcat(buf,data) +void *_xine_buffer_strcat(void *buf, const char *data) XINE_PROTECTED; + +/* + * copies given string to buf+index + */ +#define xine_buffer_strcpy(buf,index,data) \ + buf=_xine_buffer_strcpy(buf,index,data) +void *_xine_buffer_strcpy(void *buf, int index, const char *data) XINE_PROTECTED; + +/* + * returns a pointer to the first occurence of ch. + * note, that the returned pointer cannot be used + * in any other xine_buffer_* functions. + */ +char *xine_buffer_strchr(const void *buf, int ch) XINE_PROTECTED; + +/* + * get allocated memory size + */ +int xine_buffer_get_size(const void *buf) XINE_PROTECTED; + +/* + * ensures a specified buffer size if the user want to + * write directly to the buffer. Normally the special + * access functions defined here should be used. + */ +#define xine_buffer_ensure_size(buf,data) \ + buf=_xine_buffer_ensure_size(buf,data) +void *_xine_buffer_ensure_size(void *buf, int size) XINE_PROTECTED; + +#endif diff --git a/include/xine/xine_internal.h b/include/xine/xine_internal.h new file mode 100644 index 000000000..ea0f0074a --- /dev/null +++ b/include/xine/xine_internal.h @@ -0,0 +1,544 @@ +/* + * Copyright (C) 2000-2005 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef HAVE_XINE_INTERNAL_H +#define HAVE_XINE_INTERNAL_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * include public part of xine header + */ + +#include <xine.h> +#include <xine/refcounter.h> +#include <xine/input_plugin.h> +#include <xine/demux.h> +#include <xine/video_out.h> +#include <xine/audio_out.h> +#include <xine/metronom.h> +#include <xine/osd.h> +#include <xine/xineintl.h> +#include <xine/plugin_catalog.h> +#include <xine/video_decoder.h> +#include <xine/audio_decoder.h> +#include <xine/spu_decoder.h> +#include <xine/scratch.h> +#include <xine/broadcaster.h> +#include <xine/io_helper.h> +#include <xine/info_helper.h> +#include <xine/alphablend.h> + +#define XINE_MAX_EVENT_LISTENERS 50 +#define XINE_MAX_EVENT_TYPES 100 +#define XINE_MAX_TICKET_HOLDER_THREADS 64 + +/* used by plugin loader */ +#define XINE_VERSION_CODE XINE_MAJOR_VERSION*10000+XINE_MINOR_VERSION*100+XINE_SUB_VERSION + + +/* + * log constants + */ + +#define XINE_LOG_MSG 0 /* warnings, errors, ... */ +#define XINE_LOG_PLUGIN 1 +#define XINE_LOG_TRACE 2 +#define XINE_LOG_NUM 3 /* # of log buffers defined */ + +#define XINE_STREAM_INFO_MAX 99 + +typedef struct xine_ticket_s xine_ticket_t; + +/* + * the "big" xine struct, holding everything together + */ + +#ifndef XDG_BASEDIR_H +/* present here for internal convenience only */ +typedef struct { void *reserved; } xdgHandle; +#endif + +struct xine_s { + + config_values_t *config; + + plugin_catalog_t *plugin_catalog; + + int verbosity; + + int demux_strategy; + char *save_path; + + /* log output that may be presented to the user */ + scratch_buffer_t *log_buffers[XINE_LOG_NUM]; + + xine_list_t *streams; + pthread_mutex_t streams_lock; + + metronom_clock_t *clock; + + /** Handle for libxdg-basedir functions. */ + xdgHandle basedir_handle; + +#ifdef XINE_ENGINE_INTERNAL + xine_ticket_t *port_ticket; + pthread_mutex_t log_lock; + + xine_log_cb_t log_cb; + void *log_cb_user_data; +#endif +}; + +/* FIXME-ABI Some global flag bits */ +/* See xine_set_flags() */ +#ifdef XINE_ENGINE_INTERNAL +extern int _x_flags XINE_PROTECTED; +#endif + +/* + * xine thread tickets + */ + +struct xine_ticket_s { + + /* the ticket owner must assure to check for ticket revocation in + * intervals of finite length; this means that you must release + * the ticket before any operation that might block + * + * you must never write to this member directly + */ + int ticket_revoked; + + /* apply for a ticket; between acquire and relese of an irrevocable + * ticket (be sure to pair them properly!), it is guaranteed that you + * will never be blocked by ticket revocation */ + void (*acquire)(xine_ticket_t *self, int irrevocable); + + /* give a ticket back */ + void (*release)(xine_ticket_t *self, int irrevocable); + + /* renew a ticket, when it has been revoked, see ticket_revoked above; + * irrevocable must be set to one, if your thread might have acquired + * irrevocable tickets you don't know of; set it to zero only when + * you know that this is impossible */ + void (*renew)(xine_ticket_t *self, int irrevocable); + +#ifdef XINE_ENGINE_INTERNAL + /* allow handing out new tickets */ + void (*issue)(xine_ticket_t *self, int atomic); + + /* revoke all tickets and deny new ones; + * a pair of atomic revoke and issue cannot be interrupted by another + * revocation or by other threads acquiring tickets */ + void (*revoke)(xine_ticket_t *self, int atomic); + + /* behaves like acquire() but doesn't block the calling thread; when + * the thread would have been blocked, 0 is returned otherwise 1 + * this function acquires a ticket even if ticket revocation is active */ + int (*acquire_nonblocking)(xine_ticket_t *self, int irrevocable); + + /* behaves like release() but doesn't block the calling thread; should + * be used in combination with acquire_nonblocking() */ + void (*release_nonblocking)(xine_ticket_t *self, int irrevocable); + + int (*lock_port_rewiring)(xine_ticket_t *self, int ms_timeout); + void (*unlock_port_rewiring)(xine_ticket_t *self); + + void (*dispose)(xine_ticket_t *self); + + pthread_mutex_t lock; + pthread_mutex_t revoke_lock; + pthread_cond_t issued; + pthread_cond_t revoked; + int tickets_granted; + int irrevocable_tickets; + int pending_revocations; + int atomic_revoke; + pthread_t atomic_revoker_thread; + pthread_mutex_t port_rewiring_lock; + struct { + int count; + pthread_t holder; + } *holder_threads; + unsigned holder_thread_count; +#endif +}; + +/* + * xine event queue + */ + +struct xine_event_queue_s { + xine_list_t *events; + pthread_mutex_t lock; + pthread_cond_t new_event; + pthread_cond_t events_processed; + xine_stream_t *stream; + pthread_t *listener_thread; + void *user_data; + xine_event_listener_cb_t callback; + int callback_running; +}; + +/* + * xine_stream - per-stream parts of the xine engine + */ + +struct xine_stream_s { + + /* reference to xine context */ + xine_t *xine; + + /* metronom instance used by current stream */ + metronom_t *metronom; + + /* demuxers use input_plugin to read data */ + input_plugin_t *input_plugin; + + /* used by video decoders */ + xine_video_port_t *video_out; + + /* demuxers send data to video decoders using this fifo */ + fifo_buffer_t *video_fifo; + + /* used by audio decoders */ + xine_audio_port_t *audio_out; + + /* demuxers send data to audio decoders using this fifo */ + fifo_buffer_t *audio_fifo; + + /* provide access to osd api */ + osd_renderer_t *osd_renderer; + + /* master/slave streams */ + xine_stream_t *master; /* usually a pointer to itself */ + xine_stream_t *slave; + + /* input_dvd uses this one. is it possible to add helper functions instead? */ + spu_decoder_t *spu_decoder_plugin; + + /* dxr3 use this one, should be possible to fix to use the port instead */ + vo_driver_t *video_driver; + + /* these definitely should be made private! */ + int audio_channel_auto; + int spu_decoder_streamtype; + int spu_channel_user; + int spu_channel_auto; + int spu_channel_letterbox; + int spu_channel; + + /* current content detection method, see METHOD_BY_xxx */ + int content_detection_method; + +#ifdef XINE_ENGINE_INTERNAL + /* these are private variables, plugins must not access them */ + + int status; + + /* lock controlling speed change access */ + pthread_mutex_t speed_change_lock; + uint32_t ignore_speed_change:1; /*< speed changes during stop can be disastrous */ + uint32_t video_thread_created:1; + uint32_t audio_thread_created:1; + uint32_t first_frame_flag:2; + uint32_t demux_action_pending:1; + uint32_t demux_thread_created:1; + uint32_t demux_thread_running:1; + uint32_t slave_is_subtitle:1; /*< ... and will be automaticaly disposed */ + uint32_t emergency_brake:1; /*< something went really wrong and this stream must be + * stopped. usually due some fatal error on output + * layers as they cannot call xine_stop. */ + uint32_t early_finish_event:1; /*< do not wait fifos get empty before sending event */ + uint32_t gapless_switch:1; /*< next stream switch will be gapless */ + uint32_t keep_ao_driver_open:1; + + input_class_t *eject_class; + demux_plugin_t *demux_plugin; + +/* vo_driver_t *video_driver;*/ + pthread_t video_thread; + video_decoder_t *video_decoder_plugin; + extra_info_t *video_decoder_extra_info; + int video_decoder_streamtype; + int video_channel; + + uint32_t audio_track_map[50]; + int audio_track_map_entries; + + int audio_decoder_streamtype; + pthread_t audio_thread; + audio_decoder_t *audio_decoder_plugin; + extra_info_t *audio_decoder_extra_info; + + uint32_t audio_type; + /* *_user: -2 => off + -1 => auto (use *_auto value) + >=0 => respect the user's choice + */ + int audio_channel_user; +/* int audio_channel_auto; */ + +/* spu_decoder_t *spu_decoder_plugin; */ +/* int spu_decoder_streamtype; */ + uint32_t spu_track_map[50]; + int spu_track_map_entries; +/* int spu_channel_user; */ +/* int spu_channel_auto; */ +/* int spu_channel_letterbox; */ + int spu_channel_pan_scan; +/* int spu_channel; */ + + /* lock for public xine player functions */ + pthread_mutex_t frontend_lock; + + /* stream meta information */ + /* NEVER access directly, use helpers (see info_helper.c) */ + pthread_mutex_t info_mutex; + int stream_info_public[XINE_STREAM_INFO_MAX]; + int stream_info[XINE_STREAM_INFO_MAX]; + pthread_mutex_t meta_mutex; + char *meta_info_public[XINE_STREAM_INFO_MAX]; + char *meta_info[XINE_STREAM_INFO_MAX]; + + /* seeking slowdown */ + pthread_mutex_t first_frame_lock; + pthread_cond_t first_frame_reached; + + /* wait for headers sent / stream decoding finished */ + pthread_mutex_t counter_lock; + pthread_cond_t counter_changed; + int header_count_audio; + int header_count_video; + int finished_count_audio; + int finished_count_video; + + /* event mechanism */ + xine_list_t *event_queues; + pthread_mutex_t event_queues_lock; + + /* demux thread stuff */ + pthread_t demux_thread; + pthread_mutex_t demux_lock; + pthread_mutex_t demux_action_lock; + pthread_cond_t demux_resume; + pthread_mutex_t demux_mutex; /* used in _x_demux_... functions to synchronize order of pairwise A/V buffer operations */ + + extra_info_t *current_extra_info; + pthread_mutex_t current_extra_info_lock; + int video_seek_count; + + int delay_finish_event; /* delay event in 1/10 sec units. 0=>no delay, -1=>forever */ + + int slave_affection; /* what operations need to be propagated down to the slave? */ + + int err; + + xine_post_out_t video_source; + xine_post_out_t audio_source; + + broadcaster_t *broadcaster; + + refcounter_t *refcounter; +#endif +}; + +/* when explicitly noted, some functions accept an anonymous stream, + * which is a valid stream that does not want to be addressed. */ +#define XINE_ANON_STREAM ((xine_stream_t *)-1) + +typedef struct +{ + int total; + int ready; + int avail; +} +xine_query_buffers_data_t; + +typedef struct +{ + xine_query_buffers_data_t vi; + xine_query_buffers_data_t ai; + xine_query_buffers_data_t vo; + xine_query_buffers_data_t ao; +} +xine_query_buffers_t; + +/* + * private function prototypes: + */ + +int _x_query_buffers(xine_stream_t *stream, xine_query_buffers_t *query) XINE_PROTECTED; +int _x_query_buffer_usage(xine_stream_t *stream, int *num_video_buffers, int *num_audio_buffers, int *num_video_frames, int *num_audio_frames) XINE_PROTECTED; +int _x_lock_port_rewiring(xine_t *xine, int ms_to_time_out) XINE_PROTECTED; +void _x_unlock_port_rewiring(xine_t *xine) XINE_PROTECTED; +int _x_lock_frontend(xine_stream_t *stream, int ms_to_time_out) XINE_PROTECTED; +void _x_unlock_frontend(xine_stream_t *stream) XINE_PROTECTED; +int _x_query_unprocessed_osd_events(xine_stream_t *stream) XINE_PROTECTED; +int _x_demux_seek(xine_stream_t *stream, off_t start_pos, int start_time, int playing) XINE_PROTECTED; +int _x_continue_stream_processing(xine_stream_t *stream) XINE_PROTECTED; +void _x_trigger_relaxed_frame_drop_mode(xine_stream_t *stream) XINE_PROTECTED; +void _x_reset_relaxed_frame_drop_mode(xine_stream_t *stream) XINE_PROTECTED; + +void _x_handle_stream_end (xine_stream_t *stream, int non_user) XINE_PROTECTED; + +/* report message to UI. usually these are async errors */ + +int _x_message(xine_stream_t *stream, int type, ...) XINE_SENTINEL XINE_PROTECTED; + +/* flush the message queues */ + +void _x_flush_events_queues (xine_stream_t *stream) XINE_PROTECTED; + +/* extra_info operations */ +void _x_extra_info_reset( extra_info_t *extra_info ) XINE_PROTECTED; + +void _x_extra_info_merge( extra_info_t *dst, extra_info_t *src ) XINE_PROTECTED; + +void _x_get_current_info (xine_stream_t *stream, extra_info_t *extra_info, int size) XINE_PROTECTED; + + +/* demuxer helper functions from demux.c */ + +/* + * Flush audio and video buffers. It is called from demuxers on + * seek/stop, and may be useful when user input changes a stream and + * xine-lib has cached buffers that have yet to be played. + * + * warning: after clearing decoders fifos an absolute discontinuity + * indication must be sent. relative discontinuities are likely + * to cause "jumps" on metronom. + */ +void _x_demux_flush_engine (xine_stream_t *stream) XINE_PROTECTED; + +void _x_demux_control_nop (xine_stream_t *stream, uint32_t flags) XINE_PROTECTED; +void _x_demux_control_newpts (xine_stream_t *stream, int64_t pts, uint32_t flags) XINE_PROTECTED; +void _x_demux_control_headers_done (xine_stream_t *stream) XINE_PROTECTED; +void _x_demux_control_start (xine_stream_t *stream) XINE_PROTECTED; +void _x_demux_control_end (xine_stream_t *stream, uint32_t flags) XINE_PROTECTED; +int _x_demux_start_thread (xine_stream_t *stream) XINE_PROTECTED; +int _x_demux_stop_thread (xine_stream_t *stream) XINE_PROTECTED; +int _x_demux_read_header (input_plugin_t *input, void *buffer, off_t size) XINE_PROTECTED; +int _x_demux_check_extension (const char *mrl, const char *extensions); + +off_t _x_read_abort (xine_stream_t *stream, int fd, char *buf, off_t todo) XINE_PROTECTED; + +int _x_action_pending (xine_stream_t *stream) XINE_PROTECTED; + +void _x_action_raise (xine_stream_t *stream) XINE_PROTECTED; +void _x_action_lower (xine_stream_t *stream) XINE_PROTECTED; + +void _x_demux_send_data(fifo_buffer_t *fifo, uint8_t *data, int size, + int64_t pts, uint32_t type, uint32_t decoder_flags, + int input_normpos, int input_time, int total_time, + uint32_t frame_number) XINE_PROTECTED; + +int _x_demux_read_send_data(fifo_buffer_t *fifo, input_plugin_t *input, + int size, int64_t pts, uint32_t type, + uint32_t decoder_flags, off_t input_normpos, + int input_time, int total_time, + uint32_t frame_number) XINE_PROTECTED; + +void _x_demux_send_mrl_reference (xine_stream_t *stream, int alternative, + const char *mrl, const char *title, + int start_time, int duration) XINE_PROTECTED; + +/* + * MRL escaped-character decoding (overwrites the source string) + */ +void _x_mrl_unescape(char *mrl) XINE_PROTECTED; + +/* + * plugin_loader functions + * + */ + +/* on-demand loading of audio/video/spu decoder plugins */ + +video_decoder_t *_x_get_video_decoder (xine_stream_t *stream, uint8_t stream_type) XINE_PROTECTED; +void _x_free_video_decoder (xine_stream_t *stream, video_decoder_t *decoder) XINE_PROTECTED; +audio_decoder_t *_x_get_audio_decoder (xine_stream_t *stream, uint8_t stream_type) XINE_PROTECTED; +void _x_free_audio_decoder (xine_stream_t *stream, audio_decoder_t *decoder) XINE_PROTECTED; +spu_decoder_t *_x_get_spu_decoder (xine_stream_t *stream, uint8_t stream_type) XINE_PROTECTED; +void _x_free_spu_decoder (xine_stream_t *stream, spu_decoder_t *decoder) XINE_PROTECTED; +/* check for decoder availability - but don't try to initialize it */ +int _x_decoder_available (xine_t *xine, uint32_t buftype) XINE_PROTECTED; + +/* + * load_video_output_plugin + * + * load a specific video output plugin + */ + +vo_driver_t *_x_load_video_output_plugin(xine_t *this, + char *id, int visual_type, void *visual) XINE_PROTECTED; + +/* + * audio output plugin dynamic loading stuff + */ + +/* + * load_audio_output_plugin + * + * load a specific audio output plugin + */ + +ao_driver_t *_x_load_audio_output_plugin (xine_t *self, const char *id) XINE_PROTECTED; + + +void _x_set_speed (xine_stream_t *stream, int speed) XINE_PROTECTED; + +int _x_get_speed (xine_stream_t *stream) XINE_PROTECTED; + +void _x_set_fine_speed (xine_stream_t *stream, int speed) XINE_PROTECTED; + +int _x_get_fine_speed (xine_stream_t *stream) XINE_PROTECTED; + +void _x_select_spu_channel (xine_stream_t *stream, int channel) XINE_PROTECTED; + +int _x_get_audio_channel (xine_stream_t *stream) XINE_PROTECTED; + +int _x_get_spu_channel (xine_stream_t *stream) XINE_PROTECTED; + +/* + * internal events + */ + +/* sent by dvb frontend to inform ts demuxer of new pids */ +#define XINE_EVENT_PIDS_CHANGE 0x80000000 +/* sent by BluRay input plugin to inform ts demuxer about end of clip */ +#define XINE_EVENT_END_OF_CLIP 0x80000001 + +/* + * pids change event - inform ts demuxer of new pids + */ +typedef struct { + int vpid; /* video program id */ + int apid; /* audio program id */ +} xine_pids_data_t; + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/xine_plugin.h b/include/xine/xine_plugin.h new file mode 100644 index 000000000..31a14b511 --- /dev/null +++ b/include/xine/xine_plugin.h @@ -0,0 +1,105 @@ +/* + * Copyright (C) 2000-2003 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + * + * generic plugin definitions + */ + +#ifndef XINE_PLUGIN_H +#define XINE_PLUGIN_H + +#define PLUGIN_NONE 0 +#define PLUGIN_INPUT 1 +#define PLUGIN_DEMUX 2 +#define PLUGIN_AUDIO_DECODER 3 +#define PLUGIN_VIDEO_DECODER 4 +#define PLUGIN_SPU_DECODER 5 +#define PLUGIN_AUDIO_OUT 6 +#define PLUGIN_VIDEO_OUT 7 +#define PLUGIN_POST 8 + +#define PLUGIN_TYPE_MAX PLUGIN_POST + +/* this flag may be or'ed with type in order to force preloading the plugin. + * very useful to register config items on xine initialization. + */ +#define PLUGIN_MUST_PRELOAD (1 << 7) + +/* this flag may be or'ed with type to prevent the plugin loader from unloading + * the plugin + */ +#define PLUGIN_NO_UNLOAD (1 << 6) + +#define PLUGIN_TYPE_MASK ((1 << 6) - 1) + +typedef struct { + uint8_t type; /* one of the PLUGIN_* constants above */ + uint8_t API; /* API version supported by this plugin */ + const char *id; /* a name that identifies this plugin */ + uint32_t version; /* version number, increased every release */ + const void *special_info; /* plugin-type specific, see structs below */ + void *(*init)(xine_t *, void *); /* init the plugin class */ +} plugin_info_t; + + +/* special_info for a video output plugin */ +typedef struct { + int priority; /* priority of this plugin for auto-probing */ + int visual_type; /* visual type supported by this plugin */ +} vo_info_t; + +/* special info for a audio output plugin */ +typedef struct { + int priority; +} ao_info_t; + +/* special_info for a decoder plugin */ +typedef struct { + const uint32_t *supported_types; /* streamtypes this decoder can handle */ + int priority; +} decoder_info_t; + +/* special info for a post plugin */ +typedef struct { + uint32_t type; /* type of the post plugin, use one of XINE_POST_TYPE_* */ +} post_info_t; + +/* special info for a demuxer plugin */ +typedef struct { + int priority; +} demuxer_info_t; + +/* special info for an input plugin */ +typedef struct { + int priority; +} input_info_t; + + +/* register a list of statically linked plugins + * info is a list of plugin_info_t terminated by PLUGIN_NONE + * example: + * plugin_info_t acme_plugin_info[] = { + * { PLUGIN_VIDEO_OUT, 21, "acme", XINE_VERSION_CODE, &vo_info_acme, + * init_class_acme }, + * { PLUGIN_NONE, 0, "", 0, NULL, NULL } + * }; + * + */ +void xine_register_plugins(xine_t *self, plugin_info_t *info) XINE_PROTECTED; + +#endif diff --git a/include/xine/xineintl.h b/include/xine/xineintl.h new file mode 100644 index 000000000..bb9c006ef --- /dev/null +++ b/include/xine/xineintl.h @@ -0,0 +1,54 @@ +/* + * Copyright (C) 2000-2005 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ + +#ifndef HAVE_XINEINTL_H +#define HAVE_XINEINTL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <locale.h> + +#ifdef ENABLE_NLS +# include <libintl.h> +# define _(String) dgettext (XINE_TEXTDOMAIN, String) +# ifdef gettext_noop +# define N_(String) gettext_noop (String) +# else +# define N_(String) (String) +# endif +#else +/* Stubs that do something close enough. */ +# define textdomain(String) (String) +# define gettext(String) (String) +# define dgettext(Domain,Message) (Message) +# define dcgettext(Domain,Message,Type) (Message) +# define ngettext(Singular, Plural, IsPlural) (Singular) +# define bindtextdomain(Domain,Directory) (Domain) +# define _(String) (String) +# define N_(String) (String) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/xineutils.h b/include/xine/xineutils.h new file mode 100644 index 000000000..5b8b4f1f4 --- /dev/null +++ b/include/xine/xineutils.h @@ -0,0 +1,520 @@ +/* + * Copyright (C) 2000-2006 the xine project + * + * This file is part of xine, a free video player. + * + * xine is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * xine is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA + */ +#ifndef XINEUTILS_H +#define XINEUTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdlib.h> +#include <string.h> +#include <stdarg.h> +#include <pthread.h> + +#ifdef WIN32 +# include <winsock.h> +#else +# include <sys/time.h> +#endif +#include <xine/os_types.h> +#include <xine/attributes.h> +#include <xine/compat.h> +#include <xine/xmlparser.h> +#include <xine/xine_buffer.h> +#include <xine/configfile.h> +#include <xine/list.h> +#include <xine/array.h> +#include <xine/sorted_array.h> + +#include <stdio.h> +#include <string.h> + +/* + * Mark exported data symbols for link engine library clients with older + * Win32 compilers + */ +#if defined(WIN32) && !defined(XINE_LIBRARY_COMPILE) +# define DL_IMPORT __declspec(dllimport) +# define extern DL_IMPORT extern +#endif + + /* + * debugable mutexes + */ + + typedef struct { + pthread_mutex_t mutex; + char id[80]; + char *locked_by; + } xine_mutex_t; + + int xine_mutex_init (xine_mutex_t *mutex, const pthread_mutexattr_t *mutexattr, + const char *id) XINE_PROTECTED; + + int xine_mutex_lock (xine_mutex_t *mutex, const char *who) XINE_PROTECTED; + int xine_mutex_unlock (xine_mutex_t *mutex, const char *who) XINE_PROTECTED; + int xine_mutex_destroy (xine_mutex_t *mutex) XINE_PROTECTED; + + + + /* CPU Acceleration */ + +/* + * The type of an value that fits in an MMX register (note that long + * long constant values MUST be suffixed by LL and unsigned long long + * values by ULL, lest they be truncated by the compiler) + */ + +/* generic accelerations */ +#define MM_ACCEL_MLIB 0x00000001 + +/* x86 accelerations */ +#define MM_ACCEL_X86_MMX 0x80000000 +#define MM_ACCEL_X86_3DNOW 0x40000000 +#define MM_ACCEL_X86_MMXEXT 0x20000000 +#define MM_ACCEL_X86_SSE 0x10000000 +#define MM_ACCEL_X86_SSE2 0x08000000 + +/* powerpc accelerations and features */ +#define MM_ACCEL_PPC_ALTIVEC 0x04000000 +#define MM_ACCEL_PPC_CACHE32 0x02000000 + +/* SPARC accelerations */ + +#define MM_ACCEL_SPARC_VIS 0x01000000 +#define MM_ACCEL_SPARC_VIS2 0x00800000 + +/* x86 compat defines */ +#define MM_MMX MM_ACCEL_X86_MMX +#define MM_3DNOW MM_ACCEL_X86_3DNOW +#define MM_MMXEXT MM_ACCEL_X86_MMXEXT +#define MM_SSE MM_ACCEL_X86_SSE +#define MM_SSE2 MM_ACCEL_X86_SSE2 + +uint32_t xine_mm_accel (void) XINE_CONST XINE_PROTECTED; + + + + /* Optimized/fast memcpy */ + +extern void *(* xine_fast_memcpy)(void *to, const void *from, size_t len) XINE_PROTECTED; + +/* + * Debug stuff + */ +/* + * profiling (unworkable in non DEBUG isn't defined) + */ +void xine_profiler_init (void) XINE_PROTECTED; +int xine_profiler_allocate_slot (const char *label) XINE_PROTECTED; +void xine_profiler_start_count (int id) XINE_PROTECTED; +void xine_profiler_stop_count (int id) XINE_PROTECTED; +void xine_profiler_print_results (void) XINE_PROTECTED; + +/* + * Allocate and clean memory size_t 'size', then return the pointer + * to the allocated memory. + */ +void *xine_xmalloc(size_t size) XINE_MALLOC XINE_DEPRECATED XINE_PROTECTED; + +void *xine_xcalloc(size_t nmemb, size_t size) XINE_MALLOC XINE_PROTECTED; + +/* + * Copy blocks of memory. + */ +void *xine_memdup (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED; +void *xine_memdup0 (const void *src, size_t length) XINE_MALLOC XINE_PROTECTED; + +/* + * Get user home directory. + */ +const char *xine_get_homedir(void) XINE_PROTECTED; + +#if defined(WIN32) || defined(__CYGWIN__) +/* + * Get other xine directories. + */ +const char *xine_get_pluginroot(void) XINE_PROTECTED; +const char *xine_get_plugindir(void) XINE_PROTECTED; +const char *xine_get_fontdir(void) XINE_PROTECTED; +const char *xine_get_localedir(void) XINE_PROTECTED; +#endif + +/* + * Clean a string (remove spaces and '=' at the begin, + * and '\n', '\r' and spaces at the end. + */ +char *xine_chomp (char *str) XINE_PROTECTED; + +/* + * A thread-safe usecond sleep + */ +void xine_usec_sleep(unsigned usec) XINE_PROTECTED; + +/* compatibility macros */ +#define xine_strpbrk(S, ACCEPT) strpbrk((S), (ACCEPT)) +#define xine_strsep(STRINGP, DELIM) strsep((STRINGP), (DELIM)) +#define xine_setenv(NAME, VAL, XX) setenv((NAME), (VAL), (XX)) + +/** + * append to a string, reallocating + * normally, updates & returns *dest + * on error, *dest is unchanged & NULL is returned. + */ +char *xine_strcat_realloc (char **dest, char *append) XINE_PROTECTED; + +/** + * asprintf wrapper + * allocate a string large enough to hold the output, and return a pointer to + * it. This pointer should be passed to free when it is no longer needed. + * return NULL on error. + */ +char *_x_asprintf(const char *format, ...) XINE_PROTECTED XINE_MALLOC XINE_FORMAT_PRINTF(1, 2); + +/** + * opens a file, ensuring that the descriptor will be closed + * automatically after a fork/execute. + */ +int xine_open_cloexec(const char *name, int flags) XINE_PROTECTED; + +/** + * creates a file, ensuring that the descriptor will be closed + * automatically after a fork/execute. + */ +int xine_create_cloexec(const char *name, int flags, mode_t mode) XINE_PROTECTED; + +/** + * creates a socket, ensuring that the descriptor will be closed + * automatically after a fork/execute. + */ +int xine_socket_cloexec(int domain, int type, int protocol) XINE_PROTECTED; + +/* + * Color Conversion Utility Functions + * The following data structures and functions facilitate the conversion + * of RGB images to packed YUV (YUY2) images. There are also functions to + * convert from YUV9 -> YV12. All of the meaty details are written in + * color.c. + */ + +typedef struct yuv_planes_s { + + unsigned char *y; + unsigned char *u; + unsigned char *v; + unsigned int row_width; /* frame width */ + unsigned int row_count; /* frame height */ + +} yuv_planes_t; + +void init_yuv_conversion(void) XINE_PROTECTED; +void init_yuv_planes(yuv_planes_t *yuv_planes, int width, int height) XINE_PROTECTED; +void free_yuv_planes(yuv_planes_t *yuv_planes) XINE_PROTECTED; + +extern void (*yuv444_to_yuy2) + (const yuv_planes_t *yuv_planes, unsigned char *yuy2_map, int pitch) XINE_PROTECTED; +extern void (*yuv9_to_yv12) + (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, + const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, + const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, + int width, int height) XINE_PROTECTED; +extern void (*yuv411_to_yv12) + (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dest, int y_dest_pitch, + const unsigned char *u_src, int u_src_pitch, unsigned char *u_dest, int u_dest_pitch, + const unsigned char *v_src, int v_src_pitch, unsigned char *v_dest, int v_dest_pitch, + int width, int height) XINE_PROTECTED; +extern void (*yv12_to_yuy2) + (const unsigned char *y_src, int y_src_pitch, + const unsigned char *u_src, int u_src_pitch, + const unsigned char *v_src, int v_src_pitch, + unsigned char *yuy2_map, int yuy2_pitch, + int width, int height, int progressive) XINE_PROTECTED; +extern void (*yuy2_to_yv12) + (const unsigned char *yuy2_map, int yuy2_pitch, + unsigned char *y_dst, int y_dst_pitch, + unsigned char *u_dst, int u_dst_pitch, + unsigned char *v_dst, int v_dst_pitch, + int width, int height) XINE_PROTECTED; + +/* convert full range rgb to mpeg range yuv */ +#define SCALESHIFT 16 +#define SCALEFACTOR (1<<SCALESHIFT) +#define CENTERSAMPLE 128 + +#define COMPUTE_Y(r, g, b) \ + (unsigned char) \ + (((y_r_table[r] + y_g_table[g] + y_b_table[b]) >> SCALESHIFT) + 16) +#define COMPUTE_U(r, g, b) \ + (unsigned char) \ + (((u_r_table[r] + u_g_table[g] + u_b_table[b]) >> SCALESHIFT) + CENTERSAMPLE) +#define COMPUTE_V(r, g, b) \ + (unsigned char) \ + (((v_r_table[r] + v_g_table[g] + v_b_table[b]) >> SCALESHIFT) + CENTERSAMPLE) + +#define UNPACK_BGR15(packed_pixel, r, g, b) \ + b = (packed_pixel & 0x7C00) >> 7; \ + g = (packed_pixel & 0x03E0) >> 2; \ + r = (packed_pixel & 0x001F) << 3; + +#define UNPACK_BGR16(packed_pixel, r, g, b) \ + b = (packed_pixel & 0xF800) >> 8; \ + g = (packed_pixel & 0x07E0) >> 3; \ + r = (packed_pixel & 0x001F) << 3; + +#define UNPACK_RGB15(packed_pixel, r, g, b) \ + r = (packed_pixel & 0x7C00) >> 7; \ + g = (packed_pixel & 0x03E0) >> 2; \ + b = (packed_pixel & 0x001F) << 3; + +#define UNPACK_RGB16(packed_pixel, r, g, b) \ + r = (packed_pixel & 0xF800) >> 8; \ + g = (packed_pixel & 0x07E0) >> 3; \ + b = (packed_pixel & 0x001F) << 3; + +extern int y_r_table[256] XINE_PROTECTED; +extern int y_g_table[256] XINE_PROTECTED; +extern int y_b_table[256] XINE_PROTECTED; + +extern int u_r_table[256] XINE_PROTECTED; +extern int u_g_table[256] XINE_PROTECTED; +extern int u_b_table[256] XINE_PROTECTED; + +extern int v_r_table[256] XINE_PROTECTED; +extern int v_g_table[256] XINE_PROTECTED; +extern int v_b_table[256] XINE_PROTECTED; + +/* frame copying functions */ +extern void yv12_to_yv12 + (const unsigned char *y_src, int y_src_pitch, unsigned char *y_dst, int y_dst_pitch, + const unsigned char *u_src, int u_src_pitch, unsigned char *u_dst, int u_dst_pitch, + const unsigned char *v_src, int v_src_pitch, unsigned char *v_dst, int v_dst_pitch, + int width, int height) XINE_PROTECTED; +extern void yuy2_to_yuy2 + (const unsigned char *src, int src_pitch, + unsigned char *dst, int dst_pitch, + int width, int height) XINE_PROTECTED; + +/* print a hexdump of the given data */ +void xine_hexdump (const void *buf, int length) XINE_PROTECTED; + +/* + * Optimization macros for conditions + * Taken from the FIASCO L4 microkernel sources + */ +#if !defined(__GNUC__) || __GNUC__ < 3 +# define EXPECT_TRUE(x) (x) +# define EXPECT_FALSE(x) (x) +#else +# define EXPECT_TRUE(x) __builtin_expect((x),1) +# define EXPECT_FALSE(x) __builtin_expect((x),0) +#endif + +#ifdef NDEBUG +#define _x_assert(exp) \ + do { \ + if (!(exp)) \ + fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \ + __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \ + } while(0) +#else +#define _x_assert(exp) \ + do { \ + if (!(exp)) { \ + fprintf(stderr, "assert: %s:%d: %s: Assertion `%s' failed.\n", \ + __FILE__, __LINE__, __XINE_FUNCTION__, #exp); \ + abort(); \ + } \ + } while(0) +#endif + +#define _x_abort() \ + do { \ + fprintf(stderr, "abort: %s:%d: %s: Aborting.\n", \ + __FILE__, __LINE__, __XINE_FUNCTION__); \ + abort(); \ + } while(0) + + +/****** logging with xine **********************************/ + +#ifndef LOG_MODULE + #define LOG_MODULE __FILE__ +#endif /* LOG_MODULE */ + +#define LOG_MODULE_STRING printf("%s: ", LOG_MODULE ); + +#ifdef LOG_VERBOSE + #define LONG_LOG_MODULE_STRING \ + printf("%s: (%s:%d) ", LOG_MODULE, __XINE_FUNCTION__, __LINE__ ); +#else + #define LONG_LOG_MODULE_STRING LOG_MODULE_STRING +#endif /* LOG_VERBOSE */ + +#ifdef LOG + #ifdef __GNUC__ + #define lprintf(fmt, args...) \ + do { \ + LONG_LOG_MODULE_STRING \ + printf(fmt, ##args); \ + fflush(stdout); \ + } while(0) + #else /* __GNUC__ */ + #ifdef _MSC_VER + #define lprintf(fmtargs) \ + do { \ + LONG_LOG_MODULE_STRING \ + printf("%s", fmtargs); \ + fflush(stdout); \ + } while(0) + #else /* _MSC_VER */ + #define lprintf(...) \ + do { \ + LONG_LOG_MODULE_STRING \ + printf(__VA_ARGS__); \ + fflush(stdout); \ + } while(0) + #endif /* _MSC_VER */ + #endif /* __GNUC__ */ +#else /* LOG */ + #ifdef __GNUC__ + #define lprintf(fmt, args...) do {} while(0) + #else + #ifdef _MSC_VER +void __inline lprintf(const char * fmt, ...) {} + #else + #define lprintf(...) do {} while(0) + #endif /* _MSC_VER */ + #endif /* __GNUC__ */ +#endif /* LOG */ + +#ifdef __GNUC__ + #define llprintf(cat, fmt, args...) \ + do{ \ + if(cat){ \ + LONG_LOG_MODULE_STRING \ + printf( fmt, ##args ); \ + } \ + }while(0) +#else +#ifdef _MSC_VER + #define llprintf(cat, fmtargs) \ + do{ \ + if(cat){ \ + LONG_LOG_MODULE_STRING \ + printf( "%s", fmtargs ); \ + } \ + }while(0) +#else + #define llprintf(cat, ...) \ + do{ \ + if(cat){ \ + LONG_LOG_MODULE_STRING \ + printf( __VA_ARGS__ ); \ + } \ + }while(0) +#endif /* _MSC_VER */ +#endif /* __GNUC__ */ + +#ifdef __GNUC__ + #define xprintf(xine, verbose, fmt, args...) \ + do { \ + if((xine) && (xine)->verbosity >= verbose){ \ + xine_log(xine, XINE_LOG_TRACE, fmt, ##args); \ + } \ + } while(0) +#else +#ifdef _MSC_VER +void xine_xprintf(xine_t *xine, int verbose, const char *fmt, ...); + #define xprintf xine_xprintf +#else + #define xprintf(xine, verbose, ...) \ + do { \ + if((xine) && (xine)->verbosity >= verbose){ \ + xine_log(xine, XINE_LOG_TRACE, __VA_ARGS__); \ + } \ + } while(0) +#endif /* _MSC_VER */ +#endif /* __GNUC__ */ + +/* time measuring macros for profiling tasks */ + +#ifdef DEBUG +# define XINE_PROFILE(function) \ + do { \ + struct timeval current_time; \ + double dtime; \ + gettimeofday(¤t_time, NULL); \ + dtime = -(current_time.tv_sec + (current_time.tv_usec / 1000000.0)); \ + function; \ + gettimeofday(¤t_time, NULL); \ + dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \ + printf("%s: (%s:%d) took %lf seconds\n", \ + LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \ + } while(0) +# define XINE_PROFILE_ACCUMULATE(function) \ + do { \ + struct timeval current_time; \ + static double dtime = 0; \ + gettimeofday(¤t_time, NULL); \ + dtime -= current_time.tv_sec + (current_time.tv_usec / 1000000.0); \ + function; \ + gettimeofday(¤t_time, NULL); \ + dtime += current_time.tv_sec + (current_time.tv_usec / 1000000.0); \ + printf("%s: (%s:%d) took %lf seconds\n", \ + LOG_MODULE, __XINE_FUNCTION__, __LINE__, dtime); \ + } while(0) +#else +# define XINE_PROFILE(function) function +# define XINE_PROFILE_ACCUMULATE(function) function +#endif /* DEBUG */ + +/** + * get encoding of current locale + */ +char *xine_get_system_encoding(void) XINE_MALLOC XINE_PROTECTED; + +/* + * guess default encoding for the subtitles + */ +const char *xine_guess_spu_encoding(void) XINE_PROTECTED; + +/* + * use the best clock reference (API compatible with gettimeofday) + * note: it will be a monotonic clock, if available. + */ +int xine_monotonic_clock(struct timeval *tv, struct timezone *tz) XINE_PROTECTED; + +/** + * Unknown FourCC reporting functions + */ +void _x_report_video_fourcc (xine_t *, const char *module, uint32_t) XINE_PROTECTED; +void _x_report_audio_format_tag (xine_t *, const char *module, uint32_t) XINE_PROTECTED; + +/* don't harm following code */ +#ifdef extern +# undef extern +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/include/xine/xmllexer.h b/include/xine/xmllexer.h new file mode 100644 index 000000000..70fa86ee0 --- /dev/null +++ b/include/xine/xmllexer.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2002-2003,2007 the xine project + * + * This file is part of xine, a free video player. + * + * The xine-lib XML parser is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The xine-lib XML parser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110, USA + */ + +/* xml lexer */ +#ifndef XML_LEXER_H +#define XML_LEXER_H + +#ifndef XINE_DEPRECATED +#define XINE_DEPRECATED +#endif + +#ifndef XINE_PROTECTED +#define XINE_PROTECTED +#endif + +/* public constants */ +#define T_ERROR -1 /* lexer error */ +#define T_EOF 0 /* end of file */ +#define T_EOL 1 /* end of line */ +#define T_SEPAR 2 /* separator ' ' '/t' '\n' '\r' */ +#define T_M_START_1 3 /* markup start < */ +#define T_M_START_2 4 /* markup start </ */ +#define T_M_STOP_1 5 /* markup stop > */ +#define T_M_STOP_2 6 /* markup stop /> */ +#define T_EQUAL 7 /* = */ +#define T_QUOTE 8 /* \" or \' */ +#define T_STRING 9 /* "string" */ +#define T_IDENT 10 /* identifier */ +#define T_DATA 11 /* data */ +#define T_C_START 12 /* <!-- */ +#define T_C_STOP 13 /* --> */ +#define T_TI_START 14 /* <? */ +#define T_TI_STOP 15 /* ?> */ +#define T_DOCTYPE_START 16 /* <!DOCTYPE */ +#define T_DOCTYPE_STOP 17 /* > */ +#define T_CDATA_START 18 /* <![CDATA[ */ +#define T_CDATA_STOP 19 /* ]]> */ + + +/* public structure */ +struct lexer +{ + const char * lexbuf; + int lexbuf_size; + int lexbuf_pos; + int lex_mode; + int in_comment; + char *lex_malloc; +}; + + +/* public functions */ +void lexer_init(const char * buf, int size) XINE_DEPRECATED XINE_PROTECTED; +struct lexer *lexer_init_r(const char * buf, int size) XINE_PROTECTED; +void lexer_finalize_r(struct lexer * lexer) XINE_PROTECTED; +int lexer_get_token_d_r(struct lexer * lexer, char ** tok, int * tok_size, int fixed) XINE_PROTECTED; +int lexer_get_token_d(char ** tok, int * tok_size, int fixed) XINE_DEPRECATED XINE_PROTECTED; +int lexer_get_token(char * tok, int tok_size) XINE_DEPRECATED XINE_PROTECTED; +char *lexer_decode_entities (const char *tok) XINE_PROTECTED; + +#endif diff --git a/include/xine/xmlparser.h b/include/xine/xmlparser.h new file mode 100644 index 000000000..495e5136b --- /dev/null +++ b/include/xine/xmlparser.h @@ -0,0 +1,114 @@ +/* + * Copyright (C) 2002-2003,2007 the xine project + * + * This file is part of xine, a free video player. + * + * The xine-lib XML parser is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * The xine-lib XML parser is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with the Gnome Library; see the file COPYING.LIB. If not, + * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110, USA + */ + +#ifndef XML_PARSER_H +#define XML_PARSER_H + +#ifndef XINE_DEPRECATED +#define XINE_DEPRECATED +#endif + +#ifndef XINE_PROTECTED +#define XINE_PROTECTED +#endif + +/* parser modes */ +#define XML_PARSER_CASE_INSENSITIVE 0 +#define XML_PARSER_CASE_SENSITIVE 1 + +/* return codes */ +#define XML_PARSER_OK 0 +#define XML_PARSER_ERROR 1 + +/* xml_parser_build_tree_with_options flag bits */ +#define XML_PARSER_RELAXED 1 +#define XML_PARSER_MULTI_TEXT 2 + +/* node name for extra text chunks */ +#define CDATA_MARKER "[CDATA]" + +/* xml property */ +typedef struct xml_property_s { + char *name; + char *value; + struct xml_property_s *next; +} xml_property_t; + +/* xml node */ +/* .data contains any text which precedes any subtree elements; + * subtree elements may also contain only text; if so, name is "[CDATA]". + * e.g. <a>b<c />d</a> + * node1: .name="a" .data="b" .child=node2 .next=NULL + * node2: .name="c" .data=NULL .child=NULL .next=node3 + * node3: .name="[CDATA]" .data="d" .child=NULL .next=NULL + * Adjacent text items are merged. + */ +typedef struct xml_node_s { + char *name; + char *data; + struct xml_property_s *props; + struct xml_node_s *child; + struct xml_node_s *next; +} xml_node_t; + +/* xml parser */ +typedef struct xml_parser_s { + struct lexer *lexer; + int mode; +} xml_parser_t; + +void xml_parser_init(const char * buf, int size, int mode) XINE_DEPRECATED XINE_PROTECTED; +xml_parser_t *xml_parser_init_r(const char * buf, int size, int mode) XINE_PROTECTED; +void xml_parser_finalize_r(xml_parser_t *xml_parser) XINE_PROTECTED; + +int xml_parser_build_tree(xml_node_t **root_node) XINE_DEPRECATED XINE_PROTECTED; +int xml_parser_build_tree_r(xml_parser_t *xml_parser, xml_node_t **root_node) XINE_PROTECTED; + +int xml_parser_build_tree_with_options(xml_node_t **root_node, int flags) XINE_DEPRECATED XINE_PROTECTED; +int xml_parser_build_tree_with_options_r(xml_parser_t *xml_parser, xml_node_t **root_node, int flags) XINE_PROTECTED; + +void xml_parser_free_tree(xml_node_t *root_node) XINE_PROTECTED; + +const char *xml_parser_get_property (const xml_node_t *node, const char *name) XINE_PROTECTED; +int xml_parser_get_property_int (const xml_node_t *node, const char *name, + int def_value) XINE_PROTECTED; +int xml_parser_get_property_bool (const xml_node_t *node, const char *name, + int def_value) XINE_PROTECTED; + +/* for output: + * returns an escaped string (free() it when done) + * input must be in ASCII or UTF-8 + */ + +typedef enum { + XML_ESCAPE_NO_QUOTE, + XML_ESCAPE_SINGLE_QUOTE, + XML_ESCAPE_DOUBLE_QUOTE +} xml_escape_quote_t; +char *xml_escape_string (const char *s, xml_escape_quote_t quote_type) XINE_PROTECTED; + +/* for debugging purposes: dump read-in xml tree in a nicely + * indented fashion + */ + +void xml_parser_dump_tree (const xml_node_t *node) XINE_PROTECTED; + +#endif |