ThreadX docsThreadX docs
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
ThreadX
ThreadX Modules
NetX Duo
FileX
GUIX
USBX
TraceX
LevelX
  • NetX Duo Documentation

    • Understand NetX Duo
    • NetX Duo documentation
    • Chapter 1 - Introduction to NetX Duo
    • Chapter 2 - Installation and Use of NetX Duo
    • Chapter 3 - Functional Components of NetX Duo
    • Chapter 4 - Description of NetX Duo Services
    • Chapter 5 - NetX Duo Network Drivers
    • Appendix A - NetX Duo Services
    • Appendix B - NetX Duo Constants
    • Appendix C - NetX Duo Data Types
    • Appendix D - NetX Duo BSD-Compatible Socket API
    • Appendix E - NetX Duo ASCII Character Codes
    • Auto-IP

      • Chapter 1 - Introduction to NetX Duo AutoIP
      • Chapter 2 - Installation and use of NetX Duo AutoIP
      • Chapter 3 - Description of NetX Duo AutoIP services
    • BSD

      • Chapter 1 - Introduction to NetX Duo BSD
      • Chapter 2 - Installation and use of NetX Duo BSD
      • Chapter 3 - NetX Duo BSD Services
    • Crypto

      • Chapter 1 - Introduction to NetX Duo Crypto
      • Chapter 2 - Installation and use of NetX Duo Crypto
      • Chapter 3 - Functional description of NetX Duo Crypto
      • Chapter 4 - NetX Duo Crypto API description
      • Appendix - NetX Duo Crypto CAVS test
    • DHCP Client

      • Chapter 1 - Introduction to the NetX Duo DHCP Client
      • Chapter 2 - Installation and use of NetX Duo DHCP Client
      • Chapter 3 - Description of NetX Duo DHCP Client services
      • Appendix A - Description of the Restore state feature for NetX Duo DHCP Client services
    • DHCP Server

      • Chapter 1 - Introduction to NetX Duo DHCP Server
      • Chapter 2 - Installation and Use of the NetX Duo DHCP Server
      • Chapter 3 - Description of NetX Duo DHCP server services
    • DHCPv6 Client

      • Chapter 1 - Introduction to NetX Duo DHCPv6 Client
      • Chapter 2 - Installation and use of NetX Duo DHCPv6 Client
      • Chapter 3 - NetX Duo DHCPv6 configuration options
      • Chapter 4 - NetX Duo DHCPv6 Client services
      • Appendix A - Description of the Restore State Feature for NetX Duo DHCPv6 Client
    • DHCPv6 Server

      • Chapter 1 - Introduction to NetX Duo DHCPv6 server
      • Chapter 2 - Installation and use of NetX Duo DHCPv6 server
      • Chapter 3 - NetX Duo DHCPv6 server configuration options
      • Chapter 4 - NetX Duo DHCPv6 server services
      • Appendix A – NetX Duo DHCPv6 option codes
      • Appendix B - NetX Duo DHCPv6 server status codes
      • Appendix C - NetX Duo DHCPv6 unique identifiers (DUIDs)
      • Appendix D - NetX Duo Advanced DHCPv6 server example
    • DNS

      • Chapter 1 - Introduction to the NetX Duo DNS Client
      • Chapter 2 - Installation and Use of NetX Duo DNS Client
      • Chapter 3 - Description of NetX Duo DNS Client Services
    • FTP

      • Chapter 1 - Introduction to NetX Duo FTP
      • Chapter 2 - Installation and use of FTP
      • Chapter 3 - Description of FTP services
    • HTTP

      • Chapter 1 - Introduction to NetX Duo HTTP
      • Chapter 2 - Installation and Use of NetX Duo HTTP
      • Chapter 3 - Description of NetX Duo HTTP Services
    • iperf

      • Chapter 1 - Introduction to NetX Duo Iperf
      • Chapter 2 - Installing and using NetX Duo Iperf
      • Chapter 3 - Running the UDP Transmit Test
    • mDNS

      • Chapter 1 - Introduction to NetX Duo mDNS/DNS-SD
      • Chapter 2 - Installation and use of mDNS
      • Chapter 3 - Description of internal service cache
      • Chapter 4 - Description of mDNS services
    • mqtt

      • Chapter 1 - Introduction to NetX Duo MQTT
      • Chapter 2 - Installation and use of NetX Duo MQTT client
      • Chapter 3 - Description of NetX Duo MQTT Client Services
    • NAT

      • Chapter 1 - An introduction to Network Address Translation
      • Chapter 2 - Installation and use of NAT
      • Chapter 3 - NAT configuration options
      • Chapter 4 - Description of NAT services
    • POP3 Client

      • Chapter 1 - Introduction to NetX Duo POP3
      • Chapter 2 - Installation and use of NetX Duo POP3 Client
      • Chapter 3 - Description of POP3 Client services
    • PPP

      • Chapter 1 - Introduction to the NetX Duo Point-to-Point Protocol (PPP)
      • Chapter 2 - Installation and use of NetX Duo Point-to-Point Protocol (PPP)
      • Chapter 3 - Description of NetX Duo Point-to-Point Protocol (PPP) services
    • PTP Client

      • Chapter 1 - Introduction to NetX Duo PTP Client
      • Chapter 2 - Installation and Use of NetX Duo PTP Client
      • Chapter 3 - Description of NetX Duo PTP Client Services
    • rtp

      • Chapter 1 - Introduction to the NetX Duo RTP Sender
      • Chapter 2 - Installation and use of NetX Duo RTP Sender
      • Chapter 3 - Description of NetX Duo RTP Sender Services
    • rtsp

      • Chapter 1 - Introduction to the NetX Duo RTSP Server
      • Chapter 2 - Installation and use of NetX Duo RTSP Server
      • Chapter 3 - Description of NetX Duo RTSP Server Services
    • Secure DTLS

      • Chapter 1 - Introduction to NetX Duo Secure DTLS
      • Chapter 2 - Installation and use of NetX Duo Secure DTLS
      • Chapter 3 - Functional description of NetX Duo Secure DTLS
      • Chapter 4 - Description of NetX Duo Secure DTLS services
      • Appendix A - NetX Duo Secure DTLS return/error codes
    • Secure TLS

      • Chapter 1 - Introduction to NetX Duo Secure
      • Chapter 2 - Installation and use of NetX Duo Secure
      • Chapter 3 - Functional description of NetX Duo Secure
      • Chapter 4 - Description of NetX Duo Secure services
      • Appendix A - NetX Duo Secure return/error codes
    • SMTP Client

      • Chapter 1 - Introduction to NetX Duo SMTP client
      • Chapter 2 - Installation and use of NetX Duo SMTP client
      • Chapter 3 - Client description of SMTP Client services
    • snmp

      • Chapter 1 - Introduction to NetX Duo SNMP
      • Chapter 2 - Installation and use of the NetX Duo SNMP agent
      • Chapter 3 - Description of NetX Duo SNMP agent services
    • sntp client

      • Chapter 1 - Introduction to NetX Duo SNTP
      • Chapter 2 - Installation and Use of NetX Duo SNTP Client
      • Chapter 3 - Description of NetX Duo SNTP Client Services
      • Appendix A - NetX Duo SNTP Fatal Error Codes
    • telnet

      • Chapter 1 - Introduction to NetX Duo Telnet
      • Chapter 2 - Installation and use of NetX Duo Telnet
      • Chapter 3 - Description of NetX Duo Telnet services
    • TFTP

      • Chapter 1 - Introduction to NetX Duo TFTP
      • Chapter 2 - Installation and use of NetX Duo TFTP
      • Chapter 3 - Description of NetX Duo TFTP services
    • Web HTTP

      • Chapter 1 - Introduction to HTTP and HTTPS
      • Chapter 2 - Installation and use of HTTP and HTTPS
      • Chapter 3 - Description of HTTP services
    • About the NetX Duo User Guide

