Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
savoirfairelinux
jami-daemon
Commits
c8932198
Commit
c8932198
authored
Feb 13, 2008
by
Guillaume Carmel-Archambault
Browse files
Merge branch 'master' of
git+ssh://sflphone_org@sflphone.org/git/sflphone
parents
85385193
ed424321
Changes
73
Hide whitespace changes
Inline
Side-by-side
configure.ac
View file @
c8932198
...
...
@@ -35,6 +35,8 @@ AC_CONFIG_FILES([libs/Makefile \
AC_CONFIG_FILES([src/Makefile \
src/sflphone \
src/audio/Makefile \
src/audio/codecs/Makefile
src/audio/codecs/ilbc/Makefile \
src/config/Makefile \
src/dbus/Makefile \
src/zeroconf/Makefile])
...
...
sflphone-gtk/src/actions.c
View file @
c8932198
...
...
@@ -587,7 +587,7 @@ sflphone_fill_codec_list()
gchar
**
order
=
(
gchar
**
)
dbus_get_active_codec_list
();
gchar
**
details
;
gchar
**
pl
;
for
(
pl
=
order
;
*
order
;
order
++
)
{
codec_t
*
c
=
g_new0
(
codec_t
,
1
);
...
...
@@ -601,7 +601,7 @@ sflphone_fill_codec_list()
c
->
_bandwidth
=
atof
(
details
[
3
]);
codec_list_add
(
c
);
}
for
(
pl
=
codecs
;
*
codecs
;
codecs
++
)
{
details
=
(
gchar
**
)
dbus_codec_details
(
atoi
(
*
codecs
));
...
...
src/audio/CodecSpeex.h
deleted
100644 → 0
View file @
85385193
/*
* Copyright (C) 2005 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* This program 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.
*
* This program 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 this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __CODEC_SPEEX_H_
#define __CODEC_SPEEX_H_
#include
"audiocodec.h"
#include
<speex/speex.h>
class
CodecSpeex
:
public
AudioCodec
{
public:
CodecSpeex
(
int
payload
);
~
CodecSpeex
();
int
codecDecode
(
short
*
,
unsigned
char
*
,
unsigned
int
);
int
codecEncode
(
unsigned
char
*
,
short
*
,
unsigned
int
);
// only for speex
int
getFrameSize
()
{
return
_speex_frame_size
;
}
private:
unsigned
int
_clockRate
;
unsigned
int
_channel
;
void
initSpeex
();
void
terminateSpeex
();
const
SpeexMode
*
_speexModePtr
;
SpeexBits
_speex_dec_bits
;
SpeexBits
_speex_enc_bits
;
void
*
_speex_dec_state
;
void
*
_speex_enc_state
;
int
_speex_frame_size
;
};
#endif // __CODEC_SPEEX_H_
src/audio/Makefile.am
View file @
c8932198
sflcodecdir
=
$(libdir)
/sflphone/codecs
/
sflcodecdir
=
$(libdir)
/sflphone/codecs
noinst_LTLIBRARIES
=
libaudio.la
noinst_PROGRAMS
=
libcodec_ulaw.so libcodec_alaw.so libcodec_gsm.so libcodec_speex.so
libcodec_ulaw_so_SOURCES
=
ulaw.cpp
libcodec_ulaw_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_ulaw_so_LDFLAGS
=
-shared
-lc
SUBDIRS
=
codecs
libcodec_alaw_so_SOURCES
=
alaw.cpp
libcodec_alaw_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_alaw_so_LDFLAGS
=
-shared
-lc
libcodec_gsm_so_SOURCES
=
gsmcodec.cpp
libcodec_gsm_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_gsm_so_LDFLAGS
=
-shared
-lc
-lgsm
libcodec_speex_so_SOURCES
=
CodecSpeex.cpp
libcodec_speex_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_speex_so_LDFLAGS
=
-shared
-lc
-lspeex
if
USE_SPEEX
SPEEX_SOURCES_CPP
=
CodecSpeex.cpp
SPEEX_FLAG
=
-DHAVE_SPEEX
SPEEX_LIB
=
-lspeex
else
SPEEX_SOURCES_CPP
=
SPEEX_FLAG
=
SPEEX_LIB
=
endif
#SUBDIRS = ilbc
libaudio_la_SOURCES
=
audiofile.cpp tonelist.cpp
\
libaudio_la_SOURCES
=
audiofile.cpp tonelist.cpp
\
audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfgenerator.cpp
\
tonegenerator.cpp codecDescriptor.cpp
\
audioloop.cpp ringbuffer.cpp
$(SPEEX_SOURCES_CPP)
...
...
@@ -40,31 +13,8 @@ AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $
-DCODECS_DIR
=
\"
"
$(sflcodecdir)
"
\"
libaudio_la_CPPFLAGS
=
$(SPEEX_FLAG)
noinst_HEADERS
=
audioloop.h
common.h ringbuffer.h
audiofile.h
\
tonelist.h audiortp.h
audiocodec.h
audiolayer.h audiodevice.h
\
noinst_HEADERS
=
audioloop.h common.h ringbuffer.h audiofile.h
\
tonelist.h audiortp.h audiolayer.h audiodevice.h
\
dtmfgenerator.h tonegenerator.h
\
codecDescriptor.h dtmf.h tone.h
\
CodecSpeex.h
install-exec-local
:
install-libcodec_ulaw_so install-libcodec_alaw_so install-libcodec_gsm_so install-libcodec_speex_so
uninstall-local
:
uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_so
install-libcodec_ulaw_so
:
libcodec_ulaw.so
mkdir
-p
$(sflcodecdir)
$(INSTALL_PROGRAM)
libcodec_ulaw.so
$(sflcodecdir)
install-libcodec_alaw_so
:
libcodec_alaw.so
$(INSTALL_PROGRAM)
libcodec_alaw.so
$(sflcodecdir)
install-libcodec_gsm_so
:
libcodec_gsm.so
$(INSTALL_PROGRAM)
libcodec_gsm.so
$(sflcodecdir)
install-libcodec_speex_so
:
libcodec_speex.so
$(INSTALL_PROGRAM)
libcodec_speex.so
$(sflcodecdir)
codecDescriptor.h dtmf.h tone.h
uninstall-libcodec_ulaw_so
:
rm
-f
$(sflcodecdir)
/libcodec_ulaw.so
uninstall-libcodec_alaw_so
:
rm
-f
$(sflcodecdir)
/libcodec_alaw.so
uninstall-libcodec_gsm_so
:
rm
-f
$(sflcodecdir)
/libcodec_gsm.so
uninstall-libcodec_speex_so
:
rm
-f
$(sflcodecdir)
/libcodec_speex.so
rm
-rf
$(sflcodecdir)
src/audio/audiofile.h
View file @
c8932198
...
...
@@ -24,7 +24,7 @@
#define __AUDIOFILE_H__
#include
"audioloop.h"
#include
"audiocodec.h"
#include
"
codecs/
audiocodec.h"
/**
@author Yan Morin <yan.morin@savoirfairelinux.com>
...
...
src/audio/audiortp.cpp
View file @
c8932198
...
...
@@ -97,13 +97,12 @@ AudioRtp::closeRtpSession () {
// AudioRtpRTX Class //
////////////////////////////////////////////////////////////////////////////////
AudioRtpRTX
::
AudioRtpRTX
(
SIPCall
*
sipcall
,
bool
sym
)
:
_fstream
(
"/tmp/audio.
dat
"
,
std
::
ofstream
::
binary
|
std
::
ios
::
out
|
std
::
ios
::
app
)
:
_fstream
(
"/tmp/audio.
gsm
"
,
std
::
ofstream
::
binary
|
std
::
ios
::
out
|
std
::
ios
::
app
)
{
setCancel
(
cancelDeferred
);
time
=
new
ost
::
Time
();
_ca
=
sipcall
;
_sym
=
sym
;
//std::string s = "snd.dat";
// AudioRtpRTX should be close if we change sample rate
//_codecSampleRate = _ca->getAudioCodec()->getClockRate();
...
...
@@ -141,7 +140,6 @@ AudioRtpRTX::~AudioRtpRTX () {
}
//_debug("terminate audiortprtx ended...\n");
_ca
=
0
;
//fd = fopen("snd_data", "wa");
if
(
!
_sym
)
{
delete
_sessionRecv
;
_sessionRecv
=
NULL
;
delete
_sessionSend
;
_sessionSend
=
NULL
;
...
...
@@ -184,8 +182,7 @@ AudioRtpRTX::initAudioRtpSession (void)
try
{
if
(
_ca
==
0
)
{
return
;
}
AudioCodec
*
audiocodec
=
loadCodec
(
_ca
->
getAudioCodec
());
_codecSampleRate
=
audiocodec
->
getClockRate
();
_codecSampleRate
=
_audiocodec
->
getClockRate
();
_debug
(
"Init audio RTP session
\n
"
);
ost
::
InetHostAddress
remote_ip
(
_ca
->
getRemoteIp
().
c_str
());
...
...
@@ -217,12 +214,12 @@ AudioRtpRTX::initAudioRtpSession (void)
}
bool
payloadIsSet
=
false
;
if
(
audiocodec
)
{
if
(
audiocodec
->
hasDynamicPayload
())
{
payloadIsSet
=
_sessionRecv
->
setPayloadFormat
(
ost
::
DynamicPayloadFormat
((
ost
::
PayloadType
)
audiocodec
->
getPayload
(),
audiocodec
->
getClockRate
()));
if
(
_
audiocodec
)
{
if
(
_
audiocodec
->
hasDynamicPayload
())
{
payloadIsSet
=
_sessionRecv
->
setPayloadFormat
(
ost
::
DynamicPayloadFormat
((
ost
::
PayloadType
)
_
audiocodec
->
getPayload
(),
_
audiocodec
->
getClockRate
()));
}
else
{
payloadIsSet
=
_sessionRecv
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
audiocodec
->
getPayload
()));
payloadIsSet
=
_sessionSend
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
audiocodec
->
getPayload
()));
payloadIsSet
=
_sessionRecv
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
_
audiocodec
->
getPayload
()));
payloadIsSet
=
_sessionSend
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
_
audiocodec
->
getPayload
()));
}
}
_sessionSend
->
setMark
(
true
);
...
...
@@ -235,22 +232,21 @@ AudioRtpRTX::initAudioRtpSession (void)
}
bool
payloadIsSet
=
false
;
if
(
audiocodec
)
{
if
(
audiocodec
->
hasDynamicPayload
())
{
payloadIsSet
=
_session
->
setPayloadFormat
(
ost
::
DynamicPayloadFormat
((
ost
::
PayloadType
)
audiocodec
->
getPayload
(),
audiocodec
->
getClockRate
()));
if
(
_
audiocodec
)
{
if
(
_
audiocodec
->
hasDynamicPayload
())
{
payloadIsSet
=
_session
->
setPayloadFormat
(
ost
::
DynamicPayloadFormat
((
ost
::
PayloadType
)
_
audiocodec
->
getPayload
(),
_
audiocodec
->
getClockRate
()));
}
else
{
payloadIsSet
=
_session
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
audiocodec
->
getPayload
()));
payloadIsSet
=
_session
->
setPayloadFormat
(
ost
::
StaticPayloadFormat
((
ost
::
StaticPayloadType
)
_
audiocodec
->
getPayload
()));
}
}
}
unloadCodec
(
audiocodec
);
}
catch
(...)
{
_debugException
(
"! ARTP Failure: initialisation failed"
);
throw
;
}
}
AudioCodec
*
void
AudioRtpRTX
::
loadCodec
(
int
payload
)
{
using
std
::
cerr
;
...
...
@@ -282,11 +278,12 @@ AudioRtpRTX::loadCodec(int payload)
if
(
dlsym_error
){
cerr
<<
"Cannot load symbol create: "
<<
dlsym_error
<<
'\n'
;
}
return
create_codec
();
_audiocodec
=
create_codec
();
}
void
AudioRtpRTX
::
unloadCodec
(
AudioCodec
*
audiocodec
)
AudioRtpRTX
::
unloadCodec
()
{
using
std
::
cerr
;
destroy_t
*
destroy_codec
=
(
destroy_t
*
)
dlsym
(
handle_codec
,
"destroy"
);
...
...
@@ -294,7 +291,7 @@ AudioRtpRTX::unloadCodec(AudioCodec* audiocodec)
if
(
dlsym_error
){
cerr
<<
"Cannot load symbol destroy"
<<
dlsym_error
<<
'\n'
;
}
destroy_codec
(
audiocodec
);
destroy_codec
(
_
audiocodec
);
dlclose
(
handle_codec
);
}
...
...
@@ -302,7 +299,6 @@ AudioRtpRTX::unloadCodec(AudioCodec* audiocodec)
void
AudioRtpRTX
::
sendSessionFromMic
(
int
timestamp
)
{
AudioCodec
*
audiocodec
=
loadCodec
(
_ca
->
getAudioCodec
());
// STEP:
// 1. get data from mic
// 2. convert it to int16 - good sample, good rate
...
...
@@ -316,25 +312,21 @@ try {
AudioLayer
*
audiolayer
=
Manager
::
instance
().
getAudioDriver
();
if
(
!
audiolayer
)
{
_debug
(
" !ARTP: No audiolayer available for mic
\n
"
);
return
;
}
//AudioCodec* audiocodec = _ca->getAudioCodec();
if
(
!
audiocodec
)
{
_debug
(
" !ARTP: No audiocodec available for mic
\n
"
);
return
;
}
if
(
!
_audiocodec
)
{
_debug
(
" !ARTP: No audiocodec available for mic
\n
"
);
return
;
}
// we have to get 20ms of data from the mic *20/1000 = /50
int
maxBytesToGet
=
_layerSampleRate
*
_layerFrameSize
*
sizeof
(
SFLDataFormat
)
/
1000
;
// available bytes inside ringbuffer
int
availBytesFromMic
=
audiolayer
->
canGetMic
();
// take the lowest
int
bytesAvail
=
(
availBytesFromMic
<
maxBytesToGet
)
?
availBytesFromMic
:
maxBytesToGet
;
//printf("clock rate = %i\n", audiocodec->getClockRate());
// Get bytes from micRingBuffer to data_from_mic
int
nbSample
=
audiolayer
->
getMic
(
_dataAudioLayer
,
bytesAvail
)
/
sizeof
(
SFLDataFormat
);
int
nb_sample_up
=
nbSample
;
int
nbSamplesMax
=
_layerFrameSize
*
audiocodec
->
getClockRate
()
/
1000
;
//_fstream.write((char*) _dataAudioLayer, nbSample);
int
nbSamplesMax
=
_layerFrameSize
*
_audiocodec
->
getClockRate
()
/
1000
;
nbSample
=
reSampleData
(
audiocodec
->
getClockRate
(),
nb_sample_up
,
DOWN_SAMPLING
);
nbSample
=
reSampleData
(
_
audiocodec
->
getClockRate
(),
nb_sample_up
,
DOWN_SAMPLING
);
toSIP
=
_intBufferDown
;
...
...
@@ -348,7 +340,7 @@ try {
//_debug("AR: Nb sample: %d int, [0]=%d [1]=%d [2]=%d\n", nbSample, toSIP[0], toSIP[1], toSIP[2]);
// for the mono: range = 0 to RTP_FRAME2SEND * sizeof(int16)
// codecEncode(char *dest, int16* src, size in bytes of the src)
int
compSize
=
audiocodec
->
codecEncode
(
_sendDataEncoded
,
toSIP
,
nbSample
*
sizeof
(
int16
));
int
compSize
=
_
audiocodec
->
codecEncode
(
_sendDataEncoded
,
toSIP
,
nbSample
*
sizeof
(
int16
));
//printf("jusqu'ici tout vas bien\n");
// encode divise by two
...
...
@@ -364,7 +356,6 @@ try {
_debugException
(
"! ARTP: sending failed"
);
throw
;
}
unloadCodec
(
audiocodec
);
}
...
...
@@ -373,7 +364,6 @@ void
AudioRtpRTX
::
receiveSessionForSpkr
(
int
&
countTime
)
{
AudioCodec
*
audiocodec
;
if
(
_ca
==
0
)
{
return
;
}
try
{
...
...
@@ -396,12 +386,11 @@ try {
int
payload
=
adu
->
getType
();
// codec type
unsigned
char
*
data
=
(
unsigned
char
*
)
adu
->
getData
();
// data in char
unsigned
int
size
=
adu
->
getSize
();
// size in char
//_fstream.write((char*) data, size);
audiocodec
=
loadCodec
(
payload
);
// Decode data with relevant codec
_codecSampleRate
=
audiocodec
->
getClockRate
();
int
max
=
(
int
)(
_codecSampleRate
*
_layerFrameSize
);
int
max
=
(
int
)(
_codecSampleRate
*
_layerFrameSize
/
1000
);
if
(
size
>
max
)
{
_debug
(
"We have received from RTP a packet larger than expected: %s VS %s
\n
"
,
size
,
max
);
...
...
@@ -411,8 +400,11 @@ try {
//printf("size = %i\n", size);
if
(
audiocodec
!=
NULL
)
{
int
expandedSize
=
audiocodec
->
codecDecode
(
_receiveDataDecoded
,
data
,
size
);
if
(
_audiocodec
!=
NULL
)
{
int
expandedSize
=
_audiocodec
->
codecDecode
(
_receiveDataDecoded
,
data
,
size
);
// printf("%i\n", expandedSize);
//_fstream.write((char*) _receiveDataDecoded, );
//buffer _receiveDataDecoded ----> short int or int16, coded on 2 bytes
int
nbInt16
=
expandedSize
/
sizeof
(
int16
);
//nbInt16 represents the number of samples we just decoded
...
...
@@ -455,7 +447,6 @@ try {
throw
;
}
unloadCodec
(
audiocodec
);
}
...
...
@@ -527,6 +518,7 @@ AudioRtpRTX::run () {
//mic, we receive from soundcard in stereo, and we send encoded
//encoding before sending
AudioLayer
*
audiolayer
=
Manager
::
instance
().
getAudioDriver
();
loadCodec
(
_ca
->
getAudioCodec
());
_layerFrameSize
=
audiolayer
->
getFrameSize
();
// en ms
_layerSampleRate
=
audiolayer
->
getSampleRate
();
...
...
@@ -569,7 +561,8 @@ try {
Thread
::
sleep
(
TimerPort
::
getTimer
());
TimerPort
::
incTimer
(
_layerFrameSize
);
// 'frameSize' ms
}
//_fstream.close();
_fstream
.
close
();
unloadCodec
();
//_debug("stop stream for audiortp loop\n");
audiolayer
->
stopStream
();
}
catch
(
std
::
exception
&
e
)
{
...
...
src/audio/audiortp.h
View file @
c8932198
...
...
@@ -123,19 +123,22 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort {
/** Pointer on function to handle codecs **/
void
*
handle_codec
;
AudioCodec
*
_audiocodec
;
/**
* Load dynamically a codec (.so library)
* @param payload The payload of the codec you want to load
* @return AudioCodec* A pointer on a audio codec object
*/
AudioCodec
*
loadCodec
(
int
payload
);
void
loadCodec
(
int
payload
);
/**
* Destroy and close dynamically a codec (.so library)
* @param audiocodec The audio codec you want to unload
*/
void
unloadCodec
(
AudioCodec
*
audiocodec
);
void
unloadCodec
(
void
);
};
///////////////////////////////////////////////////////////////////////////////
...
...
src/audio/codecDescriptor.cpp
View file @
c8932198
...
...
@@ -22,11 +22,7 @@
#include
<iostream>
#include
<cstdlib>
#include
"audiocodec.h"
#include
"codecDescriptor.h"
/*#ifdef HAVE_SPEEX
#include "CodecSpeex.h"
#endif*/
CodecDescriptor
::
CodecDescriptor
()
{
...
...
@@ -112,7 +108,7 @@ CodecDescriptor::getBitRate(CodecType payload)
case
PAYLOAD_CODEC_ILBC_20
:
return
15.2
;
case
PAYLOAD_CODEC_ILBC_30
:
return
1
5.2
;
return
1
3.3
;
}
return
0.0
;
...
...
src/audio/codecDescriptor.h
View file @
c8932198
...
...
@@ -50,7 +50,7 @@ typedef enum {
PAYLOAD_CODEC_SPEEX_32000
=
112
}
CodecType
;
#include
"audiocodec.h"
#include
"
codecs/
audiocodec.h"
/* A codec is identified by its payload. A payload is associated with a name. */
typedef
std
::
map
<
CodecType
,
std
::
string
>
CodecMap
;
...
...
src/audio/codecs/Makefile.am
0 → 100644
View file @
c8932198
sflcodecdir
=
$(libdir)
/sflphone/codecs
noinst_PROGRAMS
=
libcodec_ulaw.so libcodec_alaw.so libcodec_gsm.so libcodec_speex.so libcodec_ilbc.so
noinst_HEADERS
=
audiocodec.h
libcodec_ulaw_so_SOURCES
=
ulaw.cpp
libcodec_ulaw_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_ulaw_so_LDFLAGS
=
-shared
-lc
libcodec_alaw_so_SOURCES
=
alaw.cpp
libcodec_alaw_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_alaw_so_LDFLAGS
=
-shared
-lc
libcodec_gsm_so_SOURCES
=
gsmcodec.cpp
libcodec_gsm_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_gsm_so_LDFLAGS
=
-shared
-lc
-lgsm
libcodec_speex_so_SOURCES
=
speexcodec.cpp
libcodec_speex_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_speex_so_LDFLAGS
=
-shared
-lc
-lspeex
libcodec_ilbc_so_SOURCES
=
ilbc.cpp
libcodec_ilbc_so_CFLAGS
=
-fPIC
-g
-Wall
libcodec_ilbc_so_LDFLAGS
=
-shared
ilbc/
*
.o
-lc
SUBDIRS
=
ilbc
install-exec-local
:
install-libcodec_ulaw_so install-libcodec_alaw_so install-libcodec_gsm_so install-libcodec_speex_so install-libcodec_ilbc_so
uninstall-local
:
uninstall-libcodec_ulaw_so uninstall-libcodec_alaw_so uninstall-libcodec_gsm_so uninstall-libcodec_speex_so uninstall-libcodec_ilbc_so
install-libcodec_ulaw_so
:
libcodec_ulaw.so
mkdir
-p
$(sflcodecdir)
$(INSTALL_PROGRAM)
libcodec_ulaw.so
$(sflcodecdir)
install-libcodec_alaw_so
:
libcodec_alaw.so
$(INSTALL_PROGRAM)
libcodec_alaw.so
$(sflcodecdir)
install-libcodec_gsm_so
:
libcodec_gsm.so
$(INSTALL_PROGRAM)
libcodec_gsm.so
$(sflcodecdir)
install-libcodec_speex_so
:
libcodec_speex.so
$(INSTALL_PROGRAM)
libcodec_speex.so
$(sflcodecdir)
install-libcodec_ilbc_so
:
libcodec_ilbc.so
$(INSTALL_PROGRAM)
libcodec_ilbc.so
$(sflcodecdir)
uninstall-libcodec_ulaw_so
:
rm
-f
$(sflcodecdir)
/libcodec_ulaw.so
uninstall-libcodec_alaw_so
:
rm
-f
$(sflcodecdir)
/libcodec_alaw.so
uninstall-libcodec_gsm_so
:
rm
-f
$(sflcodecdir)
/libcodec_gsm.so
uninstall-libcodec_speex_so
:
rm
-f
$(sflcodecdir)
/libcodec_speex.so
uninstall-libcodec_ilbc_so
:
rm
-f
$(sflcodecdir)
/libcodec_ilbc.so
rm
-rf
$(sflcodecdir)
src/audio/
NOTES
→
src/audio/
codecs/README
View file @
c8932198
File moved
src/audio/alaw.cpp
→
src/audio/
codecs/
alaw.cpp
View file @
c8932198
...
...
@@ -18,7 +18,7 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include
"common.h"
#include
"
../
common.h"
#include
"audiocodec.h"
class
Alaw
:
public
AudioCodec
{
...
...
@@ -31,7 +31,7 @@ public:
_channel
=
1
;
}
virtual
~
Alaw
(){}
virtual
int
codecDecode
(
short
*
dst
,
unsigned
char
*
src
,
unsigned
int
size
)
{
int16
*
end
=
dst
+
size
;
...
...
src/audio/codecs/audiocodec.h
0 → 100644
View file @
c8932198
#ifndef _CODEC_AUDIO_H
#define _CODEC_AUDIO_H
#include
<string>
#include
<iostream>
#include
<dlfcn.h>
class
AudioCodec
{
protected:
/** Holds SDP-compliant codec name */
std
::
string
_codecName
;
// what we put inside sdp
/** Clock rate or sample rate of the codec, in Hz */
unsigned
int
_clockRate
;
/** Number of channel 1 = mono, 2 = stereo */
unsigned
int
_channel
;
private:
int
_payload
;
bool
_hasDynamicPayload
;
public:
AudioCodec
(
int
payload
,
const
std
::
string
&
codecName
)
:
_codecName
(
codecName
)
{
_payload
=
payload
;
_clockRate
=
8000
;
// default
_channel
=
1
;
// default
_hasDynamicPayload
=
(
_payload
>=
96
&&
_payload
<=
127
)
?
true
:
false
;
}
virtual
~
AudioCodec
()
{
}
/**
* @return the number of bytes decoded
*/
virtual
int
codecDecode
(
short
*
,
unsigned
char
*
,
unsigned
int
)
=
0
;
virtual
int
codecEncode
(
unsigned
char
*
,
short
*
,
unsigned
int
)
=
0
;
/** Value used for SDP negotiation */
std
::
string
getCodecName
()
{
return
_codecName
;
}
int
getPayload
()
{
return
_payload
;
}
bool
hasDynamicPayload
()
{
return
_hasDynamicPayload
;
}
unsigned
int
getClockRate
()
{
return
_clockRate
;
}
unsigned
int
getChannel
()
{
return
_channel
;
}
};
// the types of the class factories
typedef
AudioCodec
*
create_t
();
typedef
void
destroy_t
(
AudioCodec
*
);
#endif
src/audio/gsmcodec.
h
→
src/audio/
codecs/
gsmcodec.
cpp
View file @
c8932198
...
...
@@ -18,15 +18,11 @@
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef __GSM_H__
#define __GSM_H__
#include
<gsm.h>
#include
"audiocodec.h"
/*
extern "C"
{
#include
"gsm/
gsm.h
"
}
*/
extern
"C"
{
#include
<
gsm.h
>
}
/**
* GSM audio codec C++ class (over gsm/gsm.h)
...
...
@@ -34,16 +30,43 @@
class
Gsm
:
public
AudioCodec
{
public:
// _payload should be 3
Gsm
(
int
payload
=
3
);
~
Gsm
(
void
);
Gsm
(
int
payload
=
3
)
:
AudioCodec
(
payload
,
"GSM"
){
_clockRate
=
8000
;
_channel
=
1
;
if
(
!
(
_decode_gsmhandle
=
gsm_create
()
))
printf
(
"ERROR: decode_gsm_create
\n
"
);
if
(
!
(
_encode_gsmhandle
=
gsm_create
()
))
printf
(
"AudioCodec: ERROR: encode_gsm_create
\n
"
);
}
virtual
~
Gsm
(
void
){
gsm_destroy
(
_decode_gsmhandle
);
gsm_destroy
(
_encode_gsmhandle
);
}
int
codecDecode
(
short
*
,
unsigned
char
*
,
unsigned
int
);
int
codecEncode
(
unsigned
char
*
,
short
*
,
unsigned
int
);
void
test
();
virtual
int
codecDecode
(
short
*
dst
,
unsigned
char
*
src
,
unsigned
int
size
){
(
void
)
size
;
if
(
gsm_decode
(
_decode_gsmhandle
,
(
gsm_byte
*
)
src
,
(
gsm_signal
*
)
dst
)
<
0
)
printf
(
"ERROR: gsm_decode
\n
"
);
return
320
;
}
virtual
int
codecEncode
(
unsigned
char
*
dst
,
short
*
src
,
unsigned
int
size
){
(
void
)
size
;
gsm_encode
(
_encode_gsmhandle
,
(
gsm_signal
*
)
src
,
(
gsm_byte
*
)
dst
);
return
33
;
}