RtpTransceiver bindings & requirements for publishing tracks (#39)

- RtpSender
- RtpReceiver
- RtpTransceiver
- RtpParameters
- VideoFrameBuilder
- Interior mutability on c++ side
- Cleanup bindings ( Use #pragma once instead of include guards )
     - webrtc-sys/src/* headers are now used in only one place 
     - Avoid confusion between generated headers and our headers
- AdaptedVideoTrackSource
- Cleanup the workaround with unsupported Vec<Shared<T>>
    - Put everything inside one file
This commit is contained in:
Théo Monnom
2023-02-12 19:44:04 +01:00
committed by GitHub
parent 4411f88b68
commit 16ea02075f
64 changed files with 3357 additions and 670 deletions
+37 -25
View File
@@ -2,47 +2,59 @@
// Created by theom on 14/11/2022.
//
#ifndef LIVEKIT_WEBRTC_VIDEO_FRAME_H
#define LIVEKIT_WEBRTC_VIDEO_FRAME_H
#pragma once
#include "api/video/video_frame.h"
#include "livekit/rust_types.h"
#include "livekit/video_frame_buffer.h"
#include "rtc_base/checks.h"
namespace livekit {
class VideoFrame;
class VideoFrameBuilder;
} // namespace livekit
#include "webrtc-sys/src/video_frame.rs.h"
namespace livekit {
class VideoFrame {
public:
explicit VideoFrame(const webrtc::VideoFrame& frame)
: frame_(std::move(frame)) {}
explicit VideoFrame(const webrtc::VideoFrame& frame);
int width() const { return frame_.width(); }
int height() const { return frame_.height(); }
uint32_t size() const { return frame_.size(); }
uint16_t id() const { return frame_.id(); }
int64_t timestamp_us() const { return frame_.timestamp_us(); }
int64_t ntp_time_ms() const { return frame_.ntp_time_ms(); }
uint32_t transport_frame_id() const { return frame_.transport_frame_id(); }
uint32_t timestamp() const { return frame_.timestamp(); }
int width() const;
int height() const;
uint32_t size() const;
uint16_t id() const;
int64_t timestamp_us() const;
int64_t ntp_time_ms() const;
uint32_t transport_frame_id() const;
uint32_t timestamp() const;
VideoRotation rotation() const {
return static_cast<VideoRotation>(frame_.rotation());
}
VideoRotation rotation() const;
std::unique_ptr<VideoFrameBuffer> video_frame_buffer() const;
// TODO(theomonnom) This shouldn't create a new shared_ptr at each call
std::unique_ptr<VideoFrameBuffer> video_frame_buffer() const {
return std::make_unique<VideoFrameBuffer>(frame_.video_frame_buffer());
}
webrtc::VideoFrame get() const;
private:
webrtc::VideoFrame frame_;
};
static std::unique_ptr<VideoFrame> _unique_video_frame() {
return nullptr; // Ignore
}
// Allow to create VideoFrames from Rust,
// the builder pattern will be redone in Rust
class VideoFrameBuilder {
public:
VideoFrameBuilder() = default;
// TODO(theomonnom): other setters?
void set_video_frame_buffer(std::unique_ptr<VideoFrameBuffer> buffer);
void set_timestamp_us(int64_t timestamp_us);
void set_rotation(VideoRotation rotation);
void set_id(uint16_t id);
std::unique_ptr<VideoFrame> build();
private:
webrtc::VideoFrame::Builder builder_;
};
std::unique_ptr<VideoFrameBuilder> create_video_frame_builder();
} // namespace livekit
#endif // LIVEKIT_WEBRTC_VIDEO_FRAME_H