Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Developer
CapQNX
Posts: 112
Registered: ‎01-11-2013
My Device: BlackBerry Curve
Accepted Solution

make a call using pjsip

Hi 

 

- I created sample VOIP application using pjsip, in my application registered successfully with iptel server
- I want to make a call , but i am not able to call. i am not getting error however nothing is happning.

Reference in this : http://208.74.204.192/t5/Native-Development/Porting-PJSIP-PJMEDIA-and-PJLIB-to-BlackBerry-10/ta-p/20...

Thanks All,


My Code is 

status = pjsua_create();

	if (status != PJ_SUCCESS) {
		handleError("Error creating pjsua", status);
		return status;
	}

	{
		pjsua_config cfg;
		pjsua_logging_config log_cfg;

		pjsua_config_default(&cfg);

		// Set up the two static callbacks for session up session down
		// This is where all callbacks are initialized. See PJSIP documentation
		// session up
		cfg.cb.on_reg_started = &on_reg_started;
		// traps session down
		cfg.cb.on_transport_state = &on_tp_state_changed;

		// accept incomming call
		cfg.cb.on_incoming_call = &on_incoming_call;
		// Callback called by the library when call's media state has changed
		cfg.cb.on_call_media_state = &on_call_media_state;
		// Callback called by the library when call's state has changed
		cfg.cb.on_call_state = &on_call_state;

		pjsua_logging_config_default(&log_cfg);
		log_cfg.console_level = 4;

		pjsua_media_config media_cfg;

		pjsua_media_config_default(&media_cfg);

		status = pjsua_init(&cfg, &log_cfg, &media_cfg);

		qDebug() << "2. PJ_SUCCESS :" << PJ_SUCCESS << " status : " << status;

		if (status != PJ_SUCCESS) {
			handleError("Error initializing pjsua", status);
			return status;
		}

	}

	/* Add UDP transport. */
	{
		pjsua_transport_config cfg;

		pjsua_transport_config_default(&cfg);
		cfg.port = 5060;
		status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
		if (status != PJ_SUCCESS) {
			handleError("Error creating transport", status);
			return status;
		}
	}

	/* Initialization is done, now start pjsua */
	status = pjsua_start();

	qDebug() << "3. PJ_SUCCESS :" << PJ_SUCCESS << " status : " << status;
	if (status != PJ_SUCCESS) {
		handleError("Error starting pjsua", status);
		return status;
	}

	/* Register to SIP server by creating SIP account. */
	{
		pjsua_acc_config cfg;

		pjsua_acc_config_default(&cfg);

		std::string id(sipPrefix + sipUser + atSymbol + sipDomain);
		cfg.id = pj_str((char *) id.c_str());
		std::string uri(sipPrefix + sipDomain);
		cfg.reg_uri = pj_str((char*) uri.c_str());
		cfg.cred_count = 1;
		cfg.cred_info[0].realm = pj_str((char *) sipDomain.c_str());
		cfg.cred_info[0].scheme = pj_str((char*) digest.c_str());
		cfg.cred_info[0].username = pj_str((char*) sipUser.c_str());
		cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
		cfg.cred_info[0].data = pj_str((char *) sipPassword.c_str());
		qDebug() << "Register to SIP server by creating SIP account ";

		status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);

		qDebug() << "3. PJ_SUCCESS :" << PJ_SUCCESS << " status : " << status;

		if (status != PJ_SUCCESS) {
			handleError("Error adding account", status);
			return status;
		}

	       pj_str_t uri = pj_str("iptel.org");
	       status = pjsua_call_make_call(101, &uri, 0, NULL, NULL, NULL);
	       if (status != PJ_SUCCESS) {
	           handleError("Error making Call", status);
	       }

	}

 

Please use plain text.
Retired
gsandhu
Posts: 41
Registered: ‎07-14-2008
My Device: Not Specified

Re: make a call using pjsip

Hi,

 

In your uri you are missing the Sip Prefix: "sip:" below is a good example

 

pj_str_t uri = pj_str("sip:test@opensips.org");
status = pjsua_call_make_call(acc_id, &uri, 0, NULL, NULL, NULL);
if (status != PJ_SUCCESS){
handleError("Error making call", status);
}

 

Gurtej Sandhu

Please use plain text.
Developer
CapQNX
Posts: 112
Registered: ‎01-11-2013
My Device: BlackBerry Curve

