Realization of network voice signal transmission with Java

Source: Internet
Author: User

First, the introduction

Java is a language suitable for distributed computing environments, especially for Internet programming. This is not just about the security and portability of Java, but also the fact that Java provides rich network library support for Internet programming. With these network class libraries, you can easily write multiple types of network communication programs. However, due to some restrictions, Java in the transmission of multimedia information is not very wide application, most of the applications are focused on the network to transmit audio signals such as voice. Transmission audio signal applications generally have two kinds, one is applied to the data broadcast of the transmission, for example, audio data server to several clients to send audio data signals, the most widely used is some of the Internet IP Phone, You can often see that many of the Web site to provide online IP telephony services are used by clients are embedded in the Web page Java applet program, used to achieve dial-up, call and so on basic network telephony functions; the second scenario is the part we're going to cover today, the transmission of one-to-one audio signal data. This scheme has a wider range of applications. Everyone has been to the voice chat room, most of the voice chat room to implement the voice chat function is the use of Java technology, the source of such a Web page analysis can be found this point.

I have developed a project involving the use of Java to deliver voice data over a network. Development encountered a lot of problems, and found in the internet about the Java voice transmission of less information, looking for many days, and finally from an open source code of a simple answer Machine demo program to obtain the solution to the problem. Today, I took some of my experience in point-to-point transmission of audio signals to discuss this issue with you.

Ii. the existing problems

The problems of transmitting audio over the network can be summed up as follows:

1 network connection between the two sides

To carry out the transmission of frequency data, the first is to establish data link. In common communication protocols, TCP is more reliable, so it is used in applications that do not allow data loss. And UDP is more applied to the processing speed requirements, data transmission reliability requirements are not very high applications, such as digital broadcasting. The choice of communication protocol depends on the type of application we are going to make. How to establish the network connection, the steady receive and sends the audio signal the data flow is the key.

2 audio signal acquisition and playback

In the acquisition of audio signals we must take into account the problem of sampling rate, the sampling rate of the sound signal has 8Khz, 16Khz, 32Khz, 44Khz, and so on, each data sampling considering the amount of data generated by the same, the higher the sampling rate of data generated by the larger, So we have to choose the right sampling rate to accommodate the bandwidth of the network.

3 Audio digital signal encoding and decoding.

If the directly collected audio signal data stream transmission on the network, it occupies a very large bandwidth, to 8Khz sampling rate to collect 14-bit audio data Then there are the following:

Bit * 8000/second=112,000 Bits/second or112kbps

From this we can see the transmission of audio data in such a way that you need to send 112kb of data to the network every second. So. From the point of view of bandwidth saving, it is necessary for us to compress such data. We have many options for compressing multimedia signals, such as MP2, MP3, GSM, and so on. Again, we have a problem with choosing a compressed format. Considering the timeliness of the audio data transmission, the requirements of the quality of the transmitted audio, the compression ratio of various compression formats and the system resources for compressing and decompressing, it is particularly important to choose the appropriate compression format.

Related Article

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.