Freeswitch-based method, system and device for broadcasting ring-back tone by server side by using RTP message, and medium
By using the RTP message monitoring method on the freeswitch platform, the problem of omission of ringback tone broadcast during soft-switch outbound call is solved, 100% broadcast success in complex environments is achieved, and the stability and compatibility of the voice platform are improved.
Patent Information
- Application Number
- CN202411827991.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-12
- Publication Date
- 2025-04-29
AI Technical Summary
In the prior art, when soft-switching outbound calls, the logic of the broadcast ringback tone is complex, resulting in inconsistent SDP messages returned by different operators and devices, resulting in the problem of missing ringback tone for local broadcast ringback tone.
The RTP message monitoring method based on freeswitch is used to construct a table model and monitor the RTP media stream to determine whether there is a legal RTP media stream to return. If not, the local ringback tone will be broadcast.
In complex IMS equipment and different operator environments, ensuring 100% of local ringback tones are broadcast, improving the robustness and compatibility of the voice platform.
Smart Images

Figure CN119906786A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software design, and in particular to a method, system, device and medium for realizing a server-side broadcast of a ringback tone by utilizing an RTP message based on FreeSwitch. Background Art
[0002] When a softswitch makes an outbound call, a ringback tone needs to be broadcast to the A-leg. Currently, the sip protocol 18X message combined with the P-Early-Media field is used to determine whether the server or the terminal broadcasts the ringback tone. However, the processing logic is very complicated. Different operators and different devices return different SDP messages, resulting in the omission of the local broadcast ringback tone. Summary of the invention
[0003] Aiming at the problem that the existing broadcasting method easily causes the omission of the local broadcasting ringback tone, the present invention proposes a method, system, device and medium for realizing the server-side broadcasting ringback tone by using RTP message based on freeswitch; firstly, a table model is constructed according to the record table obtained from the freeswitch voice platform; then an IVR platform is called in and the outgoing phone number is obtained, and a Bleg call is initiated according to the IMS; finally, the RTP media stream is monitored according to the constructed table model to determine whether there is a legitimate RTP media stream returned, and if so, a call is established between the incoming Aleg and the outgoing Bleg, otherwise the local ringback tone is broadcast according to the Aleg; in the case that the other end is a complex IMS device, different operators return different SDP information, and no ringback tone is returned, the local voice platform can broadcast the local ringback tone 100%.
[0004] The specific implementation contents of the present invention are as follows: A method for realizing a server-side broadcast of a ringback tone using an RTP message based on FreeSwitch, specifically comprising the following steps: Step S1: construct a table model according to the record table obtained from the freeswitch voice platform; Step S2: Call the IVR platform and obtain the outbound phone number, and initiate a Bleg call according to the IMS; Step S3: Monitor the RTP media stream according to the constructed table model to determine whether there is a legitimate RTP media stream returned. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, broadcast the local ringback tone according to Aleg.
[0005] In order to better implement the present invention, further, the step S3 specifically includes the following steps: Step S31: monitor the RTP media packet and obtain the media packet from the channel; Step S32: acquiring the RTP media stream triggering RTP event according to the number of acquired RTP media packets; Step S33: judging whether the RTP media stream is legal according to the triggered RTP event; Step S34: Determine whether there is a legitimate RTP media stream returned based on the constructed table model. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, play the local ringback tone based on the Lua script in combination with the triggered RTP event.
[0006] In order to better implement the present invention, further, the step S32 specifically includes the following steps: Step S321: monitor RTP data packets, and when the number of RTP data packets reaches 5, it is determined that the RTP media stream is received; Step S322: calling the rtp_common_read function according to the Freeswitch voice platform to read the RTP media stream, and triggering the RTP event according to the RTP media stream.
[0007] In order to better implement the present invention, further, the specific operation of step S33 is: judging whether the number of RTP media packets is legal, if the RTP media packet is greater than 12 bytes, judging that the RTP media packet is legal.
[0008] In order to better implement the present invention, further, the step S34 specifically includes the following steps: Step S341: Play the ringback tone according to the Lua script and the triggered RTP event; Step S342: according to the received SIP protocol, call the lua script Bleg to broadcast the ringback tone; Step S343: monitor whether the event_channel_rtp event from the current channel of the core layer core is received, and if received, interrupt the main thread of broadcasting the ringback tone.
[0009] In order to better implement the present invention, further, the table model in step S1 includes a call record table cc_callrecord, an operation action table cc_agentaction, and a sign-in table cc_agents.
[0010] Based on the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch, in order to better realize the present invention, further, a system for realizing server-side broadcast ringback tone by using RTP message based on freeswitch is proposed, which is used to execute the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch; it includes a construction unit, a calling unit, and a broadcasting unit; The construction unit is used to construct a table model according to the record table obtained from the freeswitch voice platform; The calling unit is used to call into the IVR platform and obtain the outbound phone number, and initiate a Bleg call according to the IMS; The broadcast unit is used to monitor the RTP media stream according to the constructed table model, and determine whether there is a legitimate RTP media stream returned. If so, a call is established between the incoming Aleg and the outgoing Bleg, otherwise a local ringback tone is broadcast according to Aleg.
[0011] Based on the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch, in order to better realize the present invention, further, an electronic device is proposed, including a memory and a processor; a computer program is stored on the memory; when the computer program is executed on the processor, the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch is realized.
[0012] Based on the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch, in order to better realize the present invention, further, a computer-readable storage medium is proposed, on which computer instructions are stored; when the computer instructions are executed on the above-mentioned electronic device, the above-mentioned method for realizing server-side broadcast ringback tone by using RTP message based on freeswitch is realized.
[0013] The present invention has the following beneficial effects: The present invention uses RTP messages to implement a method for broadcasting a ringback tone at the server end, so that when the other end is a complex IMS device, different operators return different SDP information, and no ringback tone is returned, the local voice platform can 100% broadcast the local ringback tone. When the IMS other side returns an early media ringback tone, the other party's ringback tone can also be broadcast as the ringback tone. The perception of the customer during the call process through the voice platform is effectively improved, and the robustness and compatibility of the voice platform are improved. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 A schematic diagram of a call record table cc_callrecord provided in an embodiment of the present invention.
[0015] Figure 2 A schematic diagram of the operation action table cc_agentaction provided in an embodiment of the present invention.
[0016] Figure 3 A schematic diagram of the sign-in table cc_agents provided in an embodiment of the present invention.
[0017] Figure 4 The present invention provides a flow chart of a conventional three-party call ringback tone broadcasting method.
[0018] Figure 5 The present invention provides a flow chart of a method for broadcasting a ringback tone based on an RTP media stream.
[0019] Figure 6 A schematic diagram of the RTP media stream monitoring algorithm provided by the present invention.
[0020] Figure 7 A schematic diagram of some RTP media stream monitoring codes provided by an embodiment of the present invention.
[0021] Figure 8 A schematic diagram of using a Lua script to cyclically broadcast a ringback tone code after a call is made provided in an embodiment of the present invention.
[0022] Fig. 9 A schematic diagram of the interruption playback code provided by an embodiment of the present invention.
[0023] Fig.10 A schematic diagram of the interrupted playback process provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0024] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. It should be understood that the described embodiments are only part of the embodiments of the present invention, not all of the embodiments, and therefore should not be regarded as limiting the scope of protection. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technical personnel in this field without making creative work are within the scope of protection of the present invention.
[0025] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "disposed", "connected", and "connected" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be an indirect connection through an intermediate medium, or it can be the internal communication of two elements. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0026] The professional terms and English explanations involved in this embodiment are as follows: Freeswitch: FreeSWITCH is an open source telephone soft switch platform that supports real-time audio and video communications and multiple communication protocols such as SIP and WebRTC. FreeSWITCH can be used as a switch engine, PBX, multimedia gateway, and multimedia server, etc. RTP: RTP is a UDP-based network transmission protocol, mainly used to transmit real-time data on the Internet, such as audio, video and other multimedia information. It was originally designed for multicast communication, but is also applicable to unicast sessions. RTP provides timestamps and sequence numbers to help the receiver reassemble data packets from different paths, and provides a mechanism to synchronize multiple media streams.
[0027] Aleg: Freeswitch's A-leg usually refers to the call leg that is established first in a call, which corresponds to the party that actively initiates the call. In a two-party call scenario, according to the order in which the call legs are established, the one that is established first is called A-leg. Bleg: In FreeSWITCH, B-leg refers to the called party in a call, also known as the "bridge leg" or "remote leg". Conversely, the first established session is called A-leg.
[0028] Lua: Lua is a lightweight, efficient, embeddable scripting language. It has the characteristics of being lightweight, efficient, and easy to expand. In this patent, Lua is mainly used as a programming language to control the flow of voice processes.
[0029] Core: The core in this article is the core part of FreeSWITCH communication software, which contains key data structures and complex codes, state machines, databases, etc. Including data processing and storage, the core part (Core) communicates with peripheral modules through clear interfaces. This design makes FreeSWITCH highly scalable and flexible. IMS: IMS stands for IP Multimedia Subsystem, a new form of multimedia services. The IMS architecture is based on the IP protocol and is compatible with existing PSTN and mobile networks. It is the core technology of the next generation network and an important way to solve the integration of mobile and fixed networks and introduce differentiated services such as triple play of voice, data and video.
[0030] SDP: SDP is a standard protocol used to describe information about multimedia communication sessions. This information includes but is not limited to session name, time, contact information of participants, media type (audio, video, etc.), codec information, transport protocol (such as RTP), IP address and port number, etc. The main purpose of SDP is to enable applications to exchange enough information to establish and participate in multimedia sessions.
[0031] IVR: IVR stands for Interactive Voice Response, which is an automated customer service system implemented over a telephone network. The IVR system allows users to interact with the system through the telephone keypad or voice commands to obtain the required information or services.
[0032] Embodiment 1: This embodiment proposes a method for realizing a server-side broadcast of a ringback tone using an RTP message based on FreeSwitch, which specifically includes the following steps: Step S1: construct a table model according to the record table obtained from the freeswitch voice platform.
[0033] The table model in step S1 includes a call record table cc_callrecord, an operation action table cc_agentaction, and a sign-in table cc_agents.
[0034] Step S2: Call the IVR platform and obtain the outbound phone number, and initiate a Bleg call based on the IMS.
[0035] Step S3: Monitor the RTP media stream according to the constructed table model to determine whether there is a legitimate RTP media stream returned. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, broadcast the local ringback tone according to Aleg.
[0036] Furthermore, the step S3 specifically includes the following steps: Step S31: monitor the RTP media packet and obtain the media packet from the channel; Step S32: acquiring the RTP media stream triggering RTP event according to the number of acquired RTP media packets; Furthermore, the step S32 specifically includes the following steps: Step S321: monitor RTP data packets, and when the number of RTP data packets reaches 5, it is determined that the RTP media stream is received; Step S322: calling the rtp_common_read function according to the Freeswitch voice platform to read the RTP media stream, and triggering the RTP event according to the RTP media stream.
[0037] Step S33: judging whether the RTP media stream is legal according to the triggered RTP event; Furthermore, the specific operation of step S33 is: judging whether the number of RTP media packets is legal; if the number of RTP media packets is greater than 12 bytes, judging that the RTP media packets are legal.
[0038] Step S34: Determine whether there is a legitimate RTP media stream returned based on the constructed table model. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, play the local ringback tone based on the Lua script in combination with the triggered RTP event.
[0039] The step S34 specifically includes the following steps: Step S341: Play the ringback tone according to the Lua script and the triggered RTP event; Step S342: according to the received SIP protocol, call the lua script Bleg to broadcast the ringback tone; Step S343: monitor whether the event_channel_rtp event from the current channel of the core layer core is received, and if received, interrupt the main thread of broadcasting the ringback tone.
[0040] Working principle: This embodiment uses RTP messages to implement a method for broadcasting a ringback tone on the server side, so that when the other end is a complex IMS device, different operators return different SDP information, or no ringback tone is returned, the local voice platform can 100% broadcast the local ringback tone. When the IMS other side returns an early media ringback tone, the other party's ringback tone can also be broadcast as the ringback tone. This effectively improves the customer's perception during the call process through the voice platform, and improves the robustness and compatibility of the voice platform.
[0041] Embodiment 2: This embodiment is based on the above embodiment 1. Figure 1 , Figure 2 , Figure 3 , Figure 4 , Figure 5 , Figure 6 , Figure 7 , Figure 8 , Fig. 9 , Fig.10 As shown, a specific embodiment is described in detail.
[0042] This embodiment is based on the method of using RTP real-time transport protocol media stream to realize the server-side broadcast ringback tone based on freeswitch. It can determine whether the server-side broadcasts the ringback tone according to the RTP media data packet. According to the RTP data packet returned by the media server, it detects whether there is an RTP data packet returned according to the dynamic algorithm. The lua process script is used to realize the server-side accurate broadcast of the ringback tone. Figure 1 , Figure 2 , Figure 3 As shown, the table model includes a call record table cc_callrecord, an operation action table cc_agentaction, and a sign-in table cc_agents.
[0043] The table model is mainly based on the table model involved in the call center of freeswitch, such as the incoming call record table cc_callrecord, which is used to record incoming calls. This embodiment is based on the ringback tone broadcast, which is part of the voice platform. Other parts include call management, seat management, etc.
[0044] like Figure 4 As shown in the figure, if Bleg does not return the SDP ringback tone, the Aleg incoming call user will not be able to hear the ringback tone. For the Aleg incoming call user, it is impossible to perceive the current call status. Therefore, a new way to broadcast the ringback tone is needed to solve this problem, such as Figure 5 As shown, an algorithm is used to monitor whether the RTP media stream is returned. If no legal media stream is returned, a local ringback tone is broadcast, so that the Aleg incoming user can perceive the call status.
[0045] In the core part of FreeSwitch, switch_rtp.c, there is a core file for processing RTP media streams. In the rtp_common_read function that reads the RTP media information stream, the media packets received by the current channel are superimposed.
[0046] like Figure 5 The RTP media stream monitoring algorithm shown in the figure, RTP is an application layer based on the UDP protocol, UDP is an unreliable protocol, in order to eliminate non-RTP interference, it is necessary to design an algorithm to monitor whether the current RTP media stream is valid. Figure 6 As shown, the system monitors RTP data packets. When the number of legal RTP data packets reaches 5, the RTP media stream is considered to be received.
[0047] The received RTP media message packet is legal only if it is larger than 12 bytes. A complete RTP data packet includes at least version number (2 bits), padding bit (1 bit), extension bit (1 bit), CSRC counter (4 bits), tag bit (1 bit), load type (7 bits), sequence number (16 bits), timestamp (32 bits), and SSRC (32 bits), a total of 96 bits, which is 12 bytes when converted into bytes.
[0048] The system monitors RTP media packets and will only consider it legitimate if it actually receives 5 RTP media packets from the channel. Generally speaking, it takes about 100ms to receive 5 RTP media packets. This delay is imperceptible to users.
[0049] like Figure 6 As shown, when the current channel receives more than 5 RTP media frames, an RTP event will be triggered.
[0050] Application layer implementation: Freeswitch can use a variety of scripting languages such as JavaScript, Lua, etc. to control the flow of the process. In the actual process, this embodiment uses Lua script combined with RTP triggered events to play the ringback tone.
[0051] like Figure 7 As shown, after the call is made, the Lua script is used to loop the ringback tone, such as Figure 8 As shown in the code, after receiving the 180 of the SIP protocol after the call is made, the Lua script starts to broadcast an audio file to B-leg. The content of the audio file is the ringback tone received by the user after the call is made. This avoids the problem of no audio broadcast before the session is connected.
[0052] like Fig. 9 As shown in the figure, when the Lua script layer receives the signal sent by the core kernel layer, it interrupts the sound playback. When the user hears the customized ringback tone, another background thread is also listening to whether it receives the event_channel_rtp event from the current channel of the core layer. When this event_channel_rtp event is received, the sound playback will be stopped.
[0053] like Fig.10 As shown, broadcasting the ringback tone and monitoring the RTP events from the core are parallel, so that the RTP media stream information can be received in a timely manner.
[0054] After receiving the 180 signal from the SIP protocol after the call is made, the Lua script starts to broadcast an audio file to B-leg. The content of the audio file is the ringback tone received by the user after the call is made. This avoids the problem of no audio broadcast before the session is connected.
[0055] When the user listens to the customized ringback tone, another thread in the background is also listening to whether it receives the event_channel_rtp event from the current channel of the core layer core. When this event_channel_rtp event is received, the sound will be stopped.
[0056] The other parts of this embodiment are the same as those of the above-mentioned embodiment 1, and thus will not be described in detail.
[0057] Embodiment 3: Based on any one of the above-mentioned embodiments 1 to 2, this embodiment proposes a system for realizing server-side broadcasting of ringback tone by using RTP message based on freeswitch, which is used to execute the above-mentioned method for realizing server-side broadcasting of ringback tone by using RTP message based on freeswitch; it includes a construction unit, a calling unit, and a broadcasting unit; The construction unit is used to construct a table model according to the record table obtained from the freeswitch voice platform; The calling unit is used to call into the IVR platform and obtain the outbound phone number, and initiate a Bleg call according to the IMS; The broadcast unit is used to monitor the RTP media stream according to the constructed table model, and determine whether there is a legitimate RTP media stream returned. If so, a call is established between the incoming Aleg and the outgoing Bleg, otherwise a local ringback tone is broadcast according to Aleg.
[0058] This embodiment also proposes an electronic device, including a memory and a processor; the memory stores a computer program; when the computer program is executed on the processor, the above-mentioned method of using RTP messages based on freeswitch to realize the server broadcasting ringback tone is implemented.
[0059] This embodiment also proposes a computer-readable storage medium, on which computer instructions are stored; when the computer instructions are executed on the above-mentioned electronic device, the above-mentioned method of using RTP messages based on freeswitch to realize the server broadcasting ringback tone is implemented.
[0060] The other parts of this embodiment are the same as any one of the above-mentioned embodiments 1-2, so they will not be repeated here.
[0061] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. Any simple modification or equivalent change made to the above embodiment based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A method for realizing a server-side broadcast of a ringback tone using an RTP message based on freeswitch, characterized in that: The specific steps include: Step S1: construct a table model according to the record table obtained from the freeswitch voice platform; Step S2: Call the IVR platform and obtain the outbound phone number, and initiate a Bleg call according to the IMS; Step S3: Monitor the RTP media stream according to the constructed table model to determine whether there is a legitimate RTP media stream returned. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, broadcast the local ringback tone according to Aleg.
2. According to claim 1, a method for realizing a server-side broadcast ringback tone using RTP messages based on freeswitch, characterized in that: The step S3 specifically comprises the following steps: Step S31: monitor the RTP media packet and obtain the media packet from the channel; Step S32: acquiring the RTP media stream triggering RTP event according to the number of acquired RTP media packets; Step S33: judging whether the RTP media stream is legal according to the triggered RTP event; Step S34: Determine whether there is a legitimate RTP media stream returned based on the constructed table model. If so, establish a call between the incoming Aleg and the outgoing Bleg. Otherwise, play the local ringback tone based on the Lua script in combination with the triggered RTP event.
3. According to claim 2, a method for realizing a server-side broadcast ringback tone using RTP messages based on freeswitch, characterized in that: The step S32 specifically includes the following steps: Step S321: monitor RTP data packets, and when the number of RTP data packets reaches 5, it is determined that the RTP media stream is received; Step S322: calling the rtp_common_read function according to the Freeswitch voice platform to read the RTP media stream, and triggering the RTP event according to the RTP media stream.
4. According to claim 2, a method for realizing a server-side broadcast ringback tone using RTP messages based on freeswitch, characterized in that: The specific operation of step S33 is: judging whether the number of RTP media packets is legal; if the RTP media packet is larger than 12 bytes, judging that the RTP media packet is legal.
5. According to a method for realizing a server-side broadcast ringback tone using RTP messages based on freeswitch according to claim 3, it is characterized in that: The step S34 specifically includes the following steps: Step S341: Play the ringback tone according to the Lua script and the triggered RTP event; Step S342: according to the received SIP protocol, call the lua script Bleg to broadcast the ringback tone; Step S343: monitor whether the event_channel_rtp event from the current channel of the core layer core is received, and if received, interrupt the main thread of broadcasting the ringback tone.
6. A method for realizing a server-side broadcast ringback tone using RTP messages based on freeswitch according to claim 1, characterized in that: The table model in step S1 includes a call record table cc_callrecord, an operation action table cc_agentaction, and a sign-in table cc_agents.
7. A system for realizing server-side broadcasting of ringback tone by using RTP message based on freeswitch, used for executing the method for realizing server-side broadcasting of ringback tone by using RTP message based on freeswitch as claimed in claim 1; characterized in that, It includes construction unit, calling unit and broadcasting unit; The construction unit is used to construct a table model according to the record table obtained from the freeswitch voice platform; The calling unit is used to call into the IVR platform and obtain the outbound phone number, and initiate a Bleg call according to the IMS; The broadcast unit is used to monitor the RTP media stream according to the constructed table model, and determine whether there is a legitimate RTP media stream returned. If so, a call is established between the incoming Aleg and the outgoing Bleg, otherwise a local ringback tone is broadcast according to Aleg.
8. An electronic device, characterized in that: It comprises a memory and a processor; a computer program is stored in the memory; when the computer program is executed on the processor, the method for realizing the server broadcasting ringback tone based on freeswitch using RTP message as described in any one of claims 1-6 is implemented.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions; when the computer instructions are executed on the electronic device as described in claim 8, the method of using RTP messages based on freeswitch to realize the server broadcasting ringback tone as described in any one of claims 1-6 is implemented.