コード例 #1
0
ファイル: streamutil.c プロジェクト: tibastral/symphonie
/* 
 * Register all codecs. 
 */
static pj_status_t init_codecs(pjmedia_endpt *med_endpt)
{
    pj_status_t status;

    /* To suppress warning about unused var when all codecs are disabled */
    PJ_UNUSED_ARG(status);

#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0
    status = pjmedia_codec_g711_init(med_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif

#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC!=0
    status = pjmedia_codec_gsm_init(med_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif

#if defined(PJMEDIA_HAS_SPEEX_CODEC) && PJMEDIA_HAS_SPEEX_CODEC!=0
    status = pjmedia_codec_speex_init(med_endpt, 0, -1, -1);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif

#if defined(PJMEDIA_HAS_L16_CODEC) && PJMEDIA_HAS_L16_CODEC!=0
    status = pjmedia_codec_l16_init(med_endpt, 0);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);
#endif

    return PJ_SUCCESS;
}
コード例 #2
0
ファイル: encdec.c プロジェクト: deveck/Deveck.TAM
int main(int argc, char *argv[])
{
    pj_caching_pool cp;
    pj_time_val t0, t1;
    pj_status_t status;

    if (argc != 4) {
	puts(desc);
	return 1;
    }

    CHECK( pj_init() );
    
    pj_caching_pool_init(&cp, NULL, 0);

    CHECK( pjmedia_endpt_create(&cp.factory, NULL, 1, &mept) );

    /* Register all codecs */
#if PJMEDIA_HAS_G711_CODEC
    CHECK( pjmedia_codec_g711_init(mept) );
#endif
#if PJMEDIA_HAS_GSM_CODEC
    CHECK( pjmedia_codec_gsm_init(mept) );
#endif
#if PJMEDIA_HAS_ILBC_CODEC
    CHECK( pjmedia_codec_ilbc_init(mept, 30) );
#endif
#if PJMEDIA_HAS_SPEEX_CODEC
    CHECK( pjmedia_codec_speex_init(mept, 0, 5, 5) );
#endif
#if PJMEDIA_HAS_G722_CODEC
    CHECK( pjmedia_codec_g722_init(mept) );
#endif

    pj_gettimeofday(&t0);
    status = enc_dec_test(argv[1], argv[2], argv[3]);
    pj_gettimeofday(&t1);
    PJ_TIME_VAL_SUB(t1, t0);

    pjmedia_endpt_destroy(mept);
    pj_caching_pool_destroy(&cp);
    pj_shutdown();

    if (status == PJ_SUCCESS) {
	puts("");
	puts("Success");
	printf("Duration: %ds.%03d\n", file_msec_duration/1000, 
				       file_msec_duration%1000);
	printf("Time: %lds.%03ld\n", t1.sec, t1.msec);
    }

    return 0;
}
コード例 #3
0
ファイル: test-codecs.c プロジェクト: mocidis/media-endpoint
int main() {
    pj_caching_pool cp;
    pj_caching_pool_init(&cp, NULL, 4000);
    CHECK(__FILE__, pj_init());
    pjmedia_endpt *endpoint;
    pjmedia_endpt_create(&cp.factory, NULL, 1, &endpoint);
    //pjmedia_codec_register_audio_codecs(endpoint, NULL);
    pjmedia_codec_g711_init(endpoint);
    list_codecs(endpoint);
    pjmedia_codec_g711_deinit();
    list_codecs(endpoint);
    return 0;
}
コード例 #4
0
ファイル: simpleua.c プロジェクト: Archipov/android-client
/*
 * main()
 *
 * If called with argument, treat argument as SIP URL to be called.
 * Otherwise wait for incoming calls.
 */
int main(int argc, char *argv[])
{
    pj_pool_t *pool = NULL;
    pj_status_t status;
    unsigned i;

    /* Must init PJLIB first: */
    status = pj_init();
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

    pj_log_set_level(5);

    /* Then init PJLIB-UTIL: */
    status = pjlib_util_init();
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    /* Must create a pool factory before we can allocate any memory. */
    pj_caching_pool_init(&cp, &pj_pool_factory_default_policy, 0);


    /* Create global endpoint: */
    {
	const pj_str_t *hostname;
	const char *endpt_name;

	/* Endpoint MUST be assigned a globally unique name.
	 * The name will be used as the hostname in Warning header.
	 */

	/* For this implementation, we'll use hostname for simplicity */
	hostname = pj_gethostname();
	endpt_name = hostname->ptr;

	/* Create the endpoint: */

	status = pjsip_endpt_create(&cp.factory, endpt_name, 
				    &g_endpt);
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
    }


    /* 
     * Add UDP transport, with hard-coded port 
     * Alternatively, application can use pjsip_udp_transport_attach() to
     * start UDP transport, if it already has an UDP socket (e.g. after it
     * resolves the address with STUN).
     */
    {
	pj_sockaddr addr;

	pj_sockaddr_init(AF, &addr, NULL, (pj_uint16_t)SIP_PORT);
	
	if (AF == pj_AF_INET()) {
	    status = pjsip_udp_transport_start( g_endpt, &addr.ipv4, NULL, 
						1, NULL);
	} else if (AF == pj_AF_INET6()) {
	    status = pjsip_udp_transport_start6(g_endpt, &addr.ipv6, NULL,
						1, NULL);
	} else {
	    status = PJ_EAFNOTSUP;
	}

	if (status != PJ_SUCCESS) {
	    app_perror(THIS_FILE, "Unable to start UDP transport", status);
	    return 1;
	}
    }


    /* 
     * Init transaction layer.
     * This will create/initialize transaction hash tables etc.
     */
    status = pjsip_tsx_layer_init_module(g_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    /* 
     * Initialize UA layer module.
     * This will create/initialize dialog hash tables etc.
     */
    status = pjsip_ua_init_module( g_endpt, NULL );
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    /* 
     * Init invite session module.
     * The invite session module initialization takes additional argument,
     * i.e. a structure containing callbacks to be called on specific
     * occurence of events.
     *
     * The on_state_changed and on_new_session callbacks are mandatory.
     * Application must supply the callback function.
     *
     * We use on_media_update() callback in this application to start
     * media transmission.
     */
    {
	pjsip_inv_callback inv_cb;

	/* Init the callback for INVITE session: */
	pj_bzero(&inv_cb, sizeof(inv_cb));
	inv_cb.on_state_changed = &call_on_state_changed;
	inv_cb.on_new_session = &call_on_forked;
	inv_cb.on_media_update = &call_on_media_update;

	/* Initialize invite session module:  */
	status = pjsip_inv_usage_init(g_endpt, &inv_cb);
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
    }

    /* Initialize 100rel support */
    status = pjsip_100rel_init_module(g_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);

    /*
     * Register our module to receive incoming requests.
     */
    status = pjsip_endpt_register_module( g_endpt, &mod_simpleua);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

    /*
     * Register message logger module.
     */
    status = pjsip_endpt_register_module( g_endpt, &msg_logger);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    /* 
     * Initialize media endpoint.
     * This will implicitly initialize PJMEDIA too.
     */
#if PJ_HAS_THREADS
    status = pjmedia_endpt_create(&cp.factory, NULL, 1, &g_med_endpt);
#else
    status = pjmedia_endpt_create(&cp.factory, 
				  pjsip_endpt_get_ioqueue(g_endpt), 
				  0, &g_med_endpt);
#endif
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

    /* 
     * Add PCMA/PCMU codec to the media endpoint. 
     */
#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0
    status = pjmedia_codec_g711_init(g_med_endpt);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
#endif


#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
    /* Init video subsystem */
    pool = pjmedia_endpt_create_pool(g_med_endpt, "Video subsystem", 512, 512);
    status = pjmedia_video_format_mgr_create(pool, 64, 0, NULL);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
    status = pjmedia_converter_mgr_create(pool, NULL);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
    status = pjmedia_vid_codec_mgr_create(pool, NULL);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
    status = pjmedia_vid_dev_subsys_init(&cp.factory);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

#  if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
    /* Init ffmpeg video codecs */
    status = pjmedia_codec_ffmpeg_vid_init(NULL, &cp.factory);
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
#  endif  /* PJMEDIA_HAS_FFMPEG_VID_CODEC */

#endif	/* PJMEDIA_HAS_VIDEO */
    
    /* 
     * Create media transport used to send/receive RTP/RTCP socket.
     * One media transport is needed for each call. Application may
     * opt to re-use the same media transport for subsequent calls.
     */
    for (i = 0; i < PJ_ARRAY_SIZE(g_med_transport); ++i) {
	status = pjmedia_transport_udp_create3(g_med_endpt, AF, NULL, NULL, 
					       RTP_PORT + i*2, 0, 
					       &g_med_transport[i]);
	if (status != PJ_SUCCESS) {
	    app_perror(THIS_FILE, "Unable to create media transport", status);
	    return 1;
	}

	/* 
	 * Get socket info (address, port) of the media transport. We will
	 * need this info to create SDP (i.e. the address and port info in
	 * the SDP).
	 */
	pjmedia_transport_info_init(&g_med_tpinfo[i]);
	pjmedia_transport_get_info(g_med_transport[i], &g_med_tpinfo[i]);

	pj_memcpy(&g_sock_info[i], &g_med_tpinfo[i].sock_info,
		  sizeof(pjmedia_sock_info));
    }

    /*
     * If URL is specified, then make call immediately.
     */
    if (argc > 1) {
	pj_sockaddr hostaddr;
	char hostip[PJ_INET6_ADDRSTRLEN+2];
	char temp[80];
	pj_str_t dst_uri = pj_str(argv[1]);
	pj_str_t local_uri;
	pjsip_dialog *dlg;
	pjmedia_sdp_session *local_sdp;
	pjsip_tx_data *tdata;

	if (pj_gethostip(AF, &hostaddr) != PJ_SUCCESS) {
	    app_perror(THIS_FILE, "Unable to retrieve local host IP", status);
	    return 1;
	}
	pj_sockaddr_print(&hostaddr, hostip, sizeof(hostip), 2);

	pj_ansi_sprintf(temp, "<sip:simpleuac@%s:%d>", 
			hostip, SIP_PORT);
	local_uri = pj_str(temp);

	/* Create UAC dialog */
	status = pjsip_dlg_create_uac( pjsip_ua_instance(), 
				       &local_uri,  /* local URI */
				       &local_uri,  /* local Contact */
				       &dst_uri,    /* remote URI */
				       &dst_uri,    /* remote target */
				       &dlg);	    /* dialog */
	if (status != PJ_SUCCESS) {
	    app_perror(THIS_FILE, "Unable to create UAC dialog", status);
	    return 1;
	}

	/* If we expect the outgoing INVITE to be challenged, then we should
	 * put the credentials in the dialog here, with something like this:
	 *
	    {
		pjsip_cred_info	cred[1];

		cred[0].realm	  = pj_str("sip.server.realm");
		cred[0].scheme    = pj_str("digest");
		cred[0].username  = pj_str("theuser");
		cred[0].data_type = PJSIP_CRED_DATA_PLAIN_PASSWD;
		cred[0].data      = pj_str("thepassword");

		pjsip_auth_clt_set_credentials( &dlg->auth_sess, 1, cred);
	    }
	 *
	 */


	/* Get the SDP body to be put in the outgoing INVITE, by asking
	 * media endpoint to create one for us.
	 */
	status = pjmedia_endpt_create_sdp( g_med_endpt,	    /* the media endpt	*/
					   dlg->pool,	    /* pool.		*/
					   MAX_MEDIA_CNT,   /* # of streams	*/
					   g_sock_info,     /* RTP sock info	*/
					   &local_sdp);	    /* the SDP result	*/
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);



	/* Create the INVITE session, and pass the SDP returned earlier
	 * as the session's initial capability.
	 */
	status = pjsip_inv_create_uac( dlg, local_sdp, 0, &g_inv);
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);

	/* If we want the initial INVITE to travel to specific SIP proxies,
	 * then we should put the initial dialog's route set here. The final
	 * route set will be updated once a dialog has been established.
	 * To set the dialog's initial route set, we do it with something
	 * like this:
	 *
	    {
		pjsip_route_hdr route_set;
		pjsip_route_hdr *route;
		const pj_str_t hname = { "Route", 5 };
		char *uri = "sip:proxy.server;lr";

		pj_list_init(&route_set);

		route = pjsip_parse_hdr( dlg->pool, &hname, 
					 uri, strlen(uri),
					 NULL);
		PJ_ASSERT_RETURN(route != NULL, 1);
		pj_list_push_back(&route_set, route);

		pjsip_dlg_set_route_set(dlg, &route_set);
	    }
	 *
	 * Note that Route URI SHOULD have an ";lr" parameter!
	 */

	/* Create initial INVITE request.
	 * This INVITE request will contain a perfectly good request and 
	 * an SDP body as well.
	 */
	status = pjsip_inv_invite(g_inv, &tdata);
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);



	/* Send initial INVITE request. 
	 * From now on, the invite session's state will be reported to us
	 * via the invite session callbacks.
	 */
	status = pjsip_inv_send_msg(g_inv, tdata);
	PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);


    } else {

	/* No URL to make call to */

	PJ_LOG(3,(THIS_FILE, "Ready to accept incoming calls..."));
    }


    /* Loop until one call is completed */
    for (;!g_complete;) {
	pj_time_val timeout = {0, 10};
	pjsip_endpt_handle_events(g_endpt, &timeout);
    }

    /* On exit, dump current memory usage: */
    dump_pool_usage(THIS_FILE, &cp);

    /* Destroy audio ports. Destroy the audio port first
     * before the stream since the audio port has threads
     * that get/put frames to the stream.
     */
    if (g_snd_port)
	pjmedia_snd_port_destroy(g_snd_port);

