mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
gst/src: Avoid unnecessary renegotiations during streaming
Some clients like many camera apps, including Cheese or Snapshot, trigger a lot of unnessecary renegotiations. While arguably that should be solved on a Gstreamer level, we can help out by checking if the preferred new caps are the same that are already in use and skip the renegotiation in this case. This allows several apps to e.g. take pictures without a slow and heavy stream restart.
This commit is contained in:
parent
594e3fa09f
commit
e2e8cf7944
1 changed files with 15 additions and 0 deletions
|
|
@ -864,6 +864,21 @@ gst_pipewire_src_negotiate (GstBaseSrc * basesrc)
|
|||
|
||||
GST_DEBUG_OBJECT (basesrc, "have common caps (sanitized): %" GST_PTR_FORMAT, possible_caps);
|
||||
|
||||
if (pw_stream_get_state(pwsrc->stream, NULL) == PW_STREAM_STATE_STREAMING) {
|
||||
g_autoptr (GstCaps) current_caps = NULL;
|
||||
g_autoptr (GstCaps) preferred_new_caps = NULL;
|
||||
|
||||
current_caps = gst_pad_get_current_caps (GST_BASE_SRC_PAD (pwsrc));
|
||||
preferred_new_caps = gst_caps_copy_nth (possible_caps, 0);
|
||||
|
||||
if (gst_caps_is_equal (current_caps, preferred_new_caps)) {
|
||||
GST_DEBUG_OBJECT (pwsrc,
|
||||
"Stream running and new caps equal current ones. "
|
||||
"Skipping renegotiation.");
|
||||
goto no_nego_needed;
|
||||
}
|
||||
}
|
||||
|
||||
/* open a connection with these caps */
|
||||
possible = gst_caps_to_format_all (possible_caps);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue