/* linphone Copyright (C) 2010 Belledonne Communications SARL (simon.morlat@linphone.org) This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "linphone/core.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif #include static bool_t running=TRUE; static bool_t print_stats=FALSE; static bool_t dump_stats=FALSE; static void stop(int signum){ running=FALSE; } #ifndef _WIN32 static void stats(int signum){ print_stats=TRUE; } static void dump_call_logs(int signum){ dump_stats=TRUE; } #endif /* * Call state notification callback */ static void call_state_changed(LinphoneCore *lc, LinphoneCall *call, LinphoneCallState cstate, const char *msg){ LinphoneCallParams * call_params; switch(cstate){ case LinphoneCallIncomingReceived: ms_message("Incoming call arriving !\n"); /* accept the incoming call*/ call_params = linphone_core_create_call_params(lc, call); linphone_call_params_enable_video(call_params,TRUE); linphone_call_params_set_audio_direction(call_params,LinphoneMediaDirectionSendOnly); linphone_call_params_set_video_direction(call_params,LinphoneMediaDirectionSendOnly); linphone_core_accept_call_with_params(lc,call,call_params); linphone_call_params_unref(call_params); break; default: break; } } extern MSWebCamDesc mire_desc; static void helper(const char *progname) { printf("%s --help\n" "\t\t\t--listening-uri uri to listen on, default [sip:localhost:5060]\n" "\t\t\t--max-call-duration max duration of a call in seconds, default [3600]\n" "\t\t\t--media-file \n" "\t\t\t--verbose\n", progname); exit(0); } int main(int argc, char *argv[]){ LinphoneCoreVTable vtable={0}; LinphoneCore *lc; LinphoneVideoPolicy policy; int i; LinphoneAddress *addr=NULL; LCSipTransports tp; char * tmp = NULL; LpConfig * lp_config = lp_config_new(NULL); int max_call_duration=3600; static const char *media_file = NULL; policy.automatically_accept=TRUE; signal(SIGINT,stop); #ifndef _WIN32 signal(SIGUSR1,stats); signal(SIGUSR2,dump_call_logs); #endif for(i = 1; i < argc; ++i) { if (strcmp(argv[i], "--verbose") == 0) { linphone_core_set_log_level_mask(ORTP_MESSAGE|ORTP_WARNING|ORTP_ERROR|ORTP_FATAL); } else if (strcmp(argv[i], "--max-call-duration") == 0){ max_call_duration = atoi(argv[++i]); } else if (strcmp(argv[i], "--listening-uri") == 0){ addr = linphone_address_new(argv[++i]); if (!addr) { printf("Error, bad sip uri"); helper(argv[0]); } /* switch(linphone_address_get_transport(addr)) { case LinphoneTransportUdp: case LinphoneTransportTcp: break; default: ms_error("Error, bad sip uri [%s] transport, should be udp | tcp",argv[i]); helper(); break; }*/ } else if (strcmp(argv[i], "--media-file") == 0){ i++; if (inext) { LinphoneCallLog *call_log=(LinphoneCallLog *)iterator->data; char * tmp_str = linphone_call_log_to_str(call_log); ms_message("\n%s",tmp_str); ms_free(tmp_str); } dump_stats=FALSE; ms_message("*********************************"); } for (iterator=linphone_core_get_calls(lc);iterator!=NULL;iterator=iterator->next) { LinphoneCall *call=(LinphoneCall *)iterator->data; if (linphone_call_get_duration(call) > max_call_duration) { ms_message("Terminating call [%p] after [%i] s",call,linphone_call_get_duration(call)); linphone_core_terminate_call(lc,call); break; } } } ms_message("Shutting down...\n"); linphone_core_destroy(lc); ms_message("Exited\n"); return 0; }