summaryrefslogtreecommitdiffstats
path: root/tinyMEDIA/include/tinymedia/tmedia_resampler.h
blob: 5093bc68f9a0e84d935c0969abf9f59309c111dc (plain)
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
31
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* Copyright (C) 2010-2011 Mamadou Diop.
*
* Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
*	
* This file is part of Open Source Doubango Framework.
*
* DOUBANGO is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*	
* DOUBANGO is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*	
* You should have received a copy of the GNU General Public License
* along with DOUBANGO.
*
*/

/**@file tmedia_resampler.h
 * @brief Audio Resampler Plugin
 *
 * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
 */
#ifndef TINYMEDIA_RESAMPLER_H
#define TINYMEDIA_RESAMPLER_H

#include "tinymedia_config.h"

#include "tsk_object.h"

#ifndef TMEDIA_RESAMPLER_QUALITY
#	define TMEDIA_RESAMPLER_QUALITY 5
#endif

TMEDIA_BEGIN_DECLS

/** cast any pointer to @ref tmedia_resampler_t* object */
#define TMEDIA_RESAMPLER(self)		((tmedia_resampler_t*)(self))

/** Base object for all resamplers */
typedef struct tmedia_resampler_s
{
	TSK_DECLARE_OBJECT;

	tsk_bool_t opened;

	const struct tmedia_resampler_plugin_def_s* plugin;
}
tmedia_resampler_t;

#define TMEDIA_DECLARE_RESAMPLER tmedia_resampler_t __resampler__

/** Virtual table used to define a consumer plugin */
typedef struct tmedia_resampler_plugin_def_s
{
	//! object definition used to create an instance of the resamplerr
	const tsk_object_def_t* objdef;
	
	//! full description (usefull for debugging)
	const char* desc;

	// ! quality is from 0-10
	int (* open) (tmedia_resampler_t* self, uint32_t in_freq, uint32_t out_freq, uint32_t frame_duration, uint32_t in_channels, uint32_t out_channels, uint32_t quality, uint32_t bits_per_sample);
	tsk_size_t (* process) (tmedia_resampler_t*, const void* in_data, tsk_size_t in_size_in_sample, void* out_data, tsk_size_t out_size_in_sample);
	int (* close) (tmedia_resampler_t* );
}
tmedia_resampler_plugin_def_t;

TINYMEDIA_API int tmedia_resampler_init(tmedia_resampler_t* self);
TINYMEDIA_API int tmedia_resampler_open(tmedia_resampler_t* self, uint32_t in_freq, uint32_t out_freq, uint32_t frame_duration, uint32_t in_channels, uint32_t out_channels, uint32_t quality, uint32_t bits_per_sample);
TINYMEDIA_API tsk_size_t tmedia_resampler_process(tmedia_resampler_t* self, const void* in_data, tsk_size_t in_size_in_sample, void* out_data, tsk_size_t out_size_in_sample);
TINYMEDIA_API int tmedia_resampler_close(tmedia_resampler_t* self);
TINYMEDIA_API int tmedia_resampler_deinit(tmedia_resampler_t* self);

TINYMEDIA_API int tmedia_resampler_plugin_register(const tmedia_resampler_plugin_def_t* plugin);
TINYMEDIA_API int tmedia_resampler_plugin_unregister(const tmedia_resampler_plugin_def_t* plugin);
TINYMEDIA_API tmedia_resampler_t* tmedia_resampler_create();

TMEDIA_END_DECLS


#endif /* TINYMEDIA_RESAMPLER_H */ 
OpenPOWER on IntegriCloud