int AmZRTPSessionState::initSession(AmSession* session) { DBG("Initializing ZRTP stream...\n"); // Allocate zrtp session zrtp_status_t status = zrtp_session_init( AmZRTP::zrtp_global, &zrtp_profile, ZRTP_SIGNALING_ROLE_UNKNOWN, // fixme &zrtp_session); if (zrtp_status_ok != status) { // Check error code and debug logs return status; } // Set call-back pointer to our parent structure zrtp_session_set_userdata(zrtp_session, session); // Attach audio stream status = zrtp_stream_attach(zrtp_session, &zrtp_audio); if (zrtp_status_ok != status) { // Check error code and debug logs return status; } zrtp_stream_set_userdata(zrtp_audio, session); return 0; }
zrtp_status_t zrtp_test_session_create(zrtp_test_id_t endpoint_id, zrtp_test_session_cfg_t* cfg, zrtp_test_id_t* id) { zrtp_status_t s; unsigned i; zrtp_test_session_t *the_session; zrtp_endpoint_t *the_endpoint = zrtp_test_endpoint_by_id(endpoint_id); if (!the_endpoint) return zrtp_status_fail; if (the_endpoint->sessions_count >= K_ZRTP_TEST_MAX_SESSIONS_PER_ENDPOINT) return zrtp_status_fail; the_session = &the_endpoint->sessions[the_endpoint->sessions_count++]; zrtp_memset(the_session, 0, sizeof(zrtp_test_session_t)); zrtp_memcpy(&the_session->cfg, cfg, sizeof(zrtp_test_session_cfg_t)); the_session->id = g_sessions_counter++; the_session->endpoint_id = endpoint_id; s = zrtp_session_init(the_endpoint->zrtp, &cfg->zrtp, the_endpoint->zid, cfg->role, &the_session->zrtp); if (zrtp_status_ok == s) { zrtp_session_set_userdata(the_session->zrtp, &the_session->id); for (i=0; i<cfg->streams_count; i++) { zrtp_test_stream_t *the_stream = &the_session->streams[i]; zrtp_memset(the_stream, 0, sizeof(zrtp_test_stream_t)); the_stream->id = g_streams_counter++; the_stream->session_id = the_session->id; the_stream->endpoint_id = endpoint_id; s = zrtp_stream_attach(the_session->zrtp, &the_stream->zrtp); if (zrtp_status_ok == s) { zrtp_stream_set_userdata(the_stream->zrtp, &the_stream->id); the_session->streams_count++; } else { break; } } } if (zrtp_status_ok == s) { *id = the_session->id; } return s; }