|
FFmpeg
|
#include <stdint.h>#include <stddef.h>#include "libavutil/base64.h"#include "libavutil/lfg.h"#include "avformat.h"#include "tls.h"#include "url.h"Go to the source code of this file.
Data Structures | |
| struct | RTCContext |
Macros | |
| #define | RTC_MAX_SDP_SIZE 8192 |
| Maximum size limit of a Session Description Protocol (SDP), be it an offer or answer. | |
| #define | RTC_DTLS_SRTP_KEY_LEN 16 |
| The size of the Secure Real-time Transport Protocol (SRTP) master key material that is exported by Secure Sockets Layer (SSL) after a successful Datagram Transport Layer Security (DTLS) handshake. | |
| #define | RTC_DTLS_SRTP_SALT_LEN 14 |
| #define | RTC_SRTP_KEY_SIZE AV_BASE64_SIZE(RTC_DTLS_SRTP_KEY_LEN + RTC_DTLS_SRTP_SALT_LEN) |
| #define | RTC_SRTP_SUITE "SRTP_AES128_CM_HMAC_SHA1_80" |
| The profile for OpenSSL's SRTP is SRTP_AES128_CM_SHA1_80, see ssl/d1_srtp.c. | |
| #define | RTC_DTLS_SRTP_CHECKSUM_LEN 16 |
| The maximum size of the Secure Real-time Transport Protocol (SRTP) HMAC checksum and padding that is appended to the end of the packet. | |
| #define | RTC_US_PER_MS 1000 |
| #define | RTC_MAX_UDP_BUFFER_SIZE 4096 |
| Maximum size of the buffer for sending and receiving UDP packets. | |
| #define | RTC_RTP_HEADER_SIZE 12 |
| The RTP header is 12 bytes long, comprising the Version(1B), PT(1B), SequenceNumber(2B), Timestamp(4B), and SSRC(4B). | |
| #define | RTC_ELAPSED(starttime, endtime) |
| #define | RTC_OPTIONS(pstruct, field, flag) |
Enumerations | |
| enum | RTCState { RTC_STATE_NONE , RTC_STATE_INIT , RTC_STATE_OFFER , RTC_STATE_ANSWER , RTC_STATE_NEGOTIATED , RTC_STATE_UDP_CONNECTED , RTC_STATE_ICE_CONNECTING , RTC_STATE_ICE_CONNECTED , RTC_STATE_DTLS_FINISHED , RTC_STATE_SRTP_FINISHED , RTC_STATE_READY , RTC_STATE_FAILED } |
| enum | RTCFlags { RTC_DTLS_ACTIVE = (1 << 0) } |
Functions | |
| 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_parse_answer (RTCContext *rtc) |
| Parses the ICE ufrag, pwd, and candidates from the SDP answer. | |
| 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) indicate the RTP version, see https://www.rfc-editor.org/rfc/rfc3550#section-5.1 The RTCP packet header is similar to RTP, see https://www.rfc-editor.org/rfc/rfc3550#section-6.4.1. | |
| int | ff_rtc_media_is_rtcp (const uint8_t *b, int size) |
| int | ff_rtc_udp_connect (RTCContext *rtc) |
| To establish a connection with the UDP server, we utilize ICE-LITE in a Client-Server mode. | |
| int | ff_rtc_ice_dtls_handshake (RTCContext *rtc) |
| 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_ice_check_and_send_consent (RTCContext *rtc, int64_t now) |
| Refer to RFC 7675 Periodically send Consent Freshness STUN Binding Request. | |
| void | ff_rtc_ice_check_and_update_consent (RTCContext *rtc, const uint8_t *buf, int size) |
| int | ff_rtc_ice_check_consent (RTCContext *rtc, int64_t now) |
| void | ff_rtc_deinit (RTCContext *rtc) |
| #define RTC_MAX_SDP_SIZE 8192 |
Maximum size limit of a Session Description Protocol (SDP), be it an offer or answer.
Definition at line 39 of file rtc.h.
Referenced by ff_rtc_exchange_sdp(), and generate_sdp_offer().
| #define RTC_DTLS_SRTP_KEY_LEN 16 |
The size of the Secure Real-time Transport Protocol (SRTP) master key material that is exported by Secure Sockets Layer (SSL) after a successful Datagram Transport Layer Security (DTLS) handshake.
This material consists of a key of 16 bytes and a salt of 14 bytes.
Definition at line 47 of file rtc.h.
Referenced by ff_rtc_srtp_export_keys(), and setup_srtp().
| #define RTC_DTLS_SRTP_SALT_LEN 14 |
Definition at line 48 of file rtc.h.
Referenced by ff_rtc_srtp_export_keys(), and setup_srtp().
| #define RTC_SRTP_KEY_SIZE AV_BASE64_SIZE(RTC_DTLS_SRTP_KEY_LEN + RTC_DTLS_SRTP_SALT_LEN) |
| #define RTC_SRTP_SUITE "SRTP_AES128_CM_HMAC_SHA1_80" |
The profile for OpenSSL's SRTP is SRTP_AES128_CM_SHA1_80, see ssl/d1_srtp.c.
The profile for FFmpeg's SRTP is SRTP_AES128_CM_HMAC_SHA1_80, see libavformat/srtp.c.
Definition at line 56 of file rtc.h.
Referenced by setup_srtp().
| #define RTC_DTLS_SRTP_CHECKSUM_LEN 16 |
The maximum size of the Secure Real-time Transport Protocol (SRTP) HMAC checksum and padding that is appended to the end of the packet.
To calculate the maximum size of the User Datagram Protocol (UDP) packet that can be sent out, subtract this size from the pkt_size.
Definition at line 64 of file rtc.h.
Referenced by create_rtp_muxer(), initialize(), and rtp_history_store().
| #define RTC_US_PER_MS 1000 |
Definition at line 66 of file rtc.h.
Referenced by ff_rtc_ice_check_and_send_consent(), ff_rtc_ice_check_consent(), and ff_rtc_ice_dtls_handshake().
| #define RTC_MAX_UDP_BUFFER_SIZE 4096 |
Maximum size of the buffer for sending and receiving UDP packets.
Please note that this size does not limit the size of the UDP packet that can be sent. To set the limit for packet size, modify the pkt_size parameter. For instance, it is possible to set the UDP buffer to 4096 to send or receive packets, but please keep in mind that the pkt_size option limits the packet size to 1400.
Definition at line 75 of file rtc.h.
Referenced by create_rtp_muxer(), and handle_rtx_packet().
| #define RTC_RTP_HEADER_SIZE 12 |
The RTP header is 12 bytes long, comprising the Version(1B), PT(1B), SequenceNumber(2B), Timestamp(4B), and SSRC(4B).
See https://www.rfc-editor.org/rfc/rfc3550#section-5.1
Definition at line 82 of file rtc.h.
Referenced by ff_rtc_media_is_rtcp(), ff_rtc_media_is_rtp_rtcp(), and handle_rtx_packet().
| #define RTC_ELAPSED | ( | starttime, | |
| endtime ) |
Definition at line 85 of file rtc.h.
Referenced by create_rtp_muxer(), ff_rtc_ice_check_consent(), ff_rtc_ice_dtls_handshake(), ff_rtc_initialize(), ff_rtc_parse_answer(), ff_rtc_udp_connect(), and setup_srtp().
| #define RTC_OPTIONS | ( | pstruct, | |
| field, | |||
| flag ) |
| enum RTCState |
| int ff_rtc_initialize | ( | RTCContext * | rtc | ) |
Definition at line 165 of file rtc.c.
Referenced by initialize().
| int ff_rtc_exchange_sdp | ( | RTCContext * | rtc | ) |
Exchange SDP offer with WebRTC peer to get the answer.
Definition at line 203 of file rtc.c.
Referenced by whip_init().
| int ff_rtc_parse_answer | ( | RTCContext * | rtc | ) |
Parses the ICE ufrag, pwd, and candidates from the SDP answer.
This function is used to extract the ICE ufrag, pwd, and candidates from the SDP answer. It returns an error if any of these fields is NULL. The function only uses the first candidate if there are multiple candidates. However, support for multiple candidates will be added in the future.
| rtc | Pointer to the RTCContext |
Definition at line 330 of file rtc.c.
Referenced by whip_init().
| 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) indicate the RTP version, see https://www.rfc-editor.org/rfc/rfc3550#section-5.1 The RTCP packet header is similar to RTP, see https://www.rfc-editor.org/rfc/rfc3550#section-6.4.1.
Definition at line 645 of file rtc.c.
Referenced by on_rtp_write_packet().
| int ff_rtc_media_is_rtcp | ( | const uint8_t * | b, |
| int | size ) |
Definition at line 651 of file rtc.c.
Referenced by on_rtp_write_packet(), and whip_write_packet().
| int ff_rtc_udp_connect | ( | RTCContext * | rtc | ) |
To establish a connection with the UDP server, we utilize ICE-LITE in a Client-Server mode.
In this setup, FFmpeg acts as the UDP client, while the peer functions as the UDP server.
Definition at line 700 of file rtc.c.
Referenced by whip_init().
| int ff_rtc_ice_dtls_handshake | ( | RTCContext * | rtc | ) |
Definition at line 737 of file rtc.c.
Referenced by whip_init().
| int ff_rtc_srtp_export_keys | ( | RTCContext * | rtc | ) |
This represents the material used to build the SRTP master key. It is generated by DTLS and has the following layout: 16B 16B 14B 14B client_key | server_key | client_salt | server_salt
Definition at line 846 of file rtc.c.
Referenced by setup_srtp().
| int ff_rtc_dispose_session | ( | RTCContext * | rtc | ) |
RTC is connectionless, for it's based on UDP, so it check whether sesison is timeout.
In such case, publishers can't republish the stream util the session is timeout. This function is called to notify the server that the stream is ended, server should expire and close the session immediately, so that publishers can republish the stream quickly.
Definition at line 899 of file rtc.c.
Referenced by whip_deinit().
| int ff_rtc_ice_check_and_send_consent | ( | RTCContext * | rtc, |
| int64_t | now ) |
Refer to RFC 7675 Periodically send Consent Freshness STUN Binding Request.
Definition at line 956 of file rtc.c.
Referenced by whip_write_packet().
| void ff_rtc_ice_check_and_update_consent | ( | RTCContext * | rtc, |
| const uint8_t * | buf, | ||
| int | size ) |
Definition at line 980 of file rtc.c.
Referenced by whip_write_packet().
| int ff_rtc_ice_check_consent | ( | RTCContext * | rtc, |
| int64_t | now ) |
Definition at line 988 of file rtc.c.
Referenced by whip_write_packet().
| void ff_rtc_deinit | ( | RTCContext * | rtc | ) |
Definition at line 1000 of file rtc.c.
Referenced by whip_deinit().