format.h 2.38 KB
Newer Older
1 2 3 4 5 6 7 8 9 10
/* 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).
11
 * Copyright 2014-2018, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
12 13
 */

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

22 23
#include <vorbis/codec.h>

24
#include "icecasttypes.h"
25 26
#include "client.h"
#include "refbuf.h"
27
#include "cfgfile.h"
Marvin Scholz's avatar
Marvin Scholz committed
28
#include "common/httpp/httpp.h"
29

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

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

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

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

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

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

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

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

69
int format_generic_write_to_client (client_t *client);
70 71 72
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);
Karl Heyes's avatar
Karl Heyes committed
73

74

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

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

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