James Kuszmaul | 4a42b18 | 2021-01-17 11:32:46 -0800 | [diff] [blame^] | 1 | #include "candidate.h" |
| 2 | #include "../ice_candidate/candidate.h" |
| 3 | #include <rawrtcc/code.h> |
| 4 | #include <re.h> |
| 5 | |
| 6 | /* |
| 7 | * Print debug information for an ICE candidate. |
| 8 | */ |
| 9 | int rawrtc_peer_connection_ice_candidate_debug( |
| 10 | struct re_printf* const pf, struct rawrtc_peer_connection_ice_candidate* const candidate) { |
| 11 | int err = 0; |
| 12 | |
| 13 | // Check arguments |
| 14 | if (!candidate) { |
| 15 | return 0; |
| 16 | } |
| 17 | |
| 18 | // ORTC ICE candidate |
| 19 | err |= re_hprintf(pf, "%H", rawrtc_ice_candidate_debug, candidate->candidate); |
| 20 | |
| 21 | // Media line identification tag |
| 22 | err |= re_hprintf(pf, " mid="); |
| 23 | if (candidate->mid) { |
| 24 | err |= re_hprintf(pf, "\"%s\"\n", candidate->mid); |
| 25 | } else { |
| 26 | err |= re_hprintf(pf, "n/a\n"); |
| 27 | } |
| 28 | |
| 29 | // Media line index |
| 30 | err |= re_hprintf(pf, " media_line_index="); |
| 31 | if (candidate->media_line_index >= 0 && candidate->media_line_index <= UINT8_MAX) { |
| 32 | err |= re_hprintf(pf, "%" PRId16 "\n", candidate->media_line_index); |
| 33 | } else { |
| 34 | err |= re_hprintf(pf, "n/a\n"); |
| 35 | } |
| 36 | |
| 37 | // Username fragment |
| 38 | err |= re_hprintf(pf, " username_fragment="); |
| 39 | if (candidate->username_fragment) { |
| 40 | err |= re_hprintf(pf, "\"%s\"\n", candidate->username_fragment); |
| 41 | } else { |
| 42 | err |= re_hprintf(pf, "n/a\n"); |
| 43 | } |
| 44 | |
| 45 | // Done |
| 46 | return err; |
| 47 | } |