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