Skip to content
This repository has been archived by the owner on Aug 10, 2022. It is now read-only.

Commit

Permalink
encode session description in peerconnection_gather_handler
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh committed Aug 6, 2022
1 parent f2f1178 commit 0822839
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 41 deletions.
8 changes: 7 additions & 1 deletion src/demo.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ static void peerconnection_gather_handler(void *arg)
{
struct session *sess = arg;
struct mbuf *mb_sdp = NULL;
struct odict *od = NULL;
enum sdp_type type;
int err;

Expand Down Expand Up @@ -121,7 +122,11 @@ static void peerconnection_gather_handler(void *arg)
if (err)
goto out;

err = http_reply_descr(sess->conn_pending, sess->id, type, mb_sdp);
err = session_description_encode(&od, type, mb_sdp);
if (err)
goto out;

err = http_reply_json(sess->conn_pending, sess->id, od);
if (err) {
warning("demo: reply error: %m\n", err);
goto out;
Expand All @@ -138,6 +143,7 @@ static void peerconnection_gather_handler(void *arg)

out:
mem_deref(mb_sdp);
mem_deref(od);

if (err)
session_close(sess, err);
Expand Down
2 changes: 0 additions & 2 deletions src/demo.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

int http_reply_json(struct http_conn *conn, const char *sessid,
const struct odict *od);
int http_reply_descr(struct http_conn *conn, const char *sessid,
enum sdp_type type, struct mbuf *mb_sdp);


/*
Expand Down
38 changes: 0 additions & 38 deletions src/http.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,41 +38,3 @@ int http_reply_json(struct http_conn *conn, const char *sessid,

return err;
}


/*
* format:
*
* {
* "type" : "answer",
* "sdp" : "v=0\r\ns=-\r\n..."
* }
*
* specification:
*
* https://developer.mozilla.org/en-US/docs/Web/API/RTCSessionDescription
*
* NOTE: currentLocalDescription
*/
int http_reply_descr(struct http_conn *conn, const char *sessid,
enum sdp_type type, struct mbuf *mb_sdp)
{
struct odict *od = NULL;
int err;

if (!conn || !mb_sdp)
return EINVAL;

err = session_description_encode(&od, type, mb_sdp);
if (err)
goto out;

err = http_reply_json(conn, sessid, od);
if (err)
goto out;

out:
mem_deref(od);

return err;
}

0 comments on commit 0822839

Please sign in to comment.