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