format_mp3.c 1.27 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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/* 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"

void format_mp3_free_plugin(format_plugin_t *self);
int format_mp3_get_buffer(format_plugin_t *self, char *data, unsigned long len, refbuf_t **buffer);
refbuf_queue_t *format_mp3_get_predata(format_plugin_t *self);

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;
	plugin->free_plugin = format_mp3_free_plugin;
31
    plugin->format_description = "MP3 audio";
Michael Smith's avatar
Michael Smith committed
32
33
34
35
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

	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;
}