Re: how to check username and password valid or not using pjsip

[ Edited ]

@gsandhu Thanks for your reply, it worked fine and now i am facing an new problem.

Now when i am trying to loggin using wrong username and password using pjsip it returns that i am logged in sucessfull ie. returns non-zero.

Here is my code :

	
/* set invalid username and password*/
	std::string sipDomain = "iptel.org";
	std::string sipUser = "XYZ123";
	std::string sipPassword = "XZZ123";
	std::string atSymbol = "@";
	std::string sipPrefix = "sip:";
	std::string digest = "XYZ123";

	status = pjsua_create();

	if (status != PJ_SUCCESS) {
		handleError("Error creating pjsua", status);
		return status;
	}

	{

		pjsua_config cfg;
		pjsua_logging_config log_cfg;
		pjsua_config_default(&cfg);

		// Set up the two static callbacks for session up session down
		// This is where all callbacks are initialized. See PJSIP documentation
		// session up
		cfg.cb.on_reg_started = &on_reg_started;
		// traps session down
		cfg.cb.on_transport_state = &on_tp_state_changed;
		// accept incomming call
		cfg.cb.on_incoming_call = &on_incoming_call;
		// registration state login/logout
		cfg.cb.on_reg_state = &on_reg_state;
		// Callback called by the library when call's media state has changed
		cfg.cb.on_call_media_state = &on_call_media_state;
		// Callback called by the library when call's state has changed
		cfg.cb.on_call_state = &on_call_state;
		// Callback called by nat
		cfg.cb.on_nat_detect = &on_nat_detect;


		pjsua_logging_config_default(&log_cfg);
		log_cfg.console_level = 4;

		pjsua_media_config media_cfg;

		pjsua_media_config_default(&media_cfg);

		status = pjsua_init(&cfg, &log_cfg, &media_cfg);

		if (status != PJ_SUCCESS) {
			handleError("Error initializing pjsua", status);
			return status;
		}

	}

	/* Add UDP transport. */
	{
		pjsua_transport_config cfg;

		pjsua_transport_config_default(&cfg);
		cfg.port = 5060;
		status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL);
		if (status != PJ_SUCCESS) {
			handleError("Error creating transport", status);
			return status;
		}
	}

	/* Initialization is done, now start pjsua */
	status = pjsua_start();

	qDebug() << "3. PJ_SUCCESS :" << PJ_SUCCESS << " status : " << status;
	if (status != PJ_SUCCESS) {
		handleError("Error starting pjsua", status);
		return status;
	}

	/* Register to SIP server by creating SIP account. */
	{
		pjsua_acc_config cfg;

		pjsua_acc_config_default(&cfg);

		std::string id(sipPrefix + sipUser + atSymbol + sipDomain);
		cfg.id = pj_str((char *) id.c_str());
		std::string uri(sipPrefix + sipDomain);
		cfg.reg_uri = pj_str((char*) uri.c_str());
		cfg.cred_count = 1;
		cfg.cred_info[0].realm = pj_str((char *) sipDomain.c_str());
		cfg.cred_info[0].scheme = pj_str((char*) digest.c_str());
		cfg.cred_info[0].username = pj_str((char*) sipUser.c_str());
		cfg.cred_info[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
		cfg.cred_info[0].data = pj_str((char *) sipPassword.c_str());

		status = pjsua_acc_add(&cfg, PJ_TRUE, &acc_id);
		if (status != PJ_SUCCESS) {
			handleError("Error adding account", status);
			return status;
		}

		status = pjsua_acc_is_valid(acc_id);
		if (status != PJ_SUCCESS) {
			handleError("Error invalid account id", status);
			return status;
		}


	}

	return status;

 

Please use plain text.
Retired
gsandhu
Posts: 41
Registered: ‎07-14-2008
My Device: Not Specified

Re: how to check username and password valid or not using pjsip

Hi,

 

Since this issue is isolated specifically to pjsip code and outside of core BlackBerry 10 development you will need to raise this issue to the pjsip mailing list.

 

Cheers,

 

Gurtej Sandhu

Please use plain text.
Developer
CapQNX
Posts: 112
Registered: ‎01-11-2013
My Device: BlackBerry Curve

Re: how to check username and password valid or not using pjsip

Thanks for your reply
Please use plain text.