Skip to content

feat(rtsp): Clean up RTSP code (improve JPEG header impl) and expose to xplat python and c++ library; Add python examples using espp.RtspClient and espp.RtspServer#487

Merged
finger563 merged 9 commits intomainfrom
feat/rtsp-exposed-to-lib
Aug 12, 2025

Conversation

@finger563
Copy link
Copy Markdown
Contributor

@finger563 finger563 commented Aug 12, 2025

Description

  • Update rtsp component so that it can be bound with pybind11 and used from python - this required changing some of the internal JPEG APIs to use std::span instead of std::string_view
  • Add a converter for pybind11 to convert std::span to / from python lists (using std::vector)
  • Add constructors for espp::Task to make it easier to use / wrap from within python - since python cannot use the std::mutex / std::condition_variable callback signatures
  • Add new python examples for espp::RtspClient and espp::RtspServer
  • Update existing python examples to match updated APIs

Motivation and Context

  • More RTSP example code is always useful
  • I want to be able to stream my desktop to my little devices (such as the mini-computer BYTE90)
  • I want more jpeg-agnostic support (less hard-coded to timer cam output), so that it supports other jpeg encoders and sources

How has this been tested?

  • Build and run changed code within camera-streamer example
  • Build and run changed code within camera-display example
  • Build the shared library lib/
  • Run the new python examples

Screenshots (if appropriate, e.g. schematic, board, console logs, lab pictures):

RTSP Client (espp/camera-display updated with this code):

rtsp-display-screen.mp4

RTSP Client (Python):

CleanShot 2025-08-12 at 08 53 55 CleanShot 2025-08-12 at 08 54 57

RTSP Server (Python):

CleanShot 2025-08-12 at 08 54 24

Timer and Task (Python):

CleanShot 2025-08-12 at 08 55 39

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Hardware (schematic, board, system design) change
  • Software change

Checklist:

  • My change requires a change to the documentation.
  • I have added / updated the documentation related to this change via either README or WIKI

Software

  • I have added tests to cover my changes.
  • I have updated the .github/workflows/build.yml file to add my new test to the automated cloud build github action.
  • All new and existing tests passed.
  • My code follows the code style of this project.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Aug 12, 2025

✅Static analysis result - no issues found! ✅

@finger563 finger563 requested a review from Copilot August 12, 2025 12:09
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the RTSP component to support Python bindings by transitioning internal JPEG APIs from std::string_view to std::span<const uint8_t>, implements a new span caster for pybind11, and adds comprehensive Python examples for both RTSP client and server functionality.

  • Migrated JPEG-related APIs from std::string_view to std::span<const uint8_t> for better type safety
  • Added Python bindings for RTSP classes with span converter support
  • Updated existing Python examples to use simplified Task constructor patterns

Reviewed Changes

Copilot reviewed 25 out of 26 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
lib/python_bindings/span_caster.h Implements pybind11 type converters for std::span to/from Python types
lib/python_bindings/pybind_espp.cpp Adds Python bindings for RTSP classes and updates constructor patterns
python/rtsp_server.py New RTSP server example with display/webcam capture and mDNS advertising
python/rtsp_client.py New RTSP client example with mDNS discovery and OpenCV display
components/task/include/task.hpp Adds convenience constructors for Task class
components/socket/ Adds std::span overloads for TCP/UDP socket transmit methods
components/rtsp/ Refactors JPEG APIs to use std::span instead of std::string_view
Comments suppressed due to low confidence (1)

Comment thread lib/python_bindings/span_caster.h
Comment thread components/rtsp/include/rtp_jpeg_packet.hpp
Comment thread python/rtsp_server.py Outdated
Comment thread python/rtsp_client.py Outdated
Comment thread components/rtsp/include/jpeg_header.hpp
Comment thread components/rtsp/include/jpeg_header.hpp
@finger563 finger563 self-assigned this Aug 12, 2025
@finger563 finger563 added enhancement New feature or request rtsp python labels Aug 12, 2025
@finger563 finger563 added tasks xplat cross platform support lib library for use with other systems / languages c++ labels Aug 12, 2025
@finger563 finger563 merged commit 508cf33 into main Aug 12, 2025
92 of 93 checks passed
@finger563 finger563 deleted the feat/rtsp-exposed-to-lib branch August 12, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

c++ enhancement New feature or request lib library for use with other systems / languages python rtsp tasks xplat cross platform support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants