BlueGit

ict rusty-teams

Files

rusty-teams / vendor / webrtc-sys / include / livekit / video_frame.h

video_frame.h

video_frame.h 1.9 KiB Download Raw
1/*
2 * Copyright 2025 LiveKit, Inc.
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 "api/video/video_frame.h"
20#include "livekit/video_frame_buffer.h"
21#include "rtc_base/checks.h"
22
23namespace livekit_ffi {
24class VideoFrame;
25class VideoFrameBuilder;
26} // namespace livekit_ffi
27#include "webrtc-sys/src/video_frame.rs.h"
28
29namespace livekit_ffi {
30
31class VideoFrame {
32 public:
33 explicit VideoFrame(const webrtc::VideoFrame& frame);
34
35 unsigned int width() const;
36 unsigned int height() const;
37 uint32_t size() const;
38 uint16_t id() const;
39 int64_t timestamp_us() const;
40 int64_t ntp_time_ms() const;
41 uint32_t timestamp() const;
42
43 VideoRotation rotation() const;
44 std::unique_ptr<VideoFrameBuffer> video_frame_buffer() const;
45
46 webrtc::VideoFrame get() const;
47
48 private:
49 webrtc::VideoFrame frame_;
50};
51
52// Allow to create VideoFrames from Rust,
53// the builder pattern will be redone in Rust
54class VideoFrameBuilder {
55 public:
56 VideoFrameBuilder() = default;
57
58 // TODO(theomonnom): other setters?
59 void set_video_frame_buffer(const VideoFrameBuffer& buffer);
60 void set_timestamp_us(int64_t timestamp_us);
61 void set_rotation(VideoRotation rotation);
62 void set_id(uint16_t id);
63 std::unique_ptr<VideoFrame> build();
64
65 private:
66 webrtc::VideoFrame::Builder builder_;
67};
68
69std::unique_ptr<VideoFrameBuilder> new_video_frame_builder();
70
71} // namespace livekit_ffi