GSM-R voice unit real-time voice communication adaptation method and voice unit

By loading the ALSA sound card driver and RTP protocol library in the CIR device, configuring the data buffer and starting the adaptation thread, the problem of inconsistent transmission cycles of sound card and RTP in GSM-R voice communication is solved, real-time voice data adaptation is achieved, and the improvement of improvement of the adaptation of real-time voice data is achieved. Call quality and data integrity.

CN119299439APending Publication Date: 2025-01-10CRSC COMM & INFORMATION
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411347262.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-10

AI Technical Summary

Technical Problem

In the CIR device, during GSM-R voice communication, the sound card hardware interrupt period is inconsistent with the RTP voice transmission interval period, resulting in voice data adaptation problems, which may cause voice loss and affect call quality, and face different sound card and RTP transmission parameters. The difference.

Method used

By loading the ALSA sound card driver and RTP protocol library, configuring the recording and playback data buffers, creating and starting the corresponding thread for voice media stream adaptation, ensuring that the data buffer time and sample number meet the minimum common multiple of the sound card and RTP transmission cycle, and achieving The adaptation process of voice data, including the coordination of recording and playback threads.

Benefits of technology

Real-time and data integrity of GSM-R voice communication within CIR, adapt to different sound card and RTP transmission requirements, avoid voice loss and improve call quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119299439A_ABST
    Figure CN119299439A_ABST
Patent Text Reader

Abstract

The invention relates to a GSM-R voice unit real-time voice communication adaptation method and a voice unit. The adaptation process is as follows: loading a driver, a protocol library and voice software, initializing an RTP session, and configuring a recording data buffer and a playing data buffer; when the GSM-R voice unit enters a call state, a voice recording thread is created and started, an RTP sending thread is created, when recording data buffering meets a certain condition, the RTP sending thread is started, and a voice media stream between the recording thread and the RTP sending thread is adapted through the recording data buffering; and creating and starting an RTP receiving thread, creating a voice playing thread, starting the voice playing thread when the playing data buffer meets a certain condition, and adapting a voice media stream between the RTP receiving thread and the voice playing thread through the playing data buffer. Compared with the prior art, the method can flexibly adapt to voice chips of different sound cards and RTP transmission of different voice services, and meets the requirements of real-time performance and data integrity of CIR internal voice service communication.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of railway digital communication, and in particular to a GSM-R voice unit real-time voice communication adaptation method and a voice unit. Background Art

[0002] With the rapid development of my country's railway wireless dispatching communication technology, CIR, as an important on-board equipment for railway wireless dispatching communication, has been widely used in my country's railway industry. GSM-R voice unit is an important part of CIR equipment, mainly realizing the voice communication function under GSM-R network mode.

[0003] The audio of the GSM-R voice module of the existing CIR communicates with the MMI in the form of analog voice, so there is no problem of voice digitization between the GSM-R voice module and the MMI.

[0004] In order to meet the needs of the development of broadband wireless dispatch communication technology, the CIR device needs to realize the digital transmission of all audio media streams. In the process of digital voice communication, the sound card hardware interrupt cycle may be inconsistent with the RTP voice transmission interval cycle. When performing GSM-R voice communication inside the CIR, if the sound card voice and the RTP transmission voice are not compatible, it will cause voice loss and affect the call quality. In the process of implementing GSM-R voice calls, the software must face the problem that there are many types of sound card chips and their hardware setting parameters may be different; it must also face the problem that the business layer has different requirements for RTP transmission parameters. Therefore, the GSM-R voice software needs to handle the adaptation between the sound card voice and the RTP transmission voice, and avoid voice loss on the basis of ensuring the real-time nature of voice communication. Summary of the invention

[0005] The purpose of the present invention is to overcome the defects of the above-mentioned prior art and provide a GSM-R voice unit real-time voice communication adaptation method and a voice unit.

[0006] The purpose of the present invention can be achieved by the following technical solutions:

[0007] As a first aspect of the present invention, a GSM-R voice unit real-time voice communication adaptation method is provided, the steps comprising:

