format.h 2.17 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
/* Icecast
 *
 * This program is distributed under the GNU General Public License, version 2.
 * A copy of this license is included with this source.
 *
 * Copyright 2000-2004, Jack Moffitt <jack@xiph.org, 
 *                      Michael Smith <msmith@xiph.org>,
 *                      oddsock <oddsock@xiph.org>,
 *                      Karl Heyes <karl@xiph.org>
 *                      and others (see AUTHORS for details).
 */

Jack Moffitt's avatar
Jack Moffitt committed
13 14 15 16 17 18 19 20
/* format.h
**
** format plugin header
**
*/
#ifndef __FORMAT_H__
#define __FORMAT_H__

21 22
#include "client.h"
#include "refbuf.h"
Karl Heyes's avatar
Karl Heyes committed
23
#include "httpp/httpp.h"
24

Michael Smith's avatar
Michael Smith committed
25
struct source_tag;
26
struct _mount_proxy;
Michael Smith's avatar
Michael Smith committed
27

Jack Moffitt's avatar
Jack Moffitt committed
28 29
typedef enum _format_type_tag
{
30 31 32
    FORMAT_ERROR, /* No format, source not processable */
    FORMAT_TYPE_OGG,
    FORMAT_TYPE_GENERIC
Jack Moffitt's avatar
Jack Moffitt committed
33 34 35 36
} format_type_t;

typedef struct _format_plugin_tag
{
37
    format_type_t type;
Jack Moffitt's avatar
Jack Moffitt committed
38

39 40
    /* we need to know the mount to report statistics */
    char *mount;
Jack Moffitt's avatar
Jack Moffitt committed
41

42
    const char *contenttype;
43
    char *charset;
44 45
    uint64_t read_bytes;
    uint64_t sent_bytes;
46

Karl Heyes's avatar
Karl Heyes committed
47
    refbuf_t *(*get_buffer)(struct source_tag *);
48
    int (*write_buf_to_client)(client_t *client);
Karl Heyes's avatar
Karl Heyes committed
49 50
    void (*write_buf_to_file)(struct source_tag *source, refbuf_t *refbuf);
    int (*create_client_data)(struct source_tag *source, client_t *client);
51
    void (*set_tag)(struct _format_plugin_tag *plugin, const char *tag, const char *value, const char *charset);
52
    void (*free_plugin)(struct _format_plugin_tag *self);
53
    void (*apply_settings)(client_t *client, struct _format_plugin_tag *format, struct _mount_proxy *mount);
Jack Moffitt's avatar
Jack Moffitt committed
54

55 56
    /* for internal state management */
    void *_state;
Jack Moffitt's avatar
Jack Moffitt committed
57 58
} format_plugin_t;

59
format_type_t format_get_type(const char *contenttype);
60
char *format_get_mimetype(format_type_t type);
Karl Heyes's avatar
Karl Heyes committed
61
int format_get_plugin(format_type_t type, struct source_tag *source);
Jack Moffitt's avatar
Jack Moffitt committed
62

63
int format_generic_write_to_client (client_t *client);
Karl Heyes's avatar
Karl Heyes committed
64
int format_advance_queue (struct source_tag *source, client_t *client);
65
int format_check_http_buffer (struct source_tag *source, client_t *client);
Karl Heyes's avatar
Karl Heyes committed
66 67
int format_check_file_buffer (struct source_tag *source, client_t *client);

Michael Smith's avatar
Michael Smith committed
68 69
void format_send_general_headers(format_plugin_t *format, 
        struct source_tag *source, client_t *client);
70

Jack Moffitt's avatar
Jack Moffitt committed
71 72
#endif  /* __FORMAT_H__ */