Commit 8ba45b53 authored by Guillaume Carmel-Archambault's avatar Guillaume Carmel-Archambault
Browse files

Merge branch 'master' of git+ssh://sflphone_org@sflphone.org/git/sflphone

Conflicts:

	sflphone-gtk/src/configwindow.c
parents f16e154c 8d3ec12c
......@@ -35,7 +35,6 @@ AC_CONFIG_FILES([libs/Makefile \
AC_CONFIG_FILES([src/Makefile \
src/sflphone \
src/audio/Makefile \
src/audio/gsm/Makefile \
src/config/Makefile \
src/dbus/Makefile \
src/zeroconf/Makefile])
......@@ -151,6 +150,11 @@ PKG_CHECK_MODULES([libosip2], [libosip2 >= ${LIBOSIP2_OSIPLISTNOPOINTER_MIN_VERS
SIP_CFLAGS="$SIP_CFLAGS $LIBOSIP2_CFLAGS";
AC_SUBST(SIP_CFLAGS)
dnl LIBGSM1_MIN_VERSION=1.10
dnl PKG_CHECK_MODULES(gsm, gsm >= ${LIBGSM1_MIN_VERSION})
dnl SFLPHONE_CFLAGS="$SFLPHONE_CFLAGS $libgsm1_CFLAGS"
dnl SFLPHONE_LIBS="$SFLPHONE_LIBS $libgsm1_LIBS"
LIBSAMPLERATE_MIN_VERSION=0.1.1
PKG_CHECK_MODULES(samplerate, samplerate >= ${LIBSAMPLERATE_MIN_VERSION})
SFLPHONE_CFLAGS="$SFLPHONE_CFLAGS $samplerate_CFLAGS"
......
......@@ -7,7 +7,7 @@ Dependencies to compile SFLphone daemon
`--------------------`----------`-----------------------------------------------------
Program Version Notes
--------------------------------------------------------------------------------------
libiax2 0.2.3 http://svncommunity.digium.com/view/libiax2/trunk/[svn repos] SFLphone maintains it's own copy
libiax2 0.2.3 http://svncommunity.digium.com/view/libiax2/trunk/[svn repos] Source code included in the git repository.
Common C++2 1.3.21 http://sourceforge.net/projects/cplusplus/[website]
ccRTP 1.3.5 http://sourceforge.net/projects/cplusplus/[website]
libeXosip2 ** 2.2.2 http://savannah.nongnu.org/projects/exosip/[website]
......@@ -16,7 +16,7 @@ portaudio v19 http://www.portaudio.com/[website]
portaudio C++ binds. http://www.portaudio.com/archives/pa_snapshot_v19.tar.gz[archive]
libsamplerate 0.1.2 http://www.mega-nerd.com/SRC/[website]
libdbus-glib 0.73 Packaged with your favorite distribution.
dbus-c++-1 0.5 See Build notes.
dbus-c++-1 0.5 Source code included in the git repository. See Build notes.
libexpat1 1.95.8 Packaged with your favorite distribution.
--------------------------------------------------------------------------------------
......@@ -34,3 +34,11 @@ dbus-glib 0.35
gnome-common
--------------------------------------------------------------------------------------
Dependencies to use audio codecs
------------------------------------
`--------------------`----------`-----------------------------------------------------
Program Version Notes
--------------------------------------------------------------------------------------
libgsm1 1.0.10 Standard package - Necessary to use GSM codec
--------------------------------------------------------------------------------------
......@@ -165,7 +165,7 @@ sflphone_init()
sflphone_hang_up()
{
call_t * selectedCall = call_get_selected();
main_window_callinfo(FALSE, selectedCall);
//main_window_callinfo(FALSE, selectedCall);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -197,7 +197,7 @@ sflphone_pick_up()
{
call_t * selectedCall = call_get_selected();
//printf("full name: %s\n",g_hash_table_lookup(selectedCall->properties, ACCOUNT_IAX_FULL_NAME));
main_window_callinfo(TRUE, selectedCall);
//main_window_callinfo(TRUE, selectedCall);
if(selectedCall)
{
switch(selectedCall->state)
......@@ -269,7 +269,7 @@ sflphone_fail( call_t * c )
c->state = CALL_STATE_FAILURE;
update_call_tree(c);
update_menus();
main_window_callinfo(FALSE, c);
//main_window_callinfo(FALSE, c);
}
void
......@@ -334,7 +334,7 @@ sflphone_hung_up (call_t * c )
call_list_remove(c->callID);
update_call_tree_remove(c);
update_menus();
main_window_callinfo(FALSE, c);
//main_window_callinfo(FALSE, c);
}
void process_dialing(call_t * c, guint keyval, gchar * key)
......
......@@ -249,7 +249,6 @@ select_codec(GtkTreeSelection * selection, GtkTreeModel * model)
{
return;
}
//guint item = gtk_combo_box_get_active(wid);
/* now we want this selected codec to be used as the preferred codec */
/* ie first in the list in the user config */
......@@ -453,10 +452,8 @@ create_accounts_tab()
GtkTreeSelection *treeSelection;
GtkWidget *label;
GtkTreeIter iter;
GValue val;
val.g_type = G_TYPE_POINTER;
GValue val;
val.g_type = G_TYPE_POINTER;
selectedAccount = NULL;
......@@ -711,7 +708,9 @@ create_video_tab ()
GtkWidget * label;
GtkWidget * codecBox;
GtkWidget * rate_box;
//GtkWidget * image;
GtkWidget * hbox1;
//GtkTreeIter iter;
GtkCellRenderer *renderer;
ret = gtk_vbox_new(FALSE, 10);
......@@ -788,6 +787,7 @@ create_video_tab ()
config_window_fill_codec_list();
config_window_fill_rate_list();
gtk_combo_box_set_active(GTK_COMBO_BOX(rate_box), 0);
//gtk_combo_box_set_active(rate_box, 0);
return ret;
}*/
......
SUBDIRS = gsm
#SUBDIRS = gsm
noinst_LTLIBRARIES = libaudio.la
......@@ -12,18 +12,18 @@ SPEEX_FLAG=
SPEEX_LIB=
endif
libaudio_la_SOURCES = alaw.cpp audiofile.cpp g711.cpp tonelist.cpp \
audiortp.cpp dtmf.cpp tone.cpp audiolayer.cpp audiodevice.cpp dtmfgenerator.cpp gsmcodec.cpp \
tonegenerator.cpp ulaw.cpp codecDescriptor.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)
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES)
libaudio_la_LIBADD = gsm/libgsm.la $(SPEEX_LIB)
AM_CXXFLAGS = -I$(top_srcdir)/include -I$(top_srcdir)/libs $(libccext2_CFLAGS) $(libdbuscpp_CFLAGS) $(libccrtp1_CFLAGS) $(USER_INCLUDES)
#libaudio_la_LIBADD = gsm/libgsm.la $(SPEEX_LIB)
libaudio_la_CPPFLAGS = $(SPEEX_FLAG)
noinst_HEADERS = audioloop.h common.h ringbuffer.h alaw.h audiofile.h g711.h \
noinst_HEADERS = audioloop.h common.h ringbuffer.h audiofile.h \
tonelist.h audiortp.h audiocodec.h audiolayer.h audiodevice.h \
dtmfgenerator.h gsmcodec.h tonegenerator.h ulaw.h \
dtmfgenerator.h tonegenerator.h \
codecDescriptor.h dtmf.h tone.h \
CodecSpeex.h
......@@ -28,7 +28,7 @@ public:
Alaw(int payload=0)
: AudioCodec(payload, "PCMA")
{
_description = "G711a";
//_description = "G711a";
_clockRate = 8000;
_channel = 1;
......@@ -76,10 +76,6 @@ virtual int codecEncode (unsigned char *dst, short *src, unsigned int size)
return size;
}
virtual void test()
{
printf("MON OSTIE ALAW!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
}
uint8 ALawEncode (int16 pcm16)
{
......@@ -124,11 +120,11 @@ uint8 ALawEncode (int16 pcm16)
};
// the class factories
extern "C" AudioCodec* create_alaw() {
return new Alaw();
extern "C" AudioCodec* create() {
return new Alaw(8);
}
extern "C" void destroy_alaw(AudioCodec* a) {
extern "C" void destroy(AudioCodec* a) {
delete a;
}
......@@ -3,15 +3,13 @@
#include <string>
#include <iostream>
#include <dlfcn.h>
class AudioCodec {
protected:
/** Holds SDP-compliant codec name */
std::string _codecName; // what we put inside sdp
/** Holds the GUI-style codec description */
std::string _description; // what we display to the user
/** Clock rate or sample rate of the codec, in Hz */
unsigned int _clockRate;
......@@ -19,7 +17,7 @@ protected:
unsigned int _channel;
private:
bool _active;
//bool _active;
int _payload;
bool _hasDynamicPayload;
......@@ -29,7 +27,7 @@ public:
_payload = payload;
_clockRate = 8000; // default
_channel = 1; // default
_active = false;
// _active = false;
_hasDynamicPayload = (_payload >= 96 && _payload <= 127) ? true : false;
}
......@@ -41,9 +39,6 @@ public:
*/
virtual int codecDecode(short *, unsigned char *, unsigned int) = 0;
virtual int codecEncode(unsigned char *, short *, unsigned int) = 0;
virtual void test()=0;
/** Returns description for GUI usage */
std::string getDescription() { return _description; }
/** Value used for SDP negotiation */
std::string getCodecName() { return _codecName; }
......@@ -51,8 +46,9 @@ public:
bool hasDynamicPayload() { return _hasDynamicPayload; }
unsigned int getClockRate() { return _clockRate; }
unsigned int getChannel() { return _channel; }
bool isActive() { return _active; }
void setActive(bool active) { _active = active; }
//bool isActive() { return _active; }
//void setActive(bool active) { _active = active; }
};
......
......@@ -25,20 +25,40 @@
#include <fstream>
#include <math.h>
#include <samplerate.h>
#include <dlfcn.h>
AudioFile::AudioFile()
: AudioLoop()
{
// could vary later...
_ulaw = new Ulaw(PAYLOAD_CODEC_ULAW);
//_ulaw = new Ulaw(PAYLOAD_CODEC_ULAW);
_start = false;
using std::cout;
using std::cerr;
void* codec = dlopen("codec_ulaw.so", RTLD_LAZY);
if(!codec){
cerr<<"cannot load library: "<< dlerror() <<'\n';
}
dlerror();
create_t* create_codec = (create_t*)dlsym(codec, "create");
const char* dlsym_error = dlerror();
if(dlsym_error){
cerr << "Cannot load symbol create: " << dlsym_error << '\n';
}
destroy_t* destroy_codec = (destroy_t*) dlsym(codec, "destroy");
dlsym_error = dlerror();
if(dlsym_error){
cerr << "Cannot load symbol destroy" << dlsym_error << '\n';
}
_ulaw = create_codec();
}
AudioFile::~AudioFile()
{
delete _ulaw;
delete _ulaw;
}
// load file in mono format
......@@ -82,6 +102,7 @@ AudioFile::loadFile(const std::string& filename, unsigned int sampleRate=8000)
file.read (fileBuffer,length);
file.close();
// Decode file.ul
// expandedsize is the number of bytes, not the number of int
// expandedsize should be exactly two time more, else failed
......@@ -145,7 +166,7 @@ AudioFile::loadFile(const std::string& filename, unsigned int sampleRate=8000)
_buffer = bufferTmp; // just send the buffer pointer;
bufferTmp = 0;
}
return true;
}
......@@ -24,7 +24,7 @@
#define __AUDIOFILE_H__
#include "audioloop.h"
#include "ulaw.h"
#include "audiocodec.h"
/**
@author Yan Morin <yan.morin@savoirfairelinux.com>
......@@ -42,7 +42,7 @@ public:
private:
std::string _filename;
Ulaw* _ulaw;
AudioCodec* _ulaw;
bool _start;
};
......
This diff is collapsed.
......@@ -119,6 +119,22 @@ class AudioRtpRTX : public ost::Thread, public ost::TimerPort {
* @return int The number of samples after the operation
*/
int downSampleData(int, int);
/** Pointer on function to handle codecs **/
void* handle_codec;
/**
* 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);
/**
* Destroy and close dynamically a codec (.so library)
* @param audiocodec The audio codec you want to unload
*/
void unloadCodec(AudioCodec* audiocodec);
};
///////////////////////////////////////////////////////////////////////////////
......
......@@ -22,65 +22,125 @@
#include <iostream>
#include "audiocodec.h"
#include "gsmcodec.h"
#include "alaw.h"
#include "ulaw.h"
#include "codecDescriptor.h"
#ifdef HAVE_SPEEX
/*#ifdef HAVE_SPEEX
#include "CodecSpeex.h"
#endif
#endif*/
CodecDescriptorMap::CodecDescriptorMap()
CodecDescriptor::CodecDescriptor()
{
_codecMap[PAYLOAD_CODEC_ALAW] = new Alaw();
_codecMap[PAYLOAD_CODEC_ULAW] = new Ulaw();
_codecMap[PAYLOAD_CODEC_GSM] = new Gsm();
// Default codecs
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
#ifdef HAVE_SPEEX
_codecMap[PAYLOAD_CODEC_SPEEX] = new CodecSpeex(PAYLOAD_CODEC_SPEEX); // TODO: this is a variable payload!
#endif
// theses one are not implemented yet..
// _codecMap[PAYLOAD_CODEC_ILBC] = Ilbc();
// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
// _codecMap[PAYLOAD_CODEC_SPEEX] = Speex();
}
AudioCodec*
CodecDescriptorMap::getCodec(CodecType payload)
void
CodecDescriptor::init()
{
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
// _codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
}
std::string&
CodecDescriptor::getCodecName(CodecType payload)
{
CodecMap::iterator iter = _codecMap.find(payload);
if (iter!=_codecMap.end()) {
return (iter->second);
}
return NULL;
//return ;
}
void
CodecDescriptorMap::setActive(const std::string& codecDescription)
bool
CodecDescriptor::isSupported(CodecType payload)
{
CodecMap::iterator iter = _codecMap.begin();
while(iter!=_codecMap.end()) {
if (iter->second!=0) {
if (iter->second->getDescription() == codecDescription) {
iter->second->setActive(true);
break;
if (iter->first == payload) {
// codec is already in the map --> nothing to do
_debug("Codec with payload %i already in the map\n", payload);
//break;
return true;
}
}
iter++;
}
return false;
}
void
CodecDescriptorMap::setInactive(const std::string& codecDescription)
CodecDescriptor::removeCodec(CodecType payload)
{
CodecMap::iterator iter = _codecMap.begin();
while(iter!=_codecMap.end()) {
if (iter->second!=0) {
if (iter->second->getDescription() == codecDescription) {
iter->second->setActive(false);
if (iter->first == payload) {
_debug("Codec %s removed from the list", getCodecName(payload).data());
_codecMap.erase(iter);
break;
}
}
iter++;
}
}
void
CodecDescriptor::addCodec(CodecType payload)
{
}
double
CodecDescriptor::getBitRate(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW:
return 64;
case PAYLOAD_CODEC_GSM:
return 13.3;
case PAYLOAD_CODEC_ILBC_20:
return 15.2;
case PAYLOAD_CODEC_ILBC_30:
return 15.2;
}
return -1;
}
double
CodecDescriptor::getBandwidthPerCall(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW:
return 80;
case PAYLOAD_CODEC_GSM:
return 28.6;
case PAYLOAD_CODEC_ILBC_20:
return 30.8;
}
return -1;
}
int
CodecDescriptor::getSampleRate(CodecType payload)
{
switch(payload){
case PAYLOAD_CODEC_ULAW | PAYLOAD_CODEC_ALAW | PAYLOAD_CODEC_GSM | PAYLOAD_CODEC_ILBC_20:
return 8000;
}
return -1;
}
......@@ -2,6 +2,7 @@
* Copyright (C) 2004-2005 Savoir-Faire Linux inc.
* Author: Yan Morin <yan.morin@savoirfairelinux.com>
* Author: Laurielle Lea <laurielle.lea@savoirfairelinux.com>
* Author: Emmanuel Milou <emmanuel.milou@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
......@@ -25,6 +26,7 @@
#include <string>
#include <map>
#include "../global.h"
typedef enum {
// http://www.iana.org/assignments/rtp-parameters
// http://www.gnu.org/software/ccrtp/doc/refman/html/formats_8h.html#a0
......@@ -36,7 +38,8 @@ typedef enum {
PAYLOAD_CODEC_ALAW = 8,
// http://www.ietf.org/rfc/rfc3952.txt
// 97 iLBC/8000
PAYLOAD_CODEC_ILBC = 97,
PAYLOAD_CODEC_ILBC_20 = 97,
PAYLOAD_CODEC_ILBC_30 = 98,
// http://www.speex.org/drafts/draft-herlein-speex-rtp-profile-00.txt
// 97 speex/8000
// http://support.xten.com/viewtopic.php?p=8684&sid=3367a83d01fdcad16c7459a79859b08e
......@@ -45,33 +48,72 @@ typedef enum {
} CodecType;
#include "audiocodec.h"
typedef std::map<CodecType, AudioCodec*> CodecMap;
class CodecDescriptorMap {
/* A codec is identified by its payload. A payload is associated with a name. */
typedef std::map<CodecType, std::string> CodecMap;
class CodecDescriptor {
public:
/**
* Initialize all codec
*/
CodecDescriptorMap();
~CodecDescriptorMap() {};
CodecMap getMap() { return _codecMap; }
CodecDescriptor();
~CodecDescriptor() {};
CodecMap& getCodecMap() { return _codecMap; }
/**
* Get codec with is associated payload
* @param payload the payload associated with the payload
* same as getPayload()
* @return the address of the codec or 0
* @return the name of the codec
*/
AudioCodec* getCodec(CodecType payload);
std::string& getCodecName(CodecType payload);
void init();
/**
* Get codec with is associated payload
* Put a codec active, with it's codec's _description
* O(n) if not found where n is the number of element
* @param codecDescription is the same as with getCodec(number)->getDescription()
* Check in the map codec if the specified codec is supported
* @param payload unique identifier of a codec (RFC)
* @return true if the codec specified is supported
* false otherwise
*/
void setActive(const std::string& codecDescription);
void setInactive(const std::string& codecDescription);
bool isSupported(CodecType payload);
/**
* Remove the codec with payload payload from the list
* @param payload the codec to erase
*/
void removeCodec(CodecType payload);
/**
* Add a codec in the list.
* @param payload the codec to add
*/
void addCodec(CodecType payload);
/**
* Get the bit rate of the specified codec.
* @param payload The payload of the codec
* @return double The bit rate
*/
double getBitRate(CodecType payload);
/**
* Get the bandwidth for one call with the specified codec.
* The value has been calculated with the further information:
* RTp communication, SIP protocol (the value with IAX2 is very close), no RTCP, one simultaneous call, for one channel (the incoming one).
* @param payload The payload of the codec
* @return double The bandwidth
*/
double getBandwidthPerCall(CodecType payload);
/**
* Get the clock rate of the specified codec
* @param payload The payload of the codec
* @return int The clock rate of the specified codec
*/
int getSampleRate(CodecType payload);
private:
CodecMap _codecMap;
};
......
No preview for this file type
No preview for this file type
#EXTRA_DIST = ChangeLog INSTALL MACHINES MANIFEST README COPYRIGHT
noinst_LTLIBRARIES = libgsm.la
noinst_HEADERS = config.h gsm.h private.h proto.h toast.h unproto.h
libgsm_la_SOURCES = \
add.c\
gsm_create.c\
gsm_explode.c\
long_term.c\
short_term.c\
code.c\
gsm_decode.c\
gsm_implode.c\
lpc.c\