publish client-sdk-native (#12)

* Create README.md

* add example

* crates & examples

* fix syntax

* add LICENSE

* thirdparty LICENSE

* rearrange repo

* fix build

* egui versions

* prepare publish

* fix demo compilation

* add test ci

* Update rust.yml

* forgot runs-on

* install protoc before building

* avoid rate limit

* include submodules

* updates to readme

* cache rust builds

Co-authored-by: David Zhao <[email protected]>
Co-authored-by: David Zhao <[email protected]>
This commit is contained in:
Théo Monnom
2023-01-02 20:13:48 +01:00
committed by GitHub
co-authored by David Zhao David Zhao
parent a927baac94
commit a07b3451a3
102 changed files with 893 additions and 344 deletions
+29
View File
@@ -0,0 +1,29 @@
//
// Created by Théo Monnom on 01/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_CANDIDATE_H
#define CLIENT_SDK_NATIVE_CANDIDATE_H
#include <memory>
#include "api/candidate.h"
// cricket::Candidate
namespace livekit {
class Candidate {
public:
explicit Candidate(const cricket::Candidate& candidate);
private:
cricket::Candidate candidate_;
};
static std::unique_ptr<Candidate> _unique_candidate() {
return nullptr;
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_CANDIDATE_H
+61
View File
@@ -0,0 +1,61 @@
//
// Created by Théo Monnom on 01/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_DATA_CHANNEL_H
#define CLIENT_SDK_NATIVE_DATA_CHANNEL_H
#include <memory>
#include "api/data_channel_interface.h"
#include "rust/cxx.h"
#include "rust_types.h"
#include "webrtc.h"
namespace livekit {
using NativeDataChannelInit = webrtc::DataChannelInit;
class NativeDataChannelObserver;
class DataChannel {
public:
explicit DataChannel(
std::shared_ptr<RTCRuntime> rtc_runtime,
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
void register_observer(NativeDataChannelObserver& observer);
void unregister_observer();
bool send(const DataBuffer& buffer) const;
rust::String label() const;
DataState state() const;
void close() const;
private:
std::shared_ptr<RTCRuntime> rtc_runtime_;
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel_;
};
std::unique_ptr<NativeDataChannelInit> create_data_channel_init(
DataChannelInit init);
static std::unique_ptr<DataChannel> _unique_data_channel() {
return nullptr; // Ignore
}
class NativeDataChannelObserver : public webrtc::DataChannelObserver {
public:
explicit NativeDataChannelObserver(
rust::Box<DataChannelObserverWrapper> observer);
void OnStateChange() override;
void OnMessage(const webrtc::DataBuffer& buffer) override;
void OnBufferedAmountChange(uint64_t sent_data_size) override;
private:
rust::Box<DataChannelObserverWrapper> observer_;
};
std::unique_ptr<NativeDataChannelObserver> create_native_data_channel_observer(
rust::Box<DataChannelObserverWrapper> observer);
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_DATA_CHANNEL_H
+130
View File
@@ -0,0 +1,130 @@
//
// Created by Théo Monnom on 01/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_JSEP_H
#define CLIENT_SDK_NATIVE_JSEP_H
#include <memory>
#include "api/jsep.h"
#include "api/ref_counted_base.h"
#include "rust/cxx.h"
#include "rust_types.h"
namespace livekit {
class IceCandidate {
public:
explicit IceCandidate(
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate);
rust::String sdp_mid() const;
int sdp_mline_index() const;
rust::String candidate() const; // TODO(theomonnom) Return livekit::Candidate
// instead of rust::String
rust::String stringify() const;
std::unique_ptr<webrtc::IceCandidateInterface> release();
private:
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate_;
};
std::unique_ptr<IceCandidate> create_ice_candidate(rust::String sdp_mid,
int sdp_mline_index,
rust::String sdp);
static std::unique_ptr<IceCandidate> _unique_ice_candidate() {
return nullptr; // Ignore
}
class SessionDescription {
public:
explicit SessionDescription(
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description);
rust::String stringify() const;
std::unique_ptr<SessionDescription> clone() const;
std::unique_ptr<webrtc::SessionDescriptionInterface> release();
private:
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description_;
};
std::unique_ptr<SessionDescription> create_session_description(
SdpType type,
rust::String sdp);
static std::unique_ptr<SessionDescription> _unique_session_description() {
return nullptr; // Ignore
}
// SetCreateSdpObserver
class NativeCreateSdpObserver
: public webrtc::CreateSessionDescriptionObserver {
public:
explicit NativeCreateSdpObserver(
rust::Box<CreateSdpObserverWrapper> observer);
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
void OnFailure(webrtc::RTCError error) override;
private:
rust::Box<CreateSdpObserverWrapper> observer_;
};
struct NativeCreateSdpObserverHandle {
rtc::scoped_refptr<NativeCreateSdpObserver> observer;
};
std::unique_ptr<NativeCreateSdpObserverHandle>
create_native_create_sdp_observer(rust::Box<CreateSdpObserverWrapper> observer);
// SetLocalSdpObserver
class NativeSetLocalSdpObserver
: public webrtc::SetLocalDescriptionObserverInterface {
public:
explicit NativeSetLocalSdpObserver(
rust::Box<SetLocalSdpObserverWrapper> observer);
void OnSetLocalDescriptionComplete(webrtc::RTCError error) override;
private:
rust::Box<SetLocalSdpObserverWrapper> observer_;
};
struct NativeSetLocalSdpObserverHandle {
rtc::scoped_refptr<NativeSetLocalSdpObserver> observer;
};
std::unique_ptr<NativeSetLocalSdpObserverHandle>
create_native_set_local_sdp_observer(
rust::Box<SetLocalSdpObserverWrapper> observer);
// SetRemoteSdpObserver
class NativeSetRemoteSdpObserver
: public webrtc::SetRemoteDescriptionObserverInterface {
public:
explicit NativeSetRemoteSdpObserver(
rust::Box<SetRemoteSdpObserverWrapper> observer);
void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override;
private:
rust::Box<SetRemoteSdpObserverWrapper> observer_;
};
struct NativeSetRemoteSdpObserverHandle {
rtc::scoped_refptr<NativeSetRemoteSdpObserver> observer;
};
std::unique_ptr<NativeSetRemoteSdpObserverHandle>
create_native_set_remote_sdp_observer(
rust::Box<SetRemoteSdpObserverWrapper> observer);
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_JSEP_H
+123
View File
@@ -0,0 +1,123 @@
//
// Created by Théo Monnom on 31/08/2022.
//
#ifndef CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
#define CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
#include <memory>
#include "api/media_stream_interface.h"
#include "livekit/rust_types.h"
#include "rust/cxx.h"
namespace livekit {
class NativeVideoFrameSink;
class MediaStream {
public:
explicit MediaStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
rust::String id() const;
private:
rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
};
static std::unique_ptr<MediaStream> _unique_media_stream() {
return nullptr; // Ignore
}
class MediaStreamTrack {
protected:
explicit MediaStreamTrack(
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track);
public:
static std::unique_ptr<MediaStreamTrack> from(
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track);
rust::String kind() const;
rust::String id() const;
bool enabled() const;
bool set_enabled(bool enable);
TrackState state() const;
protected:
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> track_;
};
static std::unique_ptr<MediaStreamTrack> _unique_media_stream_track() {
return nullptr; // Ignore
}
class AudioTrack : public MediaStreamTrack {
public:
explicit AudioTrack(rtc::scoped_refptr<webrtc::AudioTrackInterface> track);
};
static std::unique_ptr<AudioTrack> _unique_audio_track() {
return nullptr; // Ignore
}
class VideoTrack : public MediaStreamTrack {
public:
explicit VideoTrack(rtc::scoped_refptr<webrtc::VideoTrackInterface> track);
void add_sink(NativeVideoFrameSink& sink);
void remove_sink(NativeVideoFrameSink& sink);
void set_should_receive(bool should_receive);
bool should_receive() const;
ContentHint content_hint() const;
void set_content_hint(ContentHint hint);
private:
webrtc::VideoTrackInterface* track() const {
return static_cast<webrtc::VideoTrackInterface*>(track_.get());
}
};
static std::unique_ptr<VideoTrack> _unique_video_track() {
return nullptr; // Ignore
}
class NativeVideoFrameSink
: public rtc::VideoSinkInterface<webrtc::VideoFrame> {
public:
explicit NativeVideoFrameSink(rust::Box<VideoFrameSinkWrapper> observer);
void OnFrame(const webrtc::VideoFrame& frame) override;
void OnDiscardedFrame() override;
void OnConstraintsChanged(
const webrtc::VideoTrackSourceConstraints& constraints) override;
private:
rust::Box<VideoFrameSinkWrapper> observer_;
};
std::unique_ptr<NativeVideoFrameSink> create_native_video_frame_sink(
rust::Box<VideoFrameSinkWrapper> observer);
static const MediaStreamTrack* video_to_media(const VideoTrack* track) {
return track;
}
static const MediaStreamTrack* audio_to_media(const AudioTrack* track) {
return track;
}
static const VideoTrack* media_to_video(const MediaStreamTrack* track) {
return static_cast<const VideoTrack*>(track);
}
static const AudioTrack* media_to_audio(const MediaStreamTrack* track) {
return static_cast<const AudioTrack*>(track);
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
@@ -0,0 +1,144 @@
//
// Created by Théo Monnom on 30/08/2022.
//
#ifndef CLIENT_SDK_NATIVE_PEER_CONNECTION_H
#define CLIENT_SDK_NATIVE_PEER_CONNECTION_H
#include <memory>
#include "api/peer_connection_interface.h"
#include "data_channel.h"
#include "jsep.h"
#include "rust/cxx.h"
#include "rust_types.h"
#include "webrtc.h"
namespace livekit {
class NativeAddIceCandidateObserver;
class PeerConnection {
public:
explicit PeerConnection(
std::shared_ptr<RTCRuntime> rtc_runtime,
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
void create_offer(NativeCreateSdpObserverHandle& observer,
RTCOfferAnswerOptions options);
void create_answer(NativeCreateSdpObserverHandle& observer,
RTCOfferAnswerOptions options);
void set_local_description(std::unique_ptr<SessionDescription> desc,
NativeSetLocalSdpObserverHandle& observer);
void set_remote_description(std::unique_ptr<SessionDescription> desc,
NativeSetRemoteSdpObserverHandle& observer);
std::unique_ptr<DataChannel> create_data_channel(
rust::String label,
std::unique_ptr<NativeDataChannelInit> init);
void add_ice_candidate(std::unique_ptr<IceCandidate> candidate,
NativeAddIceCandidateObserver& observer);
std::unique_ptr<SessionDescription> local_description() const;
std::unique_ptr<SessionDescription> remote_description() const;
SignalingState signaling_state() const;
IceGatheringState ice_gathering_state() const;
IceConnectionState ice_connection_state() const;
void close();
private:
std::shared_ptr<RTCRuntime> rtc_runtime_;
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
};
static std::unique_ptr<PeerConnection> _unique_peer_connection() {
return nullptr; // Ignore
}
class NativeAddIceCandidateObserver {
public:
explicit NativeAddIceCandidateObserver(
rust::Box<AddIceCandidateObserverWrapper> observer);
void OnComplete(const RTCError& error);
private:
rust::Box<AddIceCandidateObserverWrapper> observer_;
};
std::unique_ptr<NativeAddIceCandidateObserver>
create_native_add_ice_candidate_observer(
rust::Box<AddIceCandidateObserverWrapper> observer);
class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver {
public:
explicit NativePeerConnectionObserver(
std::shared_ptr<RTCRuntime> rtc_runtime,
rust::Box<PeerConnectionObserverWrapper> observer);
void OnSignalingChange(
webrtc::PeerConnectionInterface::SignalingState new_state) override;
void OnAddStream(
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
void OnRemoveStream(
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
void OnDataChannel(
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
void OnRenegotiationNeeded() override;
void OnNegotiationNeededEvent(uint32_t event_id) override;
void OnIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
void OnStandardizedIceConnectionChange(
webrtc::PeerConnectionInterface::IceConnectionState new_state) override;
void OnConnectionChange(
webrtc::PeerConnectionInterface::PeerConnectionState new_state) override;
void OnIceGatheringChange(
webrtc::PeerConnectionInterface::IceGatheringState new_state) override;
void OnIceCandidate(const webrtc::IceCandidateInterface* candidate) override;
void OnIceCandidateError(const std::string& address,
int port,
const std::string& url,
int error_code,
const std::string& error_text) override;
void OnIceCandidatesRemoved(
const std::vector<cricket::Candidate>& candidates) override;
void OnIceConnectionReceivingChange(bool receiving) override;
void OnIceSelectedCandidatePairChanged(
const cricket::CandidatePairChangeEvent& event) override;
void OnAddTrack(
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&
streams) override;
void OnTrack(
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) override;
void OnRemoveTrack(
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) override;
void OnInterestingUsage(int usage_pattern) override;
private:
std::shared_ptr<RTCRuntime> rtc_runtime_;
rust::Box<PeerConnectionObserverWrapper> observer_;
};
std::unique_ptr<NativePeerConnectionObserver>
create_native_peer_connection_observer(
std::shared_ptr<RTCRuntime> rtc_runtime,
rust::Box<PeerConnectionObserverWrapper> observer);
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_PEER_CONNECTION_H
@@ -0,0 +1,37 @@
//
// Created by Théo Monnom on 03/08/2022.
//
#ifndef PEER_CONNECTION_FACTORY_H
#define PEER_CONNECTION_FACTORY_H
#include "api/peer_connection_interface.h"
#include "peer_connection.h"
#include "rust_types.h"
#include "webrtc.h"
namespace livekit {
using NativeRTCConfiguration =
webrtc::PeerConnectionInterface::RTCConfiguration;
class PeerConnectionFactory {
public:
explicit PeerConnectionFactory(std::shared_ptr<RTCRuntime> rtc_runtime);
~PeerConnectionFactory();
std::unique_ptr<PeerConnection> create_peer_connection(
std::unique_ptr<NativeRTCConfiguration> config,
NativePeerConnectionObserver& observer) const;
private:
std::shared_ptr<RTCRuntime> rtc_runtime_;
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
};
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(
std::shared_ptr<RTCRuntime> rtc_runtime);
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(
RTCConfiguration conf);
} // namespace livekit
#endif // PEER_CONNECTION_FACTORY_H
+26
View File
@@ -0,0 +1,26 @@
//
// Created by theom on 04/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_RTC_ERROR_H
#define CLIENT_SDK_NATIVE_RTC_ERROR_H
#include "api/rtc_error.h"
#include "webrtc-sys/src/rtc_error.rs.h"
#include "rust/cxx.h"
#include "rust_types.h"
namespace livekit {
RTCError to_error(const webrtc::RTCError& error);
std::string serialize_error(
const RTCError& error); // to be used inside cxx::Exception msg
#ifdef LIVEKIT_TEST
rust::String serialize_deserialize();
void throw_error();
#endif
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_RTC_ERROR_H
+31
View File
@@ -0,0 +1,31 @@
//
// Created by Théo Monnom on 01/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_RTP_RECEIVER_H
#define CLIENT_SDK_NATIVE_RTP_RECEIVER_H
#include <memory>
#include "api/rtp_receiver_interface.h"
#include "livekit/media_stream.h"
namespace livekit {
class RtpReceiver {
public:
explicit RtpReceiver(
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver);
std::unique_ptr<MediaStreamTrack> track() const;
private:
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver_;
};
static std::unique_ptr<RtpReceiver> _unique_rtp_receiver() {
return nullptr; // Ignore
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_RTP_RECEIVER_H
@@ -0,0 +1,28 @@
//
// Created by Théo Monnom on 02/09/2022.
//
#ifndef CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
#define CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
#include <memory>
#include "api/rtp_transceiver_interface.h"
namespace livekit {
class RtpTransceiver {
public:
explicit RtpTransceiver(
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver);
private:
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver_;
};
static std::unique_ptr<RtpTransceiver> _unique_rtp_transceiver() {
return nullptr; // Ignore
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
+38
View File
@@ -0,0 +1,38 @@
//
// Created by Théo Monnom on 30/08/2022.
//
#ifndef RUST_TYPES_H
#define RUST_TYPES_H
#include "api/peer_connection_interface.h"
namespace livekit {
struct RTCConfiguration;
struct PeerConnectionObserverWrapper;
struct CreateSdpObserverWrapper;
struct SetLocalSdpObserverWrapper;
struct SetRemoteSdpObserverWrapper;
struct DataChannelObserverWrapper;
struct AddIceCandidateObserverWrapper;
struct VideoFrameSinkWrapper;
// Shared types
enum class PeerConnectionState;
enum class SignalingState;
enum class IceConnectionState;
enum class IceGatheringState;
enum class SdpType;
enum class DataState;
enum class TrackState;
enum class ContentHint;
enum class VideoRotation;
enum class VideoFrameBufferType;
struct SdpParseError;
struct RTCOfferAnswerOptions;
struct RTCError;
struct DataChannelInit;
struct DataBuffer;
} // namespace livekit
#endif // RUST_TYPES_H
+48
View File
@@ -0,0 +1,48 @@
//
// Created by theom on 14/11/2022.
//
#ifndef LIVEKIT_WEBRTC_VIDEO_FRAME_H
#define LIVEKIT_WEBRTC_VIDEO_FRAME_H
#include "api/video/video_frame.h"
#include "livekit/rust_types.h"
#include "livekit/video_frame_buffer.h"
namespace livekit {
class VideoFrame {
public:
explicit VideoFrame(const webrtc::VideoFrame& frame)
: frame_(std::move(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(); }
VideoRotation rotation() const {
return static_cast<VideoRotation>(frame_.rotation());
}
// 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());
}
private:
webrtc::VideoFrame frame_;
};
static std::unique_ptr<VideoFrame> _unique_video_frame() {
return nullptr; // Ignore
}
} // namespace livekit
#endif // LIVEKIT_WEBRTC_VIDEO_FRAME_H
@@ -0,0 +1,103 @@
//
// Created by theom on 14/11/2022.
//
#ifndef LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
#define LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
#include <memory>
#include "api/video/video_frame_buffer.h"
#include "rust_types.h"
namespace livekit {
class PlanarYuvBuffer;
class PlanarYuv8Buffer;
class I420Buffer;
class VideoFrameBuffer {
public:
explicit VideoFrameBuffer(rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer)
: buffer_(std::move(buffer)) {}
VideoFrameBufferType buffer_type() const {
return static_cast<VideoFrameBufferType>(buffer_->type());
}
int width() const { return buffer_->width(); }
int height() const { return buffer_->height(); }
std::unique_ptr<I420Buffer> to_i420() {
return std::make_unique<I420Buffer>(buffer_->ToI420());
}
std::unique_ptr<I420Buffer> get_i420() {
// const_cast is valid here because we take the ownership on the rust side
return std::make_unique<I420Buffer>(
rtc::scoped_refptr<webrtc::I420BufferInterface>(
const_cast<webrtc::I420BufferInterface*>(buffer_->GetI420())));
}
protected:
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer_;
};
class PlanarYuvBuffer : public VideoFrameBuffer {
public:
explicit PlanarYuvBuffer(rtc::scoped_refptr<webrtc::PlanarYuvBuffer> buffer)
: VideoFrameBuffer(buffer) {}
int chroma_width() const { return buffer()->ChromaWidth(); }
int chroma_height() const { return buffer()->ChromaHeight(); }
int stride_y() const { return buffer()->StrideY(); }
int stride_u() const { return buffer()->StrideU(); }
int stride_v() const { return buffer()->StrideV(); }
private:
webrtc::PlanarYuvBuffer* buffer() const {
return static_cast<webrtc::PlanarYuvBuffer*>(buffer_.get());
}
};
class PlanarYuv8Buffer : public PlanarYuvBuffer {
public:
explicit PlanarYuv8Buffer(rtc::scoped_refptr<webrtc::PlanarYuv8Buffer> buffer)
: PlanarYuvBuffer(buffer) {}
const uint8_t* data_y() const { return buffer()->DataY(); }
const uint8_t* data_u() const { return buffer()->DataU(); }
const uint8_t* data_v() const { return buffer()->DataV(); }
private:
webrtc::PlanarYuv8Buffer* buffer() const {
return static_cast<webrtc::PlanarYuv8Buffer*>(buffer_.get());
}
};
class I420Buffer : public PlanarYuv8Buffer {
public:
explicit I420Buffer(rtc::scoped_refptr<webrtc::I420BufferInterface> buffer)
: PlanarYuv8Buffer(buffer) {}
};
static const VideoFrameBuffer* yuv_to_vfb(const PlanarYuvBuffer* yuv) {
return yuv;
}
static const PlanarYuvBuffer* yuv8_to_yuv(const PlanarYuv8Buffer* yuv8) {
return yuv8;
}
static const PlanarYuv8Buffer* i420_to_yuv8(const I420Buffer* i420) {
return i420;
}
static std::unique_ptr<VideoFrameBuffer> _unique_video_frame_buffer() {
return nullptr; // Ignore
}
} // namespace livekit
#endif // LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
+44
View File
@@ -0,0 +1,44 @@
//
// Created by theom on 18/09/2022.
//
#ifndef LIVEKIT_WEBRTC_WEBRTC_H
#define LIVEKIT_WEBRTC_WEBRTC_H
#include "rtc_base/physical_socket_server.h"
#include "rtc_base/ssl_adapter.h"
#ifdef WEBRTC_WIN
#include "rtc_base/win32_socket_init.h"
#endif
namespace livekit {
class RTCRuntime {
public:
RTCRuntime();
~RTCRuntime();
RTCRuntime(const RTCRuntime&) = delete;
RTCRuntime& operator=(const RTCRuntime&) = delete;
rtc::Thread* network_thread() const;
rtc::Thread* worker_thread() const;
rtc::Thread* signaling_thread() const;
private:
std::unique_ptr<rtc::Thread> network_thread_;
std::unique_ptr<rtc::Thread> worker_thread_;
std::unique_ptr<rtc::Thread> signaling_thread_;
#ifdef WEBRTC_WIN
rtc::WinsockInitializer winsock_;
rtc::PhysicalSocketServer ss_;
rtc::AutoSocketServerThread main_thread_ {&ss_};
#endif
};
std::shared_ptr<RTCRuntime> create_rtc_runtime();
} // namespace livekit
#endif // LIVEKIT_WEBRTC_WEBRTC_H
+30
View File
@@ -0,0 +1,30 @@
//
// Created by Théo Monnom on 01/12/2022.
//
#ifndef CLIENT_SDK_NATIVE_YUV_HELPER_H
#define CLIENT_SDK_NATIVE_YUV_HELPER_H
#include <memory>
#include "api/video/yuv_helper.h"
namespace livekit {
static void i420_to_abgr(const uint8_t* src_y,
int src_stride_y,
const uint8_t* src_u,
int src_stride_u,
const uint8_t* src_v,
int src_stride_v,
uint8_t* dst_rgba,
int dst_stride_abgr,
int width,
int height) {
webrtc::I420ToABGR(src_y, src_stride_y, src_u, src_stride_u, src_v,
src_stride_v, dst_rgba, dst_stride_abgr, width, height);
}
} // namespace livekit
#endif // CLIENT_SDK_NATIVE_YUV_HELPER_H