diff --git a/ext/webrtc/gstwebrtcbin.c b/ext/webrtc/gstwebrtcbin.c index 1386bdd816..9bf156f134 100644 --- a/ext/webrtc/gstwebrtcbin.c +++ b/ext/webrtc/gstwebrtcbin.c @@ -3235,35 +3235,11 @@ _media_add_rtx (GstSDPMedia * media, WebRTCTransceiver * trans, } } -static GstWebRTCKind -_kind_from_caps (const GstCaps * caps) -{ - GstStructure *s; - const gchar *media; - - if (gst_caps_get_size (caps) == 0) - return GST_WEBRTC_KIND_UNKNOWN; - - s = gst_caps_get_structure (caps, 0); - - media = gst_structure_get_string (s, "media"); - if (media == NULL) - return GST_WEBRTC_KIND_UNKNOWN; - - if (!g_strcmp0 (media, "audio")) - return GST_WEBRTC_KIND_AUDIO; - - if (!g_strcmp0 (media, "video")) - return GST_WEBRTC_KIND_VIDEO; - - return GST_WEBRTC_KIND_UNKNOWN; -} - static gboolean _update_transceiver_kind_from_caps (GstWebRTCRTPTransceiver * trans, const GstCaps * caps) { - GstWebRTCKind kind = _kind_from_caps (caps); + GstWebRTCKind kind = webrtc_kind_from_caps (caps); if (trans->kind == kind) return TRUE; @@ -3583,7 +3559,8 @@ _create_answer_task (GstWebRTCBin * webrtc, const GstStructure * options, if (!_update_transceiver_kind_from_caps (rtp_trans, answer_caps)) GST_WARNING_OBJECT (webrtc, "Trying to change transceiver %d kind from %d to %d", - rtp_trans->mline, rtp_trans->kind, _kind_from_caps (answer_caps)); + rtp_trans->mline, rtp_trans->kind, + webrtc_kind_from_caps (answer_caps)); if (!trans->do_nack) { answer_caps = gst_caps_make_writable (answer_caps); @@ -5656,7 +5633,7 @@ gst_webrtc_bin_create_data_channel (GstWebRTCBin * webrtc, const gchar * label, if (webrtc->priv->sctp_transport) { /* Let transport be the connection's [[SctpTransport]] slot. * - * If the [[DataChannelId]] slot is not null, transport is in + * If the [[DataChannelId]] slot is not null, transport is in * connected state and [[DataChannelId]] is greater or equal to the * transport's [[MaxChannels]] slot, throw an OperationError. */ @@ -6420,7 +6397,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ, } if (trans->kind != GST_WEBRTC_KIND_UNKNOWN) { - GstWebRTCKind kind = _kind_from_caps (caps); + GstWebRTCKind kind = webrtc_kind_from_caps (caps); if (trans->kind != kind) { GST_ERROR_OBJECT (element, "Tried to request a new sink pad %s for" @@ -6440,7 +6417,7 @@ gst_webrtc_bin_request_new_pad (GstElement * element, GstPadTemplate * templ, guint i; if (caps) - kind = _kind_from_caps (caps); + kind = webrtc_kind_from_caps (caps); for (i = 0; i < webrtc->priv->transceivers->len; i++) { GstWebRTCRTPTransceiver *tmptrans = diff --git a/ext/webrtc/utils.c b/ext/webrtc/utils.c index 044d583220..6ba101b838 100644 --- a/ext/webrtc/utils.c +++ b/ext/webrtc/utils.c @@ -205,3 +205,28 @@ _rtp_caps_from_media (const GstSDPMedia * media) return ret; } + +GstWebRTCKind +webrtc_kind_from_caps (const GstCaps * caps) +{ + GstStructure *s; + const gchar *media; + + if (gst_caps_get_size (caps) == 0) + return GST_WEBRTC_KIND_UNKNOWN; + + s = gst_caps_get_structure (caps, 0); + + media = gst_structure_get_string (s, "media"); + if (media == NULL) + return GST_WEBRTC_KIND_UNKNOWN; + + if (!g_strcmp0 (media, "audio")) + return GST_WEBRTC_KIND_AUDIO; + + if (!g_strcmp0 (media, "video")) + return GST_WEBRTC_KIND_VIDEO; + + return GST_WEBRTC_KIND_UNKNOWN; +} + diff --git a/ext/webrtc/utils.h b/ext/webrtc/utils.h index f15abe4515..6d2ce8ba9b 100644 --- a/ext/webrtc/utils.h +++ b/ext/webrtc/utils.h @@ -82,6 +82,8 @@ G_GNUC_INTERNAL const gchar * _g_checksum_to_webrtc_string (GChecksumType type); G_GNUC_INTERNAL GstCaps * _rtp_caps_from_media (const GstSDPMedia * media); +G_GNUC_INTERNAL +GstWebRTCKind webrtc_kind_from_caps (const GstCaps * caps); G_END_DECLS