Compare commits
3 Commits
d5679be3a4
...
8b04893ceb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b04893ceb | ||
|
|
1beaea8088 | ||
|
|
fc4733ffe8 |
@@ -210,7 +210,7 @@ impl WebRtcState {
|
|||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
tracing::error!("SDP offer handling failed: {e}");
|
tracing::error!("SDP offer handling failed: {e}");
|
||||||
let resp = format!("HTTP/1.1 500 Error\r\nConnection: close\r\n\r\n{e}");
|
let resp = "HTTP/1.1 500 Internal Server Error\r\nConnection: close\r\n\r\n";
|
||||||
let _ = stream.write_all(resp.as_bytes());
|
let _ = stream.write_all(resp.as_bytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -311,28 +311,26 @@ impl WebRtcInner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn discover_video_params(&mut self) {
|
fn discover_video_params(&mut self) {
|
||||||
for s in ["0", "1", "2", "3"] {
|
let mid = match self.video_mid {
|
||||||
let mid: Mid = s.into();
|
Some(m) => m,
|
||||||
if let Some(media) = self.rtc.media(mid) {
|
None => {
|
||||||
if media.kind() == MediaKind::Video {
|
tracing::warn!("discover_video_params: no video_mid yet");
|
||||||
tracing::info!("Found video media: mid={mid}");
|
return;
|
||||||
self.video_mid = Some(mid);
|
}
|
||||||
|
};
|
||||||
|
self.video_pt = None;
|
||||||
|
if let Some(writer) = self.rtc.writer(mid) {
|
||||||
|
for pp in writer.payload_params() {
|
||||||
|
tracing::debug!("Codec: pt={:?} spec={:?}", pp.pt(), pp.spec());
|
||||||
|
if pp.spec().codec.is_video() && pp.spec().codec == Codec::H264 {
|
||||||
|
self.video_pt = Some(pp.pt());
|
||||||
|
tracing::info!("H.264 payload type: {:?}", pp.pt());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if self.video_pt.is_none() {
|
||||||
if let Some(mid) = self.video_mid {
|
tracing::warn!("discover_video_params: no H.264 codec found for mid={mid}");
|
||||||
if let Some(writer) = self.rtc.writer(mid) {
|
|
||||||
for pp in writer.payload_params() {
|
|
||||||
tracing::debug!("Codec: pt={:?} spec={:?}", pp.pt(), pp.spec());
|
|
||||||
if pp.spec().codec.is_video() && pp.spec().codec == Codec::H264 {
|
|
||||||
self.video_pt = Some(pp.pt());
|
|
||||||
tracing::info!("H.264 payload type: {:?}", pp.pt());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -357,9 +355,21 @@ impl WebRtcInner {
|
|||||||
Event::IceConnectionStateChange(IceConnectionState::Disconnected) => {
|
Event::IceConnectionStateChange(IceConnectionState::Disconnected) => {
|
||||||
tracing::warn!("WebRTC disconnected");
|
tracing::warn!("WebRTC disconnected");
|
||||||
self.connected = false;
|
self.connected = false;
|
||||||
|
return Ok(true);
|
||||||
}
|
}
|
||||||
Event::MediaAdded(ma) => {
|
Event::MediaAdded(ma) => {
|
||||||
tracing::info!("Media added: mid={:?}", ma.mid);
|
tracing::info!("Media added: mid={} kind={:?}", ma.mid, ma.kind);
|
||||||
|
if ma.kind == MediaKind::Video {
|
||||||
|
if let Some(media) = self.rtc.media(ma.mid) {
|
||||||
|
if media.direction().is_sending()
|
||||||
|
&& self.video_mid.is_none()
|
||||||
|
{
|
||||||
|
self.video_mid = Some(ma.mid);
|
||||||
|
tracing::info!("Captured video mid: {}", ma.mid);
|
||||||
|
self.discover_video_params();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
tracing::debug!("WebRTC event: {:?}", e);
|
tracing::debug!("WebRTC event: {:?}", e);
|
||||||
|
|||||||
Reference in New Issue
Block a user