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
71310d81
Commit
71310d81
authored
Jul 02, 2008
by
Olivier Crête
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test for new set_selecte_remote_candidate function
parent
9eb56677
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
138 additions
and
0 deletions
+138
-0
agent/test-fallback.c
agent/test-fallback.c
+138
-0
No files found.
agent/test-fallback.c
View file @
71310d81
...
...
@@ -337,6 +337,136 @@ static int run_fallback_test (NiceAgent *lagent, NiceAgent *ragent, NiceAddress
return
0
;
}
static
int
run_safe_fallback_test
(
NiceAgent
*
lagent
,
NiceAgent
*
ragent
,
NiceAddress
*
baseaddr
)
{
NiceAddress
laddr
,
raddr
,
laddr_rtcp
,
raddr_rtcp
;
NiceCandidate
cdes
;
guint
ls_id
,
rs_id
;
memset
(
&
cdes
,
0
,
sizeof
(
NiceCandidate
));
cdes
.
priority
=
100000
;
strcpy
(
cdes
.
foundation
,
"1"
);
cdes
.
type
=
NICE_CANDIDATE_TYPE_HOST
;
cdes
.
transport
=
NICE_CANDIDATE_TRANSPORT_UDP
;
cdes
.
base_addr
=
*
baseaddr
;
/* step: initialize variables modified by the callbacks */
global_components_ready
=
0
;
global_components_ready_exit
=
4
;
global_components_failed
=
0
;
global_components_failed_exit
=
4
;
global_lagent_gathering_done
=
FALSE
;
global_ragent_gathering_done
=
FALSE
;
global_lagent_ibr_received
=
global_ragent_ibr_received
=
FALSE
;
global_lagent_cands
=
global_ragent_cands
=
0
;
global_ragent_read_exit
=
-
1
;
g_object_set
(
G_OBJECT
(
lagent
),
"controlling-mode"
,
TRUE
,
NULL
);
g_object_set
(
G_OBJECT
(
ragent
),
"controlling-mode"
,
FALSE
,
NULL
);
/* step: add one stream, with RTP+RTCP components, to each agent */
ls_id
=
nice_agent_add_stream
(
lagent
,
2
);
rs_id
=
nice_agent_add_stream
(
ragent
,
2
);
g_assert
(
ls_id
>
0
);
g_assert
(
rs_id
>
0
);
nice_agent_gather_candidates
(
lagent
,
ls_id
);
nice_agent_gather_candidates
(
ragent
,
rs_id
);
/* step: attach to mainloop (needed to register the fds) */
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
g_main_loop_get_context
(
global_mainloop
),
cb_nice_recv
,
(
gpointer
)
1
);
nice_agent_attach_recv
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
g_main_loop_get_context
(
global_mainloop
),
cb_nice_recv
,
(
gpointer
)
1
);
nice_agent_attach_recv
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
g_main_loop_get_context
(
global_mainloop
),
cb_nice_recv
,
(
gpointer
)
2
);
nice_agent_attach_recv
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
g_main_loop_get_context
(
global_mainloop
),
cb_nice_recv
,
(
gpointer
)
2
);
/* step: run mainloop until local candidates are ready
* (see timer_cb() above) */
if
(
global_lagent_gathering_done
!=
TRUE
||
global_ragent_gathering_done
!=
TRUE
)
{
g_debug
(
"test-fallback: Added streams, running mainloop until 'candidate-gathering-done'..."
);
g_main_loop_run
(
global_mainloop
);
g_assert
(
global_lagent_gathering_done
==
TRUE
);
g_assert
(
global_ragent_gathering_done
==
TRUE
);
}
/* step: find out the local candidates of each agent */
priv_get_local_addr
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
&
raddr
);
g_debug
(
"test-fallback: local RTP port R %u"
,
nice_address_get_port
(
&
raddr
));
priv_get_local_addr
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
&
laddr
);
g_debug
(
"test-fallback: local RTP port L %u"
,
nice_address_get_port
(
&
laddr
));
priv_get_local_addr
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
&
raddr_rtcp
);
g_debug
(
"test-fallback: local RTCP port R %u"
,
nice_address_get_port
(
&
raddr_rtcp
));
priv_get_local_addr
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
&
laddr_rtcp
);
g_debug
(
"test-fallback: local RTCP port L %u"
,
nice_address_get_port
(
&
laddr_rtcp
));
/* step: exchange candidate information but not the credentials */
cdes
.
component_id
=
NICE_COMPONENT_TYPE_RTP
;
cdes
.
addr
=
raddr
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTP
,
&
cdes
));
cdes
.
addr
=
laddr
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTP
,
&
cdes
));
cdes
.
component_id
=
NICE_COMPONENT_TYPE_RTCP
;
cdes
.
addr
=
raddr_rtcp
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
lagent
,
ls_id
,
NICE_COMPONENT_TYPE_RTCP
,
&
cdes
));
cdes
.
addr
=
laddr_rtcp
;
g_assert
(
nice_agent_set_selected_remote_candidate
(
ragent
,
rs_id
,
NICE_COMPONENT_TYPE_RTCP
,
&
cdes
));
g_debug
(
"test-fallback: Requested for fallback, running mainloop until component state change is completed..."
);
/* step: run the mainloop until connectivity checks succeed
* (see timer_cb() above) */
if
(
global_components_ready
<
global_components_ready_exit
)
g_main_loop_run
(
global_mainloop
);
/* note: verify that agents are in correct state */
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_ragent_state
==
NICE_COMPONENT_STATE_READY
);
/* step: next send a packet -> should work even if no ICE processing
* has been done */
g_debug
(
"test-fallback: Sent a payload packet, run mainloop until packet received."
);
/* step: send a new test packet from L ot R */
global_ragent_read
=
0
;
g_assert
(
nice_agent_send
(
lagent
,
ls_id
,
1
,
16
,
"1234567812345678"
)
==
16
);
global_ragent_read_exit
=
16
;
g_main_loop_run
(
global_mainloop
);
/* note: verify that payload was succesfully received */
g_assert
(
global_ragent_read
==
16
);
g_debug
(
"test-fallback: Ran mainloop, removing streams..."
);
/* step: clean up resources and exit */
nice_agent_remove_stream
(
lagent
,
ls_id
);
nice_agent_remove_stream
(
ragent
,
rs_id
);
g_debug
(
"test-fallback: test COMPLETED"
);
return
0
;
}
int
main
(
void
)
{
NiceAgent
*
lagent
,
*
ragent
;
/* agent's L and R */
...
...
@@ -412,6 +542,14 @@ int main (void)
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_ragent_state
==
NICE_COMPONENT_STATE_READY
);
/* step: run the safe test without sending any stnu */
g_debug
(
"test-fallback: TEST STARTS / safe fallback test"
);
result
=
run_safe_fallback_test
(
lagent
,
ragent
,
&
baseaddr
);
priv_print_global_status
();
g_assert
(
result
==
0
);
g_assert
(
global_lagent_state
==
NICE_COMPONENT_STATE_READY
);
g_assert
(
global_ragent_state
==
NICE_COMPONENT_STATE_READY
);
g_object_unref
(
lagent
);
g_object_unref
(
ragent
);
...
...
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