blob: 9c91f37c99f2e62b87226316ae2e96de560280d2 [file] [log] [blame]
James Kuszmaul64391362021-01-17 11:32:00 -08001#pragma once
2#include "data_channel.h"
3#include <rawrtcc/code.h>
4#include <re.h>
5
6/**
7 * Data channel parameters.
8 */
9struct rawrtc_data_channel_parameters;
10
11/**
12 * Create data channel parameters.
13 *
14 * For `RAWRTC_DATA_CHANNEL_TYPE_RELIABLE_*`, the reliability parameter
15 * is being ignored.
16 *
17 * When using `RAWRTC_DATA_CHANNEL_TYPE_*_RETRANSMIT`, the reliability
18 * parameter specifies the number of times a retransmission occurs if
19 * not acknowledged before the message is being discarded.
20 *
21 * When using `RAWRTC_DATA_CHANNEL_TYPE_*_TIMED`, the reliability
22 * parameter specifies the time window in milliseconds during which
23 * (re-)transmissions may occur before the message is being discarded.
24 *
25 * `*parametersp` must be unreferenced.
26 *
27 * In case `negotiated` is set to `false`, the `id` is being ignored.
28 */
29enum rawrtc_code rawrtc_data_channel_parameters_create(
30 struct rawrtc_data_channel_parameters** const parametersp, // de-referenced
31 char const* const label, // copied, nullable
32 enum rawrtc_data_channel_type const channel_type,
33 uint32_t const reliability_parameter,
34 char const* const protocol, // copied, nullable
35 bool const negotiated,
36 uint16_t const id);
37
38/**
39 * Get the label from the data channel parameters.
40 * `*labelp` will be set to a copy of the parameter's label and must be
41 * unreferenced.
42 *
43 * Return `RAWRTC_CODE_NO_VALUE` in case no label has been set.
44 * Otherwise, `RAWRTC_CODE_SUCCESS` will be returned and `*parameters*
45 * must be unreferenced.
46 */
47enum rawrtc_code rawrtc_data_channel_parameters_get_label(
48 char** const labelp, // de-referenced
49 struct rawrtc_data_channel_parameters* const parameters);
50
51/**
52 * Get the channel type from the data channel parameters.
53 */
54enum rawrtc_code rawrtc_data_channel_parameters_get_channel_type(
55 enum rawrtc_data_channel_type* const channel_typep, // de-referenced
56 struct rawrtc_data_channel_parameters* const parameters);
57
58/**
59 * Get the reliability parameter from the data channel parameters.
60 *
61 * Return `RAWRTC_CODE_NO_VALUE` in case the channel type is
62 * `RAWRTC_DATA_CHANNEL_TYPE_RELIABLE_*`. Otherwise,
63 * `RAWRTC_CODE_SUCCESS` will be returned.
64 */
65enum rawrtc_code rawrtc_data_channel_parameters_get_reliability_parameter(
66 uint32_t* const reliability_parameterp, // de-referenced
67 struct rawrtc_data_channel_parameters* const parameters);
68
69/**
70 * Get the protocol from the data channel parameters.
71 * `*protocolp` will be set to a copy of the parameter's protocol and
72 * must be unreferenced.
73 *
74 * Return `RAWRTC_CODE_NO_VALUE` in case no protocol has been set.
75 * Otherwise, `RAWRTC_CODE_SUCCESS` will be returned and `*protocolp*
76 * must be unreferenced.
77 */
78enum rawrtc_code rawrtc_data_channel_parameters_get_protocol(
79 char** const protocolp, // de-referenced
80 struct rawrtc_data_channel_parameters* const parameters);
81
82/**
83 * Get the 'negotiated' flag from the data channel parameters.
84 */
85enum rawrtc_code rawrtc_data_channel_parameters_get_negotiated(
86 bool* const negotiatedp, // de-referenced
87 struct rawrtc_data_channel_parameters* const parameters);
88
89/**
90 * Get the negotiated id from the data channel parameters.
91 *
92 * Return `RAWRTC_CODE_NO_VALUE` in case the 'negotiated' flag is set
93 * `false`. Otherwise, `RAWRTC_CODE_SUCCESS` will be returned.
94 */
95enum rawrtc_code rawrtc_data_channel_parameters_get_id(
96 uint16_t* const idp, // de-referenced
97 struct rawrtc_data_channel_parameters* const parameters);