@@ -193,9 +193,14 @@ enum WHIPState {
193193 WHIP_STATE_FAILED ,
194194};
195195
196+ typedef enum WHIPFlags {
197+ WHIP_FLAG_IGNORE_IPV6 = (1 << 0 ) // Ignore ipv6 candidate
198+ } WHIPFlags ;
199+
196200typedef struct WHIPContext {
197201 AVClass * av_class ;
198202
203+ uint32_t flags ; // enum WHIPFlags
199204 /* The state of the RTC connection. */
200205 enum WHIPState state ;
201206 /* The callback return value for DTLS. */
@@ -871,6 +876,7 @@ static int parse_answer(AVFormatContext *s)
871876 if (ptr && av_stristr (ptr , "host" )) {
872877 char protocol [17 ], host [129 ];
873878 int priority , port ;
879+ struct in6_addr addr6 ;
874880 ret = sscanf (ptr , "%16s %d %128s %d typ host" , protocol , & priority , host , & port );
875881 if (ret != 4 ) {
876882 av_log (whip , AV_LOG_ERROR , "WHIP: Failed %d to parse line %d %s from %s\n" ,
@@ -879,6 +885,11 @@ static int parse_answer(AVFormatContext *s)
879885 goto end ;
880886 }
881887
888+ if (whip -> flags & WHIP_FLAG_IGNORE_IPV6 && inet_pton (AF_INET6 , host , & addr6 ) == 1 ) {
889+ av_log (whip , AV_LOG_DEBUG , "WHIP: Ignore ipv6 %s, line %d %s \n" , host , i , line );
890+ continue ;
891+ }
892+
882893 if (av_strcasecmp (protocol , "udp" )) {
883894 av_log (whip , AV_LOG_ERROR , "WHIP: Protocol %s is not supported by RTC, choose udp, line %d %s of %s\n" ,
884895 protocol , i , line , whip -> sdp_answer );
@@ -1891,7 +1902,9 @@ static const AVOption options[] = {
18911902 { "pkt_size" , "The maximum size, in bytes, of RTP packets that send out" , OFFSET (pkt_size ), AV_OPT_TYPE_INT , { .i64 = 1200 }, -1 , INT_MAX , DEC },
18921903 { "authorization" , "The optional Bearer token for WHIP Authorization" , OFFSET (authorization ), AV_OPT_TYPE_STRING , { .str = NULL }, 0 , 0 , DEC },
18931904 { "cert_file" , "The optional certificate file path for DTLS" , OFFSET (cert_file ), AV_OPT_TYPE_STRING , { .str = NULL }, 0 , 0 , DEC },
1894- { "key_file" , "The optional private key file path for DTLS" , OFFSET (key_file ), AV_OPT_TYPE_STRING , { .str = NULL }, 0 , 0 , DEC },
1905+ { "key_file" , "The optional private key file path for DTLS" , OFFSET (key_file ), AV_OPT_TYPE_STRING , { .str = NULL }, 0 , 0 , DEC },
1906+ { "whip_flags" , "set flags affecting WHIP connection behavior" , OFFSET (flags ), AV_OPT_TYPE_FLAGS , { .i64 = 0 }, 0 , UINT_MAX , DEC , .unit = "flags" },
1907+ { "ignore_ipv6" , "ignore any IPv6 ICE candidate" , 0 , AV_OPT_TYPE_CONST , { .i64 = WHIP_FLAG_IGNORE_IPV6 }, 0 , UINT_MAX , DEC , .unit = "flags" },
18951908 { NULL },
18961909};
18971910
0 commit comments