Commit 0b32c8f1 authored by smorlat's avatar smorlat

merge g722 stuff for msrtp.c

wip for linphonecsh
	


git-svn-id: svn+ssh://svn.savannah.nongnu.org/linphone/trunk@243 3f6dc0c8-ddfe-455d-9043-3cd528dc4637
parent 53b35a41
......@@ -58,6 +58,7 @@ static int lpc_cmd_friend(LinphoneCore *, char*);
static int lpc_cmd_soundcard(LinphoneCore *, char *);
static int lpc_cmd_play(LinphoneCore *, char *);
static int lpc_cmd_record(LinphoneCore *, char *);
static int lpc_cmd_register(LinphoneCore *, char *);
/* Command handler helpers */
static void linphonec_proxy_add(LinphoneCore *lc);
static void linphonec_proxy_display(LinphoneProxyConfig *lc);
......@@ -71,6 +72,8 @@ static int linphonec_friend_call(LinphoneCore *lc, unsigned int num);
static int linphonec_friend_add(LinphoneCore *lc, const char *name, const char *addr);
static int linphonec_friend_delete(LinphoneCore *lc, int num);
/* Command table management */
static LPC_COMMAND *lpc_find_command(const char *name);
......@@ -153,6 +156,7 @@ LPC_COMMAND commands[] = {
"'record <wav file>' : record into wav file."
},
{ "quit", lpc_cmd_quit, "Exit linphonec", NULL },
{ "register", lpc_cmd_register, "register <sip uri> <sip proxy>", NULL },
{ (char *)NULL, (lpc_cmd_handler)NULL, (char *)NULL, (char *)NULL }
};
......@@ -1117,6 +1121,43 @@ linphonec_display_command_help(LPC_COMMAND *cmd)
else linphonec_out("%s\n", cmd->help);
}
static int lpc_cmd_register(LinphoneCore *lc, char *args){
char identity[512];
char proxy[512];
char passwd[512];
LinphoneProxyConfig *cfg;
const MSList *elem;
passwd[0]=proxy[0]=identity[0]='\0';
sscanf(args,"%s %s %s",identity,proxy,passwd);
if (proxy[0]=='\0' || identity[0]=='\0'){
linphonec_out("Missing parameters, see help register\n");
return 1;
}
if (passwd[0]!='\0'){
osip_from_t *from;
LinphoneAuthInfo *info;
osip_from_init(&from);
if (osip_from_parse(from,identity)==0){
info=linphone_auth_info_new(from->url->username,NULL,passwd,NULL,NULL);
linphone_core_add_auth_info(lc,info);
}
osip_from_free(from);
}
elem=linphone_core_get_proxy_config_list(lc);
if (elem) {
cfg=(LinphoneProxyConfig*)elem->data;
linphone_proxy_config_edit(cfg);
}
else cfg=linphone_proxy_config_new();
linphone_proxy_config_set_identity(cfg,identity);
linphone_proxy_config_set_server_addr(cfg,proxy);
linphone_proxy_config_enable_register(cfg,TRUE);
if (elem) linphone_proxy_config_done(cfg);
else linphone_core_add_proxy_config(lc,cfg);
return 1;
}
/***************************************************************************
*
* Command table management funx
......
......@@ -133,6 +133,53 @@ static int send_generic_command(const char *command, int print_result){
return err;
}
static int register_execute(int argc, char *argv[]){
char cmd[512];
char *username=NULL;
char *host=NULL;
char *passwd=NULL;
int i;
for(i=0;i<argc;++i){
if (strcmp(argv[i],"--host")==0){
i++;
if (i<argc){
host=argv[i];
}else print_usage();
}else if (strcmp(argv[i],"--username")==0){
i++;
if (i<argc){
username=argv[i];
}else print_usage();
}else if (strcmp(argv[i],"--password")==0){
i++;
if (i<argc){
passwd=argv[i];
}else print_usage();
}else print_usage();
}
if (username==NULL) {
fprintf(stderr,"Missing --username\n");
print_usage();
}
if (host==NULL) {
fprintf(stderr,"Missing --host\n");
print_usage();
}
if (passwd) snprintf(cmd,sizeof(cmd),"register sip:%s@%s sip:%s %s",username,host,host,passwd);
else snprintf(cmd,sizeof(cmd),"register sip:%s@%s sip:%s",username,host,host);
return send_generic_command(cmd,TRUE);
}
static int dial_execute(int argc, char *argv[]){
char cmd[512];
if (argc==1){
snprintf(cmd,sizeof(cmd),"call %s",argv[0]);
return send_generic_command(cmd,TRUE);
}else{
print_usage();
}
return -1;
}
int main(int argc, char *argv[]){
int argi;
if (argc<2){
......@@ -152,6 +199,10 @@ int main(int argc, char *argv[]){
if (argi+1<argc){
return send_generic_command(argv[argi+1],1);
}else print_usage();
}else if (strcmp(argv[argi],"register")==0){
return register_execute(argc-argi-1,&argv[argi+1]);
}else if (strcmp(argv[argi],"dial")==0){
return dial_execute(argc-argi-1,&argv[argi+1]);
}
}
return 0;
......
......@@ -101,7 +101,9 @@ static int sender_set_session(MSFilter * f, void *arg)
rtp_profile_get_payload(rtp_session_get_profile(s),
rtp_session_get_send_payload_type(s));
if (pt != NULL) {
d->rate = pt->clock_rate;
if (strcasecmp("g722", pt->mime_type)==0 )
d->rate=8000;
else d->rate = pt->clock_rate;
} else {
ms_warning("Sending undefined payload type ?");
}
......@@ -323,7 +325,9 @@ static int receiver_set_session(MSFilter * f, void *arg)
rtp_session_get_recv_payload_type
(s));
if (pt != NULL) {
d->rate = pt->clock_rate;
if (strcasecmp("g722", pt->mime_type)==0 )
d->rate=8000;
else d->rate = pt->clock_rate;
} else {
ms_warning("Receiving undefined payload type ?");
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment