1 /* 2 * Copyright (C) 2002-2003 Stefan Holst 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA. 17 * 18 * odk abstracts from xine and other software / hardware interfaces 19 */ 20 21 /* 22 * the features of odk are: 23 * 24 * - framesize independent (virtual) grid (currently 800x600) 25 * - color palette management and generation of text palettes 26 * - text alignments 27 */ 28 29 #ifndef HAVE_ODK_H 30 #define HAVE_ODK_H 31 32 #include <xine.h> 33 #include <pthread.h> 34 #include "oxine_event.h" 35 36 /* 37 * alignments for text 38 */ 39 40 #define ODK_ALIGN_LEFT 0x001 41 #define ODK_ALIGN_CENTER 0x002 42 #define ODK_ALIGN_RIGHT 0x004 43 #define ODK_ALIGN_TOP 0x008 44 #define ODK_ALIGN_VCENTER 0x010 45 #define ODK_ALIGN_BOTTOM 0x020 46 47 #define PIXMAP_SIMPLE_ARROW_UP 1 48 #define PIXMAP_SIMPLE_ARROW_DOWN 2 49 50 /* 51 * stream speeds 52 */ 53 54 #define ODK_SPEED_PAUSE 0 55 #define ODK_SPEED_SLOW_4 1 56 #define ODK_SPEED_SLOW_2 2 57 #define ODK_SPEED_NORMAL 4 58 #define ODK_SPEED_FAST_2 8 59 #define ODK_SPEED_FAST_4 16 60 61 /* 62 * opaque odk data type 63 */ 64 65 typedef struct odk_s odk_t; 66 67 /* 68 * initializes xine streams, create a drawable and returns a new odk object. 69 * the given xine struct must have been initialized. 70 */ 71 72 odk_t *odk_init(void); 73 74 /* 75 * draw primitives 76 */ 77 78 void odk_draw_point(odk_t *odk, int x, int y, int color); 79 void odk_draw_line(odk_t *odk, int x1, int y1, int x2, int y2, int color); 80 void odk_draw_rect(odk_t *odk, int x1, int y1, int x2, int y2, int filled, int color); 81 void odk_draw_text(odk_t *odk, int x, int y, const char *text, int alignment, int color); 82 83 /* 84 * show and hide an osd 85 */ 86 87 void odk_show(odk_t *odk); 88 void odk_hide(odk_t *odk); 89 90 /* 91 * clears osd 92 */ 93 94 void odk_clear(odk_t *odk); 95 96 /* 97 * simple pixmaps 98 */ 99 100 uint8_t *odk_get_pixmap(int type); 101 void odk_draw_bitmap(odk_t *odk, uint8_t *bitmap, int x1, int y1, int width, int height, 102 uint8_t *palette_map); 103 104 105 /* 106 * closes streams, osd and frees resources and odk object 107 */ 108 109 void odk_free(odk_t *odk); 110 111 /* 112 * returns sizes of text if the text would have been drawn with current font 113 */ 114 115 void odk_get_text_size(odk_t *odk, const char *text, int *width, int *height); 116 117 /* 118 * change current font 119 */ 120 121 void odk_set_font(odk_t *odk, const char *font, int size); 122 123 /* 124 * allocates 10 colors from palette and returns the index to the first 125 * color 126 */ 127 128 int odk_alloc_text_palette(odk_t *odk, uint32_t fg_color, uint8_t fg_trans, 129 uint32_t bg_color, uint8_t bg_trans, 130 uint32_t bo_color, uint8_t bo_trans); 131 132 /* 133 * returns index to given color. 134 */ 135 136 int odk_get_color(odk_t *odk, uint32_t color, uint8_t trans); 137 138 /* 139 * use these functions to register your callbacks for different events 140 */ 141 142 void odk_set_event_handler(odk_t *odk, int (*cb)(void *data, oxine_event_t *ev), void *data); 143 144 int odk_send_event(odk_t *odk, oxine_event_t *event); 145 146 /* 147 * stops a running stream (if there is one), 148 * opens a new stream, returns 0 on success. 149 */ 150 151 int odk_open_and_play(odk_t *odk, const char *mrl); 152 void odk_enqueue(odk_t *odk, const char *mrl); 153 154 /* 155 * play, stop, pause, seek a stream 156 */ 157 158 void odk_play(odk_t *odk); 159 void odk_stop(odk_t *odk); 160 void odk_set_speed(odk_t *odk, uint32_t speed); 161 uint32_t odk_get_speed(odk_t *odk); 162 void odk_seek(odk_t *odk, int how); 163 void odk_eject(odk_t *odk); 164 165 /* 166 * Stream info 167 */ 168 169 char *odk_get_meta_info(odk_t *odk, int info); 170 int odk_get_seek(odk_t *odk); /* 1..100 */ 171 int odk_get_pos_length(odk_t *odk, int *pos, int *time, int *length); 172 int odk_get_pos_length_high(odk_t *odk, int *pos, int *time, int *length); 173 const char *odk_get_mrl(odk_t *odk); 174 175 /* 176 * error handling 177 */ 178 179 int odk_get_error(odk_t *odk); 180 181 void odk_user_color(odk_t *odk, const char *name, uint32_t *color, uint8_t *trans); 182 183 #endif 184