static void kms_webrtc_session_post_constructor (KmsWebrtcSession * self, KmsBaseSdpEndpoint * ep, guint id, KmsIRtpSessionManager * manager, GMainContext * context) { KmsBaseRtpSession *base_rtp_session = KMS_BASE_RTP_SESSION (self); self->context = g_main_context_ref (context); KMS_BASE_RTP_SESSION_CLASS (kms_webrtc_session_parent_class)->post_constructor (base_rtp_session, ep, id, manager); }
KmsBaseRtpSession * kms_base_rtp_session_new (KmsBaseSdpEndpoint * ep, guint id, KmsIRtpSessionManager * manager) { GObject *obj; KmsBaseRtpSession *self; obj = g_object_new (KMS_TYPE_BASE_RTP_SESSION, NULL); self = KMS_BASE_RTP_SESSION (obj); KMS_BASE_RTP_SESSION_CLASS (G_OBJECT_GET_CLASS (self))->post_constructor (self, ep, id, manager); return self; }
static KmsIBundleConnection * kms_base_rtp_session_create_bundle_connection_default (KmsBaseRtpSession * self, const gchar * name, guint16 min_port, guint16 max_port) { KmsBaseRtpSessionClass *klass = KMS_BASE_RTP_SESSION_CLASS (G_OBJECT_GET_CLASS (self)); if (klass->create_bundle_connection == kms_base_rtp_session_create_bundle_connection_default) { GST_WARNING_OBJECT (self, "%s does not reimplement 'create_bundle_connection'", G_OBJECT_CLASS_NAME (klass)); } return NULL; }
KmsIRtpConnection * kms_base_rtp_session_create_connection (KmsBaseRtpSession * self, SdpMediaConfig * mconf, guint16 min_port, guint16 max_port) { KmsBaseRtpSessionClass *base_rtp_class = KMS_BASE_RTP_SESSION_CLASS (G_OBJECT_GET_CLASS (self)); gchar *name = kms_utils_create_connection_name_from_media_config (mconf); SdpMediaGroup *group = kms_sdp_media_config_get_group (mconf); KmsIRtpConnection *conn; conn = kms_base_rtp_session_get_connection_by_name (self, name); if (conn != NULL) { GST_DEBUG_OBJECT (self, "Re-using connection '%s'", name); goto end; } if (group != NULL) { /* bundle */ conn = KMS_I_RTP_CONNECTION (base_rtp_class->create_bundle_connection (self, name, min_port, max_port)); } else if (kms_sdp_media_config_is_rtcp_mux (mconf)) { conn = KMS_I_RTP_CONNECTION (base_rtp_class->create_rtcp_mux_connection (self, name, min_port, max_port)); } else { conn = base_rtp_class->create_connection (self, mconf, name, min_port, max_port); } if (conn != NULL) { g_hash_table_insert (self->conns, g_strdup (name), conn); kms_base_rtp_session_set_connection_stats (self, conn); } end: g_free (name); return conn; }
static void kms_webrtc_session_class_init (KmsWebrtcSessionClass * klass) { GObjectClass *gobject_class = G_OBJECT_CLASS (klass); GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass); KmsBaseRtpSessionClass *base_rtp_session_class; GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, GST_DEFAULT_NAME, 0, GST_DEFAULT_NAME); gobject_class->finalize = kms_webrtc_session_finalize; gobject_class->set_property = kms_webrtc_session_set_property; gobject_class->get_property = kms_webrtc_session_get_property; klass->post_constructor = kms_webrtc_session_post_constructor; klass->gather_candidates = kms_webrtc_session_gather_candidates; klass->add_ice_candidate = kms_webrtc_session_add_ice_candidate; klass->init_ice_agent = kms_webrtc_session_init_ice_agent; base_rtp_session_class = KMS_BASE_RTP_SESSION_CLASS (klass); /* Connection management */ base_rtp_session_class->create_connection = kms_webrtc_session_create_connection; base_rtp_session_class->create_rtcp_mux_connection = kms_webrtc_session_create_rtcp_mux_connection; base_rtp_session_class->create_bundle_connection = kms_webrtc_session_create_bundle_connection; gst_element_class_set_details_simple (gstelement_class, "WebrtcSession", "Generic", "Base bin to manage elements related with a WebRTC session.", "Miguel París Díaz <*****@*****.**>"); g_object_class_install_property (gobject_class, PROP_STUN_SERVER_IP, g_param_spec_string ("stun-server", "StunServer", "Stun Server IP Address", DEFAULT_STUN_SERVER_IP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_STUN_SERVER_PORT, g_param_spec_uint ("stun-server-port", "StunServerPort", "Stun Server Port", 1, G_MAXUINT16, DEFAULT_STUN_SERVER_PORT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); g_object_class_install_property (gobject_class, PROP_TURN_URL, g_param_spec_string ("turn-url", "TurnUrl", "TURN server URL with this format: 'user:password@address:port(?transport=[udp|tcp|tls])'." "'address' must be an IP (not a domain)." "'transport' is optional (UDP by default).", DEFAULT_STUN_TURN_URL, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); /** * KmsWebrtcSession::on-ice-candidate: * @self: the object which received the signal * @candidate: the local candidate gathered * * Notify of a new gathered local candidate for a #KmsWebrtcSession. */ kms_webrtc_session_signals[SIGNAL_ON_ICE_CANDIDATE] = g_signal_new ("on-ice-candidate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (KmsWebrtcSessionClass, on_ice_candidate), NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, KMS_TYPE_ICE_CANDIDATE); /** * KmsWebrtcSession::on-candidate-gathering-done: * @self: the object which received the signal * * Notify that all candidates have been gathered for a #KmsWebrtcSession */ kms_webrtc_session_signals[SIGNAL_ON_ICE_GATHERING_DONE] = g_signal_new ("on-ice-gathering-done", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (KmsWebrtcSessionClass, on_ice_gathering_done), NULL, NULL, NULL, G_TYPE_NONE, 0); /** * KmsWebrtcSession::on-component-state-changed * @self: the object which received the signal * @stream_id: The ID of the stream * @component_id: The ID of the component * @state: The #NiceComponentState of the component * * This signal is fired whenever a component's state changes */ kms_webrtc_session_signals[SIGNAL_ON_ICE_COMPONENT_STATE_CHANGED] = g_signal_new ("on-ice-component-state-changed", G_OBJECT_CLASS_TYPE (klass), G_SIGNAL_RUN_LAST, 0, NULL, NULL, NULL, G_TYPE_NONE, 3, G_TYPE_STRING, G_TYPE_UINT, G_TYPE_UINT, G_TYPE_INVALID); kms_webrtc_session_signals[SIGNAL_GATHER_CANDIDATES] = g_signal_new ("gather-candidates", G_TYPE_FROM_CLASS (klass), G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (KmsWebrtcSessionClass, gather_candidates), NULL, NULL, __kms_webrtc_marshal_BOOLEAN__VOID, G_TYPE_BOOLEAN, 0); kms_webrtc_session_signals[SIGNAL_ADD_ICE_CANDIDATE] = g_signal_new ("add-ice-candidate", G_TYPE_FROM_CLASS (klass), G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (KmsWebrtcSessionClass, add_ice_candidate), NULL, NULL, __kms_webrtc_marshal_BOOLEAN__OBJECT, G_TYPE_BOOLEAN, 1, KMS_TYPE_ICE_CANDIDATE); /* TODO: look for a better way of doing this */ kms_webrtc_session_signals[SIGNAL_INIT_ICE_AGENT] = g_signal_new ("init-ice-agent", G_TYPE_FROM_CLASS (klass), G_SIGNAL_ACTION | G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (KmsWebrtcSessionClass, init_ice_agent), NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); }