#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
    /* Destroy video ports */
    if (g_vid_capturer)
	pjmedia_vid_port_destroy(g_vid_capturer);
    if (g_vid_renderer)
	pjmedia_vid_port_destroy(g_vid_renderer);
#endif

    /* Destroy streams */
    if (g_med_stream)
	pjmedia_stream_destroy(g_med_stream);
#if defined(PJMEDIA_HAS_VIDEO) && (PJMEDIA_HAS_VIDEO != 0)
    if (g_med_vstream)
	pjmedia_vid_stream_destroy(g_med_vstream);

    /* Deinit ffmpeg codec */
#   if defined(PJMEDIA_HAS_FFMPEG_VID_CODEC) && PJMEDIA_HAS_FFMPEG_VID_CODEC!=0
    pjmedia_codec_ffmpeg_vid_deinit();
#   endif

#endif

    /* Destroy media transports */
    for (i = 0; i < MAX_MEDIA_CNT; ++i) {
	if (g_med_transport[i])
	    pjmedia_transport_close(g_med_transport[i]);
    }

    /* Deinit pjmedia endpoint */
    if (g_med_endpt)
	pjmedia_endpt_destroy(g_med_endpt);

    /* Deinit pjsip endpoint */
    if (g_endpt)
	pjsip_endpt_destroy(g_endpt);

    /* Release pool */
    if (pool)
	pj_pool_release(pool);

    return 0;
}
コード例 #5
0
ファイル: audio_codecs.c プロジェクト: chriszeng87/pjproject
pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt,
                                    const pjmedia_audio_codec_config *c)
{
    pjmedia_audio_codec_config default_cfg;
    pj_status_t status;

    PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
    if (!c) {
	pjmedia_audio_codec_config_default(&default_cfg);
	c = &default_cfg;
    }

    PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL);

#if PJMEDIA_HAS_PASSTHROUGH_CODECS
    status = pjmedia_codec_passthrough_init2(endpt, &c->passthrough.setting);
    if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_SPEEX_CODEC
    /* Register speex. */
    status = pjmedia_codec_speex_init(endpt, c->speex.option,
				      c->speex.quality,
				      c->speex.complexity);
    if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_ILBC_CODEC
    /* Register iLBC. */
    status = pjmedia_codec_ilbc_init( endpt, c->ilbc.mode);
    if (status != PJ_SUCCESS)
	return status;
#endif /* PJMEDIA_HAS_ILBC_CODEC */

#if PJMEDIA_HAS_GSM_CODEC
    /* Register GSM */
    status = pjmedia_codec_gsm_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif /* PJMEDIA_HAS_GSM_CODEC */

#if PJMEDIA_HAS_G711_CODEC
    /* Register PCMA and PCMU */
    status = pjmedia_codec_g711_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif	/* PJMEDIA_HAS_G711_CODEC */

#if PJMEDIA_HAS_G722_CODEC
    status = pjmedia_codec_g722_init(endpt );
    if (status != PJ_SUCCESS)
	return status;
#endif  /* PJMEDIA_HAS_G722_CODEC */

#if PJMEDIA_HAS_INTEL_IPP
    /* Register IPP codecs */
    status = pjmedia_codec_ipp_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif /* PJMEDIA_HAS_INTEL_IPP */

#if PJMEDIA_HAS_G7221_CODEC
    /* Register G722.1 codecs */
    status = pjmedia_codec_g7221_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif /* PJMEDIA_HAS_G7221_CODEC */

#if PJMEDIA_HAS_L16_CODEC
    /* Register L16 family codecs */
    status = pjmedia_codec_l16_init(endpt, 0);
    if (status != PJ_SUCCESS)
	return status;
#endif	/* PJMEDIA_HAS_L16_CODEC */

#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
    /* Register OpenCORE AMR */
    status = pjmedia_codec_opencore_amr_init(endpt, 0);
    if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_SILK_CODEC
    /* Register SILK */
    status = pjmedia_codec_silk_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_OPUS_CODEC
    /* Register OPUS */
    status = pjmedia_codec_opus_init(endpt);
    if (status != PJ_SUCCESS)
	return status;
#endif

    return PJ_SUCCESS;
}
コード例 #6
0
ファイル: OIUC.cpp プロジェクト: mocidis/oiuc-v1
void OIUC::prepare() {

    /*---------------- ICS  -----------------*/
    ics_pool_init(&app_data.ics);
    ics_pjsua_init(&app_data.ics);
    ics_init(&app_data.ics);

    //qDebug() << "INIT DONE";
#if 1
    SET_LOG_LEVEL(4);
    pj_log_set_level(3);

    ics_set_default_callback(&on_reg_start_default);
    ics_set_reg_start_callback(&on_reg_start_impl);
    ics_set_reg_state_callback(&on_reg_state_impl);
    ics_set_incoming_call_callback(&on_incoming_call_impl);
    ics_set_call_state_callback(&on_call_state_impl);
    ics_set_call_transfer_callback(&on_call_transfer_impl);
    ics_set_call_media_state_callback(&on_call_media_state_impl);

    ics_start(&app_data.ics);
    config->getPortAsterisk(); // Don't need anymore, now set default bind to any port
    ics_connect(&app_data.ics, config->getPortAsterisk());

    qDebug() << "ICS STARTED";
#endif
    /*---------------- PTTC  -----------------*/
#if 0
    pttc_init(&app_data.serial, &app_data.pttc, on_pttc_ptt, app_data.ics.pool);
    pttc_start(&app_data.serial, config->getSerialFile().toLocal8Bit().data());
#endif
    /*---------------- NODE  -----------------*/
#if 1
    memset(&app_data.node, 0, sizeof(app_data.node));

    gm_cs = "udp:" + config->getArbiterIP() + ":" + QString::number(config->getPortSendToArbiter());
    gmc_cs = "udp:" + config->getOIUCIP() + ":" + QString::number(config->getPortOIUCListen());
    adv_cs = "udp:0.0.0.0:2015";

    init_adv_server(&app_data, adv_cs.toLocal8Bit().data(), &app_data.node, app_data.ics.pool);
    app_data.node.on_leaving_server_f = &on_leaving_server;
    node_init(&app_data.node,
              config->getOIUCName().toLocal8Bit().data(),
              config->getLocation().toLocal8Bit().data(),
              config->getOIUCDescription().toLocal8Bit().data(),
              -1,
              gm_cs.toLocal8Bit().data(),
              gmc_cs.toLocal8Bit().data(),
              app_data.ics.pool);
    node_add_adv_server(&app_data.node, &app_data.adv_server);

    qDebug() << "NODE INIT DONE";
#endif
    /*---------------- GB  -----------------*/
#if 1
    memset(&app_data.gr, 0, sizeof(app_data.gr));
    app_data.gr.on_online_report_f = &on_online_report;
    app_data.gr.on_tx_report_f = &on_tx_report;
    app_data.gr.on_rx_report_f = &on_rx_report;
    app_data.gr.on_sq_report_f = &on_sq_report;
    gb_receiver_init(&app_data.gr, (char *)GB_CS, app_data.ics.pool);

    qDebug() << "GB DONE";
#endif
    /*---------------- STREAM  -----------------*/
#if 1
    node_media_config(&app_data.node, &app_data.streamer, &app_data.receiver);
    app_data.node.streamer->pool = app_data.node.receiver->pool = app_data.ics.pool;
    app_data.node.streamer->ep = app_data.node.receiver->ep = pjsua_get_pjmedia_endpt();
    pjmedia_codec_g711_init(app_data.node.streamer->ep);
    pjmedia_codec_g711_init(app_data.node.receiver->ep);

    streamer_init(app_data.node.streamer, app_data.node.streamer->ep, app_data.node.streamer->pool);
    receiver_init(app_data.node.receiver, app_data.node.receiver->ep, app_data.node.receiver->pool, config->getNumberChannels());

    streamer_config_dev_source(app_data.node.streamer, config->getSoundStreamerIdx());
    receiver_config_dev_sink(app_data.node.receiver, config->getSoundReceiverIdx());
    //streamer_config_dev_source(app_data.node.streamer, 2);
    //receiver_config_dev_sink(app_data.node.receiver, 2);
    //qDebug() << "STREAM INIT...DONE\n";
#endif
}
コード例 #7
0
ファイル: audio_codecs.c プロジェクト: imace/mbgapp
PJ_DEF(pj_status_t) pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt,
		const pjmedia_audio_codec_config *c) {
	pjmedia_audio_codec_config default_cfg;
	pj_status_t status;

	PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
	if (!c) {
		pjmedia_audio_codec_config_default(&default_cfg);
		c = &default_cfg;
	}

	PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL);

