This chapter contains a description of all NetX Duo RTSP server services (listed below) in alphabetic order.
Note: In the Return Values section in the following API descriptions, values in BOLD are not affected by the NX_DISABLE_ERROR_CHECKING define that is used to disable API error checking, while non-bold values are completely disabled.
Create an RTSP server instance
UINT nx_rtsp_server_create(
NX_RTSP_SERVER *rtsp_server_ptr,
CHAR *server_name,
UINT server_name_length,
NX_IP *ip_ptr,
NX_PACKET_POOL *rtsp_packet_pool,
VOID *stack_ptr,
ULONG stack_size,
UINT priority,
UINT server_port,
UINT (*disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr))
This service creates an RTSP server on the specified IP and port.
Threads
/* Create the RTSP Server instance "rtsp_0". */
status = nx_rtsp_server_create(&rtsp_0, "RTSP Server",
sizeof("RTSP Server") - 1, ip_ptr, pool_ptr,
rtsp_server_stack, DEMO_RTSP_SERVER_STACK_SIZE,
3, 554, rtsp_disconnect_callback);
/* If status is NX_SUCCESS an RTSP server instance was successfully created. */
Delete an RTSP server instance
UINT nx_rtsp_server_delete(NX_RTSP_SERVER *rtsp_server_ptr);
This service deletes a previously created RTSP server.
Threads
/* Delete the RTSP server instance "rtsp_0". */
status = nx_rtsp_server_delete(&rtsp_0);
/* If status is NX_SUCCESS the RTSP server instance was successfully
deleted. */
Set the callback function for DESCRIBE request
UINT nx_rtsp_server_describe_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length));
This service sets callback function for DESCRIBE request. This callback function is called when an RTSP client sends a DESCRIBE request to the server. nx_rtsp_server_sdp_set should be called in the callback function to set the SDP information for the DESCRIBE response.
Threads
/* Set DESCRIBE request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_describe_callback_set(&rtsp_0, rtsp_describe_callback);
/* If status is NX_SUCCESS the DESCRIBE request callback function was successfully set. */
Send the error response packet
UINT nx_rtsp_server_error_response_send(
NX_RTSP_CLIENT *rtsp_client_ptr,
UINT status_code);
This service sends the error response packet with specified status code.
Threads
/* Send error response to the connected RTSP client. */
status = nx_rtsp_server_error_response_send(rtsp_client_ptr, NX_RTSP_STATUS_CODE_UNSUPPORTED_MEDIA_TYPE);
/* If status is NX_SUCCESS the error response was successfully sent. */
Update the keep-alive timer
UINT nx_rtsp_server_keepalive_update(
NX_RTSP_CLIENT *rtsp_client_ptr);
This service updates the keep-alive timer. If RTP is used for media transport, the keep-alive timer is updated when an RTCP packet is received.
Threads
/* Update keep-alive timer for the connected RTSP client. */
status = nx_rtsp_server_keepalive_update(rtsp_client_ptr);
/* If status is NX_SUCCESS the keep-alive timer was successfully updated. */
Set the callback function for PAUSE request
UINT nx_rtsp_server_pause_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length,
UCHAR *range_ptr,
UINT range_length));
This service sets callback function for PAUSE request. This callback function is called when an RTSP client sends a PAUSE request to the server. nx_rtsp_server_range_npt_set can be called in the callback function to set the NPT range for the PAUSE response.
Threads
/* Set PAUSE request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_pause_callback_set(&rtsp_0, rtsp_pause_callback);
/* If status is NX_SUCCESS the PAUSE request callback function was successfully set. */
Set the callback function for PLAY request
UINT nx_rtsp_server_play_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length,
UCHAR *range_ptr,
UINT range_length));
This service sets callback function for PLAY request. This callback function is called when an RTSP client sends a PLAY request to the server. nx_rtsp_server_range_npt_set can be called in the callback function to set the NPT range for the PLAY response. nx_rtsp_server_rtp_info_set must be called in the callback function to set the RTP-Info header for the PLAY response.
Threads
/* Set PLAY request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_play_callback_set(&rtsp_0, rtsp_play_callback);
/* If status is NX_SUCCESS the PLAY request callback function was successfully set. */
Set the NPT start and end time
UINT nx_rtsp_server_range_npt_set(
NX_RTSP_CLIENT *rtsp_client_ptr
UINT npt_start,
UINT npt_end);
This service sets the NPT start and end time in Range field. This function can only be called in PLAY and PAUSE request callback functions.
Threads
/* Set the NPT start and end time. */
status = nx_rtsp_server_range_npt_set(rtsp_client_ptr, 0, 30000);
/* If status is NX_SUCCESS the NPT time was successfully set. */
Set the RTP-Info to the response packet
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);
This service sets the RTP-Info to the response packet. This function can only be called in PLAY callback function.
Threads
/* Set the RTP-Info for video. */
status = nx_rtsp_server_rtp_info_set(rtsp_client_ptr, DEMO_RTSP_VIDEO_FILE_NAME, sizeof(DEMO_RTSP_VIDEO_FILE_NAME) - 1, video_seq, video_rtptime);
/* If status is NX_SUCCESS the RTP-Info was successfully set. */
Set the SDP string to the response packet
UINT nx_rtsp_server_sdp_set(
NX_RTSP_CLIENT *rtsp_client_ptr
UCHAR *sdp_string,
UINT sdp_length);
This service sets the SDP string to the response packet. This function can only be called in DESCRIBE callback function.
Threads
/* Set the SDP string. */
status = nx_rtsp_server_sdp_set(rtsp_client_ptr, sdp, strlen(sdp));
/* If status is NX_SUCCESS the SDP was successfully set. */
Set the callback function for SETUP request
UINT nx_rtsp_server_setup_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length,
NX_RTSP_TRANSPORT *transport_ptr));
This service sets callback function for SETUP request. This callback function is called when an RTSP client sends a SETUP request to the server. The client transport information is passed to the callback function. And the callback function must set the server transport information back.
Threads
/* Set SETUP request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_setup_callback_set(&rtsp_0, rtsp_setup_callback);;
/* If status is NX_SUCCESS the SETUP request callback function was successfully set. */
Set the callback function for SET_PARAMETER request
UINT nx_rtsp_server_set_parameter_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length,
UCHAR *parameter_ptr,
ULONG parameter_length));
This service sets callback function for SET_PARAMETER request. This callback function is called when an RTSP client sends a SET_PARAMETER request to the server. The parameters which the client requests to update are passed to the callback function.
Threads
/* Set SET_PARAMETER request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_set_parameter_callback_set(&rtsp_0, rtsp_set_parameter_callback);
/* If status is NX_SUCCESS the SET_PARAMETER request callback function was successfully set. */
Start the RTSP server
UINT nx_rtsp_server_start(
NX_RTSP_SERVER *rtsp_server_ptr);
This service starts the RTSP server. This function must be called after the RTSP server is created.
Threads
/* Start the RTSP server instance "rtsp_0". */
status = nx_rtsp_server_start(&rtsp_0);
/* If status is NX_SUCCESS the RTSP server was successfully started. */
Stop the RTSP server
UINT nx_rtsp_server_stop(
NX_RTSP_SERVER *rtsp_server_ptr);
This service stops a previously started RTSP server.
Threads
/* Stop the RTSP server instance "rtsp_0". */
status = nx_rtsp_server_stop(&rtsp_0);
/* If status is NX_SUCCESS the RTSP server was successfully stopped. */
Set the callback function for TEARDOWN request
UINT nx_rtsp_server_teardown_callback_set(
NX_RTSP_SERVER *rtsp_server_ptr,
UINT (*callback)(
NX_RTSP_CLIENT *rtsp_client_ptr,
UCHAR *uri,
UINT uri_length));
This service sets callback function for TEARDOWN request. This callback function is called when an RTSP client sends a TEARDOWN request to the server. The transport sessions should be closed in this callback function.
Threads
/* Set TEARDOWN request callback function for RTSP server instance "rtsp_0". */
status = nx_rtsp_server_teardown_callback_set(&rtsp_0, rtsp_teardown_callback);;
/* If status is NX_SUCCESS the TEARDOWN request callback function was successfully set. */