diff --git a/packages/media_core/src/endpoint.rs b/packages/media_core/src/endpoint.rs index da2d190e..ef719b2e 100644 --- a/packages/media_core/src/endpoint.rs +++ b/packages/media_core/src/endpoint.rs @@ -3,8 +3,9 @@ use std::{marker::PhantomData, time::Instant}; use media_server_protocol::{ - endpoint::{PeerId, PeerMeta, RoomId, RoomInfoPublish, RoomInfoSubscribe, TrackMeta, TrackName, TrackPriority}, + endpoint::{BitrateControlMode, PeerId, PeerMeta, RoomId, RoomInfoPublish, RoomInfoSubscribe, TrackMeta, TrackName, TrackPriority}, media::MediaPacket, + protobuf, transport::RpcResult, }; use sans_io_runtime::{ @@ -26,21 +27,77 @@ mod middleware; pub struct EndpointSession(pub u64); -pub enum EndpointRemoteTrackReq {} +pub struct EndpointRemoteTrackConfig { + pub priority: TrackPriority, + pub control: Option, +} + +impl From for EndpointRemoteTrackConfig { + fn from(value: protobuf::shared::sender::Config) -> Self { + Self { + priority: value.priority.into(), + control: value.bitrate.map(|v| protobuf::shared::BitrateControlMode::try_from(v).ok()).flatten().map(|v| v.into()), + } + } +} + +pub enum EndpointRemoteTrackReq { + Config(EndpointRemoteTrackConfig), +} + +pub enum EndpointRemoteTrackRes { + Config(RpcResult<()>), +} + +pub struct EndpointLocalTrackSource { + pub peer: PeerId, + pub track: TrackName, +} -pub enum EndpointRemoteTrackRes {} +impl From for EndpointLocalTrackSource { + fn from(value: protobuf::shared::receiver::Source) -> Self { + Self { + peer: value.peer.into(), + track: value.track.into(), + } + } +} + +pub struct EndpointLocalTrackConfig { + pub priority: TrackPriority, + pub max_spatial: u8, + pub max_temporal: u8, + pub min_spatial: Option, + pub min_temporal: Option, +} + +impl From for EndpointLocalTrackConfig { + fn from(value: protobuf::shared::receiver::Config) -> Self { + Self { + priority: value.priority.into(), + max_spatial: value.max_spatial as u8, + max_temporal: value.max_temporal as u8, + min_spatial: value.min_spatial.map(|m| m as u8), + min_temporal: value.min_temporal.map(|m| m as u8), + } + } +} pub enum EndpointLocalTrackReq { - Switch(Option<(PeerId, TrackName, TrackPriority)>), + Attach(EndpointLocalTrackSource, EndpointLocalTrackConfig), + Detach(), + Config(EndpointLocalTrackConfig), } pub enum EndpointLocalTrackRes { - Switch(RpcResult<()>), + Attach(RpcResult<()>), + Detach(RpcResult<()>), + Config(RpcResult<()>), } -pub struct EndpointReqId(pub u64); -impl From for EndpointReqId { - fn from(value: u64) -> Self { +pub struct EndpointReqId(pub u32); +impl From for EndpointReqId { + fn from(value: u32) -> Self { Self(value) } } diff --git a/packages/media_core/src/endpoint/internal/local_track.rs b/packages/media_core/src/endpoint/internal/local_track.rs index 656781db..e2f01110 100644 --- a/packages/media_core/src/endpoint/internal/local_track.rs +++ b/packages/media_core/src/endpoint/internal/local_track.rs @@ -53,6 +53,7 @@ pub struct EndpointLocalTrack { impl EndpointLocalTrack { pub fn new(kind: MediaKind, room: Option) -> Self { + log::info!("[EndpointLocalTrack] track {kind}, room {:?}", room); Self { kind, room, @@ -113,8 +114,11 @@ impl EndpointLocalTrack { fn on_rpc_req(&mut self, _now: Instant, req_id: EndpointReqId, req: EndpointLocalTrackReq) -> Option { match req { - EndpointLocalTrackReq::Switch(Some((peer, track, priority))) => { + EndpointLocalTrackReq::Attach(source, config) => { + //TODO process config here if let Some(room) = self.room.as_ref() { + let peer = source.peer; + let track = source.track; log::info!("[EndpointLocalTrack] view room {room} peer {peer} track {track}"); if let Some((_peer, _track)) = self.bind.take() { log::info!("[EndpointLocalTrack] view room {room} peer {peer} track {track} => unsubscribe current {_peer} {_track}"); @@ -122,31 +126,35 @@ impl EndpointLocalTrack { self.queue.push_back(Output::Stopped(self.kind)); } self.bind = Some((peer.clone(), track.clone())); - self.queue.push_back(Output::Started(self.kind, priority)); + self.queue.push_back(Output::Started(self.kind, config.priority)); self.queue.push_back(Output::Cluster(*room, ClusterLocalTrackControl::Subscribe(peer, track))); self.selector.reset(); - Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Switch(Ok(())))) + Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Attach(Ok(())))) } else { log::warn!("[EndpointLocalTrack] view but not in room"); - Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Switch(Err(RpcError::new2(EndpointErrors::EndpointNotInRoom))))) + Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Attach(Err(RpcError::new2(EndpointErrors::EndpointNotInRoom))))) } } - EndpointLocalTrackReq::Switch(None) => { + EndpointLocalTrackReq::Detach() => { + //TODO process config here if let Some(room) = self.room.as_ref() { if let Some((peer, track)) = self.bind.take() { self.queue.push_back(Output::Stopped(self.kind)); self.queue.push_back(Output::Cluster(*room, ClusterLocalTrackControl::Unsubscribe)); log::info!("[EndpointLocalTrack] unview room {room} peer {peer} track {track}"); - Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Switch(Ok(())))) + Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Detach(Ok(())))) } else { log::warn!("[EndpointLocalTrack] unview but not bind to any source"); - Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Switch(Err(RpcError::new2(EndpointErrors::LocalTrackNotPinSource))))) + Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Detach(Err(RpcError::new2(EndpointErrors::LocalTrackNotPinSource))))) } } else { log::warn!("[EndpointLocalTrack] unview but not in room"); - Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Switch(Err(RpcError::new2(EndpointErrors::EndpointNotInRoom))))) + Some(Output::RpcRes(req_id, EndpointLocalTrackRes::Detach(Err(RpcError::new2(EndpointErrors::EndpointNotInRoom))))) } } + EndpointLocalTrackReq::Config(config) => { + todo!() + } } } diff --git a/packages/media_core/src/endpoint/internal/local_track/packet_selector.rs b/packages/media_core/src/endpoint/internal/local_track/packet_selector.rs index f7b4b678..2066ecb7 100644 --- a/packages/media_core/src/endpoint/internal/local_track/packet_selector.rs +++ b/packages/media_core/src/endpoint/internal/local_track/packet_selector.rs @@ -163,6 +163,8 @@ impl PacketSelector { self.queue.push_back(Action::RequestKeyFrame); self.need_key_frame = true; self.last_key_frame_ts = Some(now_ms); + } else { + log::info!("[LocalTrack/PacketSelector] video source changed and first pkt is key"); } } diff --git a/packages/media_core/src/endpoint/internal/remote_track.rs b/packages/media_core/src/endpoint/internal/remote_track.rs index ffef8962..735c987f 100644 --- a/packages/media_core/src/endpoint/internal/remote_track.rs +++ b/packages/media_core/src/endpoint/internal/remote_track.rs @@ -124,7 +124,7 @@ impl EndpointRemoteTrack { } fn on_rpc_req(&mut self, _now: Instant, _req_id: EndpointReqId, _req: EndpointRemoteTrackReq) -> Option { - None + todo!() } fn on_bitrate_allocation_action(&mut self, _now: Instant, action: IngressAction) -> Option { diff --git a/packages/protocol/proto/conn.proto b/packages/protocol/proto/conn.proto index 720d60a5..c46651dc 100644 --- a/packages/protocol/proto/conn.proto +++ b/packages/protocol/proto/conn.proto @@ -33,26 +33,38 @@ message Request { } message Sender { - message Switch { - optional shared.Sender.Source source = 1; + message Attach { + required shared.Sender.Source source = 1; + required shared.Sender.Config config = 2; + } + + message Detach { + } required string name = 1; oneof request { - Switch switch = 2; - shared.Sender.Config config = 3; + Attach attach = 2; + Detach detach = 3; + shared.Sender.Config config = 4; } } message Receiver { - message Switch { - optional shared.Receiver.Source source = 1; + message Attach { + required shared.Receiver.Source source = 1; + required shared.Receiver.Config config = 2; + } + + message Detach { + } required string name = 1; oneof request { - Switch switch = 2; - shared.Receiver.Config config = 3; + Attach attach = 2; + Detach detach = 3; + shared.Receiver.Config config = 4; } } @@ -91,27 +103,42 @@ message Response { } message Sender { - message Switch { + message Attach { + + } + + message Detach { + + } + + message Config { } oneof response { - Switch switch = 1; + Attach attach = 1; + Detach detach = 2; + Config config = 3; } } message Receiver { - message Switch { + message Attach { + + } + + message Detach { } - message Limit { + message Config { } oneof response { - Switch switch = 1; - Limit limit = 2; + Attach attach = 1; + Detach detach = 2; + Config config = 3; } } diff --git a/packages/protocol/src/media.rs b/packages/protocol/src/media.rs index 09ed8c15..53123be9 100644 --- a/packages/protocol/src/media.rs +++ b/packages/protocol/src/media.rs @@ -4,7 +4,7 @@ use serde::{Deserialize, Serialize}; use crate::protobuf::shared::Kind; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, derive_more::Display)] pub enum MediaKind { Audio, Video, diff --git a/packages/transport_webrtc/src/transport/webrtc.rs b/packages/transport_webrtc/src/transport/webrtc.rs index 8090ba58..dfa5b1b4 100644 --- a/packages/transport_webrtc/src/transport/webrtc.rs +++ b/packages/transport_webrtc/src/transport/webrtc.rs @@ -4,20 +4,18 @@ use std::{ }; use media_server_core::{ - endpoint::{EndpointEvent, EndpointReq}, + endpoint::{EndpointEvent, EndpointLocalTrackEvent, EndpointLocalTrackReq, EndpointRemoteTrackReq, EndpointReq, EndpointReqId, EndpointRes}, transport::{LocalTrackEvent, LocalTrackId, RemoteTrackEvent, RemoteTrackId, TransportError, TransportEvent, TransportOutput, TransportState}, }; use media_server_protocol::{ - endpoint::{BitrateControlMode, PeerId, PeerMeta, RoomId, RoomInfoPublish, RoomInfoSubscribe, TrackMeta, TrackPriority}, - media::{MediaKind, MediaScaling}, + endpoint::{PeerId, PeerMeta, RoomId, RoomInfoPublish, RoomInfoSubscribe}, + media::MediaKind, protobuf::{ self, conn::{ server_event::{ - receiver::Event as ProtoReceiverEvent2, - room::{Event as ProtoRoomEvent2, PeerJoined, PeerLeaved, TrackStarted}, - sender::Event as ProtoSenderEvent2, - Event as ProtoServerEvent, Receiver as ProtoReceiverEvent, Room as ProtoRoomEvent, Sender as ProtoSenderEvent, + room::{Event as ProtoRoomEvent2, PeerJoined, PeerLeaved, TrackStarted, TrackStopped}, + Event as ProtoServerEvent, Room as ProtoRoomEvent, }, ClientEvent, }, @@ -92,6 +90,10 @@ impl TransportWebrtcSdk { self.remote_tracks.iter_mut().find(|t| t.mid() == Some(mid)) } + fn remote_track_by_name(&mut self, name: &str) -> Option<&mut RemoteTrack> { + self.remote_tracks.iter_mut().find(|t| t.name() == name) + } + fn local_track(&mut self, track_id: LocalTrackId) -> Option<&mut LocalTrack> { self.local_tracks.iter_mut().find(|t| t.id() == track_id) } @@ -107,14 +109,20 @@ impl TransportWebrtcSdk { Some(InternalOutput::Str0mSendData(self.channel?, event.encode_to_vec())) } - fn build_res_err<'a>(&mut self, req_id: u32, err: RpcError) -> Option> { + fn build_rpc_res<'a>(&mut self, req_id: u32, res: protobuf::conn::response::Response) -> Option> { + self.build_event(protobuf::conn::server_event::Event::Response(protobuf::conn::Response { req_id, response: Some(res) })) + } + + fn build_rpc_res_err<'a>(&mut self, req_id: u32, err: RpcError) -> Option> { let response = protobuf::conn::response::Response::Error(err.into()); self.build_event(protobuf::conn::server_event::Event::Response(protobuf::conn::Response { req_id, response: Some(response) })) } } impl TransportWebrtcInternal for TransportWebrtcSdk { - fn on_codec_config(&mut self, cfg: &CodecConfig) {} + fn on_codec_config(&mut self, cfg: &CodecConfig) { + self.media_convert.set_config(cfg); + } fn on_tick<'a>(&mut self, now: Instant) -> Option> { match &self.state { @@ -172,7 +180,12 @@ impl TransportWebrtcInternal for TransportWebrtcSdk { })), })) } - EndpointEvent::PeerTrackStopped(_, _) => None, + EndpointEvent::PeerTrackStopped(peer, track) => { + log::info!("[TransportWebrtcSdk] peer {peer} track {track} stopped"); + self.build_event(ProtoServerEvent::Room(ProtoRoomEvent { + event: Some(ProtoRoomEvent2::TrackStopped(TrackStopped { peer: peer.0, track: track.0 })), + })) + } EndpointEvent::RemoteMediaTrack(track_id, event) => match event { media_server_core::endpoint::EndpointRemoteTrackEvent::RequestKeyFrame => { let mid = self.remote_track(track_id)?.mid()?; @@ -187,14 +200,58 @@ impl TransportWebrtcInternal for TransportWebrtcSdk { Some(InternalOutput::Str0mLimitBitrate(mid, bitrate)) } }, - EndpointEvent::LocalMediaTrack(_, _) => None, + EndpointEvent::LocalMediaTrack(track_id, event) => match event { + EndpointLocalTrackEvent::Media(pkt) => { + let mid = self.local_track(track_id)?.mid()?; + log::trace!("[TransportWebrtcSdk] send {:?} size {}", pkt.meta, pkt.data.len()); + Some(InternalOutput::Str0mSendMedia(mid, pkt)) + } + EndpointLocalTrackEvent::DesiredBitrate(_) => None, + }, EndpointEvent::BweConfig { .. } => None, EndpointEvent::GoAway(_, _) => None, } } - fn on_transport_rpc_res<'a>(&mut self, _now: Instant, _req_id: media_server_core::endpoint::EndpointReqId, _res: media_server_core::endpoint::EndpointRes) -> Option> { - None + fn on_transport_rpc_res<'a>(&mut self, _now: Instant, req_id: EndpointReqId, res: EndpointRes) -> Option> { + match res { + EndpointRes::JoinRoom(_) => todo!(), + EndpointRes::LeaveRoom(_) => todo!(), + EndpointRes::SubscribePeer(_) => todo!(), + EndpointRes::UnsubscribePeer(_) => todo!(), + EndpointRes::RemoteTrack(track_id, res) => match res { + media_server_core::endpoint::EndpointRemoteTrackRes::Config(Ok(_)) => self.build_rpc_res( + req_id.0, + protobuf::conn::response::Response::Sender(protobuf::conn::response::Sender { + response: Some(protobuf::conn::response::sender::Response::Config(protobuf::conn::response::sender::Config {})), + }), + ), + media_server_core::endpoint::EndpointRemoteTrackRes::Config(Err(err)) => self.build_rpc_res_err(req_id.0, err), + }, + EndpointRes::LocalTrack(_track_id, res) => match res { + media_server_core::endpoint::EndpointLocalTrackRes::Attach(Ok(_)) => self.build_rpc_res( + req_id.0, + protobuf::conn::response::Response::Receiver(protobuf::conn::response::Receiver { + response: Some(protobuf::conn::response::receiver::Response::Attach(protobuf::conn::response::receiver::Attach {})), + }), + ), + media_server_core::endpoint::EndpointLocalTrackRes::Detach(Ok(_)) => self.build_rpc_res( + req_id.0, + protobuf::conn::response::Response::Receiver(protobuf::conn::response::Receiver { + response: Some(protobuf::conn::response::receiver::Response::Detach(protobuf::conn::response::receiver::Detach {})), + }), + ), + media_server_core::endpoint::EndpointLocalTrackRes::Config(Ok(_)) => self.build_rpc_res( + req_id.0, + protobuf::conn::response::Response::Receiver(protobuf::conn::response::Receiver { + response: Some(protobuf::conn::response::receiver::Response::Config(protobuf::conn::response::receiver::Config {})), + }), + ), + media_server_core::endpoint::EndpointLocalTrackRes::Attach(Err(err)) => self.build_rpc_res_err(req_id.0, err), + media_server_core::endpoint::EndpointLocalTrackRes::Detach(Err(err)) => self.build_rpc_res_err(req_id.0, err), + media_server_core::endpoint::EndpointLocalTrackRes::Config(Err(err)) => self.build_rpc_res_err(req_id.0, err), + }, + } } fn on_str0m_event<'a>(&mut self, now: Instant, event: Str0mEvent) -> Option> { @@ -314,7 +371,7 @@ impl TransportWebrtcSdk { track.set_mid(media.mid); Some(InternalOutput::TransportOutput(TransportOutput::Event(TransportEvent::LocalTrack( track.id(), - LocalTrackEvent::Started(MediaKind::Audio), + LocalTrackEvent::Started(track.kind()), )))) } else { log::warn!("[TransportWebrtcSdk] not found track for mid {}", media.mid); @@ -331,7 +388,61 @@ impl TransportWebrtcSdk { fn on_str0m_channel_data<'a>(&mut self, data: ChannelData) -> Option> { let event = ClientEvent::decode(data.data.as_slice()).ok()?; log::info!("[TransportWebrtcSdk] on client event {:?}", event); - None + match event.event? { + protobuf::conn::client_event::Event::Request(req) => { + let req_id = req.req_id; + let to_out = |req: EndpointReq| -> Option> { Some(InternalOutput::TransportOutput(TransportOutput::RpcReq(req_id.into(), req))) }; + match req.request? { + protobuf::conn::request::Request::Session(req) => match req.request? { + protobuf::conn::request::session::Request::Join(req) => { + let meta = PeerMeta { metadata: req.info.metadata }; + to_out(EndpointReq::JoinRoom( + req.info.room.into(), + req.info.peer.into(), + meta, + req.info.publish.into(), + req.info.subscribe.into(), + )) + } + protobuf::conn::request::session::Request::Leave(_req) => to_out(EndpointReq::LeaveRoom), + protobuf::conn::request::session::Request::Sdp(_) => todo!(), + protobuf::conn::request::session::Request::Disconnect(_) => { + log::info!("[TransportWebrtcSdk] switched to disconnected with close action from client"); + self.state = State::Disconnected; + Some(InternalOutput::TransportOutput(TransportOutput::Event(TransportEvent::State(TransportState::Disconnected(None))))) + } + }, + protobuf::conn::request::Request::Sender(req) => { + let track = if let Some(track) = self.remote_track_by_name(&req.name) { + track + } else { + return self.build_rpc_res_err(req_id, RpcError::new2(WebrtcError::TrackNameNotFound)); + }; + + match req.request? { + protobuf::conn::request::sender::Request::Attach(attach) => todo!(), + protobuf::conn::request::sender::Request::Detach(_) => todo!(), + protobuf::conn::request::sender::Request::Config(config) => to_out(EndpointReq::RemoteTrack(track.id(), EndpointRemoteTrackReq::Config(config.into()))), + } + } + protobuf::conn::request::Request::Receiver(req) => { + let track = if let Some(track) = self.local_track_by_name(&req.name) { + track + } else { + return self.build_rpc_res_err(req_id, RpcError::new2(WebrtcError::TrackNameNotFound)); + }; + + match req.request? { + protobuf::conn::request::receiver::Request::Attach(attach) => { + to_out(EndpointReq::LocalTrack(track.id(), EndpointLocalTrackReq::Attach(attach.source.into(), attach.config.into()))) + } + protobuf::conn::request::receiver::Request::Detach(_) => to_out(EndpointReq::LocalTrack(track.id(), EndpointLocalTrackReq::Detach())), + protobuf::conn::request::receiver::Request::Config(config) => to_out(EndpointReq::LocalTrack(track.id(), EndpointLocalTrackReq::Config(config.into()))), + } + } + } + } + } } } diff --git a/packages/transport_webrtc/src/transport/webrtc/local_track.rs b/packages/transport_webrtc/src/transport/webrtc/local_track.rs index b673599e..5b3c3f13 100644 --- a/packages/transport_webrtc/src/transport/webrtc/local_track.rs +++ b/packages/transport_webrtc/src/transport/webrtc/local_track.rs @@ -10,11 +10,12 @@ pub struct LocalTrack { } impl LocalTrack { - pub fn new(id: LocalTrackId, config: protobuf::shared::Receiver) -> Self { + pub fn new(id: LocalTrackId, cfg: protobuf::shared::Receiver) -> Self { + log::info!("[TransportWebrcSdk/LocalTrack] create {id} config {:?}", cfg); Self { id, - name: config.name.clone().into(), - kind: config.kind().into(), + name: cfg.name.clone().into(), + kind: cfg.kind().into(), mid: None, } } @@ -36,6 +37,7 @@ impl LocalTrack { } pub fn set_mid(&mut self, mid: Mid) { + log::info!("[TransportWebrcSdk/LocalTrack] set_mid {}/{} => {}", self.id, self.name, mid); assert_eq!(self.mid, None, "LocalTrack mid {:?} already configed", self.mid); self.mid = Some(mid); } diff --git a/packages/transport_webrtc/src/transport/webrtc/remote_track.rs b/packages/transport_webrtc/src/transport/webrtc/remote_track.rs index fde7fdcd..3a69a132 100644 --- a/packages/transport_webrtc/src/transport/webrtc/remote_track.rs +++ b/packages/transport_webrtc/src/transport/webrtc/remote_track.rs @@ -20,6 +20,7 @@ pub struct RemoteTrack { impl RemoteTrack { pub fn new(id: RemoteTrackId, cfg: protobuf::shared::Sender) -> Self { + log::info!("[TransportWebrcSdk/RemoteTrack] create {id} config {:?}", cfg); Self { id, name: cfg.name.clone().into(), @@ -52,6 +53,7 @@ impl RemoteTrack { } pub fn set_str0m(&mut self, mid: Mid, sim: bool) { + log::info!("[TransportWebrcSdk/RemoteTrack] set_mid {}/{} => {}, simulcast {}", self.id, self.name, mid, sim); assert_eq!(self.mid, None, "LocalTrack mid {:?} already configed", self.mid); self.mid = Some(mid); if sim { diff --git a/packages/transport_webrtc/src/transport/whep.rs b/packages/transport_webrtc/src/transport/whep.rs index 2895eb61..5e2a72c1 100644 --- a/packages/transport_webrtc/src/transport/whep.rs +++ b/packages/transport_webrtc/src/transport/whep.rs @@ -4,7 +4,7 @@ use std::{ }; use media_server_core::{ - endpoint::{EndpointEvent, EndpointLocalTrackEvent, EndpointLocalTrackReq, EndpointReq}, + endpoint::{EndpointEvent, EndpointLocalTrackConfig, EndpointLocalTrackEvent, EndpointLocalTrackReq, EndpointLocalTrackSource, EndpointReq}, transport::{LocalTrackEvent, LocalTrackId, TransportError, TransportEvent, TransportOutput, TransportState}, }; use media_server_protocol::{ @@ -290,7 +290,19 @@ impl TransportWebrtcWhep { log::info!("[TransportWebrtcWhep] send subscribe {peer} {track}"); return Some(InternalOutput::TransportOutput(TransportOutput::RpcReq( 0.into(), //TODO generate req_id - EndpointReq::LocalTrack(AUDIO_TRACK, EndpointLocalTrackReq::Switch(Some((peer, track, DEFAULT_PRIORITY)))), + EndpointReq::LocalTrack( + AUDIO_TRACK, + EndpointLocalTrackReq::Attach( + EndpointLocalTrackSource { peer, track }, + EndpointLocalTrackConfig { + priority: DEFAULT_PRIORITY, + max_spatial: 2, + max_temporal: 2, + min_spatial: None, + min_temporal: None, + }, + ), + ), ))); } @@ -300,7 +312,19 @@ impl TransportWebrtcWhep { log::info!("[TransportWebrtcWhep] send subscribe {peer} {track}"); return Some(InternalOutput::TransportOutput(TransportOutput::RpcReq( 0.into(), //TODO generate req_id - EndpointReq::LocalTrack(VIDEO_TRACK, EndpointLocalTrackReq::Switch(Some((peer, track, DEFAULT_PRIORITY)))), + EndpointReq::LocalTrack( + VIDEO_TRACK, + EndpointLocalTrackReq::Attach( + EndpointLocalTrackSource { peer, track }, + EndpointLocalTrackConfig { + priority: DEFAULT_PRIORITY, + max_spatial: 2, + max_temporal: 2, + min_spatial: None, + min_temporal: None, + }, + ), + ), ))); } } @@ -317,7 +341,7 @@ impl TransportWebrtcWhep { log::info!("[TransportWebrtcWhep] send unsubscribe {peer} {track}"); return Some(InternalOutput::TransportOutput(TransportOutput::RpcReq( 0.into(), //TODO generate req_id - EndpointReq::LocalTrack(AUDIO_TRACK, EndpointLocalTrackReq::Switch(None)), + EndpointReq::LocalTrack(AUDIO_TRACK, EndpointLocalTrackReq::Detach()), ))); } @@ -326,7 +350,7 @@ impl TransportWebrtcWhep { log::info!("[TransportWebrtcWhep] send unsubscribe {peer} {track}"); return Some(InternalOutput::TransportOutput(TransportOutput::RpcReq( 0.into(), //TODO generate req_id - EndpointReq::LocalTrack(VIDEO_TRACK, EndpointLocalTrackReq::Switch(None)), + EndpointReq::LocalTrack(VIDEO_TRACK, EndpointLocalTrackReq::Detach()), ))); }