merge patch allowing overriding of display

This commit is contained in:
Simon Morlat 2010-10-06 14:51:55 +02:00
parent 7132d2711f
commit cfe0c35083
9 changed files with 81 additions and 103 deletions

View file

@ -34,7 +34,6 @@
#include <ctype.h>
#include <linphonecore.h>
#include "linphonec.h"
#include "private.h"
#include "lpconfig.h"
#ifndef WIN32
@ -633,7 +632,7 @@ lpc_cmd_transfer(LinphoneCore *lc, char *args)
int n=sscanf(args,"%s %s",arg1,arg2);
if (n==1 || isalpha(*arg1)){
call=linphone_core_get_current_call(lc);
if (call==NULL && linphone_core_get_calls_nb (lc)==1){
if (call==NULL && ms_list_size(linphone_core_get_calls(lc))==1){
call=(LinphoneCall*)linphone_core_get_calls(lc)->data;
}
refer_to=args;
@ -1454,7 +1453,7 @@ linphonec_proxy_add(LinphoneCore *lc)
}
linphone_proxy_config_set_identity(cfg, clean);
if ( ! cfg->reg_identity )
if ( ! linphone_proxy_config_get_identity (cfg))
{
linphonec_out("Invalid identity (sip:name@sip.domain.tld).\n");
free(input);
@ -1523,7 +1522,7 @@ linphonec_proxy_add(LinphoneCore *lc)
}
linphone_proxy_config_expires(cfg, expires);
linphonec_out("Expiration: %d seconds\n", cfg->expires);
linphonec_out("Expiration: %d seconds\n", linphone_proxy_config_get_expires (cfg));
free(input);
break;
@ -1553,7 +1552,7 @@ linphonec_proxy_add(LinphoneCore *lc)
}
linphone_proxy_config_set_route(cfg, clean);
if ( ! cfg->reg_route )
if ( ! linphone_proxy_config_get_route(cfg) )
{
linphonec_out("Invalid route.\n");
free(input);
@ -1617,12 +1616,14 @@ linphonec_proxy_add(LinphoneCore *lc)
static void
linphonec_proxy_display(LinphoneProxyConfig *cfg)
{
const char *route=linphone_proxy_config_get_route(cfg);
const char *identity=linphone_proxy_config_get_identity(cfg);
linphonec_out("sip address: %s\nroute: %s\nidentity: %s\nregister: %s\nexpires: %i\nregistered: %s\n",
cfg->reg_proxy,
(cfg->reg_route!=NULL)?cfg->reg_route:"",
(cfg->reg_identity!=NULL)?cfg->reg_identity:"",
(cfg->reg_sendregister)?"yes":"no",
cfg->expires,
linphone_proxy_config_get_addr(cfg),
(route!=NULL)? route:"",
(identity!=NULL)?identity:"",
linphone_proxy_config_register_enabled (cfg)?"yes":"no",
linphone_proxy_config_get_expires (cfg),
linphone_proxy_config_is_registered(cfg) ? "yes" : "no");
}
@ -1670,7 +1671,7 @@ linphonec_proxy_remove(LinphoneCore *lc, int index)
return;
}
linphone_core_remove_proxy_config(lc,cfg);
linphonec_out("Proxy %s removed.\n", cfg->reg_proxy);
linphonec_out("Proxy %s removed.\n", linphone_proxy_config_get_addr(cfg));
}
static int
@ -2052,14 +2053,13 @@ static int lpc_cmd_codec(int type, LinphoneCore *lc, char *args){
static void linphonec_codec_list(int type, LinphoneCore *lc){
PayloadType *pt;
codecs_config_t *config=&lc->codecs_conf;
int index=0;
MSList *node=NULL;
const MSList *node=NULL;
if (type == AUDIO) {
node=config->audio_codecs;
node=linphone_core_get_audio_codecs(lc);
} else if(type==VIDEO) {
node=config->video_codecs;
node=linphone_core_get_video_codecs(lc);
}
for(;node!=NULL;node=ms_list_next(node)){
@ -2072,20 +2072,19 @@ static void linphonec_codec_list(int type, LinphoneCore *lc){
static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
PayloadType *pt;
codecs_config_t *config=&lc->codecs_conf;
int index=0;
MSList *node=NULL;
const MSList *node=NULL;
if (type == AUDIO) {
node=config->audio_codecs;
} else if(type==VIDEO) {
node=config->video_codecs;
}
if (type == AUDIO) {
node=linphone_core_get_audio_codecs(lc);
} else if(type==VIDEO) {
node=linphone_core_get_video_codecs(lc);
}
for(;node!=NULL;node=ms_list_next(node)){
if (index == sel_index || sel_index == -1) {
pt=(PayloadType*)(node->data);
pt->flags|=PAYLOAD_TYPE_ENABLED;
linphone_core_enable_payload_type (lc,pt,TRUE);
linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "enabled");
}
index++;
@ -2094,22 +2093,21 @@ static void linphonec_codec_enable(int type, LinphoneCore *lc, int sel_index){
static void linphonec_codec_disable(int type, LinphoneCore *lc, int sel_index){
PayloadType *pt;
codecs_config_t *config=&lc->codecs_conf;
int index=0;
MSList *node=NULL;
const MSList *node=NULL;
if (type == AUDIO) {
node=config->audio_codecs;
} else if(type==VIDEO) {
node=config->video_codecs;
}
if (type == AUDIO) {
node=linphone_core_get_audio_codecs(lc);
} else if(type==VIDEO) {
node=linphone_core_get_video_codecs(lc);
}
for(;node!=NULL;node=ms_list_next(node)){
if (index == sel_index || sel_index == -1) {
pt=(PayloadType*)(node->data);
pt->flags&=~PAYLOAD_TYPE_ENABLED;
linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
}
if (index == sel_index || sel_index == -1) {
pt=(PayloadType*)(node->data);
linphone_core_enable_payload_type (lc,pt,FALSE);
linphonec_out("%2d: %s (%d) %s\n", index, pt->mime_type, pt->clock_rate, "disabled");
}
index++;
}
}
@ -2118,6 +2116,7 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
char *arg1 = args;
char *arg2 = NULL;
char *ptr = args;
LpConfig *config=linphone_core_get_config(lc);
if (!args) return 0;
@ -2140,16 +2139,16 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
n = sscanf(arg2, "%d %d %d", &delay, &tail_len, &frame_size);
if (n == 1) {
lp_config_set_int(lc->config,"sound","ec_delay",delay);
lp_config_set_int(config,"sound","ec_delay",delay);
}
else if (n == 2) {
lp_config_set_int(lc->config,"sound","ec_delay",delay);
lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
lp_config_set_int(config,"sound","ec_delay",delay);
lp_config_set_int(config,"sound","ec_tail_len",tail_len);
}
else if (n == 3) {
lp_config_set_int(lc->config,"sound","ec_delay",delay);
lp_config_set_int(lc->config,"sound","ec_tail_len",tail_len);
lp_config_set_int(lc->config,"sound","ec_framesize",frame_size);
lp_config_set_int(config,"sound","ec_delay",delay);
lp_config_set_int(config,"sound","ec_tail_len",tail_len);
lp_config_set_int(config,"sound","ec_framesize",frame_size);
}
}
}
@ -2159,9 +2158,9 @@ static int lpc_cmd_echocancellation(LinphoneCore *lc, char *args){
else if (strcmp(arg1,"show")==0){
linphonec_out("echo cancellation is %s; delay %d, tail length %d, frame size %d\n",
linphone_core_echo_cancellation_enabled(lc) ? "on" : "off",
lp_config_get_int(lc->config,"sound","ec_delay",0),
lp_config_get_int(lc->config,"sound","ec_tail_len",0),
lp_config_get_int(lc->config,"sound","ec_framesize",0));
lp_config_get_int(config,"sound","ec_delay",0),
lp_config_get_int(config,"sound","ec_tail_len",0),
lp_config_get_int(config,"sound","ec_framesize",0));
}
else {
return 0;

View file

@ -160,6 +160,7 @@ LPC_AUTH_STACK auth_stack;
static int trace_level = 0;
static char *logfile_name = NULL;
static char configfile_name[PATH_MAX];
static const char *factory_configfile_name=NULL;
static char *sipAddr = NULL; /* for autocall */
#if !defined(_WIN32_WCE)
static ortp_pipe_t client_sock=ORTP_PIPE_INVALID;
@ -696,8 +697,7 @@ linphonec_init(int argc, char **argv)
/*
* Initialize linphone core
*/
linphonec=linphone_core_new (&linphonec_vtable, configfile_name, NULL,
NULL);
linphonec=linphone_core_new (&linphonec_vtable, configfile_name, factory_configfile_name, NULL);
linphone_core_enable_video(linphonec,vcap_enabled,display_enabled);
linphone_core_enable_video_preview(linphonec,preview_enabled);
if (!(vcap_enabled || display_enabled)) printf("Warning: video is disabled in linphonec, use -V or -C or -D to enable.\n");
@ -847,6 +847,7 @@ print_usage (int exit_status)
usage: linphonec [-c file] [-s sipaddr] [-a] [-V] [-d level ] [-l logfile]\n\
linphonec -v\n\
\n\
-b file specify path of readonly factory configuration file.\n\
-c file specify path of configuration file.\n\
-d level be verbose. 0 is no output. 6 is all output\n\
-l logfile specify the log file for your SIP phone\n\
@ -1140,6 +1141,20 @@ linphonec_parse_cmdline(int argc, char **argv)
#endif /*_WIN32_WCE*/
snprintf(configfile_name, PATH_MAX, "%s", argv[arg_num]);
}
else if (strncmp ("-b", argv[arg_num], 2) == 0)
{
if ( ++arg_num >= argc ) print_usage(EXIT_FAILURE);
#if !defined(_WIN32_WCE)
if (access(argv[arg_num],F_OK)!=0 )
{
fprintf (stderr,
"Cannot open config file %s.\n",
argv[arg_num]);
exit(EXIT_FAILURE);
}
#endif /*_WIN32_WCE*/
factory_configfile_name = argv[arg_num];
}
else if (strncmp ("-s", argv[arg_num], 2) == 0)
{
arg_num++;

View file

@ -139,7 +139,7 @@ static bool_t strings_equals(const char *s1, const char *s2){
* Compare two LinphoneAddress ignoring tags and headers, basically just domain, username, and port.
* Returns TRUE if they are equal.
**/
bool_t linphone_address_weak_compare(const LinphoneAddress *a1, const LinphoneAddress *a2){
bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2){
const char *u1,*u2;
const char *h1,*h2;
int p1,p2;

View file

@ -39,8 +39,8 @@ static bool_t is_duplicate_call(LinphoneCore *lc, const LinphoneAddress *from, c
MSList *elem;
for(elem=lc->calls;elem!=NULL;elem=elem->next){
LinphoneCall *call=(LinphoneCall*)elem->data;
if (linphone_address_weak_compare(call->log->from,from) &&
linphone_address_weak_compare(call->log->to, to)){
if (linphone_address_weak_equal(call->log->from,from) &&
linphone_address_weak_equal(call->log->to, to)){
return TRUE;
}
}

View file

@ -52,10 +52,11 @@
void linphone_chat_room_send_message(LinphoneChatRoom *cr, const char *msg){
const char *identity=linphone_core_get_identity(cr->lc);
SalOp *op;
if(linphone_core_is_in_communication_with(cr->lc,cr->peer))
LinphoneCall *call;
if((call = linphone_core_get_call_by_remote_address(cr->lc,cr->peer))!=NULL)
{
ms_message("send SIP message into the call\n");
op = (linphone_core_get_current_call(cr->lc))->op;
op = call->op;
}
else
{

View file

@ -569,6 +569,8 @@ void linphone_call_init_media_streams(LinphoneCall *call){
#ifdef VIDEO_ENABLED
if ((lc->video_conf.display || lc->video_conf.capture) && md->streams[1].port>0){
call->videostream=video_stream_new(md->streams[1].port,linphone_core_ipv6_enabled(lc));
if( lc->video_conf.displaytype != NULL)
video_stream_set_display_filter_name(call->videostream,lc->video_conf.displaytype);
#ifdef TEST_EXT_RENDERER
video_stream_set_render_callback(call->videostream,rendercb,NULL);
#endif

View file

@ -350,8 +350,7 @@ void linphone_core_disable_logs(){
}
static void
net_config_read (LinphoneCore *lc)
static void net_config_read (LinphoneCore *lc)
{
int tmp;
const char *tmpstr;
@ -774,6 +773,9 @@ static void video_config_read(LinphoneCore *lc){
capture=lp_config_get_int(lc->config,"video","capture",enabled);
display=lp_config_get_int(lc->config,"video","display",enabled);
self_view=lp_config_get_int(lc->config,"video","self_view",enabled);
lc->video_conf.displaytype=lp_config_get_string(lc->config,"video","displaytype",NULL);
if(lc->video_conf.displaytype)
ms_message("we are using a specific display:%s\n",lc->video_conf.displaytype);
#ifdef VIDEO_ENABLED
linphone_core_enable_video(lc,capture,display);
linphone_core_enable_self_view(lc,self_view);
@ -1832,25 +1834,6 @@ const char * linphone_core_get_route(LinphoneCore *lc){
return route;
}
bool_t linphone_core_is_in_communication_with(LinphoneCore *lc, const char *to)
{
char *tmp;
bool_t returned;
const LinphoneAddress *la=linphone_core_get_current_call_remote_address(lc);
if(la == NULL)
{
return FALSE;
}
tmp = linphone_address_as_string(la);
if(!strcmp(tmp,to))
returned = TRUE;
else
returned = FALSE;
if(tmp)
ms_free(tmp);
return returned;
}
void linphone_core_start_pending_refered_calls(LinphoneCore *lc){
MSList *elem;
for(elem=lc->calls;elem!=NULL;elem=elem->next){
@ -2446,28 +2429,9 @@ int linphone_core_resume_call(LinphoneCore *lc, LinphoneCall *the_call)
return 0;
}
/**
* Compare the remote address with the one in call
*
* @param a the call
* @param b the remote address to compare with
* @return 0 if it's the good call else 1
*/
static int linphone_call_remote_address_compare(const void * a, const void * b)
{
if(b == NULL || a ==NULL)
return 1;
char *the_remote_address = ((char *)b);
LinphoneCall *call = ((LinphoneCall *)a);
#ifdef DEBUG
ms_message("the remote address:%s\n",the_remote_address);
ms_message("the call:%p => %s\n",call,linphone_call_get_remote_address_as_string(call));
#endif
if(!strcmp(linphone_call_get_remote_address_as_string(call),the_remote_address))
{
return 0;
}
return 1;
static int remote_address_compare(LinphoneCall *call, const LinphoneAddress *raddr){
const LinphoneAddress *addr=linphone_call_get_remote_address (call);
return !linphone_address_weak_equal (addr,raddr);
}
/**
@ -2477,12 +2441,9 @@ static int linphone_call_remote_address_compare(const void * a, const void * b)
* @return the LinphoneCall of the call if found
*/
LinphoneCall *linphone_core_get_call_by_remote_address(LinphoneCore *lc, const char *remote_address){
MSList *the_call = ms_list_find_custom(lc->calls,linphone_call_remote_address_compare,(void *)remote_address);
if(the_call != NULL)
{
return ((LinphoneCall *)the_call->data);
}
LinphoneAddress *raddr=linphone_address_new(remote_address);
MSList *elem=ms_list_find_custom(lc->calls,(int (*)(const void*,const void *))remote_address_compare,raddr);
if (elem) return (LinphoneCall*) elem->data;
return NULL;
}
@ -3082,7 +3043,7 @@ static void toggle_video_preview(LinphoneCore *lc, bool_t val){
if (val){
if (lc->previewstream==NULL){
lc->previewstream=video_preview_start(lc->video_conf.device,
lc->video_conf.vsize);
lc->video_conf.vsize,lc->video_conf.displaytype);
}
}else{
if (lc->previewstream!=NULL){

View file

@ -93,7 +93,7 @@ void linphone_address_set_port_int(LinphoneAddress *uri, int port);
void linphone_address_clean(LinphoneAddress *uri);
char *linphone_address_as_string(const LinphoneAddress *u);
char *linphone_address_as_string_uri_only(const LinphoneAddress *u);
bool_t linphone_address_weak_compare(const LinphoneAddress *a1, const LinphoneAddress *a2);
bool_t linphone_address_weak_equal(const LinphoneAddress *a1, const LinphoneAddress *a2);
void linphone_address_destroy(LinphoneAddress *u);
struct _SipSetupContext;

View file

@ -188,7 +188,6 @@ void linphone_call_stop_media_streams(LinphoneCall *call);
const char * linphone_core_get_identity(LinphoneCore *lc);
const char * linphone_core_get_route(LinphoneCore *lc);
bool_t linphone_core_is_in_communication_with(LinphoneCore *lc, const char *to);
void linphone_core_start_waiting(LinphoneCore *lc, const char *purpose);
void linphone_core_update_progress(LinphoneCore *lc, const char *purpose, float progresses);
void linphone_core_stop_waiting(LinphoneCore *lc);
@ -340,6 +339,7 @@ typedef struct video_config{
bool_t show_local;
bool_t display;
bool_t selfview; /*during calls*/
const char *displaytype;
}video_config_t;
typedef struct ui_config