@@ -14,7 +14,8 @@ use pulsebeam_runtime::{net::Transport, prelude::*};
1414use str0m:: {
1515 Candidate , Rtc , RtcConfig , RtcError ,
1616 change:: { SdpAnswer , SdpOffer } ,
17- media:: { Direction , MediaKind } ,
17+ format:: { Codec , FormatParams } ,
18+ media:: { Direction , Frequency , MediaKind , Pt } ,
1819 net:: TcpType ,
1920} ;
2021use tokio:: { sync:: oneshot, task:: JoinSet , time:: Instant } ;
@@ -280,6 +281,8 @@ impl ControllerActor {
280281 offer : SdpOffer ,
281282 sockets : & [ & UnifiedSocketWriter ] ,
282283 ) -> Result < ( Rtc , SdpAnswer ) , ControllerError > {
284+ const PT_OPUS : Pt = Pt :: new_with_value ( 111 ) ;
285+
283286 tracing:: debug!( "{offer}" ) ;
284287 let mut rtc_config = RtcConfig :: new ( )
285288 . clear_codecs ( )
@@ -295,7 +298,19 @@ impl ControllerActor {
295298 rtc_config. set_max_stun_rto ( Duration :: from_millis ( 1500 ) ) ;
296299 rtc_config. set_max_stun_retransmits ( 5 ) ;
297300 let codec_config = rtc_config. codec_config ( ) ;
298- codec_config. enable_opus ( true ) ;
301+ codec_config. add_config (
302+ PT_OPUS ,
303+ None ,
304+ Codec :: Opus ,
305+ Frequency :: FORTY_EIGHT_KHZ ,
306+ Some ( 2 ) ,
307+ FormatParams {
308+ min_p_time : Some ( 10 ) ,
309+ use_inband_fec : Some ( true ) ,
310+ use_dtx : Some ( true ) ,
311+ ..Default :: default ( )
312+ } ,
313+ ) ;
299314 // codec_config.enable_vp8(true);
300315 // h264 as the lowest common denominator due to small clients like
301316 // embedded devices, smartphones, OBS only supports H264.
0 commit comments