fix negotiation crash with CallFactoryInterface for media & moved RTCEngine code to EngineInternal
This commit is contained in:
@@ -2,6 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use thiserror::Error;
|
||||
use tokio::sync::Mutex;
|
||||
use tracing::{event, Level, trace};
|
||||
|
||||
use crate::local_participant::LocalParticipant;
|
||||
use crate::rtc_engine;
|
||||
@@ -17,7 +18,7 @@ pub struct Room {
|
||||
sid: String,
|
||||
name: String,
|
||||
local_participant: LocalParticipant,
|
||||
engine: Arc<Mutex<RTCEngine>>,
|
||||
internal: Arc<RoomInternal>
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip(url, token))]
|
||||
@@ -25,19 +26,21 @@ pub async fn connect(url: &str, token: &str) -> Result<Room, RoomError> {
|
||||
let engine = rtc_engine::connect(url, token).await?;
|
||||
|
||||
engine.on_data(Box::new(|packet| {
|
||||
event!(Level::DEBUG, "received data");
|
||||
Box::pin(async move {})
|
||||
})).await;
|
||||
|
||||
let join = engine.join_response().await;
|
||||
let engine = Arc::new(Mutex::new(engine));
|
||||
let lp = LocalParticipant::from(join.participant.unwrap(), engine.clone());
|
||||
let local_participant = LocalParticipant::from(join.participant.unwrap(), engine.clone());
|
||||
|
||||
let internal = Arc::new(RoomInternal::new(engine));
|
||||
let room_info = join.room.unwrap();
|
||||
Ok(Room {
|
||||
sid: room_info.sid,
|
||||
name: room_info.name,
|
||||
local_participant: lp,
|
||||
engine,
|
||||
local_participant,
|
||||
internal,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,3 +57,16 @@ impl Room {
|
||||
&self.name
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct RoomInternal {
|
||||
engine: Arc<Mutex<RTCEngine>>,
|
||||
}
|
||||
|
||||
impl RoomInternal {
|
||||
pub fn new(engine: Arc<Mutex<RTCEngine>>) -> Self {
|
||||
Self {
|
||||
engine
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user