#pragma once
#include "api/environment/environment_factory.h"
#include "api/peer_connection_interface.h"
#include "api/scoped_refptr.h"
#include "api/task_queue/task_queue_factory.h"
#include "livekit/audio_device.h"
#include "media_stream.h"
#include "rtp_parameters.h"
#include "rust/cxx.h"
#include "webrtc.h"
namespace livekit_ffi {
class PeerConnectionFactory;
class PeerConnectionObserverWrapper;
} #include "webrtc-sys/src/peer_connection_factory.rs.h"
namespace livekit_ffi {
class PeerConnection;
struct RtcConfiguration;
webrtc::PeerConnectionInterface::RTCConfiguration to_native_rtc_configuration(
RtcConfiguration config);
class PeerConnectionFactory {
public:
explicit PeerConnectionFactory(std::shared_ptr<RtcRuntime> rtc_runtime);
~PeerConnectionFactory();
std::shared_ptr<PeerConnection> create_peer_connection(
RtcConfiguration config,
rust::Box<PeerConnectionObserverWrapper> observer) const;
std::shared_ptr<VideoTrack> create_video_track(
rust::String label,
std::shared_ptr<VideoTrackSource> source) const;
std::shared_ptr<AudioTrack> create_audio_track(
rust::String label,
std::shared_ptr<AudioTrackSource> source) const;
RtpCapabilities rtp_sender_capabilities(MediaType type) const;
RtpCapabilities rtp_receiver_capabilities(MediaType type) const;
std::shared_ptr<RtcRuntime> rtc_runtime() const { return rtc_runtime_; }
private:
std::shared_ptr<RtcRuntime> rtc_runtime_;
webrtc::scoped_refptr<AudioDevice> audio_device_;
webrtc::scoped_refptr<webrtc::PeerConnectionFactoryInterface> peer_factory_;
webrtc::Environment env_;
};
std::shared_ptr<PeerConnectionFactory> create_peer_connection_factory();
}