BlueGit

ict rusty-teams

Files

rusty-teams / vendor / webrtc-sys / src / video_frame.cpp

video_frame.cpp

video_frame.cpp 2.4 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#include "livekit/video_frame.h"
18
19#include <memory>
20
21#include "api/video/video_frame.h"
22
23namespace livekit_ffi {
24VideoFrame::VideoFrame(const webrtc::VideoFrame& frame)
25 : frame_(std::move(frame)) {}
26
27unsigned int VideoFrame::width() const {
28 return frame_.width();
29}
30unsigned int VideoFrame::height() const {
31 return frame_.height();
32}
33uint32_t VideoFrame::size() const {
34 return frame_.size();
35}
36uint16_t VideoFrame::id() const {
37 return frame_.id();
38}
39int64_t VideoFrame::timestamp_us() const {
40 return frame_.timestamp_us();
41}
42int64_t VideoFrame::ntp_time_ms() const {
43 return frame_.ntp_time_ms();
44}
45uint32_t VideoFrame::timestamp() const {
46 return frame_.rtp_timestamp();
47}
48
49VideoRotation VideoFrame::rotation() const {
50 return static_cast<VideoRotation>(frame_.rotation());
51}
52
53// TODO(theomonnom) This shouldn't create a new shared_ptr at each call
54std::unique_ptr<VideoFrameBuffer> VideoFrame::video_frame_buffer() const {
55 return std::make_unique<VideoFrameBuffer>(frame_.video_frame_buffer());
56}
57
58webrtc::VideoFrame VideoFrame::get() const {
59 return frame_;
60}
61
62void VideoFrameBuilder::set_video_frame_buffer(const VideoFrameBuffer& buffer) {
63 builder_.set_video_frame_buffer(buffer.get()); // const & ref_counted
64}
65
66void VideoFrameBuilder::set_timestamp_us(int64_t timestamp_us) {
67 builder_.set_timestamp_us(timestamp_us);
68}
69
70void VideoFrameBuilder::set_rotation(VideoRotation rotation) {
71 builder_.set_rotation(static_cast<webrtc::VideoRotation>(rotation));
72}
73
74void VideoFrameBuilder::set_id(uint16_t id) {
75 builder_.set_id(id);
76}
77
78std::unique_ptr<VideoFrame> VideoFrameBuilder::build() {
79 return std::make_unique<VideoFrame>(builder_.build());
80}
81
82std::unique_ptr<VideoFrameBuilder> new_video_frame_builder() {
83 return std::make_unique<VideoFrameBuilder>();
84}
85
86} // namespace livekit_ffi