[0008] Load the ALSA sound card driver, ALSA-LIB library, and GSM-R voice software; load the RTP protocol dynamic library to initialize the RTP session; configure the recording data buffer and the playback data buffer according to the adaptation rules;

[0009] When the GSM-R voice unit enters the call state, a voice recording thread is created and started, an RTP sending thread is created, and when the recording data buffer meets certain conditions, the RTP sending thread is started, and the voice media stream between the recording thread and the RTP sending thread is adapted through the recording data buffer; an RTP receiving thread is created and started, a voice playing thread is created, and when the playing data buffer meets certain conditions, the voice playing thread is started, and the voice media stream between the RTP receiving thread and the voice playing thread is adapted through the playing data buffer;

[0010] When the GSM-R voice unit call ends, the GSM-R voice software main thread will first close the voice recording thread and the RTP receiving thread, and then close the RTP sending thread and the voice playing thread.

[0011] As a preferred technical solution, the parameters of recording data buffer and playback data buffer are set according to the adaptation rule, specifically:

[0012] Hardware interrupt cycle Tp based on ALSA sound card device a And RTP voice transmission interval period Tp r Set the minimum data buffer time, and correspondingly set the minimum number of samples in the data buffer and the minimum amount of audio data in the buffer.

[0013] As a preferred technical solution, the data buffer time Tp c Greater than or equal to the hardware interrupt period Tp of the ALSA sound card device a and RTP voice transmission interval period Tp r The least common multiple of ;

[0014] The number of samples Sc in the data buffer is:

[0015] Sc=Tp c / Ts

[0016] Among them, Tp c is the data buffer time; Ts is the sampling interval of a single sample;

[0017] The amount of audio data in the data buffer is:

[0018] Qt c =Sc*Qs*channels

[0019] Among them, Qs is the number of quantization bits and channels is the number of channels.

[0020] As a preferred technical solution, when the GSM-R voice unit sends a voice media stream, the adaptation process of the voice data is as follows:

[0021] When the voice recording thread is started, the recording data buffer is cleared and the recording device parameters of the ALSA sound card are set through the ALSA-LIB library interface; the voice recording thread is interrupted every hardware interrupt period Tp of the ALSA sound card device. a , remove Qt from the sound card a Audio data is written into the recording data buffer;

[0022] When the recording data buffer reaches the set buffer time, the voice recording thread starts the RTP sending thread; the RTP sending thread starts every RTP voice transmission interval period Tp r Get Qt from the recording data buffer r The audio data is encapsulated into an RTP packet for sending through the sending interface provided by the RTP library.

[0023] As a preferred technical solution, when the GSM-R voice unit receives the sent voice media stream, the voice data adaptation process is as follows:

[0024] When the RTP receiving thread starts, clear the playback data buffer every RTP voice transmission interval period Tp r Receive the RTP packet from the receiving interface provided by the RTP library and extract it from Qt r Audio data is written into the playback data buffer;

[0025] When the recording data buffer reaches the set buffer time, the RTP receiving thread starts the voice playback thread and sets the playback device parameters of the ALSA sound card through the ALSA-LIB library interface; after the voice playback thread is started, the voice playback thread will be interrupted every hardware interrupt period Tp of the ALSA sound card device. a , take out Qt from the playback data buffer a The data is written to the sound card for playback through the ALSA-LIB playback interface.

[0026] As a second aspect of the present invention, a GSM-R voice unit is provided, wherein the voice unit realizes real-time voice communication adaptation by setting a data buffer, specifically comprising:

[0027] ALSA sound card driver and ALSA-LIB library, providing sound card parameter configuration, voice recording, and voice playback interfaces for voice recording threads and voice playback threads to call

[0028] The voice recording thread obtains audio data from the sound card and writes the audio data into the recording data buffer;

[0029] Recording data buffer, used to adapt audio data between voice recording thread and RTP sending thread;

[0030] The RTP sending thread obtains audio data from the recording data buffer and calls the data sending interface of the RTP protocol library to send the audio data;

[0031] The RTP receiving thread calls the data receiving interface of the RTP protocol library to receive audio data and writes the audio data into the playback data buffer;

