Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
L
libnice
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
libnice
Commits
9c1b7ed4
Commit
9c1b7ed4
authored
Apr 22, 2015
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
examples: Make them build and work on Windows
parent
3df534a7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
7 deletions
+27
-7
examples/sdp-example.c
examples/sdp-example.c
+10
-4
examples/simple-example.c
examples/simple-example.c
+8
-0
examples/threaded-example.c
examples/threaded-example.c
+9
-3
No files found.
examples/sdp-example.c
View file @
9c1b7ed4
...
...
@@ -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
"
);
...
...
examples/simple-example.c
View file @
9c1b7ed4
...
...
@@ -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
),
...
...
examples/threaded-example.c
View file @
9c1b7ed4
...
...
@@ -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
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment