Commit 008c8846 authored by Emmanuel Lepage's avatar Emmanuel Lepage
parents 472564c1 f6dd011e
......@@ -102,7 +102,7 @@ void Account::setActiveCodecs(const std::vector<std::string> &list)
}
// update the codec string according to new codec selection
codecStr_ = ManagerImpl::serialize(list);
codecStr_ = ManagerImpl::join_string(list);
}
std::string Account::mapStateNumberToString(RegistrationState state)
......
......@@ -93,7 +93,7 @@ void IAXAccount::unserialize(const Conf::MappingNode &map)
map.getValue(CODECS_KEY, &codecStr_);
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::unserialize(codecStr_));
setActiveCodecs(ManagerImpl::split_string(codecStr_));
map.getValue(DISPLAY_NAME_KEY, &displayName_);
}
......
......@@ -1802,7 +1802,7 @@ std::string ManagerImpl::createConfigFile() const
return configdir + DIR_SEPARATOR_STR + PROGNAME + ".yml";
}
std::vector<std::string> ManagerImpl::unserialize(std::string s)
std::vector<std::string> ManagerImpl::split_string(std::string s)
{
std::vector<std::string> list;
std::string temp;
......@@ -1817,7 +1817,7 @@ std::vector<std::string> ManagerImpl::unserialize(std::string s)
return list;
}
std::string ManagerImpl::serialize(const std::vector<std::string> &v)
std::string ManagerImpl::join_string(const std::vector<std::string> &v)
{
std::ostringstream os;
std::copy(v.begin(), v.end(), std::ostream_iterator<std::string>(os, "/"));
......@@ -2531,7 +2531,7 @@ std::string ManagerImpl::getNewCallID()
std::vector<std::string> ManagerImpl::loadAccountOrder() const
{
return unserialize(preferences.getAccountOrder());
return split_string(preferences.getAccountOrder());
}
void ManagerImpl::loadDefaultAccountMap()
......@@ -2611,9 +2611,8 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
Sequence::const_iterator ip2ip = std::find_if(seq->begin(), seq->end(), isIP2IP);
if (ip2ip != seq->end()) {
MappingNode *node = dynamic_cast<MappingNode*>(*ip2ip);
if (node) {
if (node)
accountMap_[SIPAccount::IP2IP_PROFILE]->unserialize(*node);
}
}
// Initialize default UDP transport according to
......@@ -2734,13 +2733,13 @@ void ManagerImpl::setAddressbookSettings(const std::map<std::string, int32_t>& s
void ManagerImpl::setAddressbookList(const std::vector<std::string>& list)
{
addressbookPreference.setList(ManagerImpl::serialize(list));
addressbookPreference.setList(ManagerImpl::join_string(list));
saveConfig();
}
std::vector<std::string> ManagerImpl::getAddressbookList() const
{
return unserialize(addressbookPreference.getList());
return split_string(addressbookPreference.getList());
}
void ManagerImpl::setIPToIPForCall(const std::string& callID, bool IPToIP)
......
......@@ -571,9 +571,9 @@ class ManagerImpl {
* Required format: payloads separated with one slash.
* @return std::string The serializabled string
*/
static std::string serialize(const std::vector<std::string> &v);
static std::string join_string(const std::vector<std::string> &v);
static std::vector<std::string> unserialize(std::string v);
static std::vector<std::string> split_string(std::string v);
/**
* Ringtone option.
......
......@@ -268,7 +268,7 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
map.getValue(MAILBOX_KEY, &mailBox_);
map.getValue(CODECS_KEY, &codecStr_);
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::unserialize(codecStr_));
setActiveCodecs(ManagerImpl::split_string(codecStr_));
map.getValue(RINGTONE_PATH_KEY, &ringtonePath_);
map.getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_);
......
......@@ -667,8 +667,14 @@ void SIPVoIPLink::cancelKeepAliveTimer(pj_timer_entry& timer)
bool isValidIpAddress(const std::string &address)
{
size_t pos = address.find(":");
std::string address_without_port(address);
if (pos != std::string::npos)
address_without_port = address.substr(0, pos);
DEBUG("Testing address %s", address_without_port.c_str());
struct sockaddr_in sa;
int result = inet_pton(AF_INET, address.data(), &(sa.sin_addr));
int result = inet_pton(AF_INET, address_without_port.data(), &(sa.sin_addr));
return result != 0;
}
......@@ -1629,8 +1635,10 @@ void update_contact_header(pjsip_regc_cbparam *param, SIPAccount *account)
// TODO: make this based on transport type
// with pjsip_transport_get_default_port_for_type(tp_type);
if (uri->port == 0)
if (uri->port == 0) {
ERROR("Port is 0 in uri");
uri->port = DEFAULT_SIP_PORT;
}
std::string recvContactHost(uri->host.ptr, uri->host.slen);
std::stringstream ss;
......
......@@ -29,11 +29,16 @@
*/
#include <iostream>
#include <iterator>
#include <algorithm>
#include <math.h>
#include "resamplertest.h"
ResamplerTest::ResamplerTest() :
CppUnit::TestCase("Resampler module test"), inputBuffer(), outputBuffer()
{}
void ResamplerTest::setUp()
{
......@@ -44,6 +49,16 @@ void ResamplerTest::tearDown()
}
namespace {
template <typename T>
void print_buffer(T &buffer)
{
std::copy(buffer.begin(), buffer.end(),
std::ostream_iterator<SFLDataFormat>(std::cout, ", "));
std::cout << std::endl;
}
}
void ResamplerTest::testUpsamplingRamp()
{
// generate input samples and store them in inputBuffer
......@@ -59,15 +74,11 @@ void ResamplerTest::testUpsamplingRamp()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingRamp()
......@@ -84,15 +95,11 @@ void ResamplerTest::testDownsamplingRamp()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testUpsamplingTriangle()
......@@ -109,15 +116,11 @@ void ResamplerTest::testUpsamplingTriangle()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingTriangle()
......@@ -134,15 +137,11 @@ void ResamplerTest::testDownsamplingTriangle()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testUpsamplingSine()
{
......@@ -159,15 +158,11 @@ void ResamplerTest::testUpsamplingSine()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::testDownsamplingSine()
......@@ -185,36 +180,29 @@ void ResamplerTest::testDownsamplingSine()
std::copy(inputBuffer.begin(), inputBuffer.begin() + tmpInputBuffer.size(), tmpInputBuffer.begin());
std::cout << "Input Buffer" << std::endl;
for(int i = 0; i < tmpInputBuffer.size(); i++)
std::cout << tmpInputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpInputBuffer);
std::copy(outputBuffer.begin(), outputBuffer.begin() + tmpOutputBuffer.size(), tmpOutputBuffer.begin());
std::cout << "Output Buffer" << std::endl;
for(int i = 0; i < tmpOutputBuffer.size(); i++)
std::cout << tmpOutputBuffer[i] << ", ";
std::cout << std::endl;
print_buffer(tmpOutputBuffer);
}
void ResamplerTest::generateRamp()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)i;
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = i;
}
void ResamplerTest::generateTriangularSignal()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)(i*10);
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = i * 10;
}
void ResamplerTest::generateSineSignal()
{
for(int i = 0; i < inputBuffer.size(); i++) {
inputBuffer[i] = (SFLDataFormat)(1000.0 * sin((double)i));
}
for (size_t i = 0; i < inputBuffer.size(); ++i)
inputBuffer[i] = (SFLDataFormat) (1000.0 * sin(i));
}
void ResamplerTest::performUpsampling(SamplerateConverter &converter)
......@@ -222,8 +210,7 @@ void ResamplerTest::performUpsampling(SamplerateConverter &converter)
LowSmplrBuffer tmpInputBuffer;
HighSmplrBuffer tmpOutputBuffer;
int i, j;
for(i = 0, j = 0; i < (inputBuffer.size() / 2); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
for (size_t i = 0, j = 0; i < (inputBuffer.size() / 2); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
std::copy(inputBuffer.begin() + i, inputBuffer.begin() + tmpInputBuffer.size() + i, tmpInputBuffer.begin());
converter.resample(tmpInputBuffer.data(), tmpOutputBuffer.data(), tmpOutputBuffer.size(), 8000, 16000, tmpInputBuffer.size());
std::copy(tmpOutputBuffer.begin(), tmpOutputBuffer.end(), outputBuffer.begin() + j);
......@@ -235,8 +222,7 @@ void ResamplerTest::performDownsampling(SamplerateConverter &converter)
HighSmplrBuffer tmpInputBuffer;
LowSmplrBuffer tmpOutputBuffer;
int i, j;
for(i = 0, j = 0; i < inputBuffer.size(); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
for (size_t i = 0, j = 0; i < inputBuffer.size(); i += tmpInputBuffer.size(), j += tmpOutputBuffer.size()) {
std::copy(inputBuffer.begin() + i, inputBuffer.begin() + tmpInputBuffer.size() + i, tmpInputBuffer.begin());
converter.resample(tmpInputBuffer.data(), tmpOutputBuffer.data(), tmpOutputBuffer.size(), 16000, 8000, tmpInputBuffer.size());
std::copy(tmpOutputBuffer.begin(), tmpOutputBuffer.end(), outputBuffer.begin() + j);
......
......@@ -39,6 +39,7 @@
#include <tr1/array>
#include "audio/samplerateconverter.h"
#include "noncopyable.h"
#define MAX_BUFFER_LENGTH 40000
#define TMP_LOWSMPLR_BUFFER_LENGTH 160
......@@ -62,7 +63,7 @@ class ResamplerTest : public CppUnit::TestCase {
CPPUNIT_TEST_SUITE_END();
public:
ResamplerTest() : CppUnit::TestCase("Resampler module test") {}
ResamplerTest();
/*
* Code factoring - Common resources can be initialized here.
......@@ -107,6 +108,7 @@ class ResamplerTest : public CppUnit::TestCase {
void testDownsamplingSine();
private:
NON_COPYABLE(ResamplerTest);
/*
* Generate a ramp to be stored in inputBuffer
......@@ -142,12 +144,6 @@ private:
* Used to receive output samples
*/
std::tr1::array<SFLDataFormat, MAX_BUFFER_LENGTH> outputBuffer;
/**
* Pointer to samplerate converter, may be reinitialized during tests
* don't keep a statically declared instance.
*/
SamplerateConverter *converter;
};
/* Register the test module */
......
......@@ -39,7 +39,6 @@
AddrBookHandle *addrbook = NULL;
/**
* Callback called after all book have been processed
*/
......@@ -93,7 +92,7 @@ void abook_init()
void *handle = dlopen(PLUGINS_DIR"/libevladdrbook.so", RTLD_LAZY);
if (handle == NULL) {
ERROR("Addressbook: Error: Could not load addressbook");
DEBUG("Did not load addressbook");
return;
}
......@@ -102,7 +101,7 @@ void abook_init()
#define LOAD(func) do { \
addrbook-> func = dlsym(handle, "addressbook_" #func); \
if (addrbook-> func == NULL) \
ERROR("Addressbook: Couldn't load " # func); \
ERROR("Couldn't load " # func); \
} while(0)
......
......@@ -115,10 +115,8 @@ call_selected_cb(GtkTreeSelection *sel, void* data UNUSED)
GtkTreeModel *model = gtk_tree_view_get_model(gtk_tree_selection_get_tree_view(sel));
GtkTreeIter iter;
if (!gtk_tree_selection_get_selected(sel, &model, &iter)) {
DEBUG("gtk_tree_selection_get_selected return non zero!!!!!!!!!!!!!!!!!!!!!!!!! stop selected callback\n");
if (!gtk_tree_selection_get_selected(sel, &model, &iter))
return;
}
if (active_calltree_tab == history_tab)
DEBUG("Current call tree is history");
......@@ -1048,6 +1046,11 @@ remove_conference(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *it
void calltree_remove_conference(calltab_t* tab, const conference_obj_t* conf)
{
if(conf == NULL) {
ERROR("Could not remove conference, conference pointer is NULL");
return;
}
ConferenceRemoveCtx context = {tab, conf};
GtkTreeStore *store = tab->store;
GtkTreeModel *model = GTK_TREE_MODEL(store);
......
......@@ -94,11 +94,11 @@ void conferencelist_add(calltab_t *tab, const conference_obj_t* conf)
}
void conferencelist_remove(calltab_t *tab, const gchar* const conf)
void conferencelist_remove(calltab_t *tab, const gchar* const conf_id)
{
DEBUG("ConferenceList: Remove conference %s", conf);
DEBUG("ConferenceList: Remove conference %s", conf_id);
if (conf == NULL) {
if (conf_id == NULL) {
ERROR("ConferenceList: Error: Conf id is NULL");
return;
}
......@@ -108,12 +108,10 @@ void conferencelist_remove(calltab_t *tab, const gchar* const conf)
return;
}
gchar *c = (gchar*) conferencelist_get(tab, conf);
conference_obj_t *c = conferencelist_get(tab, conf_id);
if (c == NULL) {
ERROR("ConferenceList: Error: Could not find conference %s", conf);
if (c == NULL)
return;
}
g_queue_remove(tab->conferenceQueue, c);
}
......@@ -129,10 +127,8 @@ conference_obj_t* conferencelist_get(calltab_t *tab, const gchar* const conf_id)
GList *c = g_queue_find_custom(tab->conferenceQueue, conf_id, is_confID_confstruct);
if (c == NULL) {
ERROR("ConferenceList: Error: Could not find conference %s", conf_id);
if (c == NULL)
return NULL;
}
return (conference_obj_t*) c->data;
}
......
......@@ -91,7 +91,6 @@
Get configuration settings of the IP2IP_PROFILE. They are sligthly different from account settings since no VoIP accounts are involved.
</tp:docstring>
<annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="MapStringString"/>
<!--<annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="MapStringString"/>-->
<arg type="a{ss}" name="details" direction="out" tp:type="String_String_Map">
<tp:docstring>
Available parameters are:
......@@ -447,6 +446,9 @@
<signal name="accountsChanged" tp:name-for-bindings="accountsChanged">
</signal>
<signal name="historyChanged" tp:name-for-bindings="historyChanged">
</signal>
<signal name="registrationStateChanged" tp:name-for-bindings="registrationStateChanged">
<arg type="s" name="accountID"/>
<arg type="i" name="registration_state"/>
......
This diff is collapsed.
......@@ -124,14 +124,14 @@ void set_slider_value(const gchar *device, gdouble newval)
if (g_strcmp0(device, "speaker") == 0) {
dev = DEVICE_SPEAKER;
DEBUG("Slider: Set value for speaker: %f\n", newval);
DEBUG("Set value for speaker: %f\n", newval);
}
else if (g_strcmp0(device, "mic") == 0) {
dev = DEVICE_MIC;
DEBUG("Slider: Set value for mic: %f\n", newval);
DEBUG("Set value for mic: %f\n", newval);
}
else {
ERROR("Slider: Unknown device: %s", device);
ERROR("Unknown device: %s", device);
return;
}
......@@ -148,14 +148,14 @@ void set_slider_no_update (const gchar * device, gdouble newval)
if (g_strcmp0(device, "speaker") == 0) {
dev = DEVICE_SPEAKER;
DEBUG("Slider: Set value no update for speaker: %f\n", newval);
DEBUG("Set value no update for speaker: %f\n", newval);
}
else if (g_strcmp0(device, "mic") == 0) {
dev = DEVICE_MIC;
DEBUG("Slider: Set value no update for mic: %f\n", newval);
DEBUG("Set value no update for mic: %f\n", newval);
}
else {
ERROR("Slider: Unknown device: %s", device);
ERROR("Unknown device: %s", device);
return;
}
......@@ -172,8 +172,6 @@ void set_slider_no_update (const gchar * device, gdouble newval)
void toggle_slider_mute_microphone(void)
{
DEBUG("Slider: Mute/Unmute toggle");
switch(device_state) {
case DEVICE_STATE_ACTIVE:
value[DEVICE_MIC] = gtk_range_get_value(GTK_RANGE(slider[DEVICE_MIC]));
......@@ -185,7 +183,7 @@ void toggle_slider_mute_microphone(void)
device_state = DEVICE_STATE_ACTIVE;
break;
default:
ERROR("Slider: Unknown state");
ERROR("Unknown state");
break;
}
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment