format.h 1.7 KB
Newer Older
Jack Moffitt's avatar
Jack Moffitt committed
1
2
3
4
5
6
7
8
/* format.h
**
** format plugin header
**
*/
#ifndef __FORMAT_H__
#define __FORMAT_H__

9
10
#include "client.h"
#include "refbuf.h"
11
#include "httpp.h"
12

Michael Smith's avatar
Michael Smith committed
13
14
struct source_tag;

Jack Moffitt's avatar
Jack Moffitt committed
15
16
17
typedef enum _format_type_tag
{
	FORMAT_TYPE_VORBIS,
18
19
	FORMAT_TYPE_MP3,
    FORMAT_ERROR /* No format, source not processable */
Jack Moffitt's avatar
Jack Moffitt committed
20
21
22
23
24
25
} format_type_t;

typedef struct _format_plugin_tag
{
	format_type_t type;

Jack Moffitt's avatar
Jack Moffitt committed
26
27
28
	/* we need to know the mount to report statistics */
	char *mount;

29
30
    char *format_description;

Jack Moffitt's avatar
Jack Moffitt committed
31
32
33
34
35
	/* set this is the data format has a header that
	** we must send before regular data
	*/
	int has_predata;

Michael Smith's avatar
Michael Smith committed
36
37
    int (*get_buffer)(struct _format_plugin_tag *self, char *data, unsigned long
            len, refbuf_t **buffer);
Jack Moffitt's avatar
Jack Moffitt committed
38
	refbuf_queue_t *(*get_predata)(struct _format_plugin_tag *self);
39
40
    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
41
42
43
44
    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);
45

46
	void (*free_plugin)(struct _format_plugin_tag *self);
Jack Moffitt's avatar
Jack Moffitt committed
47
48
49
50
51

	/* for internal state management */
	void *_state;
} format_plugin_t;

Michael Smith's avatar
Michael Smith committed
52
format_type_t format_get_type(char *contenttype);
53
char *format_get_mimetype(format_type_t type);
54
55
format_plugin_t *format_get_plugin(format_type_t type, char *mount, 
        http_parser_t *parser);
Jack Moffitt's avatar
Jack Moffitt committed
56

57
58
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
59
60
void format_send_general_headers(format_plugin_t *format, 
        struct source_tag *source, client_t *client);
61

Jack Moffitt's avatar
Jack Moffitt committed
62
63
64
65
66
67
68
69
#endif  /* __FORMAT_H__ */