Chapter 1 - Introduction to the NetX Duo RTSP Server

The Real-Time Streaming Protocol (RTSP) is a protocol designed for multimedia network remote control. NetX Duo RTSP Server utilizes transmission control protocol (TCP) services to perform its packets transfer function. Therefore, RTSP provides a highly reliable control service.

RTSP Server normally relies on RTP to transmit continuous multimedia streams. RTSP server is responsible for the RTSP session management and it also creates the RTP Sender instance, and then creates the RTP session instance on the RTP Sender, and calls the RTP Sender APIs to send the RTP/RTCP packets.

RTSP Server Requirements

In order to function properly, the NetX Duo RTSP Server package requires that a NetX Duo is installed. In addition, an IP instance must already be created, and TCP must be enabled on that same IP instance. The RTSP Server package has no further requirements.

RTSP RFCs

RTSP Server is compliant with the following RFCs:

RFC 2326 Real Time Streaming Protocol (RTSP).

RTSP Concepts

Client-Server Model: RTSP operates on a client-server model where the client initiates requests to the server to control the streaming session.

Control and Data Channels: RTSP uses two channels: the control channel for sending control commands (play, pause, etc.) and the data channel for streaming the actual media content.

Transport Method:

  • Unicast: the media stream is sent from the RTSP server to the client which raises the RTSP request, with the port number specified in the SETUP request.

  • Multicast (server choose address): the RTSP server chooses the multicast address and port number, and sends them to the client in the DESCRIBE response. This is the typical way for live media transmission.

  • Multicast (client choose address): not supported. The RTSP server is not supported to join in an existing multicast conference through the client's request.

