Skip to content

Commit 897be5d

Browse files
committed
use http and refactor slot auto subscribe
1 parent d78403d commit 897be5d

File tree

5 files changed

+18
-21
lines changed

5 files changed

+18
-21
lines changed

demo/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ <h2>PulseBeam</h2>
1414

1515
<form id="controls" class="field middle-align mb-2">
1616
<input type="text" id="endpoint" placeholder="Enter WHIP/WHEP endpoint"
17-
value="https://localhost:3000/api/v1/rooms/test" required />
17+
value="http://localhost:3000/api/v1/rooms/test" required />
1818
<button type="submit" id="toggle" class="small-round">Start</button>
1919
</form>
2020

demo/vite.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ import basicSsl from '@vitejs/plugin-basic-ssl'
22

33
export default {
44
plugins: [
5-
basicSsl()
5+
// basicSsl()
66
],
77
}

pulsebeam/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ pub async fn run(cpu_rt: rt::Runtime) {
7777
external_ip,
7878
);
7979

80-
node::run(cpu_rt, external_addr, unified_socket, http_socket, true)
80+
node::run(cpu_rt, external_addr, unified_socket, http_socket, false)
8181
.await
8282
.unwrap();
8383
}

pulsebeam/src/participant.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -270,34 +270,32 @@ impl ParticipantActor {
270270
}
271271

272272
async fn auto_subscribe(&mut self, ctx: &mut actor::ActorContext<Self>) {
273-
let mut slot_iter = self.subscribed_video_tracks.iter_mut();
273+
let mut available_tracks = self.available_video_tracks.iter_mut();
274274

275-
'outer: for (track_id, track) in self.available_video_tracks.iter_mut() {
276-
if track.mid.is_some() {
275+
for (slot_id, slot) in self.subscribed_video_tracks.iter_mut() {
276+
if slot.track_id.is_some() {
277277
continue;
278278
}
279279

280-
loop {
281-
let (slot_id, slot) = if let Some(slot) = slot_iter.next() {
282-
slot
283-
} else {
284-
break 'outer;
285-
};
280+
for (track_id, track) in &mut available_tracks {
281+
if track.mid.is_some() {
282+
continue;
283+
}
286284

287-
if slot.track_id.is_some() {
285+
if track
286+
.track
287+
.send_high(track::TrackControlMessage::Subscribe(ctx.handle.clone()))
288+
.await
289+
.is_err()
290+
{
288291
continue;
289292
}
290293

291294
track.mid.replace(*slot_id);
292295
let meta = &track.track.meta;
293296
slot.track_id.replace(meta.id.clone());
294-
295-
// TODO: handle rejection
296-
track
297-
.track
298-
.send_high(track::TrackControlMessage::Subscribe(ctx.handle.clone()))
299-
.await;
300297
tracing::info!("allocated slot: {track_id} -> {slot_id}");
298+
break;
301299
}
302300
}
303301
}
@@ -589,7 +587,6 @@ impl ParticipantActor {
589587
return;
590588
};
591589

592-
tracing::trace!("wrote to rtp");
593590
if let Err(err) = writer.write(pt, data.network_time, data.time, data.data.clone()) {
594591
tracing::error!("failed to write media: {}", err);
595592
self.rtc.disconnect();

pulsebeam/src/signaling.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ async fn join_room(
7878

7979
// TODO: remove hardcoded URI
8080
let location_url = format!(
81-
"https://localhost:3000/api/v1/rooms/{}/participants/{}",
81+
"http://localhost:3000/api/v1/rooms/{}/participants/{}",
8282
&room_id.external, &participant_id
8383
);
8484
let mut response_headers = HeaderMap::new();

0 commit comments

Comments
 (0)