1 #include "tx_api.h"
2 #include "nx_api.h"
3 #include "netxtestcontrol.h"
4
5 extern void test_control_return(UINT);
6
7 #if !defined(NX_DISABLE_ERROR_CHECKING) && defined(__PRODUCT_NETXDUO__) && !defined(NX_DISABLE_PACKET_CHAIN)
8 #include "nx_rtp_sender.h"
9
10 #define DEMO_STACK_SIZE 4096
11
12 /* Define the ThreadX object control blocks... */
13
14 static TX_THREAD test_thread;
15
16 /* Define the ThreadX object control blocks... */
17
18 static NX_PACKET_POOL pool_0;
19 static NX_IP ip_0;
20
21 /* Define rtp sender control block. */
22 static NX_RTP_SENDER rtp_0;
23 static NX_RTP_SESSION rtp_session_0;
24
25 /* Define thread prototypes. */
26
27 static void test_entry(ULONG thread_input);
28
29
30 #ifdef CTEST
test_application_define(void * first_unused_memory)31 VOID test_application_define(void *first_unused_memory)
32 #else
33 void netx_rtp_api_test_application_define(void *first_unused_memory)
34 #endif
35 {
36
37 CHAR *pointer;
38
39
40 /* Setup the working pointer. */
41 pointer = (CHAR *) first_unused_memory;
42
43 /* Create a helper thread for the server. */
44 tx_thread_create(&test_thread, "Test thread", test_entry, 0,
45 pointer, DEMO_STACK_SIZE,
46 4, 4, TX_NO_TIME_SLICE, TX_AUTO_START);
47
48 pointer = pointer + DEMO_STACK_SIZE;
49
50 /* Initialize the NetX system. */
51 nx_system_initialize();
52 }
53
test_entry(ULONG thread_input)54 void test_entry(ULONG thread_input)
55 {
56 UINT status;
57 UINT rtp_port;
58
59
60 /* Print out test information banner. */
61 printf("NetX Test: RTP API Test............................................");
62
63 memset(&rtp_0, 0, sizeof(NX_RTP_SENDER));
64
65 /* Test and check nx_rtp_sender_create */
66 status = nx_rtp_sender_create(NX_NULL, NX_NULL, NX_NULL, NX_NULL, 0);
67 CHECK_STATUS(NX_PTR_ERROR, status);
68 status = nx_rtp_sender_create(&rtp_0, NX_NULL, NX_NULL, NX_NULL, 0);
69 CHECK_STATUS(NX_PTR_ERROR, status);
70 status = nx_rtp_sender_create(&rtp_0, &ip_0, NX_NULL, NX_NULL, 0);
71 CHECK_STATUS(NX_PTR_ERROR, status);
72 status = nx_rtp_sender_create(&rtp_0, &ip_0, &pool_0, NX_NULL, 0);
73 CHECK_STATUS(NX_PTR_ERROR, status);
74
75 /* Test and check nx_rtp_sender_delete */
76 status = nx_rtp_sender_delete(NX_NULL);
77 CHECK_STATUS(NX_PTR_ERROR, status);
78
79 /* Test and check nx_rtp_sender_port_get */
80 status = nx_rtp_sender_port_get(NX_NULL, NX_NULL, NX_NULL);
81 CHECK_STATUS(NX_PTR_ERROR, status);
82 status = nx_rtp_sender_port_get(&rtp_0, NX_NULL, NX_NULL);
83 CHECK_STATUS(NX_PTR_ERROR, status);
84 status = nx_rtp_sender_port_get(&rtp_0, &rtp_port, NX_NULL);
85 CHECK_STATUS(NX_PTR_ERROR, status);
86
87 /* Test and check nx_rtp_sender_session_create */
88 status = nx_rtp_sender_session_create(NX_NULL, NX_NULL, 0, 0, NX_NULL, 0, 0);
89 CHECK_STATUS(NX_PTR_ERROR, status);
90 status = nx_rtp_sender_session_create(&rtp_0, NX_NULL, 0, 0, NX_NULL, 0, 0);
91 CHECK_STATUS(NX_PTR_ERROR, status);
92 status = nx_rtp_sender_session_create(&rtp_0, &rtp_session_0, 0, 0, NX_NULL, 0, 0);
93 CHECK_STATUS(NX_PTR_ERROR, status);
94
95 /* Test and check nx_rtp_sender_session_packet_allocate */
96 status = nx_rtp_sender_session_packet_allocate(NX_NULL, NX_NULL, NX_WAIT_FOREVER);
97 CHECK_STATUS(NX_PTR_ERROR, status);
98 status = nx_rtp_sender_session_packet_allocate(&rtp_session_0, NX_NULL, NX_WAIT_FOREVER);
99 CHECK_STATUS(NX_PTR_ERROR, status);
100
101 /* Test and check nx_rtp_sender_session_sequence_number_get */
102 status = nx_rtp_sender_session_sequence_number_get(NX_NULL, NX_NULL);
103 CHECK_STATUS(NX_PTR_ERROR, status);
104 status = nx_rtp_sender_session_sequence_number_get(&rtp_session_0, NX_NULL);
105 CHECK_STATUS(NX_PTR_ERROR, status);
106
107 /* Test and check nx_rtp_sender_session_ssrc_get */
108 status = nx_rtp_sender_session_ssrc_get(NX_NULL, NX_NULL);
109 CHECK_STATUS(NX_PTR_ERROR, status);
110 status = nx_rtp_sender_session_ssrc_get(&rtp_session_0, NX_NULL);
111 CHECK_STATUS(NX_PTR_ERROR, status);
112
113 /* Test and check nx_rtp_sender_session_packet_send */
114 status = nx_rtp_sender_session_packet_send(NX_NULL, NX_NULL, NX_NULL, 0, 0, 0);
115 CHECK_STATUS(NX_PTR_ERROR, status);
116 status = nx_rtp_sender_session_packet_send(&rtp_session_0, NX_NULL, NX_NULL, 0, 0, 0);
117 CHECK_STATUS(NX_PTR_ERROR, status);
118
119 /* Test and check RTCP API functions */
120 status = nx_rtp_sender_rtcp_receiver_report_callback_set(NX_NULL, NX_NULL);
121 CHECK_STATUS(NX_PTR_ERROR, status);
122
123 status = nx_rtp_sender_rtcp_receiver_report_callback_set(&rtp_0, NX_NULL);
124 CHECK_STATUS(NX_PTR_ERROR, status);
125
126 status = nx_rtp_sender_rtcp_sdes_callback_set(NX_NULL, NX_NULL);
127 CHECK_STATUS(NX_PTR_ERROR, status);
128
129 status = nx_rtp_sender_rtcp_sdes_callback_set(&rtp_0, NX_NULL);
130 CHECK_STATUS(NX_PTR_ERROR, status);
131
132 /* Return the test result. */
133 printf("SUCCESS!\n");
134 test_control_return(0);
135 }
136
137 #else
138
139 #ifdef CTEST
test_application_define(void * first_unused_memory)140 VOID test_application_define(void *first_unused_memory)
141 #else
142 void netx_rtp_api_test_application_define(void *first_unused_memory)
143 #endif
144 {
145
146 /* Print out test information banner. */
147 printf("NetX Test: RTP API Test............................................N/A\n");
148
149 test_control_return(3);
150 }
151 #endif
152
153