#if PJMEDIA_HAS_PASSTHROUGH_CODECS
	status = pjmedia_codec_passthrough_init2(endpt, &c->passthough.ilbc);
	if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_SPEEX_CODEC
	/* Register speex. */
	status = pjmedia_codec_speex_init(endpt, c->speex.option, c->speex.quality,
			c->speex.complexity);
	if (status != PJ_SUCCESS)
		return status;
#endif

#if PJMEDIA_HAS_ILBC_CODEC
	/* Register iLBC. */
	status = pjmedia_codec_ilbc_init(endpt, c->ilbc.mode);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_ILBC_CODEC */

#if PJMEDIA_HAS_GSM_CODEC
	/* Register GSM */
	status = pjmedia_codec_gsm_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_GSM_CODEC */

#if PJMEDIA_HAS_G711_CODEC
	/* Register PCMA and PCMU */
	status = pjmedia_codec_g711_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif	/* PJMEDIA_HAS_G711_CODEC */

#if PJMEDIA_HAS_G722_CODEC
	status = pjmedia_codec_g722_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif  /* PJMEDIA_HAS_G722_CODEC */

#if PJMEDIA_HAS_L16_CODEC
	/* Register L16 family codecs */
	status = pjmedia_codec_l16_init(endpt, 0);
	if (status != PJ_SUCCESS)
	return status;
#endif	/* PJMEDIA_HAS_L16_CODEC */

#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_OPENCORE_AMRWB_CODEC
	/* Register OpenCORE AMR */
    status = pjmedia_codec_opencore_stagefright_init(endpt);
    if (status != PJ_SUCCESS)
        return status;
#endif

#if PJMEDIA_HAS_WEBRTC_CODEC
	/* Register WEBRTC */
	status = pjmedia_codec_webrtc_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_WEBRTC_CODEC */

#if PJMEDIA_HAS_SILK_CODEC
	status = pjmedia_codec_silk_init(endpt);
	if (status != PJ_SUCCESS)
		return status;

	// Our default config
	pjmedia_codec_silk_setting silk_settings;
	silk_settings.complexity = -1;
	silk_settings.enabled = PJ_TRUE;
	silk_settings.quality = 3;
	pjmedia_codec_silk_set_config(8000, &silk_settings);
	pjmedia_codec_silk_set_config(12000, &silk_settings);
	pjmedia_codec_silk_set_config(16000, &silk_settings);
	pjmedia_codec_silk_set_config(24000, &silk_settings);

