2 * This file is part of the Nice GLib ICE library.
4 * (C) 2014 Collabora Ltd.
5 * Contact: Philip Withnall
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is the Nice GLib ICE library.
19 * The Initial Developers of the Original Code are Collabora Ltd and Nokia
20 * Corporation. All Rights Reserved.
23 * Philip Withnall, Collabora Ltd.
25 * Alternatively, the contents of this file may be used under the terms of the
26 * the GNU Lesser General Public License Version 2.1 (the "LGPL"), in which
27 * case the provisions of LGPL are applicable instead of those above. If you
28 * wish to allow use of your version of this file only under the terms of the
29 * LGPL and not to allow others to use your version of this file under the
30 * MPL, indicate your decision by deleting the provisions above and replace
31 * them with the notice and other provisions required by the LGPL. If you do
32 * not delete the provisions above, a recipient may use your version of this
33 * file under either the MPL or the LGPL.
47 #if !GLIB_CHECK_VERSION(2, 58, 0)
48 #define G_SOURCE_FUNC(f) ((GSourceFunc) (void (*)(void)) (f))
51 /* Make the message sufficiently large to not hit Nagle’s algorithm in the
52 * pseudo-TCP implementation, and hence run really slowly. */
53 #define MESSAGE_SIZE 1284 /* bytes */
55 typedef struct _TestIOStreamThreadData TestIOStreamThreadData;
58 void (*read_thread) (GInputStream *input_stream,
59 TestIOStreamThreadData *data);
60 void (*write_thread) (GOutputStream *output_stream,
61 TestIOStreamThreadData *data);
62 void (*reliable_transport_writable) (GOutputStream *output_stream,
63 NiceAgent *agent, guint stream_id, guint component_id,
64 TestIOStreamThreadData *data);
65 void (*new_selected_pair) (NiceAgent *agent, guint stream_id,
66 guint component_id, gchar *lfoundation, gchar *rfoundation,
67 TestIOStreamThreadData *data);
68 void (*wait_transmission_cb) (NiceAgent *agent);
69 } TestIOStreamCallbacks;
71 struct _TestIOStreamThreadData {
78 GMainLoop *error_loop;
80 GMainContext *main_context;
81 GMainContext *write_context;
82 GMainContext *read_context;
85 GDestroyNotify user_data_free;
87 TestIOStreamThreadData *other;
90 const TestIOStreamCallbacks *callbacks;
94 /* Condition signalling for the stream being open/writeable. */
96 gboolean stream_ready;
105 GThread *spawn_thread (const gchar *thread_name, GThreadFunc thread_func,
107 void run_io_stream_test (guint deadlock_timeout, gboolean reliable,
108 const TestIOStreamCallbacks *callbacks,
109 gpointer l_user_data, GDestroyNotify l_user_data_free,
110 gpointer r_user_data, GDestroyNotify r_user_data_free);
111 void check_for_termination (TestIOStreamThreadData *data, gsize *recv_count,
112 gsize *other_recv_count, volatile gsize *send_count, gsize expected_recv_count);
114 void stop_main_loop (GMainLoop *loop);