[0032] Playback data buffer, used to adapt audio data between RTP receiving thread and voice playback thread;

[0033] The voice playback thread obtains audio data from the playback data buffer and writes the audio data to the sound card through the interface provided by the ALSA-LIB library;

[0034] The RTP protocol library provides RTP transmission parameter configuration, RTP audio data sending, and RTP audio data receiving interfaces for RTP sending threads and RTP receiving threads to call.

[0035] As a preferred technical solution, the parameter settings of the recording data buffer and the playback data buffer are specifically as follows:

[0036] Hardware interrupt cycle Tp based on ALSA sound card device a And RTP voice transmission interval period Tp r Set the minimum data buffer time, and correspondingly set the minimum number of samples in the data buffer and the minimum amount of audio data in the buffer.

[0037] As a preferred technical solution, the data buffer time Tp c Greater than or equal to the hardware interrupt period Tp of the ALSA sound card device a and RTP voice transmission interval period Tp r The least common multiple of ;

[0038] The number of samples Sc in the data buffer is:

[0039] Sc=Tp c / Ts

[0040] Among them, Tp c is the data buffer time; Ts is the sampling interval of a single sample;

[0041] The amount of audio data in the data buffer is:

[0042] Qt c =Sc*Qs*channels

[0043] Among them, Qs is the number of quantization bits and channels is the number of channels.

[0044] As a preferred technical solution, when the GSM-R voice unit sends a voice media stream, the adaptation process of the voice data is as follows:

[0045] When the voice recording thread is started, the recording data buffer is cleared and the recording device parameters of the ALSA sound card are set through the ALSA-LIB library interface; the voice recording thread is interrupted every hardware interrupt period Tp of the ALSA sound card device. a , remove Qt from the sound card a Audio data is written into the recording data buffer;

[0046] When the recording data buffer reaches the set buffer time, the voice recording thread starts the RTP sending thread; the RTP sending thread starts every RTP voice transmission interval period Tp r Get Qt from the recording data buffer r The audio data is encapsulated into an RTP packet for sending through the sending interface provided by the RTP library.

[0047] As a preferred technical solution, when the GSM-R voice unit receives the sent voice media stream, the voice data adaptation process is as follows:

[0048] When the RTP receiving thread starts, clear the playback data buffer every RTP voice transmission interval period Tp r Receive the RTP packet from the receiving interface provided by the RTP library and extract it from Qt r Audio data is written into the playback data buffer;

[0049] When the recording data buffer reaches the set buffer time, the RTP receiving thread starts the voice playback thread and sets the playback device parameters of the ALSA sound card through the ALSA-LIB library interface; after the voice playback thread is started, the voice playback thread will be interrupted every hardware interrupt period Tp of the ALSA sound card device. a , take out Qt from the playback data buffer a The data is written to the sound card for playback through the ALSA-LIB playback interface.

[0050] Compared with the prior art, the present invention has the following beneficial effects:

[0051] 1) The present invention proposes a real-time voice communication adaptation solution for GSM-R voice units, which meets the digitalization requirements of GSM-R voice communication services within CIR. Through voice adaptation between ALSA sound card and RTP transmission, the real-time and data integrity requirements of voice service communications within CIR are achieved.

[0052] 2) The buffer of the solution of the present invention can reasonably set the recording data buffer and the playback data buffer through software according to the actual situation of the sound card hardware configuration and the RTP transmission requirements of different voice call services, and flexibly adapt to the voice chips of different sound cards and the RTP transmission of different voice services. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] Figure 1 A schematic diagram of a module adapted for real-time voice communication of a GSM-R voice unit of the present invention;

[0054] Figure 2 The figure is a schematic diagram of the real-time voice communication adaptation process of the GSM-R voice unit of the present invention. DETAILED DESCRIPTION

[0055] The present invention is described in detail below in conjunction with the accompanying drawings and specific embodiments. This embodiment is implemented based on the technical solution of the present invention, and provides a detailed implementation method and specific operation process, but the protection scope of the present invention is not limited to the following embodiments.

[0056] Example 1

