mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-09-19 03:18:46 +00:00
Relay client call signals to RTC proxy
This commit is contained in:
45
src/data/call_signal.rs
Normal file
45
src/data/call_signal.rs
Normal file
@@ -0,0 +1,45 @@
|
||||
//! # Call signal
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::data::error::{ExecError, Res};
|
||||
use crate::data::user::UserID;
|
||||
|
||||
pub enum SdpType {
|
||||
Offer,
|
||||
Answer,
|
||||
}
|
||||
|
||||
pub struct IceCandidate {
|
||||
pub candidate: String,
|
||||
pub sdp_m_line_index: u64,
|
||||
pub sdp_mid: String,
|
||||
}
|
||||
|
||||
pub enum CallSignal {
|
||||
/// Session Description Protocol
|
||||
SDP(String, SdpType, webrtc_sdp::SdpSession),
|
||||
|
||||
/// ICE candidate
|
||||
Candidate(IceCandidate, webrtc_sdp::attribute_type::SdpAttribute),
|
||||
}
|
||||
|
||||
pub struct NewUserCallSignal {
|
||||
pub call_hash: String,
|
||||
|
||||
/// This value is set to none if the user who streams content is the same
|
||||
/// as the receiver
|
||||
pub user_id: Option<UserID>,
|
||||
pub signal: CallSignal,
|
||||
pub raw_data: String,
|
||||
}
|
||||
|
||||
impl SdpType {
|
||||
pub fn from_str(val: &str) -> Res<SdpType> {
|
||||
match val {
|
||||
"offer" => Ok(SdpType::Offer),
|
||||
"answer" => Ok(SdpType::Answer),
|
||||
_ => Err(ExecError::boxed_new(&format!("SDP type {} is unknown!", val)))
|
||||
}
|
||||
}
|
||||
}
|
@@ -37,4 +37,5 @@ pub mod lang_settings;
|
||||
pub mod security_settings;
|
||||
pub mod new_custom_emoji;
|
||||
pub mod user_ws_message;
|
||||
pub mod user_ws_connection;
|
||||
pub mod user_ws_connection;
|
||||
pub mod call_signal;
|
@@ -7,8 +7,7 @@ use serde::Serialize;
|
||||
use crate::api_data::http_error::HttpError;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::base_request_handler::{BaseRequestHandler, RequestValue};
|
||||
use crate::data::conversation::ConvID;
|
||||
use crate::data::error::{Res, ResultBoxError};
|
||||
use crate::data::error::ResultBoxError;
|
||||
use crate::data::user::UserID;
|
||||
use crate::data::user_ws_connection::UserWsConnection;
|
||||
|
||||
@@ -62,17 +61,6 @@ impl UserWsRequestHandler {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Get the ID of a call included in a WebSocket request
|
||||
pub fn post_call_id(&mut self, name: &str) -> Res<ConvID> {
|
||||
let conv_id = self.post_u64(name)?;
|
||||
|
||||
if !self.connection.is_having_call_with_conversation(&conv_id) {
|
||||
self.forbidden("You do not belong to this call!".to_string())?;
|
||||
}
|
||||
|
||||
Ok(conv_id)
|
||||
}
|
||||
}
|
||||
|
||||
impl BaseRequestHandler for UserWsRequestHandler {
|
||||
|
Reference in New Issue
Block a user