コード例 #1
0
ファイル: simple_pjsua.c プロジェクト: traviscross/ZRTP4PJ
/* Initialize the ZRTP transport and the user callbacks */
pjmedia_transport* on_create_media_transport(pjsua_call_id call_id,
                                             unsigned media_idx,
                                             pjmedia_transport *base_tp,
                                             unsigned flags)
{
    pjmedia_transport *zrtp_tp = NULL;
    pj_status_t status;
    pjmedia_endpt* endpt = pjsua_get_pjmedia_endpt();
    
    PJ_LOG(3,(THIS_FILE, "ZRTP transport created"));
    status = pjmedia_transport_zrtp_create(endpt, NULL, base_tp,
                                           &zrtp_tp, flags);
    usercb.userData = zrtp_tp;
    
    /* this is optional but highly recommended to enable the application
     * to report status information to the user, such as verfication status,
     * SAS code, etc
     */
    pjmedia_transport_zrtp_setUserCallback(zrtp_tp, &usercb);
    
    /*
     * Initialize the transport. Just the filename of the ZID file that holds
     * our partners ZID, shared data etc. If the files does not exists it will
     * be created an initialized.
     */
    pjmedia_transport_zrtp_initialize(zrtp_tp, "simple.zid", PJ_TRUE);
    return zrtp_tp;
}
コード例 #2
0
ファイル: zrtp_android.c プロジェクト: adybkows/sip-ptt
/* Initialize the ZRTP transport and the user callbacks */
pjmedia_transport* on_zrtp_transport_created(pjsua_call_id call_id,
        unsigned media_idx,
        pjmedia_transport *base_tp,
        unsigned flags) {

    pjmedia_transport *zrtp_tp = NULL;
    pj_status_t status;
    pjmedia_endpt* endpt = pjsua_get_pjmedia_endpt();

    status = pjmedia_transport_zrtp_create(endpt, NULL, base_tp,
                                           &zrtp_tp, (flags & PJSUA_MED_TP_CLOSE_MEMBER));



    if(status == PJ_SUCCESS) {
        PJ_LOG(3,(THIS_FILE, "ZRTP transport created"));

        // Build callback data ponter
        zrtp_cb_user_data* zrtp_cb_data = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_cb_user_data);
        zrtp_cb_data->zrtp_tp = zrtp_tp;
        zrtp_cb_data->call_id = call_id;
        zrtp_cb_data->cipher = pj_str("");
        zrtp_cb_data->sas = pj_str("");


        // Build callback struct
        zrtp_UserCallbacks* zrtp_cbs = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_UserCallbacks);
        zrtp_cbs->zrtp_secureOn = &zrtpSecureOn;
        zrtp_cbs->zrtp_secureOff = &zrtpSecureOff;
        zrtp_cbs->zrtp_showSAS = &zrtpShowSas;
        zrtp_cbs->zrtp_confirmGoClear = &confirmGoClear;
        zrtp_cbs->zrtp_showMessage = &showMessage;
        zrtp_cbs->zrtp_zrtpNegotiationFailed = &zrtpNegotiationFailed;
        zrtp_cbs->zrtp_zrtpNotSuppOther = &zrtpNotSuppOther;
        zrtp_cbs->zrtp_zrtpAskEnrollment = &zrtpAskEnrollment;
        zrtp_cbs->zrtp_zrtpInformEnrollment = &zrtpInformEnrollment;
        zrtp_cbs->zrtp_signSAS = &signSAS;
        zrtp_cbs->zrtp_checkSASSignature = &checkSASSignature;
        zrtp_cbs->userData = zrtp_cb_data;

        pjmedia_transport_zrtp_setUserCallback(zrtp_tp, zrtp_cbs);


        /*
        * Initialize the transport. Just the filename of the ZID file that holds
        * our partners ZID, shared data etc. If the files does not exists it will
        * be created an initialized. The ZRTP configuration is not yet implemented
        * thus the parameter is NULL.
        */
        pjmedia_transport_zrtp_initialize(zrtp_tp, css_var.zid_file, PJ_TRUE);

        return zrtp_tp;
    } else {
        PJ_LOG(1, (THIS_FILE, "ZRTP transport problem : %d", status));
        return base_tp;
    }
}
コード例 #3
0
ファイル: zrtp_android.c プロジェクト: 0x0B501E7E/CSipSimple
/* Initialize the ZRTP transport and the user callbacks */
pjmedia_transport* on_zrtp_transport_created(pjsua_call_id call_id,
	unsigned media_idx,
	pjmedia_transport *base_tp,
	unsigned flags) {
        pjsua_call *call;
		pjmedia_transport *zrtp_tp = NULL;
		pj_status_t status;
		pjmedia_endpt* endpt = pjsua_get_pjmedia_endpt();

		// For now, do zrtp only on audio stream
        call = &pjsua_var.calls[call_id];
        if (media_idx < call->med_prov_cnt) {
            pjsua_call_media *call_med = &call->media_prov[media_idx];
            if (call_med->tp && call_med->type != PJMEDIA_TYPE_AUDIO) {
                PJ_LOG(2, (THIS_FILE, "ZRTP transport not yet supported for : %d", call_med->type));
                return base_tp;
            }
        }

	    // Create zrtp transport adapter
		status = pjmedia_transport_zrtp_create(endpt, NULL, base_tp,
											   &zrtp_tp, (flags & PJSUA_MED_TP_CLOSE_MEMBER));

		if(status == PJ_SUCCESS){
			PJ_LOG(4,(THIS_FILE, "ZRTP transport created"));
			// TODO : we should use our own pool
			// Build callback data ponter
			zrtp_cb_user_data* zrtp_cb_data = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_cb_user_data);
			zrtp_cb_data->zrtp_tp = zrtp_tp;
			zrtp_cb_data->call_id = call_id;
			zrtp_cb_data->cipher = pj_str("");
			zrtp_cb_data->sas = pj_str("");
			zrtp_cb_data->sas_verified = PJ_FALSE;


			// Build callback struct
			zrtp_UserCallbacks* zrtp_cbs = PJ_POOL_ZALLOC_T(css_var.pool, zrtp_UserCallbacks);
			zrtp_cbs->zrtp_secureOn = &zrtpSecureOn;
			zrtp_cbs->zrtp_secureOff = &zrtpSecureOff;
			zrtp_cbs->zrtp_showSAS = &zrtpShowSas;
			zrtp_cbs->zrtp_confirmGoClear = &confirmGoClear;
			zrtp_cbs->zrtp_showMessage = &showMessage;
			zrtp_cbs->zrtp_zrtpNegotiationFailed = &zrtpNegotiationFailed;
			zrtp_cbs->zrtp_zrtpNotSuppOther = &zrtpNotSuppOther;
			zrtp_cbs->zrtp_zrtpAskEnrollment = &zrtpAskEnrollment;
			zrtp_cbs->zrtp_zrtpInformEnrollment = &zrtpInformEnrollment;
			zrtp_cbs->zrtp_signSAS = &signSAS;
			zrtp_cbs->zrtp_checkSASSignature = &checkSASSignature;
			zrtp_cbs->userData = zrtp_cb_data;

			pjmedia_transport_zrtp_setUserCallback(zrtp_tp, zrtp_cbs);


			/*
			* Initialize the transport. Just the filename of the ZID file that holds
			* our partners ZID, shared data etc. If the files does not exists it will
			* be created an initialized. The ZRTP configuration is not yet implemented
			* thus the parameter is NULL.
			*/
			pjmedia_transport_zrtp_initialize(zrtp_tp, css_var.zid_file, PJ_TRUE);
#if 0
			// This is a crappy hack for buggy versions of sip servers that does not correctly manage hello
			ZrtpContext* zrtpContext = pjmedia_transport_zrtp_getZrtpContext(zrtp_tp);
			zrtp_setMandatoryOnly(zrtpContext);
#endif

			return zrtp_tp;
		} else {
			PJ_LOG(1, (THIS_FILE, "ZRTP transport problem : %d", status));
			return base_tp;
		}
}