Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
self.assertEqual(d.host, "1.2.3.4")
self.assertEqual(d.name, "FreeSWITCH")
self.assertEqual(d.origin, "FreeSWITCH 1538380016 1538380017 IN IP4 1.2.3.4")
self.assertEqual(d.time, "0 0")
self.assertEqual(d.version, 0)
self.assertEqual(len(d.media), 1)
self.assertEqual(d.media[0].kind, "audio")
self.assertEqual(d.media[0].host, None)
self.assertEqual(d.media[0].port, 16628)
self.assertEqual(d.media[0].profile, "UDP/TLS/RTP/SAVPF")
self.assertEqual(d.media[0].direction, None)
self.assertEqual(
d.media[0].rtp.codecs,
[
RTCRtpCodecParameters(
mimeType="audio/PCMA", clockRate=8000, channels=1, payloadType=8
),
RTCRtpCodecParameters(
mimeType="audio/telephone-event",
clockRate=8000,
channels=1,
payloadType=101,
),
],
)
self.assertEqual(d.media[0].rtp.headerExtensions, [])
self.assertEqual(d.media[0].rtp.muxId, "")
self.assertEqual(d.media[0].rtcp_host, "1.2.3.4")
self.assertEqual(d.media[0].rtcp_port, 16628)
self.assertEqual(d.media[0].rtcp_mux, True)
parameters={
"maxplaybackrate": 48000,
"stereo": 1,
"useinbandfec": 1,
},
),
RTCRtpCodecParameters(
mimeType="audio/G722", clockRate=8000, channels=1, payloadType=9
),
RTCRtpCodecParameters(
mimeType="audio/PCMU", clockRate=8000, channels=1, payloadType=0
),
RTCRtpCodecParameters(
mimeType="audio/PCMA", clockRate=8000, channels=1, payloadType=8
),
RTCRtpCodecParameters(
mimeType="audio/telephone-event",
clockRate=8000,
channels=1,
payloadType=101,
parameters={"0-15": None},
),
],
)
self.assertEqual(
d.media[0].rtp.headerExtensions,
[
RTCRtpHeaderExtensionParameters(
id=1, uri="urn:ietf:params:rtp-hdrext:ssrc-audio-level"
),
RTCRtpHeaderExtensionParameters(
id=2, uri="urn:ietf:params:rtp-hdrext:sdes:mid"
import fractions
from unittest import TestCase
from aiortc.codecs import get_decoder, get_encoder
from aiortc.codecs.vpx import (
Vp8Decoder,
Vp8Encoder,
VpxPayloadDescriptor,
_vpx_assert,
number_of_threads,
)
from aiortc.rtcrtpparameters import RTCRtpCodecParameters
from .codecs import CodecTestCase
VP8_CODEC = RTCRtpCodecParameters(
mimeType="video/VP8", clockRate=90000, payloadType=100
)
class VpxPayloadDescriptorTest(TestCase):
def test_no_picture_id(self):
descr, rest = VpxPayloadDescriptor.parse(b"\x10")
self.assertEqual(descr.partition_start, 1)
self.assertEqual(descr.partition_id, 0)
self.assertEqual(descr.picture_id, None)
self.assertEqual(descr.tl0picidx, None)
self.assertEqual(descr.tid, None)
self.assertEqual(descr.keyidx, None)
self.assertEqual(bytes(descr), b"\x10")
self.assertEqual(repr(descr), "VpxPayloadDescriptor(S=1, PID=0, pic_id=None)")
RTCRtpCodecParameters(
mimeType="audio/PCMU", clockRate=8000, payloadType=0
)
],
encodings=[RTCRtpDecodingParameters(ssrc=1831097322, payloadType=0)],
),
)
certificate2 = RTCCertificate.generateCertificate()
session2 = RTCDtlsTransport(transport2, [certificate2])
receiver2 = DummyRtpReceiver()
session2._register_rtp_receiver(
receiver2,
RTCRtpReceiveParameters(
codecs=[
RTCRtpCodecParameters(
mimeType="audio/PCMU", clockRate=8000, payloadType=0
)
],
encodings=[RTCRtpDecodingParameters(ssrc=4028317929, payloadType=0)],
),
)
run(
asyncio.gather(
session1.start(session2.getLocalParameters()),
session2.start(session1.getLocalParameters()),
)
)
# send same RTP twice, to trigger error on the receiver side:
# "replay check failed (bad index)"
def test_common_rtx(self):
local_codecs = [
RTCRtpCodecParameters(mimeType='video/VP8', clockRate=90000, payloadType=100),
RTCRtpCodecParameters(mimeType='video/rtx', clockRate=90000, payloadType=101,
parameters={'apt': 100}),
]
remote_codecs = [
RTCRtpCodecParameters(mimeType='video/VP8', clockRate=90000, payloadType=96),
RTCRtpCodecParameters(mimeType='video/rtx', clockRate=90000, payloadType=97,
parameters={'apt': 96}),
RTCRtpCodecParameters(mimeType='video/VP9', clockRate=90000, payloadType=98),
RTCRtpCodecParameters(mimeType='video/rtx', clockRate=90000, payloadType=99,
parameters={'apt': 98}),
]
common = find_common_codecs(local_codecs, remote_codecs)
self.assertEqual(common, [
RTCRtpCodecParameters(mimeType='video/VP8', clockRate=90000, payloadType=96),
RTCRtpCodecParameters(mimeType='video/rtx', clockRate=90000, payloadType=97,
parameters={'apt': 96}),
])
self.assertEqual(d.time, "0 0")
self.assertEqual(d.version, 0)
self.assertEqual(len(d.media), 1)
self.assertEqual(d.media[0].kind, "audio")
self.assertEqual(d.media[0].host, None)
self.assertEqual(d.media[0].port, 16628)
self.assertEqual(d.media[0].profile, "UDP/TLS/RTP/SAVPF")
self.assertEqual(d.media[0].direction, None)
self.assertEqual(
d.media[0].rtp.codecs,
[
RTCRtpCodecParameters(
mimeType="audio/PCMA", clockRate=8000, channels=1, payloadType=8
),
RTCRtpCodecParameters(
mimeType="audio/telephone-event",
clockRate=8000,
channels=1,
payloadType=101,
),
],
)
self.assertEqual(d.media[0].rtp.headerExtensions, [])
self.assertEqual(d.media[0].rtp.muxId, "")
self.assertEqual(d.media[0].rtcp_host, "1.2.3.4")
self.assertEqual(d.media[0].rtcp_port, 16628)
self.assertEqual(d.media[0].rtcp_mux, True)
# ssrc
self.assertEqual(
d.media[0].ssrc,
payloadType=96,
rtcpFeedback=[
RTCRtcpFeedback(type="goog-remb"),
RTCRtcpFeedback(type="transport-cc"),
RTCRtcpFeedback(type="ccm", parameter="fir"),
RTCRtcpFeedback(type="nack"),
RTCRtcpFeedback(type="nack", parameter="pli"),
],
),
RTCRtpCodecParameters(
mimeType="video/rtx",
clockRate=90000,
payloadType=97,
parameters={"apt": 96},
),
RTCRtpCodecParameters(
mimeType="video/VP9",
clockRate=90000,
payloadType=98,
rtcpFeedback=[
RTCRtcpFeedback(type="goog-remb"),
RTCRtcpFeedback(type="transport-cc"),
RTCRtcpFeedback(type="ccm", parameter="fir"),
RTCRtcpFeedback(type="nack"),
RTCRtcpFeedback(type="nack", parameter="pli"),
],
),
RTCRtpCodecParameters(
mimeType="video/rtx",
clockRate=90000,
payloadType=99,
parameters={"apt": 98},
def test_common_feedback(self):
local_codecs = [
RTCRtpCodecParameters(
mimeType='video/VP8',
clockRate=90000,
payloadType=100,
rtcpFeedback=[
RTCRtcpFeedback(type='nack'),
RTCRtcpFeedback(type='nack', parameter='pli'),
]
)
]
remote_codecs = [
RTCRtpCodecParameters(
mimeType='video/VP8',
clockRate=90000,
payloadType=120,
rtcpFeedback=[
RTCRtcpFeedback(type='nack'),
RTCRtcpFeedback(type='nack', parameter='sli'),
]
)
]
common = find_common_codecs(local_codecs, remote_codecs)
self.assertEqual(len(common), 1)
self.assertEqual(common[0].clockRate, 90000)
self.assertEqual(common[0].name, 'VP8')
self.assertEqual(common[0].payloadType, 120)
self.assertEqual(common[0].rtcpFeedback, [
RTCRtcpFeedback(type='nack'),
rtcpFeedback=[RTCRtcpFeedback(type="transport-cc")],
parameters={"minptime": 10, "useinbandfec": 1},
),
RTCRtpCodecParameters(
mimeType="audio/ISAC", clockRate=16000, channels=1, payloadType=103
),
RTCRtpCodecParameters(
mimeType="audio/ISAC", clockRate=32000, channels=1, payloadType=104
),
RTCRtpCodecParameters(
mimeType="audio/G722", clockRate=8000, channels=1, payloadType=9
),
RTCRtpCodecParameters(
mimeType="audio/PCMU", clockRate=8000, channels=1, payloadType=0
),
RTCRtpCodecParameters(
mimeType="audio/PCMA", clockRate=8000, channels=1, payloadType=8
),
RTCRtpCodecParameters(
mimeType="audio/CN", clockRate=32000, channels=1, payloadType=106
),
RTCRtpCodecParameters(
mimeType="audio/CN", clockRate=16000, channels=1, payloadType=105
),
RTCRtpCodecParameters(
mimeType="audio/CN", clockRate=8000, channels=1, payloadType=13
),
RTCRtpCodecParameters(
mimeType="audio/telephone-event",
clockRate=48000,
channels=1,
payloadType=110,
payloadType=97,
parameters={"apt": 96},
),
RTCRtpCodecParameters(
mimeType="video/VP9",
clockRate=90000,
payloadType=98,
rtcpFeedback=[
RTCRtcpFeedback(type="goog-remb"),
RTCRtcpFeedback(type="transport-cc"),
RTCRtcpFeedback(type="ccm", parameter="fir"),
RTCRtcpFeedback(type="nack"),
RTCRtcpFeedback(type="nack", parameter="pli"),
],
),
RTCRtpCodecParameters(
mimeType="video/rtx",
clockRate=90000,
payloadType=99,
parameters={"apt": 98},
),
RTCRtpCodecParameters(
mimeType="video/red", clockRate=90000, payloadType=100
),
RTCRtpCodecParameters(
mimeType="video/rtx",
clockRate=90000,
payloadType=101,
parameters={"apt": 100},
),
RTCRtpCodecParameters(
mimeType="video/ulpfec", clockRate=90000, payloadType=102