Install & Compatibility
Where this runs
tested against v0.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.920 runs
installs and imports cleanly · install 0.0s · import 0.019s · 17.9MB
glibcpy 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.018s · 18MB
16MB installed
● package 16MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Extension
✓ from rtp import Extension
PayloadType
✓ from rtp import PayloadType
This quickstart demonstrates how to create and manipulate RTP packets. It includes examples for both encoding and decoding. Note that placeholder functions (e.g., `getExtStartBits`, `getNextPayload`) are used as the `rtp` library focuses solely on RTP packet structure, not on network transmission or specific payload content.
from rtp import RTP, Extension, PayloadType
from copy import deepcopy
# Placeholder functions for demonstration, as 'rtp' is payload-agnostic
def getExtStartBits(): return b'\x10\x00'
def getExtBody(): return b'\x01\x02\x03\x04'
def getCSRCList(): return [12345]
def getNextPayload(): return b'\xDE\xAD\xBE\xEF'
def transmit(rtp_packet): print(f"Transmitting: {rtp_packet.toBytearray().hex()}")
def getNextPacket(): return bytes.fromhex('80e000000000000000000000100001020304deadbeef')
def MyPayloadDecoder(payload_bytes): return f"Decoded payload: {payload_bytes.hex()}"
def render(decoded_data): print(f"Rendering: {decoded_data}")
# Encoding example
baseRTP = RTP(
marker=True,
payloadType=PayloadType.DYNAMIC_96, # Using a common dynamic payload type for example
extension=Extension(
startBits=getExtStartBits(),
headerExtension=getExtBody()
),
csrcList=getCSRCList()
)
# Initial packet
thisRTPBitstream = baseRTP.toBytearray()
print(f"Initial RTP Packet (hex): {thisRTPBitstream.hex()}")
# Example of sending subsequent packets (simplified loop)
nextRTP = deepcopy(baseRTP)
nextRTP.sequenceNumber += 1
nextRTP.timestamp += 160 # Example increment for timestamp
nextRTP.payload = getNextPayload()
transmit(nextRTP)
# Decoding example
decoded_rtp_packet = RTP().fromBytearray(getNextPacket())
decodedPayload = MyPayloadDecoder(decoded_rtp_packet.payload)
render(decodedPayload)
print(f"Decoded Sequence Number: {decoded_rtp_packet.sequenceNumber}")
print(f"Decoded Timestamp: {decoded_rtp_packet.timestamp}")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rtp'
The 'rtp' library is not installed in the current Python environment.
fixRun `pip install rtp` to install the library.
AttributeError: module 'rtp' has no attribute 'RTP'
Attempting to access the `RTP` class directly after a simple `import rtp` instead of `from rtp import RTP`, or a conflict with another library named 'rtp' (less likely for this specific library).
fixUse `from rtp import RTP` to directly import the class, or ensure you are not shadowing another module.
TypeError: 'bytes' object cannot be interpreted as an integer
This error or similar `TypeError` can occur when passing malformed byte data to `RTP.fromBytearray()`, or when attempting to use an incorrect type for a parameter during packet creation.
fixEnsure that the byte array passed to `fromBytearray()` represents a valid RTP packet, and that all parameters for `RTP()` constructor are of the expected types and formats.
Upgrade
Version history
0.0.4latest on PyPI · released Dec 5, 2023
Audit
Dependencies
No dependency data recorded yet.