webrtcbin: Make request-pad validation an early return

This reduces the indendation.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/2104>
This commit is contained in:
Olivier Crête 2021-03-26 15:02:50 -04:00
parent 0f758a1730
commit 0e2d128bec

View file

@ -6194,16 +6194,19 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
const gchar * name, const GstCaps * caps)
{
GstWebRTCBin *webrtc = GST_WEBRTC_BIN (element);
GstWebRTCRTPTransceiver *trans;
GstWebRTCBinPad *pad = NULL;
GstWebRTCBinPad *pad2;
guint serial;
if (!_have_nice_elements (webrtc) || !_have_dtls_elements (webrtc))
return NULL;
if (templ->direction == GST_PAD_SINK ||
g_strcmp0 (templ->name_template, "sink_%u") == 0) {
GstWebRTCRTPTransceiver *trans;
GstWebRTCBinPad *pad2;
if (templ->direction != GST_PAD_SINK ||
g_strcmp0 (templ->name_template, "sink_%u") != 0) {
GST_ERROR_OBJECT (element, "Requested pad that shouldn't be requestable");
return NULL;
}
GST_OBJECT_LOCK (webrtc);
if (name == NULL || strlen (name) < 6 || !g_str_has_prefix (name, "sink_")) {
@ -6228,11 +6231,9 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
}
if (!trans) {
trans =
GST_WEBRTC_RTP_TRANSCEIVER (_create_webrtc_transceiver (webrtc,
trans = GST_WEBRTC_RTP_TRANSCEIVER (_create_webrtc_transceiver (webrtc,
GST_WEBRTC_RTP_TRANSCEIVER_DIRECTION_SENDRECV, -1));
GST_LOG_OBJECT (webrtc, "Created new transceiver %" GST_PTR_FORMAT,
trans);
GST_LOG_OBJECT (webrtc, "Created new transceiver %" GST_PTR_FORMAT, trans);
} else {
GST_LOG_OBJECT (webrtc, "Using existing transceiver %" GST_PTR_FORMAT
" for mline %u", trans, serial);
@ -6252,7 +6253,6 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ,
g_list_append (webrtc->priv->pending_sink_transceivers,
gst_object_ref (pad));
_add_pad (webrtc, pad);
}
return GST_PAD (pad);
}