static void kms_webrtc_session_remote_sdp_add_stored_ice_candidates (gpointer data, gpointer user_data) { KmsIceCandidate *candidate = data; KmsWebrtcSession *webrtc_sess = user_data; guint8 index; index = kms_ice_candidate_get_sdp_m_line_index (candidate); kms_webrtc_session_remote_sdp_add_ice_candidate (webrtc_sess, candidate, index); }
gboolean kms_webrtc_session_set_remote_ice_candidate (KmsWebrtcSession * self, KmsIceCandidate * candidate) { KmsSdpSession *sdp_sess = KMS_SDP_SESSION (self); SdpMessageContext *local_sdp_ctx = sdp_sess->local_sdp_ctx; guint8 index; GSList *medias; SdpMediaConfig *mconf; gboolean ret; if (local_sdp_ctx == NULL) { GST_INFO_OBJECT (self, "Cannot add candidate until local SDP is generated."); return TRUE; /* We do not know if the candidate is valid until it is set */ } medias = kms_sdp_message_context_get_medias (local_sdp_ctx); index = kms_ice_candidate_get_sdp_m_line_index (candidate); mconf = g_slist_nth_data (medias, index); if (mconf == NULL) { GST_WARNING_OBJECT (self, "Media not found in local SDP for index %" G_GUINT16_FORMAT, index); return FALSE; } else if (kms_sdp_media_config_is_inactive (mconf)) { GST_DEBUG_OBJECT (self, "Media inactive for index %" G_GUINT16_FORMAT, index); return TRUE; } else { gchar *stream_id; stream_id = kms_webrtc_session_get_stream_id (self, mconf); if (stream_id == NULL) { return FALSE; } if (!kms_ice_base_agent_add_ice_candidate (self->agent, candidate, stream_id)) { GST_WARNING_OBJECT (self, "Cannot add candidate: '%s'in stream_id: %s.", kms_ice_candidate_get_candidate (candidate), stream_id); ret = FALSE; } else { GST_TRACE_OBJECT (self, "Candidate added: '%s' in stream_id: %s.", kms_ice_candidate_get_candidate (candidate), stream_id); ret = TRUE; } } return ret; }
void WebRtcEndpointImpl::onIceCandidate (KmsIceCandidate *candidate) { try { std::string cand_str (kms_ice_candidate_get_candidate (candidate) ); std::string mid_str (kms_ice_candidate_get_sdp_mid (candidate) ); int sdp_m_line_index = kms_ice_candidate_get_sdp_m_line_index (candidate); std::shared_ptr <IceCandidate> cand ( new IceCandidate (cand_str, mid_str, sdp_m_line_index) ); OnIceCandidate event (shared_from_this(), OnIceCandidate::getName(), cand); signalOnIceCandidate (event); } catch (std::bad_weak_ptr &e) { } }
static gboolean kms_webrtc_session_add_ice_candidate (KmsWebrtcSession * self, KmsIceCandidate * candidate) { guint8 index; gboolean ret; GST_DEBUG_OBJECT (self, "Add ICE candidate '%s'", kms_ice_candidate_get_candidate (candidate)); KMS_SDP_SESSION_LOCK (self); self->remote_candidates = g_slist_append (self->remote_candidates, g_object_ref (candidate)); ret = kms_webrtc_session_set_remote_ice_candidate (self, candidate); index = kms_ice_candidate_get_sdp_m_line_index (candidate); kms_webrtc_session_remote_sdp_add_ice_candidate (self, candidate, index); KMS_SDP_SESSION_UNLOCK (self); return ret; }