Registry / http-networking / rtp
library0.0.4pypypi✓ verified 87d ago

The `rtp` library is a Python library for decoding, encoding, and interacting with Real-time Transport Protocol (RTP) packets. Currently at version 0.0.4, it is under active development by BBC R&D. This library is designed to be payload-agnostic and does not provide network functionality or handle specific payload bitstreams; it is intended to be used in conjunction with other libraries for those purposes.

pip install rtp
INSTALL
IMPORT
SIG · RTP
R
rtp
http-networkingpythonv0.0.4
Install
1.6s avg
Import
18ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
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
musl
py 3.103.920 runs
installs and imports cleanly · install 0.0s · import 0.019s · 17.9MB
glibc
py 3.103.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.

RTP
from rtp import RTP
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}")
Debug
Known issues
gotchaThis library explicitly handles only RTP packet encoding/decoding and does NOT provide any network functionality (like sending over UDP) or specific payload handling. Users need to implement or integrate with other libraries for these aspects.
fix
Ensure you have separate components for network transport (e.g., `socket` module) and specific payload type encoding/decoding (e.g., `rtpPayload-ttml`).
affects: 0.0.1 - 0.0.4
breakingAs a library in early development (version 0.0.4), expect potential breaking changes in minor versions (0.x.x) as the API matures. Always review release notes when upgrading.
fix
Consult the GitHub repository's release notes or changelog for specific breaking changes before upgrading. Pin exact versions in your `requirements.txt`.
affects: < 1.0.0
gotchaThe quickstart examples and common usage patterns require helper functions (e.g., `getExtStartBits`, `getExtBody`, `getCSRCList`, `getNextPayload`) that are not part of the `rtp` library itself. Users must provide these based on their specific RTP implementation needs.
fix
Implement the necessary helper functions to generate extension headers, CSRC lists, and actual payload data according to your RTP stream specifications.
affects: 0.0.1 - 0.0.4
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'rtp'
The 'rtp' library is not installed in the current Python environment.
fix
Run `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).
fix
Use `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.
fix
Ensure 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.

Agent activity
22 hits · last 30 days
node
18
Amazon
1
OpenAI (training)
1
Resources
rtp — pip install rtp · libregistry