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
26
struct source_tag;

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

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

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

41
42
    char *format_description;

43
44
45
46
    /* set this is the data format has a header that
    ** we must send before regular data
    */
    int has_predata;
Jack Moffitt's avatar
Jack Moffitt committed
47

Michael Smith's avatar
Michael Smith committed
48
49
    int (*get_buffer)(struct _format_plugin_tag *self, char *data, unsigned long
            len, refbuf_t **buffer);
50
    refbuf_queue_t *(*get_predata)(struct _format_plugin_tag *self);
51
52
    int (*write_buf_to_client)(struct _format_plugin_tag *format, 
            client_t *client, unsigned char *buf, int len);
Michael Smith's avatar
Michael Smith committed
53
54
55
56
    void *(*create_client_data)(struct _format_plugin_tag *format,
            struct source_tag *source, client_t *client);
    void (*client_send_headers)(struct _format_plugin_tag *format, 
            struct source_tag *source, client_t *client);
57

58
    void (*free_plugin)(struct _format_plugin_tag *self);
Jack Moffitt's avatar
Jack Moffitt committed
59

60
61
    /* for internal state management */
    void *_state;
Jack Moffitt's avatar
Jack Moffitt committed
62
63
} format_plugin_t;

Michael Smith's avatar
Michael Smith committed
64
format_type_t format_get_type(char *contenttype);
65
char *format_get_mimetype(format_type_t type);
66
67
format_plugin_t *format_get_plugin(format_type_t type, char *mount, 
        http_parser_t *parser);
Jack Moffitt's avatar
Jack Moffitt committed
68

69
70
int format_generic_write_buf_to_client(format_plugin_t *format, 
        client_t *client, unsigned char *buf, int len);
Michael Smith's avatar
Michael Smith committed
71
72
void format_send_general_headers(format_plugin_t *format, 
        struct source_tag *source, client_t *client);
73

Jack Moffitt's avatar
Jack Moffitt committed
74
75
76
77
78
79
80
81
#endif  /* __FORMAT_H__ */