use derive_more::{From, Into};
use wasm_bindgen::prelude::*;
use crate::{
api::{MediaDirection, MediaKind, MediaSourceKind},
media::track::remote,
};
#[wasm_bindgen]
#[derive(Clone, Debug, From, Into)]
pub struct RemoteMediaTrack(remote::Track);
#[wasm_bindgen]
impl RemoteMediaTrack {
#[must_use]
pub fn get_track(&self) -> web_sys::MediaStreamTrack {
Clone::clone(self.0.get_track().as_ref())
}
#[must_use]
pub fn muted(&self) -> bool {
self.0.muted()
}
pub fn on_muted(&self, cb: js_sys::Function) {
self.0.on_muted(cb.into());
}
pub fn on_unmuted(&self, cb: js_sys::Function) {
self.0.on_unmuted(cb.into());
}
pub fn on_stopped(&self, cb: js_sys::Function) {
self.0.on_stopped(cb.into());
}
pub fn on_media_direction_changed(&self, cb: js_sys::Function) {
self.0.on_media_direction_changed(cb.into());
}
#[must_use]
pub fn kind(&self) -> MediaKind {
self.0.kind().into()
}
#[must_use]
pub fn media_source_kind(&self) -> MediaSourceKind {
self.0.media_source_kind().into()
}
#[must_use]
pub fn media_direction(&self) -> MediaDirection {
self.0.media_direction().into()
}
}