diff --git a/setup.py b/setup.py index 71027c7ae..bcfdf2716 100644 --- a/setup.py +++ b/setup.py @@ -21,9 +21,9 @@ "aioice>=0.7.5,<0.8.0", "av>=8.0.0,<9.0.0", "cffi>=1.0.0", - "crc32c>=2.1", "cryptography>=2.2", 'dataclasses; python_version < "3.7"', + "google-crc32c>=1.1", "pyee>=6.0.0", "pylibsrtp>=0.5.6", ] diff --git a/src/aiortc/rtcsctptransport.py b/src/aiortc/rtcsctptransport.py index dc0033fc1..e4a638b91 100644 --- a/src/aiortc/rtcsctptransport.py +++ b/src/aiortc/rtcsctptransport.py @@ -22,7 +22,12 @@ no_type_check, ) -from crc32c import crc32c +# The `crc32c` package offers better performance but uses an LGPL license, +# so we use `google-crc32c` by default. +try: + from crc32c import crc32c +except ImportError: + from google_crc32c import value as crc32c from pyee import AsyncIOEventEmitter from .exceptions import InvalidStateError diff --git a/stubs/google_crc32c.pyi b/stubs/google_crc32c.pyi new file mode 100644 index 000000000..1366f064e --- /dev/null +++ b/stubs/google_crc32c.pyi @@ -0,0 +1 @@ +def value(data: bytes) -> int: ...