Skip to content
Snippets Groups Projects
Commit 03c7a8f7 authored by sfl's avatar sfl
Browse files

Merge commit 'origin/master' into video

parents c2333706 d792b6b0
No related branches found
No related tags found
No related merge requests found
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "dbus.h"
GQueue * codecQueue = NULL; GQueue * codecQueue = NULL;
gint gint
...@@ -68,8 +70,9 @@ void ...@@ -68,8 +70,9 @@ void
codec_set_active(gchar* name) codec_set_active(gchar* name)
{ {
codec_t * c = codec_list_get(name); codec_t * c = codec_list_get(name);
if(c){ if(c)
printf("%s set active/n", c->name); {
printf("%s set active\n", c->name);
c->is_active = TRUE; c->is_active = TRUE;
} }
} }
...@@ -112,6 +115,9 @@ codec_set_prefered_order(guint index) ...@@ -112,6 +115,9 @@ codec_set_prefered_order(guint index)
g_queue_push_head(codecQueue, prefered); g_queue_push_head(codecQueue, prefered);
} }
/**
*
*/
void void
codec_list_move_codec_up(guint index) codec_list_move_codec_up(guint index)
{ {
...@@ -121,13 +127,16 @@ 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); g_queue_push_nth(codecQueue, codec, index-1);
} }
// TEMP // DEBUG
int i; int i;
printf("\nCodec list\n"); printf("\nCodec list\n");
for(i=0; i < codecQueue->length; i++) for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name); printf("%s\n", codec_list_get_nth(i)->name);
} }
/**
*
*/
void void
codec_list_move_codec_down(guint index) codec_list_move_codec_down(guint index)
{ {
...@@ -137,9 +146,67 @@ 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); g_queue_push_nth(codecQueue, codec, index+1);
} }
// TEMP // PRINT
int i; int i;
printf("\nCodec list\n"); printf("\nCodec list\n");
for(i=0; i < codecQueue->length; i++) for(i=0; i < codecQueue->length; i++)
printf("%s\n", codec_list_get_nth(i)->name); 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); ...@@ -54,5 +54,6 @@ void codec_set_prefered_order(guint index);
void codec_list_move_codec_up(guint index); void codec_list_move_codec_up(guint index);
void codec_list_move_codec_down(guint index); void codec_list_move_codec_down(guint index);
void codec_list_update_to_daemon();
#endif #endif
...@@ -298,7 +298,8 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, gpointer data ...@@ -298,7 +298,8 @@ codec_active_toggled(GtkCellRendererToggle *renderer, gchar *path, gpointer data
else else
codec_set_inactive(name); 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) ...@@ -356,7 +357,8 @@ codec_move(gboolean moveUp, gpointer data)
else else
codec_list_move_codec_down(indice); 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() ...@@ -43,7 +43,8 @@ CodecDescriptor::init()
_codecMap[PAYLOAD_CODEC_ULAW] = "PCMU"; _codecMap[PAYLOAD_CODEC_ULAW] = "PCMU";
_codecMap[PAYLOAD_CODEC_GSM] = "GSM"; _codecMap[PAYLOAD_CODEC_GSM] = "GSM";
_codecMap[PAYLOAD_CODEC_ALAW] = "PCMA"; _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 ...@@ -51,9 +52,11 @@ void
CodecDescriptor::setDefaultOrder() CodecDescriptor::setDefaultOrder()
{ {
_codecOrder.clear(); _codecOrder.clear();
//_codecOrder.push_back(PAYLOAD_CODEC_ILBC_20);
_codecOrder.push_back(PAYLOAD_CODEC_ULAW); _codecOrder.push_back(PAYLOAD_CODEC_ULAW);
_codecOrder.push_back(PAYLOAD_CODEC_ALAW); _codecOrder.push_back(PAYLOAD_CODEC_ALAW);
_codecOrder.push_back(PAYLOAD_CODEC_GSM); _codecOrder.push_back(PAYLOAD_CODEC_GSM);
//_codecOrder.push_back(PAYLOAD_CODEC_SPEEX_8000);
} }
std::string& std::string&
...@@ -154,6 +157,15 @@ CodecDescriptor::getSampleRate(CodecType payload) ...@@ -154,6 +157,15 @@ CodecDescriptor::getSampleRate(CodecType payload)
case PAYLOAD_CODEC_ILBC_20: case PAYLOAD_CODEC_ILBC_20:
printf("PAYLOAD = %i\n", payload); printf("PAYLOAD = %i\n", payload);
return 8000; 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: default:
return -1; return -1;
} }
......
...@@ -1090,7 +1090,7 @@ ManagerImpl::initAudioCodec (void) ...@@ -1090,7 +1090,7 @@ ManagerImpl::initAudioCodec (void)
// init list of all supported codecs // init list of all supported codecs
_codecDescriptorMap.init(); _codecDescriptorMap.init();
// if the user never set the codec list, use the default one // if the user never set the codec list, use the default one
if(getConfigString(AUDIO, "Activecodecs") == ""){ if(getConfigString(AUDIO, "ActiveCodecs") == ""){
_codecDescriptorMap.setDefaultOrder(); _codecDescriptorMap.setDefaultOrder();
} }
// else retrieve the one he set in the config file // else retrieve the one he set in the config file
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment