webrtc: webrtcsink: set perfect-timestamp=true on audio encoders

Chrome audio decoder doesn't cope well with not perfect ts, generating
noises in the audio.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/merge_requests/1524>
This commit is contained in:
Guillaume Desmottes 2024-04-02 14:10:36 +02:00
parent 0aabbb3186
commit 35b84d219f
4 changed files with 10 additions and 1 deletions

2
Cargo.lock generated
View file

@ -2930,6 +2930,7 @@ dependencies = [
"gst-plugin-webrtc-signalling-protocol",
"gstreamer",
"gstreamer-app",
"gstreamer-audio",
"gstreamer-base",
"gstreamer-rtp",
"gstreamer-sdp",
@ -3071,6 +3072,7 @@ dependencies = [
"gstreamer-base",
"libc",
"once_cell",
"serde",
"smallvec",
]

View file

@ -11,6 +11,7 @@ rust-version.workspace = true
[dependencies]
gst = { workspace = true, features = ["v1_20", "serde"] }
gst-app = { workspace = true, features = ["v1_20"] }
gst-audio = { workspace = true, features = ["v1_20", "serde"] }
gst-video = { workspace = true, features = ["v1_20", "serde"] }
gst-webrtc = { workspace = true, features = ["v1_20"] }
gst-sdp = { workspace = true, features = ["v1_20"] }

View file

@ -319,7 +319,7 @@ b. In the second tab start the `simple-whip-client` as shown in the below comman
``` shell
./whip-client --url http://127.0.0.1:8190/whip/endpoint \
-A "audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay pt=100 ssrc=1 ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=100" \
-A "audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc perfect-timestamp=true ! rtpopuspay pt=100 ssrc=1 ! queue ! application/x-rtp,media=audio,encoding-name=OPUS,payload=100" \
-V "videotestsrc is-live=true pattern=ball ! videoconvert ! queue ! vp8enc deadline=1 ! rtpvp8pay pt=96 ssrc=2 ! queue ! application/x-rtp,media=video,encoding-name=VP8,payload=96" \
-S stun://stun.l.google.com:19302 \
-l 7 \

View file

@ -693,6 +693,12 @@ fn add_nv4l2enc_force_keyunit_workaround(enc: &gst::Element) {
/// Default configuration for known encoders, can be disabled
/// by returning True from an encoder-setup handler.
fn configure_encoder(enc: &gst::Element, start_bitrate: u32) {
let audio_encoder = enc.is::<gst_audio::AudioEncoder>();
if audio_encoder {
// Chrome audio decoder expects perfect timestamps
enc.set_property("perfect-timestamp", true);
}
if let Some(factory) = enc.factory() {
match factory.name().as_str() {
"vp8enc" | "vp9enc" => {