blob: 180a6f52db9ca0d823eb08319cfef37ccd057379 [file] [log] [blame]
James Kuszmaul4a42b182021-01-17 11:32:46 -08001#pragma once
2#include <rawrtcc/code.h>
3#include <re.h>
4
5// Dependencies
6struct rawrtc_ice_candidate;
7
8/*
9 * Peer connection ICE candidate.
10 */
11struct rawrtc_peer_connection_ice_candidate;
12
13/*
14 * Create a new ICE candidate from SDP.
15 * `*candidatesp` must be unreferenced.
16 *
17 * Note: This is equivalent to creating an `RTCIceCandidate` from an
18 * `RTCIceCandidateInit` instance in the W3C WebRTC
19 * specification.
20 */
21enum rawrtc_code rawrtc_peer_connection_ice_candidate_create(
22 struct rawrtc_peer_connection_ice_candidate** const candidatep, // de-referenced
23 char* const sdp,
24 char* const mid, // nullable, copied
25 uint8_t const* const media_line_index, // nullable, copied
26 char* const username_fragment // nullable, copied
27);
28
29/*
30 * Encode the ICE candidate into SDP.
31 * `*sdpp` will be set to a copy of the SDP attribute that must be
32 * unreferenced.
33 *
34 * Note: This is equivalent to the `candidate` attribute of the W3C
35 * WebRTC specification's `RTCIceCandidateInit`.
36 */
37enum rawrtc_code rawrtc_peer_connection_ice_candidate_get_sdp(
38 char** const sdpp, // de-referenced
39 struct rawrtc_peer_connection_ice_candidate* const candidate);
40
41/*
42 * Get the media stream identification tag the ICE candidate is
43 * associated to.
44 * `*midp` will be set to a copy of the candidate's mid and must be
45 * unreferenced.
46 *
47 * Return `RAWRTC_CODE_NO_VALUE` in case no 'mid' has been set.
48 * Otherwise, `RAWRTC_CODE_SUCCESS` will be returned and `*midp* must
49 * be unreferenced.
50 */
51enum rawrtc_code rawrtc_peer_connection_ice_candidate_get_sdp_mid(
52 char** const midp, // de-referenced
53 struct rawrtc_peer_connection_ice_candidate* const candidate);
54
55/*
56 * Get the media stream line index the ICE candidate is associated to.
57 * Return `RAWRTC_CODE_NO_VALUE` in case no media line index has been
58 * set.
59 */
60enum rawrtc_code rawrtc_peer_connection_ice_candidate_get_sdp_media_line_index(
61 uint8_t* const media_line_index, // de-referenced
62 struct rawrtc_peer_connection_ice_candidate* const candidate);
63
64/*
65 * Get the username fragment the ICE candidate is associated to.
66 * `*username_fragmentp` will be set to a copy of the candidate's
67 * username fragment and must be unreferenced.
68 *
69 * Return `RAWRTC_CODE_NO_VALUE` in case no username fragment has been
70 * set. Otherwise, `RAWRTC_CODE_SUCCESS` will be returned and
71 * `*username_fragmentp* must be unreferenced.
72 */
73enum rawrtc_code rawrtc_peer_connection_ice_candidate_get_username_fragment(
74 char** const username_fragmentp, // de-referenced
75 struct rawrtc_peer_connection_ice_candidate* const candidate);
76
77/*
78 * Get the underlying ORTC ICE candidate from the ICE candidate.
79 * `*ortc_candidatep` must be unreferenced.
80 */
81enum rawrtc_code rawrtc_peer_connection_ice_candidate_get_ortc_candidate(
82 struct rawrtc_ice_candidate** const ortc_candidatep, // de-referenced
83 struct rawrtc_peer_connection_ice_candidate* const candidate);