Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added experimental ff and marked some api as experimental #120

Merged
merged 1 commit into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions jarust_plugins/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ default = ["echo_test", "audio_bridge", "video_room"]
echo_test = []
audio_bridge = []
video_room = []
__experimental = []

[dev-dependencies]
anyhow = "1.0.79"
Expand Down
26 changes: 8 additions & 18 deletions jarust_plugins/examples/video_room.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
use jarust::jaconfig::JaConfig;
use jarust::jaconfig::TransportType;
use jarust_transport::japrotocol::{EstablishmentProtocol, Jsep, JsepType};
use jarust::jaconnection::CreateConnectionParams;
use jarust::TransactionGenerationStrategy;
use jarust_plugins::video_room::jahandle_ext::VideoRoom;
use jarust_plugins::video_room::msg_options::*;
use jarust_plugins::{AttachPluginParams, Identifier};
use jarust_plugins::AttachPluginParams;
use jarust_plugins::Identifier;
use jarust_transport::japrotocol::EstablishmentProtocol;
use jarust_transport::japrotocol::Jsep;
use jarust_transport::japrotocol::JsepType;
use std::path::Path;
use tracing_subscriber::EnvFilter;

Expand Down Expand Up @@ -39,7 +42,7 @@ async fn main() -> anyhow::Result<()> {
.attach_video_room(AttachPluginParams { capacity, timeout })
.await?;

let event_logger = tokio::spawn(async move {
tokio::spawn(async move {
while let Some(e) = events.recv().await {
tracing::info!("{e:#?}");
}
Expand All @@ -62,18 +65,8 @@ async fn main() -> anyhow::Result<()> {
.edit_room(
room_id.clone(),
VideoRoomEditOptions {
secret: None,
new_description: Some("A brand new description!".to_string()),
new_secret: None,
new_pin: None,
new_is_private: None,
new_require_pvtid: None,
new_bitrate: None,
new_fir_freq: None,
new_publishers: None,
new_lock_record: None,
new_rec_dir: None,
permanent: None,
..Default::default()
},
timeout,
)
Expand Down Expand Up @@ -152,14 +145,11 @@ async fn main() -> anyhow::Result<()> {
videocodec: Some("h264".to_string()),
bitrate: Some(3500),
record: Some(false),
filename: None,
display: None,
audio_level_average: None,
audio_active_packets: None,
descriptions: vec![VideoRoomPublishDescription {
mid: "stream-0".to_string(),
description: "The ultimate stream!!".to_string(),
}],
..Default::default()
},
timeout,
)
Expand Down
4 changes: 2 additions & 2 deletions jarust_plugins/src/audio_bridge/msg_opitons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ use crate::Identifier;
use serde::Serialize;

tryfrom_serde_value!(
ChangeRoomOptions EditRoomOptions DestroyRoomMsg JoinRoomOptions
CreateRoomOptions EditRoomOptions DestroyRoomMsg JoinRoomOptions
AllowedOptions AllowAction ConfigureOptions MuteOptions MuteRoomOptions
KickOptions KickAllOptions CreateRoomOptions
KickOptions KickAllOptions ChangeRoomOptions
);

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Default, Serialize)]
Expand Down
12 changes: 8 additions & 4 deletions jarust_plugins/src/video_room/events.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
use crate::video_room::responses::{AttachedStream, Attendee, ConfiguredStream, Publisher};
use crate::video_room::responses::AttachedStream;
use crate::video_room::responses::Attendee;
use crate::video_room::responses::ConfiguredStream;
use crate::video_room::responses::Publisher;
use crate::Identifier;
use jarust::error::JaError;
use jarust::prelude::JaResponse;
use jarust_transport::error::JaTransportError;
use jarust_transport::japrotocol::{
EstablishmentProtocol, GenericEvent, JaHandleEvent, ResponseType,
};
use jarust_transport::japrotocol::EstablishmentProtocol;
use jarust_transport::japrotocol::GenericEvent;
use jarust_transport::japrotocol::JaHandleEvent;
use jarust_transport::japrotocol::ResponseType;
use serde::Deserialize;
use serde_json::from_value;

Expand Down
24 changes: 14 additions & 10 deletions jarust_plugins/src/video_room/handle.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
use std::ops::Deref;
use std::time::Duration;

use serde_json::json;

use jarust::prelude::*;
use jarust_rt::JaTask;
use jarust_transport::japrotocol::EstablishmentProtocol;

use crate::video_room::msg_options::*;
use crate::video_room::responses::*;
use crate::Identifier;
use jarust::prelude::*;
use jarust_rt::JaTask;
use jarust_transport::japrotocol::EstablishmentProtocol;
use serde_json::json;
use std::ops::Deref;
use std::time::Duration;

pub struct VideoRoomHandle {
handle: JaHandle,
Expand Down Expand Up @@ -148,6 +145,7 @@ impl VideoRoomHandle {
self.handle.send_waiton_rsp::<()>(message, timeout).await
}

#[cfg(feature = "__experimental")]
pub async fn moderate(
&self,
room: Identifier,
Expand Down Expand Up @@ -194,6 +192,7 @@ impl VideoRoomHandle {
.await
}

#[cfg(feature = "__experimental")]
pub async fn list_forwarders(
&self,
room: Identifier,
Expand All @@ -209,6 +208,7 @@ impl VideoRoomHandle {
.await
}

#[cfg(feature = "__experimental")]
pub async fn rtp_forward(
&self,
room: Identifier,
Expand All @@ -224,6 +224,7 @@ impl VideoRoomHandle {
.await
}

#[cfg(feature = "__experimental")]
pub async fn stop_rtp_forward(
&self,
room: Identifier,
Expand Down Expand Up @@ -352,7 +353,7 @@ impl VideoRoomHandle {
Ok(())
}

/// A combination of [join_as_publisher()] and [configure_publisher()]
/// A combination of [VideoRoomHandle::join_as_publisher()] and [VideoRoomHandle::configure_publisher()]
pub async fn join_and_configure(
&self,
join_options: VideoRoomPublisherJoinOptions,
Expand Down Expand Up @@ -447,6 +448,7 @@ impl VideoRoomHandle {
Ok(())
}

#[cfg(feature = "__experimental")]
pub async fn update(
&self,
subscribe: Vec<VideoRoomSubscriberJoinStream>,
Expand All @@ -464,13 +466,15 @@ impl VideoRoomHandle {
Ok(())
}

#[cfg(feature = "__experimental")]
pub async fn pause(&self, timeout: Duration) -> JaResult<()> {
self.handle
.send_waiton_ack(json!({"request": "pause"}), timeout)
.await?;
Ok(())
}

#[cfg(feature = "__experimental")]
pub async fn switch(
&self,
streams: Vec<VideoRoomSwitchStream>,
Expand Down
14 changes: 5 additions & 9 deletions jarust_plugins/src/video_room/jahandle_ext.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
use std::ops::Deref;

use jarust::japlugin::AttachHandleParams;
use tokio::sync::mpsc;

use jarust::prelude::*;

use crate::AttachPluginParams;

use super::events::PluginEvent;
use super::handle::VideoRoomHandle;
use crate::AttachPluginParams;
use jarust::japlugin::AttachHandleParams;
use jarust::prelude::*;
use std::ops::Deref;
use tokio::sync::mpsc;

#[async_trait::async_trait]
pub trait VideoRoom: Attach {
Expand Down
3 changes: 1 addition & 2 deletions jarust_plugins/src/video_room/msg_options.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde::Serialize;

use crate::Identifier;
use serde::Serialize;

//
// Create Message
Expand Down
3 changes: 1 addition & 2 deletions jarust_plugins/src/video_room/responses.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use serde::Deserialize;

use crate::Identifier;
use serde::Deserialize;

#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug, Deserialize)]
pub struct Room {
Expand Down
Loading