diff --git a/sflphone-client-gnome/src/accountlist.h b/sflphone-client-gnome/src/accountlist.h index 46103121e9f71556e9f86c0ed2291959eb6465f3..75943ada163a76d4acc026464d4c1c240220c4a3 100644 --- a/sflphone-client-gnome/src/accountlist.h +++ b/sflphone-client-gnome/src/accountlist.h @@ -82,8 +82,9 @@ typedef struct { GHashTable * properties; GPtrArray * credential_information; - /* The codec list */ + /* The codec lists */ GQueue *codecs; + GQueue *vcodecs; guint _messages_number; } account_t; diff --git a/sflphone-client-gnome/src/actions.c b/sflphone-client-gnome/src/actions.c index f825fc9333a1b8f24d1170450def21fdeb813f54..4a5e8ce7dd0ab8588f0d66672b3326051fb7a1b4 100644 --- a/sflphone-client-gnome/src/actions.c +++ b/sflphone-client-gnome/src/actions.c @@ -370,7 +370,12 @@ gboolean sflphone_init (GError **error) history = calltab_init (TRUE, HISTORY); account_list_init (); - codec_capabilities_load (); + if (!codecs_load ()) { + ERROR ("No codecs found"); + dbus_unregister (getpid()); + exit (1); + } + conferencelist_init (current_calls); conferencelist_init (history); @@ -391,9 +396,9 @@ void sflphone_fill_ip2ip_profile (void) ip2ip_profile = (GHashTable *) dbus_get_ip2_ip_details(); } -void sflphone_get_ip2ip_properties (GHashTable **properties) +GHashTable *sflphone_get_ip2ip_properties (void) { - *properties = ip2ip_profile; + return ip2ip_profile; } void @@ -1186,83 +1191,86 @@ sflphone_rec_call() void sflphone_fill_codec_list () { - - guint account_list_size; - guint i; - account_t *current = NULL; - - DEBUG ("SFLphone: Fill codec list"); - - account_list_size = account_list_get_size (); + guint i, account_list_size = account_list_get_size (); for (i=0; i<account_list_size; i++) { - current = account_list_get_nth (i); - - if (current) { - sflphone_fill_codec_list_per_account (¤t); - } + account_t *current = account_list_get_nth (i); + if (current) + sflphone_fill_codec_list_per_account (current); } - } -void sflphone_fill_codec_list_per_account (account_t **account) +static void sflphone_fill_codec_list_per_account_cat (account_t *account, gboolean is_audio) { - gchar **order; - gchar** pl; GQueue *codeclist; - gboolean active = FALSE; - - order = (gchar**) dbus_get_active_audio_codec_list ( (*account)->accountID); - - codeclist = (*account)->codecs; + order = is_audio + ? dbus_get_active_audio_codec_list (account->accountID) + : dbus_get_active_video_codec_list (account->accountID); + + if (is_audio) { + if (!account->codecs) + account->codecs = g_queue_new(); + codeclist = account->codecs; + } else { + if (!account->vcodecs) + account->vcodecs = g_queue_new(); + codeclist = account->vcodecs; + } - // First clean the list - codec_list_clear (&codeclist); + g_queue_clear (codeclist); if (! (*order)) ERROR ("SFLphone: No codec list provided"); + GQueue* codecs = is_audio ? get_audio_codecs_list() : get_video_codecs_list(); + gchar **pl; for (pl=order; *pl; pl++) { - codec_t * cpy = NULL; - - // Each account will have a copy of the system-wide capabilities - codec_create_new_from_caps (codec_list_get_by_payload ( (gconstpointer) (size_t) atoi (*pl), NULL), &cpy); - - if (cpy) { - cpy->is_active = TRUE; - codec_list_add (cpy, &codeclist); - } else - ERROR ("SFLphone: Couldn't find codec"); + codec_t *orig; + if (is_audio) + orig = codec_list_get_by_payload (atoi(*pl), codecs); + else + orig = codec_list_get_by_name(*pl, codecs); + codec_t *c = codec_create_new_from_caps (orig); + + if (c) + g_queue_push_tail (codeclist, (gpointer) c); + else + ERROR ("SFLphone: Couldn't find codec %s %p", *pl, orig); + g_free(*pl); } + g_free(order); - // Test here if we just added some active codec. - active = (codeclist->length == 0) ? TRUE : FALSE; - - guint caps_size = codec_list_get_size (), i=0; + // if no codecs were added, activate them all + gboolean active = codeclist->length == 0; + guint i, caps_size = g_queue_get_length(codecs); for (i=0; i<caps_size; i++) { - - codec_t * current_cap = capabilities_get_nth (i); - + codec_t * codec = g_queue_peek_nth (codecs, i); + gboolean found; // Check if this codec has already been enabled for this account - if (codec_list_get_by_payload ( (gconstpointer) (size_t) (current_cap->_payload), codeclist) == NULL) { - // codec_t *cpy; - // codec_create_new_from_caps (current_cap, &cpy); - current_cap->is_active = active; - codec_list_add (current_cap, &codeclist); - } else { + if (is_audio) + found = codec_list_get_by_payload (codec->payload, codeclist) != NULL; + else + found = codec_list_get_by_name(codec->name, codeclist) != NULL; + if (!found) { + codec->is_active = active; + g_queue_push_tail (codeclist, (gpointer)codec); } - } +} - (*account)->codecs = codeclist; +void sflphone_fill_codec_list_per_account (account_t *account) +{ + sflphone_fill_codec_list_per_account_cat(account, TRUE); + sflphone_fill_codec_list_per_account_cat(account, FALSE); } + void sflphone_fill_call_list (void) { - gchar** calls = (gchar**) dbus_get_call_list(); + gchar** calls = dbus_get_call_list(); GHashTable *call_details; callable_obj_t *c; gchar *callID; diff --git a/sflphone-client-gnome/src/actions.h b/sflphone-client-gnome/src/actions.h index 65139d3941a93b2c95cf6cca9383714ba19f62a6..86d3df8ceacd87a06895c530e4ffaab4911c9f7b 100644 --- a/sflphone-client-gnome/src/actions.h +++ b/sflphone-client-gnome/src/actions.h @@ -172,7 +172,7 @@ void sflphone_fill_ip2ip_profile (void); * @return The internal hash table representing * the settings for the ip2ip profile. */ -void sflphone_get_ip2ip_properties (GHashTable **properties); +GHashTable *sflphone_get_ip2ip_properties (void); /** * Initialize the accounts data structure @@ -192,7 +192,7 @@ void sflphone_set_current_account(); */ void sflphone_fill_codec_list (); -void sflphone_fill_codec_list_per_account (account_t **); +void sflphone_fill_codec_list_per_account (account_t *); void sflphone_add_participant(); diff --git a/sflphone-client-gnome/src/callable_obj.c b/sflphone-client-gnome/src/callable_obj.c index 2c416005bb48b6172b4bec4ec4b16a053852fcd4..0531448078ac7e9578ab0dcb6e4d77f8df36938b 100644 --- a/sflphone-client-gnome/src/callable_obj.c +++ b/sflphone-client-gnome/src/callable_obj.c @@ -96,19 +96,13 @@ gchar* call_get_peer_number (const gchar *format) gchar* call_get_audio_codec (callable_obj_t *obj) { - gchar *audio_codec = ""; - codec_t *codec; - gchar *format =""; - int samplerate; - + gchar *format = NULL; if (obj) { - audio_codec = dbus_get_current_audio_codec_name (obj); - codec = codec_list_get_by_name (audio_codec, NULL); - - if (codec) { - samplerate = codec->sample_rate; - format = g_markup_printf_escaped ("%s/%i", audio_codec, samplerate); - } + gchar *audio_codec = dbus_get_current_audio_codec_name (obj); + codec_t *codec = codec_list_get_by_name (audio_codec, get_audio_codecs_list()); + if (codec) + format = g_markup_printf_escaped ("%s/%s", audio_codec, codec->sample_rate); + g_free(audio_codec); } return format; diff --git a/sflphone-client-gnome/src/codeclist.c b/sflphone-client-gnome/src/codeclist.c index 9f52a684160a9c11af97931a769364f0cb076ac8..a3a8d319c19926f747f7cb3012623ec73f8ac467 100644 --- a/sflphone-client-gnome/src/codeclist.c +++ b/sflphone-client-gnome/src/codeclist.c @@ -32,333 +32,220 @@ #include <string.h> #include <stdlib.h> +#include <stdint.h> #include <unistd.h> #include "dbus.h" -static GQueue * codecsCapabilities = NULL; +static GQueue audioCodecs = G_QUEUE_INIT; +static GQueue videoCodecs = G_QUEUE_INIT; -gint -is_name_codecstruct (gconstpointer a, gconstpointer b) -{ - codec_t * c = (codec_t *) a; - - if (strcmp (c->name, (const gchar *) b) ==0) - return 0; - else - return 1; -} - -gint -is_payload_codecstruct (gconstpointer a, gconstpointer b) +/* + * Instanciate a new codec + * + * @param payload The unique RTP payload + * @return codec The new codec instance, or NULL + */ +static codec_t *codec_create (gint payload, gchar **specs) { - codec_t * c = (codec_t *) a; + codec_t *codec = g_new0 (codec_t, 1); + if (!codec) { + g_strfreev(specs); + return NULL; + } - if (c->_payload == GPOINTER_TO_INT (b)) - return 0; - else - return 1; -} + codec->payload = payload; + codec->name = specs[0]; + codec->bitrate = specs[1]; + codec->sample_rate = specs[2]; + codec->is_active = TRUE; -void codec_list_init (GQueue **queue) -{ + g_free(specs); - // Create the queue object that will contain the audio codecs - *queue = g_queue_new(); + return codec; } -void codec_capabilities_load (void) +static gboolean codecs_audio_load (void) { - guint payload; - - // Create the queue object that will contain the global list of audio codecs - if (codecsCapabilities != NULL) - g_queue_free (codecsCapabilities); - - codecsCapabilities = g_queue_new(); - - // This is a global list inherited by all accounts - gchar **codecs = dbus_audio_codec_list (); + gchar **codecs = dbus_audio_codec_list(); gchar **codecs_orig = codecs; - if (codecs != NULL) { - // Add the codecs in the list - for (; *codecs; codecs++) { - - codec_t *c; - payload = atoi (*codecs); - gchar **specs = dbus_audio_codec_details (payload); - codec_create_new_with_specs (payload, specs, TRUE, &c); - g_strfreev(specs); - g_queue_push_tail (codecsCapabilities, (gpointer*) c); - g_free(*codecs); - } - g_free(codecs_orig); + if (!codecs) + return FALSE; + + // Add the codecs in the list + for (; *codecs; codecs++) { + int payload = atoi(*codecs); + codec_t *c = codec_create(payload, dbus_audio_codec_details(payload)); + if (c) + g_queue_push_tail (&audioCodecs, (gpointer*) c); + g_free(*codecs); } + g_free(codecs_orig); // If we didn't load any codecs, problem ... - if (g_queue_get_length (codecsCapabilities) == 0) { - - // Error message - ERROR ("No audio codecs found"); - dbus_unregister (getpid()); - exit (1); + if (g_queue_get_length (&audioCodecs) == 0) { + return FALSE; } -} - -void account_create_codec_list (account_t **acc) -{ - GQueue *_codecs; - - _codecs = (*acc)->codecs; - if (_codecs != NULL) - g_queue_free (_codecs); - - _codecs = g_queue_new (); - - (*acc)->codecs = _codecs; + return TRUE; } -void codec_create_new (gint payload, gboolean active, codec_t **c) -{ - - codec_t *codec; - gchar **specs; - - codec = g_new0 (codec_t, 1); - codec->_payload = payload; - specs = (gchar **) dbus_audio_codec_details (payload); - codec->name = specs[0]; - codec->sample_rate = atoi (specs[1]); - codec->_bitrate = atoi (specs[2]); - codec->_bandwidth = atoi (specs[3]); - codec->is_active = active; - - *c = codec; -} - -void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, codec_t **c) -{ - - codec_t *codec; - - codec = g_new0 (codec_t, 1); - codec->_payload = payload; - codec->name = strdup(specs[0]); - codec->sample_rate = atoi (specs[1]); - codec->_bitrate = atoi (specs[2]); - codec->_bandwidth = atoi (specs[3]); - codec->is_active = active; - - *c = codec; -} - -void codec_create_new_from_caps (codec_t *original, codec_t **copy) +static gboolean codecs_video_load (void) { + gchar **codecs = dbus_video_codec_list(); + gchar **codecs_orig = codecs; - codec_t *codec; + if (!codecs) + return FALSE; - if (!original) { - *copy = NULL; - return; + int payload = 96; // dynamic payloads + // Add the codecs in the list + for (; *codecs; codecs++) { + codec_t *c = codec_create(payload++, dbus_video_codec_details(*codecs)); + if (c) + g_queue_push_tail (&videoCodecs, (gpointer*) c); + g_free(*codecs); } + g_free(codecs_orig); - codec = g_new0 (codec_t, 1); - codec->_payload = original->_payload; - codec->name = original->name; - codec->sample_rate = original->sample_rate; - codec->_bitrate = original->_bitrate; - codec->_bandwidth = original->_bandwidth; - codec->is_active = original->is_active; + // If we didn't load any codecs, problem ... + if (g_queue_get_length (&videoCodecs) == 0) { + return FALSE; + } - *copy = codec; + return TRUE; } - -void codec_list_clear (GQueue **queue) +gboolean codecs_load(void) { - - if (*queue != NULL) - g_queue_free (*queue); - - *queue = g_queue_new(); + return codecs_audio_load() && codecs_video_load(); } -/*void codec_list_clear (void) { - - g_queue_free (codecsCapabilities); - codecsCapabilities = g_queue_new(); -}*/ - -void codec_list_add (codec_t * c, GQueue **queue) +static void codec_free(gpointer data, gpointer user_data UNUSED) { - - // Add a codec to a specific list - g_queue_push_tail (*queue, (gpointer *) c); + codec_t *codec = (codec_t*)data; + g_free(codec->name); + g_free(codec->sample_rate); + g_free(codec->bitrate); } -void codec_set_active (codec_t **c) +void codecs_unload (void) { - - if (c) { - DEBUG ("%s set active", (*c)->name); - (*c)->is_active = TRUE; - } + g_queue_foreach(&audioCodecs, codec_free, NULL); } -void codec_set_inactive (codec_t **c) +codec_t *codec_create_new_from_caps (codec_t *original) { + if (!original) + return NULL; - if (c) { - DEBUG ("%s set active", (*c)->name); - (*c)->is_active = FALSE; + codec_t *codec = g_new0 (codec_t, 1); + if (codec) { + memcpy(codec, original, sizeof *codec); + codec->is_active = TRUE; } + + return codec; } -guint codec_list_get_size () +static gint +is_name_codecstruct (gconstpointer a, gconstpointer b) { - - // The system wide codec list and the one per account have exactly the same size - // The only difference may be the order and the enabled codecs - return g_queue_get_length (codecsCapabilities); + return strcmp (((codec_t*)a)->name, (const gchar *) b); } codec_t* codec_list_get_by_name (gconstpointer name, GQueue *q) { - - // If NULL is passed as argument, we look into the global capabilities - if (q == NULL) - q = codecsCapabilities; - GList * c = g_queue_find_custom (q, name, is_name_codecstruct); - - if (c) - return (codec_t *) c->data; - else - return NULL; -} - -codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q) -{ - - // If NULL is passed as argument, we look into the global capabilities - if (q == NULL) - q = codecsCapabilities; - - GList * c = g_queue_find_custom (q, payload, is_payload_codecstruct); - - if (c) - return (codec_t *) c->data; - else - return NULL; + return c ? (codec_t *) c->data : NULL; } -codec_t* codec_list_get_nth (guint index, GQueue *q) +static gint +is_payload_codecstruct (gconstpointer a, gconstpointer b) { - return g_queue_peek_nth (q, index); + return ((codec_t*)a)->payload != GPOINTER_TO_INT (b); } -codec_t* capabilities_get_nth (guint index) +codec_t* codec_list_get_by_payload (int payload, GQueue *q) { - - return g_queue_peek_nth (codecsCapabilities, index); + GList * c = g_queue_find_custom (q, (gconstpointer)(uintptr_t)payload, is_payload_codecstruct); + return c ? (codec_t *) c->data : NULL; } void codec_set_prefered_order (guint index, GQueue *q) { - - codec_t * prefered = codec_list_get_nth (index, q); + codec_t * prefered = g_queue_peek_nth (q, index); g_queue_pop_nth (q, index); g_queue_push_head (q, prefered); } -void codec_list_move_codec_up (guint index, GQueue **q) +void codec_list_move (guint index, GQueue *q, gboolean up) { + guint already = up ? 0 : q->length; + gint new = up ? index - 1 : index + 1; - DEBUG ("Codec list Size: %i \n", codec_list_get_size ()); - - GQueue *tmp = *q; - - if (index != 0) { - gpointer codec = g_queue_pop_nth (tmp, index); - g_queue_push_nth (tmp, codec, index-1); - } - - *q = tmp; - -} - -void codec_list_move_codec_down (guint index, GQueue **q) -{ - - DEBUG ("Codec list Size: %i \n",codec_list_get_size()); - - GQueue *tmp = *q; - - if (index != tmp->length) { - gpointer codec = g_queue_pop_nth (tmp, index); - g_queue_push_nth (tmp, codec, index+1); - } - - *q = tmp; + if (index == already) + return; + gpointer codec = g_queue_pop_nth (q, index); + g_queue_push_nth (q, codec, new); } -void codec_list_update_to_daemon (account_t *acc) +static void codec_list_update_to_daemon_cat (account_t *acc, gboolean is_audio) { + gchar** codecList = NULL; - // String listing codecs payloads - const gchar** codecList; - - // Length of the codec list - int length = acc->codecs->length; - - // Initiate double array char list for one string - codecList = (void*) malloc (sizeof (void*)); + GQueue *q = is_audio ? acc->codecs : acc->vcodecs; + int length = q->length; // Get all codecs in queue - int c = 0; - int i = 0; + int i, c = 0; for (i = 0; i < length; i++) { - codec_t* currentCodec = codec_list_get_nth (i, acc->codecs); - - // 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); - c++; - } + codec_t* currentCodec = g_queue_peek_nth (q, i); + + // Save only if active + if (currentCodec && currentCodec->is_active) { + codecList = (void*) realloc (codecList, (c+1) *sizeof (void*)); + + if (is_audio) + * (codecList+c) = g_strdup_printf("%d", currentCodec->payload); + else + * (codecList+c) = g_strdup(currentCodec->name); + c++; } } // Allocate NULL array at the end for Dbus codecList = (void*) realloc (codecList, (c+1) *sizeof (void*)); * (codecList+c) = NULL; + c++; // call dbus function with array of strings - dbus_set_active_audio_codec_list (codecList, acc->accountID); + if (is_audio) + dbus_set_active_audio_codec_list ((const gchar**)codecList, acc->accountID); + else + dbus_set_active_video_codec_list ((const gchar**)codecList, acc->accountID); // Delete memory - for (i = 0; i < c; i++) { - free ( (gchar*) * (codecList+i)); - } - + for (i = 0; i < c; i++) + free (*(codecList+i)); free (codecList); } -GQueue* get_system_codec_list (void) +void codec_list_update_to_daemon (account_t *acc) +{ + codec_list_update_to_daemon_cat (acc, TRUE); + codec_list_update_to_daemon_cat (acc, FALSE); +} + +GQueue* get_audio_codecs_list (void) +{ + return &audioCodecs; +} + +GQueue* get_video_codecs_list (void) { - return codecsCapabilities; + return &videoCodecs; } diff --git a/sflphone-client-gnome/src/codeclist.h b/sflphone-client-gnome/src/codeclist.h index fdfda4fe11ae26c348d9d2b69e0d5ec797600898..691c345837e26d5814d6d30af944dbf1c3889fec 100644 --- a/sflphone-client-gnome/src/codeclist.h +++ b/sflphone-client-gnome/src/codeclist.h @@ -39,17 +39,15 @@ typedef struct { /** Payload of the codec */ - gint _payload; + gint payload; /** Tells if the codec has been activated */ gboolean is_active; /** String description */ gchar * name; /** Sample rate */ - int sample_rate; + gchar * sample_rate; /** Bitrate */ - gdouble _bitrate; - /** Bandwidth */ - gdouble _bandwidth; + gchar * bitrate; } codec_t; /** @struct codec_t @@ -58,49 +56,16 @@ typedef struct { * This match how the server internally works and the dbus API to save and retrieve the codecs details. */ -/** - * This function initialize a specific codec list. - */ -void codec_list_init (GQueue **q); - /** * This function initialize the system wide codec list. + * @return FALSE if initialization failed */ -void codec_capabilities_load (void); - -/** - * This function empty and free a specific codec list. - */ -void codec_list_clear (GQueue **q); +gboolean codecs_load (void); /** * This function empty and free the system wide codec list. */ -void system_codec_list_clear (void); - -/** - * This function append an codec to list. - * @param c The codec you want to add - */ -void codec_list_add (codec_t * c, GQueue **q); - -/** - * Set a codec active. An active codec will be used for codec negociation - * @param name The string description of the codec - */ -void codec_set_active (codec_t **c); - -/** - * Set a codec inactive. An active codec won't be used for codec negociation - * @param name The string description of the codec - */ -void codec_set_inactive (codec_t **c); - -/** - * Return the number of codecs in the list - * @return guint The number of codecs in the list - */ -guint codec_list_get_size(); +void codecs_unload (void); /** * Return the codec structure that corresponds to the string description @@ -109,14 +74,6 @@ guint codec_list_get_size(); */ codec_t * codec_list_get_by_name (gconstpointer name, GQueue *q); -/** - * Return the codec at the nth position in the list - * @param index The position of the codec you want - * @return codec_t* A codec or NULL - */ -codec_t* codec_list_get_nth (guint index, GQueue *q); -codec_t* capabilities_get_nth (guint index); - /** * Set the prefered codec first in the codec list * @param index The position in the list of the prefered codec @@ -126,54 +83,22 @@ void codec_set_prefered_order (guint index, GQueue *q); /** * Move the codec from an unit up in the codec_list * @param index The current index in the list + * @param q + * @param up true if moving upwards */ -void codec_list_move_codec_up (guint index, GQueue **q); - -/** - * Move the codec from an unit down in the codec_list - * @param index The current index in the list - */ -void codec_list_move_codec_down (guint index, GQueue **q); +void codec_list_move (guint index, GQueue *q, gboolean up); /** * Notify modifications on codecs to the server */ void codec_list_update_to_daemon (account_t *acc); -codec_t* codec_list_get_by_payload (gconstpointer payload, GQueue *q); +codec_t* codec_list_get_by_payload (int payload, GQueue *q); -GQueue* get_system_codec_list (void); +GQueue* get_video_codecs_list (void); -/** - * Instanciate a new codecs with the given payload. - * Fetches codec specification through D-Bus - * - * @param payload The unique RTP payload - * @param active Whether or not this codec should active (checked) - * @param c A pointer to receive the new codec instance - */ -void codec_create_new (gint payload, gboolean active, codec_t **c); - -/* - * Instanciate a new codec with the given specification - * - * @param payload The unique RTP payload - * @param specs A list of codec specifications. Ordered: name, sample rate, bit rate, bandwith - * @param active Whether or not this codec should active (checked) - * @param c A pointer to receive the new codec instance - */ -void codec_create_new_with_specs (gint payload, gchar **specs, gboolean active, codec_t **c); - - -void codec_create_new_from_caps (codec_t *original, codec_t **copy); -/* - * Attach a codec list to a specific account - * - * @param acc A pointer on the account to modify - */ -void account_create_codec_list (account_t **acc); +GQueue* get_audio_codecs_list (void); +codec_t *codec_create_new_from_caps (codec_t *original); #endif - - diff --git a/sflphone-client-gnome/src/config/accountconfigdialog.c b/sflphone-client-gnome/src/config/accountconfigdialog.c index 78c8ccb554f17ddbb34aa2f7192f197965f14f50..45aa50635690d5c6a7a394f14e426202b8382e3b 100644 --- a/sflphone-client-gnome/src/config/accountconfigdialog.c +++ b/sflphone-client-gnome/src/config/accountconfigdialog.c @@ -1254,7 +1254,7 @@ static GtkWidget* create_audiocodecs_configuration (account_t *currentAccount) return ret; } -GtkWidget* create_videocodecs_configuration (account_t **a) +GtkWidget* create_videocodecs_configuration (account_t *a) { // Main widget @@ -1329,7 +1329,7 @@ void show_account_window (account_t * currentAccount) currentAccount = g_new0 (account_t, 1); currentAccount->properties = dbus_get_account_details (NULL); currentAccount->accountID = "new"; - sflphone_fill_codec_list_per_account (¤tAccount); + sflphone_fill_codec_list_per_account (currentAccount); } dialog = GTK_DIALOG (gtk_dialog_new_with_buttons (_ ("Account settings"), @@ -1367,7 +1367,7 @@ void show_account_window (account_t * currentAccount) gtk_notebook_page_num (GTK_NOTEBOOK (notebook), audiocodecs_tab); /* Video Codecs */ - videocodecs_tab = create_videocodecs_configuration (¤tAccount); + videocodecs_tab = create_videocodecs_configuration (currentAccount); gtk_notebook_append_page (GTK_NOTEBOOK (notebook), videocodecs_tab, gtk_label_new (_ ("Video"))); gtk_notebook_page_num (GTK_NOTEBOOK (notebook), videocodecs_tab); diff --git a/sflphone-client-gnome/src/config/audioconf.c b/sflphone-client-gnome/src/config/audioconf.c index 42f6fc3dcbe0129d1a016c879a72dd516a625b88..a0f467dca0eef7e1631e74a5f881e3cf968aa930 100644 --- a/sflphone-client-gnome/src/config/audioconf.c +++ b/sflphone-client-gnome/src/config/audioconf.c @@ -70,40 +70,35 @@ static void active_is_always_recording (void); */ static void preferences_dialog_fill_codec_list (account_t *a) { - GtkListStore *codecStore; GtkTreeIter iter; - GQueue *current; // Get model of view and clear it codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); gtk_list_store_clear (codecStore); - current = a ? a->codecs : get_system_codec_list (); + GQueue *list = a ? a->codecs : get_audio_codecs_list (); // Insert codecs unsigned int i; - for (i = 0; i < current->length; i++) { - codec_t *c = codec_list_get_nth (i, current); + for (i = 0; i < list->length; i++) { + codec_t *c = g_queue_peek_nth (list, i); if (c) { DEBUG ("%s", c->name); gtk_list_store_append (codecStore, &iter); - gchar *samplerate = g_strdup_printf ("%d kHz", c->sample_rate/1000); - gchar *bitrate = g_strdup_printf ("%.1f kbps", c->_bitrate); - gchar *bw = g_strdup_printf ("%.1f kbps", c->_bandwidth); + gchar *samplerate = g_strdup_printf ("%s kHz", c->sample_rate); + gchar *bitrate = g_strdup_printf ("%s kbps", c->bitrate); gtk_list_store_set (codecStore, &iter, COLUMN_CODEC_ACTIVE, c->is_active, - COLUMN_CODEC_NAME, c->name, + COLUMN_CODEC_NAME, c->name, COLUMN_CODEC_FREQUENCY, samplerate, COLUMN_CODEC_BITRATE, bitrate, - COLUMN_CODEC_BANDWIDTH, bw, -1); g_free(samplerate); g_free(bitrate); - g_free(bw); } } } @@ -533,11 +528,11 @@ codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoin printf ("%i\n", g_queue_get_length (acc->codecs)); if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"8 kHz") ==0)) - codec = codec_list_get_by_payload ( (gconstpointer) 110, acc->codecs); + codec = codec_list_get_by_payload (110, acc->codecs); else if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"16 kHz") ==0)) - codec = codec_list_get_by_payload ( (gconstpointer) 111, acc->codecs); + codec = codec_list_get_by_payload (111, acc->codecs); else if ( (g_strcasecmp (name,"speex") ==0) && (g_strcasecmp (srate,"32 kHz") ==0)) - codec = codec_list_get_by_payload ( (gconstpointer) 112, acc->codecs); + codec = codec_list_get_by_payload (112, acc->codecs); else codec = codec_list_get_by_name ( (gconstpointer) name, acc->codecs); @@ -552,11 +547,7 @@ codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpoin gtk_tree_path_free (treePath); // Modify codec queue to represent change - if (active) { - codec_set_active (&codec); - } else { - codec_set_inactive (&codec); - } + codec->is_active = active; } /** @@ -572,19 +563,11 @@ static void codec_move (gboolean moveUp, gpointer data) GtkTreeSelection *selection; GtkTreePath *treePath; gchar *path; - account_t *acc; - GQueue *acc_q; // Get view, model and selection of codec store model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (codecTreeView)); - // Retrieve the user data - acc = (account_t*) data; - - if (acc) - acc_q = acc->codecs; - // Find selected iteration and create a copy gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter); iter2 = gtk_tree_iter_copy (&iter); @@ -592,8 +575,7 @@ static void codec_move (gboolean moveUp, gpointer data) // Find path of iteration path = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), &iter); treePath = gtk_tree_path_new_from_string (path); - gint *indices = gtk_tree_path_get_indices (treePath); - gint indice = indices[0]; + gint indice = *gtk_tree_path_get_indices (treePath); // Depending on button direction get new path if (moveUp) @@ -616,11 +598,7 @@ static void codec_move (gboolean moveUp, gpointer data) g_free (path); // Perpetuate changes in codec queue - if (moveUp) - codec_list_move_codec_up (indice, &acc_q); - else - codec_list_move_codec_down (indice, &acc_q); - + codec_list_move (indice, ((account_t*)data)->codecs, moveUp); } /** @@ -700,11 +678,6 @@ GtkWidget* audiocodecs_box (account_t *a) treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); - // Frequency column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); - g_object_unref (G_OBJECT (codecStore)); gtk_container_add (GTK_CONTAINER (scrolledWindow), codecTreeView); diff --git a/sflphone-client-gnome/src/config/videoconf.c b/sflphone-client-gnome/src/config/videoconf.c index 0362e65653f2fbf32f05c2bc3f768dfb408b7c94..0b630296a98bc295781d4af88abf69e317803793 100644 --- a/sflphone-client-gnome/src/config/videoconf.c +++ b/sflphone-client-gnome/src/config/videoconf.c @@ -36,6 +36,7 @@ #include "dbus.h" #include "video/video_preview.h" #include <assert.h> +#include "codeclist.h" #include <clutter/clutter.h> #include <clutter-gtk/clutter-gtk.h> @@ -75,7 +76,6 @@ enum { COLUMN_CODEC_ACTIVE, COLUMN_CODEC_NAME, COLUMN_CODEC_BITRATE, - COLUMN_CODEC_BANDWIDTH, CODEC_COLUMN_COUNT }; @@ -171,39 +171,35 @@ preview_button_clicked(GtkButton *button, gpointer data UNUSED) /** * Fills the tree list with supported codecs */ -static void preferences_dialog_fill_codec_list (account_t **a UNUSED) +static void preferences_dialog_fill_codec_list (account_t *a) { GtkListStore *codecStore; - gchar **video_codecs = NULL, **specs = NULL; GtkTreeIter iter; - glong payload; // Get model of view and clear it codecStore = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView))); gtk_list_store_clear (codecStore); - // This is a global list inherited by all accounts - video_codecs = (gchar**) dbus_video_codec_list (); - if (video_codecs != NULL) { - // Add the codecs in the list - for (; *video_codecs; video_codecs++) { - payload = atol (*video_codecs); - specs = (gchar **) dbus_video_codec_details (payload); - DEBUG("%s\n", *video_codecs); - DEBUG("%s\n", specs[0]); - DEBUG("%d\n", payload); - - // Insert codecs - gtk_list_store_append (codecStore, &iter); - gtk_list_store_set (codecStore, &iter, - COLUMN_CODEC_ACTIVE, TRUE, // Active - COLUMN_CODEC_NAME, specs[0], // Name - COLUMN_CODEC_BITRATE, g_strdup_printf ("%.1f kbps", 1000.0), // Bitrate (kbps) - COLUMN_CODEC_BANDWIDTH, g_strdup_printf ("%.1f kbps", 1000.0), // Bandwidth (kpbs) - -1); - } + GQueue *list = a ? a->vcodecs : get_video_codecs_list (); + + // Add the codecs in the list + unsigned i; + for (i = 0 ; i < list->length; i++) { + codec_t *c = g_queue_peek_nth (list, i); + + if (c) { + printf("%s", c->name); + gtk_list_store_append (codecStore, &iter); + gchar *bitrate = g_strdup_printf ("%s kbps", c->bitrate); + + gtk_list_store_set (codecStore, &iter, + COLUMN_CODEC_ACTIVE, c->is_active, + COLUMN_CODEC_NAME, c->name, + COLUMN_CODEC_BITRATE, bitrate, + -1); + g_free(bitrate); + } } - } @@ -212,9 +208,8 @@ static void preferences_dialog_fill_codec_list (account_t **a UNUSED) * and in configuration files */ static void -codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path UNUSED, gpointer data UNUSED) +codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path, gpointer data) { -#if 0 GtkTreeIter iter; GtkTreePath *treePath; GtkTreeModel *model; @@ -241,9 +236,9 @@ codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path UNUSED -1); printf ("%s\n", name); - printf ("%i\n", g_queue_get_length (acc->codecs)); + printf ("%i\n", g_queue_get_length (acc->vcodecs)); - codec = codec_list_get_by_name ( (gconstpointer) name, acc->codecs); + codec = codec_list_get_by_name ( (gconstpointer) name, acc->vcodecs); // Toggle active value active = !active; @@ -256,19 +251,14 @@ codec_active_toggled (GtkCellRendererToggle *renderer UNUSED, gchar *path UNUSED gtk_tree_path_free (treePath); // Modify codec queue to represent change - if (active) { - codec_set_active (&codec); - } else { - codec_set_inactive (&codec); - } -#endif + codec->is_active = active; } /** * Move codec in list depending on direction and selected codec and * update changes in the daemon list and the configuration files */ -static void codec_move (gboolean moveUp, gpointer data UNUSED) +static void codec_move (gboolean moveUp, gpointer data) { GtkTreeIter iter; @@ -277,19 +267,11 @@ static void codec_move (gboolean moveUp, gpointer data UNUSED) GtkTreeSelection *selection; GtkTreePath *treePath; gchar *path; - //account_t *acc; - //GQueue *acc_q; // Get view, model and selection of codec store model = gtk_tree_view_get_model (GTK_TREE_VIEW (codecTreeView)); selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (codecTreeView)); - // Retrieve the user data - //acc = (account_t*) data; - - //if (acc) - // acc_q = acc->codecs; - // Find selected iteration and create a copy gtk_tree_selection_get_selected (GTK_TREE_SELECTION (selection), &model, &iter); iter2 = gtk_tree_iter_copy (&iter); @@ -297,8 +279,8 @@ static void codec_move (gboolean moveUp, gpointer data UNUSED) // Find path of iteration path = gtk_tree_model_get_string_from_iter (GTK_TREE_MODEL (model), &iter); treePath = gtk_tree_path_new_from_string (path); - //gint *indices = gtk_tree_path_get_indices (treePath); - //gint indice = indices[0]; + gint *indices = gtk_tree_path_get_indices (treePath); + gint indice = indices[0]; // Depending on button direction get new path if (moveUp) @@ -320,13 +302,8 @@ static void codec_move (gboolean moveUp, gpointer data UNUSED) gtk_tree_iter_free (iter2); g_free (path); -#if 0 // Perpetuate changes in codec queue - if (moveUp) - codec_list_move_codec_up (indice, &acc_q); - else - codec_list_move_codec_down (indice, &acc_q); -#endif + codec_list_move (indice, ((account_t*)data)->vcodecs, moveUp); } /** @@ -347,7 +324,7 @@ static void codec_move_down (GtkButton *button UNUSED, gpointer data) codec_move (FALSE, data); } -GtkWidget* videocodecs_box (account_t **a) +GtkWidget* videocodecs_box (account_t *a) { GtkWidget *ret; GtkWidget *scrolledWindow; @@ -388,7 +365,7 @@ GtkWidget* videocodecs_box (account_t **a) gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); // Toggle codec active property on clicked - g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (codec_active_toggled), (gpointer) *a); + g_signal_connect (G_OBJECT (renderer), "toggled", G_CALLBACK (codec_active_toggled), (gpointer) a); // Name column renderer = gtk_cell_renderer_text_new(); @@ -400,11 +377,6 @@ GtkWidget* videocodecs_box (account_t **a) treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bitrate"), renderer, "text", COLUMN_CODEC_BITRATE, NULL); gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); - // Bandwidth column - renderer = gtk_cell_renderer_text_new(); - treeViewColumn = gtk_tree_view_column_new_with_attributes (_ ("Bandwidth"), renderer, "text", COLUMN_CODEC_BANDWIDTH, NULL); - gtk_tree_view_append_column (GTK_TREE_VIEW (codecTreeView), treeViewColumn); - g_object_unref (G_OBJECT (codecStore)); gtk_container_add (GTK_CONTAINER (scrolledWindow), codecTreeView); @@ -416,12 +388,12 @@ GtkWidget* videocodecs_box (account_t **a) codecMoveUpButton = gtk_button_new_from_stock (GTK_STOCK_GO_UP); gtk_widget_set_sensitive (GTK_WIDGET (codecMoveUpButton), FALSE); gtk_box_pack_start (GTK_BOX (buttonBox), codecMoveUpButton, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (codecMoveUpButton), "clicked", G_CALLBACK (codec_move_up), *a); + g_signal_connect (G_OBJECT (codecMoveUpButton), "clicked", G_CALLBACK (codec_move_up), a); codecMoveDownButton = gtk_button_new_from_stock (GTK_STOCK_GO_DOWN); gtk_widget_set_sensitive (GTK_WIDGET (codecMoveDownButton), FALSE); gtk_box_pack_start (GTK_BOX (buttonBox), codecMoveDownButton, FALSE, FALSE, 0); - g_signal_connect (G_OBJECT (codecMoveDownButton), "clicked", G_CALLBACK (codec_move_down), *a); + g_signal_connect (G_OBJECT (codecMoveDownButton), "clicked", G_CALLBACK (codec_move_down), a); preferences_dialog_fill_codec_list (a); diff --git a/sflphone-client-gnome/src/contacts/calltree.c b/sflphone-client-gnome/src/contacts/calltree.c index f167078583066e3b9d53a1016885750e90662caf..70fca7c1e876476512a9f123d948d78a994c1ce4 100644 --- a/sflphone-client-gnome/src/contacts/calltree.c +++ b/sflphone-client-gnome/src/contacts/calltree.c @@ -367,7 +367,7 @@ row_single_click (GtkTreeView *tree_view UNUSED, void * data UNUSED) DEBUG ("Display SAS once %s", displaySasOnce); } else { GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); + properties = sflphone_get_ip2ip_properties (); if (properties != NULL) { displaySasOnce = g_hash_table_lookup (properties, ACCOUNT_DISPLAY_SAS_ONCE); @@ -802,7 +802,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) } } else { GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); + properties = sflphone_get_ip2ip_properties (); if (properties != NULL) { srtp_enabled = g_hash_table_lookup (properties, ACCOUNT_SRTP_ENABLED); @@ -851,6 +851,7 @@ calltree_update_call (calltab_t* tab, callable_obj_t * c, GtkTreeIter *parent) calltree_display_call_info (c, DISPLAY_TYPE_STATE_CODE, audio_codec, &description); } } + g_free(audio_codec); /* Update icons */ if (tab == current_calls) { diff --git a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml index 55c63e196d6c57457efacb175d402bf6dc3a8473..b09fa91f5aabde33ebd3caf6f9722737a9e73b3c 100755 --- a/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-client-gnome/src/dbus/configurationmanager-introspec.xml @@ -752,7 +752,7 @@ <method name="getVideoCodecDetails" tp:name-for-bindings="getVideoCodecDetails"> <tp:docstring> </tp:docstring> - <arg type="i" name="payload" direction="in"> + <arg type="s" name="codec" direction="in"> <tp:docstring> </tp:docstring> </arg> @@ -763,6 +763,34 @@ </arg> </method> + <method name="getActiveVideoCodecList" tp:name-for-bindings="getActiveVideoCodecList"> + <tp:docstring> + </tp:docstring> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + <arg type="as" name="list" direction="out"> + <tp:docstring> + </tp:docstring> + </arg> + </method> + + <method name="setActiveVideoCodecList" tp:name-for-bindings="setActiveVideoCodecList"> + <tp:docstring> + </tp:docstring> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorString"/> + <arg type="as" name="list" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + </method> + <!-- General Settings Panel --> <method name="isMd5CredentialHashing" tp:name-for-bindings="isMd5CredentialHashing"> diff --git a/sflphone-client-gnome/src/dbus/dbus.c b/sflphone-client-gnome/src/dbus/dbus.c index 7f6e3019a64ade790dd7286b7350fad3ba4598e6..e2daa4d90f279a5eda05b69042fd6d2f8470d480 100644 --- a/sflphone-client-gnome/src/dbus/dbus.c +++ b/sflphone-client-gnome/src/dbus/dbus.c @@ -1460,6 +1460,40 @@ dbus_video_codec_list() return array; } +gchar** +dbus_get_active_video_codec_list (gchar *accountID) +{ + + gchar ** array = NULL; + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_get_active_video_codec_list ( + configurationManagerProxy, accountID, &array, &error); + + if (error) { + ERROR ("Failed to call get_active_audio_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } + + return array; +} + +void +dbus_set_active_video_codec_list (const gchar** list, const gchar *accountID) +{ + + GError *error = NULL; + org_sflphone_SFLphone_ConfigurationManager_set_active_video_codec_list ( + configurationManagerProxy, list, accountID, &error); + + if (error) { + ERROR ("Failed to call set_active_audio_codec_list() on ConfigurationManager: %s", + error->message); + g_error_free (error); + } +} + + gchar** dbus_audio_codec_details (int payload) { @@ -1479,13 +1513,13 @@ dbus_audio_codec_details (int payload) } gchar** -dbus_video_codec_details (int payload) +dbus_video_codec_details (gchar *codec) { GError *error = NULL; gchar ** array = NULL; org_sflphone_SFLphone_ConfigurationManager_get_video_codec_details ( - configurationManagerProxy, payload, &array, &error); + configurationManagerProxy, codec, &array, &error); if (error) { ERROR ("Failed to call get_video_codec_details() on ConfigurationManager: %s", diff --git a/sflphone-client-gnome/src/dbus/dbus.h b/sflphone-client-gnome/src/dbus/dbus.h index 5ac15e52717897805ecf7f20c9be2ccd4ea2598c..14805e7c340b67e6c8c8c7dd4bbb22c54b7be2bc 100644 --- a/sflphone-client-gnome/src/dbus/dbus.h +++ b/sflphone-client-gnome/src/dbus/dbus.h @@ -215,10 +215,10 @@ gchar** dbus_audio_codec_details (int payload); /** * ConfigurationManager - Get the video codec details - * @param payload The payload of the video codec + * @param codec The name of the video codec * @return gchar** The video codec details */ -gchar** dbus_video_codec_details (int payload); +gchar** dbus_video_codec_details (gchar *codec); /** * ConfigurationManager - Get the default audio codec list @@ -239,6 +239,18 @@ gchar** dbus_get_active_audio_codec_list (gchar *accountID); */ void dbus_set_active_audio_codec_list (const gchar** list, const gchar*); +/** + * ConfigurationManager - Get the list of the audio codecs used for media negotiation + * @return gchar** The list of audio codecs + */ +gchar** dbus_get_active_video_codec_list (gchar *accountID); + +/** + * ConfigurationManager - Set the list of audio codecs used for media negociation + * @param list The list of audio codecs + */ +void dbus_set_active_video_codec_list (const gchar** list, const gchar*); + /** * CallManager - return the audio codec name * @param callable_obj_t* current call diff --git a/sflphone-client-gnome/src/main.c b/sflphone-client-gnome/src/main.c index 0d527b32d039080cbb72b16b276064dab1282845..7dc8518e7bc9b0c633e3acda2cd914e32c29618e 100644 --- a/sflphone-client-gnome/src/main.c +++ b/sflphone-client-gnome/src/main.c @@ -134,6 +134,7 @@ main (int argc, char *argv[]) /* start the main loop */ gtk_main (); + codecs_unload(); shortcuts_destroy_bindings(); OUT: diff --git a/sflphone-client-gnome/src/mainwindow.c b/sflphone-client-gnome/src/mainwindow.c index ddac77cadf5250abbab8a60f6f63e5bd7e6d305e..c81c8acd6d3b07d4a6ce2d1eeb75dd541dbd177c 100644 --- a/sflphone-client-gnome/src/mainwindow.c +++ b/sflphone-client-gnome/src/mainwindow.c @@ -501,7 +501,7 @@ main_window_zrtp_not_supported (callable_obj_t * c) } else { DEBUG ("Account is null callID %s", c->_callID); GHashTable * properties = NULL; - sflphone_get_ip2ip_properties (&properties); + properties = sflphone_get_ip2ip_properties (); if (properties != NULL) { warning_enabled = g_hash_table_lookup (properties, diff --git a/sflphone-common/src/Codec.h b/sflphone-common/src/Codec.h index 34d3a2bbf78b3364b07ffffd02ab754d887675cd..9b4981a0e414c4ca81dc8efe1128d1498ae719aa 100644 --- a/sflphone-common/src/Codec.h +++ b/sflphone-common/src/Codec.h @@ -65,11 +65,6 @@ class Codec * @return The bitrate for which this codec is configured // TODO deal with VBR case. */ virtual double getBitRate() const = 0; - - /** - * @return The expected bandwidth used by this codec. - */ - virtual double getBandwidth() const = 0; }; } diff --git a/sflphone-common/src/account.cpp b/sflphone-common/src/account.cpp index c2626dcfdedf7726537589b966d63035bc35b597..d0258749a26db0a33563cde4a6558f8c07802b2a 100644 --- a/sflphone-common/src/account.cpp +++ b/sflphone-common/src/account.cpp @@ -32,6 +32,7 @@ #include "account.h" #include "manager.h" +#include "video/video_endpoint.h" Account::Account (const std::string& accountID, const std::string &type) : _accountID (accountID) @@ -80,9 +81,14 @@ void Account::loadDefaultCodecs() codecList.push_back ("112"); setActiveCodecs (codecList); -} + setActiveVideoCodecs(sfl_video::getVideoCodecList()); +} +void Account::setActiveVideoCodecs (const std::vector <std::string> &list) +{ + _videoCodecOrder = list; +} void Account::setActiveCodecs (const std::vector <std::string> &list) { diff --git a/sflphone-common/src/account.h b/sflphone-common/src/account.h index f14602fb397ffaaf1d7c46c24e3266eeed520cc0..12d40e9a6c824c442aa65155f4746ec4d6912d59 100644 --- a/sflphone-common/src/account.h +++ b/sflphone-common/src/account.h @@ -141,6 +141,7 @@ const std::string accountEnableKey ("enable"); const std::string mailboxKey ("mailbox"); const std::string codecsKey ("codecs"); // 0/9/110/111/112/ +const std::string videocodecsKey ("videocodecs"); const std::string ringtonePathKey ("ringtonePath"); const std::string ringtoneEnabledKey ("ringtoneEnabled"); const std::string displayNameKey ("displayName"); @@ -287,6 +288,14 @@ class Account : public Serializable _type = type; } + /** + * Accessor to data structures + * @return std::vector<std::string>& The list that reflects the user's choice + */ + const std::vector<std::string>& getActiveVideoCodecs (void) const { + return _videoCodecOrder; + } + /** * Accessor to data structures * @return CodecOrder& The list that reflects the user's choice @@ -300,6 +309,7 @@ class Account : public Serializable * SDP offer and configuration respectively */ void setActiveCodecs (const std::vector <std::string>& list); + void setActiveVideoCodecs (const std::vector <std::string>& list); std::string getRingtonePath (void) const { return _ringtonePath; @@ -403,6 +413,11 @@ class Account : public Serializable */ std::pair<int, std::string> _registrationStateDetailed; + /** + * Vector containing the order of the video codecs + */ + std::vector<std::string> _videoCodecOrder; + /** * Vector containing the order of the codecs */ diff --git a/sflphone-common/src/audio/codecs/audiocodec.cpp b/sflphone-common/src/audio/codecs/audiocodec.cpp index d688f809795296a320d2b78577f128109c0f7cff..fdf02025b1c5675ac85ce88c8f90d33a53f52880 100644 --- a/sflphone-common/src/audio/codecs/audiocodec.cpp +++ b/sflphone-common/src/audio/codecs/audiocodec.cpp @@ -38,15 +38,14 @@ namespace sfl { AudioCodec::AudioCodec (uint8 payload, const std::string &codecName) : _codecName (codecName), _clockRate (8000), _channel (1), _bitrate (0.0), - _bandwidth (0), _hasDynamicPayload (false), _payload(payload) + _hasDynamicPayload (false), _payload(payload) { init (payload, _clockRate); } AudioCodec::AudioCodec (const AudioCodec& codec) : _codecName (codec._codecName), _clockRate (codec._clockRate), _channel ( - codec._channel), _bitrate (codec._bitrate), _bandwidth ( - codec._bandwidth), _hasDynamicPayload (false), _payload(codec._payload) + codec._channel), _bitrate (codec._bitrate), _hasDynamicPayload (false), _payload(codec._payload) { init (codec._payload, codec._clockRate); } @@ -110,11 +109,6 @@ double AudioCodec::getBitRate (void) const return _bitrate; } -double AudioCodec::getBandwidth (void) const -{ - return _bandwidth; -} - AudioCodec::~AudioCodec() { delete _payloadFormat; diff --git a/sflphone-common/src/audio/codecs/audiocodec.h b/sflphone-common/src/audio/codecs/audiocodec.h index e38f31aaad7295afd4fb5318cde02683a68b4324..0ee896fd4f332b71bcde0bec962c3ee30007d422 100644 --- a/sflphone-common/src/audio/codecs/audiocodec.h +++ b/sflphone-common/src/audio/codecs/audiocodec.h @@ -132,11 +132,6 @@ class AudioCodec : public Codec */ double getBitRate() const; - /** - * @Override - */ - double getBandwidth() const; - /** * @return the framing size for this codec. */ diff --git a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp index 49db0b4ac07c04a0d587cd2f35cfc93a9f221bb2..105c6f58a7480bb323fe4ee981b75cf562c150be 100644 --- a/sflphone-common/src/audio/codecs/audiocodecfactory.cpp +++ b/sflphone-common/src/audio/codecs/audiocodecfactory.cpp @@ -129,24 +129,13 @@ double AudioCodecFactory::getBitRate (AudioCodecType payload) return 0.0; } -double AudioCodecFactory::getBandwidthPerCall (AudioCodecType payload) -{ - - CodecsMap::iterator iter = _CodecsMap.find (payload); - - if (iter!=_CodecsMap.end()) - return (iter->second->getBandwidth()); - else - return 0.0; -} - int AudioCodecFactory::getSampleRate (AudioCodecType payload) { CodecsMap::iterator iter = _CodecsMap.find (payload); if (iter!=_CodecsMap.end()) - return (iter->second->getClockRate()); + return (iter->second->getClockRate() / 1000); else return 0; } @@ -421,21 +410,15 @@ std::vector <std::string> AudioCodecFactory::getCodecSpecifications (const int32 // Add the name of the codec v.push_back (getCodecName ( (AudioCodecType) payload)); - // Add the sample rate - ss << getSampleRate ( (AudioCodecType) payload); - v.push_back ( (ss.str()).data()); - ss.str (""); - // Add the bit rate ss << getBitRate ( (AudioCodecType) payload); v.push_back ( (ss.str()).data()); ss.str (""); - // Add the bandwidth information - ss << getBandwidthPerCall ( (AudioCodecType) payload); + // Add the sample rate + ss << getSampleRate ( (AudioCodecType) payload); v.push_back ( (ss.str()).data()); ss.str (""); return v; - } diff --git a/sflphone-common/src/audio/codecs/audiocodecfactory.h b/sflphone-common/src/audio/codecs/audiocodecfactory.h index 877b2ec55539752ff538be27210c537584f00d0b..d55456b6ee8e74601609c0cb4d93f7a23c654aa0 100644 --- a/sflphone-common/src/audio/codecs/audiocodecfactory.h +++ b/sflphone-common/src/audio/codecs/audiocodecfactory.h @@ -106,15 +106,6 @@ class AudioCodecFactory */ double getBitRate (AudioCodecType 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 (AudioCodecType payload); - /** * Get the clock rate of the specified codec * @param payload The payload of the codec diff --git a/sflphone-common/src/dbus/configurationmanager-introspec.xml b/sflphone-common/src/dbus/configurationmanager-introspec.xml index 55c63e196d6c57457efacb175d402bf6dc3a8473..d85f16e440020839f20a365919dd61920151abb5 100755 --- a/sflphone-common/src/dbus/configurationmanager-introspec.xml +++ b/sflphone-common/src/dbus/configurationmanager-introspec.xml @@ -752,7 +752,7 @@ <method name="getVideoCodecDetails" tp:name-for-bindings="getVideoCodecDetails"> <tp:docstring> </tp:docstring> - <arg type="i" name="payload" direction="in"> + <arg type="s" name="codec" direction="in"> <tp:docstring> </tp:docstring> </arg> @@ -763,6 +763,35 @@ </arg> </method> + <method name="getActiveVideoCodecList" tp:name-for-bindings="getActiveVideoCodecList"> + <tp:docstring> + </tp:docstring> + <annotation name="com.trolltech.QtDBus.QtTypeName.Out0" value="VectorString"/> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + <arg type="as" name="list" direction="out"> + <tp:docstring> + </tp:docstring> + </arg> + </method> + + <method name="setActiveVideoCodecList" tp:name-for-bindings="setActiveVideoCodecList"> + <tp:docstring> + </tp:docstring> + <annotation name="com.trolltech.QtDBus.QtTypeName.In0" value="VectorString"/> + <arg type="as" name="list" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + <arg type="s" name="accountID" direction="in"> + <tp:docstring> + </tp:docstring> + </arg> + </method> + + <!-- General Settings Panel --> <method name="isMd5CredentialHashing" tp:name-for-bindings="isMd5CredentialHashing"> diff --git a/sflphone-common/src/dbus/configurationmanager.cpp b/sflphone-common/src/dbus/configurationmanager.cpp index e9ad66e1c3dd73cbfc261e597e99975766208137..794a6649b8884bdaaef8ca21720ec4bbda1e8af0 100644 --- a/sflphone-common/src/dbus/configurationmanager.cpp +++ b/sflphone-common/src/dbus/configurationmanager.cpp @@ -397,23 +397,7 @@ std::vector<std::string> ConfigurationManager::getAudioCodecList (void) */ std::vector<std::string> ConfigurationManager::getVideoCodecList (void) { - std::vector<std::string> list; - typedef std::map<int, std::string> VideoCodecsMap; - VideoCodecsMap codecs = sfl_video::getCodecsMap(); - VideoCodecsMap::iterator iter = codecs.begin(); - - while (iter != codecs.end()) { - std::stringstream ss; - - if (not iter->second.empty()) { - ss << iter->first; - list.push_back(ss.str()); - } - - iter++; - } - - return list; + return sfl_video::getVideoCodecList(); } std::vector<std::string> ConfigurationManager::getSupportedTlsMethod (void) @@ -435,9 +419,9 @@ std::vector<std::string> ConfigurationManager::getAudioCodecDetails ( } std::vector<std::string> ConfigurationManager::getVideoCodecDetails ( - const int32_t& payload) + const std::string& codec) { - return sfl_video::getCodecSpecifications(payload); + return sfl_video::getCodecSpecifications(codec); } std::vector<std::string> ConfigurationManager::getActiveAudioCodecList ( @@ -485,6 +469,32 @@ void ConfigurationManager::setActiveAudioCodecList ( Manager::instance().saveConfig(); } +std::vector<std::string> ConfigurationManager::getActiveVideoCodecList ( + const std::string& accountID) +{ + std::vector<std::string> v; + Account *acc = Manager::instance().getAccount (accountID); + + if (acc != NULL) { + v = acc->getActiveVideoCodecs(); + } + + return v; + +} + +void ConfigurationManager::setActiveVideoCodecList ( + const std::vector<std::string>& list, const std::string& accountID) +{ + Account *acc = Manager::instance().getAccount (accountID); + + if (acc != NULL) { + acc->setActiveVideoCodecs (list); + } + + Manager::instance().saveConfig(); +} + std::vector<std::string> ConfigurationManager::getAudioPluginList() { diff --git a/sflphone-common/src/dbus/configurationmanager.h b/sflphone-common/src/dbus/configurationmanager.h index 5a0c6b1b39d3206f0f76e6ebb19260724718f01c..4db6831f6442cf92b9b97628d26cb706c051521a 100644 --- a/sflphone-common/src/dbus/configurationmanager.h +++ b/sflphone-common/src/dbus/configurationmanager.h @@ -88,9 +88,11 @@ class ConfigurationManager std::vector< std::string > getVideoCodecList (void); std::vector< std::string > getSupportedTlsMethod (void); std::vector< std::string > getAudioCodecDetails (const int32_t& payload); - std::vector< std::string > getVideoCodecDetails (const int32_t& payload); + std::vector< std::string > getVideoCodecDetails (const std::string& payload); std::vector< std::string > getActiveAudioCodecList (const std::string& accountID); void setActiveAudioCodecList (const std::vector< std::string >& list, const std::string& accountID); + std::vector< std::string > getActiveVideoCodecList (const std::string& accountID); + void setActiveVideoCodecList (const std::vector< std::string >& list, const std::string& accountID); std::vector< std::string > getAudioPluginList(); void setAudioPlugin (const std::string& audioPlugin); diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index 494f009b05c523fb04e3a151c8cfac2324bf2c35..de11b2d8fd73cdb32b99709b4104b0e0a5285607 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -52,6 +52,8 @@ #include "conference.h" +#include "video/libav_utils.h" + #include <cerrno> #include <ctime> #include <cstdlib> @@ -88,6 +90,9 @@ ManagerImpl::ManagerImpl (void) : // initialize random generator for call id srand (time (NULL)); + // initialize libav libraries + libav_utils::sfl_avcodec_init(); + _cleaner = new NumberCleaner(); _history = new HistoryManager(); _imModule = new sfl::InstantMessaging(); diff --git a/sflphone-common/src/sip/sdp.cpp b/sflphone-common/src/sip/sdp.cpp index 170d767e7520fcc40ae2984785f697bbd3a21a88..8c46bab8a8c305b5a21a4c5788e3b4d38ba6862e 100644 --- a/sflphone-common/src/sip/sdp.cpp +++ b/sflphone-common/src/sip/sdp.cpp @@ -596,7 +596,7 @@ void Sdp::addVideoMediaDescription() rtpmap.enc_name = pj_str((char*) "H264"); rtpmap.clock_rate = 90000; rtpmap.param.slen = 0; - rtpmap.param.ptr = ""; + rtpmap.param.ptr = (char* const)""; pjmedia_sdp_attr *attr; pjmedia_sdp_rtpmap_to_attr (memPool_, &rtpmap, &attr); med->attr[med->attr_count++] = attr; diff --git a/sflphone-common/src/sip/sipaccount.cpp b/sflphone-common/src/sip/sipaccount.cpp index 38a72e598ef11abc436c581b05c9f8d3e92c7f5c..b1a3a0856e678b6a52417f7b376596bd3435b4d3 100644 --- a/sflphone-common/src/sip/sipaccount.cpp +++ b/sflphone-common/src/sip/sipaccount.cpp @@ -135,6 +135,13 @@ void SIPAccount::serialize (Conf::YamlEmitter *emitter) Conf::ScalarNode sameasLocal (_publishedSameasLocal); Conf::ScalarNode resolveOnce (_resolveOnce); Conf::ScalarNode codecs (_codecStr); + std::vector<std::string>::const_iterator git; + for(git = _videoCodecOrder.begin() ; git != _videoCodecOrder.end(); ++git) + std::cout << *git << std::endl; + std::cout << Manager::instance ().serialize (_videoCodecOrder) << std::endl; + + Conf::ScalarNode vcodecs (Manager::instance ().serialize (_videoCodecOrder)); + Conf::ScalarNode ringtonePath (_ringtonePath); Conf::ScalarNode ringtoneEnabled (_ringtoneEnabled); Conf::ScalarNode stunServer (_stunServer); @@ -189,6 +196,7 @@ void SIPAccount::serialize (Conf::YamlEmitter *emitter) accountmap.setKeyValue (dtmfTypeKey, &dtmfType); accountmap.setKeyValue (displayNameKey, &displayName); accountmap.setKeyValue (codecsKey, &codecs); + accountmap.setKeyValue (videocodecsKey, &vcodecs); accountmap.setKeyValue (ringtonePathKey, &ringtonePath); accountmap.setKeyValue (ringtoneEnabledKey, &ringtoneEnabled); @@ -265,9 +273,13 @@ void SIPAccount::unserialize (Conf::MappingNode *map) map->getValue(accountEnableKey, &_enabled); map->getValue(mailboxKey, &_mailBox); map->getValue(codecsKey, &_codecStr); + std::string vcodecs; + map->getValue(videocodecsKey, &vcodecs); // Update codec list which one is used for SDP offer setActiveCodecs (Manager::instance ().unserialize (_codecStr)); + setActiveVideoCodecs (Manager::instance ().unserialize (vcodecs)); + map->getValue(ringtonePathKey, &_ringtonePath); map->getValue(ringtoneEnabledKey, &_ringtoneEnabled); map->getValue(expireKey, &_registrationExpire); diff --git a/sflphone-common/src/video/libav_utils.cpp b/sflphone-common/src/video/libav_utils.cpp index 938799d1e06ea2fdcf400cead2c668e9c3e0018d..d14453c22b448129626da1bf7e1537342d7d2a57 100644 --- a/sflphone-common/src/video/libav_utils.cpp +++ b/sflphone-common/src/video/libav_utils.cpp @@ -29,11 +29,11 @@ */ #include "libav_utils.h" -#include <list> +#include <vector> #include <algorithm> #include <string> #include <iostream> - +#include <assert.h> #include <cc++/thread.h> extern "C" { @@ -41,34 +41,36 @@ extern "C" { #include <libavformat/avformat.h> } -namespace libav_utils { -bool isSupportedCodec(const char *name) -{ - static std::list<std::string> SUPPORTED_CODECS; - if (SUPPORTED_CODECS.empty()) - { - SUPPORTED_CODECS.push_back("mpeg4"); - SUPPORTED_CODECS.push_back("h263p"); - SUPPORTED_CODECS.push_back("libx264"); - SUPPORTED_CODECS.push_back("libtheora"); - SUPPORTED_CODECS.push_back("libvpx"); - } - return std::find(SUPPORTED_CODECS.begin(), SUPPORTED_CODECS.end(), name) != - SUPPORTED_CODECS.end(); -} +static std::map<std::string, std::string> encoders; +static std::vector<std::string> video_codecs; +/* application wide mutex to protect concurrent access to avcodec */ +static ost::Mutex avcodec_lock; +namespace { +std::string friendlyName(const std::string &codec) +{ + std::map<std::string, std::string>::const_iterator it; + for (it = encoders.begin(); it != encoders.end(); ++it) + if (it->second == codec) + return it->first; + return ""; +} -std::list<std::string> installedCodecs() +void findInstalledVideoCodecs() { - std::list<std::string> codecs; - AVCodec *p = NULL, *p2; + std::vector<std::string> sfl_codecs; + std::map<std::string, std::string>::const_iterator it; + for (it = encoders.begin(); it != encoders.end(); ++it) + sfl_codecs.push_back(it->second); + + const char *last_name = "000"; while (true) { - p2 = NULL; + AVCodec *p = NULL, *p2 = NULL; while ((p = av_codec_next(p))) { if((p2 == NULL or strcmp(p->name, p2->name) < 0) and @@ -81,20 +83,22 @@ std::list<std::string> installedCodecs() break; last_name = p2->name; - switch(p2->type) - { - case AVMEDIA_TYPE_VIDEO: - if (isSupportedCodec(p2->name)) - codecs.push_back(p2->name); - break; - default: - break; - } + if (p2->type == AVMEDIA_TYPE_VIDEO) + if (std::find(sfl_codecs.begin(), sfl_codecs.end(), p2->name) != sfl_codecs.end()) + video_codecs.push_back(friendlyName(p2->name)); } - return codecs; } -static ost::Mutex avcodec_lock; + +} // end anon namespace + +namespace libav_utils { + + +std::vector<std::string> getVideoCodecList() +{ + return video_codecs; +} static int avcodecManageMutex(void **mutex, enum AVLockOp op) { @@ -115,6 +119,11 @@ static int avcodecManageMutex(void **mutex, enum AVLockOp op) return 0; } +std::map<std::string, std::string> encodersMap() +{ + return encoders; +} + void sfl_avcodec_init() { static int done = 0; @@ -128,6 +137,15 @@ void sfl_avcodec_init() av_register_all(); av_lockmgr_register(avcodecManageMutex); + + /* list of codecs tested and confirmed to work */ + encoders["H264"] = "libx264"; + encoders["H263-2000"] = "h263p"; + //encoders["MP4V-ES"] = "mpeg4video"; + //encoders["VP8"] = "libvpx"; + //encoders["THEORA"] = "libtheora"; + + findInstalledVideoCodecs(); } } // end namespace libav_utils diff --git a/sflphone-common/src/video/libav_utils.h b/sflphone-common/src/video/libav_utils.h index 02b447dea7e570ab9a976f5125c4b82cf7083955..b812d4fe5781d5d47e1f7966037e0ba0fd26dbc3 100644 --- a/sflphone-common/src/video/libav_utils.h +++ b/sflphone-common/src/video/libav_utils.h @@ -31,21 +31,14 @@ #ifndef __LIBAV_UTILS_H__ #define __LIBAV_UTILS_H__ -#include <list> +#include <vector> +#include <map> #include <string> namespace libav_utils { - /** - * Returns the list of codecs installed at runtime and that we support - */ - std::list<std::string> installedCodecs(); - /** - * Returns true if a given codec is supported, that is to say it's use - * has been anticipated and it has been tested. - */ - bool isSupportedCodec(const char *codec); - void sfl_avcodec_init(); + std::map<std::string, std::string> encodersMap(); + std::vector<std::string> getVideoCodecList(); } #endif // __LIBAV_UTILS_H__ diff --git a/sflphone-common/src/video/test/test_video_endpoint.cpp b/sflphone-common/src/video/test/test_video_endpoint.cpp index 4b2745aab36a11f7554a96d14ac1b60fe4d57b57..5ed67424214e8b0e06e693e15b084b49b3e80629 100644 --- a/sflphone-common/src/video/test/test_video_endpoint.cpp +++ b/sflphone-common/src/video/test/test_video_endpoint.cpp @@ -36,15 +36,6 @@ #include "video_endpoint.h" #include "libav_utils.h" -void VideoEndpointTest::testIsSupportedCodec() -{ - /* This would list codecs */ - assert(libav_utils::isSupportedCodec("mpeg4")); - assert(not libav_utils::isSupportedCodec("mp3")); - assert(not libav_utils::isSupportedCodec("xan_wc4")); - assert(not libav_utils::isSupportedCodec("schroedinger")); -} - void VideoEndpointTest::testListInstalledCodecs() { /* This would list codecs */ @@ -73,6 +64,5 @@ int main (int argc, char* argv[]) VideoEndpointTest test; test.testListInstalledCodecs(); test.testCodecMap(); - test.testIsSupportedCodec(); return 0; } diff --git a/sflphone-common/src/video/video_endpoint.cpp b/sflphone-common/src/video/video_endpoint.cpp index 5e7ad56b221d73f217a2d005bdd1e6c360fc2f3f..5b6eb01cd354a33065068aa0cd5d82a484a3754b 100644 --- a/sflphone-common/src/video/video_endpoint.cpp +++ b/sflphone-common/src/video/video_endpoint.cpp @@ -39,63 +39,32 @@ namespace sfl_video { /* anonymous namespace */ namespace { -std::string encoderName(int payload) -{ - std::string result = getCodecsMap()[payload]; - if (result.empty()) - return "MISSING"; - else - return result; -} - int FAKE_BITRATE() { - return 1000000; + return 1000; } -int getBitRate(int payload) -{ - return FAKE_BITRATE(); -} - -int getBandwidthPerCall(int payload) +int getBitRate(const std::string &codec) { return FAKE_BITRATE(); } } // end anonymous namespace -std::map<int, std::string> getCodecsMap() +std::vector<std::string> getVideoCodecList() { - static std::map<int, std::string> CODECS_MAP; - if (CODECS_MAP.empty()) - { - CODECS_MAP[96] = "H263-2000"; - CODECS_MAP[97] = "H264"; - CODECS_MAP[98] = "MP4V-ES"; - CODECS_MAP[99] = "VP8"; - CODECS_MAP[100] = "THEORA"; - } - return CODECS_MAP; + return libav_utils::getVideoCodecList(); } -std::vector<std::string> getCodecSpecifications(int payload) +std::vector<std::string> getCodecSpecifications(const std::string &codec) { - std::vector<std::string> v; + std::vector<std::string> v(1, codec); std::stringstream ss; - // Add the name of the codec - v.push_back (encoderName(payload)); - // Add the bit rate - ss << getBitRate(payload); + ss << getBitRate(codec); v.push_back(ss.str()); ss.str(""); - // Add the bandwidth information - ss << getBandwidthPerCall(payload); - v.push_back (ss.str()); - ss.str (""); - return v; } diff --git a/sflphone-common/src/video/video_endpoint.h b/sflphone-common/src/video/video_endpoint.h index 1aaa59ac666d9ca68a063c62e3b8f81ee95e3730..1fec9d7b473277697005bd55d9308b76809fb307 100644 --- a/sflphone-common/src/video/video_endpoint.h +++ b/sflphone-common/src/video/video_endpoint.h @@ -36,8 +36,12 @@ #include <map> namespace sfl_video { - std::vector<std::string> getCodecSpecifications(int payload); - std::map<int, std::string> getCodecsMap(); + /** + * Returns the list of codecs installed at runtime and that we support + */ + std::vector<std::string> getVideoCodecList(); + + std::vector<std::string> getCodecSpecifications(const std::string &codec); } #endif // __VIDEO_ENDPOINT_H__ diff --git a/sflphone-common/src/video/video_receive_thread.cpp b/sflphone-common/src/video/video_receive_thread.cpp index d731b6f39cf63bbad6c0e1493dd0fc01895e5dc5..b0a26f2f3dd102970effcf3a2123249b6197b6f3 100644 --- a/sflphone-common/src/video/video_receive_thread.cpp +++ b/sflphone-common/src/video/video_receive_thread.cpp @@ -30,7 +30,6 @@ */ #include "video_receive_thread.h" -#include "libav_utils.h" // libav includes extern "C" { @@ -222,8 +221,6 @@ void VideoReceiveThread::loadSDP() void VideoReceiveThread::setup() { - libav_utils::sfl_avcodec_init(); - dstWidth_ = atoi(args_["width"].c_str()); dstHeight_ = atoi(args_["height"].c_str()); format_ = av_get_pix_fmt(args_["format"].c_str()); diff --git a/sflphone-common/src/video/video_send_thread.cpp b/sflphone-common/src/video/video_send_thread.cpp index 1ed98378d574fcfee483810a05ae8b1e6ca69028..760b2610c5e4e2f8f553cb91f3e1aceb81a3d1df 100644 --- a/sflphone-common/src/video/video_send_thread.cpp +++ b/sflphone-common/src/video/video_send_thread.cpp @@ -29,7 +29,6 @@ */ #include "video_send_thread.h" -#include "libav_utils.h" // libav includes extern "C" { @@ -123,7 +122,6 @@ void VideoSendThread::prepareEncoderContext() void VideoSendThread::setup() { int ret; - libav_utils::sfl_avcodec_init(); if (!test_source_) {