2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006, 2007 Collabora Ltd.
5 * Contact: Dafydd Harries
6 * (C) 2006, 2007 Nokia Corporation. All rights reserved.
7 * Contact: Kai Vehmanen
9 * The contents of this file are subject to the Mozilla Public License Version
10 * 1.1 (the "License"); you may not use this file except in compliance with
11 * the License. You may obtain a copy of the License at
12 * http://www.mozilla.org/MPL/
14 * Software distributed under the License is distributed on an "AS IS" basis,
15 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
16 * for the specific language governing rights and limitations under the
19 * The Original Code is the Nice GLib ICE library.
21 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
22 * Corporation. All Rights Reserved.
25 * Dafydd Harries, Collabora Ltd.
27 * Alternatively, the contents of this file may be used under the terms of the
28 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
29 * case the provisions of LGPL are applicable instead of those above. If you
30 * wish to allow use of your version of this file only under the terms of the
31 * LGPL and not to allow others to use your version of this file under the
32 * MPL, indicate your decision by deleting the provisions above and replace
33 * them with the notice and other provisions required by the LGPL. If you do
34 * not delete the provisions above, a recipient may use your version of this
35 * file under either the MPL or the LGPL.
47 * @brief ICE stream functionality
50 stream_new (guint n_components
)
54 gboolean errors
= FALSE
;
55 GSList
*modified_list
;
58 stream
= g_slice_new0 (Stream
);
59 for (n
= 0; n
< n_components
; n
++) {
60 component
= component_new (n
+ 1);
62 modified_list
= g_slist_append (stream
->components
, component
);
64 stream
->components
= modified_list
;
77 stream
->n_components
= n_components
;
78 stream
->initial_binding_request_received
= FALSE
;
84 stream_free (Stream
*stream
)
88 for (i
= stream
->components
; i
; i
= i
->next
) {
89 Component
*component
= i
->data
;
90 component_free (component
);
93 g_slist_free (stream
->components
);
94 g_slice_free (Stream
, stream
);
98 stream_find_component_by_id (const Stream
*stream
, guint id
)
102 for (i
= stream
->components
; i
; i
= i
->next
) {
103 Component
*component
= i
->data
;
104 if (component
&& component
->id
== id
)
112 * Returns true if all components of the stream are either
113 * 'CONNECTED' or 'READY' (connected plus nominated).
116 stream_all_components_ready (const Stream
*stream
)
120 for (i
= stream
->components
; i
; i
= i
->next
) {
121 Component
*component
= i
->data
;
123 !(component
->state
== NICE_COMPONENT_STATE_CONNECTED
||
124 component
->state
== NICE_COMPONENT_STATE_READY
))
133 * Initialized the local crendentials for the stream.
135 void stream_initialize_credentials (Stream
*stream
, NiceRNG
*rng
)
137 /* note: generate ufrag/pwd for the stream (see ICE 15.4.
138 * '"ice-ufrag" and "ice-pwd" Attributes', ID-19) */
139 nice_rng_generate_bytes_print (rng
, NICE_STREAM_DEF_UFRAG
- 1, stream
->local_ufrag
);
140 nice_rng_generate_bytes_print (rng
, NICE_STREAM_DEF_PWD
- 1, stream
->local_password
);
144 * Resets the stream state to that of a ICE restarted
148 stream_restart (Stream
*stream
, NiceRNG
*rng
)
153 stream
->initial_binding_request_received
= FALSE
;
155 stream_initialize_credentials (stream
, rng
);
157 for (i
= stream
->components
; i
&& res
; i
= i
->next
) {
158 Component
*component
= i
->data
;
160 res
= component_restart (component
);