Commit 03c7a8f7 authored by sfl's avatar sfl

Merge commit 'origin/master' into video

parents c2333706 d792b6b0
......@@ -22,6 +22,8 @@
#include <string.h>
#include <stdlib.h>
#include "dbus.h"
GQueue * codecQueue = NULL;
gint
......@@ -67,11 +69,12 @@ codec_list_add(codec_t * c)
void
codec_set_active(gchar* name)
{
codec_t * c = codec_list_get(name);
if(c){
printf("%s set active/n", c->name);
c->is_active = TRUE;
}
codec_t * c = codec_list_get(name);
if(c)
{
printf("%s set active\n", c->name);
c->is_active = TRUE;
}
}
void
......@@ -112,6 +115,9 @@ codec_set_prefered_order(guint index)
g_queue_push_head(codecQueue, prefered);
}
/**
*
*/
void
codec_list_move_codec_up(guint index)
{
......@@ -121,13 +127,16 @@ codec_list_move_codec_up(guint index)
g_queue_push_nth(codecQueue, codec, index-1);
}
// TEMP
// DEBUG
int i;
printf("\nCodec list\n");
for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name);
}
/**
*
*/
void
codec_list_move_codec_down(guint index)
{
......@@ -137,9 +146,67 @@ codec_list_move_codec_down(guint index)
g_queue_push_nth(codecQueue, codec, index+1);
}
// TEMP
// PRINT
int i;
printf("\nCodec list\n");
for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name);
}
/**
*
*/
void
codec_list_update_to_daemon()
{
// String listing of all codecs payloads
const gchar** codecList;
// Length of the codec list
int length = codecQueue->length;
// Initiate double array char list for one string
codecList = (void*)malloc(sizeof(void*));
// Get all codecs in queue
int i, c = 0;
printf("List of active codecs :");
for(i = 0; i < length; i++)
{
codec_t* currentCodec = codec_list_get_nth(i);
// Assert not null
if(currentCodec)
{
// Save only if active
if(currentCodec->is_active)
{
// Reallocate memory each time more than one active codec is found
if(c!=0)
codecList = (void*)realloc(codecList, (c+1)*sizeof(void*));
// Allocate memory for the payload
*(codecList+c) = (gchar*)malloc(sizeof(gchar*));
char payload[10];
// Put payload string in char array
sprintf(payload, "%d", currentCodec->_payload);
strcpy((char*)*(codecList+c), payload);
g_print(" %s", *(codecList+c));
c++;
}
}
}
// Allocate NULL array at the end for Dbus
codecList = (void*)realloc(codecList, (c+1)*sizeof(void*));
*(codecList+c) = NULL;
printf("\n");
// call dbus function with array of strings
dbus_set_active_codec_list(codecList);
// Delete memory
for(i = 0; i < c; i++) {
free((gchar*)*(codecList+i));
}
free(codecList);
}
......@@ -54,5 +54,6 @@ void codec_set_prefered_order(guint index);
void codec_list_move_codec_up(guint index);
void codec_list_move_codec_down(guint index);
void codec_list_update_to_daemon();
#endif
......@@ -298,7 +298,8 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, gpointer data
else
codec_set_inactive(name);
// TODO Perpetuate changes to the deamon
// Perpetuate changes to the deamon
codec_list_update_to_daemon();
}
/**
......@@ -356,7 +357,8 @@ codec_move(gboolean moveUp, gpointer data)
else
codec_list_move_codec_down(indice);
// TODO Perpetuate changes to the deamon
// Perpetuate changes to the deamon
codec_list_update_to_daemon();
}
/**
......
......@@ -43,7 +43,8 @@ CodecDescriptor::init()
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA";
_codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
//_codecMap[PAYLOAD_CODEC_ILBC_20] = "iLBC";
_codecMap[PAYLOAD_CODEC_SPEEX_8000] = "speex";;
}
......@@ -51,9 +52,11 @@ void
CodecDescriptor::setDefaultOrder()
{
_codecOrder.clear();
//_codecOrder.push_back(PAYLOAD_CODEC_ILBC_20);
_codecOrder.push_back(PAYLOAD_CODEC_ULAW);
_codecOrder.push_back(PAYLOAD_CODEC_ALAW);
_codecOrder.push_back(PAYLOAD_CODEC_GSM);
//_codecOrder.push_back(PAYLOAD_CODEC_SPEEX_8000);
}
std::string&
......@@ -154,6 +157,15 @@ CodecDescriptor::getSampleRate(CodecType payload)
case PAYLOAD_CODEC_ILBC_20:
printf("PAYLOAD = %i\n", payload);
return 8000;
case PAYLOAD_CODEC_SPEEX_8000:
printf("PAYLOAD = %i\n", payload);
return 8000;
case PAYLOAD_CODEC_SPEEX_16000:
printf("PAYLOAD = %i\n", payload);
return 16000;
case PAYLOAD_CODEC_SPEEX_32000:
printf("PAYLOAD = %i\n", payload);
return 32000;
default:
return -1;
}
......
......@@ -1090,7 +1090,7 @@ ManagerImpl::initAudioCodec (void)
// init list of all supported codecs
_codecDescriptorMap.init();
// if the user never set the codec list, use the default one
if(getConfigString(AUDIO, "Activecodecs") == ""){
if(getConfigString(AUDIO, "ActiveCodecs") == ""){
_codecDescriptorMap.setDefaultOrder();
}
// else retrieve the one he set in the config file
......
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