[0057] In order to ensure the real-time and integrity of voice calls, the present invention sets a reasonable data buffer in the CIR. When there is a voice call in the GSM-R voice unit, the data of the ALSA sound card and the RTP transmission data are aligned in time beats to achieve adaptation between the voice of the sound card and the RTP transmission voice. The specific adaptation rules and the adaptation implementation process are described as follows.

[0058] 1. Adaptation rules

[0059] (1) Determine the main parameters of voice media streams in GSM-R calls within the CIR

[0060] Within the CIR, the parameters of the GSM-R voice service are defined as: sampling frequency Fs (defined as 8000 Hz in this embodiment), sampling interval of a single sample is Ts=1 / Fs (defined as 0.125 ms in this embodiment), number of channels channels (defined as 1 in this embodiment, i.e., mono), coding (defined as PCM A-law in this embodiment), and number of quantization bits Qs (defined as 1 byte in this embodiment, i.e., 8-bit quantization).

[0061] (2) Determine the main parameters of the ALSA sound card voice media stream

[0062] According to the parameter definition of GSM-R voice service, the voice recording thread / voice playing thread sets the sampling frequency (8000 Hz in this embodiment), the number of channels (defined as 1, i.e., mono) and the voice encoding / decoding mode (PCM A-law in this embodiment) of the sound card recording device, and sets the sound card device to non-blocking mode, and obtains the hardware interrupt period (period) Tp of the ALSA sound card device. a (In this embodiment, the return value of the sound card device is 21.25ms.) Therefore, the number of audio samples corresponding to a single hardware interrupt period (period) of the device is S a =Tp a / Ts (170 in this embodiment), corresponding to the audio data payload data volume Qt a =S a *Qs*channels (170 bytes in this embodiment).

[0063] (3) Determine the main parameters of the RTP voice transmission media stream

[0064] According to the parameter definition of GSM-R voice service, combined with the requirements of RTP standard for PCM A-law transmission, RTP voice transmission interval period (period) Tp r The RTP transmission parameters are mainly load type (PT=8 in this embodiment), time label timestamp (i.e., the number of audio samples in a single RTP voice transmission interval Sr=Tp r / Ts, 160 in this example), audio data payload Qt r =Sr*Qs*channels (160 bytes in this embodiment).

[0065] (4) Determine the data buffer setting rules

[0066] The time corresponding to the data buffer Buff should not be less than the hardware interrupt cycle Tp of the ALSA sound card device a (21.25ms in this example) and RTP voice transmission interval period Tp r The lowest common multiple Tp (20ms in this embodiment) c (340ms in this embodiment), the number of samples corresponding to Buff Sc = Tp c / Ts (2720 in this embodiment), the corresponding Buff buffer audio data size is Qt c =Sc*Qs*channels (2720 bytes in this embodiment).

[0067] 2. GSM-R voice software realizes the adaptation between the voice of the sound card and the voice transmitted by RTP. The description of the implementation process is as follows:

[0068] Step 1. The CIR is turned on or restarted, the GSM-R voice unit is powered on, and the system automatically loads the ALSA sound card driver, ALSA-LIB library, and GSM-R voice software. The GSM-R voice software main thread will allocate the recording data buffer (set to a 3200-byte buffer in this embodiment, slightly larger than 2720 bytes) and the playback data buffer (set to a 3200-byte buffer in this embodiment, slightly larger than 2720 bytes) according to the parameters determined in the adaptation rules; the GSM-R voice software main thread will load the RTP protocol dynamic library and initialize the RTP session according to the main parameters of the RTP voice transmission media stream determined in the adaptation rules.

[0069] Step 2: When the GSM-R voice unit enters the talk state:

[0070] 2a) The main thread of the GSM-R voice software will create and start the voice recording thread and the RTP receiving thread, and create the RTP sending thread and the voice playing thread.

[0071] 2b-1) When the GSM-R voice unit sends a voice media stream to the MMI, the voice data adaptation process is as follows: Figure 2 shown.

