39#define RTC_MAX_SDP_SIZE 8192
47#define RTC_DTLS_SRTP_KEY_LEN 16
48#define RTC_DTLS_SRTP_SALT_LEN 14
50#define RTC_SRTP_KEY_SIZE AV_BASE64_SIZE(RTC_DTLS_SRTP_KEY_LEN + RTC_DTLS_SRTP_SALT_LEN)
56#define RTC_SRTP_SUITE "SRTP_AES128_CM_HMAC_SHA1_80"
64#define RTC_DTLS_SRTP_CHECKSUM_LEN 16
66#define RTC_US_PER_MS 1000
75#define RTC_MAX_UDP_BUFFER_SIZE 4096
82#define RTC_RTP_HEADER_SIZE 12
85#define RTC_ELAPSED(starttime, endtime) ((float)(endtime - starttime) / 1000)
245#define RTC_OPTIONS(pstruct, field, flag) \
246 { "handshake_timeout", "Timeout in milliseconds for ICE and DTLS handshake.", offsetof(pstruct, field.handshake_timeout), AV_OPT_TYPE_INT, { .i64 = 5000 }, -1, INT_MAX, flag }, \
247 { "timeout", "Set timeout for socket I/O operations", offsetof(pstruct, field.timeout), AV_OPT_TYPE_DURATION, { .i64 = -1 }, -1, INT_MAX, flag }, \
248 { "pkt_size", "The maximum size, in bytes, of RTP packets that send out", offsetof(pstruct, field.pkt_size), AV_OPT_TYPE_INT, { .i64 = 1200 }, -1, INT_MAX, flag }, \
249 { "ts_buffer_size", "The buffer size, in bytes, of underlying protocol", offsetof(pstruct, field.ts_buffer_size), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, INT_MAX, flag }, \
250 { "dtls_active", "Set dtls role as active", 0, AV_OPT_TYPE_CONST, { .i64 = RTC_DTLS_ACTIVE }, 0, UINT_MAX, flag, .unit = "flags" }, \
251 { "authorization", "The optional Bearer token for HTTP Authorization", offsetof(pstruct, field.authorization), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, flag }, \
252 { "cert_file", "The optional certificate file path for DTLS", offsetof(pstruct, field.cert_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, flag }, \
253 { "key_file", "The optional private key file path for DTLS", offsetof(pstruct, field.key_file), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, flag }
#define RTC_SRTP_KEY_SIZE
#define RTC_MAX_UDP_BUFFER_SIZE
Maximum size of the buffer for sending and receiving UDP packets.
void ff_rtc_ice_check_and_update_consent(RTCContext *rtc, const uint8_t *buf, int size)
void ff_rtc_deinit(RTCContext *rtc)
#define RTC_DTLS_SRTP_SALT_LEN
int ff_rtc_parse_answer(RTCContext *rtc)
Parses the ICE ufrag, pwd, and candidates from the SDP answer.
int ff_rtc_media_is_rtcp(const uint8_t *b, int size)
int ff_rtc_ice_dtls_handshake(RTCContext *rtc)
int ff_rtc_ice_check_consent(RTCContext *rtc, int64_t now)
int ff_rtc_srtp_export_keys(RTCContext *rtc)
int ff_rtc_dispose_session(RTCContext *rtc)
RTC is connectionless, for it's based on UDP, so it check whether sesison is timeout.
int ff_rtc_media_is_rtp_rtcp(const uint8_t *b, int size)
In RTP packets, the first byte is represented as 0b10xxxxxx, where the initial two bits (0b10) indica...
int ff_rtc_initialize(RTCContext *rtc)
int ff_rtc_exchange_sdp(RTCContext *rtc)
Exchange SDP offer with WebRTC peer to get the answer.
int ff_rtc_ice_check_and_send_consent(RTCContext *rtc, int64_t now)
Refer to RFC 7675 Periodically send Consent Freshness STUN Binding Request.
#define RTC_DTLS_SRTP_KEY_LEN
The size of the Secure Real-time Transport Protocol (SRTP) master key material that is exported by Se...
@ RTC_STATE_ICE_CONNECTED
@ RTC_STATE_SRTP_FINISHED
@ RTC_STATE_DTLS_FINISHED
@ RTC_STATE_UDP_CONNECTED
@ RTC_STATE_ICE_CONNECTING
@ RTC_STATE_NEGOTIATED
After parsing the answer received from the peer, the local peer negotiates the abilities in the offer...
int ff_rtc_udp_connect(RTCContext *rtc)
To establish a connection with the UDP server, we utilize ICE-LITE in a Client-Server mode.
Context structure for the Lagged Fibonacci PRNG.
char srtp_send_key[RTC_SRTP_KEY_SIZE]
uint8_t dtls_srtp_materials[(RTC_DTLS_SRTP_KEY_LEN+RTC_DTLS_SRTP_SALT_LEN) *2]
This represents the material used to build the SRTP master key.
char key_buf[MAX_CERTIFICATE_SIZE]
char * remote_fingerprint
int pkt_size
The size of RTP packet, should generally be set to MTU.
char buf[RTC_MAX_UDP_BUFFER_SIZE]
char * ice_protocol
This represents the ICE candidate protocol, priority, host and port.
char * sdp_offer
This is the SDP offer generated by the local peer based on the codec parameters, DTLS,...
int64_t last_consent_rx_time
char srtp_recv_key[RTC_SRTP_KEY_SIZE]
char cert_buf[MAX_CERTIFICATE_SIZE]
int64_t last_consent_tx_time
char * authorization
The optional Bearer token for HTTP Authorization.
#define MAX_CERTIFICATE_SIZE
Maximum size limit of a certificate and private key size.
unbuffered private I/O API