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:
@@ -2,13 +2,17 @@
|
||||
// Created by Théo Monnom on 01/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_CANDIDATE_H
|
||||
#define CLIENT_SDK_NATIVE_CANDIDATE_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/candidate.h"
|
||||
|
||||
namespace livekit {
|
||||
class Candidate;
|
||||
}
|
||||
#include "webrtc-sys/src/candidate.rs.h"
|
||||
|
||||
// cricket::Candidate
|
||||
namespace livekit {
|
||||
|
||||
@@ -20,10 +24,8 @@ class Candidate {
|
||||
cricket::Candidate candidate_;
|
||||
};
|
||||
|
||||
static std::unique_ptr<Candidate> _unique_candidate() {
|
||||
static std::shared_ptr<Candidate> _shared_candidate() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_CANDIDATE_H
|
||||
|
||||
@@ -2,19 +2,22 @@
|
||||
// Created by Théo Monnom on 01/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
||||
#define CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/data_channel_interface.h"
|
||||
#include "livekit/webrtc.h"
|
||||
#include "rust/cxx.h"
|
||||
#include "rust_types.h"
|
||||
#include "webrtc.h"
|
||||
|
||||
namespace livekit {
|
||||
class DataChannel;
|
||||
using NativeDataChannelInit = webrtc::DataChannelInit;
|
||||
class NativeDataChannelObserver;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/data_channel.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class DataChannel {
|
||||
public:
|
||||
@@ -22,8 +25,8 @@ class DataChannel {
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime,
|
||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
||||
|
||||
void register_observer(NativeDataChannelObserver& observer);
|
||||
void unregister_observer();
|
||||
void register_observer(NativeDataChannelObserver& observer) const;
|
||||
void unregister_observer() const;
|
||||
bool send(const DataBuffer& buffer) const;
|
||||
rust::String label() const;
|
||||
DataState state() const;
|
||||
@@ -57,5 +60,3 @@ class NativeDataChannelObserver : public webrtc::DataChannelObserver {
|
||||
std::unique_ptr<NativeDataChannelObserver> create_native_data_channel_observer(
|
||||
rust::Box<DataChannelObserverWrapper> observer);
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
#pragma once
|
||||
|
||||
#include "rust/cxx.h"
|
||||
|
||||
namespace livekit {
|
||||
class MediaStream;
|
||||
class AudioTrack;
|
||||
class VideoTrack;
|
||||
class Candidate;
|
||||
class RtpSender;
|
||||
class RtpReceiver;
|
||||
class RtpTransceiver;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/helper.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
// Impl not needed
|
||||
static rust::Vec<MediaStreamPtr> _vec_media_stream_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<CandidatePtr> _vec_candidate_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<AudioTrackPtr> _vec_audio_track_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<VideoTrackPtr> _vec_video_track_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<RtpSenderPtr> _vec_rtp_sender_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<RtpReceiverPtr> _vec_rtp_receiver_ptr() {
|
||||
throw;
|
||||
}
|
||||
static rust::Vec<RtpTransceiverPtr> _vec_rtp_transceiver_ptr() {
|
||||
throw;
|
||||
}
|
||||
|
||||
} // namespace livekit
|
||||
@@ -2,15 +2,24 @@
|
||||
// Created by Théo Monnom on 01/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_JSEP_H
|
||||
#define CLIENT_SDK_NATIVE_JSEP_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/jsep.h"
|
||||
#include "api/ref_counted_base.h"
|
||||
#include "api/set_local_description_observer_interface.h"
|
||||
#include "api/set_remote_description_observer_interface.h"
|
||||
#include "rust/cxx.h"
|
||||
#include "rust_types.h"
|
||||
|
||||
namespace livekit {
|
||||
class IceCandidate;
|
||||
class SessionDescription;
|
||||
struct NativeCreateSdpObserverHandle;
|
||||
struct NativeSetLocalSdpObserverHandle;
|
||||
struct NativeSetRemoteSdpObserverHandle;
|
||||
}; // namespace livekit
|
||||
#include "webrtc-sys/src/jsep.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
@@ -31,11 +40,11 @@ class IceCandidate {
|
||||
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate_;
|
||||
};
|
||||
|
||||
std::unique_ptr<IceCandidate> create_ice_candidate(rust::String sdp_mid,
|
||||
std::shared_ptr<IceCandidate> create_ice_candidate(rust::String sdp_mid,
|
||||
int sdp_mline_index,
|
||||
rust::String sdp);
|
||||
|
||||
static std::unique_ptr<IceCandidate> _unique_ice_candidate() {
|
||||
static std::shared_ptr<IceCandidate> _shared_ice_candidate() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
@@ -126,5 +135,3 @@ std::unique_ptr<NativeSetRemoteSdpObserverHandle>
|
||||
create_native_set_remote_sdp_observer(
|
||||
rust::Box<SetRemoteSdpObserverWrapper> observer);
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_JSEP_H
|
||||
|
||||
@@ -2,78 +2,92 @@
|
||||
// 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
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/media_stream_interface.h"
|
||||
#include "livekit/rust_types.h"
|
||||
#include "api/video/video_frame.h"
|
||||
#include "livekit/helper.h"
|
||||
#include "livekit/video_frame.h"
|
||||
#include "media/base/adapted_video_track_source.h"
|
||||
#include "rtc_base/synchronization/mutex.h"
|
||||
#include "rtc_base/timestamp_aligner.h"
|
||||
#include "rust/cxx.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class MediaStream;
|
||||
class MediaStreamTrack;
|
||||
class VideoTrack;
|
||||
class AudioTrack;
|
||||
class NativeVideoFrameSink;
|
||||
class AdaptedVideoTrackSource;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/media_stream.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class MediaStream {
|
||||
public:
|
||||
explicit MediaStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
|
||||
|
||||
rust::String id() const;
|
||||
rust::Vec<VideoTrackPtr> get_video_tracks() const;
|
||||
rust::Vec<AudioTrackPtr> get_audio_tracks() const;
|
||||
|
||||
std::shared_ptr<AudioTrack> find_audio_track(rust::String track_id) const;
|
||||
std::shared_ptr<VideoTrack> find_video_track(rust::String track_id) const;
|
||||
|
||||
bool add_audio_track(std::shared_ptr<AudioTrack> audio_track) const;
|
||||
bool add_video_track(std::shared_ptr<VideoTrack> video_track) const;
|
||||
bool remove_audio_track(std::shared_ptr<AudioTrack> audio_track) const;
|
||||
bool remove_video_track(std::shared_ptr<VideoTrack> video_track) 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(
|
||||
static std::shared_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);
|
||||
bool set_enabled(bool enable) const;
|
||||
|
||||
TrackState state() const;
|
||||
|
||||
rtc::scoped_refptr<webrtc::MediaStreamTrackInterface> get() const {
|
||||
return track_;
|
||||
}
|
||||
|
||||
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 add_sink(NativeVideoFrameSink& sink) const;
|
||||
void remove_sink(NativeVideoFrameSink& sink) const;
|
||||
|
||||
void set_should_receive(bool should_receive);
|
||||
void set_should_receive(bool should_receive) const;
|
||||
bool should_receive() const;
|
||||
ContentHint content_hint() const;
|
||||
void set_content_hint(ContentHint hint);
|
||||
void set_content_hint(ContentHint hint) const;
|
||||
|
||||
private:
|
||||
webrtc::VideoTrackInterface* track() const {
|
||||
@@ -81,10 +95,6 @@ class VideoTrack : public MediaStreamTrack {
|
||||
}
|
||||
};
|
||||
|
||||
static std::unique_ptr<VideoTrack> _unique_video_track() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
class NativeVideoFrameSink
|
||||
: public rtc::VideoSinkInterface<webrtc::VideoFrame> {
|
||||
public:
|
||||
@@ -102,22 +112,61 @@ class NativeVideoFrameSink
|
||||
std::unique_ptr<NativeVideoFrameSink> create_native_video_frame_sink(
|
||||
rust::Box<VideoFrameSinkWrapper> observer);
|
||||
|
||||
static const MediaStreamTrack* video_to_media(const VideoTrack* track) {
|
||||
return track;
|
||||
}
|
||||
// Native impl of the WebRTC interface
|
||||
class NativeVideoTrackSource : public rtc::AdaptedVideoTrackSource {
|
||||
public:
|
||||
NativeVideoTrackSource();
|
||||
~NativeVideoTrackSource() override;
|
||||
|
||||
static const MediaStreamTrack* audio_to_media(const AudioTrack* track) {
|
||||
return track;
|
||||
}
|
||||
bool is_screencast() const override;
|
||||
absl::optional<bool> needs_denoising() const override;
|
||||
webrtc::MediaSourceInterface::SourceState state() const override;
|
||||
bool remote() const override;
|
||||
|
||||
bool on_captured_frame(const webrtc::VideoFrame& frame);
|
||||
|
||||
private:
|
||||
webrtc::Mutex mutex_;
|
||||
rtc::TimestampAligner timestamp_aligner_;
|
||||
};
|
||||
|
||||
class AdaptedVideoTrackSource {
|
||||
public:
|
||||
AdaptedVideoTrackSource(rtc::scoped_refptr<NativeVideoTrackSource> source);
|
||||
|
||||
bool on_captured_frame(std::unique_ptr<VideoFrame> frame)
|
||||
const; // frames pushed from Rust (+interior mutability)
|
||||
|
||||
rtc::scoped_refptr<NativeVideoTrackSource> get() const;
|
||||
|
||||
private:
|
||||
rtc::scoped_refptr<NativeVideoTrackSource> source_;
|
||||
};
|
||||
|
||||
std::unique_ptr<AdaptedVideoTrackSource> create_adapted_video_track_source();
|
||||
|
||||
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);
|
||||
return static_cast<const AudioTrack*>(track);
|
||||
}
|
||||
|
||||
static std::shared_ptr<MediaStreamTrack> _shared_media_stream_track() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
static std::shared_ptr<AudioTrack> _shared_audio_track() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
static std::shared_ptr<VideoTrack> _shared_video_track() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
static std::shared_ptr<MediaStream> _shared_media_stream() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef OBJC_VIDEO_FACTORY_H
|
||||
#define OBJC_VIDEO_FACTORY_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
|
||||
@@ -11,5 +11,3 @@ std::unique_ptr<webrtc::VideoEncoderFactory> CreateObjCVideoEncoderFactory();
|
||||
std::unique_ptr<webrtc::VideoDecoderFactory> CreateObjCVideoDecoderFactory();
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // OBJC_VIDEO_FACTORY_H
|
||||
|
||||
@@ -2,20 +2,30 @@
|
||||
// Created by Théo Monnom on 30/08/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
||||
#define CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/peer_connection_interface.h"
|
||||
#include "data_channel.h"
|
||||
#include "jsep.h"
|
||||
#include "livekit/data_channel.h"
|
||||
#include "livekit/helper.h"
|
||||
#include "livekit/jsep.h"
|
||||
#include "livekit/media_stream.h"
|
||||
#include "livekit/rtp_receiver.h"
|
||||
#include "livekit/rtp_sender.h"
|
||||
#include "livekit/rtp_transceiver.h"
|
||||
#include "livekit/webrtc.h"
|
||||
#include "rust/cxx.h"
|
||||
#include "rust_types.h"
|
||||
#include "webrtc.h"
|
||||
|
||||
namespace livekit {
|
||||
class NativeAddIceCandidateObserver;
|
||||
class PeerConnection;
|
||||
class NativeAddIceCandidateObserver;
|
||||
class NativePeerConnectionObserver;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/peer_connection.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class PeerConnection {
|
||||
public:
|
||||
@@ -24,23 +34,54 @@ class PeerConnection {
|
||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
|
||||
|
||||
void create_offer(NativeCreateSdpObserverHandle& observer,
|
||||
RTCOfferAnswerOptions options);
|
||||
RTCOfferAnswerOptions options) const;
|
||||
|
||||
void create_answer(NativeCreateSdpObserverHandle& observer,
|
||||
RTCOfferAnswerOptions options);
|
||||
RTCOfferAnswerOptions options) const;
|
||||
|
||||
void set_local_description(std::unique_ptr<SessionDescription> desc,
|
||||
NativeSetLocalSdpObserverHandle& observer);
|
||||
NativeSetLocalSdpObserverHandle& observer) const;
|
||||
|
||||
void set_remote_description(std::unique_ptr<SessionDescription> desc,
|
||||
NativeSetRemoteSdpObserverHandle& observer);
|
||||
NativeSetRemoteSdpObserverHandle& observer) const;
|
||||
|
||||
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<NativeDataChannelInit> init) const;
|
||||
|
||||
void add_ice_candidate(std::shared_ptr<IceCandidate> candidate,
|
||||
NativeAddIceCandidateObserver& observer) const;
|
||||
|
||||
std::shared_ptr<RtpSender> add_track(
|
||||
std::shared_ptr<MediaStreamTrack> track,
|
||||
const rust::Vec<rust::String>& stream_ids) const;
|
||||
|
||||
void remove_track(std::shared_ptr<RtpSender> sender) const;
|
||||
|
||||
std::shared_ptr<RtpTransceiver> add_transceiver(
|
||||
std::shared_ptr<MediaStreamTrack> track,
|
||||
RtpTransceiverInit init) const;
|
||||
|
||||
std::shared_ptr<RtpTransceiver> add_transceiver_for_media(
|
||||
MediaType media_type,
|
||||
RtpTransceiverInit init) const;
|
||||
|
||||
rust::Vec<RtpSenderPtr> get_senders() const;
|
||||
|
||||
rust::Vec<RtpReceiverPtr> get_receivers() const;
|
||||
|
||||
rust::Vec<RtpTransceiverPtr> get_transceivers() const;
|
||||
|
||||
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:
|
||||
@@ -140,5 +181,3 @@ create_native_peer_connection_observer(
|
||||
std::shared_ptr<RTCRuntime> rtc_runtime,
|
||||
rust::Box<PeerConnectionObserverWrapper> observer);
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
||||
|
||||
@@ -2,18 +2,22 @@
|
||||
// Created by Théo Monnom on 03/08/2022.
|
||||
//
|
||||
|
||||
#ifndef PEER_CONNECTION_FACTORY_H
|
||||
#define PEER_CONNECTION_FACTORY_H
|
||||
#pragma once
|
||||
|
||||
#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;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/peer_connection_factory.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class PeerConnectionFactory {
|
||||
public:
|
||||
explicit PeerConnectionFactory(std::shared_ptr<RTCRuntime> rtc_runtime);
|
||||
@@ -33,5 +37,3 @@ std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory(
|
||||
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(
|
||||
RTCConfiguration conf);
|
||||
} // namespace livekit
|
||||
|
||||
#endif // PEER_CONNECTION_FACTORY_H
|
||||
|
||||
@@ -2,13 +2,11 @@
|
||||
// Created by theom on 04/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_RTC_ERROR_H
|
||||
#define CLIENT_SDK_NATIVE_RTC_ERROR_H
|
||||
#pragma once
|
||||
|
||||
#include "api/rtc_error.h"
|
||||
#include "webrtc-sys/src/rtc_error.rs.h"
|
||||
#include "rust/cxx.h"
|
||||
#include "rust_types.h"
|
||||
#include "webrtc-sys/src/rtc_error.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
@@ -22,5 +20,3 @@ void throw_error();
|
||||
#endif
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_RTC_ERROR_H
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/media_types.h"
|
||||
#include "api/priority.h"
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/rtp_transceiver_direction.h"
|
||||
#include "webrtc-sys/src/rtp_parameters.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
webrtc::RtcpFeedback to_native_rtcp_feedback(RtcpFeedback feedback);
|
||||
webrtc::RtpCodecCapability to_native_rtp_codec_capability(
|
||||
RtpCodecCapability capability);
|
||||
webrtc::RtpHeaderExtensionCapability to_native_rtp_header_extension_capability(
|
||||
RtpHeaderExtensionCapability header);
|
||||
webrtc::RtpExtension to_native_rtp_extension(RtpExtension ext);
|
||||
webrtc::RtpFecParameters to_rtp_fec_parameters(RtpFecParameters fec);
|
||||
webrtc::RtpRtxParameters to_rtp_rtx_parameters(RtpRtxParameters rtx);
|
||||
webrtc::RtpEncodingParameters to_native_rtp_encoding_paramters(
|
||||
RtpEncodingParameters parameters);
|
||||
webrtc::RtpCodecParameters to_native_rtp_codec_parameters(
|
||||
RtpCodecParameters params);
|
||||
webrtc::RtpCapabilities to_rtp_capabilities(RtpCapabilities capabilities);
|
||||
webrtc::RtcpParameters to_native_rtcp_paramaters(RtcpParameters params);
|
||||
webrtc::RtpParameters to_native_rtp_parameters(RtpParameters params);
|
||||
|
||||
RtcpFeedback to_rust_rtcp_feedback(webrtc::RtcpFeedback feedback);
|
||||
RtpCodecCapability to_rust_rtp_codec_capability(
|
||||
webrtc::RtpCodecCapability capability);
|
||||
RtpHeaderExtensionCapability to_rust_rtp_header_extension_capability(
|
||||
webrtc::RtpHeaderExtensionCapability header);
|
||||
RtpExtension to_rust_rtp_extension(webrtc::RtpExtension ext);
|
||||
RtpFecParameters to_rust_rtp_fec_parameters(webrtc::RtpFecParameters fec);
|
||||
RtpRtxParameters to_rust_rtp_rtx_parameters(webrtc::RtpRtxParameters param);
|
||||
RtpEncodingParameters to_rust_rtp_encoding_parameters(
|
||||
webrtc::RtpEncodingParameters params);
|
||||
RtpCodecParameters to_rust_rtp_codec_parameters(
|
||||
webrtc::RtpCodecParameters params);
|
||||
RtpCapabilities to_rust_rtp_capabilities(webrtc::RtpCapabilities capabilities);
|
||||
RtcpParameters to_rust_rtcp_parameters(webrtc::RtcpParameters params);
|
||||
RtpParameters to_rust_rtp_parameters(webrtc::RtpParameters params);
|
||||
|
||||
} // namespace livekit
|
||||
@@ -2,30 +2,51 @@
|
||||
// Created by Théo Monnom on 01/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
||||
#define CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/rtp_receiver_interface.h"
|
||||
#include "livekit/helper.h"
|
||||
#include "livekit/media_stream.h"
|
||||
#include "livekit/rtp_parameters.h"
|
||||
#include "rust/cxx.h"
|
||||
|
||||
namespace livekit {
|
||||
class RtpReceiver;
|
||||
}
|
||||
#include "webrtc-sys/src/rtp_receiver.rs.h"
|
||||
namespace livekit {
|
||||
|
||||
// TODO(theomonnom): Implement RtpReceiverObserverInterface?
|
||||
// TODO(theomonnom): RtpSource
|
||||
// TODO(theomonnom): FrameTransformer & FrameDecryptor interface
|
||||
class RtpReceiver {
|
||||
public:
|
||||
explicit RtpReceiver(
|
||||
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver);
|
||||
|
||||
std::unique_ptr<MediaStreamTrack> track() const;
|
||||
std::shared_ptr<MediaStreamTrack> track() const;
|
||||
|
||||
rust::Vec<rust::String> stream_ids() const;
|
||||
rust::Vec<MediaStreamPtr> streams() const;
|
||||
|
||||
MediaType media_type() const;
|
||||
rust::String id() const;
|
||||
|
||||
RtpParameters get_parameters() const;
|
||||
|
||||
// bool set_parameters(RtpParameters parameters) const; // Seems unsupported
|
||||
|
||||
void set_jitter_buffer_minimum_delay(bool is_some,
|
||||
double delay_seconds) const;
|
||||
|
||||
private:
|
||||
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver_;
|
||||
};
|
||||
|
||||
static std::unique_ptr<RtpReceiver> _unique_rtp_receiver() {
|
||||
return nullptr; // Ignore
|
||||
static std::shared_ptr<RtpReceiver> _shared_rtp_receiver() {
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
||||
} // namespace livekit
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/rtp_sender_interface.h"
|
||||
#include "livekit/media_stream.h"
|
||||
#include "livekit/rtc_error.h"
|
||||
#include "livekit/rtp_parameters.h"
|
||||
#include "rust/cxx.h"
|
||||
|
||||
namespace livekit {
|
||||
class RtpSender;
|
||||
}
|
||||
#include "webrtc-sys/src/rtp_sender.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
// TODO(theomonnom): FrameTransformer & FrameEncryptor interface
|
||||
class RtpSender {
|
||||
public:
|
||||
explicit RtpSender(rtc::scoped_refptr<webrtc::RtpSenderInterface> sender);
|
||||
|
||||
bool set_track(std::shared_ptr<MediaStreamTrack> track) const;
|
||||
|
||||
std::shared_ptr<MediaStreamTrack> track() const;
|
||||
|
||||
uint32_t ssrc() const;
|
||||
|
||||
MediaType media_type() const;
|
||||
|
||||
rust::String id() const;
|
||||
|
||||
rust::Vec<rust::String> stream_ids() const;
|
||||
|
||||
void set_streams(const rust::Vec<rust::String>& stream_ids) const;
|
||||
|
||||
rust::Vec<RtpEncodingParameters> init_send_encodings() const;
|
||||
|
||||
RtpParameters get_parameters() const;
|
||||
|
||||
void set_parameters(RtpParameters params) const;
|
||||
|
||||
rtc::scoped_refptr<webrtc::RtpSenderInterface> get() const { return sender_; }
|
||||
|
||||
private:
|
||||
rtc::scoped_refptr<webrtc::RtpSenderInterface> sender_;
|
||||
};
|
||||
|
||||
static std::shared_ptr<RtpSender> _shared_rtp_sender() {
|
||||
return nullptr; // Ignore
|
||||
}
|
||||
} // namespace livekit
|
||||
@@ -2,27 +2,73 @@
|
||||
// Created by Théo Monnom on 02/09/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
||||
#define CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/rtp_parameters.h"
|
||||
#include "api/rtp_transceiver_direction.h"
|
||||
#include "api/rtp_transceiver_interface.h"
|
||||
#include "livekit/rtc_error.h"
|
||||
#include "livekit/rtp_parameters.h"
|
||||
#include "livekit/rtp_receiver.h"
|
||||
#include "livekit/rtp_sender.h"
|
||||
#include "rust/cxx.h"
|
||||
|
||||
namespace livekit {
|
||||
class RtpTransceiver;
|
||||
}
|
||||
#include "webrtc-sys/src/rtp_transceiver.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
webrtc::RtpTransceiverInit to_native_rtp_transceiver_init(
|
||||
RtpTransceiverInit init);
|
||||
|
||||
class RtpTransceiver {
|
||||
public:
|
||||
explicit RtpTransceiver(
|
||||
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver);
|
||||
|
||||
MediaType media_type() const;
|
||||
|
||||
rust::String mid() const;
|
||||
|
||||
std::shared_ptr<RtpSender> sender() const;
|
||||
|
||||
std::shared_ptr<RtpReceiver> receiver() const;
|
||||
|
||||
bool stopped() const;
|
||||
|
||||
bool stopping() const;
|
||||
|
||||
RtpTransceiverDirection direction() const;
|
||||
|
||||
void set_direction(RtpTransceiverDirection direction) const;
|
||||
|
||||
RtpTransceiverDirection current_direction() const;
|
||||
|
||||
RtpTransceiverDirection fired_direction() const;
|
||||
|
||||
void stop_standard() const;
|
||||
|
||||
void set_codec_preferences(rust::Vec<RtpCodecCapability> codecs) const;
|
||||
|
||||
rust::Vec<RtpCodecCapability> codec_preferences() const;
|
||||
|
||||
rust::Vec<RtpHeaderExtensionCapability> header_extensions_to_offer() const;
|
||||
|
||||
rust::Vec<RtpHeaderExtensionCapability> header_extensions_negotiated() const;
|
||||
|
||||
void set_offered_rtp_header_extensions(
|
||||
rust::Vec<RtpHeaderExtensionCapability> header_extensions_to_offer) const;
|
||||
|
||||
private:
|
||||
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver_;
|
||||
};
|
||||
|
||||
static std::unique_ptr<RtpTransceiver> _unique_rtp_transceiver() {
|
||||
return nullptr; // Ignore
|
||||
static std::shared_ptr<RtpTransceiver> _shared_rtp_transceiver() {
|
||||
return nullptr;
|
||||
}
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
||||
} // namespace livekit
|
||||
|
||||
@@ -1,38 +0,0 @@
|
||||
//
|
||||
// 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
|
||||
@@ -1,8 +1,7 @@
|
||||
#ifndef VIDEO_DECODER_FACTORY_H
|
||||
#define VIDEO_DECODER_FACTORY_H
|
||||
#pragma once
|
||||
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
#include "api/video_codecs/video_decoder.h"
|
||||
#include "api/video_codecs/video_decoder_factory.h"
|
||||
|
||||
namespace livekit {
|
||||
class VideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
||||
@@ -18,5 +17,3 @@ class VideoDecoderFactory : public webrtc::VideoDecoderFactory {
|
||||
std::vector<std::unique_ptr<webrtc::VideoDecoderFactory>> factories_;
|
||||
};
|
||||
} // namespace livekit
|
||||
|
||||
#endif // VIDEO_DECODER_FACTORY_H
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
#ifndef VIDEO_ENCODER_FACTORY_H
|
||||
#define VIDEO_ENCODER_FACTORY_H
|
||||
#pragma once
|
||||
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
#include "api/video_codecs/video_encoder.h"
|
||||
#include "api/video_codecs/video_encoder_factory.h"
|
||||
|
||||
namespace livekit {
|
||||
class VideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
||||
@@ -18,5 +17,3 @@ class VideoEncoderFactory : public webrtc::VideoEncoderFactory {
|
||||
std::vector<std::unique_ptr<webrtc::VideoEncoderFactory>> factories_;
|
||||
};
|
||||
} // namespace livekit
|
||||
|
||||
#endif // VIDEO_ENCODER_FACTORY_H
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -2,75 +2,50 @@
|
||||
// Created by theom on 14/11/2022.
|
||||
//
|
||||
|
||||
#ifndef LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
|
||||
#define LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/video/i420_buffer.h"
|
||||
#include "api/video/video_frame_buffer.h"
|
||||
#include "rust_types.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class VideoFrameBuffer;
|
||||
class PlanarYuvBuffer;
|
||||
class PlanarYuv8Buffer;
|
||||
class PlanarYuv16BBuffer;
|
||||
class BiplanarYuvBuffer;
|
||||
class BiplanarYuv8Buffer;
|
||||
class I420Buffer;
|
||||
class I420ABuffer;
|
||||
class I422Buffer;
|
||||
class I444Buffer;
|
||||
class I010Buffer;
|
||||
class NV12Buffer;
|
||||
} // namespace livekit
|
||||
#include "webrtc-sys/src/video_frame_buffer.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class VideoFrameBuffer {
|
||||
public:
|
||||
explicit VideoFrameBuffer(rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer)
|
||||
: buffer_(std::move(buffer)) {}
|
||||
explicit VideoFrameBuffer(
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer);
|
||||
|
||||
VideoFrameBufferType buffer_type() const {
|
||||
return static_cast<VideoFrameBufferType>(buffer_->type());
|
||||
}
|
||||
VideoFrameBufferType buffer_type() const;
|
||||
|
||||
int width() const { return buffer_->width(); }
|
||||
int height() const { return buffer_->height(); }
|
||||
int width() const;
|
||||
int height() const;
|
||||
|
||||
std::unique_ptr<I420Buffer> to_i420() {
|
||||
return std::make_unique<I420Buffer>(buffer_->ToI420());
|
||||
}
|
||||
|
||||
// const_cast is valid here because we take the ownership on the rust side
|
||||
std::unique_ptr<I420Buffer> get_i420() {
|
||||
return std::make_unique<I420Buffer>(
|
||||
rtc::scoped_refptr<webrtc::I420BufferInterface>(
|
||||
const_cast<webrtc::I420BufferInterface*>(buffer_->GetI420())));
|
||||
}
|
||||
|
||||
std::unique_ptr<I420ABuffer> get_i420a() {
|
||||
return std::make_unique<I420ABuffer>(
|
||||
rtc::scoped_refptr<webrtc::I420ABufferInterface>(
|
||||
const_cast<webrtc::I420ABufferInterface*>(buffer_->GetI420A())));
|
||||
}
|
||||
|
||||
std::unique_ptr<I422Buffer> get_i422() {
|
||||
return std::make_unique<I422Buffer>(
|
||||
rtc::scoped_refptr<webrtc::I422BufferInterface>(
|
||||
const_cast<webrtc::I422BufferInterface*>(buffer_->GetI422())));
|
||||
}
|
||||
|
||||
std::unique_ptr<I444Buffer> get_i444() {
|
||||
return std::make_unique<I444Buffer>(
|
||||
rtc::scoped_refptr<webrtc::I444BufferInterface>(
|
||||
const_cast<webrtc::I444BufferInterface*>(buffer_->GetI444())));
|
||||
}
|
||||
|
||||
std::unique_ptr<I010Buffer> get_i010() {
|
||||
return std::make_unique<I010Buffer>(
|
||||
rtc::scoped_refptr<webrtc::I010BufferInterface>(
|
||||
const_cast<webrtc::I010BufferInterface*>(buffer_->GetI010())));
|
||||
}
|
||||
|
||||
std::unique_ptr<NV12Buffer> get_nv12() {
|
||||
return std::make_unique<NV12Buffer>(
|
||||
rtc::scoped_refptr<webrtc::NV12BufferInterface>(
|
||||
const_cast<webrtc::NV12BufferInterface*>(buffer_->GetNV12())));
|
||||
}
|
||||
// Takes ownership
|
||||
std::unique_ptr<I420Buffer> to_i420();
|
||||
std::unique_ptr<I420Buffer> get_i420();
|
||||
std::unique_ptr<I420ABuffer> get_i420a();
|
||||
std::unique_ptr<I422Buffer> get_i422();
|
||||
std::unique_ptr<I444Buffer> get_i444();
|
||||
std::unique_ptr<I010Buffer> get_i010();
|
||||
std::unique_ptr<NV12Buffer> get_nv12();
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> get() const;
|
||||
|
||||
protected:
|
||||
rtc::scoped_refptr<webrtc::VideoFrameBuffer> buffer_;
|
||||
@@ -78,120 +53,102 @@ class VideoFrameBuffer {
|
||||
|
||||
class PlanarYuvBuffer : public VideoFrameBuffer {
|
||||
public:
|
||||
explicit PlanarYuvBuffer(rtc::scoped_refptr<webrtc::PlanarYuvBuffer> buffer)
|
||||
: VideoFrameBuffer(buffer) {}
|
||||
explicit PlanarYuvBuffer(rtc::scoped_refptr<webrtc::PlanarYuvBuffer> buffer);
|
||||
|
||||
int chroma_width() const { return buffer()->ChromaWidth(); }
|
||||
int chroma_height() const { return buffer()->ChromaHeight(); }
|
||||
int chroma_width() const;
|
||||
int chroma_height() const;
|
||||
|
||||
int stride_y() const { return buffer()->StrideY(); }
|
||||
int stride_u() const { return buffer()->StrideU(); }
|
||||
int stride_v() const { return buffer()->StrideV(); }
|
||||
int stride_y() const;
|
||||
int stride_u() const;
|
||||
int stride_v() const;
|
||||
|
||||
private:
|
||||
webrtc::PlanarYuvBuffer* buffer() const {
|
||||
return static_cast<webrtc::PlanarYuvBuffer*>(buffer_.get());
|
||||
}
|
||||
webrtc::PlanarYuvBuffer* buffer() const;
|
||||
};
|
||||
|
||||
class PlanarYuv8Buffer : public PlanarYuvBuffer {
|
||||
public:
|
||||
explicit PlanarYuv8Buffer(rtc::scoped_refptr<webrtc::PlanarYuv8Buffer> buffer)
|
||||
: PlanarYuvBuffer(buffer) {}
|
||||
explicit PlanarYuv8Buffer(
|
||||
rtc::scoped_refptr<webrtc::PlanarYuv8Buffer> 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(); }
|
||||
const uint8_t* data_y() const;
|
||||
const uint8_t* data_u() const;
|
||||
const uint8_t* data_v() const;
|
||||
|
||||
private:
|
||||
webrtc::PlanarYuv8Buffer* buffer() const {
|
||||
return static_cast<webrtc::PlanarYuv8Buffer*>(buffer_.get());
|
||||
}
|
||||
webrtc::PlanarYuv8Buffer* buffer() const;
|
||||
};
|
||||
|
||||
class PlanarYuv16BBuffer : public PlanarYuvBuffer {
|
||||
public:
|
||||
explicit PlanarYuv16BBuffer(
|
||||
rtc::scoped_refptr<webrtc::PlanarYuv16BBuffer> buffer)
|
||||
: PlanarYuvBuffer(buffer) {}
|
||||
rtc::scoped_refptr<webrtc::PlanarYuv16BBuffer> buffer);
|
||||
|
||||
const uint16_t* data_y() const { return buffer()->DataY(); }
|
||||
const uint16_t* data_u() const { return buffer()->DataU(); }
|
||||
const uint16_t* data_v() const { return buffer()->DataV(); }
|
||||
const uint16_t* data_y() const;
|
||||
const uint16_t* data_u() const;
|
||||
const uint16_t* data_v() const;
|
||||
|
||||
private:
|
||||
webrtc::PlanarYuv16BBuffer* buffer() const {
|
||||
return static_cast<webrtc::PlanarYuv16BBuffer*>(buffer_.get());
|
||||
}
|
||||
webrtc::PlanarYuv16BBuffer* buffer() const;
|
||||
};
|
||||
|
||||
class BiplanarYuvBuffer : public VideoFrameBuffer {
|
||||
public:
|
||||
explicit BiplanarYuvBuffer(
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuvBuffer> buffer)
|
||||
: VideoFrameBuffer(buffer) {}
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuvBuffer> buffer);
|
||||
|
||||
int chroma_width() const { return buffer()->ChromaWidth(); }
|
||||
int chroma_height() const { return buffer()->ChromaHeight(); }
|
||||
int chroma_width() const;
|
||||
int chroma_height() const;
|
||||
|
||||
int stride_y() const { return buffer()->StrideY(); }
|
||||
int stride_uv() const { return buffer()->StrideUV(); }
|
||||
int stride_y() const;
|
||||
int stride_uv() const;
|
||||
|
||||
private:
|
||||
webrtc::BiplanarYuvBuffer* buffer() const {
|
||||
return static_cast<webrtc::BiplanarYuvBuffer*>(buffer_.get());
|
||||
}
|
||||
webrtc::BiplanarYuvBuffer* buffer() const;
|
||||
};
|
||||
|
||||
class BiplanarYuv8Buffer : public BiplanarYuvBuffer {
|
||||
public:
|
||||
explicit BiplanarYuv8Buffer(
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuv8Buffer> buffer)
|
||||
: BiplanarYuvBuffer(buffer) {}
|
||||
rtc::scoped_refptr<webrtc::BiplanarYuv8Buffer> buffer);
|
||||
|
||||
const uint8_t* data_y() const { return buffer()->DataY(); }
|
||||
const uint8_t* data_uv() const { return buffer()->DataUV(); }
|
||||
const uint8_t* data_y() const;
|
||||
const uint8_t* data_uv() const;
|
||||
|
||||
private:
|
||||
webrtc::BiplanarYuv8Buffer* buffer() const {
|
||||
return static_cast<webrtc::BiplanarYuv8Buffer*>(buffer_.get());
|
||||
}
|
||||
webrtc::BiplanarYuv8Buffer* buffer() const;
|
||||
};
|
||||
|
||||
std::unique_ptr<I420Buffer> create_i420_buffer(int width, int height);
|
||||
|
||||
class I420Buffer : public PlanarYuv8Buffer {
|
||||
public:
|
||||
explicit I420Buffer(rtc::scoped_refptr<webrtc::I420BufferInterface> buffer)
|
||||
: PlanarYuv8Buffer(buffer) {}
|
||||
explicit I420Buffer(rtc::scoped_refptr<webrtc::I420BufferInterface> buffer);
|
||||
};
|
||||
|
||||
class I420ABuffer : public I420Buffer {
|
||||
public:
|
||||
explicit I420ABuffer(rtc::scoped_refptr<webrtc::I420ABufferInterface> buffer)
|
||||
: I420Buffer(buffer) {}
|
||||
explicit I420ABuffer(rtc::scoped_refptr<webrtc::I420ABufferInterface> buffer);
|
||||
};
|
||||
|
||||
class I422Buffer : public PlanarYuv8Buffer {
|
||||
public:
|
||||
explicit I422Buffer(rtc::scoped_refptr<webrtc::I422BufferInterface> buffer)
|
||||
: PlanarYuv8Buffer(buffer) {}
|
||||
explicit I422Buffer(rtc::scoped_refptr<webrtc::I422BufferInterface> buffer);
|
||||
};
|
||||
|
||||
class I444Buffer : public PlanarYuv8Buffer {
|
||||
public:
|
||||
explicit I444Buffer(rtc::scoped_refptr<webrtc::I444BufferInterface> buffer)
|
||||
: PlanarYuv8Buffer(buffer) {}
|
||||
explicit I444Buffer(rtc::scoped_refptr<webrtc::I444BufferInterface> buffer);
|
||||
};
|
||||
|
||||
class I010Buffer : public PlanarYuv16BBuffer {
|
||||
public:
|
||||
explicit I010Buffer(rtc::scoped_refptr<webrtc::I010BufferInterface> buffer)
|
||||
: PlanarYuv16BBuffer(buffer) {}
|
||||
explicit I010Buffer(rtc::scoped_refptr<webrtc::I010BufferInterface> buffer);
|
||||
};
|
||||
|
||||
class NV12Buffer : public BiplanarYuv8Buffer {
|
||||
public:
|
||||
explicit NV12Buffer(rtc::scoped_refptr<webrtc::NV12BufferInterface> buffer)
|
||||
: BiplanarYuv8Buffer(buffer) {}
|
||||
explicit NV12Buffer(rtc::scoped_refptr<webrtc::NV12BufferInterface> buffer);
|
||||
};
|
||||
|
||||
static const VideoFrameBuffer* yuv_to_vfb(const PlanarYuvBuffer* yuv) {
|
||||
@@ -240,9 +197,7 @@ static const BiplanarYuv8Buffer* nv12_to_biyuv8(const NV12Buffer* nv12) {
|
||||
}
|
||||
|
||||
static std::unique_ptr<VideoFrameBuffer> _unique_video_frame_buffer() {
|
||||
return nullptr; // Ignore
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // LIVEKIT_WEBRTC_VIDEO_FRAME_BUFFER_H
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
// Created by theom on 18/09/2022.
|
||||
//
|
||||
|
||||
#ifndef LIVEKIT_WEBRTC_WEBRTC_H
|
||||
#define LIVEKIT_WEBRTC_WEBRTC_H
|
||||
#pragma once
|
||||
|
||||
#include "rtc_base/physical_socket_server.h"
|
||||
#include "rtc_base/ssl_adapter.h"
|
||||
@@ -12,6 +11,11 @@
|
||||
#include "rtc_base/win32_socket_init.h"
|
||||
#endif
|
||||
|
||||
namespace livekit {
|
||||
class RTCRuntime;
|
||||
}
|
||||
#include "webrtc-sys/src/webrtc.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
class RTCRuntime {
|
||||
@@ -30,15 +34,14 @@ class RTCRuntime {
|
||||
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_};
|
||||
rtc::AutoSocketServerThread main_thread_{&ss_};
|
||||
#endif
|
||||
};
|
||||
|
||||
std::shared_ptr<RTCRuntime> create_rtc_runtime();
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // LIVEKIT_WEBRTC_WEBRTC_H
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
// Created by Théo Monnom on 01/12/2022.
|
||||
//
|
||||
|
||||
#ifndef CLIENT_SDK_NATIVE_YUV_HELPER_H
|
||||
#define CLIENT_SDK_NATIVE_YUV_HELPER_H
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "api/video/yuv_helper.h"
|
||||
#include "webrtc-sys/src/yuv_helper.rs.h"
|
||||
|
||||
namespace livekit {
|
||||
|
||||
@@ -68,5 +68,3 @@ static void i420_to_rgba(const uint8_t* src_y,
|
||||
}
|
||||
|
||||
} // namespace livekit
|
||||
|
||||
#endif // CLIENT_SDK_NATIVE_YUV_HELPER_H
|
||||
|
||||
Reference in New Issue
Block a user