Skip to content

Commit

Permalink
Set the RTP recv/send buffer to a bigger size.
Browse files Browse the repository at this point in the history
  • Loading branch information
buendiya authored and jlaine committed Mar 27, 2022
1 parent b541ccd commit f08956b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/aioice/ice.py
Original file line number Diff line number Diff line change
Expand Up @@ -854,9 +854,14 @@ async def get_component_candidates(
for address in addresses:
# create transport
try:
_, protocol = await loop.create_datagram_endpoint(
transport, protocol = await loop.create_datagram_endpoint(
lambda: StunProtocol(self), local_addr=(address, 0)
)
sock = transport.get_extra_info("socket")
if sock is not None:
sock.setsockopt(
socket.SOL_SOCKET, socket.SO_RCVBUF, turn.UDP_SOCKET_BUFFER_SIZE
)
except OSError as exc:
self.__log_info("Could not bind to %s - %s", address, exc)
continue
Expand Down
5 changes: 5 additions & 0 deletions src/aioice/turn.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import asyncio
import hashlib
import logging
import socket
import struct
import time
from typing import Any, Callable, Dict, List, Optional, Text, Tuple, Union, cast
Expand All @@ -14,6 +15,7 @@
DEFAULT_ALLOCATION_LIFETIME = 600
TCP_TRANSPORT = 0x06000000
UDP_TRANSPORT = 0x11000000
UDP_SOCKET_BUFFER_SIZE = 262144


def is_channel_data(data: bytes) -> bool:
Expand Down Expand Up @@ -406,6 +408,9 @@ async def create_turn_endpoint(
),
remote_addr=server_addr,
)
sock = inner_transport.get_extra_info("socket")
if sock is not None:
sock.setsockopt(socket.SOL_SOCKET, socket.SO_RCVBUF, UDP_SOCKET_BUFFER_SIZE)

try:
protocol = protocol_factory()
Expand Down

0 comments on commit f08956b

Please sign in to comment.