Skip to content

Commit

Permalink
expose detach_handle() function to transport plugins
Browse files Browse the repository at this point in the history
  • Loading branch information
nowylie committed Sep 1, 2016
1 parent a5ef9a6 commit 054348f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
22 changes: 21 additions & 1 deletion janus.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ guint64 janus_transport_create_session(janus_transport *plugin, void *transport,
void janus_transport_update_session_activity(guint64 session_id);
int janus_transport_destroy_session(guint64 session_id);
guint64 janus_transport_attach_handle(guint64 session_id, const char *plugin_package, const char *token, int *err);
int janus_transport_detach_handle(guint64 session_id, guint64 handle_id);

static janus_transport_callbacks janus_handler_transport =
{
Expand All @@ -309,7 +310,8 @@ static janus_transport_callbacks janus_handler_transport =
.create_session = janus_transport_create_session,
.update_session_activity = janus_transport_update_session_activity,
.destroy_session = janus_transport_destroy_session,
.attach_handle = janus_transport_attach_handle
.attach_handle = janus_transport_attach_handle,
.detach_handle = janus_transport_detach_handle
};
GThreadPool *tasks = NULL;
void janus_transport_task(gpointer data, gpointer user_data);
Expand Down Expand Up @@ -2546,6 +2548,24 @@ guint64 janus_transport_attach_handle(guint64 session_id, const char *plugin_pac
return handle_id;
}

int janus_transport_detach_handle(guint64 session_id, guint64 handle_id) {
janus_session *session = janus_session_find(session_id);
if (session == NULL) return JANUS_ERROR_SESSION_NOT_FOUND;

janus_ice_handle *handle = janus_ice_handle_find(session, handle_id);
if (handle == NULL) return JANUS_ERROR_HANDLE_NOT_FOUND;
if (handle->app == NULL || handle->app_handle == NULL) return JANUS_ERROR_PLUGIN_DETACH;

int err = janus_ice_handle_destroy(session, handle_id);
janus_mutex_lock(&session->mutex);
g_hash_table_remove(session->ice_handles, &handle_id);
janus_mutex_unlock(&session->mutex);

if (err != 0) return JANUS_ERROR_PLUGIN_DETACH;

return 0;
}

void janus_transport_task(gpointer data, gpointer user_data) {
JANUS_LOG(LOG_VERB, "Transport task pool, serving request\n");
janus_request *request = (janus_request *)data;
Expand Down
1 change: 1 addition & 0 deletions transports/transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ struct janus_transport_callbacks {
void (* const update_session_activity)(guint64 session_id);
int (* const destroy_session)(guint64 session_id);
guint64 (* const attach_handle)(guint64 session_id, const char *plugin_package, const char *token, int *err);
int (* const detach_handle)(guint64 session_id, guint64 handle_id);
};

/*! \brief The hook that transport plugins need to implement to be created from the gateway */
Expand Down

0 comments on commit 054348f

Please sign in to comment.