RTSP Server Communication/Method

RTSP Server methods referred in RFC 2326:

  • OPTIONS: supported by default. This method requests the methods supported by the server.
Example:
    RTSP Client -> RTSP Server: OPTIONS * RTSP/1.0
                                CSeq: 1
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 1
                                Public: OPTIONS, DESCRIBE, SETUP, TEARDOWN, PLAY, PAUSE, SET_PARAMETER
  • DESCRIBE: supported. This method requests information about the media stream. The application can choose to enable this method by registering the callback function nx_rtsp_server_describe_callback_set().
Example:
    RTSP Client -> RTSP Server: DESCRIBE rtsp://10.0.0.55:554 RTSP/1.0
                                CSeq: 2
                                Accept: application/sdp
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 2
                                Content-Type: application/sdp
                                Content-Length: 149

                                v=0
                                s=PCM audio, streamed by the NetX Duo RTSP Server
                                m=audio 0 RTP/AVP 11
                                a=rtpmap:11 L16/44100/1
                                a=fmtp:11 emphasis=50-15
                                a=ptime:5
                                a=control:trackID=0
  • SETUP: supported. This method prepares the server for streaming. The application MUST enable this method by registering the callback function nx_rtsp_server_setup_callback_set().
Example:
    RTSP Client -> RTSP Server: SETUP rtsp://10.0.0.55:554/trackID=0 RTSP/1.0
                                CSeq: 3
                                Transport: RTP/AVP;unicast;client_port=55612-55613
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 3
                                Server: RTSP Server
                                Session: 15724;timeout=60
                                Transport: RTP/AVP;unicast;client_port=55612-55613;server_port=5004-5005;ssrc=6334
  • PLAY: supported. This method starts playing the media stream. The application MUST enable this method by registering the callback function nx_rtsp_server_play_callback_set().
Example:
    RTSP Client -> RTSP Server: PLAY rtsp://10.0.0.55:554 RTSP/1.0
                                CSeq: 4
                                Session: 15724
                                Range: npt=0.000-
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 4
                                Server: RTSP Server
                                RTP-Info: url=rtsp://10.0.0.55:554/trackID=0;seq=26500;rtptime=19169
                                Range: npt=0.000-
                                Session: 15724;timeout=60
  • PAUSE: supported. This method pauses the media stream. The application can choose to enable this method by registering the callback function nx_rtsp_server_pause_callback_set().
