Live555 client connection and RTSP interaction-network connection processing and RTSP connection module

Source: Internet
Author: User
1 socket creation, binding, listening to the main function main () after it is started, it will be called (dynamicrtspserver: createnew-> rtspserver: setupoursocket setupstreamsocket) in setupstreamsocket, create, bind, listen to, and set non-blocking mode operations on S-end sockets in TCP. The listening port is 854. after the socket-related operations are completed, new dynamicrtspserver (derived from rtspserver) is executed. Therefore, rtspserver: rtspserver is also called and env is executed in it. taskscheduler (). turnonbackgroundreadhandling (fserversocket, (taskscheduler: backgroundhandlerproc *) & incomingconnectionhandler, this) Note: This en V is generated by calling basicusageenvironment: createnew in the main () function. The first function parameter fserversocket is the server listening socket. The second parameter is the rtspserver: incomingconnectionhandler address pointer. In basictaskscheduler: turnonbackgroundreadhandling, The fserversocket is stored in the handlerset * (handlerset * basictaskscheders: freadhandlers) structure. At the same time, the listening socket is placed in freadset, which is used in the select mechanism below. Map the second parameter to Handler-> handlerproc. 2. Prepare for connection execution Code : Env-> taskscheduler (). doeventloop (); The env is the same as the Env in 1. Call: basictaskscheduler0: doeventloop-> basictaskscheduler0: doeventloop. Execute select in the infinite loop of doeventloop to wait for the client to connect. Run the code: int selectresult = select (fmaxnumsockets, & readset, null, null, & TV _timetodelay). The listening socket has been placed in readset. If the client connection is detected, execute: (* Handler-> handlerproc) (Handler-> clientdata, socket_readable); that is, rtspserver: incomingconnectionhandler. In this function, the accept () Client is connected to create rtspclientsession * Note: rtspclientsession encapsulates the RTSP function. 3. The client connection is received and RTSP interaction is completed. envir () is executed in rtspclientsession: rtspclientsession (). taskscheduler (). turnonbackgroundreadhandling (fclientsocket, (taskscheduler: backgroundhandlerproc *) & incomingrequesthandler, this) parameter 1: client socket parameter generated by accept () 2: after receiving and processing the client information, the address pointer of the processing function waits for receiving the information sent from the connected client in addition to listening for new client connections in the singlestep function. Or call incomingrequesthandler (* Handler-> handlerproc) (Handler-> clientdata, socket_readable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.