1 /* Icecast
2  *
3  * This program is distributed under the GNU General Public License, version 2.
4  * A copy of this license is included with this source.
5  *
6  * Copyright 2000-2004, Jack Moffitt <jack@xiph.org,
7  *                      Michael Smith <msmith@xiph.org>,
8  *                      oddsock <oddsock@xiph.org>,
9  *                      Karl Heyes <karl@xiph.org>
10  *                      and others (see AUTHORS for details).
11  */
12 
13 /* format.h
14 **
15 ** format plugin header
16 **
17 */
18 #ifndef __FORMAT_H__
19 #define __FORMAT_H__
20 
21 #include "client.h"
22 #include "refbuf.h"
23 #include "httpp/httpp.h"
24 
25 struct source_tag;
26 struct _mount_proxy;
27 
28 typedef enum _format_type_tag
29 {
30     FORMAT_ERROR, /* No format, source not processable */
31     FORMAT_TYPE_OGG,
32     FORMAT_TYPE_EBML,
33     FORMAT_TYPE_GENERIC
34 } format_type_t;
35 
36 typedef struct _format_plugin_tag
37 {
38     format_type_t type;
39 
40     /* we need to know the mount to report statistics */
41     char *mount;
42 
43     const char *contenttype;
44     char *charset;
45     uint64_t read_bytes;
46     uint64_t sent_bytes;
47 
48     refbuf_t *(*get_buffer)(struct source_tag *);
49     int (*write_buf_to_client)(client_t *client);
50     void (*write_buf_to_file)(struct source_tag *source, refbuf_t *refbuf);
51     int (*create_client_data)(struct source_tag *source, client_t *client);
52     void (*set_tag)(struct _format_plugin_tag *plugin, const char *tag, const char *value, const char *charset);
53     void (*free_plugin)(struct _format_plugin_tag *self);
54     void (*apply_settings)(client_t *client, struct _format_plugin_tag *format, struct _mount_proxy *mount);
55 
56     /* for internal state management */
57     void *_state;
58 } format_plugin_t;
59 
60 format_type_t format_get_type(const char *contenttype);
61 char *format_get_mimetype(format_type_t type);
62 int format_get_plugin(format_type_t type, struct source_tag *source);
63 
64 int format_generic_write_to_client (client_t *client);
65 int format_advance_queue (struct source_tag *source, client_t *client);
66 int format_check_http_buffer (struct source_tag *source, client_t *client);
67 int format_check_file_buffer (struct source_tag *source, client_t *client);
68 
69 void format_send_general_headers(format_plugin_t *format,
70         struct source_tag *source, client_t *client);
71 
72 #endif  /* __FORMAT_H__ */
73 
74