Example:
    RTSP Client -> RTSP Server: PAUSE rtsp://10.0.0.55:554 RTSP/1.0
                                CSeq: 5
                                Session: 15724
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 5
                                Server: RTSP Server
                                Range: npt=0.000-
                                Session: 15724;timeout=60
  • SET_PARAMETER: supported. This method sets the value of a parameter. The application can choose to enable this method by registering the callback function nx_rtsp_server_set_parameter_callback_set().
Example:
    RTSP Client -> RTSP Server: SET_PARAMETER rtsp://10.0.0.55:554 RTSP/1.0
                                CSeq: 6
                                Content-Type: text/parameters
                                Content-Length: 15

                                volume: 0.5
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 6
                                Server: RTSP Server
                                Session: 15724;timeout=60
  • TEARDOWN: supported. This method ends the session and stops streaming. The application MUST enable this method by registering the callback function nx_rtsp_server_teardown_callback_set().
Example:
    RTSP Client -> RTSP Server: TEARDOWN rtsp://10.0.0.55:554 RTSP/1.0
                                CSeq: 7
                                Session: 15724
    RTSP Server -> RTSP Client: RTSP/1.0 200 OK
                                CSeq: 7
                                Server: RTSP Server
  • ANNOUNCE: not supported. The application can use DESCRIBE method to present the description of RTSP Server.
  • GET_PARAMETERS: not supported.
  • REDIRECT: not supported.
  • RECORD: not supported.
  • Embedded (Interleaved) Binary Data: not supported.

RTSP Server Basic Operation

An application can create an RTSP server by calling nx_rtsp_server_create(). After that, all functional needed RTSP method callback functions shall be registered before starting the server. Mandatory registered RTSP methods MUST be registered before staring the RTSP server; otherwise, starting the RTSP server will fail.

Mandatory registered RTSP methods:

  • SETUP: registered by calling nx_rtsp_server_setup_callback_set()
  • PLAY: registered by calling nx_rtsp_server_play_callback_set()
  • TEARDOWN: registered by calling nx_rtsp_server_teardown_callback_set()

Optional registered RTSP methods:

  • DESCRIBE: registered by calling nx_rtsp_server_describe_callback_set()
  • PAUSE: registered by calling nx_rtsp_server_pause_callback_set()
  • SET_PARAMETER: registered by calling nx_rtsp_server_set_parameter_callback_set()

When all mandatory RTSP methods are successfully registered, the application can start the RTSP server by calling nx_rtsp_server_start(). The RTSP server is then ready to accept incoming RTSP requests. The application can temporarily stop the RTSP server by calling nx_rtsp_server_stop() and restart the RTSP server by calling nx_rtsp_server_start(). The application can also release the resources through deleting the RTSP server by calling nx_rtsp_server_delete().

Note: A software timer used to check RTSP session timeout is created with the RTSP server. The application can change the timeout value by modifying the macro NX_RTSP_SERVER_ACTIVITY_TIMEOUT. The default timeout value is 60 seconds. The software timer is automatically refreshed when an RTSP request is received from the client; therefore, some RTSP client(s) usually send a OPTION request to keep the RTSP session alive. Besides, if RTP is applied as the real-time data sending mechanism, the periodical received RTCP report from the receiver also refreshes the software timer. Thus, the application shall call the function nx_rtsp_server_keepalive_update() in the callback function of RTCP RR report receiving. Reference the user guide in the RTP module for more details about RTCP RR report.

As the RTSP server receives a DESCRIBE request, it invokes the callback function if the function is set. The callback function passes the pointer to the RTSP client and the pointer to the URI with URI length. In the callback function, since SDP (Session Description Protocol) is applied as the standard to present media initialization information for RTSP server resources, the application SHOULD call nx_rtsp_server_sdp_set() which passes the SDP string to RTSP server. The SDP string contains the information about the supported multimedia format and corresponding details of the RTSP server. These information is parsed and attached in the response of the DESCRIBE request to the RTSP client. Besides, these information probably contains the mechanism utilized by RTSP to send real-time data stream(s). RTP is normally a typical protocol to use. The SDP string shall be compliant with the standard if describing RTP. Except above operations, this callback function may also execute any other application needed code. The callback function is declared as:

UINT (*nx_rtsp_server_method_describe_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length);

Note: A standard format SDP string which can describe current RTSP server multimedia resources shall be prepared for the DESCRIBE request callback function.

As the RTSP server receives a SETUP request, it invokes the callback function which must have been set. The callback function passes the pointer to the RTSP client, the pointer to the URI with URI length and the pointer to the transport structure. The application shall parse the URI string first, and if RTP is applied as the real-time data sending mechanism, the application can setup specific RTP sessions based on the parsed setup requirement from the client, and may also execute any other application needed code. The callback function is declared as:

UINT (*nx_rtsp_server_method_setup_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length,
                                             NX_RTSP_TRANSPORT *transport_ptr);

As the RTSP server receives a PLAY request, it invokes the callback function which must have been set. The callback function passes the pointer to the RTSP client, the pointer to the URI with URI length and the pointer to the string with the playing time range information. The application shall parse the range string and if RTP is applied as the real-time data sending mechanism, read and set RTP sequence number with the play range into the response of PLAY request to the client by calling nx_rtsp_server_rtp_info_set(), and may execute any other application needed code. The callback function is declared as:

UINT (*nx_rtsp_server_method_play_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length,
                                            UCHAR *range_ptr, UINT range_length);

As the RTSP server receives a PAUSE request, it invokes the callback function if the function is set. The callback function passes the pointer to the RTSP client and the pointer to the URI with URI length and the pointer to the string with the playing time range information. In the callback function, the application could execute own code to temporarily pause current data sending. The callback function is declared as:

UINT (*nx_rtsp_server_method_pause_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length,
                                             UCHAR *range_ptr, UINT range_length);

Note: In the callback function of PLAY and PAUSE request, through parsing the received range string, the application can execute nothing with the Range field if the requested NPT start and end time in Range field initially looks like "Range: npt=0.000-". It is also possible that none zero time Range field is requested by the receiver, then the application can set a significant NPT start and end time in Range field inside the response of PLAY or PAUSE request by calling nx_rtsp_server_range_npt_set(). The application set time range may be different with the parsed range requested by the receiver, the value can vary depending on the real application.

As the RTSP server receives a SET_PARAMETER request, it invokes the callback function if the function is set. The callback function passes the pointer to the RTSP client and the pointer to the URI with URI length and the pointer to the string with the parameter information. In the callback function, the application could execute own code to set the value of the parameter(s) parsed by the request from the client. The callback function is declared as:

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

As the RTSP server receives a TEARDOWN request, it invokes the callback function which must have been set. The callback function passes the pointer to the RTSP client, the pointer to the URI with URI length. If RTP is applied as the real-time data sending mechanism, the application shall delete the related RTP session(s) with the receiver, and execute any other application needed code. The callback function is declared as:

UINT (*nx_rtsp_server_method_teardown_callback)(NX_RTSP_CLIENT *rtsp_client_ptr, UCHAR *uri, UINT uri_length);

As the RTSP server receives a disconnection from the receiver and so, invokes the application callback function if the function is set. The callback function passes the pointer to the RTSP client. In the callback function, the application could execute own needed code. The callback function is declared as:

UINT (*nx_rtsp_server_disconnect_callback)(NX_RTSP_CLIENT *rtsp_client_ptr);
Next
Chapter 2 - Installation and use of NetX Duo RTSP Server