2 * This file is part of the Nice GLib ICE library.
4 * (C) 2006-2009 Collabora Ltd.
5 * Contact: Youness Alaoui
6 * (C) 2006-2009 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.
26 * Youness Alaoui, Collabora Ltd.
28 * Alternatively, the contents of this file may be used under the terms of the
29 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
30 * case the provisions of LGPL are applicable instead of those above. If you
31 * wish to allow use of your version of this file only under the terms of the
32 * LGPL and not to allow others to use your version of this file under the
33 * MPL, indicate your decision by deleting the provisions above and replace
34 * them with the notice and other provisions required by the LGPL. If you do
35 * not delete the provisions above, a recipient may use your version of this
36 * file under either the MPL or the LGPL.
48 * @brief ICE stream functionality
51 stream_new (guint n_components
)
57 stream
= g_slice_new0 (Stream
);
58 for (n
= 0; n
< n_components
; n
++) {
59 component
= component_new (n
+ 1);
60 stream
->components
= g_slist_append (stream
->components
, component
);
63 stream
->n_components
= n_components
;
64 stream
->initial_binding_request_received
= FALSE
;
70 stream_free (Stream
*stream
)
74 for (i
= stream
->components
; i
; i
= i
->next
) {
75 Component
*component
= i
->data
;
76 component_free (component
);
79 g_slist_free (stream
->components
);
80 g_slice_free (Stream
, stream
);
84 stream_find_component_by_id (const Stream
*stream
, guint id
)
88 for (i
= stream
->components
; i
; i
= i
->next
) {
89 Component
*component
= i
->data
;
90 if (component
&& component
->id
== id
)
98 * Returns true if all components of the stream are either
99 * 'CONNECTED' or 'READY' (connected plus nominated).
102 stream_all_components_ready (const Stream
*stream
)
106 for (i
= stream
->components
; i
; i
= i
->next
) {
107 Component
*component
= i
->data
;
109 !(component
->state
== NICE_COMPONENT_STATE_CONNECTED
||
110 component
->state
== NICE_COMPONENT_STATE_READY
))
119 * Initialized the local crendentials for the stream.
121 void stream_initialize_credentials (Stream
*stream
, NiceRNG
*rng
)
123 /* note: generate ufrag/pwd for the stream (see ICE 15.4.
124 * '"ice-ufrag" and "ice-pwd" Attributes', ID-19) */
125 nice_rng_generate_bytes_print (rng
, NICE_STREAM_DEF_UFRAG
- 1, stream
->local_ufrag
);
126 nice_rng_generate_bytes_print (rng
, NICE_STREAM_DEF_PWD
- 1, stream
->local_password
);
130 * Resets the stream state to that of a ICE restarted
134 stream_restart (Stream
*stream
, NiceRNG
*rng
)
139 stream
->initial_binding_request_received
= FALSE
;
141 stream_initialize_credentials (stream
, rng
);
143 for (i
= stream
->components
; i
&& res
; i
= i
->next
) {
144 Component
*component
= i
->data
;
146 res
= component_restart (component
);