Added .clang-format + reformatted code
This commit is contained in:
@@ -0,0 +1,24 @@
|
|||||||
|
# Using the same .clang-format as libwebrtc
|
||||||
|
# https://github.com/webrtc-sdk/webrtc/blob/m104_release/.clang-format
|
||||||
|
BasedOnStyle: Chromium
|
||||||
|
---
|
||||||
|
Language: Java
|
||||||
|
BasedOnStyle: Google
|
||||||
|
---
|
||||||
|
Language: ObjC
|
||||||
|
BasedOnStyle: Google
|
||||||
|
BinPackParameters: false
|
||||||
|
BinPackArguments: false
|
||||||
|
ColumnLimit: 100
|
||||||
|
ObjCBlockIndentWidth: 2
|
||||||
|
AllowAllParametersOfDeclarationOnNextLine: true
|
||||||
|
AlignOperands: false
|
||||||
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
|
AllowShortFunctionsOnASingleLine: Inline
|
||||||
|
BreakBeforeTernaryOperators: false
|
||||||
|
IndentWrappedFunctionNames: true
|
||||||
|
ContinuationIndentWidth: 4
|
||||||
|
ObjCSpaceBeforeProtocolList: true
|
||||||
|
---
|
||||||
|
Language: Cpp
|
||||||
|
IncludeBlocks: Regroup
|
||||||
@@ -6,23 +6,24 @@
|
|||||||
#define CLIENT_SDK_NATIVE_CANDIDATE_H
|
#define CLIENT_SDK_NATIVE_CANDIDATE_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/candidate.h"
|
#include "api/candidate.h"
|
||||||
|
|
||||||
// cricket::Candidate
|
// cricket::Candidate
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class Candidate {
|
class Candidate {
|
||||||
public:
|
public:
|
||||||
explicit Candidate(const cricket::Candidate &candidate);
|
explicit Candidate(const cricket::Candidate& candidate);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
cricket::Candidate candidate_;
|
cricket::Candidate candidate_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<Candidate> _unique_candidate(){
|
static std::unique_ptr<Candidate> _unique_candidate() {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_CANDIDATE_H
|
#endif // CLIENT_SDK_NATIVE_CANDIDATE_H
|
||||||
|
|||||||
@@ -6,45 +6,52 @@
|
|||||||
#define CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
#define CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/data_channel_interface.h"
|
#include "api/data_channel_interface.h"
|
||||||
#include "rust_types.h"
|
|
||||||
#include "rust/cxx.h"
|
#include "rust/cxx.h"
|
||||||
|
#include "rust_types.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
using NativeDataChannelInit = webrtc::DataChannelInit;
|
using NativeDataChannelInit = webrtc::DataChannelInit;
|
||||||
class NativeDataChannelObserver;
|
class NativeDataChannelObserver;
|
||||||
|
|
||||||
class DataChannel {
|
class DataChannel {
|
||||||
public:
|
public:
|
||||||
explicit DataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
explicit DataChannel(
|
||||||
|
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel);
|
||||||
|
|
||||||
void register_observer(NativeDataChannelObserver &observer);
|
void register_observer(NativeDataChannelObserver& observer);
|
||||||
void unregister_observer();
|
void unregister_observer();
|
||||||
bool send(const DataBuffer& buffer);
|
bool send(const DataBuffer& buffer);
|
||||||
rust::String label() const;
|
rust::String label() const;
|
||||||
void close();
|
void close();
|
||||||
private:
|
|
||||||
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel_;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativeDataChannelInit> create_data_channel_init(DataChannelInit init);
|
private:
|
||||||
|
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel_;
|
||||||
|
};
|
||||||
|
|
||||||
static std::unique_ptr<DataChannel> _unique_data_channel(){
|
std::unique_ptr<NativeDataChannelInit> create_data_channel_init(
|
||||||
return nullptr; // Ignore
|
DataChannelInit init);
|
||||||
}
|
|
||||||
|
|
||||||
class NativeDataChannelObserver : public webrtc::DataChannelObserver {
|
static std::unique_ptr<DataChannel> _unique_data_channel() {
|
||||||
public:
|
return nullptr; // Ignore
|
||||||
explicit NativeDataChannelObserver(rust::Box<DataChannelObserverWrapper> observer);
|
}
|
||||||
|
|
||||||
void OnStateChange() override;
|
class NativeDataChannelObserver : public webrtc::DataChannelObserver {
|
||||||
void OnMessage(const webrtc::DataBuffer& buffer) override;
|
public:
|
||||||
void OnBufferedAmountChange(uint64_t sent_data_size) override;
|
explicit NativeDataChannelObserver(
|
||||||
private:
|
rust::Box<DataChannelObserverWrapper> observer);
|
||||||
rust::Box<DataChannelObserverWrapper> observer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativeDataChannelObserver> create_native_data_channel_observer(rust::Box<DataChannelObserverWrapper> observer);
|
void OnStateChange() override;
|
||||||
} // livekit
|
void OnMessage(const webrtc::DataBuffer& buffer) override;
|
||||||
|
void OnBufferedAmountChange(uint64_t sent_data_size) override;
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_DATA_CHANNEL_H
|
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
|
||||||
|
|||||||
@@ -6,93 +6,111 @@
|
|||||||
#define CLIENT_SDK_NATIVE_JSEP_H
|
#define CLIENT_SDK_NATIVE_JSEP_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/jsep.h"
|
#include "api/jsep.h"
|
||||||
|
#include "api/ref_counted_base.h"
|
||||||
#include "rust/cxx.h"
|
#include "rust/cxx.h"
|
||||||
#include "rust_types.h"
|
#include "rust_types.h"
|
||||||
#include "api/ref_counted_base.h"
|
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class IceCandidate {
|
class IceCandidate {
|
||||||
public:
|
public:
|
||||||
explicit IceCandidate(std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate);
|
explicit IceCandidate(
|
||||||
|
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate);
|
||||||
|
|
||||||
std::unique_ptr<webrtc::IceCandidateInterface> release();
|
std::unique_ptr<webrtc::IceCandidateInterface> release();
|
||||||
private:
|
|
||||||
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate_;
|
|
||||||
};
|
|
||||||
|
|
||||||
static std::unique_ptr<IceCandidate> _unique_ice_candidate(){
|
private:
|
||||||
return nullptr; // Ignore
|
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate_;
|
||||||
}
|
};
|
||||||
|
|
||||||
class SessionDescription {
|
static std::unique_ptr<IceCandidate> _unique_ice_candidate() {
|
||||||
public:
|
return nullptr; // Ignore
|
||||||
explicit SessionDescription(std::unique_ptr<webrtc::SessionDescriptionInterface> session_description);
|
}
|
||||||
|
|
||||||
rust::String stringify() const;
|
class SessionDescription {
|
||||||
std::unique_ptr<SessionDescription> clone() const;
|
public:
|
||||||
std::unique_ptr<webrtc::SessionDescriptionInterface> release();
|
explicit SessionDescription(
|
||||||
|
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description);
|
||||||
|
|
||||||
private:
|
rust::String stringify() const;
|
||||||
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description_;
|
std::unique_ptr<SessionDescription> clone() const;
|
||||||
};
|
std::unique_ptr<webrtc::SessionDescriptionInterface> release();
|
||||||
|
|
||||||
static std::unique_ptr<SessionDescription> _unique_session_description(){
|
private:
|
||||||
return nullptr; // Ignore
|
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description_;
|
||||||
}
|
};
|
||||||
|
|
||||||
// SetCreateSdpObserver
|
static std::unique_ptr<SessionDescription> _unique_session_description() {
|
||||||
|
return nullptr; // Ignore
|
||||||
|
}
|
||||||
|
|
||||||
class NativeCreateSdpObserver : public webrtc::CreateSessionDescriptionObserver {
|
// SetCreateSdpObserver
|
||||||
public:
|
|
||||||
explicit NativeCreateSdpObserver(rust::Box<CreateSdpObserverWrapper> observer);
|
|
||||||
|
|
||||||
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
|
class NativeCreateSdpObserver
|
||||||
void OnFailure(webrtc::RTCError error) override;
|
: public webrtc::CreateSessionDescriptionObserver {
|
||||||
private:
|
public:
|
||||||
rust::Box<CreateSdpObserverWrapper> observer_;
|
explicit NativeCreateSdpObserver(
|
||||||
};
|
rust::Box<CreateSdpObserverWrapper> observer);
|
||||||
|
|
||||||
struct NativeCreateSdpObserverHandle {
|
void OnSuccess(webrtc::SessionDescriptionInterface* desc) override;
|
||||||
rtc::scoped_refptr<NativeCreateSdpObserver> observer;
|
void OnFailure(webrtc::RTCError error) override;
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativeCreateSdpObserverHandle> create_native_create_sdp_observer(rust::Box<CreateSdpObserverWrapper> observer);
|
private:
|
||||||
|
rust::Box<CreateSdpObserverWrapper> observer_;
|
||||||
|
};
|
||||||
|
|
||||||
// SetLocalSdpObserver
|
struct NativeCreateSdpObserverHandle {
|
||||||
|
rtc::scoped_refptr<NativeCreateSdpObserver> observer;
|
||||||
|
};
|
||||||
|
|
||||||
class NativeSetLocalSdpObserver : public webrtc::SetLocalDescriptionObserverInterface{
|
std::unique_ptr<NativeCreateSdpObserverHandle>
|
||||||
public:
|
create_native_create_sdp_observer(rust::Box<CreateSdpObserverWrapper> observer);
|
||||||
explicit NativeSetLocalSdpObserver(rust::Box<SetLocalSdpObserverWrapper> observer);
|
|
||||||
|
|
||||||
void OnSetLocalDescriptionComplete(webrtc::RTCError error) override;
|
// SetLocalSdpObserver
|
||||||
private:
|
|
||||||
rust::Box<SetLocalSdpObserverWrapper> observer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct NativeSetLocalSdpObserverHandle {
|
class NativeSetLocalSdpObserver
|
||||||
rtc::scoped_refptr<NativeSetLocalSdpObserver> observer;
|
: public webrtc::SetLocalDescriptionObserverInterface {
|
||||||
};
|
public:
|
||||||
|
explicit NativeSetLocalSdpObserver(
|
||||||
|
rust::Box<SetLocalSdpObserverWrapper> observer);
|
||||||
|
|
||||||
std::unique_ptr<NativeSetLocalSdpObserverHandle> create_native_set_local_sdp_observer(rust::Box<SetLocalSdpObserverWrapper> observer);
|
void OnSetLocalDescriptionComplete(webrtc::RTCError error) override;
|
||||||
|
|
||||||
// SetRemoteSdpObserver
|
private:
|
||||||
|
rust::Box<SetLocalSdpObserverWrapper> observer_;
|
||||||
|
};
|
||||||
|
|
||||||
class NativeSetRemoteSdpObserver : public webrtc::SetRemoteDescriptionObserverInterface{
|
struct NativeSetLocalSdpObserverHandle {
|
||||||
public:
|
rtc::scoped_refptr<NativeSetLocalSdpObserver> observer;
|
||||||
explicit NativeSetRemoteSdpObserver(rust::Box<SetRemoteSdpObserverWrapper> observer);
|
};
|
||||||
|
|
||||||
void OnSetRemoteDescriptionComplete(webrtc::RTCError error) override;
|
std::unique_ptr<NativeSetLocalSdpObserverHandle>
|
||||||
private:
|
create_native_set_local_sdp_observer(
|
||||||
rust::Box<SetRemoteSdpObserverWrapper> observer_;
|
rust::Box<SetLocalSdpObserverWrapper> observer);
|
||||||
};
|
|
||||||
|
|
||||||
struct NativeSetRemoteSdpObserverHandle {
|
// SetRemoteSdpObserver
|
||||||
rtc::scoped_refptr<NativeSetRemoteSdpObserver> observer;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativeSetRemoteSdpObserverHandle> create_native_set_remote_sdp_observer(rust::Box<SetRemoteSdpObserverWrapper> observer);
|
class NativeSetRemoteSdpObserver
|
||||||
} // livekit
|
: public webrtc::SetRemoteDescriptionObserverInterface {
|
||||||
|
public:
|
||||||
|
explicit NativeSetRemoteSdpObserver(
|
||||||
|
rust::Box<SetRemoteSdpObserverWrapper> observer);
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_JSEP_H
|
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
|
||||||
|
|||||||
@@ -6,21 +6,23 @@
|
|||||||
#define CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
|
#define CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/media_stream_interface.h"
|
#include "api/media_stream_interface.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class MediaStreamInterface {
|
class MediaStreamInterface {
|
||||||
public:
|
public:
|
||||||
explicit MediaStreamInterface(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
|
explicit MediaStreamInterface(
|
||||||
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> media_stream_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<MediaStreamInterface> _unique_media_stream(){
|
static std::unique_ptr<MediaStreamInterface> _unique_media_stream() {
|
||||||
return nullptr; // Ignore
|
return nullptr; // Ignore
|
||||||
}
|
}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
|
#endif // CLIENT_SDK_NATIVE_MEDIA_STREAM_INTERFACE_H
|
||||||
|
|||||||
@@ -6,76 +6,128 @@
|
|||||||
#define CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
#define CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/peer_connection_interface.h"
|
#include "api/peer_connection_interface.h"
|
||||||
#include "rust/cxx.h"
|
|
||||||
#include "data_channel.h"
|
#include "data_channel.h"
|
||||||
#include "jsep.h"
|
#include "jsep.h"
|
||||||
|
#include "rust/cxx.h"
|
||||||
#include "rust_types.h"
|
#include "rust_types.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
class NativeAddIceCandidateObserver;
|
class NativeAddIceCandidateObserver;
|
||||||
|
|
||||||
class PeerConnection {
|
class PeerConnection {
|
||||||
public:
|
public:
|
||||||
explicit PeerConnection(rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
|
explicit PeerConnection(
|
||||||
|
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection);
|
||||||
|
|
||||||
void create_offer(NativeCreateSdpObserverHandle &observer, RTCOfferAnswerOptions options);
|
void create_offer(NativeCreateSdpObserverHandle& observer,
|
||||||
void create_answer(NativeCreateSdpObserverHandle &observer, RTCOfferAnswerOptions options);
|
RTCOfferAnswerOptions options);
|
||||||
void set_local_description(std::unique_ptr<SessionDescription> desc, NativeSetLocalSdpObserverHandle &observer);
|
void create_answer(NativeCreateSdpObserverHandle& observer,
|
||||||
void set_remote_description(std::unique_ptr<SessionDescription> desc, NativeSetRemoteSdpObserverHandle &observer);
|
RTCOfferAnswerOptions options);
|
||||||
std::unique_ptr<DataChannel> create_data_channel(rust::String label, std::unique_ptr<NativeDataChannelInit> init);
|
void set_local_description(std::unique_ptr<SessionDescription> desc,
|
||||||
void add_ice_candidate(std::unique_ptr<IceCandidate> candidate, NativeAddIceCandidateObserver &observer);
|
NativeSetLocalSdpObserverHandle& observer);
|
||||||
void close();
|
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);
|
||||||
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
|
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<PeerConnection> _unique_peer_connection() {
|
static std::unique_ptr<PeerConnection> _unique_peer_connection() {
|
||||||
return nullptr; // Ignore
|
return nullptr; // Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
class NativeAddIceCandidateObserver {
|
class NativeAddIceCandidateObserver {
|
||||||
public:
|
public:
|
||||||
explicit NativeAddIceCandidateObserver(rust::Box<AddIceCandidateObserverWrapper> observer);
|
explicit NativeAddIceCandidateObserver(
|
||||||
|
rust::Box<AddIceCandidateObserverWrapper> observer);
|
||||||
|
|
||||||
void OnComplete(const RTCError &error);
|
void OnComplete(const RTCError& error);
|
||||||
private:
|
|
||||||
rust::Box<AddIceCandidateObserverWrapper> observer_;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativeAddIceCandidateObserver> create_native_add_ice_candidate_observer(rust::Box<AddIceCandidateObserverWrapper> observer);
|
private:
|
||||||
|
rust::Box<AddIceCandidateObserverWrapper> observer_;
|
||||||
|
};
|
||||||
|
|
||||||
class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver {
|
std::unique_ptr<NativeAddIceCandidateObserver>
|
||||||
public:
|
create_native_add_ice_candidate_observer(
|
||||||
explicit NativePeerConnectionObserver(rust::Box<PeerConnectionObserverWrapper> observer);
|
rust::Box<AddIceCandidateObserverWrapper> observer);
|
||||||
|
|
||||||
void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override;
|
class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver {
|
||||||
void OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
|
public:
|
||||||
void OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
|
explicit NativePeerConnectionObserver(
|
||||||
void OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) override;
|
rust::Box<PeerConnectionObserverWrapper> observer);
|
||||||
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:
|
void OnSignalingChange(
|
||||||
rust::Box<PeerConnectionObserverWrapper> observer_;
|
webrtc::PeerConnectionInterface::SignalingState new_state) override;
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<NativePeerConnectionObserver> create_native_peer_connection_observer(rust::Box<PeerConnectionObserverWrapper> observer);
|
void OnAddStream(
|
||||||
} // livekit
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) override;
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
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:
|
||||||
|
rust::Box<PeerConnectionObserverWrapper> observer_;
|
||||||
|
};
|
||||||
|
|
||||||
|
std::unique_ptr<NativePeerConnectionObserver>
|
||||||
|
create_native_peer_connection_observer(
|
||||||
|
rust::Box<PeerConnectionObserverWrapper> observer);
|
||||||
|
} // namespace livekit
|
||||||
|
|
||||||
|
#endif // CLIENT_SDK_NATIVE_PEER_CONNECTION_H
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// Created by Théo Monnom on 03/08/2022.
|
// Created by Théo Monnom on 03/08/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef PEER_CONNECTION_FACTORY_H
|
#ifndef PEER_CONNECTION_FACTORY_H
|
||||||
#define PEER_CONNECTION_FACTORY_H
|
#define PEER_CONNECTION_FACTORY_H
|
||||||
|
|
||||||
@@ -11,25 +10,28 @@
|
|||||||
#include "rust_types.h"
|
#include "rust_types.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
using NativeRTCConfiguration = webrtc::PeerConnectionInterface::RTCConfiguration;
|
using NativeRTCConfiguration =
|
||||||
|
webrtc::PeerConnectionInterface::RTCConfiguration;
|
||||||
|
|
||||||
class PeerConnectionFactory {
|
class PeerConnectionFactory {
|
||||||
public:
|
public:
|
||||||
PeerConnectionFactory();
|
PeerConnectionFactory();
|
||||||
|
|
||||||
std::unique_ptr<PeerConnection> create_peer_connection(std::unique_ptr<NativeRTCConfiguration> config, NativePeerConnectionObserver &observer) const;
|
std::unique_ptr<PeerConnection> create_peer_connection(
|
||||||
|
std::unique_ptr<NativeRTCConfiguration> config,
|
||||||
|
NativePeerConnectionObserver& observer) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<rtc::Thread> network_thread_;
|
std::unique_ptr<rtc::Thread> network_thread_;
|
||||||
std::unique_ptr<rtc::Thread> worker_thread_;
|
std::unique_ptr<rtc::Thread> worker_thread_;
|
||||||
std::unique_ptr<rtc::Thread> signaling_thread_;
|
std::unique_ptr<rtc::Thread> signaling_thread_;
|
||||||
|
|
||||||
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
|
rtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory();
|
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory();
|
||||||
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(RTCConfiguration conf);
|
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(
|
||||||
} // livekit
|
RTCConfiguration conf);
|
||||||
|
} // namespace livekit
|
||||||
|
|
||||||
|
#endif // PEER_CONNECTION_FACTORY_H
|
||||||
#endif //PEER_CONNECTION_FACTORY_H
|
|
||||||
|
|||||||
@@ -7,19 +7,20 @@
|
|||||||
|
|
||||||
#include "api/rtc_error.h"
|
#include "api/rtc_error.h"
|
||||||
#include "libwebrtc-sys/src/rtc_error.rs.h"
|
#include "libwebrtc-sys/src/rtc_error.rs.h"
|
||||||
#include "rust_types.h"
|
|
||||||
#include "rust/cxx.h"
|
#include "rust/cxx.h"
|
||||||
|
#include "rust_types.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
RTCError to_error(const webrtc::RTCError &error);
|
RTCError to_error(const webrtc::RTCError& error);
|
||||||
std::string serialize_error(const RTCError &error); // to be used inside cxx::Exception msg
|
std::string serialize_error(
|
||||||
|
const RTCError& error); // to be used inside cxx::Exception msg
|
||||||
|
|
||||||
#ifdef LIVEKIT_TEST
|
#ifdef LIVEKIT_TEST
|
||||||
rust::String serialize_deserialize();
|
rust::String serialize_deserialize();
|
||||||
void throw_error();
|
void throw_error();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_RTC_ERROR_H
|
#endif // CLIENT_SDK_NATIVE_RTC_ERROR_H
|
||||||
|
|||||||
@@ -6,21 +6,23 @@
|
|||||||
#define CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
#define CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/rtp_receiver_interface.h"
|
#include "api/rtp_receiver_interface.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class RtpReceiver {
|
class RtpReceiver {
|
||||||
public:
|
public:
|
||||||
explicit RtpReceiver(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver);
|
explicit RtpReceiver(
|
||||||
|
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver_;
|
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<RtpReceiver> _unique_rtp_receiver(){
|
static std::unique_ptr<RtpReceiver> _unique_rtp_receiver() {
|
||||||
return nullptr; // Ignore
|
return nullptr; // Ignore
|
||||||
}
|
}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
#endif // CLIENT_SDK_NATIVE_RTP_RECEIVER_H
|
||||||
|
|||||||
@@ -6,21 +6,23 @@
|
|||||||
#define CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
#define CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "api/rtp_transceiver_interface.h"
|
#include "api/rtp_transceiver_interface.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class RtpTransceiver {
|
class RtpTransceiver {
|
||||||
public:
|
public:
|
||||||
explicit RtpTransceiver(rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver);
|
explicit RtpTransceiver(
|
||||||
|
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver_;
|
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver_;
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::unique_ptr<RtpTransceiver> _unique_rtp_transceiver(){
|
static std::unique_ptr<RtpTransceiver> _unique_rtp_transceiver() {
|
||||||
return nullptr; // Ignore
|
return nullptr; // Ignore
|
||||||
}
|
}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
#endif // CLIENT_SDK_NATIVE_RTP_TRANSCEIVER_H
|
||||||
|
|||||||
@@ -2,26 +2,25 @@
|
|||||||
// Created by Théo Monnom on 30/08/2022.
|
// Created by Théo Monnom on 30/08/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef RUST_TYPES_H
|
#ifndef RUST_TYPES_H
|
||||||
#define RUST_TYPES_H
|
#define RUST_TYPES_H
|
||||||
|
|
||||||
#include "api/peer_connection_interface.h"
|
#include "api/peer_connection_interface.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
struct RTCConfiguration;
|
struct RTCConfiguration;
|
||||||
struct PeerConnectionObserverWrapper;
|
struct PeerConnectionObserverWrapper;
|
||||||
struct CreateSdpObserverWrapper;
|
struct CreateSdpObserverWrapper;
|
||||||
struct SetLocalSdpObserverWrapper;
|
struct SetLocalSdpObserverWrapper;
|
||||||
struct SetRemoteSdpObserverWrapper;
|
struct SetRemoteSdpObserverWrapper;
|
||||||
struct DataChannelObserverWrapper;
|
struct DataChannelObserverWrapper;
|
||||||
struct AddIceCandidateObserverWrapper;
|
struct AddIceCandidateObserverWrapper;
|
||||||
|
|
||||||
// Shared types
|
// Shared types
|
||||||
struct RTCOfferAnswerOptions;
|
struct RTCOfferAnswerOptions;
|
||||||
struct RTCError;
|
struct RTCError;
|
||||||
struct DataChannelInit;
|
struct DataChannelInit;
|
||||||
struct DataBuffer;
|
struct DataBuffer;
|
||||||
}
|
} // namespace livekit
|
||||||
|
|
||||||
#endif //RUST_TYPES_H
|
#endif // RUST_TYPES_H
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
#ifndef LIVEKIT_WEBRTC_WEBRTC_H
|
#ifndef LIVEKIT_WEBRTC_WEBRTC_H
|
||||||
#define LIVEKIT_WEBRTC_WEBRTC_H
|
#define LIVEKIT_WEBRTC_WEBRTC_H
|
||||||
|
|
||||||
#include "rtc_base/ssl_adapter.h"
|
|
||||||
#include "rtc_base/physical_socket_server.h"
|
#include "rtc_base/physical_socket_server.h"
|
||||||
|
#include "rtc_base/ssl_adapter.h"
|
||||||
|
|
||||||
#ifdef WEBRTC_WIN
|
#ifdef WEBRTC_WIN
|
||||||
#include "rtc_base/win32_socket_init.h"
|
#include "rtc_base/win32_socket_init.h"
|
||||||
@@ -14,21 +14,22 @@
|
|||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
class RTCRuntime {
|
class RTCRuntime {
|
||||||
public:
|
public:
|
||||||
RTCRuntime();
|
RTCRuntime();
|
||||||
~RTCRuntime();
|
~RTCRuntime();
|
||||||
|
|
||||||
RTCRuntime(const RTCRuntime&) = delete;
|
RTCRuntime(const RTCRuntime&) = delete;
|
||||||
RTCRuntime& operator=(const RTCRuntime&) = delete;
|
RTCRuntime& operator=(const RTCRuntime&) = delete;
|
||||||
private:
|
|
||||||
#ifdef WEBRTC_WIN
|
|
||||||
rtc::WinsockInitializer winsock_;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
std::unique_ptr<RTCRuntime> create_rtc_runtime();
|
private:
|
||||||
|
#ifdef WEBRTC_WIN
|
||||||
|
rtc::WinsockInitializer winsock_;
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
} // livekit
|
std::unique_ptr<RTCRuntime> create_rtc_runtime();
|
||||||
|
|
||||||
#endif //LIVEKIT_WEBRTC_WEBRTC_H
|
} // namespace livekit
|
||||||
|
|
||||||
|
#endif // LIVEKIT_WEBRTC_WEBRTC_H
|
||||||
|
|||||||
@@ -5,7 +5,6 @@
|
|||||||
#include "livekit/candidate.h"
|
#include "livekit/candidate.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
Candidate::Candidate(const cricket::Candidate &candidate) : candidate_(candidate) {
|
Candidate::Candidate(const cricket::Candidate& candidate)
|
||||||
|
: candidate_(candidate) {}
|
||||||
}
|
} // namespace livekit
|
||||||
} // livekit
|
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
use cxx::UniquePtr;
|
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
|
|||||||
@@ -2,78 +2,83 @@
|
|||||||
// Created by Théo Monnom on 01/09/2022.
|
// Created by Théo Monnom on 01/09/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "livekit/data_channel.h"
|
||||||
|
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include "livekit/data_channel.h"
|
|
||||||
#include "libwebrtc-sys/src/data_channel.rs.h"
|
#include "libwebrtc-sys/src/data_channel.rs.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
DataChannel::DataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) : data_channel_(std::move(data_channel)) {
|
DataChannel::DataChannel(
|
||||||
|
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel)
|
||||||
|
: data_channel_(std::move(data_channel)) {}
|
||||||
|
|
||||||
}
|
void DataChannel::register_observer(NativeDataChannelObserver& observer) {
|
||||||
|
data_channel_->RegisterObserver(&observer);
|
||||||
|
}
|
||||||
|
|
||||||
void DataChannel::register_observer(NativeDataChannelObserver &observer) {
|
void DataChannel::unregister_observer() {
|
||||||
data_channel_->RegisterObserver(&observer);
|
data_channel_->UnregisterObserver();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataChannel::unregister_observer() {
|
bool DataChannel::send(const DataBuffer& buffer) {
|
||||||
data_channel_->UnregisterObserver();
|
return data_channel_->Send(webrtc::DataBuffer{
|
||||||
}
|
rtc::CopyOnWriteBuffer(buffer.ptr, buffer.len), buffer.binary});
|
||||||
|
}
|
||||||
|
|
||||||
bool DataChannel::send(const DataBuffer &buffer) {
|
rust::String DataChannel::label() const {
|
||||||
return data_channel_->Send(webrtc::DataBuffer{rtc::CopyOnWriteBuffer(buffer.ptr, buffer.len), buffer.binary });
|
return data_channel_->label();
|
||||||
}
|
}
|
||||||
|
|
||||||
rust::String DataChannel::label() const{
|
void DataChannel::close() {
|
||||||
return data_channel_->label();
|
return data_channel_->Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DataChannel::close() {
|
std::unique_ptr<NativeDataChannelInit> create_data_channel_init(
|
||||||
return data_channel_->Close();
|
DataChannelInit init) {
|
||||||
}
|
auto rtc_init = std::make_unique<webrtc::DataChannelInit>();
|
||||||
|
rtc_init->id = init.id;
|
||||||
|
rtc_init->negotiated = init.negotiated;
|
||||||
|
rtc_init->ordered = init.ordered;
|
||||||
|
rtc_init->protocol = init.protocol.c_str();
|
||||||
|
rtc_init->reliable = init.reliable;
|
||||||
|
|
||||||
std::unique_ptr<NativeDataChannelInit> create_data_channel_init(DataChannelInit init) {
|
if (init.has_max_retransmit_time)
|
||||||
auto rtc_init = std::make_unique<webrtc::DataChannelInit>();
|
rtc_init->maxRetransmitTime = init.max_retransmit_time;
|
||||||
rtc_init->id = init.id;
|
|
||||||
rtc_init->negotiated = init.negotiated;
|
|
||||||
rtc_init->ordered = init.ordered;
|
|
||||||
rtc_init->protocol = init.protocol.c_str();
|
|
||||||
rtc_init->reliable = init.reliable;
|
|
||||||
|
|
||||||
if(init.has_max_retransmit_time)
|
if (init.has_max_retransmits)
|
||||||
rtc_init->maxRetransmitTime = init.max_retransmit_time;
|
rtc_init->maxRetransmits = init.max_retransmits;
|
||||||
|
|
||||||
if(init.has_max_retransmits)
|
if (init.has_priority)
|
||||||
rtc_init->maxRetransmits = init.max_retransmits;
|
rtc_init->priority = static_cast<webrtc::Priority>(init.priority);
|
||||||
|
|
||||||
if(init.has_priority)
|
return rtc_init;
|
||||||
rtc_init->priority = static_cast<webrtc::Priority>(init.priority);
|
}
|
||||||
|
|
||||||
return rtc_init;
|
NativeDataChannelObserver::NativeDataChannelObserver(
|
||||||
}
|
rust::Box<DataChannelObserverWrapper> observer)
|
||||||
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
NativeDataChannelObserver::NativeDataChannelObserver(rust::Box<DataChannelObserverWrapper> observer) : observer_(std::move(observer)){
|
void NativeDataChannelObserver::OnStateChange() {
|
||||||
|
observer_->on_state_change();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
void NativeDataChannelObserver::OnMessage(const webrtc::DataBuffer& buffer) {
|
||||||
|
DataBuffer data{};
|
||||||
|
data.ptr = buffer.data.data();
|
||||||
|
data.len = buffer.data.size();
|
||||||
|
data.binary = buffer.binary;
|
||||||
|
observer_->on_message(data);
|
||||||
|
}
|
||||||
|
|
||||||
void NativeDataChannelObserver::OnStateChange() {
|
void NativeDataChannelObserver::OnBufferedAmountChange(
|
||||||
observer_->on_state_change();
|
uint64_t sent_data_size) {
|
||||||
}
|
observer_->on_buffered_amount_change(sent_data_size);
|
||||||
|
}
|
||||||
|
|
||||||
void NativeDataChannelObserver::OnMessage(const webrtc::DataBuffer &buffer) {
|
std::unique_ptr<NativeDataChannelObserver> create_native_data_channel_observer(
|
||||||
DataBuffer data{};
|
rust::Box<DataChannelObserverWrapper> observer) {
|
||||||
data.ptr = buffer.data.data();
|
return std::make_unique<NativeDataChannelObserver>(std::move(observer));
|
||||||
data.len = buffer.data.size();
|
}
|
||||||
data.binary = buffer.binary;
|
} // namespace livekit
|
||||||
observer_->on_message(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeDataChannelObserver::OnBufferedAmountChange(uint64_t sent_data_size) {
|
|
||||||
observer_->on_buffered_amount_change(sent_data_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<NativeDataChannelObserver> create_native_data_channel_observer(rust::Box<DataChannelObserverWrapper> observer){
|
|
||||||
return std::make_unique<NativeDataChannelObserver>(std::move(observer));
|
|
||||||
}
|
|
||||||
} // livekit
|
|
||||||
@@ -1,9 +1,7 @@
|
|||||||
use cxx::UniquePtr;
|
|
||||||
use std::slice;
|
use std::slice;
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum Priority {
|
pub enum Priority {
|
||||||
@@ -83,6 +81,7 @@ pub mod ffi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsafe impl Send for ffi::DataChannel {}
|
unsafe impl Send for ffi::DataChannel {}
|
||||||
|
|
||||||
unsafe impl Send for ffi::NativeDataChannelObserver {}
|
unsafe impl Send for ffi::NativeDataChannelObserver {}
|
||||||
|
|
||||||
// DataChannelObserver
|
// DataChannelObserver
|
||||||
|
|||||||
@@ -2,93 +2,106 @@
|
|||||||
// Created by Théo Monnom on 01/09/2022.
|
// Created by Théo Monnom on 01/09/2022.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
#include "livekit/jsep.h"
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#include "livekit/rtc_error.h"
|
|
||||||
#include "livekit/jsep.h"
|
|
||||||
#include "libwebrtc-sys/src/jsep.rs.h"
|
#include "libwebrtc-sys/src/jsep.rs.h"
|
||||||
|
#include "livekit/rtc_error.h"
|
||||||
#include "rtc_base/ref_counted_object.h"
|
#include "rtc_base/ref_counted_object.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
IceCandidate::IceCandidate(std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate) : ice_candidate_(std::move(ice_candidate)){
|
IceCandidate::IceCandidate(
|
||||||
|
std::unique_ptr<webrtc::IceCandidateInterface> ice_candidate)
|
||||||
|
: ice_candidate_(std::move(ice_candidate)) {}
|
||||||
|
|
||||||
}
|
std::unique_ptr<webrtc::IceCandidateInterface> IceCandidate::release() {
|
||||||
|
return std::move(ice_candidate_);
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<webrtc::IceCandidateInterface> IceCandidate::release() {
|
SessionDescription::SessionDescription(
|
||||||
return std::move(ice_candidate_);
|
std::unique_ptr<webrtc::SessionDescriptionInterface> session_description)
|
||||||
}
|
: session_description_(std::move(session_description)) {}
|
||||||
|
|
||||||
SessionDescription::SessionDescription(std::unique_ptr<webrtc::SessionDescriptionInterface> session_description) : session_description_(std::move(session_description)){
|
rust::String SessionDescription::stringify() const {
|
||||||
|
std::string str;
|
||||||
|
session_description_->ToString(&str);
|
||||||
|
return rust::String{str};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
std::unique_ptr<SessionDescription> SessionDescription::clone() const {
|
||||||
|
return std::make_unique<SessionDescription>(session_description_->Clone());
|
||||||
|
}
|
||||||
|
|
||||||
rust::String SessionDescription::stringify() const {
|
std::unique_ptr<webrtc::SessionDescriptionInterface>
|
||||||
std::string str;
|
SessionDescription::release() {
|
||||||
session_description_->ToString(&str);
|
return std::move(session_description_);
|
||||||
return rust::String{str};
|
}
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<SessionDescription> SessionDescription::clone() const {
|
// CreateSdpObserver
|
||||||
return std::make_unique<SessionDescription>(session_description_->Clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<webrtc::SessionDescriptionInterface> SessionDescription::release() {
|
NativeCreateSdpObserver::NativeCreateSdpObserver(
|
||||||
return std::move(session_description_);
|
rust::Box<CreateSdpObserverWrapper> observer)
|
||||||
}
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
// CreateSdpObserver
|
void NativeCreateSdpObserver::OnSuccess(
|
||||||
|
webrtc::SessionDescriptionInterface* desc) {
|
||||||
|
// We have ownership of desc
|
||||||
|
observer_->on_success(std::make_unique<SessionDescription>(
|
||||||
|
std::unique_ptr<webrtc::SessionDescriptionInterface>(desc)));
|
||||||
|
}
|
||||||
|
|
||||||
NativeCreateSdpObserver::NativeCreateSdpObserver(
|
void NativeCreateSdpObserver::OnFailure(webrtc::RTCError error) {
|
||||||
rust::Box<CreateSdpObserverWrapper> observer) : observer_(std::move(observer)) {
|
observer_->on_failure(to_error(error));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
std::unique_ptr<NativeCreateSdpObserverHandle>
|
||||||
|
create_native_create_sdp_observer(
|
||||||
|
rust::Box<CreateSdpObserverWrapper> observer) {
|
||||||
|
return std::make_unique<NativeCreateSdpObserverHandle>(
|
||||||
|
NativeCreateSdpObserverHandle{
|
||||||
|
rtc::make_ref_counted<NativeCreateSdpObserver>(std::move(observer))});
|
||||||
|
}
|
||||||
|
|
||||||
void NativeCreateSdpObserver::OnSuccess(webrtc::SessionDescriptionInterface *desc) {
|
// SetLocalSdpObserver
|
||||||
// We have ownership of desc
|
|
||||||
observer_->on_success(std::make_unique<SessionDescription>(std::unique_ptr<webrtc::SessionDescriptionInterface>(desc)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeCreateSdpObserver::OnFailure(webrtc::RTCError error) {
|
NativeSetLocalSdpObserver::NativeSetLocalSdpObserver(
|
||||||
observer_->on_failure(to_error(error));
|
rust::Box<SetLocalSdpObserverWrapper> observer)
|
||||||
}
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
std::unique_ptr<NativeCreateSdpObserverHandle> create_native_create_sdp_observer(rust::Box<CreateSdpObserverWrapper> observer){
|
void NativeSetLocalSdpObserver::OnSetLocalDescriptionComplete(
|
||||||
return std::make_unique<NativeCreateSdpObserverHandle>(NativeCreateSdpObserverHandle {
|
webrtc::RTCError error) {
|
||||||
rtc::make_ref_counted<NativeCreateSdpObserver>(std::move(observer))
|
observer_->on_set_local_description_complete(to_error(error));
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// SetLocalSdpObserver
|
std::unique_ptr<NativeSetLocalSdpObserverHandle>
|
||||||
|
create_native_set_local_sdp_observer(
|
||||||
|
rust::Box<SetLocalSdpObserverWrapper> observer) {
|
||||||
|
return std::make_unique<NativeSetLocalSdpObserverHandle>(
|
||||||
|
NativeSetLocalSdpObserverHandle{
|
||||||
|
rtc::make_ref_counted<NativeSetLocalSdpObserver>(
|
||||||
|
std::move(observer))});
|
||||||
|
}
|
||||||
|
|
||||||
NativeSetLocalSdpObserver::NativeSetLocalSdpObserver(rust::Box<SetLocalSdpObserverWrapper> observer) : observer_(std::move(observer)) {
|
// SetRemoteSdpObserver
|
||||||
|
|
||||||
}
|
NativeSetRemoteSdpObserver::NativeSetRemoteSdpObserver(
|
||||||
|
rust::Box<SetRemoteSdpObserverWrapper> observer)
|
||||||
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
void NativeSetLocalSdpObserver::OnSetLocalDescriptionComplete(webrtc::RTCError error) {
|
void NativeSetRemoteSdpObserver::OnSetRemoteDescriptionComplete(
|
||||||
observer_->on_set_local_description_complete(to_error(error));
|
webrtc::RTCError error) {
|
||||||
}
|
observer_->on_set_remote_description_complete(to_error(error));
|
||||||
|
}
|
||||||
|
|
||||||
std::unique_ptr<NativeSetLocalSdpObserverHandle> create_native_set_local_sdp_observer(rust::Box<SetLocalSdpObserverWrapper> observer){
|
std::unique_ptr<NativeSetRemoteSdpObserverHandle>
|
||||||
return std::make_unique<NativeSetLocalSdpObserverHandle>(NativeSetLocalSdpObserverHandle {
|
create_native_set_remote_sdp_observer(
|
||||||
rtc::make_ref_counted<NativeSetLocalSdpObserver>(std::move(observer))
|
rust::Box<SetRemoteSdpObserverWrapper> observer) {
|
||||||
});
|
return std::make_unique<NativeSetRemoteSdpObserverHandle>(
|
||||||
}
|
NativeSetRemoteSdpObserverHandle{
|
||||||
|
rtc::make_ref_counted<NativeSetRemoteSdpObserver>(
|
||||||
|
std::move(observer))});
|
||||||
|
}
|
||||||
|
|
||||||
// SetRemoteSdpObserver
|
} // namespace livekit
|
||||||
|
|
||||||
NativeSetRemoteSdpObserver::NativeSetRemoteSdpObserver(rust::Box<SetRemoteSdpObserverWrapper> observer) : observer_(std::move(observer)) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativeSetRemoteSdpObserver::OnSetRemoteDescriptionComplete(webrtc::RTCError error) {
|
|
||||||
observer_->on_set_remote_description_complete(to_error(error));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<NativeSetRemoteSdpObserverHandle> create_native_set_remote_sdp_observer(rust::Box<SetRemoteSdpObserverWrapper> observer){
|
|
||||||
return std::make_unique<NativeSetRemoteSdpObserverHandle>(NativeSetRemoteSdpObserverHandle {
|
|
||||||
rtc::make_ref_counted<NativeSetRemoteSdpObserver>(std::move(observer))
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
} // livekit
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
use cxx::UniquePtr;
|
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
|
|
||||||
|
use cxx::UniquePtr;
|
||||||
|
|
||||||
use crate::rtc_error::ffi::RTCError;
|
use crate::rtc_error::ffi::RTCError;
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
|
|
||||||
extern "Rust" {
|
extern "Rust" {
|
||||||
type CreateSdpObserverWrapper;
|
type CreateSdpObserverWrapper;
|
||||||
fn on_success(
|
fn on_success(
|
||||||
@@ -46,7 +46,7 @@ pub mod ffi {
|
|||||||
) -> UniquePtr<NativeSetRemoteSdpObserverHandle>;
|
) -> UniquePtr<NativeSetRemoteSdpObserverHandle>;
|
||||||
|
|
||||||
fn _unique_ice_candidate() -> UniquePtr<IceCandidate>; // Ignore
|
fn _unique_ice_candidate() -> UniquePtr<IceCandidate>; // Ignore
|
||||||
fn _unique_session_description() -> UniquePtr<SessionDescription>; // Ignore
|
fn _unique_session_description() -> UniquePtr<SessionDescription>; // Ignore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
MediaStreamInterface::MediaStreamInterface(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) : media_stream_(std::move(stream)) {
|
MediaStreamInterface::MediaStreamInterface(
|
||||||
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream)
|
||||||
}
|
: media_stream_(std::move(stream)) {}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
@@ -1,5 +1,3 @@
|
|||||||
use cxx::UniquePtr;
|
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
unsafe extern "C++" {
|
unsafe extern "C++" {
|
||||||
|
|||||||
@@ -3,193 +3,234 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "livekit/peer_connection.h"
|
#include "livekit/peer_connection.h"
|
||||||
|
|
||||||
#include "libwebrtc-sys/src/peer_connection.rs.h"
|
#include "libwebrtc-sys/src/peer_connection.rs.h"
|
||||||
#include "livekit/rtc_error.h"
|
#include "livekit/rtc_error.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
inline webrtc::PeerConnectionInterface::RTCOfferAnswerOptions toNativeOfferAnswerOptions(const RTCOfferAnswerOptions& options) {
|
inline webrtc::PeerConnectionInterface::RTCOfferAnswerOptions
|
||||||
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions rtc_options;
|
toNativeOfferAnswerOptions(const RTCOfferAnswerOptions& options) {
|
||||||
rtc_options.offer_to_receive_video = options.offer_to_receive_video;
|
webrtc::PeerConnectionInterface::RTCOfferAnswerOptions rtc_options;
|
||||||
rtc_options.offer_to_receive_audio = options.offer_to_receive_audio;
|
rtc_options.offer_to_receive_video = options.offer_to_receive_video;
|
||||||
rtc_options.voice_activity_detection = options.voice_activity_detection;
|
rtc_options.offer_to_receive_audio = options.offer_to_receive_audio;
|
||||||
rtc_options.ice_restart = options.ice_restart;
|
rtc_options.voice_activity_detection = options.voice_activity_detection;
|
||||||
rtc_options.use_rtp_mux = options.use_rtp_mux;
|
rtc_options.ice_restart = options.ice_restart;
|
||||||
rtc_options.raw_packetization_for_video = options.raw_packetization_for_video;
|
rtc_options.use_rtp_mux = options.use_rtp_mux;
|
||||||
rtc_options.num_simulcast_layers = options.num_simulcast_layers;
|
rtc_options.raw_packetization_for_video = options.raw_packetization_for_video;
|
||||||
rtc_options.use_obsolete_sctp_sdp = options.use_obsolete_sctp_sdp;
|
rtc_options.num_simulcast_layers = options.num_simulcast_layers;
|
||||||
return rtc_options;
|
rtc_options.use_obsolete_sctp_sdp = options.use_obsolete_sctp_sdp;
|
||||||
}
|
return rtc_options;
|
||||||
|
}
|
||||||
|
|
||||||
PeerConnection::PeerConnection(rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection) : peer_connection_(std::move(peer_connection)) {
|
PeerConnection::PeerConnection(
|
||||||
|
rtc::scoped_refptr<webrtc::PeerConnectionInterface> peer_connection)
|
||||||
|
: peer_connection_(std::move(peer_connection)) {}
|
||||||
|
|
||||||
}
|
void PeerConnection::create_offer(
|
||||||
|
NativeCreateSdpObserverHandle& observer_handle,
|
||||||
|
RTCOfferAnswerOptions options) {
|
||||||
|
peer_connection_->CreateOffer(observer_handle.observer.get(),
|
||||||
|
toNativeOfferAnswerOptions(options));
|
||||||
|
}
|
||||||
|
|
||||||
void PeerConnection::create_offer(NativeCreateSdpObserverHandle &observer_handle, RTCOfferAnswerOptions options) {
|
void PeerConnection::create_answer(
|
||||||
peer_connection_->CreateOffer(observer_handle.observer.get(), toNativeOfferAnswerOptions(options));
|
NativeCreateSdpObserverHandle& observer_handle,
|
||||||
}
|
RTCOfferAnswerOptions options) {
|
||||||
|
peer_connection_->CreateAnswer(observer_handle.observer.get(),
|
||||||
|
toNativeOfferAnswerOptions(options));
|
||||||
|
}
|
||||||
|
|
||||||
void PeerConnection::create_answer(NativeCreateSdpObserverHandle &observer_handle, RTCOfferAnswerOptions options) {
|
void PeerConnection::set_local_description(
|
||||||
peer_connection_->CreateAnswer(observer_handle.observer.get(), toNativeOfferAnswerOptions(options));
|
std::unique_ptr<SessionDescription> desc,
|
||||||
}
|
NativeSetLocalSdpObserverHandle& observer) {
|
||||||
|
peer_connection_->SetLocalDescription(desc->clone()->release(),
|
||||||
|
observer.observer);
|
||||||
|
}
|
||||||
|
|
||||||
void PeerConnection::set_local_description(std::unique_ptr<SessionDescription> desc, NativeSetLocalSdpObserverHandle &observer) {
|
void PeerConnection::set_remote_description(
|
||||||
peer_connection_->SetLocalDescription(desc->clone()->release(), observer.observer);
|
std::unique_ptr<SessionDescription> desc,
|
||||||
}
|
NativeSetRemoteSdpObserverHandle& observer) {
|
||||||
|
peer_connection_->SetRemoteDescription(desc->clone()->release(),
|
||||||
|
observer.observer);
|
||||||
|
}
|
||||||
|
|
||||||
void PeerConnection::set_remote_description(std::unique_ptr<SessionDescription> desc, NativeSetRemoteSdpObserverHandle &observer) {
|
std::unique_ptr<DataChannel> PeerConnection::create_data_channel(
|
||||||
peer_connection_->SetRemoteDescription(desc->clone()->release(), observer.observer);
|
rust::String label,
|
||||||
}
|
std::unique_ptr<NativeDataChannelInit> init) {
|
||||||
|
auto result =
|
||||||
|
peer_connection_->CreateDataChannelOrError(label.c_str(), init.get());
|
||||||
|
|
||||||
std::unique_ptr<DataChannel> PeerConnection::create_data_channel(rust::String label, std::unique_ptr<NativeDataChannelInit> init) {
|
if (!result.ok()) {
|
||||||
auto result = peer_connection_->CreateDataChannelOrError(label.c_str(), init.get());
|
throw std::runtime_error(serialize_error(to_error(result.error())));
|
||||||
|
}
|
||||||
|
|
||||||
if(!result.ok()) {
|
return std::make_unique<DataChannel>(result.value());
|
||||||
throw std::runtime_error(serialize_error(to_error(result.error())));
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return std::make_unique<DataChannel>(result.value());
|
void PeerConnection::add_ice_candidate(
|
||||||
}
|
std::unique_ptr<IceCandidate> candidate,
|
||||||
|
NativeAddIceCandidateObserver& observer) {
|
||||||
|
peer_connection_->AddIceCandidate(
|
||||||
|
candidate->release(),
|
||||||
|
[&](const webrtc::RTCError& err) { observer.OnComplete(to_error(err)); });
|
||||||
|
}
|
||||||
|
|
||||||
void PeerConnection::add_ice_candidate(std::unique_ptr<IceCandidate> candidate, NativeAddIceCandidateObserver &observer){
|
void PeerConnection::close() {
|
||||||
peer_connection_->AddIceCandidate(candidate->release(), [&](const webrtc::RTCError& err){
|
peer_connection_->Close();
|
||||||
observer.OnComplete(to_error(err));
|
}
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
void PeerConnection::close() {
|
// AddIceCandidateObserver
|
||||||
peer_connection_->Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
// AddIceCandidateObserver
|
NativeAddIceCandidateObserver::NativeAddIceCandidateObserver(
|
||||||
|
rust::Box<AddIceCandidateObserverWrapper> observer)
|
||||||
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
NativeAddIceCandidateObserver::NativeAddIceCandidateObserver(rust::Box<AddIceCandidateObserverWrapper> observer) : observer_(std::move(observer)) {
|
void NativeAddIceCandidateObserver::OnComplete(const RTCError& error) {
|
||||||
|
observer_->on_complete(error);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
std::unique_ptr<NativeAddIceCandidateObserver>
|
||||||
|
create_native_add_ice_candidate_observer(
|
||||||
|
rust::Box<AddIceCandidateObserverWrapper> observer) {
|
||||||
|
return std::make_unique<NativeAddIceCandidateObserver>(std::move(observer));
|
||||||
|
}
|
||||||
|
|
||||||
void NativeAddIceCandidateObserver::OnComplete(const RTCError &error) {
|
// PeerConnectionObserver
|
||||||
observer_->on_complete(error);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<NativeAddIceCandidateObserver> create_native_add_ice_candidate_observer(rust::Box<AddIceCandidateObserverWrapper> observer) {
|
NativePeerConnectionObserver::NativePeerConnectionObserver(
|
||||||
return std::make_unique<NativeAddIceCandidateObserver>(std::move(observer));
|
rust::Box<PeerConnectionObserverWrapper> observer)
|
||||||
}
|
: observer_(std::move(observer)) {}
|
||||||
|
|
||||||
// PeerConnectionObserver
|
void NativePeerConnectionObserver::OnSignalingChange(
|
||||||
|
webrtc::PeerConnectionInterface::SignalingState new_state) {
|
||||||
|
observer_->on_signaling_change(static_cast<SignalingState>(new_state));
|
||||||
|
}
|
||||||
|
|
||||||
NativePeerConnectionObserver::NativePeerConnectionObserver(rust::Box<PeerConnectionObserverWrapper> observer) : observer_(std::move(observer)) {
|
void NativePeerConnectionObserver::OnAddStream(
|
||||||
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
||||||
|
observer_->on_add_stream(std::make_unique<MediaStreamInterface>(stream));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
void NativePeerConnectionObserver::OnRemoveStream(
|
||||||
|
rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
||||||
|
observer_->on_remove_stream(std::make_unique<MediaStreamInterface>(stream));
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) {
|
void NativePeerConnectionObserver::OnDataChannel(
|
||||||
observer_->on_signaling_change(static_cast<SignalingState>(new_state));
|
rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
||||||
}
|
observer_->on_data_channel(std::make_unique<DataChannel>(data_channel));
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnAddStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
void NativePeerConnectionObserver::OnRenegotiationNeeded() {
|
||||||
observer_->on_add_stream(std::make_unique<MediaStreamInterface>(stream));
|
observer_->on_renegotiation_needed();
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnRemoveStream(rtc::scoped_refptr<webrtc::MediaStreamInterface> stream) {
|
void NativePeerConnectionObserver::OnNegotiationNeededEvent(uint32_t event_id) {
|
||||||
observer_->on_remove_stream(std::make_unique<MediaStreamInterface>(stream));
|
observer_->on_negotiation_needed_event(event_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnDataChannel(rtc::scoped_refptr<webrtc::DataChannelInterface> data_channel) {
|
void NativePeerConnectionObserver::OnIceConnectionChange(
|
||||||
observer_->on_data_channel(std::make_unique<DataChannel>(data_channel));
|
webrtc::PeerConnectionInterface::IceConnectionState new_state) {
|
||||||
}
|
observer_->on_ice_connection_change(
|
||||||
|
static_cast<IceConnectionState>(new_state));
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnRenegotiationNeeded() {
|
void NativePeerConnectionObserver::OnStandardizedIceConnectionChange(
|
||||||
observer_->on_renegotiation_needed();
|
webrtc::PeerConnectionInterface::IceConnectionState new_state) {
|
||||||
}
|
observer_->on_standardized_ice_connection_change(
|
||||||
|
static_cast<IceConnectionState>(new_state));
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnNegotiationNeededEvent(uint32_t event_id) {
|
void NativePeerConnectionObserver::OnConnectionChange(
|
||||||
observer_->on_negotiation_needed_event(event_id);
|
webrtc::PeerConnectionInterface::PeerConnectionState new_state) {
|
||||||
}
|
observer_->on_connection_change(static_cast<PeerConnectionState>(new_state));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void NativePeerConnectionObserver::OnIceGatheringChange(
|
||||||
NativePeerConnectionObserver::OnIceConnectionChange(webrtc::PeerConnectionInterface::IceConnectionState new_state) {
|
webrtc::PeerConnectionInterface::IceGatheringState new_state) {
|
||||||
observer_->on_ice_connection_change(static_cast<IceConnectionState>(new_state));
|
observer_->on_ice_gathering_change(static_cast<IceGatheringState>(new_state));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnStandardizedIceConnectionChange(
|
void NativePeerConnectionObserver::OnIceCandidate(
|
||||||
webrtc::PeerConnectionInterface::IceConnectionState new_state) {
|
const webrtc::IceCandidateInterface* candidate) {
|
||||||
observer_->on_standardized_ice_connection_change(static_cast<IceConnectionState>(new_state));
|
auto new_candidate = webrtc::CreateIceCandidate(candidate->sdp_mid(),
|
||||||
}
|
candidate->sdp_mline_index(),
|
||||||
|
candidate->candidate());
|
||||||
|
observer_->on_ice_candidate(
|
||||||
|
std::make_unique<IceCandidate>(std::move(new_candidate)));
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void NativePeerConnectionObserver::OnIceCandidateError(
|
||||||
NativePeerConnectionObserver::OnConnectionChange(webrtc::PeerConnectionInterface::PeerConnectionState new_state) {
|
const std::string& address,
|
||||||
observer_->on_connection_change(static_cast<PeerConnectionState>(new_state));
|
int port,
|
||||||
}
|
const std::string& url,
|
||||||
|
int error_code,
|
||||||
|
const std::string& error_text) {
|
||||||
|
observer_->on_ice_candidate_error(address, port, url, error_code, error_text);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void NativePeerConnectionObserver::OnIceCandidatesRemoved(
|
||||||
NativePeerConnectionObserver::OnIceGatheringChange(webrtc::PeerConnectionInterface::IceGatheringState new_state) {
|
const std::vector<cricket::Candidate>& candidates) {
|
||||||
observer_->on_ice_gathering_change(static_cast<IceGatheringState>(new_state));
|
rust::Vec<CandidatePtr> vec;
|
||||||
}
|
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnIceCandidate(const webrtc::IceCandidateInterface *candidate) {
|
for (const auto& item : candidates) {
|
||||||
auto new_candidate = webrtc::CreateIceCandidate(candidate->sdp_mid(), candidate->sdp_mline_index(),
|
vec.push_back(CandidatePtr{std::make_unique<Candidate>(item)});
|
||||||
candidate->candidate());
|
}
|
||||||
observer_->on_ice_candidate(std::make_unique<IceCandidate>(std::move(new_candidate)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnIceCandidateError(const std::string &address, int port, const std::string &url,
|
observer_->on_ice_candidates_removed(std::move(vec));
|
||||||
int error_code, const std::string &error_text) {
|
}
|
||||||
observer_->on_ice_candidate_error(address, port, url, error_code, error_text);
|
|
||||||
}
|
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnIceCandidatesRemoved(const std::vector<cricket::Candidate> &candidates) {
|
void NativePeerConnectionObserver::OnIceConnectionReceivingChange(
|
||||||
rust::Vec<CandidatePtr> vec;
|
bool receiving) {
|
||||||
|
observer_->on_ice_connection_receiving_change(receiving);
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &item: candidates) {
|
void NativePeerConnectionObserver::OnIceSelectedCandidatePairChanged(
|
||||||
vec.push_back(CandidatePtr{
|
const cricket::CandidatePairChangeEvent& event) {
|
||||||
std::make_unique<Candidate>(item)
|
CandidatePairChangeEvent e;
|
||||||
});
|
e.selected_candidate_pair.local =
|
||||||
}
|
std::make_unique<Candidate>(event.selected_candidate_pair.local);
|
||||||
|
e.selected_candidate_pair.remote =
|
||||||
|
std::make_unique<Candidate>(event.selected_candidate_pair.remote);
|
||||||
|
e.last_data_received_ms = event.last_data_received_ms;
|
||||||
|
e.reason = event.reason;
|
||||||
|
e.estimated_disconnected_time_ms = event.estimated_disconnected_time_ms;
|
||||||
|
|
||||||
observer_->on_ice_candidates_removed(std::move(vec));
|
observer_->on_ice_selected_candidate_pair_changed(std::move(e));
|
||||||
}
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnIceConnectionReceivingChange(bool receiving) {
|
void NativePeerConnectionObserver::OnAddTrack(
|
||||||
observer_->on_ice_connection_receiving_change(receiving);
|
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
|
||||||
}
|
const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>>&
|
||||||
|
streams) {
|
||||||
|
rust::Vec<MediaStreamPtr> vec;
|
||||||
|
|
||||||
void
|
for (const auto& item : streams) {
|
||||||
NativePeerConnectionObserver::OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) {
|
vec.push_back(MediaStreamPtr{std::make_unique<MediaStreamInterface>(item)});
|
||||||
CandidatePairChangeEvent e;
|
}
|
||||||
e.selected_candidate_pair.local = std::make_unique<Candidate>(event.selected_candidate_pair.local);
|
|
||||||
e.selected_candidate_pair.remote = std::make_unique<Candidate>(event.selected_candidate_pair.remote);
|
|
||||||
e.last_data_received_ms = event.last_data_received_ms;
|
|
||||||
e.reason = event.reason;
|
|
||||||
e.estimated_disconnected_time_ms = event.estimated_disconnected_time_ms;
|
|
||||||
|
|
||||||
observer_->on_ice_selected_candidate_pair_changed(std::move(e));
|
observer_->on_add_track(std::make_unique<RtpReceiver>(receiver),
|
||||||
}
|
std::move(vec));
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnAddTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver,
|
void NativePeerConnectionObserver::OnTrack(
|
||||||
const std::vector<rtc::scoped_refptr<webrtc::MediaStreamInterface>> &streams) {
|
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
|
||||||
rust::Vec<MediaStreamPtr> vec;
|
observer_->on_track(std::make_unique<RtpTransceiver>(transceiver));
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &item: streams) {
|
void NativePeerConnectionObserver::OnRemoveTrack(
|
||||||
vec.push_back(MediaStreamPtr{
|
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) {
|
||||||
std::make_unique<MediaStreamInterface>(item)
|
observer_->on_remove_track(std::make_unique<RtpReceiver>(receiver));
|
||||||
});
|
}
|
||||||
}
|
|
||||||
|
|
||||||
observer_->on_add_track(std::make_unique<RtpReceiver>(receiver), std::move(vec));
|
void NativePeerConnectionObserver::OnInterestingUsage(int usage_pattern) {
|
||||||
}
|
observer_->on_interesting_usage(usage_pattern);
|
||||||
|
}
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnTrack(rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) {
|
std::unique_ptr<NativePeerConnectionObserver>
|
||||||
observer_->on_track(std::make_unique<RtpTransceiver>(transceiver));
|
create_native_peer_connection_observer(
|
||||||
}
|
rust::Box<PeerConnectionObserverWrapper> observer) {
|
||||||
|
return std::make_unique<NativePeerConnectionObserver>(std::move(observer));
|
||||||
void NativePeerConnectionObserver::OnRemoveTrack(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) {
|
}
|
||||||
observer_->on_remove_track(std::make_unique<RtpReceiver>(receiver));
|
} // namespace livekit
|
||||||
}
|
|
||||||
|
|
||||||
void NativePeerConnectionObserver::OnInterestingUsage(int usage_pattern) {
|
|
||||||
observer_->on_interesting_usage(usage_pattern);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<NativePeerConnectionObserver> create_native_peer_connection_observer(rust::Box<PeerConnectionObserverWrapper> observer) {
|
|
||||||
return std::make_unique<NativePeerConnectionObserver>(std::move(observer));
|
|
||||||
}
|
|
||||||
} // livekit
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
use cxx::UniquePtr;
|
||||||
|
|
||||||
use crate::candidate::ffi::Candidate;
|
use crate::candidate::ffi::Candidate;
|
||||||
use crate::data_channel::ffi::DataChannel;
|
use crate::data_channel::ffi::DataChannel;
|
||||||
use crate::jsep::ffi::IceCandidate;
|
use crate::jsep::ffi::IceCandidate;
|
||||||
@@ -5,11 +7,9 @@ use crate::media_stream_interface::ffi::MediaStreamInterface;
|
|||||||
use crate::rtc_error::ffi::RTCError;
|
use crate::rtc_error::ffi::RTCError;
|
||||||
use crate::rtp_receiver::ffi::RtpReceiver;
|
use crate::rtp_receiver::ffi::RtpReceiver;
|
||||||
use crate::rtp_transceiver::ffi::RtpTransceiver;
|
use crate::rtp_transceiver::ffi::RtpTransceiver;
|
||||||
use cxx::UniquePtr;
|
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
|
|
||||||
struct CandidatePair {
|
struct CandidatePair {
|
||||||
local: UniquePtr<Candidate>,
|
local: UniquePtr<Candidate>,
|
||||||
remote: UniquePtr<Candidate>,
|
remote: UniquePtr<Candidate>,
|
||||||
@@ -246,6 +246,7 @@ pub mod ffi {
|
|||||||
|
|
||||||
// https://webrtc.github.io/webrtc-org/native-code/native-apis/
|
// https://webrtc.github.io/webrtc-org/native-code/native-apis/
|
||||||
unsafe impl Sync for ffi::PeerConnection {}
|
unsafe impl Sync for ffi::PeerConnection {}
|
||||||
|
|
||||||
unsafe impl Send for ffi::PeerConnection {}
|
unsafe impl Send for ffi::PeerConnection {}
|
||||||
|
|
||||||
unsafe impl Send for ffi::NativePeerConnectionObserver {}
|
unsafe impl Send for ffi::NativePeerConnectionObserver {}
|
||||||
|
|||||||
@@ -3,85 +3,93 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "livekit/peer_connection_factory.h"
|
#include "livekit/peer_connection_factory.h"
|
||||||
#include "api/video_codecs/builtin_video_decoder_factory.h"
|
|
||||||
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_decoder_factory.h"
|
||||||
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
#include "api/audio_codecs/builtin_audio_encoder_factory.h"
|
||||||
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
|
||||||
#include "media/engine/webrtc_media_engine.h"
|
|
||||||
#include "api/task_queue/default_task_queue_factory.h"
|
|
||||||
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
#include "api/rtc_event_log/rtc_event_log_factory.h"
|
||||||
|
#include "api/task_queue/default_task_queue_factory.h"
|
||||||
|
#include "api/video_codecs/builtin_video_decoder_factory.h"
|
||||||
|
#include "api/video_codecs/builtin_video_encoder_factory.h"
|
||||||
#include "libwebrtc-sys/src/peer_connection_factory.rs.h"
|
#include "libwebrtc-sys/src/peer_connection_factory.rs.h"
|
||||||
#include "livekit/rtc_error.h"
|
#include "livekit/rtc_error.h"
|
||||||
|
#include "media/engine/webrtc_media_engine.h"
|
||||||
|
|
||||||
namespace livekit{
|
namespace livekit {
|
||||||
|
|
||||||
PeerConnectionFactory::PeerConnectionFactory(){
|
PeerConnectionFactory::PeerConnectionFactory() {
|
||||||
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
rtc::LogMessage::LogToDebug(rtc::LS_INFO);
|
||||||
RTC_LOG(LS_INFO) << "PeerConnectionFactory::PeerConnectionFactory()";
|
RTC_LOG(LS_INFO) << "PeerConnectionFactory::PeerConnectionFactory()";
|
||||||
|
|
||||||
network_thread_ = rtc::Thread::CreateWithSocketServer();
|
network_thread_ = rtc::Thread::CreateWithSocketServer();
|
||||||
network_thread_->SetName("network_thread", &network_thread_);
|
network_thread_->SetName("network_thread", &network_thread_);
|
||||||
network_thread_->Start();
|
network_thread_->Start();
|
||||||
worker_thread_ = rtc::Thread::Create();
|
worker_thread_ = rtc::Thread::Create();
|
||||||
worker_thread_->SetName("worker_thread", &worker_thread_);
|
worker_thread_->SetName("worker_thread", &worker_thread_);
|
||||||
worker_thread_->Start();
|
worker_thread_->Start();
|
||||||
signaling_thread_ = rtc::Thread::Create();
|
signaling_thread_ = rtc::Thread::Create();
|
||||||
signaling_thread_->SetName("signaling_thread", &signaling_thread_);
|
signaling_thread_->SetName("signaling_thread", &signaling_thread_);
|
||||||
signaling_thread_->Start();
|
signaling_thread_->Start();
|
||||||
|
|
||||||
webrtc::PeerConnectionFactoryDependencies dependencies;
|
webrtc::PeerConnectionFactoryDependencies dependencies;
|
||||||
dependencies.network_thread = network_thread_.get();
|
dependencies.network_thread = network_thread_.get();
|
||||||
dependencies.worker_thread = worker_thread_.get();
|
dependencies.worker_thread = worker_thread_.get();
|
||||||
dependencies.signaling_thread = signaling_thread_.get();
|
dependencies.signaling_thread = signaling_thread_.get();
|
||||||
dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
|
dependencies.task_queue_factory = webrtc::CreateDefaultTaskQueueFactory();
|
||||||
dependencies.event_log_factory = std::make_unique<webrtc::RtcEventLogFactory>(dependencies.task_queue_factory.get());
|
dependencies.event_log_factory = std::make_unique<webrtc::RtcEventLogFactory>(
|
||||||
|
dependencies.task_queue_factory.get());
|
||||||
|
|
||||||
cricket::MediaEngineDependencies media_deps;
|
cricket::MediaEngineDependencies media_deps;
|
||||||
media_deps.task_queue_factory = dependencies.task_queue_factory.get();
|
media_deps.task_queue_factory = dependencies.task_queue_factory.get();
|
||||||
media_deps.video_encoder_factory = webrtc::CreateBuiltinVideoEncoderFactory();
|
media_deps.video_encoder_factory = webrtc::CreateBuiltinVideoEncoderFactory();
|
||||||
media_deps.video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory();
|
media_deps.video_decoder_factory = webrtc::CreateBuiltinVideoDecoderFactory();
|
||||||
media_deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
|
media_deps.audio_encoder_factory = webrtc::CreateBuiltinAudioEncoderFactory();
|
||||||
media_deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();
|
media_deps.audio_decoder_factory = webrtc::CreateBuiltinAudioDecoderFactory();
|
||||||
|
|
||||||
dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
|
dependencies.media_engine = cricket::CreateMediaEngine(std::move(media_deps));
|
||||||
|
|
||||||
peer_factory_ = webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
|
peer_factory_ =
|
||||||
|
webrtc::CreateModularPeerConnectionFactory(std::move(dependencies));
|
||||||
|
|
||||||
if (peer_factory_.get() == nullptr) {
|
if (peer_factory_.get() == nullptr) {
|
||||||
RTC_LOG_ERR(LS_ERROR) << "Failed to create PeerConnectionFactory";
|
RTC_LOG_ERR(LS_ERROR) << "Failed to create PeerConnectionFactory";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<PeerConnection> PeerConnectionFactory::create_peer_connection(
|
||||||
|
std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config,
|
||||||
|
NativePeerConnectionObserver& observer) const {
|
||||||
|
webrtc::PeerConnectionDependencies deps{&observer};
|
||||||
|
auto result =
|
||||||
|
peer_factory_->CreatePeerConnectionOrError(*config, std::move(deps));
|
||||||
|
|
||||||
|
if (!result.ok()) {
|
||||||
|
throw std::runtime_error(serialize_error(to_error(result.error())));
|
||||||
|
}
|
||||||
|
|
||||||
|
return std::make_unique<PeerConnection>(result.value());
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory() {
|
||||||
|
return std::make_unique<PeerConnectionFactory>();
|
||||||
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(
|
||||||
|
RTCConfiguration conf) {
|
||||||
|
auto rtc =
|
||||||
|
std::make_unique<webrtc::PeerConnectionInterface::RTCConfiguration>();
|
||||||
|
for (auto& item : conf.ice_servers) {
|
||||||
|
webrtc::PeerConnectionInterface::IceServer ice_server;
|
||||||
|
ice_server.username = item.username.c_str();
|
||||||
|
ice_server.password = item.password.c_str();
|
||||||
|
|
||||||
|
for (auto& url : item.urls) {
|
||||||
|
ice_server.urls.emplace_back(url.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<PeerConnection> PeerConnectionFactory::create_peer_connection(std::unique_ptr<webrtc::PeerConnectionInterface::RTCConfiguration> config, NativePeerConnectionObserver &observer) const {
|
rtc->servers.push_back(ice_server);
|
||||||
webrtc::PeerConnectionDependencies deps{&observer};
|
}
|
||||||
auto result = peer_factory_->CreatePeerConnectionOrError(*config, std::move(deps));
|
|
||||||
|
|
||||||
if(!result.ok()) {
|
return rtc;
|
||||||
throw std::runtime_error(serialize_error(to_error(result.error())));
|
}
|
||||||
}
|
} // namespace livekit
|
||||||
|
|
||||||
return std::make_unique<PeerConnection>(result.value());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<PeerConnectionFactory> create_peer_connection_factory() {
|
|
||||||
return std::make_unique<PeerConnectionFactory>();
|
|
||||||
}
|
|
||||||
|
|
||||||
std::unique_ptr<NativeRTCConfiguration> create_rtc_configuration(RTCConfiguration conf){
|
|
||||||
auto rtc = std::make_unique<webrtc::PeerConnectionInterface::RTCConfiguration>();
|
|
||||||
for (auto &item: conf.ice_servers){
|
|
||||||
webrtc::PeerConnectionInterface::IceServer ice_server;
|
|
||||||
ice_server.username = item.username.c_str();
|
|
||||||
ice_server.password = item.password.c_str();
|
|
||||||
|
|
||||||
for (auto &url: item.urls){
|
|
||||||
ice_server.urls.emplace_back(url.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
rtc->servers.push_back(ice_server);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rtc;
|
|
||||||
}
|
|
||||||
} // namespace lk
|
|
||||||
@@ -1,25 +1,10 @@
|
|||||||
use crate::candidate::ffi::Candidate;
|
|
||||||
use crate::data_channel::ffi::DataChannel;
|
|
||||||
use crate::jsep::ffi::IceCandidate;
|
|
||||||
use crate::jsep::CreateSdpObserver;
|
|
||||||
use crate::media_stream_interface::ffi::MediaStreamInterface;
|
|
||||||
use crate::peer_connection::ffi::{
|
|
||||||
CandidatePairChangeEvent, IceConnectionState, IceGatheringState, PeerConnectionState,
|
|
||||||
SignalingState,
|
|
||||||
};
|
|
||||||
use crate::peer_connection::PeerConnectionObserver;
|
|
||||||
use crate::rtp_receiver::ffi::RtpReceiver;
|
|
||||||
use crate::rtp_transceiver::ffi::RtpTransceiver;
|
|
||||||
use crate::{jsep, peer_connection};
|
|
||||||
use cxx::UniquePtr;
|
|
||||||
use log::info;
|
|
||||||
use std::any::Any;
|
use std::any::Any;
|
||||||
use std::thread::sleep;
|
|
||||||
use std::time::Duration;
|
use crate::jsep::CreateSdpObserver;
|
||||||
|
use crate::peer_connection::PeerConnectionObserver;
|
||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct ICEServer {
|
pub struct ICEServer {
|
||||||
pub urls: Vec<String>,
|
pub urls: Vec<String>,
|
||||||
@@ -37,7 +22,7 @@ pub mod ffi {
|
|||||||
|
|
||||||
type PeerConnection = crate::peer_connection::ffi::PeerConnection;
|
type PeerConnection = crate::peer_connection::ffi::PeerConnection;
|
||||||
type NativePeerConnectionObserver =
|
type NativePeerConnectionObserver =
|
||||||
crate::peer_connection::ffi::NativePeerConnectionObserver;
|
crate::peer_connection::ffi::NativePeerConnectionObserver;
|
||||||
type PeerConnectionFactory;
|
type PeerConnectionFactory;
|
||||||
type NativeRTCConfiguration;
|
type NativeRTCConfiguration;
|
||||||
|
|
||||||
|
|||||||
@@ -3,53 +3,54 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "livekit/rtc_error.h"
|
#include "livekit/rtc_error.h"
|
||||||
|
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
|
|
||||||
RTCError to_error(const webrtc::RTCError &error) {
|
RTCError to_error(const webrtc::RTCError& error) {
|
||||||
RTCError lk_error;
|
RTCError lk_error;
|
||||||
lk_error.error_detail = static_cast<RTCErrorDetailType>(error.error_detail());
|
lk_error.error_detail = static_cast<RTCErrorDetailType>(error.error_detail());
|
||||||
lk_error.error_type = static_cast<RTCErrorType>(error.type());
|
lk_error.error_type = static_cast<RTCErrorType>(error.type());
|
||||||
lk_error.has_sctp_cause_code = error.sctp_cause_code().has_value();
|
lk_error.has_sctp_cause_code = error.sctp_cause_code().has_value();
|
||||||
lk_error.sctp_cause_code = error.sctp_cause_code().value_or(0);
|
lk_error.sctp_cause_code = error.sctp_cause_code().value_or(0);
|
||||||
lk_error.message = error.message();
|
lk_error.message = error.message();
|
||||||
return lk_error;
|
return lk_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string serialize_error(const RTCError &error) {
|
std::string serialize_error(const RTCError& error) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
ss << std::hex << std::setfill('0');
|
ss << std::hex << std::setfill('0');
|
||||||
ss << std::setw(8) << (uint32_t) error.error_type;
|
ss << std::setw(8) << (uint32_t)error.error_type;
|
||||||
ss << std::setw(8) << (uint32_t) error.error_detail;
|
ss << std::setw(8) << (uint32_t)error.error_detail;
|
||||||
ss << std::setw(2) << (uint16_t) error.has_sctp_cause_code;
|
ss << std::setw(2) << (uint16_t)error.has_sctp_cause_code;
|
||||||
ss << std::setw(4) << (uint16_t) error.sctp_cause_code;
|
ss << std::setw(4) << (uint16_t)error.sctp_cause_code;
|
||||||
ss << std::dec << std::setw(1) << std::string(error.message);
|
ss << std::dec << std::setw(1) << std::string(error.message);
|
||||||
return ss.str();
|
return ss.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIVEKIT_TEST
|
#ifdef LIVEKIT_TEST
|
||||||
rust::String serialize_deserialize(){
|
rust::String serialize_deserialize() {
|
||||||
RTCError lk_error;
|
RTCError lk_error;
|
||||||
lk_error.error_type = RTCErrorType::InternalError;
|
lk_error.error_type = RTCErrorType::InternalError;
|
||||||
lk_error.error_detail = RTCErrorDetailType::DataChannelFailure;
|
lk_error.error_detail = RTCErrorDetailType::DataChannelFailure;
|
||||||
lk_error.has_sctp_cause_code = true;
|
lk_error.has_sctp_cause_code = true;
|
||||||
lk_error.sctp_cause_code = 24;
|
lk_error.sctp_cause_code = 24;
|
||||||
lk_error.message = "this is not a test, I repeat, this is not a test";
|
lk_error.message = "this is not a test, I repeat, this is not a test";
|
||||||
return serialize_error(lk_error);
|
return serialize_error(lk_error);
|
||||||
}
|
}
|
||||||
|
|
||||||
void throw_error() {
|
void throw_error() {
|
||||||
RTCError lk_error;
|
RTCError lk_error;
|
||||||
lk_error.error_type = RTCErrorType::InvalidModification;
|
lk_error.error_type = RTCErrorType::InvalidModification;
|
||||||
lk_error.error_detail = RTCErrorDetailType::None;
|
lk_error.error_detail = RTCErrorDetailType::None;
|
||||||
lk_error.has_sctp_cause_code = false;
|
lk_error.has_sctp_cause_code = false;
|
||||||
lk_error.sctp_cause_code = 0;
|
lk_error.sctp_cause_code = 0;
|
||||||
lk_error.message = "exception is thrown!";
|
lk_error.message = "exception is thrown!";
|
||||||
throw std::runtime_error(serialize_error(lk_error));
|
throw std::runtime_error(serialize_error(lk_error));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
@@ -6,7 +6,6 @@ use std::fmt::{Display, Formatter};
|
|||||||
|
|
||||||
#[cxx::bridge(namespace = "livekit")]
|
#[cxx::bridge(namespace = "livekit")]
|
||||||
pub mod ffi {
|
pub mod ffi {
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
pub enum RTCErrorType {
|
pub enum RTCErrorType {
|
||||||
@@ -42,7 +41,8 @@ pub mod ffi {
|
|||||||
pub error_type: RTCErrorType,
|
pub error_type: RTCErrorType,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
pub error_detail: RTCErrorDetailType,
|
pub error_detail: RTCErrorDetailType,
|
||||||
pub has_sctp_cause_code: bool, // cxx doesn't support the Option trait
|
pub has_sctp_cause_code: bool,
|
||||||
|
// cxx doesn't support the Option trait
|
||||||
pub sctp_cause_code: u16,
|
pub sctp_cause_code: u16,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "livekit/rtp_receiver.h"
|
#include "livekit/rtp_receiver.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
RtpReceiver::RtpReceiver(rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver) : receiver_(std::move(receiver)) {
|
RtpReceiver::RtpReceiver(
|
||||||
|
rtc::scoped_refptr<webrtc::RtpReceiverInterface> receiver)
|
||||||
}
|
: receiver_(std::move(receiver)) {}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
@@ -5,7 +5,7 @@
|
|||||||
#include "livekit/rtp_transceiver.h"
|
#include "livekit/rtp_transceiver.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
RtpTransceiver::RtpTransceiver(rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver) : transceiver_(std::move(transceiver)) {
|
RtpTransceiver::RtpTransceiver(
|
||||||
|
rtc::scoped_refptr<webrtc::RtpTransceiverInterface> transceiver)
|
||||||
}
|
: transceiver_(std::move(transceiver)) {}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
@@ -3,20 +3,21 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "livekit/webrtc.h"
|
#include "livekit/webrtc.h"
|
||||||
|
|
||||||
#include "rtc_base/logging.h"
|
#include "rtc_base/logging.h"
|
||||||
|
|
||||||
namespace livekit {
|
namespace livekit {
|
||||||
RTCRuntime::RTCRuntime() {
|
RTCRuntime::RTCRuntime() {
|
||||||
RTC_LOG(LS_INFO) << "RTCRuntime()";
|
RTC_LOG(LS_INFO) << "RTCRuntime()";
|
||||||
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
|
RTC_CHECK(rtc::InitializeSSL()) << "Failed to InitializeSSL()";
|
||||||
}
|
}
|
||||||
|
|
||||||
RTCRuntime::~RTCRuntime() {
|
RTCRuntime::~RTCRuntime() {
|
||||||
RTC_LOG(LS_INFO) << "~RTCRuntime()";
|
RTC_LOG(LS_INFO) << "~RTCRuntime()";
|
||||||
RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
|
RTC_CHECK(rtc::CleanupSSL()) << "Failed to CleanupSSL()";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<RTCRuntime> create_rtc_runtime(){
|
std::unique_ptr<RTCRuntime> create_rtc_runtime() {
|
||||||
return std::make_unique<RTCRuntime>();
|
return std::make_unique<RTCRuntime>();
|
||||||
}
|
}
|
||||||
} // livekit
|
} // namespace livekit
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
use cxx::UniquePtr;
|
|
||||||
use libwebrtc_sys::data_channel as sys_dc;
|
|
||||||
use log::trace;
|
|
||||||
use std::fmt::{Debug, Formatter};
|
use std::fmt::{Debug, Formatter};
|
||||||
use std::sync::{Arc, Mutex};
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
|
use cxx::UniquePtr;
|
||||||
|
use log::trace;
|
||||||
|
|
||||||
|
use libwebrtc_sys::data_channel as sys_dc;
|
||||||
pub use sys_dc::ffi::Priority;
|
pub use sys_dc::ffi::Priority;
|
||||||
|
|
||||||
pub struct DataChannel {
|
pub struct DataChannel {
|
||||||
@@ -78,7 +79,8 @@ impl DataChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub type OnStateChangeHandler = Box<dyn FnMut() + Send + Sync>;
|
pub type OnStateChangeHandler = Box<dyn FnMut() + Send + Sync>;
|
||||||
pub type OnMessageHandler = Box<dyn FnMut(&[u8], bool) + Send + Sync>; // data, is_binary
|
pub type OnMessageHandler = Box<dyn FnMut(&[u8], bool) + Send + Sync>;
|
||||||
|
// data, is_binary
|
||||||
pub type OnBufferedAmountChangeHandler = Box<dyn FnMut(u64) + Send + Sync>;
|
pub type OnBufferedAmountChangeHandler = Box<dyn FnMut(u64) + Send + Sync>;
|
||||||
|
|
||||||
struct InternalDataChannelObserver {
|
struct InternalDataChannelObserver {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use cxx::{SharedPtr, UniquePtr};
|
use cxx::UniquePtr;
|
||||||
|
|
||||||
use libwebrtc_sys::jsep as sys_jsep;
|
use libwebrtc_sys::jsep as sys_jsep;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|||||||
@@ -1,12 +1,19 @@
|
|||||||
|
use std::fmt::Debug;
|
||||||
|
use std::sync::{Arc, Mutex};
|
||||||
|
|
||||||
use cxx::UniquePtr;
|
use cxx::UniquePtr;
|
||||||
|
use log::trace;
|
||||||
|
use thiserror::Error;
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use libwebrtc_sys::data_channel as sys_dc;
|
use libwebrtc_sys::data_channel as sys_dc;
|
||||||
use libwebrtc_sys::jsep as sys_jsep;
|
use libwebrtc_sys::jsep as sys_jsep;
|
||||||
use libwebrtc_sys::peer_connection as sys_pc;
|
use libwebrtc_sys::peer_connection as sys_pc;
|
||||||
use log::trace;
|
pub use libwebrtc_sys::peer_connection::ffi::IceConnectionState;
|
||||||
use std::fmt::{Debug, Formatter};
|
pub use libwebrtc_sys::peer_connection::ffi::IceGatheringState;
|
||||||
use std::sync::{Arc, Mutex};
|
pub use libwebrtc_sys::peer_connection::ffi::PeerConnectionState;
|
||||||
use thiserror::Error;
|
pub use libwebrtc_sys::peer_connection::ffi::RTCOfferAnswerOptions;
|
||||||
use tokio::sync::{mpsc, oneshot};
|
pub use libwebrtc_sys::peer_connection::ffi::SignalingState;
|
||||||
|
|
||||||
use crate::data_channel::{DataChannel, DataChannelInit};
|
use crate::data_channel::{DataChannel, DataChannelInit};
|
||||||
use crate::jsep::{IceCandidate, SessionDescription};
|
use crate::jsep::{IceCandidate, SessionDescription};
|
||||||
@@ -15,12 +22,6 @@ use crate::rtc_error::RTCError;
|
|||||||
use crate::rtp_receiver::RtpReceiver;
|
use crate::rtp_receiver::RtpReceiver;
|
||||||
use crate::rtp_transceiver::RtpTransceiver;
|
use crate::rtp_transceiver::RtpTransceiver;
|
||||||
|
|
||||||
pub use libwebrtc_sys::peer_connection::ffi::IceConnectionState;
|
|
||||||
pub use libwebrtc_sys::peer_connection::ffi::IceGatheringState;
|
|
||||||
pub use libwebrtc_sys::peer_connection::ffi::PeerConnectionState;
|
|
||||||
pub use libwebrtc_sys::peer_connection::ffi::RTCOfferAnswerOptions;
|
|
||||||
pub use libwebrtc_sys::peer_connection::ffi::SignalingState;
|
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
pub enum SdpError {
|
pub enum SdpError {
|
||||||
#[error("recv failure: {0}")]
|
#[error("recv failure: {0}")]
|
||||||
@@ -343,16 +344,16 @@ pub type OnRenegotiationNeededHandler = Box<dyn FnMut() + Send + Sync>;
|
|||||||
pub type OnNegotiationNeededEventHandler = Box<dyn FnMut(u32) + Send + Sync>;
|
pub type OnNegotiationNeededEventHandler = Box<dyn FnMut(u32) + Send + Sync>;
|
||||||
pub type OnIceConnectionChangeHandler = Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
pub type OnIceConnectionChangeHandler = Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
||||||
pub type OnStandardizedIceConnectionChangeHandler =
|
pub type OnStandardizedIceConnectionChangeHandler =
|
||||||
Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
Box<dyn FnMut(IceConnectionState) + Send + Sync>;
|
||||||
pub type OnConnectionChangeHandler = Box<dyn FnMut(PeerConnectionState) + Send + Sync>;
|
pub type OnConnectionChangeHandler = Box<dyn FnMut(PeerConnectionState) + Send + Sync>;
|
||||||
pub type OnIceGatheringChangeHandler = Box<dyn FnMut(IceGatheringState) + Send + Sync>;
|
pub type OnIceGatheringChangeHandler = Box<dyn FnMut(IceGatheringState) + Send + Sync>;
|
||||||
pub type OnIceCandidateHandler = Box<dyn FnMut(IceCandidate) + Send + Sync>;
|
pub type OnIceCandidateHandler = Box<dyn FnMut(IceCandidate) + Send + Sync>;
|
||||||
pub type OnIceCandidateErrorHandler =
|
pub type OnIceCandidateErrorHandler =
|
||||||
Box<dyn FnMut(String, i32, String, i32, String) + Send + Sync>;
|
Box<dyn FnMut(String, i32, String, i32, String) + Send + Sync>;
|
||||||
pub type OnIceCandidatesRemovedHandler = Box<dyn FnMut(Vec<IceCandidate>) + Send + Sync>;
|
pub type OnIceCandidatesRemovedHandler = Box<dyn FnMut(Vec<IceCandidate>) + Send + Sync>;
|
||||||
pub type OnIceConnectionReceivingChangeHandler = Box<dyn FnMut(bool) + Send + Sync>;
|
pub type OnIceConnectionReceivingChangeHandler = Box<dyn FnMut(bool) + Send + Sync>;
|
||||||
pub type OnIceSelectedCandidatePairChangedHandler =
|
pub type OnIceSelectedCandidatePairChangedHandler =
|
||||||
Box<dyn FnMut(libwebrtc_sys::peer_connection::ffi::CandidatePairChangeEvent) + Send + Sync>;
|
Box<dyn FnMut(libwebrtc_sys::peer_connection::ffi::CandidatePairChangeEvent) + Send + Sync>;
|
||||||
pub type OnAddTrackHandler = Box<dyn FnMut(RtpReceiver, Vec<MediaStream>) + Send + Sync>;
|
pub type OnAddTrackHandler = Box<dyn FnMut(RtpReceiver, Vec<MediaStream>) + Send + Sync>;
|
||||||
pub type OnTrackHandler = Box<dyn FnMut(RtpTransceiver) + Send + Sync>;
|
pub type OnTrackHandler = Box<dyn FnMut(RtpTransceiver) + Send + Sync>;
|
||||||
pub type OnRemoveTrackHandler = Box<dyn FnMut(RtpReceiver) + Send + Sync>;
|
pub type OnRemoveTrackHandler = Box<dyn FnMut(RtpReceiver) + Send + Sync>;
|
||||||
@@ -367,16 +368,16 @@ pub(crate) struct InternalObserver {
|
|||||||
on_negotiation_needed_event_handler: Arc<Mutex<Option<OnNegotiationNeededEventHandler>>>,
|
on_negotiation_needed_event_handler: Arc<Mutex<Option<OnNegotiationNeededEventHandler>>>,
|
||||||
on_ice_connection_change_handler: Arc<Mutex<Option<OnIceConnectionChangeHandler>>>,
|
on_ice_connection_change_handler: Arc<Mutex<Option<OnIceConnectionChangeHandler>>>,
|
||||||
on_standardized_ice_connection_change_handler:
|
on_standardized_ice_connection_change_handler:
|
||||||
Arc<Mutex<Option<OnStandardizedIceConnectionChangeHandler>>>,
|
Arc<Mutex<Option<OnStandardizedIceConnectionChangeHandler>>>,
|
||||||
on_connection_change_handler: Arc<Mutex<Option<OnConnectionChangeHandler>>>,
|
on_connection_change_handler: Arc<Mutex<Option<OnConnectionChangeHandler>>>,
|
||||||
on_ice_gathering_change_handler: Arc<Mutex<Option<OnIceGatheringChangeHandler>>>,
|
on_ice_gathering_change_handler: Arc<Mutex<Option<OnIceGatheringChangeHandler>>>,
|
||||||
on_ice_candidate_handler: Arc<Mutex<Option<OnIceCandidateHandler>>>,
|
on_ice_candidate_handler: Arc<Mutex<Option<OnIceCandidateHandler>>>,
|
||||||
on_ice_candidate_error_handler: Arc<Mutex<Option<OnIceCandidateErrorHandler>>>,
|
on_ice_candidate_error_handler: Arc<Mutex<Option<OnIceCandidateErrorHandler>>>,
|
||||||
on_ice_candidates_removed_handler: Arc<Mutex<Option<OnIceCandidatesRemovedHandler>>>,
|
on_ice_candidates_removed_handler: Arc<Mutex<Option<OnIceCandidatesRemovedHandler>>>,
|
||||||
on_ice_connection_receiving_change_handler:
|
on_ice_connection_receiving_change_handler:
|
||||||
Arc<Mutex<Option<OnIceConnectionReceivingChangeHandler>>>,
|
Arc<Mutex<Option<OnIceConnectionReceivingChangeHandler>>>,
|
||||||
on_ice_selected_candidate_pair_changed_handler:
|
on_ice_selected_candidate_pair_changed_handler:
|
||||||
Arc<Mutex<Option<OnIceSelectedCandidatePairChangedHandler>>>,
|
Arc<Mutex<Option<OnIceSelectedCandidatePairChangedHandler>>>,
|
||||||
on_add_track_handler: Arc<Mutex<Option<OnAddTrackHandler>>>,
|
on_add_track_handler: Arc<Mutex<Option<OnAddTrackHandler>>>,
|
||||||
on_track_handler: Arc<Mutex<Option<OnTrackHandler>>>,
|
on_track_handler: Arc<Mutex<Option<OnTrackHandler>>>,
|
||||||
on_remove_track_handler: Arc<Mutex<Option<OnRemoveTrackHandler>>>,
|
on_remove_track_handler: Arc<Mutex<Option<OnRemoveTrackHandler>>>,
|
||||||
@@ -604,12 +605,13 @@ impl sys_pc::PeerConnectionObserver for InternalObserver {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use log::trace;
|
||||||
|
use tokio::sync::mpsc;
|
||||||
|
|
||||||
use crate::data_channel::{DataChannel, DataChannelInit};
|
use crate::data_channel::{DataChannel, DataChannelInit};
|
||||||
use crate::jsep::IceCandidate;
|
use crate::jsep::IceCandidate;
|
||||||
use crate::peer_connection_factory::{ICEServer, PeerConnectionFactory, RTCConfiguration};
|
use crate::peer_connection_factory::{ICEServer, PeerConnectionFactory, RTCConfiguration};
|
||||||
use crate::webrtc::RTCRuntime;
|
use crate::webrtc::RTCRuntime;
|
||||||
use log::trace;
|
|
||||||
use tokio::sync::mpsc;
|
|
||||||
|
|
||||||
fn init_log() {
|
fn init_log() {
|
||||||
let _ = env_logger::builder().is_test(true).try_init();
|
let _ = env_logger::builder().is_test(true).try_init();
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
use cxx::UniquePtr;
|
use cxx::UniquePtr;
|
||||||
|
|
||||||
use libwebrtc_sys::peer_connection as sys_pc;
|
use libwebrtc_sys::peer_connection as sys_pc;
|
||||||
use libwebrtc_sys::peer_connection_factory as sys_factory;
|
use libwebrtc_sys::peer_connection_factory as sys_factory;
|
||||||
|
pub use sys_factory::ffi::{ICEServer, RTCConfiguration};
|
||||||
|
|
||||||
use crate::peer_connection::{InternalObserver, PeerConnection};
|
use crate::peer_connection::{InternalObserver, PeerConnection};
|
||||||
use crate::rtc_error::RTCError;
|
use crate::rtc_error::RTCError;
|
||||||
|
|
||||||
pub use sys_factory::ffi::{ICEServer, RTCConfiguration};
|
|
||||||
|
|
||||||
pub struct PeerConnectionFactory {
|
pub struct PeerConnectionFactory {
|
||||||
cxx_handle: UniquePtr<sys_factory::ffi::PeerConnectionFactory>,
|
cxx_handle: UniquePtr<sys_factory::ffi::PeerConnectionFactory>,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
use std::fmt;
|
|
||||||
|
|
||||||
// TODO(theomonnom) Wrap the RTCError ffi so we can use Option(u16)
|
// TODO(theomonnom) Wrap the RTCError ffi so we can use Option(u16)
|
||||||
pub use libwebrtc_sys::rtc_error::ffi::RTCError;
|
pub use libwebrtc_sys::rtc_error::ffi::RTCError;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
use cxx::UniquePtr;
|
use cxx::UniquePtr;
|
||||||
|
|
||||||
use libwebrtc_sys::webrtc as sys_rtc;
|
use libwebrtc_sys::webrtc as sys_rtc;
|
||||||
|
|
||||||
pub struct RTCRuntime {
|
pub struct RTCRuntime {
|
||||||
|
|||||||
Reference in New Issue
Block a user