mirror of
https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs.git
synced 2024-12-22 18:16:28 +00:00
net/quinn: Improve datagram handling
We now check if the peer actually supports Datagram and refusing to proceed if it does not. Since the datagram size can actually change over the lifetime of a connection according to variation in path MTU estimate, also check buffer size before trying to send. Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1613>
This commit is contained in:
parent
dbad98132f
commit
bc5ed023e4
2 changed files with 46 additions and 6 deletions
|
@ -498,12 +498,28 @@ impl QuinnQuicSink {
|
|||
};
|
||||
|
||||
if use_datagram {
|
||||
match conn.send_datagram(Bytes::copy_from_slice(src)) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(Some(gst::error_msg!(
|
||||
gst::ResourceError::Failed,
|
||||
["Sending data failed: {}", e]
|
||||
))),
|
||||
match conn.max_datagram_size() {
|
||||
Some(size) => {
|
||||
if src.len() > size {
|
||||
return Err(Some(gst::error_msg!(
|
||||
gst::ResourceError::Failed,
|
||||
["Sending data failed, current max datagram size: {size}"]
|
||||
)));
|
||||
}
|
||||
|
||||
match conn.send_datagram(Bytes::copy_from_slice(src)) {
|
||||
Ok(_) => Ok(()),
|
||||
Err(e) => Err(Some(gst::error_msg!(
|
||||
gst::ResourceError::Failed,
|
||||
["Sending data failed: {}", e]
|
||||
))),
|
||||
}
|
||||
}
|
||||
/*
|
||||
* We check for datagram being unsupported by peer in
|
||||
* start/init_connection, so we should never reach here.
|
||||
*/
|
||||
None => unreachable!(),
|
||||
}
|
||||
} else {
|
||||
let send = &mut stream.as_mut().unwrap();
|
||||
|
@ -627,6 +643,18 @@ impl QuinnQuicSink {
|
|||
|
||||
Some(res)
|
||||
} else {
|
||||
match connection.max_datagram_size() {
|
||||
Some(datagram_size) => {
|
||||
gst::info!(CAT, imp: self, "Datagram size reported by peer: {datagram_size}");
|
||||
}
|
||||
None => {
|
||||
return Err(WaitError::FutureError(gst::error_msg!(
|
||||
gst::ResourceError::Failed,
|
||||
["Datagram unsupported by the peer"]
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
|
|
|
@ -690,6 +690,18 @@ impl QuinnQuicSrc {
|
|||
|
||||
Some(res)
|
||||
} else {
|
||||
match connection.max_datagram_size() {
|
||||
Some(datagram_size) => {
|
||||
gst::info!(CAT, imp: self, "Datagram size reported by peer: {datagram_size}");
|
||||
}
|
||||
None => {
|
||||
return Err(WaitError::FutureError(gst::error_msg!(
|
||||
gst::ResourceError::Failed,
|
||||
["Datagram unsupported by the peer"]
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue