summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CrĂȘte <olivier.crete@collabora.com>2015-04-22 19:56:09 -0500
committerOlivier CrĂȘte <olivier.crete@collabora.com>2015-04-22 20:58:46 -0400
commit9c1b7ed4207faf94ac5d466e45db7f5f91c2729e (patch)
tree434f11b5399603df3e0e5302be9b64d60c537ecf
parent3df534a75cb3c47f4808d0269d9cffe763813417 (diff)
downloadlibnice-9c1b7ed4207faf94ac5d466e45db7f5f91c2729e.tar.gz
examples: Make them build and work on Windows
-rw-r--r--examples/sdp-example.c14
-rw-r--r--examples/simple-example.c8
-rw-r--r--examples/threaded-example.c12
3 files changed, 27 insertions, 7 deletions
diff --git a/examples/sdp-example.c b/examples/sdp-example.c
index b3c5588..bf31c5a 100644
--- a/examples/sdp-example.c
+++ b/examples/sdp-example.c
@@ -41,10 +41,11 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include <unistd.h>
#include <agent.h>
+#include <gio/gnetworking.h>
+
static GMainLoop *gloop;
static gchar *stun_addr = NULL;
static guint stun_port;
@@ -95,6 +96,7 @@ main(int argc, char *argv[])
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
+ g_networking_init();
gloop = g_main_loop_new(NULL, FALSE);
@@ -119,8 +121,12 @@ example_thread(void *data)
gchar *line = NULL;
gchar *sdp, *sdp64;
+#ifdef G_OS_WIN32
+ io_stdin = g_io_channel_win32_new(_fileno(stdin));
+#else
io_stdin = g_io_channel_unix_new(fileno(stdin));
- g_io_channel_set_flags (io_stdin, G_IO_FLAG_NONBLOCK, NULL);
+#endif
+ g_io_channel_set_flags(io_stdin, G_IO_FLAG_NONBLOCK, NULL);
// Create the nice agent
agent = nice_agent_new(g_main_loop_get_context (gloop),
@@ -198,7 +204,7 @@ example_thread(void *data)
g_free (sdp);
g_free (line);
} else if (s == G_IO_STATUS_AGAIN) {
- usleep (100000);
+ g_usleep (100000);
}
}
@@ -223,7 +229,7 @@ example_thread(void *data)
printf("> ");
fflush (stdout);
} else if (s == G_IO_STATUS_AGAIN) {
- usleep (100000);
+ g_usleep (100000);
} else {
// Ctrl-D was pressed.
nice_agent_send(agent, stream_id, 1, 1, "\0");
diff --git a/examples/simple-example.c b/examples/simple-example.c
index 936c8f0..aa259aa 100644
--- a/examples/simple-example.c
+++ b/examples/simple-example.c
@@ -42,8 +42,11 @@
#include <string.h>
#include <ctype.h>
+#include <gio/gnetworking.h>
+
#include <agent.h>
+
static GMainLoop *gloop;
static GIOChannel* io_stdin;
static guint stream_id;
@@ -104,9 +107,14 @@ main(int argc, char *argv[])
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
+ g_networking_init();
gloop = g_main_loop_new(NULL, FALSE);
+#ifdef G_OS_WIN32
+ io_stdin = g_io_channel_win32_new(_fileno(stdin));
+#else
io_stdin = g_io_channel_unix_new(fileno(stdin));
+#endif
// Create the nice agent
agent = nice_agent_new(g_main_loop_get_context (gloop),
diff --git a/examples/threaded-example.c b/examples/threaded-example.c
index e672d89..2564b3a 100644
--- a/examples/threaded-example.c
+++ b/examples/threaded-example.c
@@ -41,10 +41,11 @@
#include <stdio.h>
#include <string.h>
#include <ctype.h>
-#include <unistd.h>
#include <agent.h>
+#include <gio/gnetworking.h>
+
static GMainLoop *gloop;
static gchar *stun_addr = NULL;
static guint stun_port;
@@ -104,6 +105,7 @@ main(int argc, char *argv[])
#if !GLIB_CHECK_VERSION(2, 36, 0)
g_type_init();
#endif
+ g_networking_init();
gloop = g_main_loop_new(NULL, FALSE);
@@ -129,7 +131,11 @@ example_thread(void *data)
gchar *line = NULL;
int rval;
+#ifdef G_OS_WIN32
+ io_stdin = g_io_channel_win32_new(_fileno(stdin));
+#else
io_stdin = g_io_channel_unix_new(fileno(stdin));
+#endif
g_io_channel_set_flags (io_stdin, G_IO_FLAG_NONBLOCK, NULL);
// Create the nice agent
@@ -202,7 +208,7 @@ example_thread(void *data)
}
g_free (line);
} else if (s == G_IO_STATUS_AGAIN) {
- usleep (100000);
+ g_usleep (100000);
}
}
@@ -238,7 +244,7 @@ example_thread(void *data)
printf("> ");
fflush (stdout);
} else if (s == G_IO_STATUS_AGAIN) {
- usleep (100000);
+ g_usleep (100000);
} else {
// Ctrl-D was pressed.
nice_agent_send(agent, stream_id, 1, 1, "\0");