bool_t video_stream_enable_strp(VideoStream* stream, enum ortp_srtp_crypto_suite_t suite, const char* snd_key, const char* rcv_key) { // assign new srtp transport to stream->session // with 2 Master Keys RtpTransport *rtp_tpt, *rtcp_tpt; if (!ortp_srtp_supported()) { ms_error("ortp srtp support not enabled"); return FALSE; } ms_message("%s: stream=%p key='%s' key='%s'", __FUNCTION__, stream, snd_key, rcv_key); stream->srtp_session = ortp_srtp_create_configure_session(suite, rtp_session_get_send_ssrc(stream->session), snd_key, rcv_key); if (!stream->srtp_session) { return FALSE; } // TODO: check who will free rtp_tpt ? srtp_transport_new(stream->srtp_session, &rtp_tpt, &rtcp_tpt); rtp_session_set_transports(stream->session, rtp_tpt, rtcp_tpt); return TRUE; }
static int check_srtp_session_created(MediaStream *stream){ if (stream->sessions.srtp_session==NULL){ err_status_t err; srtp_t session; RtpTransport *rtp=NULL,*rtcp=NULL; err = ortp_srtp_create(&session, NULL); if (err != 0) { ms_error("Failed to create srtp session (%d)", err); return -1; } stream->sessions.srtp_session=session; srtp_transport_new(session,&rtp,&rtcp); rtp_session_set_transports(stream->sessions.rtp_session,rtp,rtcp); stream->sessions.is_secured=TRUE; } return 0; }