#endif /* PJMEDIA_HAS_SILK_CODEC */

	// Dynamic loading of plugins codecs
	unsigned i;

	for (i = 0; i < css_var.extra_aud_codecs_cnt; i++) {
		dynamic_factory *codec = &css_var.extra_aud_codecs[i];
		pj_status_t (*init_factory)(
							pjmedia_endpt *endpt) = get_library_factory(codec);
		if(init_factory != NULL){
			status = init_factory(endpt);
			if(status != PJ_SUCCESS) {
				PJ_LOG(2, (THIS_FILE,"Error loading dynamic codec plugin"));
			}
    	}
	}

	// Register opus sdp rewriter
	// TODO -- get info from registrations made previously + only when opus detected
	pjsip_opus_sdp_rewriter_init(16000);

	return PJ_SUCCESS;
}
コード例 #8
0
ファイル: pjsua_jni_addons.c プロジェクト: mmajid/abc-voip
PJ_DEF(pj_status_t) pjmedia_codec_register_audio_codecs(pjmedia_endpt *endpt,
		const pjmedia_audio_codec_config *c) {
	pjmedia_audio_codec_config default_cfg;
	pj_status_t status;

	PJ_ASSERT_RETURN(endpt, PJ_EINVAL);
	if (!c) {
		pjmedia_audio_codec_config_default(&default_cfg);
		c = &default_cfg;
	}

	PJ_ASSERT_RETURN(c->ilbc.mode==20 || c->ilbc.mode==30, PJ_EINVAL);

#if PJMEDIA_HAS_PASSTHROUGH_CODECS
	status = pjmedia_codec_passthrough_init2(endpt, &c->passthough.ilbc);
	if (status != PJ_SUCCESS)
	return status;
#endif

#if PJMEDIA_HAS_SPEEX_CODEC
	/* Register speex. */
	status = pjmedia_codec_speex_init(endpt, c->speex.option, c->speex.quality,
			c->speex.complexity);
	if (status != PJ_SUCCESS)
		return status;
#endif

#if PJMEDIA_HAS_ILBC_CODEC
	/* Register iLBC. */
	status = pjmedia_codec_ilbc_init(endpt, c->ilbc.mode);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_ILBC_CODEC */

#if PJMEDIA_HAS_GSM_CODEC
	/* Register GSM */
	status = pjmedia_codec_gsm_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_GSM_CODEC */

#if PJMEDIA_HAS_G711_CODEC
	/* Register PCMA and PCMU */
	status = pjmedia_codec_g711_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif	/* PJMEDIA_HAS_G711_CODEC */

#if PJMEDIA_HAS_G722_CODEC
	status = pjmedia_codec_g722_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif  /* PJMEDIA_HAS_G722_CODEC */

#if PJMEDIA_HAS_L16_CODEC
	/* Register L16 family codecs */
	status = pjmedia_codec_l16_init(endpt, 0);
	if (status != PJ_SUCCESS)
	return status;
#endif	/* PJMEDIA_HAS_L16_CODEC */

#if PJMEDIA_HAS_OPENCORE_AMRNB_CODEC || PJMEDIA_HAS_AMR_STAGEFRIGHT_CODEC
	/* Register OpenCORE AMR-NB */
	status = pjmedia_codec_opencore_amrnb_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif

#if PJMEDIA_HAS_WEBRTC_CODEC
	/* Register WEBRTC */
	status = pjmedia_codec_webrtc_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_WEBRTC_CODEC */

#if PJMEDIA_HAS_G729_CODEC
	/* Register WEBRTC */
	status = pjmedia_codec_g729_init(endpt);
	if (status != PJ_SUCCESS)
		return status;
#endif /* PJMEDIA_HAS_G729_CODEC */

	// Dynamic loading of plugins codecs
	unsigned i;

	for (i = 0; i < css_var.extra_aud_codecs_cnt; i++) {
		dynamic_factory *codec = &css_var.extra_aud_codecs[i];
		pj_status_t (*init_factory)(
							pjmedia_endpt *endpt) = get_library_factory(codec);
		if(init_factory != NULL){
			status = init_factory(endpt);
			if(status != PJ_SUCCESS) {
				PJ_LOG(2, (THIS_FILE,"Error loading dynamic codec plugin"));
			}
    	}
	}

	return PJ_SUCCESS;
}
コード例 #9
0
int main(int argc, char *argv[]) {
    char temp[10];
    pj_caching_pool cp;
    pj_pool_t *pool;
    pjmedia_endpt *ep;
    pjmedia_stream *stream;
    pjmedia_codec_info *ci;

    int rport = 5321;
    char *rhost = "239.1.0.2";
    //char *rhost = "192.168.2.50";

    if (argc < 3) {
        usage(argv[0]);
    }

#if 1
    int lport;

    lport = atoi(argv[1]);
    char *file = argv[2];
#endif

#if 0
    int lport = 2345;
#endif
  
    pj_init();

    pj_log_set_level(5);
    pj_caching_pool_init(&cp, NULL, 1024);
    streamer.pool = pj_pool_create(&cp.factory, "pool1", 1024, 1024, NULL);
    pjmedia_endpt_create(&cp.factory, NULL, 1, &streamer.ep);
    pjmedia_codec_g711_init(streamer.ep);

    streamer_init(&streamer, streamer.ep, streamer.pool);
    streamer_config_stream(&streamer, lport, rhost, rport);
    streamer_config_file_source(&streamer, file);
    //streamer_config_dev_source(&streamer, 2);
    streamer_start(&streamer);
    fprintf(stdout, "Local port: %d, File: %s\n", lport, file);
    
   
    while(1) {
        fprintf(stdout, "s=Stop - r=Resume: ");
        fflush(stdout);
        if (fgets(temp, sizeof(temp), stdin) == NULL)
            exit(-1);
        fprintf(stdout, "%s\n",temp);
        switch(temp[0]) {
        case 's':
        case 'S':
            streamer_stop(&streamer);
            break;
        case 'r':
        case 'R':
            streamer_start(&streamer);
            break;
        case '+':
            rport++;
            streamer_stop(&streamer);
            streamer_config_stream(&streamer, lport, rhost, rport);
            streamer_start(&streamer);
            break;
        case '-':
            rport--;
            streamer_stop(&streamer);
            streamer_config_stream(&streamer, lport, rhost, rport);
            streamer_start(&streamer);
            break;
        case 'v':
            streamer_update_stats(&streamer);
            fprintf(stdout, "rtt:%d - delay:%d - pkt:%d - lost: %d - discard:%d\n",
                            streamer.streams[0].delay.mean_rtt_us, streamer.streams[0].delay.mean_delay_ms,
                            streamer.streams[0].drop.pkt, streamer.streams[0].drop.lost, streamer.streams[0].drop.discard);
            break;
        }
        pj_thread_sleep(5*100);
    }

    return 0;
}
コード例 #10
0
JNIEXPORT jint JNICALL Java_org_sipdroid_pjlib_codec_open
  (JNIEnv *env, jclass cls, jstring codec_id) {
    int rc = 0;
    unsigned count = 1;

    LOGE("Intializing PJLIB...");
    pj_init();
    pj_caching_pool_init(&caching_pool, &pj_pool_factory_default_policy, 0);

    pj_log_set_decor(PJ_LOG_HAS_NEWLINE);
    pj_log_set_level(3);

    mem = &caching_pool.factory;

    char* ctmp;
    jboolean iscopy;
    const char *codec_str = env->GetStringUTFChars(codec_id, &iscopy);
    ctmp = const_cast<char*>(codec_str);
    const pj_str_t pj_codec_str = pj_str(ctmp);

    unsigned clock_rate = 8000;

    LOGE("pj_pool_create");

    pool = pj_pool_create(mem, "pool", 1024, 1024, NULL);

    LOGE("PJ_POOL_ZALLOC_T");
    cp = PJ_POOL_ZALLOC_T(pool, struct codec_port);

    LOGE("pjmedia_endpt_create");
    status = pjmedia_endpt_create(mem, NULL, 0, &cp->endpt);
    if (status != PJ_SUCCESS)
	return NULL;

    cm = pjmedia_endpt_get_codec_mgr(cp->endpt);
#if PJMEDIA_HAS_G711_CODEC
    CHECK( pjmedia_codec_g711_init(cp->endpt) );
#endif
#if PJMEDIA_HAS_GSM_CODEC
    CHECK( pjmedia_codec_gsm_init(cp->endpt) );
#endif
#if PJMEDIA_HAS_ILBC_CODEC
    CHECK( pjmedia_codec_ilbc_init(cp->endpt, 30) );
#endif
#if PJMEDIA_HAS_SPEEX_CODEC
    CHECK( pjmedia_codec_speex_init(cp->endpt, 0, 5, 5) );
#endif
#if PJMEDIA_HAS_G722_CODEC
    CHECK( pjmedia_codec_g722_init(cp->endpt) );
#endif

     LOGE("pjmedia_codec_mgr_find_codecs_by_id: %s", codec_str);
     CHECK( status = pjmedia_codec_mgr_find_codecs_by_id(cm,
						 &pj_codec_str, &count, &ci, NULL) );
    if (status != PJ_SUCCESS) {
        LOGE("Cannot find codec");
	return NULL;
    }


    LOGE("pjmedia_codec_mgr_get_default_param");
    CHECK( status = pjmedia_codec_mgr_get_default_param(cm, ci, &param) );

    if (status != PJ_SUCCESS) {
        LOGE("pjmedia_codec_mgr_get_default_param failed");
	return NULL;
    }
    
    //param.setting.vad = 1;

    LOGE("pjmedia_codec_mgr_alloc_codec");
    CHECK( status = pjmedia_codec_mgr_alloc_codec(cm, ci, &cp->codec) );
    if (status != PJ_SUCCESS) {
        LOGE("Cannot allocate codec");
	return NULL;
    }


    LOGE("codec->op->init"); // channels=%d frm_ptime=%s", ci->channel_cnt, param.info.frm_ptime);
    status = (*cp->codec->op->init)(cp->codec, pool);
    if (status != PJ_SUCCESS)
	return NULL;

     LOGE("codec->op->open");
    status = cp->codec->op->open(cp->codec, &param);
    if (status != PJ_SUCCESS)
	return NULL;

    samples_per_frame = param.info.clock_rate * param.info.frm_ptime / 1000;

    LOGE("Finished initializing codec...");
    LOGE(" -> clock_rate=%d channel_count=%d samples_per_frame=%d pcm_bits_per_sample=%d", param.info.clock_rate, param.info.channel_cnt, \
									samples_per_frame, param.info.pcm_bits_per_sample);
    return (jint)PJ_SUCCESS;
}
コード例 #11
0
ファイル: riuc4.c プロジェクト: mocidis/riuc-v1
int main(int argc, char *argv[]) {
    if (argc < 3) {
        usage(argv[0]);
    }

    /*------------ CONFIG VARIABLES ------------*/
    sqlite3 *db;
    char *sql, sql_cmd[100];
    sqlite3_stmt *stmt;

    char id[10], location[30], desc[50];
    char gm_cs[50], gmc_cs[50], adv_cs[50], gb_cs[50];
    char gm_cs_tmp[50], gmc_cs_tmp[50], adv_cs_tmp[50];

    int snd_dev_r0, snd_dev_r1, snd_dev_r2, snd_dev_r3;

    int adv_port = ADV_PORT;
    int gb_port = GB_PORT; 

    /*------------ INIT & STREAM VARIABLES ------------*/
    pj_caching_pool cp;
    pj_pool_t *pool;
    pjmedia_endpt *ep;

    endpoint_t streamers[MAX_NODE];
    endpoint_t receivers[MAX_NODE];
    adv_server_t adv_server;
    
    /*------------ OTHER VARIABLES ------------*/
    pthread_t thread;
    char *dummy, option[10];
    int i, n, input, f_quit = 0;
    int snd_dev[4];

    /*-----------------------------------------*/

    SET_LOG_LEVEL(4);

    /*------------ START ------------*/
#if 1
    SHOW_LOG(3, "Press '1': Set sound devices configure\nPress 's': Show databases\nPress 'Space': Load databases\nPress 'q': Quit\n");

    CALL_SQLITE (open (argv[2], &db));
    while(!f_quit) {
        dummy = fgets(option, sizeof(option), stdin);
        switch(option[0]) {
            case '1':
                SHOW_LOG(3, "Set device index for each radio...\n");
                for (i = 0; i < MAX_NODE; i++){
                    SHOW_LOG(3, "Radio %d: ", i);
                    dummy = fgets(option, sizeof(option), stdin);           
                    input = atoi(&option[0]);
                    n = sprintf(sql_cmd, "UPDATE riuc_config SET snd_dev_r%d =(?)", i);
                    sql_cmd[n] = '\0';
                    CALL_SQLITE (prepare_v2 (db, sql_cmd, strlen (sql_cmd) + 1, & stmt, NULL));
                    CALL_SQLITE (bind_int (stmt, 1, input));
                    CALL_SQLITE_EXPECT (step (stmt), DONE);
                }
                SHOW_LOG(3, "Config completed\n");               
                f_quit = 1;
                break;
            case 's':
                sql = "SELECT *FROM riuc_config";
                CALL_SQLITE (prepare_v2 (db, sql, strlen (sql) + 1, &stmt, NULL));

                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    printf("ID: %s\n", sqlite3_column_text(stmt, 0));
                    printf("Location: %s\n", sqlite3_column_text(stmt, 1));
                    printf("Desc: %s\n", sqlite3_column_text(stmt, 2));
                    printf("GM_CS: %s\n", sqlite3_column_text(stmt, 3));
                    printf("GMC_CS: %s\n", sqlite3_column_text(stmt, 4));
                    printf("snd_dev_r0: %u\n", sqlite3_column_int(stmt, 5));
                    printf("snd_dev_r1: %u\n", sqlite3_column_int(stmt, 6));
                    printf("snd_dev_r2: %u\n", sqlite3_column_int(stmt, 7));
                    printf("snd_dev_r3: %u\n", sqlite3_column_int(stmt, 8));
                }
                break;
            case ' ':
                f_quit = 1;
                break;
            case 'q':
                return 0;
            default:
                SHOW_LOG(3, "Unknown option\n");
        }
    }
    f_quit = 0;
#endif
    /*------------ LOAD CONFIG ------------*/
    //CALL_SQLITE (open ("databases/riuc.db", &db));
    sql = "SELECT * FROM riuc_config";
    CALL_SQLITE (prepare_v2 (db, sql, strlen (sql) + 1, &stmt, NULL));

    //WARNING: MAX NUMBER OF SOUND DEV = 4
    while (sqlite3_step(stmt) == SQLITE_ROW) {
        strcpy(id, sqlite3_column_text(stmt, 0));
        strcpy(location, sqlite3_column_text(stmt, 1));
        strcpy(desc, sqlite3_column_text(stmt, 2));
        strcpy(gm_cs, sqlite3_column_text(stmt, 3));
        strcpy(gmc_cs, sqlite3_column_text(stmt, 4));
        snd_dev_r0 = sqlite3_column_int(stmt, 5);
        snd_dev_r1 = sqlite3_column_int(stmt, 6);
        snd_dev_r2 = sqlite3_column_int(stmt, 7);
        snd_dev_r3 = sqlite3_column_int(stmt, 8);
        auto_invite = sqlite3_column_int(stmt, 9);
    }

    snd_dev[0] = snd_dev_r0;
    snd_dev[1] = snd_dev_r1;
    snd_dev[2] = snd_dev_r2;
    snd_dev[3] = snd_dev_r3;

    n = sprintf(adv_cs, "udp:0.0.0.0:%d", adv_port);
    adv_cs[n] = '\0';
    n = sprintf(gb_cs, "udp:%s:%d",GB_MIP, gb_port);
    gb_cs[n] = '\0';
    
    SHOW_LOG(3, "========= LOADED CONFIG ========\n");
    SHOW_LOG(3, "ID: %s\nDesc: %s\nGM_CS: %s\nGMC_CS: %s\nADV_CS: %s\nGB_CS: %s\nsnd_r0: %d\nsnd_r1: %d\nsnd_r2: %d\nsnd_r3: %dAuto invite: %d\n", id, desc, gm_cs, gmc_cs, adv_cs, gm_cs, snd_dev_r0, snd_dev_r1, snd_dev_r2, snd_dev_r3, auto_invite);
    SHOW_LOG(3, "================================\n");

    /*------------ INIT ------------*/
    pj_init();
    pj_caching_pool_init(&cp, NULL, 10000);
    pool = pj_pool_create(&cp.factory, "pool1", 1024, 1024, NULL);

    SHOW_LOG(2, "INIT CP AND POOL...DONE\n");

    /*------------ NODE ------------*/
