unofficial-rtos-docs

Chapter 3 - Description of NetX Duo RTSP Server Services

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.

nx_rtsp_server_create

Create an RTSP server instance

Prototype

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))

Description

This service creates an RTSP server on the specified IP and port.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_delete

Delete an RTSP server instance

Prototype

UINT nx_rtsp_server_delete(NX_RTSP_SERVER *rtsp_server_ptr);

Description

This service deletes a previously created RTSP server.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_describe_callback_set

Set the callback function for DESCRIBE request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_error_response_send

Send the error response packet

Prototype

UINT nx_rtsp_server_error_response_send(
    NX_RTSP_CLIENT *rtsp_client_ptr,
    UINT status_code);

Description

This service sends the error response packet with specified status code.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_keepalive_update

Update the keep-alive timer

Prototype

UINT nx_rtsp_server_keepalive_update(
    NX_RTSP_CLIENT *rtsp_client_ptr);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_pause_callback_set

Set the callback function for PAUSE request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_play_callback_set

Set the callback function for PLAY request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_range_npt_set

Set the NPT start and end time

Prototype

UINT nx_rtsp_server_range_npt_set(
    NX_RTSP_CLIENT *rtsp_client_ptr
    UINT npt_start,
    UINT npt_end);

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_rtp_info_set

Set the RTP-Info to the response packet

Prototype

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);

Description

This service sets the RTP-Info to the response packet. This function can only be called in PLAY callback function.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_sdp_set

Set the SDP string to the response packet

Prototype

UINT nx_rtsp_server_sdp_set(
    NX_RTSP_CLIENT *rtsp_client_ptr
    UCHAR *sdp_string,
    UINT sdp_length);

Description

This service sets the SDP string to the response packet. This function can only be called in DESCRIBE callback function.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_setup_callback_set

Set the callback function for SETUP request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_set_parameter_callback_set

Set the callback function for SET_PARAMETER request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_start

Start the RTSP server

Prototype

UINT nx_rtsp_server_start(
    NX_RTSP_SERVER *rtsp_server_ptr);

Description

This service starts the RTSP server. This function must be called after the RTSP server is created.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_stop

Stop the RTSP server

Prototype

UINT nx_rtsp_server_stop(
    NX_RTSP_SERVER *rtsp_server_ptr);

Description

This service stops a previously started RTSP server.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */

nx_rtsp_server_teardown_callback_set

Set the callback function for TEARDOWN request

Prototype

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));

Description

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.

Input Parameters

Return Values

Allowed From

Threads

Example

/* 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. */