format_mp3.c 1.58 KB
Newer Older
Michael Smith's avatar
Michael Smith committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
/* format_mp3.c
**
** format plugin for mp3 (no metadata)
**
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "refbuf.h"

#include "stats.h"
#include "format.h"

16
17
18
19
20
static void format_mp3_free_plugin(format_plugin_t *self);
static int format_mp3_get_buffer(format_plugin_t *self, char *data, 
        unsigned long len, refbuf_t **buffer);
static refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self);
static void *format_mp3_create_client_data(format_plugin_t *self);
Michael Smith's avatar
Michael Smith committed
21
22
23
24
25
26
27
28
29
30
31

format_plugin_t *format_mp3_get_plugin(void)
{
	format_plugin_t *plugin;

	plugin = (format_plugin_t *)malloc(sizeof(format_plugin_t));

	plugin->type = FORMAT_TYPE_MP3;
	plugin->has_predata = 0;
	plugin->get_buffer = format_mp3_get_buffer;
	plugin->get_predata = format_mp3_get_predata;
32
33
    plugin->write_buf_to_client = format_generic_write_buf_to_client;
    plugin->create_client_data = format_mp3_create_client_data;
Michael Smith's avatar
Michael Smith committed
34
	plugin->free_plugin = format_mp3_free_plugin;
35
    plugin->format_description = "MP3 audio";
Michael Smith's avatar
Michael Smith committed
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67

	plugin->_state = NULL;

	return plugin;
}

void format_mp3_free_plugin(format_plugin_t *self)
{
	/* free the plugin instance */
	free(self);
}

int format_mp3_get_buffer(format_plugin_t *self, char *data, unsigned long len, refbuf_t **buffer)
{
	refbuf_t *refbuf;
    if(!data) {
        *buffer = NULL;
        return 0;
    }
    refbuf = refbuf_new(len);

    memcpy(refbuf->data, data, len);

    *buffer = refbuf;
	return 0;
}

refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self)
{
    return NULL;
}

68
69
70
static void *format_mp3_create_client_data(format_plugin_t *self) {
    return NULL;
}
Michael Smith's avatar
Michael Smith committed
71
72