Skip to content

Commit f3ba6f9

Browse files
committed
use 0x42001f h264 profile for compatibility
1 parent d4361cc commit f3ba6f9

File tree

3 files changed

+36
-17
lines changed

3 files changed

+36
-17
lines changed

pulsebeam-runtime/src/actor.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub trait Actor: Sized + Send + 'static {
8888
/// The type of low-priority messages this actor processes.
8989
type LowPriorityMsg: Debug + Send + 'static;
9090
/// The unique identifier for this actor.
91-
type Meta: Eq + Hash + Debug + Clone + Send;
91+
type Meta: Eq + Hash + Display + Debug + Clone + Send;
9292

9393
/// ObservableState is a state snapshot of an actor. This is mainly used
9494
/// for testing.
@@ -204,7 +204,7 @@ impl<A: Actor> Clone for ActorHandle<A> {
204204

205205
impl<A: Actor> std::fmt::Debug for ActorHandle<A> {
206206
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
207-
self.meta.fmt(f)
207+
std::fmt::Debug::fmt(&self.meta, f)
208208
}
209209
}
210210

@@ -325,11 +325,9 @@ pub fn spawn<A: Actor>(a: A, config: RunnerConfig) -> (ActorHandle<A>, JoinHandl
325325
};
326326

327327
let actor_id = a.meta().clone();
328-
let join = tokio::spawn(run(a, ctx).instrument(tracing::span!(
329-
tracing::Level::INFO,
330-
"run",
331-
?actor_id
332-
)))
328+
let join = tokio::spawn(
329+
run(a, ctx).instrument(tracing::span!(tracing::Level::INFO, "run", %actor_id)),
330+
)
333331
.map(|res| match res {
334332
Ok(ret) => (actor_id, ret),
335333
Err(_) => (actor_id, ActorStatus::ShutDown),
@@ -368,7 +366,7 @@ async fn run<A: Actor>(mut a: A, mut ctx: ActorContext<A>) -> ActorStatus {
368366
};
369367

370368
tracing::debug!("post_stop successful.");
371-
tracing::info!(status = %status_after_run, "exited.");
369+
tracing::info!(status = %status_after_run, "exited");
372370

373371
status_after_run
374372
}

pulsebeam/src/controller.rs

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
use futures::stream::FuturesUnordered;
88
use pulsebeam_runtime::actor;
99
use pulsebeam_runtime::prelude::*;
10-
use str0m::{Candidate, Rtc, RtcError, change::SdpOffer, error::SdpError};
10+
use str0m::{Candidate, RtcConfig, RtcError, change::SdpOffer, error::SdpError};
1111
use tokio::sync::oneshot;
1212

1313
#[derive(thiserror::Error, Debug)]
@@ -103,16 +103,30 @@ impl ControllerActor {
103103
offer: String,
104104
) -> Result<String, ControllerError> {
105105
let offer = SdpOffer::from_sdp_string(&offer)?;
106-
let mut rtc = Rtc::builder()
106+
tracing::info!("{offer}");
107+
let mut rtc_config = RtcConfig::new()
108+
.clear_codecs()
107109
// Uncomment this to see statistics
108110
// .set_stats_interval(Some(Duration::from_secs(1)))
109-
.set_ice_lite(false)
110-
.enable_vp9(false)
111-
.enable_vp8(false)
112-
// h264 as the lowest common denominator due to small clients like
113-
// embedded devices, smartphones, OBS only supports H264
114-
.enable_h264(true)
115-
.build();
111+
.set_ice_lite(false);
112+
let codec_config = rtc_config.codec_config();
113+
codec_config.enable_opus(true);
114+
// h264 as the lowest common denominator due to small clients like
115+
// embedded devices, smartphones, OBS only supports H264.
116+
// Baseline profile to ensure compatibility with all platforms.
117+
codec_config.add_h264(
118+
108.into(), // PT for video
119+
Some(109.into()), // RTX PT
120+
true, // packetization-mode = 1
121+
0x42e01f, // Baseline 3.1
122+
);
123+
// codec_config.add_h264(
124+
// 127.into(), // PT for video
125+
// Some(121.into()), // RTX PT
126+
// true, // packetization-mode = 1 (fragmented)
127+
// 0x42001f, // Constrained Baseline 3.1
128+
// );
129+
let mut rtc = rtc_config.build();
116130

117131
for addr in self.local_addrs.iter() {
118132
// TODO: add tcp and ssltcp later
@@ -138,6 +152,7 @@ impl ControllerActor {
138152
.await
139153
.map_err(|_| ControllerError::ServiceUnavailable)?;
140154

155+
tracing::info!("{answer}");
141156
Ok(answer.to_sdp_string())
142157
}
143158

pulsebeam/src/message.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ pub struct TrackMeta {
3030
pub simulcast_rids: Option<Vec<Rid>>,
3131
}
3232

33+
impl std::fmt::Display for TrackMeta {
34+
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
35+
std::fmt::Display::fmt(&self.id, f)
36+
}
37+
}
38+
3339
#[derive(Debug)]
3440
pub struct KeyframeRequest {
3541
pub rid: Option<Rid>,

0 commit comments

Comments
 (0)