srtpdec: Simplify checking the unprotect error

Introduce an err label to jump to. Avoid logging two warnings per
failure.
This commit is contained in:
Jan Alexander Steffens (heftig) 2019-03-15 11:13:14 +01:00
parent 34eaeb17f2
commit 24b0e3e55f
No known key found for this signature in database
GPG Key ID: DE5E0C5F25941CA5

View File

@ -1382,48 +1382,47 @@ unprotect:
#endif #endif
} }
if (err != srtp_err_status_ok) { /* Signal user depending on type of error */
GST_WARNING_OBJECT (pad, switch (err) {
"Unable to unprotect buffer (unprotect failed code %d)", err); case srtp_err_status_ok:
/* success! */
/* Signal user depending on type of error */ break;
switch (err) { case srtp_err_status_key_expired:
case srtp_err_status_key_expired: /* Update stream */
if (find_stream_by_ssrc (filter, ssrc)) {
/* Update stream */ GST_OBJECT_UNLOCK (filter);
if (find_stream_by_ssrc (filter, ssrc)) { if (request_key_with_signal (filter, ssrc, SIGNAL_HARD_LIMIT)) {
GST_OBJECT_UNLOCK (filter); GST_OBJECT_LOCK (filter);
if (request_key_with_signal (filter, ssrc, SIGNAL_HARD_LIMIT)) { goto unprotect;
GST_OBJECT_LOCK (filter);
goto unprotect;
} else {
GST_OBJECT_LOCK (filter);
GST_WARNING_OBJECT (filter, "Hard limit reached, no new key, "
"dropping");
}
} else { } 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"); "dropping");
} }
break; } else {
case srtp_err_status_auth_fail: GST_WARNING_OBJECT (filter, "Could not find matching stream, "
GST_WARNING_OBJECT (filter, "Error authentication packet, dropping"); "dropping");
break; }
case srtp_err_status_cipher_fail: goto err;
GST_WARNING_OBJECT (filter, "Error while decrypting packet, dropping"); case srtp_err_status_auth_fail:
break; GST_WARNING_OBJECT (filter, "Error authentication packet, dropping");
default: goto err;
GST_WARNING_OBJECT (filter, "Other error, dropping"); case srtp_err_status_cipher_fail:
break; GST_WARNING_OBJECT (filter, "Error while decrypting packet, dropping");
} goto err;
default:
gst_buffer_unmap (buf, &map); GST_WARNING_OBJECT (pad,
return FALSE; "Unable to unprotect buffer (unprotect failed code %d)", err);
goto err;
} }
gst_buffer_unmap (buf, &map); gst_buffer_unmap (buf, &map);
gst_buffer_set_size (buf, size); gst_buffer_set_size (buf, size);
return TRUE; return TRUE;
err:
gst_buffer_unmap (buf, &map);
return FALSE;
} }
static GstFlowReturn static GstFlowReturn