[0072] 2b-1-1) When the voice recording thread is started, the recording data buffer is first cleared, and the recording device parameters of the ALSA sound card are set through the ALSA-LIB library interface according to the main parameters of the ALSA sound card voice media stream determined in the adaptation rule. Then, the voice recording thread is interrupted every hardware interrupt period (period) Tp of the ALSA sound card device. a (21.25ms in this embodiment), remove Qt from the sound card a data (170 bytes in this embodiment) are written into the recording data buffer.

[0073] 2b-1-2) When the recording data buffer is larger than 16 TP for the first time a After a period (i.e. 340ms, corresponding to 2720 bytes of buffered data), the voice recording thread starts the RTP sending thread, and the RTP sending thread sends the voice data every RTP voice transmission interval period (period) Tp r (20ms in this embodiment) Take Qt out from the recording data buffer r The audio data is encapsulated into an RTP packet and sent to MMI through the sending interface provided by the RTP library.

[0074] 2b-2) When the GSM-R voice unit receives the voice media stream sent by the MMI, the voice data adaptation process is as follows: Figure 2 shown.

[0075] 2b-2-1) When the RTP receiving thread starts, first clear the playback data buffer, and then every RTP voice transmission interval period (period) Tp r (20ms in this embodiment) receives the RTP packet from the receiving interface provided by the RTP library, and extracts Qt from it r The audio payload data (160 bytes in this example) is written into the playback data buffer.

[0076] 2b-2-2) When the recording data buffer is greater than 17 Tp r After a period (i.e. 340ms, corresponding to 2720 bytes of buffered data), the RTP receiving thread starts the voice playing thread. The voice playing thread sets the playback device parameters of the ALSA sound card through the ALSA-LIB library interface according to the main parameters of the ALSA sound card voice media stream determined in the adaptation rules. After the voice playing thread is started, the voice playing thread will be interrupted every hardware interrupt period (period) Tp of the ALSA sound card device. a (21.25ms in this embodiment), take out Qt from the playback data buffer a Data (170 bytes in this embodiment) are written into the sound card for playback through the ALSA-LIB playback interface.

[0077] Step 3: When the GSM-R voice unit call ends:

[0078] The main thread of the GSM-R voice software will first close the voice recording thread and the RTP receiving thread, and then close the RTP sending thread and the voice playing thread.

[0079] Example 2

[0080] As a second implementation of the present invention, this embodiment also provides a GSM-R voice unit using the method described in the above embodiment. The main GSM-R voice unit functional modules involved in the implementation of this technical solution include: ALSA sound card driver and ALSA-LIB library, voice recording thread, recording data buffer, RTP sending thread, RTP receiving thread, play data buffer, voice play thread, and RTP protocol library. Its components are as follows: Figure 1 shown.

[0081] The ALSA sound card driver and ALSA-LIB library mainly provide interfaces such as sound card parameter configuration, voice recording, and voice playback, which are called by the voice recording thread and voice playback thread.

[0082] The voice recording thread mainly sets the recording parameters of the sound card, obtains audio data from the sound card, and writes the audio data into the recording data buffer through the interface provided by the ALSA-LIB library according to the requirements of the GSM-R voice call service within CIR.

[0083] The recording data buffer is mainly used for adapting audio data between the voice recording thread and the RTP sending thread. The adaptation rules of the recording data buffer need to meet the actual conditions of the sound card hardware and the RTP transmission requirements of the CIR for the GSM-R voice call service.

[0084] The RTP sending thread mainly sets the RTP transport layer parameters based on the requirements of the GSM-R voice call service within CIR through the interface provided by the RTP protocol library. The RTP sending thread obtains audio data from the recording data buffer and calls the data sending interface of the RTP protocol library to send the audio data.

[0085] The RTP receiving thread mainly sets the RTP transport layer parameters through the interface provided by the RTP protocol library according to the requirements of the GSM-R voice call service within the CIR. The RTP receiving thread calls the data receiving interface of the RTP protocol library to receive audio data and writes the audio data into the playback data buffer.

[0086] The playback data buffer is mainly used for the adaptation of audio data between the RTP receiving thread and the voice playback thread. The adaptation rules of the playback data buffer need to meet the actual conditions of the sound card hardware and the RTP transmission requirements of the CIR for the GSM-R voice call service.

