Skip to content

Commit 5ce31a5

Browse files
committed
[*] fix: share screen disable audio causes error
1 parent a761bbc commit 5ce31a5

File tree

6 files changed

+26
-35
lines changed

6 files changed

+26
-35
lines changed

lib/recorder/examples/share_screen_demo.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,22 +44,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4444
.with_share_screen_config(
4545
ShareScreenConfig::new("0.0.0.0:9090".to_string())
4646
.with_save_mp4(true)
47-
.with_disable_host_ipv6(true)
48-
// .with_enable_https(true)
49-
// .with_cert_file(Some("../wrtc/data/ca.crt".to_string()))
50-
// .with_key_file(Some("../wrtc/data/ca.key".to_string()))
51-
// start turnserver: `turnserver -c ./turnserver.conf -v`
52-
// .with_turn_server(Some(RTCIceServer {
53-
// urls: vec!["turn:192.168.10.8:3478".to_string()],
54-
// username: "foo".to_string(),
55-
// credential: "123456".to_string(),
56-
// })) // NOTE: change or remove it
57-
// .with_stun_server(Some(RTCIceServer {
58-
// urls: vec!["stun:192.168.10.8:3478".to_string()],
59-
// username: "foo".to_string(),
60-
// credential: "123456".to_string(),
61-
// })) // NOTE: change or remove it
62-
.with_host_ips(vec!["192.168.10.8".to_string()]), // NOTE: change or remove it
47+
.with_disable_host_ipv6(true),
48+
// .with_enable_https(true)
49+
// .with_cert_file(Some("../wrtc/data/ca.crt".to_string()))
50+
// .with_key_file(Some("../wrtc/data/ca.key".to_string()))
51+
// start turnserver: `turnserver -c ./turnserver.conf -v`
52+
// .with_turn_server(Some(RTCIceServer {
53+
// urls: vec!["turn:192.168.10.8:3478".to_string()],
54+
// username: "foo".to_string(),
55+
// credential: "123456".to_string(),
56+
// })) // NOTE: change or remove it
57+
// .with_stun_server(Some(RTCIceServer {
58+
// urls: vec!["stun:192.168.10.8:3478".to_string()],
59+
// username: "foo".to_string(),
60+
// credential: "123456".to_string(),
61+
// })) // NOTE: change or remove it
62+
// .with_host_ips(vec!["192.168.10.8".to_string()]), // NOTE: change or remove it
6363
)
6464
.with_enable_recording_speaker(true)
6565
// .with_audio_device_name(Some(default_input.name))

lib/recorder/src/process_mode.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,10 +458,8 @@ impl RecordingSession {
458458
.with_video(video_info)
459459
.with_disable_host_ipv6(self.config.share_screen_config.disable_host_ipv6);
460460

461-
if self.config.share_screen_config.stun_server.is_some()
462-
|| self.config.share_screen_config.turn_server.is_some()
463-
{
464-
media_info.ice_servers.clear();
461+
if self.config.share_screen_config.stun_server.is_some() {
462+
media_info.ice_servers.clear(); // contain default stun serever
465463
}
466464

467465
if let Some(ref stun) = self.config.share_screen_config.stun_server {

lib/wrtc/src/client.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ impl WHEPClient {
101101
}
102102
};
103103

104-
info!("ice servers: {:#?}", media_info);
104+
info!("media_info: {:#?}", media_info);
105105

106106
Ok(Self {
107107
config,
@@ -182,19 +182,16 @@ impl WHEPClient {
182182
};
183183

184184
let peer_connection = Arc::new(api.new_peer_connection(config).await?);
185+
peer_connection
186+
.add_transceiver_from_kind(RTPCodecType::Video, None)
187+
.await?;
185188

186189
if self.media_info.audio.is_some() {
187190
peer_connection
188191
.add_transceiver_from_kind(RTPCodecType::Audio, None)
189192
.await?;
190193
}
191194

192-
if self.media_info.audio.is_some() {
193-
peer_connection
194-
.add_transceiver_from_kind(RTPCodecType::Video, None)
195-
.await?;
196-
}
197-
198195
let exit_notify = self.exit_notify.clone();
199196
let video_sender = self.video_sender.clone();
200197
let audio_sender = self.audio_sender.clone();

lib/wrtc/src/whep.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,7 @@ use webrtc::{
2828
};
2929

3030
pub type Result<T> = std::result::Result<T, WebRTCError>;
31-
pub const ICE_SERVERS: [&str; 2] = [
32-
"stun:stun.nextcloud.com:443",
33-
"stun:stun.l.google.com:19302",
34-
];
31+
pub const ICE_SERVERS: [&str; 1] = ["stun:stun.l.google.com:19302"];
3532

3633
#[non_exhaustive]
3734
#[derive(Debug, Setters, Clone)]
@@ -77,7 +74,7 @@ pub async fn handle_whep(
7774
let mut registry = Registry::new();
7875
registry = register_default_interceptors(registry, &mut m)?;
7976

80-
log::info!("host_ips: {:?}", config.host_ips);
77+
log::info!("whep config: {:#?}", config);
8178

8279
let mut setting_engine = SettingEngine::default();
8380
if config.disable_host_ipv6 {

wayshot/src/logic/share_screen.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,11 @@ impl From<config::ShareScreen> for ShareScreenConfig {
394394
fn from(c: config::ShareScreen) -> ShareScreenConfig {
395395
ShareScreenConfig::new(c.listen_addr)
396396
.with_save_mp4(c.save_mp4)
397+
.with_host_ips(c.host_ips)
397398
.with_disable_host_ipv6(c.disable_host_ipv6)
398399
.with_enable_https(c.enable_https)
399400
.with_cert_file(Some(c.cert_file))
400401
.with_key_file(Some(c.key_file))
401-
.with_host_ips(c.host_ips)
402402
.with_auth_token(if c.auth_token.trim().is_empty() {
403403
None
404404
} else {
@@ -414,7 +414,6 @@ impl From<config::ShareScreen> for ShareScreenConfig {
414414
} else {
415415
None
416416
})
417-
.with_host_ips(vec!["192.168.10.8".to_string()])
418417
}
419418
}
420419

wayshot/src/version.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pub static VERSION: &str = "v0.3.1";
1+
pub static VERSION: &str = "v0.3.0";

0 commit comments

Comments
 (0)