1 /**************************************************************************/
2 /*                                                                        */
3 /*       Copyright (c) Microsoft Corporation. All rights reserved.        */
4 /*                                                                        */
5 /*       This software is licensed under the Microsoft Software License   */
6 /*       Terms for Microsoft Azure RTOS. Full text of the license can be  */
7 /*       found in the LICENSE file at https://aka.ms/AzureRTOS_EULA       */
8 /*       and in the root directory of this software.                      */
9 /*                                                                        */
10 /**************************************************************************/
11 
12 
13 /**************************************************************************/
14 /**************************************************************************/
15 /**                                                                       */
16 /** NetX Component                                                        */
17 /**                                                                       */
18 /**   Real Time Streaming Protocol (RTSP)                                 */
19 /**                                                                       */
20 /**************************************************************************/
21 /**************************************************************************/
22 
23 
24 /**************************************************************************/
25 /*                                                                        */
26 /*  APPLICATION INTERFACE DEFINITION                       RELEASE        */
27 /*                                                                        */
28 /*    nx_rtsp_server.h                                    PORTABLE C      */
29 /*                                                           6.3.0        */
30 /*  AUTHOR                                                                */
31 /*                                                                        */
32 /*    Wenhui Xie, Microsoft Corporation                                   */
33 /*                                                                        */
34 /*  DESCRIPTION                                                           */
35 /*                                                                        */
36 /*    This file defines the NetX RTSP Server component, including all     */
37 /*    data types and external references.                                 */
38 /*                                                                        */
39 /*  RELEASE HISTORY                                                       */
40 /*                                                                        */
41 /*    DATE              NAME                      DESCRIPTION             */
42 /*                                                                        */
43 /*  10-31-2023     Wenhui Xie               Initial Version 6.3.0         */
44 /*                                                                        */
45 /**************************************************************************/
46 
47 #ifndef NX_RTSP_SERVER_H
48 #define NX_RTSP_SERVER_H
49 
50 #include "tx_api.h"
51 #include "nx_api.h"
52 
53 /* Determine if a C++ compiler is being used.  If so, ensure that standard
54    C is used to process the API information.  */
55 
56 #ifdef __cplusplus
57 /* Yes, C++ compiler is present.  Use standard C.  */
58 extern   "C" {
59 
60 #endif
61 
62 /* Define the RTSP Server ID.  */
63 #define NX_RTSP_SERVER_ID                                       0x52545350UL
64 
65 /* Define the RTSP protocol version of the RTSP Server.  */
66 #define NX_RTSP_VERSION_STRING                                  "RTSP/1.0"
67 
68 /* Define the RTSP SDP content type.  */
69 #define NX_RTSP_SERVER_CONTENT_TYPE_SDP                         "application/sdp"
70 
71 /* Define the RTSP status code.  */
72 #define NX_RTSP_STATUS_CODE_OK                                  200
73 #define NX_RTSP_STATUS_CODE_CREATED                             201
74 #define NX_RTSP_STATUS_CODE_LOW_ON_STORAGE_SPACE                250
75 #define NX_RTSP_STATUS_CODE_MULTIPLE_CHOICES                    300
76 #define NX_RTSP_STATUS_CODE_MOVED_PERMANENTLY                   301
77 #define NX_RTSP_STATUS_CODE_MOVED_TEMPORARILY                   302
78 #define NX_RTSP_STATUS_CODE_SEE_OTHER                           303
79 #define NX_RTSP_STATUS_CODE_NOT_MODIFIED                        304
80 #define NX_RTSP_STATUS_CODE_USE_PROXY                           305
81 #define NX_RTSP_STATUS_CODE_GOING_AWAY                          350
82 #define NX_RTSP_STATUS_CODE_LOAD_BALANCING                      351
83 #define NX_RTSP_STATUS_CODE_BAD_REQUEST                         400
84 #define NX_RTSP_STATUS_CODE_UNAUTHORIZED                        401
85 #define NX_RTSP_STATUS_CODE_PAYMENT_REQUIRED                    402
86 #define NX_RTSP_STATUS_CODE_FORBIDDEN                           403
87 #define NX_RTSP_STATUS_CODE_NOT_FOUND                           404
88 #define NX_RTSP_STATUS_CODE_METHOD_NOT_ALLOWED                  405
89 #define NX_RTSP_STATUS_CODE_NOT_ACCEPTABLE                      406
90 #define NX_RTSP_STATUS_CODE_PROXY_AUTHENTICATION_REQUIRED       407
91 #define NX_RTSP_STATUS_CODE_REQUEST_TIMEOUT                     408
92 #define NX_RTSP_STATUS_CODE_GONE                                410
93 #define NX_RTSP_STATUS_CODE_LENGTH_REQUIRED                     411
94 #define NX_RTSP_STATUS_CODE_PRECONDITION_FAILED                 412
95 #define NX_RTSP_STATUS_CODE_REQUEST_ENTITY_TOO_LARGE            413
96 #define NX_RTSP_STATUS_CODE_REQUESTURI_TOO_LARGE                414
97 #define NX_RTSP_STATUS_CODE_UNSUPPORTED_MEDIA_TYPE              415
98 #define NX_RTSP_STATUS_CODE_PARAMETER_NOT_UNDERSTOOD            451
99 #define NX_RTSP_STATUS_CODE_RESERVED                            452
100 #define NX_RTSP_STATUS_CODE_NOT_ENOUGH_BANDWIDTH                453
101 #define NX_RTSP_STATUS_CODE_SESSION_NOT_FOUND                   454
102 #define NX_RTSP_STATUS_CODE_METHOD_NOT_VALID_IN_THIS_STATE      455
103 #define NX_RTSP_STATUS_CODE_HEADER_FIELD_NOT_VALID_FOR_RESOURCE 456
104 #define NX_RTSP_STATUS_CODE_INVALID_RANGE                       457
105 #define NX_RTSP_STATUS_CODE_PARAMETER_IS_READONLY               458
106 #define NX_RTSP_STATUS_CODE_AGGREGATE_OPERATION_NOT_ALLOWED     459
107 #define NX_RTSP_STATUS_CODE_ONLY_AGGREGATE_OPERATION_ALLOWED    460
108 #define NX_RTSP_STATUS_CODE_UNSUPPORTED_TRANSPORT               461
109 #define NX_RTSP_STATUS_CODE_DESTINATION_UNREACHABLE             462
110 #define NX_RTSP_STATUS_CODE_INTERNAL_SERVER_ERROR               500
111 #define NX_RTSP_STATUS_CODE_NOT_IMPLEMENTED                     501
112 #define NX_RTSP_STATUS_CODE_BAD_GATEWAY                         502
113 #define NX_RTSP_STATUS_CODE_SERVICE_UNAVAILABLE                 503
114 #define NX_RTSP_STATUS_CODE_GATEWAY_TIMEOUT                     504
115 #define NX_RTSP_STATUS_CODE_RTSP_VERSION_NOT_SUPPORTED          505
116 #define NX_RTSP_STATUS_CODE_OPTION_NOT_SUPPORTED                551
117 
118 /* Define the RTSP Server error code.  */
119 #define NX_RTSP_SERVER_ALREADY_STARTED                          0x7000
120 #define NX_RTSP_SERVER_NOT_STARTED                              0x7001
121 #define NX_RTSP_SERVER_INTERNAL_ERROR                           0x7002
122 #define NX_RTSP_SERVER_NO_PACKET                                0x7003
123 #define NX_RTSP_SERVER_NOT_IMPLEMENTED                          0x7004
124 #define NX_RTSP_SERVER_MISSING_REQUIRED_CALLBACKS               0x7005
125 #define NX_RTSP_SERVER_INVALID_REQUEST                          0x7006
126 #define NX_RTSP_SERVER_INVALID_PARAMETER                        0x7007
127 #define NX_RTSP_SERVER_UNSUPPORTED                              0x7008
128 #define NX_RTSP_SERVER_FAILED                                   0x7009
129 
130 /* Define the max number of concurrent Clients the Server supports.  */
131 #ifndef NX_RTSP_SERVER_MAX_CLIENTS
132 #define NX_RTSP_SERVER_MAX_CLIENTS                              2
133 #endif /* NX_RTSP_SERVER_MAX_CLIENTS */
134 
135 /* Define the RTSP Server time slice.  */
136 #ifndef NX_RTSP_SERVER_TIME_SLICE
137 #define NX_RTSP_SERVER_TIME_SLICE                               TX_NO_TIME_SLICE
138 #endif /* NX_RTSP_SERVER_TIME_SLICE */
139 
140 /* Define the timeout for the packet allocation and data appending.  */
141 #ifndef NX_RTSP_SERVER_PACKET_TIMEOUT
142 #define NX_RTSP_SERVER_PACKET_TIMEOUT                           (1 * NX_IP_PERIODIC_RATE)
143 #endif /* NX_RTSP_SERVER_PACKET_TIMEOUT */
144 
145 /* Define the timeout for the RTSP Server socket accepting.  */
146 #ifndef NX_RTSP_SERVER_ACCEPT_TIMEOUT
147 #define NX_RTSP_SERVER_ACCEPT_TIMEOUT                           (10 * NX_IP_PERIODIC_RATE)
148 #endif /* NX_RTSP_SERVER_ACCEPT_TIMEOUT */
149 
150 /* Define the timeout for the packet sending.  */
151 #ifndef NX_RTSP_SERVER_SEND_TIMEOUT
152 #define NX_RTSP_SERVER_SEND_TIMEOUT                             (1 * NX_IP_PERIODIC_RATE)
153 #endif /* NX_RTSP_SERVER_SEND_TIMEOUT */
154 
155 /* Define the timeout in seconds for Client activity.  */
156 #ifndef NX_RTSP_SERVER_ACTIVITY_TIMEOUT
157 #define NX_RTSP_SERVER_ACTIVITY_TIMEOUT                         60
158 #endif /* NX_RTSP_SERVER_ACTIVITY_TIMEOUT */
159 
160 /* Define the type of service.  */
161 #ifndef NX_RTSP_SERVER_TYPE_OF_SERVICE
162 #define NX_RTSP_SERVER_TYPE_OF_SERVICE                          NX_IP_NORMAL
163 #endif /* NX_RTSP_SERVER_TYPE_OF_SERVICE */
164 
165 /* Define the fragment option.  */
166 #ifndef NX_RTSP_SERVER_FRAGMENT_OPTION
167 #define NX_RTSP_SERVER_FRAGMENT_OPTION                          NX_FRAGMENT_OKAY
168 #endif /* NX_RTSP_SERVER_FRAGMENT_OPTION */
169 
170 /* Define the TTL.  */
171 #ifndef NX_RTSP_SERVER_TIME_TO_LIVE
172 #define NX_RTSP_SERVER_TIME_TO_LIVE                             NX_IP_TIME_TO_LIVE
173 #endif /* NX_RTSP_SERVER_TIME_TO_LIVE */
174 
175 /* Define the window size.  */
176 #ifndef NX_RTSP_SERVER_WINDOW_SIZE
177 #define NX_RTSP_SERVER_WINDOW_SIZE                              8192
178 #endif /* NX_RTSP_SERVER_WINDOW_SIZE */
179 
180 /* Define the RTSP Server events.  */
181 #define NX_RTSP_SERVER_ALL_EVENTS                               0xFFFFFFFF
182 #define NX_RTSP_SERVER_CONNECT_EVENT                            0x00000001
183 #define NX_RTSP_SERVER_DISCONNECT_EVENT                         0x00000002
184 #define NX_RTSP_SERVER_REQUEST_EVENT                            0x00000004
185 #define NX_RTSP_SERVER_TIMEOUT_EVENT                            0x00000008
186 
187 /* Define the RTSP state.  */
188 #define NX_RTSP_STATE_INIT                                      1
189 #define NX_RTSP_STATE_READY                                     2
190 #define NX_RTSP_STATE_PLAYING                                   3
191 
192 /* Define the transport type.  */
193 #define NX_RTSP_TRANSPORT_TYPE_UDP                              0x00
194 #define NX_RTSP_TRANSPORT_TYPE_TCP                              0x01
195 
196 /* There are several modes of transport, see https://www.rfc-editor.org/rfc/rfc2326#section-1.6
197    1. unicast.
198    2. multicast, Server chooses address.
199    3. multicast, Client chooses address.  */
200 #define NX_RTSP_TRANSPORT_MODE_UNICAST                          0x00
201 #define NX_RTSP_TRANSPORT_MODE_MULTICAST_SERVER                 0x01
202 #define NX_RTSP_TRANSPORT_MODE_MULTICAST_CLIENT                 0x02
203 
204 /* Define Server capabilities.  */
205 #define NX_RTSP_METHOD_OPTIONS                                  0x00
206 #define NX_RTSP_METHOD_DESCRIBE                                 0x01
207 #define NX_RTSP_METHOD_SETUP                                    0x02
208 #define NX_RTSP_METHOD_PLAY                                     0x03
209 #define NX_RTSP_METHOD_PAUSE                                    0x04
210 #define NX_RTSP_METHOD_TEARDOWN                                 0x05
211 #define NX_RTSP_METHOD_SET_PARAMETER                            0x06
212 #define NX_RTSP_METHOD_NOT_SUPPORT                              0xFF
213 
214 /* Define the transport structure.  */
215 typedef struct NX_RTSP_TRANSPORT_STRUCT
216 {
217     UCHAR       transport_type;    /* UDP or TCP.  */
218 
219     UCHAR       transport_mode;    /* Unicast or multicast(Server or Client chooses address).  */
220 
221     USHORT      multicast_ttl;     /* TTL for multicast.  */
222 
223     ULONG       rtp_ssrc;          /* RTP SSRC.  */
224 
225     USHORT      client_rtp_port;   /* Client RTP port.  */
226 
227     USHORT      client_rtcp_port;  /* Client RTCP port.  */
228 
229     USHORT      server_rtp_port;   /* Server RTP port.  */
230 
231     USHORT      server_rtcp_port;  /* Server RTCP port.  */
232 
233     NXD_ADDRESS client_ip_address; /* Client IP address.  */
234 
235     NXD_ADDRESS server_ip_address; /* Server IP address.  */
236 
237     UINT        interface_index;   /* IP interface index.  */
238 } NX_RTSP_TRANSPORT;
239 
240 /* Define the response status code and description.  */
241 typedef struct NX_RTSP_RESPONSE_STRCUT
242 {
243     UINT  nx_rtsp_response_code;        /* The value of the response status code.  */
244 
245     CHAR *nx_rtsp_response_description; /* The description of the response status code.  */
246 } NX_RTSP_RESPONSE;
247 
248 /* Define the Client request structure.  */
249 typedef struct NX_RTSP_CLIENT_REQUEST_STRUCT
250 {
251     UINT              nx_rtsp_client_request_method;                 /* OPTION/SETUP/DESCRIBE/PLAY/PAUSE/TEARDOWN/SET_PARAMETER.  */
252 
253     UINT              nx_rtsp_client_request_sequence_number;        /* Current Client sequence number.  */
254 
255     UCHAR            *nx_rtsp_client_request_uri_ptr;                /* Request URI name.  */
256     UINT              nx_rtsp_client_request_uri_length;             /* Request URI length.  */
257 
258     UCHAR            *nx_rtsp_client_request_range_ptr;              /* Range field, needed for holding the PLAY and PAUSE method.  */
259     UINT              nx_rtsp_client_request_range_length;           /* Range field length.  */
260 
261     ULONG             nx_rtsp_client_request_session_id;             /* Session id for request method.  */
262 
263     UINT              nx_rtsp_client_request_response_code;          /* Response status code.  */
264 
265     NX_RTSP_TRANSPORT nx_rtsp_client_request_transport;              /* Transport structure.  */
266 } NX_RTSP_CLIENT_REQUEST;
267 
268 /* Define the Client data structure.  */
269 typedef struct NX_RTSP_CLIENT_STRUCT
270 {
271     UCHAR                         nx_rtsp_client_valid;                    /* This entry is valid or not.  */
272 
273     UCHAR                         nx_rtsp_client_state;                    /* The state a Client is in: INIT/READY/PLAYING. See page 77 RFC 2326.  */
274 
275     UCHAR                         nx_rtsp_client_reserved[2];              /* Reserved.  */
276 
277     NX_TCP_SOCKET                 nx_rtsp_client_socket;                   /* The socket for incoming request.  */
278 
279     ULONG                         nx_rtsp_client_request_activity_timeout; /* Timeout for Client activity.  */
280 
281     ULONG                         nx_rtsp_client_session_id;               /* Session ID, assigned by RTSP, in host byte order.  */
282 
283     struct NX_RTSP_SERVER_STRUCT *nx_rtsp_client_server_ptr;               /* Pointer to the RTSP Server.  */
284 
285     NX_RTSP_CLIENT_REQUEST       *nx_rtsp_client_request_ptr;              /* Pointer to the current Client request.  */
286 
287     NX_RTSP_CLIENT_REQUEST        nx_rtsp_client_request;                  /* The stored client request. */
288 
289     NX_PACKET                    *nx_rtsp_client_request_packet;           /* The request packet received from Client.  */
290 
291     UINT                          nx_rtsp_client_request_bytes_total;      /* The total bytes of the request.  */
292 
293     UINT                          nx_rtsp_client_request_content_length;   /* The content length of the request.  */
294 
295     NX_PACKET                    *nx_rtsp_client_response_packet;          /* The response packet will be send to Client.  */
296 
297     UINT                          nx_rtsp_client_npt_start;                /* The start time in milliseconds of the NPT.  */
298     UINT                          nx_rtsp_client_npt_end;                  /* The end time in milliseconds of the NPT.  */
299 } NX_RTSP_CLIENT;
300 
301 /* Define the method callbacks structure.  */
302 typedef struct NX_RTSP_SERVER_METHOD_CALLBACKS_STRUCT
303 {
304     UINT (*nx_rtsp_server_method_describe_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length);
305 
306     UINT (*nx_rtsp_server_method_setup_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, NX_RTSP_TRANSPORT *transport_ptr);
307 
308     UINT (*nx_rtsp_server_method_play_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length);
309 
310     UINT (*nx_rtsp_server_method_teardown_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length);
311 
312     UINT (*nx_rtsp_server_method_pause_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length);
313 
314     UINT (*nx_rtsp_server_method_set_parameter_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *parameter_ptr, ULONG parameter_length);
315 } NX_RTSP_SERVER_METHOD_CALLBACKS;
316 
317 /* Define the Server structure.  */
318 typedef struct NX_RTSP_SERVER_STRUCT
319 {
320     ULONG                    nx_rtsp_server_id;                 /* The ID of RTSP Server.  */
321 
322     CHAR                    *nx_rtsp_server_name;               /* The name of RTSP Server.  */
323 
324     UINT                     nx_rtsp_server_name_length;        /* The length of RTSP Server's name.  */
325 
326     TX_THREAD                nx_rtsp_server_thread;             /* RTSP Server thread.  */
327 
328     TX_TIMER                 nx_rtsp_server_timer;              /* Timer for Client activity.  */
329 
330     TX_EVENT_FLAGS_GROUP     nx_rtsp_server_event_flags;        /* Event flags.  */
331 
332     NX_IP                   *nx_rtsp_server_ip_ptr;             /* Pointer to the IP instance.  */
333 
334     USHORT                   nx_rtsp_server_port;               /* RTSP Server port.  */
335 
336     UCHAR                    nx_rtsp_server_started;            /* The RTSP Server is started or not.  */
337 
338     UCHAR                    nx_rtsp_server_reserved;           /* Reserved.  */
339 
340     NX_PACKET_POOL          *nx_rtsp_server_packet_pool;        /* Packet Pool for packet allocation.  */
341 
342     /* Infos recorded in RTSP Server procedures.  */
343     ULONG                    nx_rtsp_server_allocation_errors;
344     ULONG                    nx_rtsp_server_relisten_errors;
345     ULONG                    nx_rtsp_server_disconnection_requests;
346     UINT                     nx_rtsp_server_connected_client_count;
347 
348     /* Data structure for all the Clients connected to the RTSP Server.  */
349     NX_RTSP_CLIENT           nx_rtsp_server_client_list[NX_RTSP_SERVER_MAX_CLIENTS];
350 
351     /* The callbacks for the received methods and disconnection.  */
352     UINT                     (*nx_rtsp_server_disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr);
353     NX_RTSP_SERVER_METHOD_CALLBACKS nx_rtsp_server_method_callbacks;
354 } NX_RTSP_SERVER;
355 
356 #ifndef NX_RTSP_SERVER_SOURCE_CODE
357 
358 /* Application caller is present, perform API mapping.  */
359 
360 /* Determine if error checking is desired.  If so, map API functions
361    to the appropriate error checking front-ends.  Otherwise, map API
362    functions to the core functions that actually perform the work.
363    Note: error checking is enabled by default.  */
364 #ifdef NX_DISABLE_ERROR_CHECKING
365 
366 /* Services without error checking.  */
367 #define nx_rtsp_server_create                        _nx_rtsp_server_create
368 #define nx_rtsp_server_delete                        _nx_rtsp_server_delete
369 #define nx_rtsp_server_start                         _nx_rtsp_server_start
370 #define nx_rtsp_server_stop                          _nx_rtsp_server_stop
371 
372 #define nx_rtsp_server_describe_callback_set         _nx_rtsp_server_describe_callback_set
373 #define nx_rtsp_server_setup_callback_set            _nx_rtsp_server_setup_callback_set
374 #define nx_rtsp_server_play_callback_set             _nx_rtsp_server_play_callback_set
375 #define nx_rtsp_server_pause_callback_set            _nx_rtsp_server_pause_callback_set
376 #define nx_rtsp_server_teardown_callback_set         _nx_rtsp_server_teardown_callback_set
377 #define nx_rtsp_server_set_parameter_callback_set    _nx_rtsp_server_set_parameter_callback_set
378 
379 #define nx_rtsp_server_sdp_set                       _nx_rtsp_server_sdp_set
380 #define nx_rtsp_server_rtp_info_set                  _nx_rtsp_server_rtp_info_set
381 #define nx_rtsp_server_range_npt_set                 _nx_rtsp_server_range_npt_set
382 
383 #define nx_rtsp_server_keepalive_update              _nx_rtsp_server_keepalive_update
384 #define nx_rtsp_server_error_response_send           _nx_rtsp_server_error_response_send
385 
386 #else
387 
388 /* Services with error checking.  */
389 #define nx_rtsp_server_create                        _nxe_rtsp_server_create
390 #define nx_rtsp_server_delete                        _nxe_rtsp_server_delete
391 #define nx_rtsp_server_start                         _nxe_rtsp_server_start
392 #define nx_rtsp_server_stop                          _nxe_rtsp_server_stop
393 
394 #define nx_rtsp_server_describe_callback_set         _nxe_rtsp_server_describe_callback_set
395 #define nx_rtsp_server_setup_callback_set            _nxe_rtsp_server_setup_callback_set
396 #define nx_rtsp_server_play_callback_set             _nxe_rtsp_server_play_callback_set
397 #define nx_rtsp_server_pause_callback_set            _nxe_rtsp_server_pause_callback_set
398 #define nx_rtsp_server_teardown_callback_set         _nxe_rtsp_server_teardown_callback_set
399 #define nx_rtsp_server_set_parameter_callback_set    _nxe_rtsp_server_set_parameter_callback_set
400 
401 #define nx_rtsp_server_sdp_set                       _nxe_rtsp_server_sdp_set
402 #define nx_rtsp_server_rtp_info_set                  _nxe_rtsp_server_rtp_info_set
403 #define nx_rtsp_server_range_npt_set                 _nxe_rtsp_server_range_npt_set
404 
405 #define nx_rtsp_server_keepalive_update              _nxe_rtsp_server_keepalive_update
406 #define nx_rtsp_server_error_response_send           _nxe_rtsp_server_error_response_send
407 
408 #endif /* NX_DISABLE_ERROR_CHECKING */
409 
410 /* Define the prototypes accessible to the application software.  */
411 
412 UINT nx_rtsp_server_describe_callback_set(NX_RTSP_SERVER * rtsp_server,
413                                           UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
414 
415 UINT nx_rtsp_server_setup_callback_set(NX_RTSP_SERVER * rtsp_server,
416                                        UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, NX_RTSP_TRANSPORT *transport_ptr));
417 
418 UINT nx_rtsp_server_play_callback_set(NX_RTSP_SERVER * rtsp_server,
419                                       UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
420 
421 UINT nx_rtsp_server_teardown_callback_set(NX_RTSP_SERVER * rtsp_server,
422                                           UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
423 
424 
425 UINT nx_rtsp_server_pause_callback_set(NX_RTSP_SERVER * rtsp_server,
426                                        UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
427 
428 UINT nx_rtsp_server_set_parameter_callback_set(NX_RTSP_SERVER * rtsp_server,
429                                                UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *parameter_ptr, ULONG parameter_length));
430 
431 UINT nx_rtsp_server_create(NX_RTSP_SERVER *rtsp_server_ptr, CHAR *server_name, UINT server_name_length,
432                            NX_IP *ip_ptr, NX_PACKET_POOL *rtsp_packet_pool, VOID *stack_ptr, ULONG stack_size, UINT priority, UINT server_port,
433                            UINT (*disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr));
434 
435 UINT nx_rtsp_server_delete(NX_RTSP_SERVER *rtsp_server);
436 
437 UINT nx_rtsp_server_start(NX_RTSP_SERVER *rtsp_server);
438 
439 UINT nx_rtsp_server_stop(NX_RTSP_SERVER *rtsp_server);
440 
441 /* Called in DESCRIBE callback function to set SDP string.  */
442 UINT nx_rtsp_server_sdp_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *sdp_string, UINT sdp_length);
443 
444 /* Called in PLAY callback function to set RTP-Info field, including the RTP sequence number and RTP timestamp.  */
445 UINT nx_rtsp_server_rtp_info_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *track_id, UINT track_id_len, UINT rtp_seq, UINT rtp_time);
446 
447 /* Called in PLAY and PAUSE callback functions to set the NPT start and end time in Range field.  */
448 UINT nx_rtsp_server_range_npt_set(NX_RTSP_CLIENT *rtsp_client_ptr, UINT npt_start, UINT npt_end);
449 
450 /* If received RTCP reports, call this API to update the keepalive timeout. https://www.rfc-editor.org/rfc/rfc2326#appendix-A.2.  */
451 UINT nx_rtsp_server_keepalive_update(NX_RTSP_CLIENT *rtsp_client_ptr);
452 
453 UINT nx_rtsp_server_error_response_send(NX_RTSP_CLIENT *rtsp_client_ptr, UINT status_code);
454 
455 #else
456 
457 /* Define the prototypes accessible to the application software.  */
458 
459 UINT _nx_rtsp_server_describe_callback_set(NX_RTSP_SERVER * rtsp_server,
460                                            UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
461 UINT _nxe_rtsp_server_describe_callback_set(NX_RTSP_SERVER * rtsp_server,
462                                             UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
463 
464 UINT _nx_rtsp_server_setup_callback_set(NX_RTSP_SERVER * rtsp_server,
465                                         UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, NX_RTSP_TRANSPORT *transport_ptr));
466 UINT _nxe_rtsp_server_setup_callback_set(NX_RTSP_SERVER * rtsp_server,
467                                          UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, NX_RTSP_TRANSPORT *transport_ptr));
468 
469 UINT _nx_rtsp_server_play_callback_set(NX_RTSP_SERVER * rtsp_server,
470                                        UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
471 UINT _nxe_rtsp_server_play_callback_set(NX_RTSP_SERVER * rtsp_server,
472                                         UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
473 
474 UINT _nx_rtsp_server_teardown_callback_set(NX_RTSP_SERVER * rtsp_server,
475                                            UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
476 UINT _nxe_rtsp_server_teardown_callback_set(NX_RTSP_SERVER * rtsp_server,
477                                             UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length));
478 
479 UINT _nx_rtsp_server_pause_callback_set(NX_RTSP_SERVER * rtsp_server,
480                                         UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
481 UINT _nxe_rtsp_server_pause_callback_set(NX_RTSP_SERVER * rtsp_server,
482                                          UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *range_ptr, UINT range_length));
483 
484 
485 UINT _nx_rtsp_server_set_parameter_callback_set(NX_RTSP_SERVER * rtsp_server,
486                                                 UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *parameter_ptr, ULONG parameter_length));
487 UINT _nxe_rtsp_server_set_parameter_callback_set(NX_RTSP_SERVER * rtsp_server,
488                                                  UINT (*)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length, UCHAR *parameter_ptr, ULONG parameter_length));
489 
490 UINT _nx_rtsp_server_create(NX_RTSP_SERVER *rtsp_server_ptr, CHAR *server_name, UINT server_name_length,
491                             NX_IP *ip_ptr, NX_PACKET_POOL *rtsp_packet_pool, VOID *stack_ptr, ULONG stack_size, UINT priority, UINT server_port,
492                             UINT (*disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr));
493 UINT _nxe_rtsp_server_create(NX_RTSP_SERVER *rtsp_server_ptr, CHAR *server_name, UINT server_name_length,
494                              NX_IP *ip_ptr, NX_PACKET_POOL *rtsp_packet_pool, VOID *stack_ptr, ULONG stack_size, UINT priority, UINT server_port,
495                              UINT (*disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr));
496 
497 UINT _nx_rtsp_server_delete(NX_RTSP_SERVER *rtsp_server);
498 UINT _nxe_rtsp_server_delete(NX_RTSP_SERVER *rtsp_server);
499 
500 UINT _nx_rtsp_server_start(NX_RTSP_SERVER *rtsp_server);
501 UINT _nxe_rtsp_server_start(NX_RTSP_SERVER *rtsp_server);
502 
503 UINT _nx_rtsp_server_stop(NX_RTSP_SERVER *rtsp_server);
504 UINT _nxe_rtsp_server_stop(NX_RTSP_SERVER *rtsp_server);
505 
506 /* Called in DESCRIBE callback function to set SDP string.  */
507 UINT _nx_rtsp_server_sdp_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *sdp_string, UINT sdp_length);
508 UINT _nxe_rtsp_server_sdp_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *sdp_string, UINT sdp_length);
509 
510 /* Called in PLAY callback function to set RTP-Info field, including the RTP sequence number and RTP timestamp.  */
511 UINT _nx_rtsp_server_rtp_info_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *track_id, UINT track_id_len, UINT rtp_seq, UINT rtp_time);
512 UINT _nxe_rtsp_server_rtp_info_set(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *track_id, UINT track_id_len, UINT rtp_seq, UINT rtp_time);
513 
514 /* Called in PLAY and PAUSE callback functions to set the NPT start and end time in Range field.  */
515 UINT _nx_rtsp_server_range_npt_set(NX_RTSP_CLIENT *rtsp_client_ptr, UINT npt_start, UINT npt_end);
516 UINT _nxe_rtsp_server_range_npt_set(NX_RTSP_CLIENT *rtsp_client_ptr, UINT npt_start, UINT npt_end);
517 
518 /* If received RTCP reports, call this API to update the keepalive timeout. https://www.rfc-editor.org/rfc/rfc2326#appendix-A.2.  */
519 UINT _nx_rtsp_server_keepalive_update(NX_RTSP_CLIENT *rtsp_client_ptr);
520 UINT _nxe_rtsp_server_keepalive_update(NX_RTSP_CLIENT *rtsp_client_ptr);
521 
522 UINT _nx_rtsp_server_error_response_send(NX_RTSP_CLIENT *rtsp_client_ptr, UINT status_code);
523 UINT _nxe_rtsp_server_error_response_send(NX_RTSP_CLIENT *rtsp_client_ptr, UINT status_code);
524 
525 #endif /* NX_RTSP_SERVER_SOURCE_CODE */
526 
527 
528 /* Determine if a C++ compiler is being used.  If so, complete the standard
529    C conditional started above.  */
530 #ifdef __cplusplus
531 }
532 #endif
533 
534 #endif /* NX_RTSP_SERVER_H */
535 
536