[0087] The voice playback thread mainly sets the playback parameters of the sound card through the interface provided by the ALSA-LIB library according to the requirements of the GSM-R voice call service within CIR. The voice playback thread obtains audio data from the playback data buffer and writes the audio data to the sound card through the interface provided by the ALSA-LIB library.

[0088] The RTP protocol library should provide interfaces such as RTP transmission parameter configuration, RTP audio data sending, and RTP audio data receiving for calling by RTP sending thread and RTP receiving thread.

[0089] When the GSM-R voice unit has a voice call, the GSM-R voice software implements the adaptation between the voice of the sound card and the RTP transmission voice. The specific adaptation rules and adaptation implementation process are described in detail in Example 1.

[0090] The preferred specific embodiments of the present invention are described in detail above. It should be understood that a person skilled in the art can make many modifications and changes based on the concept of the present invention without creative work. Therefore, any technical solution that can be obtained by a person skilled in the art through logical analysis, reasoning or limited experiments based on the concept of the present invention on the basis of the prior art should be within the scope of protection determined by the claims.

Claims

1. A method for real-time voice communication adaptation of a GSM-R voice unit, characterized in that the steps include: Load ALSA sound card driver, ALSA-LIB library, and GSM-R voice software; Load the RTP protocol dynamic library to initialize the RTP session; Configure recording data buffer and playback data buffer according to adaptation rules; When the GSM-R voice unit enters the call state, a voice recording thread is created and started, an RTP sending thread is created, and when the recording data buffer meets certain conditions, the RTP sending thread is started, and the voice media stream between the recording thread and the RTP sending thread is adapted through the recording data buffer; an RTP receiving thread is created and started, a voice playing thread is created, and when the playing data buffer meets certain conditions, the voice playing thread is started, and the voice media stream between the RTP receiving thread and the voice playing thread is adapted through the playing data buffer; When the GSM-R voice unit call ends, the GSM-R voice software main thread will first close the voice recording thread and the RTP receiving thread, and then close the RTP sending thread and the voice playing thread.

2. A GSM-R voice unit real-time voice communication adaptation method according to claim 1, characterized in that: The parameters of recording data buffer and playing data buffer are set according to the adaptation rule, specifically: Hardware interrupt cycle Tp based on ALSA sound card device a And RTP voice transmission interval period Tp r Set the minimum time of the data buffer, and set the minimum number of samples in the data buffer and the minimum amount of audio data in the buffer based on the minimum time of the data buffer.

3. A GSM-R voice unit real-time voice communication adaptation method according to claim 2, characterized in that: The data buffer time Tp c Greater than or equal to the hardware interrupt period Tp of the ALSA sound card device a and RTP voice transmission interval period Tp r The least common multiple of ; The number of samples Sc in the data buffer is: Sc=Tpc / Ts Among them, Tp c is the data buffer time; Ts is the sampling interval of a single sample; The amount of audio data in the data buffer is: Qt c =Sc*Qs*channels Among them, Qs is the number of quantization bits and channels is the number of channels.

4. A GSM-R voice unit real-time voice communication adaptation method according to claim 1, characterized in that: When the GSM-R voice unit sends a voice media stream, the adaptation process of the voice data is as follows: When the voice recording thread is started, the recording data buffer is cleared and the recording device parameters of the ALSA sound card are set through the ALSA-LIB library interface; the voice recording thread is interrupted every hardware interrupt period Tp of the ALSA sound card device. a , remove Qt from the sound card a Audio data is written into the recording data buffer; When the recording data buffer reaches the set buffer time, the voice recording thread starts the RTP sending thread; the RTP sending thread starts every RTP voice transmission interval period Tp r Get Qt from the recording data buffer r The audio data is encapsulated into an RTP packet for sending through the sending interface provided by the RTP library.

