From fbe95d63f97a800e295e12e190084e3d9265fcb3 Mon Sep 17 00:00:00 2001 From: Sjoerd Simons Date: Tue, 3 Mar 2009 17:35:00 +0000 Subject: Hardcode some a default codec preferences For video use H264 over Theora as it's better quality and there is no reason to prefer a free codec if people already have the patented bits installed anyway. Also prefer H263 as it's reasonable and it works around our H263-1998 negotiation being slightly broken because of gstreamer :( For audio prefer speex wideband over speex smallband and all other audio codecs. And in general disable various codecs that are not really suitable for use in conferencing. From: Sjoerd Simons svn path=/trunk/; revision=2567 --- libempathy/empathy-call-handler.c | 52 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'libempathy/empathy-call-handler.c') diff --git a/libempathy/empathy-call-handler.c b/libempathy/empathy-call-handler.c index 59afe3f99..8d159cdd4 100644 --- a/libempathy/empathy-call-handler.c +++ b/libempathy/empathy-call-handler.c @@ -289,6 +289,56 @@ empathy_call_handler_tf_channel_closed_cb (TfChannel *tfchannel, g_signal_emit (G_OBJECT (handler), signals[CLOSED], 0); } +static GList * +empathy_call_handler_tf_channel_codec_config_get_defaults (FsCodec *codecs) +{ + GList *l = NULL; + int i; + + for (i = 0; codecs[i].encoding_name != NULL; i++) + l = g_list_append (l, fs_codec_copy (codecs + i)); + + return l; +} + +static GList * +empathy_call_handler_tf_channel_codec_config_cb (TfChannel *channel, + guint stream_id, FsMediaType media_type, guint direction, gpointer user_data) +{ + FsCodec audio_codecs[] = { + { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 16000, }, + { FS_CODEC_ID_ANY, "SPEEX", FS_MEDIA_TYPE_AUDIO, 8000, }, + + { FS_CODEC_ID_DISABLE, "DV", FS_MEDIA_TYPE_AUDIO, }, + { FS_CODEC_ID_DISABLE, "MPA", FS_MEDIA_TYPE_AUDIO, }, + { FS_CODEC_ID_DISABLE, "VORBIS", FS_MEDIA_TYPE_AUDIO, }, + { FS_CODEC_ID_DISABLE, "MP3", FS_MEDIA_TYPE_AUDIO, }, + { 0, NULL, 0,} + }; + FsCodec video_codecs[] = { + { FS_CODEC_ID_ANY, "H264", FS_MEDIA_TYPE_VIDEO, }, + { FS_CODEC_ID_ANY, "THEORA", FS_MEDIA_TYPE_VIDEO, }, + { FS_CODEC_ID_ANY, "H263", FS_MEDIA_TYPE_VIDEO, }, + + { FS_CODEC_ID_DISABLE, "DV", FS_MEDIA_TYPE_VIDEO, }, + { FS_CODEC_ID_DISABLE, "JPEG", FS_MEDIA_TYPE_VIDEO, }, + { FS_CODEC_ID_DISABLE, "MPV", FS_MEDIA_TYPE_VIDEO, }, + { 0, NULL, 0} + }; + + switch (media_type) + { + case FS_MEDIA_TYPE_AUDIO: + return empathy_call_handler_tf_channel_codec_config_get_defaults + (audio_codecs); + case FS_MEDIA_TYPE_VIDEO: + return empathy_call_handler_tf_channel_codec_config_get_defaults + (video_codecs); + } + + return NULL; +} + static void empathy_call_handler_start_tpfs (EmpathyCallHandler *self) { @@ -308,6 +358,8 @@ empathy_call_handler_start_tpfs (EmpathyCallHandler *self) G_CALLBACK (empathy_call_handler_tf_channel_stream_created_cb), self); g_signal_connect (priv->tfchannel, "closed", G_CALLBACK (empathy_call_handler_tf_channel_closed_cb), self); + g_signal_connect (priv->tfchannel, "stream-get-codec-config", + G_CALLBACK (empathy_call_handler_tf_channel_codec_config_cb), self); g_object_unref (channel); } -- cgit v1.2.3