format.h 2.31 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
/* format.h
14 15 16 17
 **
 ** format plugin header
 **
 */
Jack Moffitt's avatar
Jack Moffitt committed
18 19 20
#ifndef __FORMAT_H__
#define __FORMAT_H__

21 22
#include <vorbis/codec.h>

23
#include "icecasttypes.h"
24 25
#include "client.h"
#include "refbuf.h"
26
#include "cfgfile.h"
27
#include "common/httpp/httpp.h"
28

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

typedef struct _format_plugin_tag
{
39
    format_type_t type;
Jack Moffitt's avatar
Jack Moffitt committed
40

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

44 45 46 47
    const char  *contenttype;
    char        *charset;
    uint64_t    read_bytes;
    uint64_t    sent_bytes;
48

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

57 58 59
    /* meta data */
    vorbis_comment vc;

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

64
format_type_t format_get_type(const char *contenttype);
65
char *format_get_mimetype(format_type_t type);
66
int format_get_plugin(format_type_t type, source_t *source);
Jack Moffitt's avatar
Jack Moffitt committed
67

68
int format_generic_write_to_client (client_t *client);
69 70 71
int format_advance_queue (source_t *source, client_t *client);
int format_check_http_buffer (source_t *source, client_t *client);
int format_check_file_buffer (source_t *source, client_t *client);
72

73

74
void format_send_general_headers(format_plugin_t *format, 
75
        source_t *source, client_t *client);
76

77 78
void format_set_vorbiscomment(format_plugin_t *plugin, const char *tag, const char *value);

Jack Moffitt's avatar
Jack Moffitt committed
79 80
#endif  /* __FORMAT_H__ */