// // Created by Théo Monnom on 30/08/2022. // #ifndef CLIENT_SDK_NATIVE_PEER_CONNECTION_H #define CLIENT_SDK_NATIVE_PEER_CONNECTION_H #include #include "api/peer_connection_interface.h" #include "rust/cxx.h" #include "data_channel.h" #include "jsep.h" #include "rust_types.h" namespace livekit { class NativePeerConnectionObserver; class PeerConnection { public: explicit PeerConnection(rtc::scoped_refptr peer_connection, std::unique_ptr observer); void close(); void create_offer(std::unique_ptr observer, RTCOfferAnswerOptions options); void create_answer(std::unique_ptr observer, RTCOfferAnswerOptions options); void set_local_description(std::unique_ptr desc, std::unique_ptr observer); void set_remote_description(std::unique_ptr desc, std::unique_ptr observer); private: rtc::scoped_refptr peer_connection_; std::unique_ptr observer_; }; static std::unique_ptr _unique_peer_connection() { return nullptr; // Ignore } class NativePeerConnectionObserver : public webrtc::PeerConnectionObserver { public: explicit NativePeerConnectionObserver(rust::Box observer); ~NativePeerConnectionObserver() override = default; void OnSignalingChange(webrtc::PeerConnectionInterface::SignalingState new_state) override; void OnAddStream(rtc::scoped_refptr stream) override; void OnRemoveStream(rtc::scoped_refptr stream) override; void OnDataChannel(rtc::scoped_refptr 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 &candidates) override; void OnIceConnectionReceivingChange(bool receiving) override; void OnIceSelectedCandidatePairChanged(const cricket::CandidatePairChangeEvent &event) override; void OnAddTrack(rtc::scoped_refptr receiver, const std::vector> &streams) override; void OnTrack(rtc::scoped_refptr transceiver) override; void OnRemoveTrack(rtc::scoped_refptr receiver) override; void OnInterestingUsage(int usage_pattern) override; private: rust::Box observer_; }; std::unique_ptr create_native_peer_connection_observer(rust::Box observer); } // livekit #endif //CLIENT_SDK_NATIVE_PEER_CONNECTION_H