hi, i have added ring start,ringback, and ring stop functions in my program, i have given all default value for that and now my main function is: int main(int argc, char *argv[]) { int i; pjsua_acc_id acc_id; pj_status_t status; pjsua_transport_id transport_id =-1; //pjsua_transport_config tcp_cfg; /* Create pjsua first! */ status = pjsua_create(); if (status != PJ_SUCCESS) error_exit("Error in pjsua_create()", status); /* If argument is specified, it's got to be a valid SIP URL */ if (argc > 1) { status = pjsua_verify_sip_url(argv[1]); if (status != PJ_SUCCESS) error_exit("Invalid URL in argv", status); } /* Init pjsua */ default_config(&app_config); status =parse_args(argc,argv,&app_config,&uri_arg); if(status!=PJ_SUCCESS) return status; app_config.cfg.cb.on_incoming_call = &on_incoming_call; app_config.cfg.cb.on_call_media_state = &on_call_media_state; app_config.cfg.cb.on_call_state = &on_call_state; //pjsua_logging_config_default(&log_cfg); app_config.log_cfg.console_level = 4; status = pjsua_init(&app_config.cfg, &app_config.log_cfg, &app_config.media_cfg); if (status != PJ_SUCCESS) error_exit("Error in pjsua_init()", status); #ifdef STEREO_DEMO stereo_demo(); #endif /* Optionally registers WAV file */ for (i=0; i<1; ++i) { pjsua_player_id wav_id; unsigned play_options = 0; if (app_config.auto_play_hangup) play_options |= PJMEDIA_FILE_NO_LOOP; status = pjsua_player_create(&app_config.wav_files[i], play_options, &wav_id); if (status != PJ_SUCCESS) printf("Unable to create player\n"); //goto on_error; if (app_config.wav_id == PJSUA_INVALID_ID) { app_config.wav_id = wav_id; app_config.wav_port = pjsua_player_get_conf_port(app_config.wav_id); if (app_config.auto_play_hangup) { pjmedia_port *port; pjsua_player_get_port(app_config.wav_id, &port); status = pjmedia_wav_player_set_eof_cb(port, NULL, &on_playfile_done); if (status != PJ_SUCCESS) printf("Unable to get port for wav player\n"); } } } printf("%d..............................................\n",app_config.tone_count); /* Optionally registers tone players */ for (i=0; i<1; ++i) { pjmedia_port *tport; char name[80]; pj_str_t label; pj_status_t status; pj_ansi_snprintf(name, sizeof(name), "tone-%d,%d", app_config.tones[i].freq1, app_config.tones[i].freq2); label = pj_str(name); status = pjmedia_tonegen_create2(app_config.pool, &label, 8000, 1, 160, 16, PJMEDIA_TONEGEN_LOOP, &tport); if (status != PJ_SUCCESS) { pjsua_perror(THIS_FILE, "Unable to create tone generator", status); //goto on_error; } status = pjsua_conf_add_port(app_config.pool, tport, &app_config.tone_slots[i]); pj_assert(status == PJ_SUCCESS); status = pjmedia_tonegen_play(tport, 1, &app_config.tones[i], 0); pj_assert(status == PJ_SUCCESS); } /* Create ringback tones */ if (app_config.no_tones == PJ_FALSE) { unsigned i, samples_per_frame; pjmedia_tone_desc tone[RING_CNT+RINGBACK_CNT]; pj_str_t name; samples_per_frame = app_config.media_cfg.audio_frame_ptime * app_config.media_cfg.clock_rate * app_config.media_cfg.channel_count / 1000; /* Ringback tone (call is ringing) */ name = pj_str("ringback"); status = pjmedia_tonegen_create2(app_config.pool, &name, app_config.media_cfg.clock_rate, app_config.media_cfg.channel_count, samples_per_frame, 16, PJMEDIA_TONEGEN_LOOP, &app_config.ringback_port); if (status != PJ_SUCCESS) printf("Ringback tone can not create\n"); //goto on_error; pj_bzero(&tone, sizeof(tone)); for (i=0; i<RINGBACK_CNT; ++i) { tone[i].freq1 = RINGBACK_FREQ1; tone[i].freq2 = RINGBACK_FREQ2; tone[i].on_msec = RINGBACK_ON; tone[i].off_msec = RINGBACK_OFF; } tone[RINGBACK_CNT-1].off_msec = RINGBACK_INTERVAL; pjmedia_tonegen_play(app_config.ringback_port, RINGBACK_CNT, tone, PJMEDIA_TONEGEN_LOOP); status = pjsua_conf_add_port(app_config.pool, app_config.ringback_port, &app_config.ringback_slot); if (status != PJ_SUCCESS) printf("unable to add ringback port\n"); //goto on_error; /* Ring (to alert incoming call) */ name = pj_str("ring"); status = pjmedia_tonegen_create2(app_config.pool, &name, app_config.media_cfg.clock_rate, app_config.media_cfg.channel_count, samples_per_frame, 16, PJMEDIA_TONEGEN_LOOP, &app_config.ring_port); if (status != PJ_SUCCESS) printf("Ring can not create\n"); //goto on_error; for (i=0; i<RING_CNT; ++i) { tone[i].freq1 = RING_FREQ1; tone[i].freq2 = RING_FREQ2; tone[i].on_msec = RING_ON; tone[i].off_msec = RING_OFF; } tone[RING_CNT-1].off_msec = RING_INTERVAL; pjmedia_tonegen_play(app_config.ring_port, RING_CNT, tone, PJMEDIA_TONEGEN_LOOP); status = pjsua_conf_add_port(app_config.pool, app_config.ring_port, &app_config.ring_slot); if (status != PJ_SUCCESS) printf("Unable to add Ring port\n"); //goto on_error; } /* Add UDP transport. */ { //pjsua_transport_config cfg; //pjsua_transport_config_default(&cfg); //cfg.port = 5060; status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &app_config.udp_cfg, &transport_id); if (status != PJ_SUCCESS) error_exit("Error creating transport", status); } /* Set sound device latency */ pjmedia_snd_set_latency(app_config.capture_lat, app_config.playback_lat); /* Use null sound device? */ #ifndef STEREO_DEMO if (app_config.null_audio) { status = pjsua_set_null_snd_dev(); if (status != PJ_SUCCESS) return status; } #endif if (app_config.capture_dev != PJSUA_INVALID_ID || app_config.playback_dev != PJSUA_INVALID_ID) { status = pjsua_set_snd_dev(app_config.capture_dev, app_config.playback_dev); if (status != PJ_SUCCESS) // goto on_error; printf("Unable to open playback device\n"); } /* Initialization is done, now start pjsua */ status = pjsua_start(); if (status != PJ_SUCCESS) error_exit("Error starting pjsua", status); /* Register to SIP server by creating SIP account. */ { pjsua_acc_config cfg; pjsua_acc_config_default(&cfg); cfg.id = pj_str("sip:" SIP_USER "@" SIP_DOMAIN); cfg.reg_uri = pj_str("sip:" SIP_DOMAIN); cfg.cred_count = 1; cfg.cred_info[0].realm = pj_str("*"); cfg.cred_info[0].scheme = pj_str("digest"); cfg.cred_info[0].username = pj_str(SIP_USER); cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD; cfg.cred_info[0].data = pj_str(SIP_PASSWD); status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id); if (status != PJ_SUCCESS) error_exit("Error adding account", status); } printf("%d......................",app_config.wav_count); /* If URL is specified, make call to the URL. */ if (argc > 1) { pj_str_t uri = pj_str(argv[1]); status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL); if (status != PJ_SUCCESS) error_exit("Error making call", status); } for (;;) { char option[10]; puts("Press 'h' to hangup all calls, 'q' to quit"); fgets(option, sizeof(option), stdin); if (option[0] == 'q'){ pjsua_destroy(); break; } if (option[0] == 'h') pjsua_call_hangup_all(); } but still i am not getting ring, i think i am not getting correct value of tone_count and wav_count, will you help for this.... Regards New_bie -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20090116/85cd6114/attachment-0001.html>