Squashed 'third_party/rawrtc/rawrtc/' content from commit aa3ae4b24
Change-Id: I38a655a4259b62f591334e90a1315bd4e7e4d8ec
git-subtree-dir: third_party/rawrtc/rawrtc
git-subtree-split: aa3ae4b247275cc6e69c30613b3a4ba7fdc82d1b
diff --git a/src/peer_connection_ice_candidate/utils.c b/src/peer_connection_ice_candidate/utils.c
new file mode 100644
index 0000000..49cd11e
--- /dev/null
+++ b/src/peer_connection_ice_candidate/utils.c
@@ -0,0 +1,47 @@
+#include "candidate.h"
+#include "../ice_candidate/candidate.h"
+#include <rawrtcc/code.h>
+#include <re.h>
+
+/*
+ * Print debug information for an ICE candidate.
+ */
+int rawrtc_peer_connection_ice_candidate_debug(
+ struct re_printf* const pf, struct rawrtc_peer_connection_ice_candidate* const candidate) {
+ int err = 0;
+
+ // Check arguments
+ if (!candidate) {
+ return 0;
+ }
+
+ // ORTC ICE candidate
+ err |= re_hprintf(pf, "%H", rawrtc_ice_candidate_debug, candidate->candidate);
+
+ // Media line identification tag
+ err |= re_hprintf(pf, " mid=");
+ if (candidate->mid) {
+ err |= re_hprintf(pf, "\"%s\"\n", candidate->mid);
+ } else {
+ err |= re_hprintf(pf, "n/a\n");
+ }
+
+ // Media line index
+ err |= re_hprintf(pf, " media_line_index=");
+ if (candidate->media_line_index >= 0 && candidate->media_line_index <= UINT8_MAX) {
+ err |= re_hprintf(pf, "%" PRId16 "\n", candidate->media_line_index);
+ } else {
+ err |= re_hprintf(pf, "n/a\n");
+ }
+
+ // Username fragment
+ err |= re_hprintf(pf, " username_fragment=");
+ if (candidate->username_fragment) {
+ err |= re_hprintf(pf, "\"%s\"\n", candidate->username_fragment);
+ } else {
+ err |= re_hprintf(pf, "n/a\n");
+ }
+
+ // Done
+ return err;
+}