MT#56447 handle Janus POST alternative usage

Change-Id: I02220111662ef830ad3b74a93ba3d73216e72c16
pull/1611/head
Richard Fuchs 2 years ago
parent c41188c0ca
commit 1379ba2310

@ -1699,6 +1699,35 @@ const char *websocket_janus_get(struct websocket_message *wm) {
}
const char *websocket_janus_post(struct websocket_message *wm) {
str uri;
str_init(&uri, wm->uri);
ilog(LOG_DEBUG, "Processing Janus POST: '%s'", wm->uri);
uint64_t session_id = 0;
uint64_t handle_id = 0;
str_shift_cmp(&uri, "/");
// parse out session ID and handle ID if given
str s;
if (str_token_sep(&s, &uri, '/'))
goto done;
if (str_cmp(&s, "janus"))
goto done;
if (str_token_sep(&s, &uri, '/'))
goto done;
session_id = str_to_ui(&s, 0);
if (str_token_sep(&s, &uri, '/'))
goto done;
handle_id = str_to_ui(&s, 0);
done:
return websocket_janus_process_json(wm, session_id, handle_id);
}
void janus_init(void) {
mutex_init(&janus_lock);
janus_tokens = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, g_free);

@ -591,6 +591,8 @@ static int websocket_http_body(struct websocket_conn *wc, const char *body, size
handler = websocket_janus_process;
else if (!strcmp(uri, "/janus") && wm->method == M_POST && wm->content_type == CT_JSON)
handler = websocket_janus_process;
else if (!strncmp(uri, "/janus/", 7) && wm->method == M_POST && wm->content_type == CT_JSON)
handler = websocket_janus_post;
if (!handler) {
ilogs(http, LOG_WARN, "Unhandled HTTP POST URI: '%s'", wm->uri);

@ -12,6 +12,7 @@ void janus_free(void);
const char *websocket_janus_process(struct websocket_message *wm);
const char *websocket_janus_get(struct websocket_message *wm);
const char *websocket_janus_post(struct websocket_message *wm);
void janus_detach_websocket(struct janus_session *session, struct websocket_conn *wc);
void janus_media_up(struct call_monologue *);

Loading…
Cancel
Save