blob: 8a2010314636f66930d8170d466cc69b576b2c31 [file] [log] [blame]
Benny Prijonoa4bf0212006-02-10 15:57:08 +00001/* $Id$ */
2/*
3 * Copyright (C)2003-2006 Benny Prijono <benny@prijono.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
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#include <pjmedia-codec.h>
20
21/* Include factories: */
22#include <pjmedia-codec/config.h>
23#include <pjmedia-codec/gsm.h>
Benny Prijonoeb30bf52006-03-04 20:43:52 +000024#include <pjmedia-codec/speex.h>
Benny Prijonoa4bf0212006-02-10 15:57:08 +000025
26
27static pjmedia_endpt *the_endpt;
28static struct codec_list
29{
30 pj_status_t (*init)(pjmedia_endpt*);
31 pj_status_t (*deinit)(void);
32} codec_list[] =
33{
34
35#if PJMEDIA_CODEC_HAS_GSM
36 { &pjmedia_codec_gsm_init, &pjmedia_codec_gsm_deinit},
37#endif
38
Benny Prijonoeb30bf52006-03-04 20:43:52 +000039#if PJMEDIA_CODEC_HAS_SPEEX
40 { &pjmedia_codec_speex_init_default, &pjmedia_codec_speex_deinit},
41#endif
42
Benny Prijonoa4bf0212006-02-10 15:57:08 +000043 { NULL, NULL }
44};
45
46/*
47 * Initialize pjmedia-codec library, and register all codec factories
48 * in this library.
49 */
50PJ_DEF(pj_status_t) pjmedia_codec_init(pjmedia_endpt *endpt)
51{
52 pj_status_t status;
53 unsigned i;
54
55 the_endpt = endpt;
56
57 for (i=0; codec_list[i].init; ++i) {
58 status = (*codec_list[i].init)(the_endpt);
59 if (status != PJ_SUCCESS)
60 return status;
61 }
62 return PJ_SUCCESS;
63}
64
65
66/*
67 * Deinitialize pjmedia-codec library, and unregister all codec factories
68 * in this library.
69 */
70PJ_DEF(pj_status_t) pjmedia_codec_deinit(void)
71{
72 pj_status_t status;
73 unsigned i;
74
75 for (i=0; codec_list[i].init; ++i) {
76 status = (*codec_list[i].deinit)();
77 if (status != PJ_SUCCESS)
78 return status;
79 }
80
81 return PJ_SUCCESS;
82}
83
84
85
86