1 /* 2 * Copyright (C) 2000-2019 the xine project 3 * 4 * This file is part of xine, a free video player. 5 * 6 * xine is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * xine is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 19 */ 20 21 #ifndef HAVE_DEMUX_H 22 #define HAVE_DEMUX_H 23 24 #include <xine/attributes.h> 25 #include <xine/input_plugin.h> 26 #include <xine/buffer.h> 27 #include <xine/xine_internal.h> 28 29 struct plugin_node_s; 30 31 #define DEMUXER_PLUGIN_IFACE_VERSION 27 32 33 #define DEMUX_OK 0 34 #define DEMUX_FINISHED 1 35 36 #define DEMUX_CANNOT_HANDLE 0 37 #define DEMUX_CAN_HANDLE 1 38 39 #define METHOD_BY_CONTENT 1 40 #define METHOD_BY_MRL 2 41 #define METHOD_EXPLICIT 3 42 43 typedef struct demux_class_s demux_class_t ; 44 typedef struct demux_plugin_s demux_plugin_t; 45 46 struct demux_class_s { 47 48 /* 49 * open a new instance of this plugin class 50 */ 51 demux_plugin_t* (*open_plugin) (demux_class_t *this_gen, xine_stream_t *stream, input_plugin_t *input); 52 53 /** 54 * @brief short human readable identifier for this plugin class 55 */ 56 const char *identifier; 57 58 /** 59 * @brief human readable (verbose = 1 line) description for this plugin class 60 * 61 * The description is passed to gettext() to internationalise. 62 */ 63 const char *description; 64 65 /** 66 * @brief Optional non-standard catalog to use with dgettext() for description. 67 */ 68 const char *text_domain; 69 70 /** 71 * @brief MIME types supported for this plugin 72 */ 73 74 const char* mimetypes; 75 76 /** 77 * @brief space separated list of file extensions this demuxer is 78 * likely to handle 79 * 80 * (will be used to filter media files in file selection dialogs) 81 */ 82 const char* extensions; 83 84 /* 85 * close down, free all resources 86 */ 87 void (*dispose) (demux_class_t *this_gen); 88 }; 89 90 #define default_demux_class_dispose (void (*) (demux_class_t *this_gen))free 91 92 /* 93 * any demux plugin must implement these functions 94 */ 95 96 struct demux_plugin_s { 97 98 /* 99 * send headers, followed by BUF_CONTROL_HEADERS_DONE down the 100 * fifos, then return. do not start demux thread (yet) 101 */ 102 103 void (*send_headers) (demux_plugin_t *this_gen); 104 105 /* 106 * ask demux to seek 107 * 108 * for seekable streams, a start position can be specified 109 * 110 * start_pos : position in input source (0..65535) 111 * this is defined as most convenient to demuxer, can be 112 * either time or offset based. 113 * start_time : position measured in miliseconds from stream start 114 * playing : true if this is a new seek within an already playing stream 115 * false if playback of this stream has not started yet 116 * 117 * if both parameters are !=0 start_pos will be used 118 * for non-seekable streams both values will be ignored 119 * 120 * returns the demux status (like get_status, but immediately after 121 * starting the demuxer) 122 */ 123 124 int (*seek) (demux_plugin_t *this_gen, 125 off_t start_pos, int start_time, int playing ); 126 127 /* 128 * send a chunk of data down to decoder fifos 129 * 130 * the meaning of "chunk" is specific to every demux, usually 131 * it involves parsing one unit of data from stream. 132 * 133 * this function will be called from demux loop and should return 134 * the demux current status 135 */ 136 137 int (*send_chunk) (demux_plugin_t *this_gen); 138 139 /* 140 * free resources 141 */ 142 143 void (*dispose) (demux_plugin_t *this_gen) ; 144 145 /* 146 * returns DEMUX_OK or DEMUX_FINISHED 147 */ 148 149 int (*get_status) (demux_plugin_t *this_gen) ; 150 151 /* 152 * gets stream length in miliseconds (might be estimated) 153 * may return 0 for non-seekable streams 154 */ 155 156 int (*get_stream_length) (demux_plugin_t *this_gen); 157 158 /* 159 * return capabilities of demuxed stream 160 */ 161 162 uint32_t (*get_capabilities) (demux_plugin_t *this_gen); 163 164 /* 165 * request optional data from input plugin. 166 */ 167 int (*get_optional_data) (demux_plugin_t *this_gen, void *data, int data_type); 168 169 /* 170 * "backwards" link to plugin class 171 */ 172 173 demux_class_t *demux_class; 174 175 /** 176 * @brief Pointer to the loaded plugin node. 177 * 178 * Used by the plugins loader. It's an opaque type when using the 179 * structure outside of xine's build. 180 */ 181 struct plugin_node_s *node XINE_PRIVATE_FIELD; 182 }; 183 184 #define default_demux_plugin_dispose (void (*) (demux_plugin_t *this_gen))free 185 186 /* 187 * possible capabilites a demux plugin can have: 188 */ 189 #define DEMUX_CAP_NOCAP 0x00000000 190 191 /* 192 * DEMUX_CAP_AUDIOLANG: 193 * DEMUX_CAP_SPULANG: 194 * demux plugin knows something about audio/spu languages, 195 * e.g. knows that audio stream #0 is english, 196 * audio stream #1 is german, ... Same bits as INPUT 197 * capabilities . 198 */ 199 200 #define DEMUX_CAP_AUDIOLANG 0x00000008 201 #define DEMUX_CAP_SPULANG 0x00000010 202 203 /* 204 * DEMUX_CAP_CHAPTERS: 205 * The media streams provided by this plugin have an internal 206 * structure dividing it into segments usable for navigation. 207 * For those plugins, the behaviour of the skip button in UIs 208 * should be changed from "next MRL" to "next chapter" by 209 * sending XINE_EVENT_INPUT_NEXT. 210 * Same bits as INPUT capabilities. 211 */ 212 213 #define DEMUX_CAP_CHAPTERS 0x00000080 214 215 /* 216 * DEMUX_CAP_STOP: 217 * demux plugin needs to do some cleanup work _before_ end buffers 218 * when the stream is stopped (eg flushing a pending discontinuity). 219 * This shall be done by calling 220 * demux_plugin->get_optional_data (demux_plugin, NULL, DEMUX_OPTIONAL_DATA_STOP). 221 */ 222 223 #define DEMUX_CAP_STOP 0x00000100 224 225 /* 226 * DEMUX_CAP_VIDEO_TIME: 227 * demux plugin has video, and it can tell its current video time in milliseconds. 228 * It can do that especially after a seek by normpos and/or to nearest keyframe. 229 * This shall be done by calling 230 * demux_plugin->get_optional_data (demux_plugin, (int32_t *)(&msec), DEMUX_OPTIONAL_DATA_VIDEO_TIME). 231 */ 232 233 #define DEMUX_CAP_VIDEO_TIME 0x00000200 234 235 236 #define DEMUX_OPTIONAL_UNSUPPORTED 0 237 #define DEMUX_OPTIONAL_SUCCESS 1 238 239 #define DEMUX_OPTIONAL_DATA_AUDIOLANG 2 240 #define DEMUX_OPTIONAL_DATA_SPULANG 3 241 #define DEMUX_OPTIONAL_DATA_STOP 4 242 #define DEMUX_OPTIONAL_DATA_VIDEO_TIME 5 243 244 #endif 245