This folder contains some test python scripts for loading the espp shared
objects built within the espp/lib folder into Python.
Table of Contents
This section gives a brief overview of what the scripts in this folder do.
task.py: This script is a simple example of how to use theespplibrary to create a task. It demonstrates how to create a task, run it, and handle its results. Note: unlike python multithreading, this task is actually run in a separate thread.timer.py: This script demonstrates how to use theespplibrary to create a timer. It shows how to create a timer, start it, and handle its expiration. The timer runs in a separate thread and calls a callback function when it expires. Note: unlike python multithreading, this timer is actually run in a separate thread.udp_client.pyandudp_server.py: These scripts demonstrate how to use theespplibrary to create a UDP client and server. The server listens for incoming UDP packets and prints them to the console, while the client sends UDP packets to the server.rtsp_client.pyandrtsp_server.py: These scripts demonstrate how to use theespplibrary to create an RTSP client and server. The server streams MJPEG video from a webcam or display capture. The camera path captures live microphone audio by default, while display capture keeps the simulated audio tone unless--audio-source microphoneis selected. The client receives the stream, validates audio delivery, plays the audio in real time, and displays the video in a window. Note: these scripts require additional 3rd party libraries such asopencv,mss,zeroconf, andsounddevice.rtsp_client_multitrack.pyandrtsp_server_multitrack.py: These scripts exercise the generic multitrack RTSP APIs. The multitrack server includes audio by default; camera mode uses live microphone capture and the other video sources use the simulated tone unless--audio-source microphoneis selected. Pass--no-audioto disable the audio track. The multitrack client plays audio by default when running with a UI; use--no-audio-playbackto disable it or--play-audio --headlessto exercise playback without opening the video window.cobs_demo.py: Demonstration of ESPP COBS functionality with native Python data types. Shows ESPP encoding/decoding, cross-library compatibility with the cobs-python library, and practical usage examples. Includes design differences explanation and validation against the reference implementation.
Important Design Differences: The ESPP COBS implementation differs from other COBS libraries:
- Delimiters: ESPP automatically adds
0x00delimiters to encoded packets, while other libraries may not - Empty Packets: ESPP ignores empty packets (length = 0) for performance, while other libraries may encode them
- Compatibility: The demo scripts show how to handle these differences for cross-library integration
For all scripts, you must have the espp shared objects built and the required Python dependencies installed:
pip install -r requirements.txtNote: The COBS demo script (cobs_demo.py) requires the cobs library for cross-validation with the reference implementation.
accessible in the espp/lib folder. See the espp/lib
README for more details.
Some tests (e.g. rtsp_client.py, rtsp_server.py) make use of 3rd party
libraries such as zeroconf, opencv, mss, sounddevice to facilitate mDNS
discovery, image display / webcam capture, display capture, and audio
playback. For these tests, you will need to install the requirements.txt:
# create the virtual environment
python3 -m venv env
# activate it
source env/bin/activate
# install the requirements
pip install -r requirements.txtAfterwards, you only need to source the environment and run the test in question:
source env/bin/activate
# now you can run the tests
python3 rtsp_server.pyTo run a test, you can use the following commands:
python3 <test_name>.py
# e.g.
python3 task.py
# or
python3 udp_client.pyNote: the udp_client.py script requires a running instance of the
udp_server.py script. To run the server, use the following command from
another terminal:
python3 udp_server.py