Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
wkazmierczak committed Oct 21, 2024
1 parent b96f664 commit 647d600
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion compositor_pipeline/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ impl Pipeline {
download_dir: download_dir.into(),
event_emitter,
tokio_rt: Arc::new(
Runtime::new().map_err(|err| InitPipelineError::CreateTokioRuntime(err))?,
Runtime::new().map_err(InitPipelineError::CreateTokioRuntime)?,
),
#[cfg(feature = "vk-video")]
vulkan_ctx: preinitialized_ctx.and_then(|ctx| ctx.vulkan_ctx),
Expand Down
13 changes: 5 additions & 8 deletions compositor_pipeline/src/pipeline/output/whip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,18 @@ fn start_whip_sender_thread(

match chunk.kind {
DataKind::Audio => {
if let Err(_) = audio_track.write(&chunk.data).await {
if audio_track.write(&chunk.data).await.is_err() {
error!("Error occurred while writing to audio track for session");
}
}
DataKind::Video => {
if let Err(_) = video_track.write(&chunk.data).await {
if video_track.write(&chunk.data).await.is_err() {
error!("Error occurred while writing to video track for session");
}
}
}
}
let _ = client.delete(whip_session_url).send().await; // not unwrapping, because server may have gone down, so it should be handled better way
let _ = client.delete(whip_session_url).send().await;
});
}

Expand Down Expand Up @@ -204,7 +204,6 @@ async fn init_pc() -> (
..Default::default()
};
let peer_connection = Arc::new(api.new_peer_connection(config).await.unwrap());
// Create Track that we send video back to browser on
let video_track = Arc::new(TrackLocalStaticRTP::new(
RTCRtpCodecCapability {
mime_type: MIME_TYPE_H264.to_owned(),
Expand Down Expand Up @@ -236,11 +235,10 @@ async fn connect(
peer_connection: Arc<RTCPeerConnection>,
endpoint_url: String,
bearer_token: String,
should_close: Arc<AtomicBool>, // TODO handle should_close if necessary
should_close: Arc<AtomicBool>,
tokio_rt: Arc<tokio::runtime::Runtime>,
client: reqwest::Client,
) -> anyhow::Result<Url> {
// TODO replace anyhow with proper errors
peer_connection.on_ice_connection_state_change(Box::new(
move |connection_state: RTCIceConnectionState| {
debug!("Connection State has changed {connection_state}");
Expand Down Expand Up @@ -289,7 +287,7 @@ async fn connect(
.unwrap();

let answer = response.bytes().await.unwrap();
let _ = peer_connection.set_local_description(offer).await.unwrap();
peer_connection.set_local_description(offer).await.unwrap();

peer_connection
.set_remote_description(
Expand All @@ -302,7 +300,6 @@ async fn connect(
let client = Arc::new(client);

let location1: Url = location_url.clone();
println!("{location1}");

peer_connection.on_ice_candidate(Box::new(move |candidate| {
if let Some(candidate) = candidate {
Expand Down
3 changes: 1 addition & 2 deletions integration_tests/examples/whip_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ fn client_code() -> Result<()> {
&json!({
"type": "whip",
"endpoint_url": "https://g.webrtc.live-video.net:4443/v2/offer",
// "endpoint_url": "http://localhost:9000/whip",
"bearer_token": "", // your Bearer token
"bearer_token": "", // your Bearer token
"video": {
"resolution": {
"width": VIDEO_RESOLUTION.width,
Expand Down

0 comments on commit 647d600

Please sign in to comment.