[pjsip] Building errors under Linux (Semaphore, SRTP functions and -members)

Helmut Wolf HelmutWolf1 at gmx.de
Mon Feb 18 06:14:50 EST 2008

Hi Benny,

Thank you for fixing the bug! After SVN update I can't build pjsip project under Linux (Windows works fine):

1) Unknown type sem_t.

I have found different defines for Semaphore:

The define in /pjlib/include/pj/config.h:598 is:
  #define PJ_HAS_SEMAPHORE 1

But the usage in /pjlib/src/pj/os_core_unix.c:37 is:
#  include <semaphore.h>

In source file I have replaced PJ_HAS_SEMAPHORE_H with PJ_HAS_SEMAPHORE and it works.

2) Missing reference to some srtp functions in transport_srtp.c

I have defined PJMEDIA_HAS_SRTP to 0 in config_site. With this define I got another errors (Windows and Linux) which I have fixed
with adding

#if defined(PJMEDIA_HAS_SRTP) && (PJMEDIA_HAS_SRTP != 0)

I have added this on the following code blocks:

### pjsua_app.c ###

Line 1326:

    /* SRTP */
    if (app_config.cfg.use_srtp != PJSUA_DEFAULT_USE_SRTP) {
	pj_ansi_sprintf(line, "--use-srtp %d\n",
	pj_strcat2(&cfg, line);
    if (app_config.cfg.srtp_secure_signaling != 
	pj_ansi_sprintf(line, "--srtp-secure %d\n",
	pj_strcat2(&cfg, line);

### pcaputil.c:248 ###

    /* Create SRTP transport is needed */
    if (srtp_crypto->slen) {
	pjmedia_srtp_crypto crypto;

	pj_bzero(&crypto, sizeof(crypto));
	crypto.key = *srtp_key;
	crypto.name = *srtp_crypto;
	T( pjmedia_transport_srtp_create(app.mept, NULL, NULL, &app.srtp) );
	T( pjmedia_transport_srtp_start(app.srtp, &crypto, &crypto) );

### pcaputil.c:157 ###

	/* Decrypt SRTP */
	if (app.srtp) {
	    int len = sz;
	    status = pjmedia_transport_srtp_decrypt_pkt(app.srtp, PJ_TRUE, 
						        buf, &len);
	    if (status != PJ_SUCCESS) {
		char errmsg[PJ_ERR_MSG_SIZE];
		pj_strerror(status, errmsg, sizeof(errmsg));
		printf("SRTP packet decryption failed, skipping packet: %s\n", 
	    sz = len;

	    /* Decode RTP packet again */
	    status = pjmedia_rtp_decode_rtp(&app.rtp_sess, buf, sz, &r,
					    &p, payload_size);
	    if (status != PJ_SUCCESS) {
		char errmsg[PJ_ERR_MSG_SIZE];
		pj_strerror(status, errmsg, sizeof(errmsg));
		printf("Not RTP packet, skipping packet: %s\n", errmsg);

Now building project on Windows and Linux works fine.

Best regards,

More information about the pjsip mailing list