19#include "livekit/build.h"
22#if !LIVEKIT_CAPTURE_ENABLED && !defined(LIVEKIT_BUILDING_SDK)
23#error "Capture sources require a capture-enabled LiveKit SDK; rebuild with --capture."
32#include "livekit/result.h"
33#include "livekit/room_event_types.h"
34#include "livekit/video_source.h"
35#include "livekit/visibility.h"
42class OwnedCaptureSource;
68 std::uint32_t width = 0;
69 std::uint32_t height = 0;
95 std::optional<VideoCodec>
codec;
258 int width() const noexcept;
262 int height() const noexcept;
314 [[nodiscard]] std::future<Result<CaptureResult, CaptureError>>
join();
317 friend class livekit::FfiClient;
325 static std::shared_ptr<CaptureSource> fromOwned(
const proto::OwnedCaptureSource& owned);
328 std::unique_ptr<Impl> impl_;
Lightweight success-or-error return type for non-exceptional API failures.
Definition result.h:40
Represents a real-time video source that can accept frames from the application and feed them into th...
Definition video_source.h:65
A server-side capture source (livekit-capture) that produces video without per-frame FFI traffic.
Definition capture_source.h:194
static std::future< Result< std::shared_ptr< CaptureSource >, CaptureError > > create(const GstreamerVideoSourceConfig &config)
Create a capture source from a GStreamer pipeline configuration.
Result< void, CaptureError > start()
Start pumping frames into the RTC video source.
Result< void, CaptureError > stop()
Signal a running capture to stop after the frame in flight.
CaptureSourceKind kind() const noexcept
Kind of media this source produces.
std::future< Result< CaptureResult, CaptureError > > join()
Consume the running pump and wait asynchronously for it to exit.
static std::future< Result< std::shared_ptr< CaptureSource >, CaptureError > > create(ClockVideoSourceConfig config)
Create the built-in wall clock capture source.
static std::future< Result< std::shared_ptr< CaptureSource >, CaptureError > > create(PatternVideoSourceConfig config)
Create the built-in test pattern capture source.
Capture sources and their configuration types.
Definition capture_source.h:48
GstreamerBitrateUnit
Bitrate unit expected by a GStreamer encoder property.
Definition capture_source.h:59
@ Kbps
Kilobits per second.
CaptureSourceKind
Kind of media a capture source produces.
Definition capture_source.h:51
@ Pixel
Pixel frames, published through the WebRTC encoder.
@ Encoded
Pre-encoded access units, published as passthrough.
Pattern
Test pattern rendered by the built-in pattern source.
Definition capture_source.h:108
@ Gradient
Animated color gradient.
@ Logo
Bouncing LiveKit logo.
CaptureErrorKind
Terminal pump failure category; matches the FFI CaptureErrorKind enum.
Definition capture_source.h:146
@ Panicked
The pump thread panicked.
@ Rtc
The RTC video source rejected a frame.
@ Source
The capture source failed or violated its contract.
CaptureExit
Why a capture ended without error.
Definition capture_source.h:138
@ Stopped
Stopped via CaptureSource::stop (or source destruction).
@ EndOfStream
The producer reached the end of its stream.
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
VideoCodec
Codec used to publish a video track.
Definition video_codec.h:22
Options for publishing a track to the room.
Definition room_event_types.h:343
Structured terminal pump failure reported by the Rust FFI.
Definition capture_source.h:156
CaptureErrorKind kind
Error category.
Definition capture_source.h:161
std::string message
Human-readable error message.
Definition capture_source.h:158
Video resolution in pixels.
Definition capture_source.h:67
Successful terminal statistics of a started capture.
Definition capture_source.h:165
CaptureExit exit
Why the capture ended successfully.
Definition capture_source.h:170
std::uint64_t frames_captured
Number of frames or access units captured.
Definition capture_source.h:167
Wall clock with millisecond precision, rendered on the GPU.
Definition capture_source.h:129
CaptureResolution resolution
Output resolution; both components must be positive.
Definition capture_source.h:131
std::uint32_t framerate_fps
Output frame rate in frames per second; must be non-zero.
Definition capture_source.h:134
Binding from WebRTC rate-control targets to a GStreamer encoder property.
Definition capture_source.h:73
std::string element
Name of the encoder element in the pipeline (e.g. lk_encoder).
Definition capture_source.h:75
GstreamerBitrateUnit unit
Unit the property expects.
Definition capture_source.h:82
std::string property
Bitrate property to set on the element (e.g.
Definition capture_source.h:79
Configuration for encoded ingest from a GStreamer pipeline.
Definition capture_source.h:86
std::optional< VideoCodec > codec
Codec expected from the pipeline; inferred from pipeline caps when omitted.
Definition capture_source.h:95
std::optional< GstreamerRateControl > rate_control
Forwards WebRTC rate-control targets to an encoder element's bitrate property.
Definition capture_source.h:104
std::optional< CaptureResolution > resolution
Encoded frame resolution.
Definition capture_source.h:100
std::string pipeline
GStreamer launch description for the encoded producer pipeline.
Definition capture_source.h:91
Configuration for the built-in test source rendering a Pattern.
Definition capture_source.h:116
std::uint32_t framerate_fps
Output frame rate in frames per second; must be non-zero.
Definition capture_source.h:121
CaptureResolution resolution
Output resolution; both components must be positive.
Definition capture_source.h:118
Pattern pattern
Pattern to render.
Definition capture_source.h:124