~ubuntu-branches/ubuntu/trusty/sflphone/trusty

« back to all changes in this revision

Viewing changes to daemon/libs/pjproject-2.0.1/pjmedia/include/pjmedia/converter.h

  • Committer: Package Import Robot
  • Author(s): Mark Purcell
  • Date: 2014-01-28 18:23:36 UTC
  • mfrom: (4.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20140128182336-jrsv0k9u6cawc068
Tags: 1.3.0-1
* New upstream release 
  - Fixes "New Upstream Release" (Closes: #735846)
  - Fixes "Ringtone does not stop" (Closes: #727164)
  - Fixes "[sflphone-kde] crash on startup" (Closes: #718178)
  - Fixes "sflphone GUI crashes when call is hung up" (Closes: #736583)
* Build-Depends: ensure GnuTLS 2.6
  - libucommon-dev (>= 6.0.7-1.1), libccrtp-dev (>= 2.0.6-3)
  - Fixes "FTBFS Build-Depends libgnutls{26,28}-dev" (Closes: #722040)
* Fix "boost 1.49 is going away" unversioned Build-Depends: (Closes: #736746)
* Add Build-Depends: libsndfile-dev, nepomuk-core-dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: converter.h 3664 2011-07-19 03:42:28Z nanang $ */
2
 
/*
3
 
 * Copyright (C) 2010-2011 Teluu Inc. (http://www.teluu.com)
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
16
 
 * along with this program; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
 
 */
19
 
#ifndef __PJMEDIA_CONVERTER_H__
20
 
#define __PJMEDIA_CONVERTER_H__
21
 
 
22
 
 
23
 
/**
24
 
 * @file pjmedia/converter.h Format conversion utilities
25
 
 * @brief Format conversion utilities
26
 
 */
27
 
 
28
 
#include <pjmedia/frame.h>
29
 
#include <pjmedia/format.h>
30
 
#include <pj/list.h>
31
 
#include <pj/pool.h>
32
 
 
33
 
 
34
 
/**
35
 
 * @defgroup PJMEDIA_CONVERTER Format converter
36
 
 * @ingroup PJMEDIA_FRAME_OP
37
 
 * @brief Audio and video converter utilities
38
 
 * @{
39
 
 */
40
 
 
41
 
PJ_BEGIN_DECL
42
 
 
43
 
/**
44
 
 * This describes conversion parameter. It specifies the source and
45
 
 * destination formats of the conversion.
46
 
 */
47
 
typedef struct pjmedia_conversion_param
48
 
{
49
 
    pjmedia_format      src;    /**< Source format.             */
50
 
    pjmedia_format      dst;    /**< Destination format.        */
51
 
} pjmedia_conversion_param;
52
 
 
53
 
 
54
 
/** Forward declaration of factory operation structure */
55
 
typedef struct pjmedia_converter_factory_op pjmedia_converter_factory_op;
56
 
 
57
 
/**
58
 
 * Converter priority guides. Converter priority determines which converter
59
 
 * instance to be used if more than one converters are able to perform the
60
 
 * requested conversion. Converter implementor can use this value to order
61
 
 * the preference based on attributes such as quality or performance. Higher
62
 
 * number indicates higher priority.
63
 
 */
64
 
typedef enum pjmedia_converter_priority_guide
65
 
{
66
 
    /** Lowest priority. */
67
 
    PJMEDIA_CONVERTER_PRIORITY_LOWEST           = 0,
68
 
 
69
 
    /** Normal priority. */
70
 
    PJMEDIA_CONVERTER_PRIORITY_NORMAL           = 15000,
71
 
 
72
 
    /** Highest priority. */
73
 
    PJMEDIA_CONVERTER_PRIORITY_HIGHEST          = 32000
74
 
} pjmedia_converter_priority_guide;
75
 
 
76
 
/**
77
 
 * Converter factory. The converter factory registers a callback function
78
 
 * to create converters.
79
 
 */
80
 
typedef struct pjmedia_converter_factory
81
 
{
82
 
    /**
83
 
     * Standard list members.
84
 
     */
85
 
    PJ_DECL_LIST_MEMBER(struct pjmedia_converter_factory);
86
 
 
87
 
    /**
88
 
     * Factory name.
89
 
     */
90
 
    const char                   *name;
91
 
 
92
 
    /**
93
 
     * Converter priority determines which converter instance to be used if
94
 
     * more than one converters are able to perform the requested conversion.
95
 
     * Converter implementor can use this value to order the preference based
96
 
     * on attributes such as quality or performance. Higher number indicates
97
 
     * higher priority. The pjmedia_converter_priority_guide enumeration shall
98
 
     * be used as the base value to set the priority.
99
 
     */
100
 
    int priority;
101
 
 
102
 
    /**
103
 
     * Pointer to factory operation.
104
 
     */
105
 
    pjmedia_converter_factory_op *op;
106
 
 
107
 
} pjmedia_converter_factory;
108
 
 
109
 
/** Forward declaration for converter operation. */
110
 
typedef struct pjmedia_converter_op pjmedia_converter_op;
111
 
 
112
 
/**
113
 
 * This structure describes a converter instance.
114
 
 */
115
 
typedef struct pjmedia_converter
116
 
{
117
 
    /**
118
 
     * Pointer to converter operation.
119
 
     */
120
 
    pjmedia_converter_op *op;
121
 
 
122
 
} pjmedia_converter;
123
 
 
124
 
 
125
 
/**
126
 
 * Converter factory operation.
127
 
 */
128
 
struct pjmedia_converter_factory_op
129
 
{
130
 
    /**
131
 
     * This function creates a converter with the specified conversion format,
132
 
     * if such format is supported.
133
 
     *
134
 
     * @param cf        The converter factory.
135
 
     * @param pool      Pool to allocate memory from.
136
 
     * @param prm       Conversion parameter.
137
 
     * @param p_cv      Pointer to hold the created converter instance.
138
 
     *
139
 
     * @return          PJ_SUCCESS if converter has been created successfully.
140
 
     */
141
 
    pj_status_t (*create_converter)(pjmedia_converter_factory *cf,
142
 
                                    pj_pool_t *pool,
143
 
                                    const pjmedia_conversion_param *prm,
144
 
                                    pjmedia_converter **p_cv);
145
 
 
146
 
    /**
147
 
     * Destroy the factory.
148
 
     *
149
 
     * @param cf        The converter factory.
150
 
     */
151
 
    void (*destroy_factory)(pjmedia_converter_factory *cf);
152
 
};
153
 
 
154
 
/**
155
 
 * Converter operation.
156
 
 */
157
 
struct pjmedia_converter_op
158
 
{
159
 
    /**
160
 
     * Convert the buffer in the source frame and save the result in the
161
 
     * buffer of the destination frame, according to conversion format that
162
 
     * was specified when the converter was created.
163
 
     *
164
 
     * Note that application should use #pjmedia_converter_convert() instead
165
 
     * of calling this function directly.
166
 
     *
167
 
     * @param cv        The converter instance.
168
 
     * @param src_frame The source frame.
169
 
     * @param dst_frame The destination frame.
170
 
     *
171
 
     * @return          PJ_SUCCESS if conversion has been performed
172
 
     *                  successfully.
173
 
     */
174
 
    pj_status_t (*convert)(pjmedia_converter *cv,
175
 
                           pjmedia_frame *src_frame,
176
 
                           pjmedia_frame *dst_frame);
177
 
 
178
 
    /**
179
 
     * Destroy the converter instance.
180
 
     *
181
 
     * Note that application should use #pjmedia_converter_destroy() instead
182
 
     * of calling this function directly.
183
 
     *
184
 
     * @param cv        The converter.
185
 
     */
186
 
    void (*destroy)(pjmedia_converter *cv);
187
 
 
188
 
};
189
 
 
190
 
 
191
 
/**
192
 
 * Opaque data type for conversion manager. Typically, the conversion manager
193
 
 * is a singleton instance, although application may instantiate more than one
194
 
 * instances of this if required.
195
 
 */
196
 
typedef struct pjmedia_converter_mgr pjmedia_converter_mgr;
197
 
 
198
 
 
199
 
/**
200
 
 * Create a new conversion manager instance. This will also set the pointer
201
 
 * to the singleton instance if the value is still NULL.
202
 
 *
203
 
 * @param pool          Pool to allocate memory from.
204
 
 * @param mgr           Pointer to hold the created instance of the
205
 
 *                      conversion manager.
206
 
 *
207
 
 * @return              PJ_SUCCESS on success or the appropriate error code.
208
 
 */
209
 
PJ_DECL(pj_status_t) pjmedia_converter_mgr_create(pj_pool_t *pool,
210
 
                                                  pjmedia_converter_mgr **mgr);
211
 
 
212
 
/**
213
 
 * Get the singleton instance of the conversion manager.
214
 
 *
215
 
 * @return              The instance.
216
 
 */
217
 
PJ_DECL(pjmedia_converter_mgr*) pjmedia_converter_mgr_instance(void);
218
 
 
219
 
/**
220
 
 * Manually assign a specific video manager instance as the singleton
221
 
 * instance. Normally this is not needed if only one instance is ever
222
 
 * going to be created, as the library automatically assign the singleton
223
 
 * instance.
224
 
 *
225
 
 * @param mgr           The instance to be used as the singleton instance.
226
 
 *                      Application may specify NULL to clear the singleton
227
 
 *                      singleton instance.
228
 
 */
229
 
PJ_DECL(void) pjmedia_converter_mgr_set_instance(pjmedia_converter_mgr *mgr);
230
 
 
231
 
/**
232
 
 * Destroy a converter manager. If the manager happens to be the singleton
233
 
 * instance, the singleton instance will be set to NULL.
234
 
 *
235
 
 * @param mgr           The converter manager. Specify NULL to use
236
 
 *                      the singleton instance.
237
 
 */
238
 
PJ_DECL(void) pjmedia_converter_mgr_destroy(pjmedia_converter_mgr *mgr);
239
 
 
240
 
/**
241
 
 * Register a converter factory to the converter manager.
242
 
 *
243
 
 * @param mgr           The converter manager. Specify NULL to use
244
 
 *                      the singleton instance.
245
 
 * @param f             The converter factory to be registered.
246
 
 *
247
 
 * @return              PJ_SUCCESS on success or the appropriate error code.
248
 
 */
249
 
PJ_DECL(pj_status_t)
250
 
pjmedia_converter_mgr_register_factory(pjmedia_converter_mgr *mgr,
251
 
                                       pjmedia_converter_factory *f);
252
 
 
253
 
/**
254
 
 * Unregister a previously registered converter factory from the converter
255
 
 * manager.
256
 
 *
257
 
 * @param mgr           The converter manager. Specify NULL to use
258
 
 *                      the singleton instance.
259
 
 * @param f             The converter factory to be unregistered.
260
 
 * @param call_destroy  If this is set to non-zero, the \a destroy_factory()
261
 
 *                      callback of the factory will be called while
262
 
 *                      unregistering the factory from the manager.
263
 
 *
264
 
 * @return              PJ_SUCCESS on success or the appropriate error code.
265
 
 */
266
 
PJ_DECL(pj_status_t)
267
 
pjmedia_converter_mgr_unregister_factory(pjmedia_converter_mgr *mgr,
268
 
                                         pjmedia_converter_factory *f,
269
 
                                         pj_bool_t call_destroy);
270
 
 
271
 
/**
272
 
 * Create a converter instance to perform the specified format conversion
273
 
 * as specified in \a param.
274
 
 *
275
 
 * @param mgr           The converter manager. Specify NULL to use
276
 
 *                      the singleton instance.
277
 
 * @param pool          Pool to allocate the memory from.
278
 
 * @param param         Conversion parameter.
279
 
 * @param p_cv          Pointer to hold the created converter.
280
 
 *
281
 
 * @return              PJ_SUCCESS if a converter has been created successfully
282
 
 *                      or the appropriate error code.
283
 
 */
284
 
PJ_DECL(pj_status_t) pjmedia_converter_create(pjmedia_converter_mgr *mgr,
285
 
                                              pj_pool_t *pool,
286
 
                                              pjmedia_conversion_param *param,
287
 
                                              pjmedia_converter **p_cv);
288
 
 
289
 
/**
290
 
 * Convert the buffer in the source frame and save the result in the
291
 
 * buffer of the destination frame, according to conversion format that
292
 
 * was specified when the converter was created.
293
 
 *
294
 
 * @param cv            The converter instance.
295
 
 * @param src_frame     The source frame.
296
 
 * @param dst_frame     The destination frame.
297
 
 *
298
 
 * @return              PJ_SUCCESS if conversion has been performed
299
 
 *                      successfully.
300
 
 */
301
 
PJ_DECL(pj_status_t) pjmedia_converter_convert(pjmedia_converter *cv,
302
 
                                               pjmedia_frame *src_frame,
303
 
                                               pjmedia_frame *dst_frame);
304
 
 
305
 
/**
306
 
 * Destroy the converter.
307
 
 *
308
 
 * @param cv            The converter instance.
309
 
 */
310
 
PJ_DECL(void) pjmedia_converter_destroy(pjmedia_converter *cv);
311
 
 
312
 
 
313
 
PJ_END_DECL
314
 
 
315
 
/**
316
 
 * @}
317
 
 */
318
 
 
319
 
 
320
 
#endif /* __PJMEDIA_CONVERTER_H__ */