5. A GSM-R voice unit real-time voice communication adaptation method according to claim 1, characterized in that: When the GSM-R voice unit receives the sent voice media stream, the voice data adaptation process is as follows: When the RTP receiving thread starts, clear the playback data buffer every RTP voice transmission interval period Tp r Receive the RTP packet from the receiving interface provided by the RTP library and extract it from Qt r Audio data is written into the playback data buffer; When the recording data buffer reaches the set buffer time, the RTP receiving thread starts the voice playback thread and sets the playback device parameters of the ALSA sound card through the ALSA-LIB library interface; after the voice playback thread is started, the voice playback thread will be interrupted every hardware interrupt period Tp of the ALSA sound card device. a , take out Qt from the playback data buffer a The data is written to the sound card for playback through the ALSA-LIB playback interface.

6. A GSM-R voice unit, characterized in that: The voice unit realizes real-time voice communication adaptation by setting data buffer, which specifically includes: ALSA sound card driver and ALSA-LIB library, providing sound card parameter configuration, voice recording, and voice playback interfaces for voice recording threads and voice playback threads to call The voice recording thread obtains audio data from the sound card and writes the audio data into the recording data buffer; Recording data buffer, used to adapt audio data between voice recording thread and RTP sending thread; The RTP sending thread obtains audio data from the recording data buffer and calls the data sending interface of the RTP protocol library to send the audio data; The RTP receiving thread calls the data receiving interface of the RTP protocol library to receive audio data and writes the audio data into the playback data buffer; Playback data buffer, used to adapt audio data between RTP receiving thread and voice playback thread; The voice playback thread obtains audio data from the playback data buffer and writes the audio data to the sound card through the interface provided by the ALSA-LIB library; The RTP protocol library provides RTP transmission parameter configuration, RTP audio data sending, and RTP audio data receiving interfaces for RTP sending threads and RTP receiving threads to call.

7. A GSM-R voice unit according to claim 6, characterized in that: The parameter settings of the recording data buffer and the playback data buffer are specifically as follows: Hardware interrupt cycle Tp based on ALSA sound card device a And RTP voice transmission interval period Tp r Set the minimum time of the data buffer, and set the minimum number of samples and the minimum amount of audio data in the data buffer based on the minimum time of the data buffer.

8. A GSM-R voice unit according to claim 7, characterized in that: The data buffer time Tp c Greater than or equal to the hardware interrupt period Tp of the ALSA sound card device a and RTP voice transmission interval period Tp r The least common multiple of ; The number of samples Sc in the data buffer is: Sc=Tpc / Ts Among them, Tp c is the data buffer time; Ts is the sampling interval of a single sample; The amount of audio data in the data buffer is: Qt c =Sc*Qs*channels Among them, Qs is the number of quantization bits and channels is the number of channels.

9. A GSM-R voice unit according to claim 6, characterized in that: When the GSM-R voice unit sends a voice media stream, the adaptation process of the voice data is as follows: When the voice recording thread is started, the recording data buffer is cleared and the recording device parameters of the ALSA sound card are set through the ALSA-LIB library interface; the voice recording thread is interrupted every hardware interrupt period Tp of the ALSA sound card device. a , remove Qt from the sound card a Audio data is written into the recording data buffer; When the recording data buffer reaches the set buffer time, the voice recording thread starts the RTP sending thread; the RTP sending thread starts every RTP voice transmission interval period Tp r Get Qt from the recording data buffer r The audio data is encapsulated into an RTP packet for sending through the sending interface provided by the RTP library.

10. A GSM-R voice unit according to claim 6, characterized in that: When the GSM-R voice unit receives the sent voice media stream, the voice data adaptation process is as follows: When the RTP receiving thread starts, clear the playback data buffer every RTP voice transmission interval period Tp r Receive the RTP packet from the receiving interface provided by the RTP library and extract it from Qt r Audio data is written into the playback data buffer; When the recording data buffer reaches the set buffer time, the RTP receiving thread starts the voice playback thread and sets the playback device parameters of the ALSA sound card through the ALSA-LIB library interface; after the voice playback thread is started, the voice playback thread will be interrupted every hardware interrupt period Tp of the ALSA sound card device. a , take out Qt from the playback data buffer a The data is written to the sound card for playback through the ALSA-LIB playback interface.