Loading...
Searching...
No Matches
ml::ScreenSenderBase Class Reference

Captures this machine's desktop and publishes it as an H.264 RTSP stream (the sending counterpart to ScreenReceiver). More...

#include <Malena/Screen/ScreenSender.h>

Inheritance diagram for ml::ScreenSenderBase:
[legend]

Public Member Functions

 ScreenSenderBase (const char *name, const char *rtspUrl)
 ScreenSenderBase (const ScreenSenderBase &)=delete
virtual ~ScreenSenderBase ()
bool isPublishing () const
ScreenSenderBaseoperator= (const ScreenSenderBase &)=delete
const std::string & senderName () const
void setCaptureIndex (int index)
void setCaptureWindow (unsigned int windowId)
void setUrl (const std::string &rtspUrl)
void setWindowHelperPath (const std::string &path)
void start ()
void stop ()
const std::string & url () const

Detailed Description

Captures this machine's desktop and publishes it as an H.264 RTSP stream (the sending counterpart to ScreenReceiver).

Headless (no UI): it captures the screen with a platform-native GStreamer source, encodes with a platform-native non-GPL H.264 encoder, and pushes the stream to an RTSP server (e.g. MediaMTX on the Pi) via rtspclientsink. A Malena admin app constructs one of these to share its own desktop; the stream is then displayed by any ScreenReceiver pulling the same path.

capture → videoconvert → H.264 encode → h264parse → rtspclientsink(URL)

Encoders are chosen to keep the product distributable (no GPL/x264):

  • macOS : VideoToolbox (vtenc_h264) + avfvideosrc capture-screen
  • Windows : Media Foundation (mfh264enc) + d3d11screencapturesrc
  • Linux/Pi: V4L2 stateful HW encoder (v4l2h264enc) + ximagesrc

The pipeline runs on its own GStreamer threads with a background watcher that auto-reconnects (with backoff) if the RTSP server is not yet up or drops.

See also
ScreenReceiver

Definition at line 36 of file ScreenSender.h.

Constructor & Destructor Documentation

◆ ScreenSenderBase() [1/2]

ml::ScreenSenderBase::ScreenSenderBase ( const char * name,
const char * rtspUrl )
Parameters
nameHuman-readable label for logs/status.
rtspUrlPublish target, e.g. "rtsp://192.168.4.1:8554/admin".

◆ ~ScreenSenderBase()

virtual ml::ScreenSenderBase::~ScreenSenderBase ( )
virtual

◆ ScreenSenderBase() [2/2]

ml::ScreenSenderBase::ScreenSenderBase ( const ScreenSenderBase & )
delete

Member Function Documentation

◆ isPublishing()

bool ml::ScreenSenderBase::isPublishing ( ) const

True while the pipeline is live (PLAYING with no recent error).

◆ operator=()

ScreenSenderBase & ml::ScreenSenderBase::operator= ( const ScreenSenderBase & )
delete

◆ senderName()

const std::string & ml::ScreenSenderBase::senderName ( ) const

◆ setCaptureIndex()

void ml::ScreenSenderBase::setCaptureIndex ( int index)

Choose which display (monitor) to capture. macOS: avfvideosrc device-index; Windows: d3d11screencapturesrc monitor-index; Linux currently ignores it (whole primary screen). Restarts if running. Default 0 (primary display). Also selects whole-display capture mode (the default).

◆ setCaptureWindow()

void ml::ScreenSenderBase::setCaptureWindow ( unsigned int windowId)

Capture a single window instead of a whole display (macOS only). Streams via an external helper (set with setWindowHelperPath) that uses ScreenCaptureKit, since the built-in GStreamer screen sources can only grab a full display. If no helper is configured, falls back to whole-display capture. Restarts if running.

Parameters
windowIdNative window id (macOS CGWindowID / SCWindow.windowID).

◆ setUrl()

void ml::ScreenSenderBase::setUrl ( const std::string & rtspUrl)

Change the publish destination. Restarts the pipeline if running, so the caller can derive the URL at runtime (e.g. from a configured media host) rather than fixing it at construction. No-op if unchanged.

◆ setWindowHelperPath()

void ml::ScreenSenderBase::setWindowHelperPath ( const std::string & path)

Path to the per-window capture helper executable (e.g. LockInWindowCapture). Spawned with --window-id <id> --url <url> when in window-capture mode.

◆ start()

void ml::ScreenSenderBase::start ( )

Start (or restart) capturing + publishing. Non-blocking.

◆ stop()

void ml::ScreenSenderBase::stop ( )

Stop publishing and release the pipeline.

◆ url()

const std::string & ml::ScreenSenderBase::url ( ) const

The documentation for this class was generated from the following file: