diff options
author | Jan Alexander Steffens (heftig) <jsteffens@make.tv> | 2019-03-15 11:13:14 +0100 |
---|---|---|
committer | Jan Alexander Steffens (heftig) <jsteffens@make.tv> | 2019-03-19 13:47:41 +0100 |
commit | 24b0e3e55f2af8bbb32098cba7902717315ed406 (patch) | |
tree | b88325da10ae05b1a6deed0f814c3c5b9d9a719f /ext/srtp | |
parent | 34eaeb17f230424513af2b25c8b9062a7b27577c (diff) | |
download | gstreamer-plugins-bad-24b0e3e55f2af8bbb32098cba7902717315ed406.tar.gz |
srtpdec: Simplify checking the unprotect error
Introduce an err label to jump to. Avoid logging two warnings per
failure.
Diffstat (limited to 'ext/srtp')
-rw-r--r-- | ext/srtp/gstsrtpdec.c | 67 |
1 files changed, 33 insertions, 34 deletions
diff --git a/ext/srtp/gstsrtpdec.c b/ext/srtp/gstsrtpdec.c index b5d6388ad..86730b35e 100644 --- a/ext/srtp/gstsrtpdec.c +++ b/ext/srtp/gstsrtpdec.c @@ -1382,48 +1382,47 @@ unprotect: #endif } - if (err != srtp_err_status_ok) { - GST_WARNING_OBJECT (pad, - "Unable to unprotect buffer (unprotect failed code %d)", err); - - /* Signal user depending on type of error */ - switch (err) { - case srtp_err_status_key_expired: - - /* Update stream */ - if (find_stream_by_ssrc (filter, ssrc)) { - GST_OBJECT_UNLOCK (filter); - if (request_key_with_signal (filter, ssrc, SIGNAL_HARD_LIMIT)) { - GST_OBJECT_LOCK (filter); - goto unprotect; - } else { - GST_OBJECT_LOCK (filter); - GST_WARNING_OBJECT (filter, "Hard limit reached, no new key, " - "dropping"); - } + /* Signal user depending on type of error */ + switch (err) { + case srtp_err_status_ok: + /* success! */ + break; + case srtp_err_status_key_expired: + /* Update stream */ + if (find_stream_by_ssrc (filter, ssrc)) { + GST_OBJECT_UNLOCK (filter); + if (request_key_with_signal (filter, ssrc, SIGNAL_HARD_LIMIT)) { + GST_OBJECT_LOCK (filter); + goto unprotect; } else { - GST_WARNING_OBJECT (filter, "Could not find matching stream, " + GST_OBJECT_LOCK (filter); + GST_WARNING_OBJECT (filter, "Hard limit reached, no new key, " "dropping"); } - break; - case srtp_err_status_auth_fail: - GST_WARNING_OBJECT (filter, "Error authentication packet, dropping"); - break; - case srtp_err_status_cipher_fail: - GST_WARNING_OBJECT (filter, "Error while decrypting packet, dropping"); - break; - default: - GST_WARNING_OBJECT (filter, "Other error, dropping"); - break; - } - - gst_buffer_unmap (buf, &map); - return FALSE; + } else { + GST_WARNING_OBJECT (filter, "Could not find matching stream, " + "dropping"); + } + goto err; + case srtp_err_status_auth_fail: + GST_WARNING_OBJECT (filter, "Error authentication packet, dropping"); + goto err; + case srtp_err_status_cipher_fail: + GST_WARNING_OBJECT (filter, "Error while decrypting packet, dropping"); + goto err; + default: + GST_WARNING_OBJECT (pad, + "Unable to unprotect buffer (unprotect failed code %d)", err); + goto err; } gst_buffer_unmap (buf, &map); gst_buffer_set_size (buf, size); return TRUE; + +err: + gst_buffer_unmap (buf, &map); + return FALSE; } static GstFlowReturn |