Lan audio intercom

Source: Internet
Author: User

Local Area Network Audio intercom involves audio collection, audio playback, network transmission, and other technologies. multi-thread processing is required.

First, two types of data are transmitted in the network, namely command data (signaling) and audio data.

Second, any end of the intercom needs to receive audio data, play the audio at the same time, collect the audio, and send the audio data.

Third, you do not need to process packet loss and sort packets in TCP mode.

4. Call the client to initiate an intercom request and call the client to receive the request as a server.

 

The server opens a listening thread and waits for the client to connect. When the accept in the listening thread returns a valid socket (indicating a successful connection between the client and the server), open a receiving data thread recvthread and processthread for the socket. Recvthread is used to receive audio data and messages sent from the client and store them in the data buffer zone. Processthread reads, analyzes, and processes data from the data buffer zone.

 

If the sender sends 10 times of data, each time it is 1280 bytes, it does not mean that the receiver will receive 10 times, because each time the receiver receives more than 1280 bytes, and, not necessarily an integer multiple of 1280, that is to say, the received data is not a complete package, and the remaining data will be received at the next time. Therefore, you can set a Data Length in a fixed-length header to read the data length in the header to determine how much data needs to be read.

 

Source code: http://download.csdn.net/source/3194636

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.