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.
40
#include "test-io-stream-common.h"
48
#define NUM_MESSAGES 10
55
read_thread_cb (GInputStream *input_stream, TestIOStreamThreadData *data)
59
guint8 buf[MESSAGE_SIZE];
62
g_mutex_lock (&count_lock);
64
g_cond_broadcast (&count_cond);
65
g_mutex_unlock (&count_lock);
67
/* Block on receiving some data. */
69
len = g_input_stream_read (input_stream, buf, sizeof (buf), NULL, &error);
70
if (!data->user_data) {
71
g_assert_cmpint (len, ==, sizeof(buf));
75
g_assert_cmpint (len, ==, -1);
77
g_assert_error (error, G_IO_ERROR, G_IO_ERROR_BROKEN_PIPE);
78
g_clear_error (&error);
80
stop_main_loop (data->error_loop);
84
write_thread_cb (GOutputStream *output_stream, TestIOStreamThreadData *data)
86
gchar buf[MESSAGE_SIZE] = {0};
92
ret = g_output_stream_write (output_stream, buf, sizeof (buf), NULL,
95
g_mutex_lock (&count_lock);
97
g_cond_broadcast (&count_cond);
98
if (data->user_data) {
99
g_assert_cmpint (ret, ==, sizeof(buf));
100
g_mutex_unlock (&count_lock);
105
g_cond_wait (&count_cond, &count_lock);
106
g_mutex_unlock (&count_lock);
109
/* Now we remove the stream, lets see how the writer handles that */
111
tmp = g_object_get_data (G_OBJECT (data->other->agent), "stream-id");
112
stream_id = GPOINTER_TO_UINT (tmp);
114
nice_agent_remove_stream (data->other->agent, stream_id);
119
const TestIOStreamCallbacks callbacks = {
128
WSAStartup (0x0202, &w);
131
g_thread_init (NULL);
133
run_io_stream_test (30, TRUE, &callbacks, (gpointer) TRUE, NULL, NULL, NULL);