LiveKit C++ SDK
Real-time audio/video 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
24namespace livekit {
25
26class VideoFrame;
27
33enum class VideoRotation {
34 VIDEO_ROTATION_0 = 0,
35 VIDEO_ROTATION_90 = 90,
36 VIDEO_ROTATION_180 = 180,
37 VIDEO_ROTATION_270 = 270,
38};
39
47 std::optional<std::uint64_t> user_timestamp_us;
48 std::optional<std::uint32_t> frame_id;
49};
50
55 std::int64_t timestamp_us = 0;
56 VideoRotation rotation = VideoRotation::VIDEO_ROTATION_0;
57 // Populate meta data when you want to send user timestamps or frame IDs.
58 std::optional<VideoFrameMetadata> metadata;
59};
60
66public:
76 VideoSource(int width, int height);
77 virtual ~VideoSource() = default;
78
79 VideoSource(const VideoSource &) = delete;
80 VideoSource &operator=(const VideoSource &) = delete;
81 VideoSource(VideoSource &&) noexcept = default;
82 VideoSource &operator=(VideoSource &&) noexcept = default;
83
85 int width() const noexcept { return width_; }
86 int height() const noexcept { return height_; }
87
89 std::uint64_t ffi_handle_id() const noexcept { return handle_.get(); }
90
97 void captureFrame(const VideoFrame &frame,
98 const VideoCaptureOptions &options);
99
103 void captureFrame(const VideoFrame &frame, std::int64_t timestamp_us = 0,
104 VideoRotation rotation = VideoRotation::VIDEO_ROTATION_0);
105
106private:
107 FfiHandle handle_; // owned FFI handle
108 int width_{0};
109 int height_{0};
110};
111
112} // namespace livekit
RAII wrapper for an FFI handle (uintptr_t) coming from Rust.
Definition ffi_handle.h:29
Definition video_frame.h:59
Definition video_source.h:65
void captureFrame(const VideoFrame &frame, const VideoCaptureOptions &options)
int width() const noexcept
Source resolution as declared at construction.
Definition video_source.h:85
VideoSource(int width, int height)
void captureFrame(const VideoFrame &frame, std::int64_t timestamp_us=0, VideoRotation rotation=VideoRotation::VIDEO_ROTATION_0)
std::uint64_t ffi_handle_id() const noexcept
Underlying FFI handle ID (0 if invalid).
Definition video_source.h:89
Definition video_source.h:54
Definition video_source.h:46