| 1 |
/* |
| 2 |
* Copyright 2008-2011 Various Authors |
| 3 |
* Copyright 2004-2005 Timo Hirvonen |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it and/or |
| 6 |
* modify it under the terms of the GNU General Public License as |
| 7 |
* published by the Free Software Foundation; either version 2 of the |
| 8 |
* License, or (at your option) any later version. |
| 9 |
* |
| 10 |
* This program is distributed in the hope that it will be useful, but |
| 11 |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 |
* General Public License for more details. |
| 14 |
* |
| 15 |
* You should have received a copy of the GNU General Public License |
| 16 |
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef _IP_H |
| 20 |
#define _IP_H |
| 21 |
|
| 22 |
#include "keyval.h" |
| 23 |
#include "sf.h" |
| 24 |
#include "channelmap.h" |
| 25 |
|
| 26 |
#ifndef __GNUC__ |
| 27 |
#include <fcntl.h> |
| 28 |
#include <unistd.h> |
| 29 |
#endif |
| 30 |
|
| 31 |
enum { |
| 32 |
/* no error */ |
| 33 |
IP_ERROR_SUCCESS, |
| 34 |
/* system error (error code in errno) */ |
| 35 |
IP_ERROR_ERRNO, |
| 36 |
/* file type not recognized */ |
| 37 |
IP_ERROR_UNRECOGNIZED_FILE_TYPE, |
| 38 |
/* file type recognized, but not supported */ |
| 39 |
IP_ERROR_UNSUPPORTED_FILE_TYPE, |
| 40 |
/* function not supported (usually seek) */ |
| 41 |
IP_ERROR_FUNCTION_NOT_SUPPORTED, |
| 42 |
/* input plugin detected corrupted file */ |
| 43 |
IP_ERROR_FILE_FORMAT, |
| 44 |
/* malformed uri */ |
| 45 |
IP_ERROR_INVALID_URI, |
| 46 |
/* sample format not supported */ |
| 47 |
IP_ERROR_SAMPLE_FORMAT, |
| 48 |
/* wrong disc inserted */ |
| 49 |
IP_ERROR_WRONG_DISC, |
| 50 |
/* could not read disc */ |
| 51 |
IP_ERROR_NO_DISC, |
| 52 |
/* error parsing response line / headers */ |
| 53 |
IP_ERROR_HTTP_RESPONSE, |
| 54 |
/* usually 404 */ |
| 55 |
IP_ERROR_HTTP_STATUS, |
| 56 |
/* too many redirections */ |
| 57 |
IP_ERROR_HTTP_REDIRECT_LIMIT, |
| 58 |
/* plugin does not have this option */ |
| 59 |
IP_ERROR_NOT_OPTION, |
| 60 |
/* */ |
| 61 |
IP_ERROR_INTERNAL |
| 62 |
}; |
| 63 |
|
| 64 |
struct input_plugin_data { |
| 65 |
/* filled by ip-layer */ |
| 66 |
char *filename; |
| 67 |
int fd; |
| 68 |
|
| 69 |
unsigned int remote : 1; |
| 70 |
unsigned int metadata_changed : 1; |
| 71 |
|
| 72 |
/* shoutcast */ |
| 73 |
int counter; |
| 74 |
int metaint; |
| 75 |
char *metadata; |
| 76 |
char *icy_name; |
| 77 |
char *icy_genre; |
| 78 |
char *icy_url; |
| 79 |
|
| 80 |
/* filled by plugin */ |
| 81 |
sample_format_t sf; |
| 82 |
channel_position_t channel_map[CHANNELS_MAX]; |
| 83 |
void *private; |
| 84 |
}; |
| 85 |
|
| 86 |
struct input_plugin_ops { |
| 87 |
int (*open)(struct input_plugin_data *ip_data); |
| 88 |
int (*close)(struct input_plugin_data *ip_data); |
| 89 |
int (*read)(struct input_plugin_data *ip_data, char *buffer, int count); |
| 90 |
int (*seek)(struct input_plugin_data *ip_data, double offset); |
| 91 |
int (*read_comments)(struct input_plugin_data *ip_data, |
| 92 |
struct keyval **comments); |
| 93 |
int (*duration)(struct input_plugin_data *ip_data); |
| 94 |
long (*bitrate)(struct input_plugin_data *ip_data); |
| 95 |
long (*bitrate_current)(struct input_plugin_data *ip_data); |
| 96 |
char *(*codec)(struct input_plugin_data *ip_data); |
| 97 |
char *(*codec_profile)(struct input_plugin_data *ip_data); |
| 98 |
int (*set_option)(int key, const char *val); |
| 99 |
int (*get_option)(int key, char **val); |
| 100 |
}; |
| 101 |
|
| 102 |
/* symbols exported by plugin */ |
| 103 |
extern const struct input_plugin_ops ip_ops; |
| 104 |
extern const int ip_priority; |
| 105 |
extern const char * const ip_extensions[]; |
| 106 |
extern const char * const ip_mime_types[]; |
| 107 |
extern const char * const ip_options[]; |
| 108 |
|
| 109 |
#endif |