2
* Copyright (C) 2004, 2005, 2006, 2009, 2008, 2009, 2010 Savoir-Faire Linux Inc.
3
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
4
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
* Additional permission under GNU GPL version 3 section 7:
22
* If you modify this program, or any covered work, by linking or
23
* combining it with the OpenSSL project's OpenSSL library (or a
24
* modified version of that library), containing parts covered by the
25
* terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc.
26
* grants you additional permission to convey the resulting work.
27
* Corresponding Source for a non-source form of such a combination
28
* shall include the source code for the parts of OpenSSL used as well
29
* as that of the covered work.
33
#include "audiocodec.h"
40
* GSM audio codec C++ class (over gsm/gsm.h)
43
class Gsm : public AudioCodec
47
// _payload should be 3
48
Gsm (int payload=3) : AudioCodec (payload, "GSM"), _decode_gsmhandle (NULL), _encode_gsmhandle (NULL) {
50
_frameSize = 160; // samples, 20 ms at 8kHz
55
if (! (_decode_gsmhandle = gsm_create()))
56
printf ("ERROR: decode_gsm_create");
58
if (! (_encode_gsmhandle = gsm_create()))
59
printf ("AudioCodec: ERROR: encode_gsm_create");
64
Gsm& operator= (const Gsm&);
67
gsm_destroy (_decode_gsmhandle);
68
gsm_destroy (_encode_gsmhandle);
71
virtual int codecDecode (short * dst, unsigned char * src, unsigned int size) {
72
// _debug("Decoded by gsm ");
75
if (gsm_decode (_decode_gsmhandle, (gsm_byte*) src, (gsm_signal*) dst) < 0)
76
printf ("ERROR: gsm_decode");
81
virtual int codecEncode (unsigned char * dst, short * src, unsigned int size) {
83
// _debug("Encoded by gsm ");
85
gsm_encode (_encode_gsmhandle, (gsm_signal*) src, (gsm_byte*) dst);
90
gsm _decode_gsmhandle;
91
gsm _encode_gsmhandle;
94
extern "C" AudioCodec* create()
99
extern "C" void destroy (AudioCodec* a)