#if 1

    init_adv_server(&adv_server, adv_cs, pool);

    for (i = 0;i < MAX_NODE; i++) {
        memset(gm_cs_tmp, 0, sizeof(gm_cs_tmp));
        memset(gmc_cs_tmp, 0, sizeof(gmc_cs_tmp));
        memset(adv_cs_tmp, 0, sizeof(adv_cs_tmp));

        ansi_copy_str(gm_cs_tmp, gm_cs);
        ansi_copy_str(adv_cs_tmp, adv_cs);
        ansi_copy_str(gmc_cs_tmp, gmc_cs);

        n = strlen(gmc_cs);

        gmc_cs_tmp[n-1] = i + 1+ '0';

        memset(&riuc_data.node[i], 0, sizeof(riuc_data.node[i]));
        riuc_data.node[i].on_leaving_server_f = &on_leaving_server;
        node_init(&riuc_data.node[i], id, location, desc, i, gm_cs_tmp, gmc_cs_tmp, pool);
        node_add_adv_server(&riuc_data.node[i], &adv_server);
    }

    SHOW_LOG(2, "INIT NODE...DONE\n");
#endif
    /*----------- GB --------------*/
#if 1
    memset(&riuc_data.gb_sender, 0, sizeof(riuc_data.gb_sender));
    n = sprintf(gb_cs, "udp:%s:%d", GB_MIP, GB_PORT);
    gb_cs[n] = '\0';
    gb_sender_create(&riuc_data.gb_sender, gb_cs);

    SHOW_LOG(2, "INIT GB SENDER...DONE\n");
#endif
    /*----------- RIUC4 --------------*/
#if 1
    memset(riuc_data.serial_file, 0, sizeof(riuc_data.serial_file));
    strncpy(riuc_data.serial_file, argv[1], strlen(argv[1]));
    riuc4_init(&riuc_data.serial, &riuc_data.riuc4, &on_riuc4_status, pool);
    riuc4_start(&riuc_data.serial, riuc_data.serial_file);

    SHOW_LOG(2, "INIT RIUC4...DONE\n");
#if 1
    for (i = 0; i < MAX_NODE; i++) {
        riuc4_enable_rx(&riuc_data.riuc4, i);
        usleep(250*1000);
        riuc4_enable_tx(&riuc_data.riuc4, i);
        usleep(250*1000);
    }
#endif
    SHOW_LOG(2, "ENABLE TX & RX...DONE\n");
#endif
    /*----------- STREAM --------------*/
#if 1
    SHOW_LOG(3, "INIT STREAM...START\n");
    pjmedia_endpt_create(&cp.factory, NULL, 1, &ep);
#if 1
    SHOW_LOG(3, "CODEC INIT\n");
    pjmedia_codec_g711_init(ep);

    for (i = 0; i < MAX_NODE; i++) {
        SHOW_LOG(3, "NODE MEDIA CONFIG\n");
        node_media_config(&riuc_data.node[i], &streamers[i], &receivers[i]);
        SHOW_LOG(3, "SET POOL\n");
        riuc_data.node[i].streamer->pool = pool;
        riuc_data.node[i].receiver->pool = pool;
        
        SHOW_LOG(3, "SET ENDPOINT\n");
        riuc_data.node[i].receiver->ep = ep;
        riuc_data.node[i].streamer->ep = ep;

        SHOW_LOG(3, "INIT STREAMER & RECEIVER FOR NODE %d\n", i);
        streamer_init(riuc_data.node[i].streamer, riuc_data.node[i].streamer->ep, riuc_data.node[i].receiver->pool);
        receiver_init(riuc_data.node[i].receiver, riuc_data.node[i].receiver->ep, riuc_data.node[i].receiver->pool, 2);
    }
    
    SHOW_LOG(3, "CONFIG SOUND DEVICE\n");
    for (i = 0; i < MAX_NODE; i++) {
        streamer_config_dev_source(riuc_data.node[i].streamer, snd_dev[i]);
        receiver_config_dev_sink(riuc_data.node[i].receiver, snd_dev[i]);
    }

    SHOW_LOG(2, "INIT STREAM...DONE\n");
    /*---------------------------------*/
    pthread_create(&thread, NULL, auto_register, &riuc_data);
