MPD
Main Page
Data Structures
Files
File List
Globals
src
encoder_plugin.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2003-2010 The Music Player Daemon Project
3
* http://www.musicpd.org
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License along
16
* with this program; if not, write to the Free Software Foundation, Inc.,
17
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18
*/
19
20
#ifndef MPD_ENCODER_PLUGIN_H
21
#define MPD_ENCODER_PLUGIN_H
22
23
#include <glib.h>
24
25
#include <stdbool.h>
26
#include <stddef.h>
27
28
struct
encoder_plugin
;
29
struct
audio_format
;
30
struct
config_param
;
31
struct
tag
;
32
33
struct
encoder
{
34
const
struct
encoder_plugin
*
plugin
;
35
};
36
37
struct
encoder_plugin
{
38
const
char
*
name
;
39
40
struct
encoder
*(*init)(
const
struct
config_param
*param,
41
GError **error);
42
43
void (*
finish
)(
struct
encoder
*
encoder
);
44
45
bool (*
open
)(
struct
encoder
*
encoder
,
46
struct
audio_format
*
audio_format
,
47
GError **error);
48
49
void (*
close
)(
struct
encoder
*
encoder
);
50
51
bool (*
flush
)(
struct
encoder
*
encoder
, GError **error);
52
53
bool (*
pre_tag
)(
struct
encoder
*
encoder
, GError **error);
54
55
bool (*
tag
)(
struct
encoder
*
encoder
,
const
struct
tag
*
tag
,
56
GError **error);
57
58
bool (*
write
)(
struct
encoder
*
encoder
,
59
const
void
*data,
size_t
length,
60
GError **error);
61
62
size_t (*
read
)(
struct
encoder
*
encoder
,
void
*dest,
size_t
length);
63
64
const
char
*(*get_mime_type)(
struct
encoder
*
encoder
);
65
};
66
71
static
inline
void
72
encoder_struct_init
(
struct
encoder
*
encoder
,
73
const
struct
encoder_plugin
*
plugin
)
74
{
75
encoder->
plugin
=
plugin
;
76
}
77
86
static
inline
struct
encoder
*
87
encoder_init
(
const
struct
encoder_plugin
*
plugin
,
88
const
struct
config_param
*param, GError **error)
89
{
90
return
plugin->
init
(param, error);
91
}
92
98
static
inline
void
99
encoder_finish
(
struct
encoder
*
encoder
)
100
{
101
encoder->
plugin
->
finish
(encoder);
102
}
103
115
static
inline
bool
116
encoder_open
(
struct
encoder
*
encoder
,
struct
audio_format
*
audio_format
,
117
GError **error)
118
{
119
return
encoder->
plugin
->
open
(encoder, audio_format, error);
120
}
121
128
static
inline
void
129
encoder_close
(
struct
encoder
*
encoder
)
130
{
131
if
(encoder->
plugin
->
close
!= NULL)
132
encoder->
plugin
->
close
(encoder);
133
}
134
143
static
inline
bool
144
encoder_flush
(
struct
encoder
*
encoder
, GError **error)
145
{
146
/* this method is optional */
147
return
encoder->
plugin
->
flush
!= NULL
148
? encoder->
plugin
->
flush
(encoder, error)
149
:
true
;
150
}
151
162
static
inline
bool
163
encoder_pre_tag
(
struct
encoder
*
encoder
, GError **error)
164
{
165
/* this method is optional */
166
return
encoder->
plugin
->
pre_tag
!= NULL
167
? encoder->
plugin
->
pre_tag
(encoder, error)
168
:
true
;
169
}
170
182
static
inline
bool
183
encoder_tag
(
struct
encoder
*
encoder
,
const
struct
tag
*
tag
, GError **error)
184
{
185
/* this method is optional */
186
return
encoder->
plugin
->
tag
!= NULL
187
? encoder->
plugin
->
tag
(encoder, tag, error)
188
:
true
;
189
}
190
200
static
inline
bool
201
encoder_write
(
struct
encoder
*
encoder
,
const
void
*data,
size_t
length,
202
GError **error)
203
{
204
return
encoder->
plugin
->
write
(encoder, data, length, error);
205
}
206
215
static
inline
size_t
216
encoder_read
(
struct
encoder
*
encoder
,
void
*dest,
size_t
length)
217
{
218
return
encoder->
plugin
->
read
(encoder, dest, length);
219
}
220
227
static
inline
const
char
*
228
encoder_get_mime_type
(
struct
encoder
*
encoder
)
229
{
230
/* this method is optional */
231
return
encoder->
plugin
->
get_mime_type
!= NULL
232
? encoder->
plugin
->
get_mime_type
(encoder)
233
: NULL;
234
}
235
236
#endif
Generated on Sun Aug 12 2012 21:58:03 for MPD by
1.8.2