LiveKit C++ Client SDK v1.12.2
Real-time audio/video/data SDK for C++
Loading...
Searching...
No Matches
encoded_video_source.h
1/*
2 * Copyright 2026 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#include <vector>
22
23#include "livekit/video_codec.h"
24#include "livekit/video_source.h"
25#include "livekit/visibility.h"
26
27namespace livekit {
28
34class LIVEKIT_API EncodedVideoSource final : public VideoSource {
35public:
37 struct Frame {
39 bool is_keyframe = false;
42 std::uint32_t width = 0;
45 std::uint32_t height = 0;
47 std::int64_t timestamp_us = 0;
49 std::vector<std::uint8_t> data;
51 std::optional<VideoFrameMetadata> metadata;
52 };
53
55 struct RateControl {
57 std::uint64_t target_bitrate_bps = 0;
59 double framerate_fps = 0.0;
60 };
61
63 struct Feedback {
65 bool keyframe_requested = false;
67 std::optional<RateControl> rate_control;
68 };
69
77 EncodedVideoSource(VideoCodec codec, int width, int height);
78
80 VideoCodec codec() const noexcept { return codec_; }
81
88 [[nodiscard]] bool captureFrame(const Frame& frame) const;
89
94 [[nodiscard]] Feedback takeFeedback() const;
95
96private:
97 using VideoSource::captureFrame;
98
99 VideoCodec codec_;
100};
101
102} // namespace livekit
Video source for publishing pre-encoded access units without re-encoding.
Definition encoded_video_source.h:34
bool captureFrame(const Frame &frame) const
Submit one complete encoded access unit.
EncodedVideoSource(VideoCodec codec, int width, int height)
Create a pre-encoded source for one codec and initial resolution.
VideoCodec codec() const noexcept
Codec carried by every frame submitted to this source.
Definition encoded_video_source.h:80
Feedback takeFeedback() const
Consume pending keyframe and rate-control feedback.
Represents a real-time video source that can accept frames from the application and feed them into th...
Definition video_source.h:64
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
Pending feedback from the pre-encoded passthrough encoder.
Definition encoded_video_source.h:63
std::optional< RateControl > rate_control
Latest rate-control target, if the publishing pipeline requested one.
Definition encoded_video_source.h:67
One complete pre-encoded video access unit.
Definition encoded_video_source.h:37
std::vector< std::uint8_t > data
Complete encoded access-unit payload.
Definition encoded_video_source.h:49
std::optional< VideoFrameMetadata > metadata
Optional packet-trailer metadata.
Definition encoded_video_source.h:51
Latest encoder rate-control target requested by the publishing pipeline.
Definition encoded_video_source.h:55