LiveKit C++ Client SDK v1.1.0
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
video_source.h
1/*
2 * Copyright 2025 LiveKit
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an “AS IS” BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#pragma once
18
19#include <cstdint>
20#include <optional>
21
22#include "livekit/ffi_handle.h"
23#include "livekit/visibility.h"
24
25namespace livekit {
26
27class VideoFrame;
28
32enum class VideoRotation {
33 VIDEO_ROTATION_0 = 0,
34 VIDEO_ROTATION_90 = 90,
35 VIDEO_ROTATION_180 = 180,
36 VIDEO_ROTATION_270 = 270,
37};
38
44 std::optional<std::uint64_t> user_timestamp_us;
45 std::optional<std::uint32_t> frame_id;
46};
47
50 std::int64_t timestamp_us = 0;
51 VideoRotation rotation = VideoRotation::VIDEO_ROTATION_0;
53 std::optional<VideoFrameMetadata> metadata;
54};
55
58class LIVEKIT_API VideoSource {
59public:
67 VideoSource(int width, int height);
68 virtual ~VideoSource() = default;
69
70 VideoSource(const VideoSource&) = delete;
71 VideoSource& operator=(const VideoSource&) = delete;
72 VideoSource(VideoSource&&) noexcept = default;
73 VideoSource& operator=(VideoSource&&) noexcept = default;
74
76 int width() const noexcept { return width_; }
77 int height() const noexcept { return height_; }
78
80 std::uint64_t ffiHandleId() const noexcept { return handle_.get(); }
81
86 void captureFrame(const VideoFrame& frame, const VideoCaptureOptions& options);
87
89 void captureFrame(const VideoFrame& frame, std::int64_t timestamp_us = 0,
90 VideoRotation rotation = VideoRotation::VIDEO_ROTATION_0);
91
92private:
93 FfiHandle handle_; // owned FFI handle
94 int width_{0};
95 int height_{0};
96};
97
98} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
Public SDK representation of a video frame.
Definition video_frame.h:48
Represents a real-time video source that can accept frames from the application and feed them into th...
Definition video_source.h:58
void captureFrame(const VideoFrame &frame, const VideoCaptureOptions &options)
Push a VideoFrame into the FFI video source.
std::uint64_t ffiHandleId() const noexcept
Underlying FFI handle ID (0 if invalid).
Definition video_source.h:80
VideoSource(int width, int height)
Create a new native video source with a fixed resolution.
void captureFrame(const VideoFrame &frame, std::int64_t timestamp_us=0, VideoRotation rotation=VideoRotation::VIDEO_ROTATION_0)
Backward-compatible convenience overload for timestamp + rotation only.
Public API for the LiveKit C++ Client SDK.
Definition audio_frame.h:25
VideoRotation
Rotation of a video frame.
Definition video_source.h:32
Capture options for a single outbound video frame.
Definition video_source.h:49
std::optional< VideoFrameMetadata > metadata
Populate meta data when you want to send user timestamps or frame IDs.
Definition video_source.h:53
Optional packet-trailer metadata carried alongside a video frame.
Definition video_source.h:43