mod whep;
mod whip;
use std::net::SocketAddr;
use url::Url;
#[derive(Clone, Debug, Default)]
#[non_exhaustive]
pub struct Config {
pub ice_candidates: Vec<SocketAddr>,
}
#[derive(Clone)]
pub struct Client {
config: Config,
http: reqwest::Client,
}
impl Client {
pub fn new(config: Config) -> Self {
Self {
config,
http: reqwest::Client::new(),
}
}
pub(crate) fn config(&self) -> &Config {
&self.config
}
pub(crate) fn http(&self) -> &reqwest::Client {
&self.http
}
pub async fn subscribe(&self, url: Url, broadcast: moq_net::broadcast::Producer) -> crate::Result<()> {
whep::dial(self, url, broadcast).await
}
pub async fn publish(
&self,
url: Url,
origin: moq_net::origin::Consumer,
path: impl moq_net::AsPath,
) -> crate::Result<()> {
whip::dial(self, url, origin, path).await
}
}