#endif
#endif
    while(!f_quit) {
        dummy = fgets(option, sizeof(option), stdin);

        switch(option[0]) {
            case 'c':
                for (i = 0; i < MAX_NODE; i++){
                    SHOW_LOG(3, "Set device index for each radio...\nRadio %d: ", i);
                    dummy = fgets(option, sizeof(option), stdin);           
                    input = atoi(&option[0]);
                    n = sprintf(sql_cmd, "UPDATE riuc_config SET snd_dev_r%d =(?)", i);
                    sql_cmd[n] = '\0';
                    CALL_SQLITE (prepare_v2 (db, sql_cmd, strlen (sql_cmd) + 1, & stmt, NULL));
                    CALL_SQLITE (bind_int (stmt, 1, input));
                    CALL_SQLITE_EXPECT (step (stmt), DONE);

                    streamer_config_dev_source(riuc_data.node[i].streamer, input);
                    receiver_config_dev_sink(riuc_data.node[i].receiver, input);
                }


                SHOW_LOG(3, "Config completed\n");               
                break;
            case 's':
                sql = "SELECT *FROM riuc_config";
                CALL_SQLITE (prepare_v2 (db, sql, strlen (sql) + 1, &stmt, NULL));

                while (sqlite3_step(stmt) == SQLITE_ROW) {
                    printf("ID: %s\n", sqlite3_column_text(stmt, 0));
                    printf("Location: %s\n", sqlite3_column_text(stmt, 1));
                    printf("Desc: %s\n", sqlite3_column_text(stmt, 2));
                    printf("GM_CS: %s\n", sqlite3_column_text(stmt, 3));
                    printf("GMC_CS: %s\n", sqlite3_column_text(stmt, 4));
                    printf("snd_dev_r0: %u\n", sqlite3_column_int(stmt, 5));
                    printf("snd_dev_r1: %u\n", sqlite3_column_int(stmt, 6));
                    printf("snd_dev_r2: %u\n", sqlite3_column_int(stmt, 7));
                    printf("snd_dev_r3: %u\n", sqlite3_column_int(stmt, 8));
                }
                break;
            case 't':
                node_start_session(&riuc_data.node[0]);
                break;
            case 'y':
                node_stop_session(&riuc_data.node[0]);
                break;
            case 'j':
                node_invite(&riuc_data.node[0], "FTW");
                break;
            case 'l':
                node_repulse(&riuc_data.node[0], "FTW");
                break;
            case 'q':
                f_quit = 1;
                break;
            default:
                SHOW_LOG(3, "Unknown option\n"); 
                break;
        }   

    }
    SHOW_LOG(3, "Quiting...\n");
    //pthread_join(thread, NULL);

    sqlite3_finalize(stmt);
    sqlite3_close(db);

    return 0;
}
コード例 #12
0
ファイル: jbsim.c プロジェクト: ddv2005/intercom
static pj_status_t test_init(void)
{
    struct stream_cfg strm_cfg;
    pj_status_t status;

    /* Must init PJLIB first: */
    status = pj_init();
    PJ_ASSERT_RETURN(status == PJ_SUCCESS, status);

    /* Must create a pool factory before we can allocate any memory. */
    pj_caching_pool_init(&g_app.cp, &pj_pool_factory_default_policy, 0);

    /* Pool */
    g_app.pool = pj_pool_create(&g_app.cp.factory, "g_app", 512, 512, NULL);

    /* Log file */
    if (g_app.cfg.log_file) {
	status = pj_file_open(g_app.pool, g_app.cfg.log_file, 
			      PJ_O_WRONLY,
			      &g_app.log_fd);
	if (status != PJ_SUCCESS) {
	    jbsim_perror("Error writing output file", status);
	    goto on_error;
	}

	pj_log_set_decor(PJ_LOG_HAS_SENDER | PJ_LOG_HAS_COLOR | PJ_LOG_HAS_LEVEL_TEXT);
	pj_log_set_log_func(&log_cb);
    }

    /* 
     * Initialize media endpoint.
     * This will implicitly initialize PJMEDIA too.
     */
    status = pjmedia_endpt_create(&g_app.cp.factory, NULL, 0, &g_app.endpt);
    if (status != PJ_SUCCESS) {
	jbsim_perror("Error creating media endpoint", status);
	goto on_error;
    }

    /* Register codecs */
#if defined(PJMEDIA_HAS_GSM_CODEC) && PJMEDIA_HAS_GSM_CODEC != 0
    pjmedia_codec_gsm_init(g_app.endpt);
#endif
#if defined(PJMEDIA_HAS_G711_CODEC) && PJMEDIA_HAS_G711_CODEC!=0
    pjmedia_codec_g711_init(g_app.endpt);
#endif
#if defined(PJMEDIA_HAS_SPEEX_CODEC) && PJMEDIA_HAS_SPEEX_CODEC!=0
    pjmedia_codec_speex_init(g_app.endpt, 0, PJMEDIA_CODEC_SPEEX_DEFAULT_QUALITY,
			     PJMEDIA_CODEC_SPEEX_DEFAULT_COMPLEXITY);
#endif
#if defined(PJMEDIA_HAS_G722_CODEC) && (PJMEDIA_HAS_G722_CODEC != 0)
    pjmedia_codec_g722_init(g_app.endpt);
#endif
#if defined(PJMEDIA_HAS_ILBC_CODEC) && PJMEDIA_HAS_ILBC_CODEC != 0
    /* Init ILBC with mode=20 to make the losts occur at the same
     * places as other codecs.
     */
    pjmedia_codec_ilbc_init(g_app.endpt, 20);
#endif
#if defined(PJMEDIA_HAS_INTEL_IPP) && PJMEDIA_HAS_INTEL_IPP != 0
    pjmedia_codec_ipp_init(g_app.endpt);
#endif
#if defined(PJMEDIA_HAS_OPENCORE_AMRNB_CODEC) && (PJMEDIA_HAS_OPENCORE_AMRNB_CODEC != 0)
    pjmedia_codec_opencore_amrnb_init(g_app.endpt);
#endif
#if defined(PJMEDIA_HAS_L16_CODEC) && PJMEDIA_HAS_L16_CODEC != 0
    pjmedia_codec_l16_init(g_app.endpt, 0);
#endif

    /* Create the loop transport */
    status = pjmedia_transport_loop_create(g_app.endpt, &g_app.loop);
    if (status != PJ_SUCCESS) {
	jbsim_perror("Error creating loop transport", status);
	goto on_error;
    }

    /* Create transmitter stream */
    pj_bzero(&strm_cfg, sizeof(strm_cfg));
    strm_cfg.name = "tx";
    strm_cfg.dir = PJMEDIA_DIR_ENCODING;
    strm_cfg.codec = g_app.cfg.codec;
    strm_cfg.ptime = g_app.cfg.tx_ptime;
    strm_cfg.dtx = g_app.cfg.tx_dtx;
    strm_cfg.plc = PJ_TRUE;
    status = stream_init(&strm_cfg, &g_app.tx);
    if (status != PJ_SUCCESS) 
	goto on_error;

    /* Create transmitter WAV */
    status = pjmedia_wav_player_port_create(g_app.pool, 
					    g_app.cfg.tx_wav_in,
					    g_app.cfg.tx_ptime,
					    0,
					    0,
					    &g_app.tx_wav);
    if (status != PJ_SUCCESS) {
	jbsim_perror("Error reading input WAV file", status);
	goto on_error;
    }

    /* Make sure stream and WAV parameters match */
    if (g_app.tx_wav->info.clock_rate != g_app.tx->port->info.clock_rate ||
	g_app.tx_wav->info.channel_count != g_app.tx->port->info.channel_count)
    {
	jbsim_perror("Error: Input WAV file has different clock rate "
		     "or number of channels than the codec", PJ_SUCCESS);
	goto on_error;
    }


    /* Create receiver */
    pj_bzero(&strm_cfg, sizeof(strm_cfg));
    strm_cfg.name = "rx";
    strm_cfg.dir = PJMEDIA_DIR_DECODING;
    strm_cfg.codec = g_app.cfg.codec;
    strm_cfg.ptime = g_app.cfg.rx_ptime;
    strm_cfg.dtx = PJ_TRUE;
    strm_cfg.plc = g_app.cfg.rx_plc;
    status = stream_init(&strm_cfg, &g_app.rx);
    if (status != PJ_SUCCESS) 
	goto on_error;

    /* Create receiver WAV */
    status = pjmedia_wav_writer_port_create(g_app.pool, 
					    g_app.cfg.rx_wav_out,
					    g_app.rx->port->info.clock_rate,
					    g_app.rx->port->info.channel_count,
					    g_app.rx->port->info.samples_per_frame,
					    g_app.rx->port->info.bits_per_sample,
					    0,
					    0,
					    &g_app.rx_wav);
    if (status != PJ_SUCCESS) {
	jbsim_perror("Error creating output WAV file", status);
	goto on_error;
    }


    /* Frame buffer */
    g_app.framebuf = (pj_int16_t*)
		     pj_pool_alloc(g_app.pool,
				   MAX(g_app.rx->port->info.samples_per_frame,
				       g_app.tx->port->info.samples_per_frame) * sizeof(pj_int16_t));


    /* Set the receiver in the loop transport */
    pjmedia_transport_loop_disable_rx(g_app.loop, g_app.tx->strm, PJ_TRUE);

    /* Done */
    return PJ_SUCCESS;

on_error:
    test_destroy();
    return status;
}
コード例 #13
-1
ファイル: footprint.c プロジェクト: 0x0B501E7E/pjproject
int dummy_function()
{
    pj_caching_pool cp;
 
    sprintf(NULL, "%d", 0);
    rand();
    
#ifdef HAS_PJLIB
    pj_init();
    pj_caching_pool_init(&cp, NULL, 0);
    pj_array_erase(NULL, 0, 0, 0);
    pj_create_unique_string(NULL, NULL);
    pj_hash_create(NULL, 0);
    pj_hash_get(NULL, NULL, 0, NULL);
    pj_hash_set(NULL, NULL, NULL, 0, 0, NULL);
    pj_ioqueue_create(NULL, 0, NULL);
    pj_ioqueue_register_sock(NULL, NULL, 0, NULL, NULL, NULL);
    pj_pool_alloc(NULL, 0);
    pj_timer_heap_create(NULL, 0, NULL);
#endif

#ifdef HAS_PJLIB_STUN
    pjstun_get_mapped_addr(&cp.factory, 0, NULL, NULL, 80, NULL, 80, NULL);
#endif

#ifdef HAS_PJLIB_GETOPT
    pj_getopt_long(0, NULL, NULL, NULL, NULL);
#endif
    
#ifdef HAS_PJLIB_XML
    pj_xml_parse(NULL, NULL, 100);
    pj_xml_print(NULL, NULL, 10, PJ_FALSE);
    pj_xml_clone(NULL, NULL);
    pj_xml_node_new(NULL, NULL);
    pj_xml_attr_new(NULL, NULL, NULL);
    pj_xml_add_node(NULL, NULL);
    pj_xml_add_attr(NULL, NULL);
    pj_xml_find_node(NULL, NULL);
    pj_xml_find_next_node(NULL, NULL, NULL);
    pj_xml_find_attr(NULL, NULL, NULL);
    pj_xml_find(NULL, NULL, NULL, NULL);
#endif

#ifdef HAS_PJLIB_SCANNER
    pj_cis_buf_init(NULL);
    pj_cis_init(NULL, NULL);
    pj_cis_dup(NULL, NULL);
    pj_cis_add_alpha(NULL);
    pj_cis_add_str(NULL, NULL);

    pj_scan_init(NULL, NULL, 0, 0, NULL);
    pj_scan_fini(NULL);
    pj_scan_peek(NULL, NULL, NULL);
    pj_scan_peek_n(NULL, 0, NULL);
    pj_scan_peek_until(NULL, NULL, NULL);
    pj_scan_get(NULL, NULL, NULL);
    pj_scan_get_unescape(NULL, NULL, NULL);
    pj_scan_get_quote(NULL, 0, 0, NULL);
    pj_scan_get_n(NULL, 0, NULL);
    pj_scan_get_char(NULL);
    pj_scan_get_until(NULL, NULL, NULL);
    pj_scan_strcmp(NULL, NULL, 0);
    pj_scan_stricmp(NULL, NULL, 0);
    pj_scan_stricmp_alnum(NULL, NULL, 0);
    pj_scan_get_newline(NULL);
    pj_scan_restore_state(NULL, NULL);
#endif

#ifdef HAS_PJLIB_DNS
    pj_dns_make_query(NULL, NULL, 0, 0, NULL);
    pj_dns_parse_packet(NULL, NULL, 0, NULL);
    pj_dns_packet_dup(NULL, NULL, 0, NULL);
#endif

#ifdef HAS_PJLIB_RESOLVER
    pj_dns_resolver_create(NULL, NULL, 0, NULL, NULL, NULL);
    pj_dns_resolver_set_ns(NULL, 0, NULL, NULL);
    pj_dns_resolver_handle_events(NULL, NULL);
    pj_dns_resolver_destroy(NULL, 0);
    pj_dns_resolver_start_query(NULL, NULL, 0, 0, NULL, NULL, NULL);
    pj_dns_resolver_cancel_query(NULL, 0);
    pj_dns_resolver_add_entry(NULL, NULL, 0);
#endif

#ifdef HAS_PJLIB_SRV_RESOLVER
    pj_dns_srv_resolve(NULL, NULL, 0, NULL, NULL, PJ_FALSE, NULL, NULL);
#endif

#ifdef HAS_PJLIB_CRC32
    pj_crc32_init(NULL);
    pj_crc32_update(NULL, NULL, 0);
    pj_crc32_final(NULL);
#endif

#ifdef HAS_PJLIB_HMAC_MD5
    pj_hmac_md5(NULL, 0, NULL, 0, NULL);
#endif

#ifdef HAS_PJLIB_HMAC_SHA1
    pj_hmac_sha1(NULL, 0, NULL, 0, NULL);
#endif

#ifdef HAS_PJNATH_STUN
    pj_stun_session_create(NULL, NULL, NULL, PJ_FALSE, NULL);
    pj_stun_session_destroy(NULL);
    pj_stun_session_set_credential(NULL, NULL);
    pj_stun_session_create_req(NULL, 0, NULL, NULL);
    pj_stun_session_create_ind(NULL, 0, NULL);
    pj_stun_session_create_res(NULL, NULL, 0, NULL, NULL);
    pj_stun_session_send_msg(NULL, PJ_FALSE, NULL, 0, NULL);
#endif

#ifdef HAS_PJNATH_ICE
    pj_ice_strans_create(NULL, NULL, 0, NULL, NULL, NULL);
    pj_ice_strans_set_stun_domain(NULL, NULL, NULL);
    pj_ice_strans_create_comp(NULL, 0, 0, NULL);
    pj_ice_strans_add_cand(NULL, 0, PJ_ICE_CAND_TYPE_HOST, 0, NULL, PJ_FALSE);
    pj_ice_strans_init_ice(NULL, PJ_ICE_SESS_ROLE_CONTROLLED, NULL, NULL);
    pj_ice_strans_start_ice(NULL, NULL, NULL, 0, NULL);
    pj_ice_strans_stop_ice(NULL);
    pj_ice_strans_sendto(NULL, 0, NULL, 0, NULL, 0);
#endif

#ifdef HAS_PJSIP_CORE_MSG_ELEM
    /* Parameter container */
    pjsip_param_find(NULL, NULL);
    pjsip_param_print_on(NULL, NULL, 0, NULL, NULL, 0);

    /* SIP URI */
    pjsip_sip_uri_create(NULL, 0);
    pjsip_name_addr_create(NULL);

    /* TEL URI */
    pjsip_tel_uri_create(NULL);

    /* Message and headers */
    pjsip_msg_create(NULL, PJSIP_REQUEST_MSG);
    pjsip_msg_print(NULL, NULL, 0);
    pjsip_accept_hdr_create(NULL);
    pjsip_allow_hdr_create(NULL);
    pjsip_cid_hdr_create(NULL);
    pjsip_clen_hdr_create(NULL);
    pjsip_cseq_hdr_create(NULL);
    pjsip_contact_hdr_create(NULL);
    pjsip_ctype_hdr_create(NULL);
    pjsip_expires_hdr_create(NULL, 0);
    pjsip_from_hdr_create(NULL);
    pjsip_max_fwd_hdr_create(NULL, 0);
    pjsip_min_expires_hdr_create(NULL, 0);
    pjsip_rr_hdr_create(NULL);
    pjsip_require_hdr_create(NULL);
    pjsip_retry_after_hdr_create(NULL, 0);
    pjsip_supported_hdr_create(NULL);
    pjsip_unsupported_hdr_create(NULL);
    pjsip_via_hdr_create(NULL);
    pjsip_warning_hdr_create(NULL, 0, NULL, NULL);

    pjsip_parse_uri(NULL, NULL, 0, 0);
    pjsip_parse_msg(NULL, NULL, 0, NULL);
    pjsip_parse_rdata(NULL, 0, NULL);
    pjsip_find_msg(NULL, 0, 0, NULL);
#endif

#ifdef HAS_PJSIP_CORE
    pjsip_endpt_create(NULL, NULL, NULL);

    pjsip_tpmgr_create(NULL, NULL, NULL, NULL, NULL);
    pjsip_tpmgr_destroy(NULL);
    pjsip_transport_send(NULL, NULL, NULL, 0, NULL, NULL);


#endif

#ifdef HAS_PJSIP_CORE_MSG_UTIL
    pjsip_endpt_create_request(NULL, NULL, NULL, NULL, NULL, NULL, NULL,
			       -1, NULL, NULL);
    pjsip_endpt_create_request_from_hdr(NULL, NULL, NULL, NULL, NULL, NULL,
					NULL, -1, NULL, NULL);
    pjsip_endpt_create_response(NULL, NULL, -1, NULL, NULL);
    pjsip_endpt_create_ack(NULL, NULL, NULL, NULL);
    pjsip_endpt_create_cancel(NULL, NULL, NULL);
    pjsip_get_request_dest(NULL, NULL);
    pjsip_endpt_send_request_stateless(NULL, NULL, NULL, NULL);
    pjsip_get_response_addr(NULL, NULL, NULL);
    pjsip_endpt_send_response(NULL, NULL, NULL, NULL, NULL);
    pjsip_endpt_respond_stateless(NULL, NULL, -1, NULL, NULL, NULL);
#endif

#ifdef HAS_PJSIP_UDP_TRANSPORT
    pjsip_udp_transport_start(NULL, NULL, NULL, 1, NULL);
#endif

#ifdef HAS_PJSIP_TCP_TRANSPORT
    pjsip_tcp_transport_start(NULL, NULL, 1, NULL);
#endif

#ifdef HAS_PJSIP_TLS_TRANSPORT
    pjsip_tls_transport_start(NULL, NULL, NULL, NULL, 0, NULL);
#endif

#ifdef HAS_PJSIP_TRANSACTION
    pjsip_tsx_layer_init_module(NULL);

    pjsip_tsx_layer_destroy();
    pjsip_tsx_create_uac(NULL, NULL, NULL);
    pjsip_tsx_create_uas(NULL, NULL, NULL);
    pjsip_tsx_recv_msg(NULL, NULL);
    pjsip_tsx_send_msg(NULL, NULL);
    pjsip_tsx_terminate(NULL, 200);

    pjsip_endpt_send_request(NULL, NULL, -1, NULL, NULL);
    pjsip_endpt_respond(NULL, NULL, NULL, -1, NULL, NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_SDP
    pjmedia_sdp_parse(NULL, NULL, 1024, NULL);
    pjmedia_sdp_print(NULL, NULL, 1024);
    pjmedia_sdp_validate(NULL);
    pjmedia_sdp_session_clone(NULL, NULL);
    pjmedia_sdp_session_cmp(NULL, NULL, 0);
    pjmedia_sdp_attr_to_rtpmap(NULL, NULL, NULL);
    pjmedia_sdp_attr_get_fmtp(NULL, NULL);
    pjmedia_sdp_attr_get_rtcp(NULL, NULL);
    pjmedia_sdp_conn_clone(NULL, NULL);
    pjmedia_sdp_media_clone(NULL, NULL);
    pjmedia_sdp_media_find_attr(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_SDP_NEGOTIATOR
    pjmedia_sdp_neg_create_w_local_offer(NULL, NULL, NULL);
    pjmedia_sdp_neg_create_w_remote_offer(NULL, NULL, NULL, NULL);
    pjmedia_sdp_neg_get_state(NULL);
    pjmedia_sdp_neg_negotiate(NULL, NULL, PJ_FALSE);
#endif

#ifdef HAS_PJSIP_UA_LAYER
    pjsip_ua_init_module(NULL, NULL);
    pjsip_ua_destroy();
    pjsip_dlg_create_uac(NULL, NULL, NULL, NULL, NULL, NULL);
    pjsip_dlg_create_uas_and_inc_lock(NULL, NULL, NULL, NULL);
    pjsip_dlg_terminate(NULL);
    pjsip_dlg_set_route_set(NULL, NULL);
    pjsip_dlg_create_request(NULL, NULL, -1, NULL);
    pjsip_dlg_send_request(NULL, NULL, -1, NULL);
    pjsip_dlg_create_response(NULL, NULL, -1, NULL, NULL);
    pjsip_dlg_modify_response(NULL, NULL, -1, NULL);
    pjsip_dlg_send_response(NULL, NULL, NULL);
    pjsip_dlg_respond(NULL, NULL, -1, NULL, NULL, NULL);
#endif

#ifdef HAS_PJSIP_AUTH_CLIENT
    pjsip_auth_clt_init(NULL, NULL, NULL, 0);
    pjsip_auth_clt_clone(NULL, NULL, NULL);
    pjsip_auth_clt_set_credentials(NULL, 0, NULL);
    pjsip_auth_clt_init_req(NULL, NULL);
    pjsip_auth_clt_reinit_req(NULL, NULL, NULL, NULL);
#endif

#ifdef HAS_PJSIP_INV_SESSION
    pjsip_inv_usage_init(NULL, NULL);
    pjsip_inv_create_uac(NULL, NULL, 0, NULL);
    pjsip_inv_verify_request(NULL, NULL, NULL, NULL, NULL, NULL);
    pjsip_inv_create_uas(NULL, NULL, NULL, 0, NULL);
    pjsip_inv_terminate(NULL, 200, PJ_FALSE);
    pjsip_inv_invite(NULL, NULL);
    pjsip_inv_initial_answer(NULL, NULL, 200, NULL, NULL, NULL);
    pjsip_inv_answer(NULL, 200, NULL, NULL, NULL);
    pjsip_inv_end_session(NULL, 200, NULL, NULL);
    pjsip_inv_reinvite(NULL, NULL, NULL, NULL);
    pjsip_inv_update(NULL, NULL, NULL, NULL);
    pjsip_inv_send_msg(NULL, NULL);
    pjsip_dlg_get_inv_session(NULL);
    //pjsip_tsx_get_inv_session(NULL);
    pjsip_inv_state_name(PJSIP_INV_STATE_NULL);
#endif

#ifdef HAS_PJSIP_REGC
    //pjsip_regc_get_module();
    pjsip_regc_create(NULL, NULL, NULL, NULL);
    pjsip_regc_destroy(NULL);
    pjsip_regc_get_info(NULL, NULL);
    pjsip_regc_get_pool(NULL);
    pjsip_regc_init(NULL, NULL, NULL, NULL, 0, NULL, 600);
    pjsip_regc_set_credentials(NULL, 1, NULL);
    pjsip_regc_set_route_set(NULL, NULL);
    pjsip_regc_register(NULL, PJ_TRUE, NULL);
    pjsip_regc_unregister(NULL, NULL);
    pjsip_regc_update_contact(NULL, 10, NULL);
    pjsip_regc_update_expires(NULL, 600);
    pjsip_regc_send(NULL, NULL);
#endif

#ifdef HAS_PJSIP_EVENT_FRAMEWORK
    pjsip_evsub_init_module(NULL);
    pjsip_evsub_instance();
    pjsip_evsub_register_pkg(NULL, NULL, 30, 10, NULL);
    pjsip_evsub_create_uac(NULL, NULL, NULL, 10, NULL);
    pjsip_evsub_create_uas(NULL, NULL, NULL, 10, NULL);
    pjsip_evsub_terminate(NULL, PJ_FALSE);
    pjsip_evsub_get_state(NULL);
    pjsip_evsub_get_state_name(NULL);
    pjsip_evsub_initiate(NULL, NULL, -1, NULL);
    pjsip_evsub_accept(NULL, NULL, 200, NULL);
    pjsip_evsub_notify(NULL, PJSIP_EVSUB_STATE_ACTIVE, NULL, NULL, NULL);
    pjsip_evsub_current_notify(NULL, NULL);
    pjsip_evsub_send_request(NULL, NULL);
    pjsip_tsx_get_evsub(NULL);
    pjsip_evsub_set_mod_data(NULL, 1, NULL);
    pjsip_evsub_get_mod_data(NULL, 1);
#endif

#ifdef HAS_PJSIP_CALL_TRANSFER
    pjsip_xfer_init_module(NULL);
    pjsip_xfer_create_uac(NULL, NULL, NULL);
    pjsip_xfer_create_uas(NULL, NULL, NULL, NULL);
    pjsip_xfer_initiate(NULL, NULL, NULL);
    pjsip_xfer_accept(NULL, NULL, 200, NULL);
    pjsip_xfer_notify(NULL, PJSIP_EVSUB_STATE_ACTIVE, 200, NULL, NULL);
    pjsip_xfer_current_notify(NULL, NULL);
    pjsip_xfer_send_request(NULL, NULL);
#endif

#ifdef HAS_PJSIP_PRESENCE
    pjsip_pres_init_module(NULL, NULL);
    pjsip_pres_instance();
    pjsip_pres_create_uac(NULL, NULL, 0, NULL);
    pjsip_pres_create_uas(NULL, NULL, NULL, NULL);
    pjsip_pres_terminate(NULL, PJ_FALSE);
    pjsip_pres_initiate(NULL, 100, NULL);
    pjsip_pres_accept(NULL, NULL, 200, NULL);
    pjsip_pres_notify(NULL, PJSIP_EVSUB_STATE_ACTIVE, NULL, NULL, NULL);
    pjsip_pres_current_notify(NULL, NULL);
    pjsip_pres_send_request(NULL, NULL);
    pjsip_pres_get_status(NULL, NULL);
    pjsip_pres_set_status(NULL, NULL);
#endif

#ifdef HAS_PJSIP_IS_COMPOSING
    pjsip_iscomposing_create_xml(NULL, PJ_TRUE, NULL, NULL, 0);
    pjsip_iscomposing_create_body(NULL, PJ_TRUE, NULL, NULL, 0);
    pjsip_iscomposing_parse(NULL, NULL, 0, NULL, NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA
    pjmedia_endpt_create(NULL, NULL, 1, NULL);
    pjmedia_endpt_destroy(NULL);
    pjmedia_endpt_create_sdp(NULL, NULL, 1, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_EC
    pjmedia_echo_create(NULL, 0, 0, 0, 0, 0, NULL);
    pjmedia_echo_destroy(NULL);
    pjmedia_echo_playback(NULL, NULL);
    pjmedia_echo_capture(NULL, NULL, 0);
    pjmedia_echo_cancel(NULL, NULL, NULL, 0, NULL);
#endif

#ifdef HAS_PJMEDIA_SND_DEV
    pjmedia_snd_init(NULL);
    pjmedia_snd_get_dev_count();
    pjmedia_snd_get_dev_info(0);
    pjmedia_snd_open(-1, -1, 8000, 1, 80, 16, NULL, NULL, NULL, NULL);
    pjmedia_snd_open_rec(-1, 8000, 1, 160, 16, NULL, NULL, NULL);
    pjmedia_snd_open_player(-1, 8000, 1, 160, 16, NULL, NULL, NULL);
    pjmedia_snd_stream_start(NULL);
    pjmedia_snd_stream_stop(NULL);
    pjmedia_snd_stream_close(NULL);
    pjmedia_snd_deinit();
#endif

#ifdef HAS_PJMEDIA_SND_PORT
    pjmedia_snd_port_create(NULL, -1, -1, 8000, 1, 180, 16, 0, NULL);
    pjmedia_snd_port_create_rec(NULL, -1, 8000, 1, 160, 16, 0, NULL);
    pjmedia_snd_port_create_player(NULL, -1, 8000, 1, 160, 16, 0, NULL);
    pjmedia_snd_port_destroy(NULL);
    pjmedia_snd_port_get_snd_stream(NULL);
    pjmedia_snd_port_connect(NULL, NULL);
    pjmedia_snd_port_get_port(NULL);
    pjmedia_snd_port_disconnect(NULL);
#endif

#ifdef HAS_PJMEDIA_RESAMPLE
    pjmedia_resample_create(NULL, PJ_TRUE, PJ_TRUE, 0, 0, 0, 0, NULL);
    pjmedia_resample_run(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_SILENCE_DET
    pjmedia_silence_det_create(NULL, 8000, 80, NULL);
    pjmedia_silence_det_detect(NULL, NULL, 0, NULL);
    pjmedia_silence_det_apply(NULL, 0);
#endif

#ifdef HAS_PJMEDIA_PLC
    pjmedia_plc_create(NULL, 8000, 80, 0, NULL);
    pjmedia_plc_save(NULL, NULL);
    pjmedia_plc_generate(NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_CONFERENCE
    pjmedia_conf_create(NULL, 10, 8000, 1, 160, 16, 0, NULL);
    pjmedia_conf_destroy(NULL);
    pjmedia_conf_get_master_port(NULL);
    pjmedia_conf_add_port(NULL, NULL, NULL, NULL, NULL);
    pjmedia_conf_configure_port(NULL, 1, 0, 0);
    pjmedia_conf_connect_port(NULL, 0, 0, 0);
    pjmedia_conf_disconnect_port(NULL, 0, 0);
    pjmedia_conf_remove_port(NULL, 0);
    pjmedia_conf_enum_ports(NULL, NULL, NULL);
    pjmedia_conf_get_port_info(NULL, 0, NULL);
    pjmedia_conf_get_ports_info(NULL, NULL, NULL);
    pjmedia_conf_get_signal_level(NULL, 0, NULL, NULL);
    pjmedia_conf_adjust_rx_level(NULL, 0, 0);
    pjmedia_conf_adjust_tx_level(NULL, 0, 0);
#endif

#ifdef HAS_PJMEDIA_MASTER_PORT
    pjmedia_master_port_create(NULL, NULL, NULL, 0, NULL);
    pjmedia_master_port_start(NULL);
    pjmedia_master_port_stop(NULL);
    pjmedia_master_port_set_uport(NULL, NULL);
    pjmedia_master_port_get_uport(NULL);
    pjmedia_master_port_set_dport(NULL, NULL);
    pjmedia_master_port_get_dport(NULL);
    pjmedia_master_port_destroy(NULL, PJ_FALSE);
#endif

#ifdef HAS_PJMEDIA_RTP
    pjmedia_rtp_session_init(NULL, 0, 0);
    pjmedia_rtp_encode_rtp(NULL, 0, 0, 0, 0, NULL, NULL);
    pjmedia_rtp_decode_rtp(NULL, NULL, 0, NULL, NULL, NULL);
    pjmedia_rtp_session_update(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_RTCP
    pjmedia_rtcp_init(NULL, NULL, 0, 0, 0);
    pjmedia_rtcp_get_ntp_time(NULL, NULL);
    pjmedia_rtcp_fini(NULL);
    pjmedia_rtcp_rx_rtp(NULL, 0, 0, 0);
    pjmedia_rtcp_tx_rtp(NULL, 0);
    pjmedia_rtcp_rx_rtcp(NULL, NULL, 0);
    pjmedia_rtcp_build_rtcp(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_JBUF
    pjmedia_jbuf_create(NULL, NULL, 0, 0, 0, NULL);
    pjmedia_jbuf_set_fixed(NULL, 0);
    pjmedia_jbuf_set_adaptive(NULL, 0, 0, 0);
    pjmedia_jbuf_destroy(NULL);
    pjmedia_jbuf_put_frame(NULL, NULL, 0, 0);
    pjmedia_jbuf_get_frame(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_STREAM
    pjmedia_stream_create(NULL, NULL, NULL, NULL, NULL, NULL);
    pjmedia_stream_destroy(NULL);
    pjmedia_stream_get_port(NULL, NULL);
    pjmedia_stream_get_transport(NULL);
    pjmedia_stream_start(NULL);
    pjmedia_stream_get_stat(NULL, NULL);
    pjmedia_stream_pause(NULL, PJMEDIA_DIR_ENCODING);
    pjmedia_stream_resume(NULL, PJMEDIA_DIR_ENCODING);
    pjmedia_stream_dial_dtmf(NULL, NULL);
    pjmedia_stream_check_dtmf(NULL);
    pjmedia_stream_get_dtmf(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_TONEGEN
    pjmedia_tonegen_create(NULL, 0, 0, 0, 0, 0, NULL);
    pjmedia_tonegen_is_busy(NULL);
    pjmedia_tonegen_stop(NULL);
    pjmedia_tonegen_play(NULL, 0, NULL, 0);
    pjmedia_tonegen_play_digits(NULL, 0, NULL, 0);
    pjmedia_tonegen_get_digit_map(NULL, NULL);
    pjmedia_tonegen_set_digit_map(NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_UDP_TRANSPORT
    pjmedia_transport_udp_create(NULL, NULL, 0, 0, NULL);
    pjmedia_transport_udp_close(NULL);
#endif

#ifdef HAS_PJMEDIA_FILE_PLAYER
    pjmedia_wav_player_port_create(NULL, NULL, 0, 0, 0, NULL);
    pjmedia_wav_player_port_set_pos(NULL, 0);
    pjmedia_wav_player_port_get_pos(NULL);
    pjmedia_wav_player_set_eof_cb(NULL, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_FILE_CAPTURE
    pjmedia_wav_writer_port_create(NULL, NULL, 8000, 1, 80, 16, 0, 0, NULL);
    pjmedia_wav_writer_port_get_pos(NULL);
    pjmedia_wav_writer_port_set_cb(NULL, 0, NULL, NULL);
#endif

#ifdef HAS_PJMEDIA_MEM_PLAYER
    pjmedia_mem_player_create(NULL, NULL, 1000, 8000, 1, 80, 16, 0, NULL);
#endif

#ifdef HAS_PJMEDIA_MEM_CAPTURE
    pjmedia_mem_capture_create(NULL, NULL, 1000, 8000, 1, 80, 16, 0, NULL);
#endif

#ifdef HAS_PJMEDIA_ICE
    pjmedia_ice_create(NULL, NULL, 0, NULL, NULL);
    pjmedia_ice_destroy(NULL);
    pjmedia_ice_start_init(NULL, 0, NULL, NULL, NULL);
    pjmedia_ice_init_ice(NULL, PJ_ICE_SESS_ROLE_CONTROLLED, NULL, NULL);
    pjmedia_ice_modify_sdp(NULL, NULL, NULL);
    pjmedia_ice_start_ice(NULL, NULL, NULL, 0);
    pjmedia_ice_stop_ice(NULL);
#endif

#ifdef HAS_PJMEDIA_G711_CODEC
    pjmedia_codec_g711_init(NULL);
    pjmedia_codec_g711_deinit();
#endif

#ifdef HAS_PJMEDIA_GSM_CODEC
    pjmedia_codec_gsm_init(NULL);
    pjmedia_codec_gsm_deinit();
#endif

#ifdef HAS_PJMEDIA_SPEEX_CODEC
    pjmedia_codec_speex_init(NULL, 0, 0, 0);
    pjmedia_codec_speex_deinit();
#endif

#ifdef HAS_PJMEDIA_ILBC_CODEC
    pjmedia_codec_ilbc_init(NULL, 0);
    pjmedia_codec_ilbc_deinit();
#endif

    return 0;
}