Data transmission method and device, electronic equipment and readable storage medium

By simultaneously establishing Wi-Fi and Bluetooth connections between the phone and the speaker and adaptively switching transmission paths, the audio stuttering problem caused by poor Wi-Fi communication quality is solved, achieving smooth and high-quality audio playback and improving the user experience.

CN115915481BActive Publication Date: 2025-12-09HUAWEI TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111166561.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-30
Publication Date
2025-12-09
Estimated Expiration
2041-09-30

AI Technical Summary

Technical Problem

In existing technologies, poor communication quality when a mobile phone and a speaker are connected via Wi-Fi causes audio playback to stutter. Users need to manually switch to Bluetooth connection to ensure smooth audio playback, but this is complicated and cannot restore high-quality audio in a timely manner.

Method used

By establishing Wi-Fi and Bluetooth connections simultaneously between the mobile phone and the speaker, and adaptively switching audio transmission paths based on communication quality, the system ensures smooth and high-quality audio playback. It also employs data replication and identification management mechanisms to reduce switching latency.

Benefits of technology

It enables automatic switching of transmission paths in interference environments, ensuring smooth and high-quality audio playback, improving user experience, and avoiding the complexity of manual operation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115915481B_ABST
    Figure CN115915481B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide a data transmission method and device, electronic equipment and readable storage medium. A first device and a second device have established a first wireless channel and a second wireless channel. The first wireless channel and the second wireless channel are Bluetooth channels or Wi-Fi channels. The first wireless channel and the second wireless channel are different. In the method, the first device sends first audio data to the second device through the first wireless channel. If it is determined according to a target parameter that a target channel for data transmission is the second wireless channel, the first device sends second audio data to the second device through the second wireless channel. The target parameter is related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device and the running mode of the second device. In the embodiments of the present application, the first device can switch the target channel, so that the user can enjoy high-quality audio under the premise of ensuring the smoothness of audio played by the second device.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the communication technology, and in particular, to a data transmission method and device, electronic equipment and readable storage medium. BACKGROUND

[0002] The mobile phone can be connected with the sound box through Bluetooth and Wi-Fi. When the mobile phone is connected with the sound box through Bluetooth, the mobile phone can send audio data to the sound box through the Bluetooth channel between the mobile phone and the sound box, so that the sound box plays audio based on the audio data. When the mobile phone is connected with the sound box through Wi-Fi, the mobile phone can send audio data to the sound box through the Wi-Fi channel between the mobile phone and the sound box, so that the sound box plays audio based on the audio data.

[0003] At present, when the mobile phone makes the sound box play audio through the Wi-Fi channel between the mobile phone and the sound box, if the communication quality of the Wi-Fi channel is poor, it will cause the audio to be played with lag. The user needs to manually close the Wi-Fi connection between the mobile phone and the sound box, establish a Bluetooth connection between the mobile phone and the sound box, and the mobile phone can control the sound box to play audio based on the Bluetooth channel between the mobile phone and the sound box. However, the control method in the prior art is complicated to operate. SUMMARY

[0004] Embodiments of the present application provide a data transmission method and device, electronic equipment and readable storage medium. The electronic equipment can automatically switch the channel for transmitting audio data, so that the user can enjoy high-quality audio on the premise of ensuring the smoothness of the second device playing audio.

[0005] In a first aspect, embodiments of the present application provide a data transmission method. The execution subject of the method can be a first device or a chip in the first device. The following is described by taking the first device as an example. In the method, the first device and a second device have established a first wireless channel and a second wireless channel. The first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is a Bluetooth channel or a Wi-Fi channel, and the first wireless channel and the second wireless channel are different. The first device can play audio through the second device.

[0006] In the method, the first device can send first audio data to the second device through the first wireless channel. The first audio data is used for the second device to play first audio, that is, the second device can play the first audio based on the first audio data in response to receiving the first audio data. If the first device determines that the target channel for data transmission is the second wireless channel according to a target parameter, the first device sends second audio data to the second device through the second wireless channel.

[0007] The target parameter is related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the operation mode of the first device, and the operation mode of the second device, and the second audio data is used for the second device to play second audio. The first device can determine the target channel for data transmission as the second wireless channel according to the target parameter, which can be referred to the related description below.

[0008] In the embodiments of the present application, when the first device plays audio through the second device, the first device can switch the channel for transmitting audio data according to the target parameter, which can ensure that the user can enjoy high-definition audio while ensuring the fluency of audio playing in an interference environment, avoiding audio lag, and improving the user experience.

[0009] In a possible implementation, the first device can detect whether the first audio data has been completely transmitted through the first wireless channel before transmitting the second audio data to the second device through the second wireless channel. The first device transmits the second audio data to the second device through the second wireless channel in response to detecting that the first audio data has been completely transmitted through the first wireless channel.

[0010] In a possible implementation, in order to reduce the time delay of audio playing caused by channel switching, the first device can copy the second audio data twice to obtain first data and second data, and mark the first data and the second data with the same identifier. The first device transmits the first data to the second device through the first wireless channel and transmits the second data to the second device through the second wireless channel.

[0011] In this implementation, the second device can send information to the first device to stop using the first wireless channel in response to receiving the first data and the second data with the same identifier from the first device through the two wireless channels. In addition, the second device can play the second audio based on the data from the second wireless channel.

[0012] Correspondingly, the first device can transmit third audio data to the second device through the second wireless channel in response to receiving the information to stop using the first wireless channel. The second device can play the third audio in response to receiving the third audio data.

[0013] The following describes that the first device determines the target channel as the second wireless channel according to the target parameter:

[0014] First, the target parameter is related to the communication quality of the first wireless channel.

[0015] If the first device determines, according to the target parameter, that the communication quality of the first wireless channel is less than or equal to the preset communication quality of the first wireless channel, the first device determines that the target channel is the second wireless channel.

[0016] The parameter for representing the communication quality of the first wireless channel can include, but is not limited to, a packet error rate, a throughput rate, etc. of the first wireless channel. For example, when the throughput rate of the first wireless channel is less than a first preset throughput rate, it can be determined that the communication quality of the first wireless channel is less than or equal to a preset communication quality of the first wireless channel, i.e., the first preset throughput rate represents the preset communication quality of the first wireless channel.

[0017] Secondly, the target parameter is related to the communication quality of the first wireless channel and the communication quality of the second wireless channel.

[0018] If the first device determines, according to the target parameter, that the communication quality of the first wireless channel is less than or equal to a preset communication quality of the first wireless channel, and the communication quality of the second wireless channel is greater than or equal to a preset communication quality of the second wireless channel, the target channel is determined to be the second wireless channel.

[0019] For example, when the throughput rate of the first wireless channel is less than a first preset throughput rate, it can be determined that the communication quality of the first wireless channel is less than or equal to a preset communication quality of the first wireless channel. At this time, the first device further needs to detect whether the throughput rate of the second wireless channel is greater than or equal to a second preset throughput rate. When the throughput rate of the second wireless channel is greater than or equal to the second preset throughput rate, it represents that the communication quality of the second wireless channel is greater than or equal to a preset communication quality of the second wireless channel. Then, the first device can determine that the communication quality of the first wireless channel is poor, but the communication quality of the second wireless channel is good, and thus the target channel is determined to be the second wireless channel.

[0020] Thirdly, the target parameter is related to the running mode of the first device and the running mode of the second device.

[0021] When the first wireless channel is a Wi-Fi channel, if the first device detects that the running mode of the first device and / or the second device enters a low-power mode, the target channel is determined to be a Bluetooth channel, and the Bluetooth channel is the second wireless channel. When the first wireless channel is a Bluetooth channel, if it is detected that the devices switched to the low-power mode have all exited the low-power mode, the target channel is determined to be a Wi-Fi channel, and the Wi-Fi channel is the second wireless channel. Alternatively,

[0022] In an embodiment, the target parameter is related to the running mode of the first device. When the first wireless channel is a Wi-Fi channel, if the first device detects that the running mode of the first device enters a low-power mode, the target channel is determined to be a Bluetooth channel, and the Bluetooth channel is the second wireless channel. Alternatively,

[0023] In an embodiment, the target parameter is related to an operation mode of the second device, and when the first wireless channel is a Wi-Fi channel, if the first device detects that the operation mode of the second device enters a low-power mode, the first device determines that the target channel is a Bluetooth channel, and the Bluetooth channel is the second wireless channel.

[0024] In an embodiment, the target parameter is related to an operation mode of the second device, and when the first wireless channel is a Wi-Fi channel, if the first device detects that the operation mode of the second device enters a low-power mode, the first device determines that the target channel is a Bluetooth channel, and the Bluetooth channel is the second wireless channel.

[0025] When the first wireless channel is a Wi-Fi channel, if the first device detects that the operation mode of the first device enters a low-power mode, the first device determines that the target channel is a Bluetooth channel, and the first device further needs to detect whether the communication quality of the second wireless channel is greater than or equal to a preset communication quality of the second wireless channel, and if the communication quality of the second wireless channel is greater than or equal to the preset communication quality of the second wireless channel, the first device can determine that the target channel is the Bluetooth channel.

[0026] In an embodiment, the target parameter is further related to a type of the second audio data. In this embodiment, the second audio data and the first audio data can be data in different audio.

[0027] In an embodiment, the target parameter is further related to a type of the second audio data. In this embodiment, the second audio data and the first audio data can be data in different audio.

[0028] In an embodiment, the preset type can be high-definition audio, and the non-preset type can be non-high-definition audio.

[0029] In an embodiment, the target parameter is further related to a type of the second audio data. In this embodiment, the second audio data and the first audio data can be data in different audio.

[0030] In an embodiment, the target parameter is further related to a type of the second audio data. In this embodiment, the second audio data and the first audio data can be data in different audio.

[0031] In an embodiment, before the first device transmits the first audio data to the second device through the first wireless channel, the target channel for transmitting the first audio data can be determined as the first wireless channel based on the target parameter. For details, refer to the description of the first device determining the target channel as the second wireless channel based on the target parameter.

[0032] In a second aspect, an embodiment of the present application provides a data transmission method. The execution subject of the method can be the second device or a chip in the second device. The following description takes the second device as an example. In the method, the second device can receive the first audio data from the first device through the first wireless channel, and play the first audio based on the first audio data. The second device can receive the second audio data from the first device through the second wireless channel, and play the second audio based on the second audio data.

[0033] In a third aspect, an embodiment of the present application provides a data transmission method. The execution subject of the method can be the first device or a chip in the first device. The following description takes the first device as an example. In the method, the first device can duplicate the first audio data into two parts, i.e., the first data and the second data, and the first audio data is used for the second device to play the first audio.

[0034] The first device can mark the first data and the second data with the same identifier, and transmit the first data to the second device through the first wireless channel, and transmit the second data to the second device through the second wireless channel.

[0035] In a fourth aspect, an embodiment of the present application provides a data transmission method. The execution subject of the method can be the second device or a chip in the second device. The following description takes the second device as an example. In the method, the second device can store the first data from the Wi-Fi channel in a cache area of the second device in response to receiving the first data and the second data with the same identifier from the first device, and play the first audio based on the first data in the cache area. Because the audio data from the Wi-Fi channel is uncoded data, the user can enjoy high-definition audio.

[0036] In a possible implementation, if the quality of the Wi-Fi channel deteriorates, causing the amount of audio data in the cache area of the second device to gradually decrease, in order to ensure the fluency of audio playing, the second device can store the audio data from the Bluetooth channel in the cache area of the second device after decoding the audio data from the Bluetooth channel in response to the amount of audio data in the cache area of the second device being less than a waterline value.

[0037] In a possible implementation, to ensure the smoothness of the audio data playing, the second device can store the audio data from the first wireless channel into the buffer of the second device and discard the audio data from the second wireless channel, according to the first identifier of the audio data from the first wireless channel and the second identifier of the audio data from the second wireless channel, if the first identifier is not included in the buffer of the second device and the second identifier is included in the buffer of the second device. In this way, the second device can store the audio data from the channel which is received first by the second device into the buffer of the second device preferentially, to play, and the smoothness of the audio data playing can be ensured. It should be understood that the first identifier and the second identifier can be the same or different, when the first identifier and the second identifier are the same, the second device can store the audio data from the Wi-Fi channel into the buffer of the second device and discard the audio data from the Bluetooth channel.

[0038] In a fifth aspect, an embodiment of the present application provides a data transmission apparatus, comprising:

[0039] The first fusion management module is configured to:

[0040] The first fusion management module is configured to:

[0041] If the target channel for data transmission is determined to be the second wireless channel according to a target parameter, the second fusion management module is configured to send second audio data to the second device through the second wireless channel, the target parameter being related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device, and the running mode of the second device, the second audio data being used for the second device to play second audio.

[0042] In a possible implementation, the first fusion management module is further configured to detect whether the first audio data has been sent through the first wireless channel completely, and in response to detecting that the first audio data has been sent through the first wireless channel completely, send the second audio data to the second device through the second wireless channel.

[0043] In a possible implementation, the target parameter is related to the communication quality of the first wireless channel.

[0044] The first fusion management module is specifically configured to determine that the target channel is the second wireless channel, if the communication quality of the first wireless channel is determined to be less than or equal to a preset communication quality of the first wireless channel according to the target parameter.

[0045] In a possible implementation, the target parameter is related to the communication quality of the first wireless channel and the communication quality of the second wireless channel.

[0046] The first fusion management module is specifically configured to determine the target channel as the second wireless channel if it is determined according to the target parameter that the communication quality of the first wireless channel is less than or equal to the preset communication quality of the first wireless channel, and the communication quality of the second wireless channel is greater than or equal to the preset communication quality of the second wireless channel.

[0047] In a possible implementation, the target parameter is related to the running mode of the first device and the running mode of the second device.

[0048] The first fusion management module is specifically configured to:

[0049] When the first wireless channel is a Wi-Fi channel, if it is detected that the running mode of the first device and / or the second device enters a low-power consumption mode, the target channel is determined as a Bluetooth channel, and the Bluetooth channel is the second wireless channel.

[0050] In a possible implementation, the first fusion management module is further configured to copy the second audio data twice to obtain first data and second data, mark the first data and the second data with the same identifier, and send the first data to the second device through the first wireless channel and send the second data to the second device through the second wireless channel.

[0051] In a possible implementation, the first fusion management module is further configured to, in response to receiving information from the second device that the first wireless channel is stopped from being used, send third audio data to the second device through the second wireless channel, where the third audio data is used for the second device to play third audio.

[0052] In a possible implementation, the first fusion management module is further configured to determine, according to the target parameter, that the target channel for transmitting the first audio data is the first wireless channel.

[0053] In a possible implementation, the target parameter is related to the type of the first audio data, and the first wireless channel is a Wi-Fi channel.

[0054] The first fusion management module is further configured to:

[0055] Based on the target parameter, if it is determined that the type of the first audio data is a preset type, the target channel for transmitting the first audio data is determined as the Wi-Fi channel, and the preset type has a mapping relationship with the Wi-Fi channel.

[0056] Based on the target parameter, if it is determined that the type of the first audio data is a non-pre-set type, it is determined that the target channel for transmitting the first audio data is the Bluetooth channel, the non-pre-set type has a mapping relationship with the Bluetooth channel.

[0057] In a sixth aspect, an embodiment of the present application provides a data transmission device, comprising:

[0058] A second fusion management module is configured to receive first audio data from the first device through the first wireless channel.

[0059] A player is configured to play first audio based on the first audio data.

[0060] The second fusion management module is further configured to receive second audio data from the first device through the second wireless channel.

[0061] The player is further configured to play second audio based on the second audio data.

[0062] In a possible implementation, the second fusion management module is specifically configured to receive first data from the first device through the first wireless channel and receive second data from the first device through the second wireless channel, the first data and the second data are obtained by copying the second audio data into two parts by the first device, and the first data and the second data have the same identifier.

[0063] The second fusion management module is further configured to send information for stopping using the first wireless channel to the first device.

[0064] In a possible implementation, the second fusion management module is further configured to receive third audio data from the first device through the second wireless channel.

[0065] The player is further configured to play third audio based on the third audio data.

[0066] In a seventh aspect, an embodiment of the present application provides a data transmission device, comprising:

[0067] A first fusion management module is configured to copy first audio data into two parts, i.e., first data and second data, mark the first data and the second data with the same identifier, and send the first data to the second device through the first wireless channel and send the second data to the second device through the second wireless channel, the first audio data being used for the second device to play first audio.

[0068] In an eighth aspect, an embodiment of the present application provides a data transmission apparatus, comprising:

[0069] A second fusion management module is configured to receive first data from the first wireless channel and second data from the second wireless channel, the first data and the second data being obtained by duplicating first audio data by the first device, and store the first data in a cache.

[0070] A player is configured to play the first audio based on the first data in the cache.

[0071] In a possible implementation, the second fusion management module is further configured to store data from the second wireless channel in the cache after decoding processing, if an amount of audio data in the cache is less than a preset amount, the second wireless channel being a Bluetooth channel.

[0072] The player is further configured to play the audio based on the decoded data in the cache.

[0073] In a possible implementation, the second fusion management module is further configured to, according to a first identifier of the audio data from the first wireless channel and a second identifier of the audio data from the second wireless channel, store the audio data from the first wireless channel in the cache and discard the audio data from the second wireless channel, if the first identifier is not included in the cache and the second identifier is included in the cache.

[0074] In a ninth aspect, an embodiment of the present application provides an electronic device, which is the first device or the second device. The electronic device can include a processor, a memory, a Bluetooth controller, and a Wi-Fi controller. The memory is configured to store computer executable program codes, and the program codes include instructions. When the processor executes the instructions, the instructions cause the electronic device to perform the method in the first aspect to the fourth aspect.

[0075] In a tenth aspect, an embodiment of the present application provides an electronic device, which can be the first device or the second device. The electronic device can include units, modules or circuits configured to perform the method provided in the first aspect to the fourth aspect.

[0076] In an eleventh aspect, an embodiment of the present application provides a computer program product including instructions, which, when executed on a computer, cause the computer to perform the method in the first aspect to the fourth aspect.

[0077] In a twelfth aspect, the embodiments of the present application provide a computer readable storage medium, wherein instructions are stored in the computer readable storage medium, and when the instructions are executed on a computer, the computer is caused to perform the method in the first aspect to the fourth aspect.

[0078] The implementation manners of the second aspect to the twelfth aspect have the beneficial effects of the first aspect, which will not be repeated here. BRIEF DESCRIPTION OF DRAWINGS

[0079] Figure 1 A scenario for which the embodiments of the present application are applicable;

[0080] Figure 2 An audio broadcast diagram for which the embodiments of the present application are applicable;

[0081] Figure 3A An interaction diagram of the first device and the second device provided by the embodiments of the present application;

[0082] Figure 3B Another interaction diagram of the first device and the second device provided by the embodiments of the present application;

[0083] Figure 4 A process diagram of the first device and the second device establishing a Bluetooth channel provided by the embodiments of the present application;

[0084] Figure 5 A process diagram of the first device and the second device establishing a Wi-Fi channel provided by the embodiments of the present application;

[0085] Figure 6 A flow diagram of one embodiment of the data transmission method provided by the embodiments of the present application;

[0086] Figure 7 A flow diagram of another embodiment of the data transmission method provided by the embodiments of the present application;

[0087] Figure 8 A diagram of data transmission provided by the embodiments of the present application;

[0088] Figure 9 A flow diagram of another embodiment of the data transmission method provided by the embodiments of the present application;

[0089] Figure 10 Another diagram of data transmission provided by the embodiments of the present application;

[0090] Figure 11 A flow diagram of another embodiment of the data transmission method provided by the embodiments of the present application;

[0091] Figure 12Another schematic diagram of data transmission provided for an embodiment of the present application;

[0092] Figure 13 Another schematic diagram of data transmission provided for an embodiment of the present application;

[0093] Figure 14 Another schematic diagram of data transmission provided for an embodiment of the present application;

[0094] Figure 15 Another schematic diagram of data transmission provided for an embodiment of the present application;

[0095] Figure 16 Another schematic diagram of data transmission provided for an embodiment of the present application; DETAILED DESCRIPTION

[0096] Figure 1 Another schematic diagram of data transmission provided for an embodiment of the present application; Figure 1 The scenario includes a first device and a second device, Figure 1 In an embodiment, the first device is a mobile phone and the second device is a sound box. The first device can be wirelessly connected to the second device, and the first device can play audio through the second device. For example, the first device can be connected to the second device through Bluetooth, the first device can transmit audio data to the second device through the Bluetooth channel between the first device and the second device, and the second device can play audio based on the audio data from the first device.

[0097] In an embodiment, the first device supports Bluetooth connection and Wi-Fi connection with the second device. The first device can transmit audio data to the second device through the Bluetooth channel between the first device and the second device, and the second device can play audio based on the audio data. The first device can also transmit audio data to the second device through the Wi-Fi channel between the first device and the second device, and the second device can also play audio based on the audio data. It should be understood that the bandwidth of the Wi-Fi channel is greater than that of the Bluetooth channel, so when the first device and the second device are connected by Wi-Fi, the first device can send audio data of lossless audio, 5.1 surround sound, 7.1 surround sound, etc. to the second device, and the second device can play lossless audio, 5.1 surround sound, 7.1 surround sound, etc. (hereinafter, lossless audio is taken as an example for description). When the first device and the second device are connected by Bluetooth, because the bandwidth of the Bluetooth channel is limited, the first device can encode the audio data and send it to the second device, and the second device can play the encoded audio.

[0098] It should be understood that the first device in the embodiments of the present application can include, but is not limited to, a mobile phone, a tablet computer (PAD), a smart screen, a handheld device with a wireless communication function, a computing device, a vehicle-mounted device, or a wearable device, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in a smart home, and the like. The second device can include, but is not limited to, a mobile phone, a PAD, a smart screen, a headset, a handheld device with a wireless communication function, a vehicle-mounted device, or a wearable device, a VR terminal device, an AR terminal device, a wireless terminal in industrial control, a wireless terminal in a smart home, and the like, and an electronic device with an audio playing function. The forms of the first device and the second device are not specifically limited in the embodiments of the present application.

[0099] Figure 2 An existing audio playing diagram is shown in FIG. 1a. Referring to FIG. 1a, the first device is connected to the second device via Wi-Fi, and is not connected to the second device via Bluetooth. The first device can send audio data to the second device via a Wi-Fi channel, and correspondingly, the second device can play lossless audio. Figure 2 In FIG. 1a, the lossless audio is represented by the number "123". Figure 2 When the Wi-Fi connection between the first device and the second device is interfered, that is, the communication quality of the Wi-Fi channel is poor, the audio data transmitted via the Wi-Fi channel will be lost, causing the audio playing of the second device to be stuck. Referring to FIG. 1b, it should be understood that Figure 2 In FIG. 1b, the lossless audio is represented by the numbers "4, 5, and 8", and the second device playing audio is stuck, as represented by the ellipsis, that is, the numbers "6 and 7" are not played. Figure 2

[0100] When the user perceives that the audio playing of the second device is stuck, the user can manually disconnect the Wi-Fi connection between the first device and the second device, and connect the first device and the second device via Bluetooth. After the first device and the second device are connected via Bluetooth, the first device can send audio data to the second device via a Bluetooth channel, and correspondingly, the second device can play encoded audio from the Bluetooth channel. Referring to FIG. 1c, the encoded audio is represented by the number "90". Figure 2 Figure 2 It should be understood that the process of the user manually disconnecting the Wi-Fi connection and connecting the first device and the second device via Bluetooth is not shown in FIG. 1c, and can be described in the prior art.

[0101] ​​When the first device and the second device are connected via Bluetooth, the audio heard by the user is encoded audio, which is lossy audio. The user cannot perceive whether the communication quality of the Wi-Fi channel has improved, and thus cannot manually connect the first device and the second device via the Wi-Fi channel at an appropriate time, and thus the user cannot enjoy lossless audio.

[0102] To address the above problems, the first device and the second device can be simultaneously connected via Wi-Fi and Bluetooth. If the first device can adaptively switch the channel for transmitting audio data according to the communication quality of the Wi-Fi channel and the communication quality of the Bluetooth channel, the smoothness of audio playing can be ensured, and the user can enjoy lossless audio in a timely manner, and the user experience can be improved. Accordingly, an embodiment of the present application provides a data transmission method. Under the premise that the first device is simultaneously connected to the second device via Wi-Fi and Bluetooth, the first device can adaptively switch the channel for transmitting audio data based on the communication quality of the Wi-Fi channel and the communication quality of the Bluetooth channel, so as to improve the user experience.

[0103] The first device plays audio via the second device is an example, and in an embodiment, the first device can also display a file via the second device. In this embodiment, the first device can send file data to the second device, and the second device can display the file on the interface of the second device in response to receiving the file data. The embodiments of the present application do not limit the service performed by the first device via the second device, that is, do not limit the type of data sent by the first device to the second device.

[0104] It should be understood that the following embodiments are described by taking the first device and the second device as being simultaneously connected via Bluetooth and Wi-Fi, and the first device playing audio via the second device as an example.

[0105] Before introducing the data transmission method provided by the embodiments of the present application, the structure of the first device and the second device will be described first. Referring to Figure 3A and Figure 3B , Figure 3B for Figure 3A detailed schematic diagram.

[0106] In an embodiment, the first device includes a host central processing unit (Host CPU) and a wireless chip. The first Bluetooth controller and the first Wi-Fi controller can be integrated on the wireless chip. In an embodiment, the first Bluetooth controller (may be referred to as the first BT controller or the first BT controller) and the first Wi-Fi controller (may be referred to as the first Wi-Fi controller) can be independently set up, Figure 3B In an embodiment, the first Bluetooth controller and the first Wi-Fi controller are integrated on the wireless chip.

[0107] In an embodiment, the Host CPU can include an application processor (AP), an audio framework (Audio FWK), an advanced audio distribution profile hardware abstraction layer (A2DP audioHAL), A2DP and audio / video distribution transport protocol (A2DP and AVDTP), a first fusion management module, a Quality of Service (QoS) module, a logical link control and adaptation protocol (L2CAP) module, and a kernel layer. The kernel layer includes a first transmission control protocol / internet protocol (TCP / IP) module. It should be understood that the A2DP and AVDTP can include an A2DP module and an AVDTP module.

[0108] The AP can include at least one application package of an application (APP), and the application can include but is not limited to a camera, a gallery, a calendar, a call, a map, a navigation, a Bluetooth, a music, a video, a short message, etc. Figure 3B In an embodiment, an audio class application related to audio playback, a telephone application, and a video class application are shown.

[0109] An audio FWK is configured to decode audio data from an application, and perform resampling, mixing, etc. on the decoded audio data, and send the processed audio data to an A2DP audio HAL.

[0110] The A2DP audio HAL is configured to buffer audio data. For example, the A2DP audio HAL can buffer the audio data in a buffer of the A2DP audio HAL.

[0111] When the audio data is transmitted through a Bluetooth channel between the first device and the second device, an A2DP module is configured to read the audio data from the buffer of the A2DP audio HAL, and encode the audio data to obtain encoded data (hereinafter referred to as encoded data), and the A2DP module can transmit the encoded data to an AVDTP module.

[0112] The AVDTP module is configured to transmit the encoded data to a first L2CAP module.

[0113] A QoS module is configured to obtain a communication quality of the Bluetooth channel and a communication quality of the Wi-Fi channel.

[0114] A first fusion management module is configured to select a transmission path of the audio data based on a type of the audio data, and / or a parameter obtained by the QoS module, such as the communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel. For details, refer to the description of the following Figure 6

[0115] The first L2CAP module is configured to manage distribution of the audio data, so as to implement transmission of the audio data through the Bluetooth channel or the Wi-Fi channel.

[0116] In an embodiment, the first L2CAP module can send the audio data to the first BT controller. In an embodiment, the first L2CAP module can send the audio data to the first BT controller through a first host controller interface (HCI). The first HCI is located between a Host CPU and a wireless chip, and is configured to implement data transmission between the Host CPU and the wireless chip. Part of the first HCI is located in the Host CPU, and part of the first HCI is located in the wireless chip Controller. Figure 3B

[0117] ​​When the audio data is transmitted through the Wi-Fi channel between the first device and the second device, the first L2CAP module can read the audio data from the A2DP audio HAL and send the audio data to the first Wi-Fi controller through the first TCP / IP module.

[0118] The first TCP / IP module is further configured to assist the first device and the second device to establish a Wi-Fi based transport layer data channel.

[0119] In an embodiment, the first A2DP and AVDTP, the first L2CAP module, and the first TCP / IP module can be referred to as a connection management module.

[0120] In an embodiment, the second device comprises a host central processing unit (Host CPU), a second BT controller, a second Wi-Fi controller, a codec module, and a player. In an embodiment, the second BT controller and the second Wi-Fi controller can also be integrated on a chip. Figure 3B In an embodiment, the second BT controller and the second Wi-Fi controller are independently arranged.

[0121] The codec module is configured to decode the audio data and send the decoded audio data to the player.

[0122] The player is configured to play the audio.

[0123] The Host CPU in the second device comprises a second L2CAP module and a second TCP / IP module.

[0124] The second L2CAP module is configured to send the received audio data to the codec module so that the codec module decodes the received audio data.

[0125] The second TCP / IP module is configured to assist the first device and the second device to establish a Wi-Fi based transport layer data channel.

[0126] In an embodiment, the Host CPU in the second device can further comprise a second fusion management module. The second fusion management module is configured to construct and maintain a buffer for buffering the audio data. For details, refer to the related description in Figures 11-13

[0127] It should be understood that the above brief description of the modules in the first device and the second device can refer to the following detailed description. Figure 6 ​The descriptions in the document and the existing technical descriptions of each module will not be repeated here. It should be noted that... Figure 3A and Figure 3B In the diagram below, dashed lines represent audio data transmitted via Wi-Fi, and solid lines represent audio data transmitted via Bluetooth.

[0128] exist Figure 3A and Figure 3B Based on the structures of the first and second devices shown, the following will be combined with... Figure 4 This document briefly describes the process of establishing Bluetooth and Wi-Fi pathways between the first and second devices. It should be understood that a Bluetooth pathway may include a Bluetooth access layer link and a corresponding L2CAP channel. A Wi-Fi pathway may include a Wi-Fi access layer link, a socket connection, and a corresponding L2CAP channel.

[0129] Taking a mobile phone as the first device and a speaker as the second device as an example, refer to... Figure 4 The process of establishing a Bluetooth path between the first device and the second device may include:

[0130] Step 1: The user turns on the Bluetooth function of both their mobile phone and the speaker.

[0131] Step 2: Scan the speaker's logo with your phone. The user then operates on the phone or speaker to connect the phone and speaker via Bluetooth.

[0132] During step 2, the mobile phone and the speaker can establish a Bluetooth access layer link.

[0133] Then, the AVDTP module in the mobile phone can send a command to the first L2CAP module to establish an L2CAP channel for the corresponding Bluetooth path. The first L2CAP module responds to the command to establish an L2CAP channel, which is used to transmit data from the AVDTP module.

[0134] Reference Figure 5 The process of establishing a Wi-Fi connection between the first device and the second device may include:

[0135] Step 1a: Based on the peer-to-peer (P2P) protocol, the mobile phone acts as the GO (group owner), sending parameters such as username, password, and encryption method to the speaker via Bluetooth message.

[0136] Step 2a: The speaker acts as a GC (group client), joining the P2P network of the mobile GO using the "username, password, and encryption method" parameters from Step 1a above.

[0137] In an embodiment, step 1a can be replaced by step 1b: based on a peer to peer (P2P) protocol, the sound box acts as a group owner (GO), and sends parameters such as a username, a password, and an encryption mode to the mobile phone through a Bluetooth message. Similarly, step 2a can be replaced by step 2b: the mobile phone acts as a group client (GC), and joins the P2P network of the sound box GO by using the parameters such as the username, the password, and the encryption mode in step 1b.

[0138] During steps 2a and 2b, the mobile phone and the sound box can sequentially establish a Wi-Fi access layer link and a socket connection between the first TCP / IP module and the second TCP / IP module.

[0139] Then, the first fusion management module in the mobile phone can send an instruction to the first L2CAP module to establish an L2CAP channel corresponding to the Wi-Fi channel, and the first L2CAP module establishes the L2CAP channel in response to the instruction, where the L2CAP channel is used to map the TCP / IP connection (socket connection) between the mobile phone and the sound box.

[0140] On the basis of Figure 4 and Figure 5 , the first device and the second device have established a Bluetooth channel and a Wi-Fi channel. The data transmission method provided by the embodiments of the present application will be described below in conjunction with specific embodiments. The following embodiments can be combined with each other, and the same or similar concepts or processes can not be described in some embodiments.

[0141] Figure 6 A flowchart of an embodiment of the data transmission method provided by the embodiments of the present application. Referring to Figure 6 , the data transmission method provided by the embodiments of the present application can include:

[0142] S601, the application program sends audio data to the A2DP audio HAL through the Audio FWK in response to receiving an instruction to play audio.

[0143] After the first device and the second device have established a Bluetooth channel and a Wi-Fi channel, the user can operate the first device to control the second device to play audio. For example, the user can open an audio application in the first device and select audio A to control the second device to play audio A.

[0144] The application program, in response to detecting a user inputted instruction to play audio, can acquire the audio data locally if the first device has stored the audio data locally, or download the audio data from a server corresponding to the audio application program if the first device has not stored the audio data. The embodiments of the present application do not repeat the process of the application program acquiring the audio data.

[0145] The application program can send the audio data to the A2DP audio HAL through the Audio FWK. In an embodiment, the application program can send the audio data to the Audio FWK, and the Audio FWK can decode, resample, and mix the audio data, and send the processed audio data to the A2DP audio HAL. The decoding manner of the Audio FWK on the audio data can include, but is not limited to, pulse code modulation (PCM) or free lossless audio codec. In the following embodiments, the audio data decoded by the Audio FWK is taken as an example of PCM audio data, and accordingly, the Audio FWK can send the PCM audio data to the A2DP audio HAL.

[0146] S602, the A2DP audio HAL buffers the audio data.

[0147] In an embodiment, the A2DP audio HAL buffers the PCM audio data, for example, the A2DP audio HAL can buffer the PCM audio data in a buffer of the A2DP audio HAL.

[0148] S603, the first fusion management module determines a target path for transmitting the audio data according to a target parameter.

[0149] The target parameter can be related to any one of the following: a type of the audio data, and / or a communication quality of the Bluetooth path, and / or a communication quality of the Wi-Fi path, a running mode of the first device, and a running mode of the second device. In the embodiments of the present application, the target path can be the Bluetooth path and / or the Wi-Fi path.

[0150] In an embodiment, the type of the audio data can include high-definition (high-quality) audio and non-high-definition (non-high-quality) audio. The high-definition audio can satisfy, for example, condition 1 or condition 2:

[0151] Condition 1: the sampling rate is greater than or equal to 48KHz, the bit width is greater than or equal to 24bit, and the channel is greater than or equal to 2.

[0152] Condition 2: Sampling rate greater than or equal to 96KHz, bit width greater than or equal to 16bit and less than 24bit, and number of channels greater than or equal to 2.

[0153] It should be understood that the bit width in conditions 1 and 2 is a parameter used to measure the changes in sound fluctuations in audio. The larger the bit width value, the better the resolution of the audio, that is, the higher the sampling frequency of the Audio FWK.

[0154] It should be understood that when Audio FWK sends PCM audio data to A2DP audio HAL, it can also send audio parameters of the PCM audio data to A2DP audio HAL. These audio parameters include the sampling rate, bit width, and number of channels. In response to receiving the audio parameters of the PCM audio data, A2DP audio HAL can send these parameters to the first fusion management module. In this way, the first fusion management module can obtain the audio parameters of the PCM audio data, namely the audio sampling rate, bit width, and number of channels, and then determine the type of audio data based on these parameters.

[0155] In one embodiment, such as Figure 3B As shown, the Host CPU includes a QoS module, which is used to obtain the communication quality of the Bluetooth channel and the Wi-Fi channel. Therefore, the first fusion management module can read the "communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel" from the QoS module. The communication quality of the Bluetooth channel can be characterized by at least one of the following parameters: packet error rate (PER) and throughput. It should be understood that a lower packet error rate indicates better communication quality of the Bluetooth channel, and a higher throughput indicates better communication quality of the Bluetooth channel. Similarly, the communication quality of the Wi-Fi channel can be characterized by at least one of the following parameters: packet error rate (PER) and throughput. It should be understood that the communication quality of the Bluetooth channel and the Wi-Fi channel can also be characterized by other parameters, and this embodiment does not limit this.

[0156] The first fusion management module determines the target path based on the target parameters, as shown below:

[0157] In one embodiment, the first fusion management module can determine the target path based on the type of audio data. Specifically, when the audio data type is high-definition audio, the first fusion management module can determine the target path to be a Wi-Fi path. When the audio data type is non-high-definition audio, the first fusion management module can determine the target path to be a Bluetooth path.

[0158] It can be understood that the high-definition audio can be taken as a preset type, which has a mapping relationship with the Wi-Fi channel. Therefore, the first fusion management module can determine that the target channel is the Wi-Fi channel in response to the type of the audio data being high-definition audio. Similarly, the first fusion management module can determine that the target channel is the Bluetooth channel in response to the type of the audio data being non-high-definition audio (i.e., a non-preset type), which has a mapping relationship with the Bluetooth channel. It should be understood that the preset type can be other predefined types of audio, and the embodiments of the present application do not limit this. The above is described by taking the high-definition audio as an example of the preset type of audio data. Or,

[0159] The first fusion management module can determine the target channel according to the communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel. For example, the first fusion management module can determine that the target channel is the Wi-Fi channel when it detects that the packet error rate of the Bluetooth channel is greater than or equal to a first preset packet error rate and the packet error rate of the Wi-Fi channel is less than a second preset packet error rate. The first preset packet error rate can be the same as the second preset packet error rate, or the first preset packet error rate can be greater than the second preset packet error rate. Similarly, the first fusion management module can determine that the target channel is the Bluetooth channel when it detects that the packet error rate of the Wi-Fi channel is greater than or equal to the first preset packet error rate and the packet error rate of the Bluetooth channel is less than the second preset packet error rate. It should be understood that the packet error rate of the Bluetooth channel being greater than or equal to the first preset packet error rate can be used to represent that the communication quality of the Bluetooth channel is greater than or equal to the preset communication quality of the Bluetooth channel, that is, when the packet error rate is used to represent the communication quality, the first preset packet error rate is used to represent the preset communication quality of the Bluetooth channel. The packet error rate of the Wi-Fi channel being less than the second preset packet error rate can be used to represent that the communication quality of the Wi-Fi channel is less than the preset communication quality of the Wi-Fi channel, that is, when the packet error rate is used to represent the communication quality, the second preset packet error rate is used to represent the preset communication quality of the Wi-Fi channel. It should be noted that the first preset packet error rate and the second preset packet error rate are both preset values. Or,

[0160] In an embodiment, the first fusion management module can determine the target channel according to the communication quality of the Wi-Fi channel. For example, the first fusion management module can determine that the target channel is the Wi-Fi channel when it detects that the packet error rate of the Wi-Fi channel is less than the second preset packet error rate. Or, the first fusion management module can determine the target channel according to the communication quality of the Bluetooth channel. For example, the first fusion management module can determine that the target channel is the Bluetooth channel when it detects that the packet error rate of the Bluetooth channel is less than the second preset packet error rate. Or,

[0161] In an embodiment, the first fusion management module can determine the target path according to the type of the audio data, and the communication quality of the Bluetooth path and the communication quality of the Wi-Fi path. For example, in terms of the packet error rate, the first fusion management module can determine that the to-be-selected path is the Wi-Fi path in response to the type of the audio data being high-definition audio, and determine that the target path is the Wi-Fi path if the packet error rate of the Wi-Fi path is less than a second preset packet error rate. Similarly, the first fusion management module can determine that the to-be-selected path is the Bluetooth path in response to the type of the audio data being non-high-definition audio, and determine that the target path is the Bluetooth path if the packet error rate of the Bluetooth path is less than the second preset packet error rate.

[0162] In an embodiment, the first fusion management module can determine that the target path is the Bluetooth path if the operating mode of the first device and / or the operating mode of the second device is switched to the low-power consumption mode. That is, the first fusion management module can determine that the target path is the Bluetooth path if at least one of the first device and the second device is switched to the low-power consumption mode. It should be noted that when the second device is switched to the low-power consumption mode, the second device can send information to the first device, and the information is used to indicate that the operating mode of the second device is the low-power consumption mode. The first device can determine that the second device enters the low-power consumption mode in response to receiving the information.

[0163] For example, when the first device and / or the second device enters the low-power consumption mode, the first device transmits the audio data through the Bluetooth path. In an embodiment, when the first device enters the low-power consumption mode, the first Wi-Fi controller in the first device is in a sleep state, and when the second device enters the low-power consumption mode, the second Wi-Fi controller in the second device is in a sleep state.

[0164] Correspondingly, if the device in the low-power consumption mode exits the low-power consumption mode, the first device can determine that the target path is the Wi-Fi path. For example, the devices in the low-power consumption mode are the first device and the second device, and the first device can determine that the target path is the Wi-Fi path in response to detecting that the first device and the second device both exit the low-power consumption mode.

[0165] S604, in response to the target path being the Bluetooth path, the first fusion management module sends an encoding instruction to the A2DP module.

[0166] When the first fusion management module determines that the target path is the Bluetooth path, the first fusion management module sends an encoding instruction to the A2DP module, and the encoding instruction is used to instruct the A2DP module to read the audio data from the A2DP audio HAL and encode the audio data.

[0167] In an embodiment, the first fusion management module can synchronize the target channel to the first L2CAP module in response to the target channel being a Bluetooth channel. The first fusion management module can synchronize the target channel to the first L2CAP module by sending an identifier of the target channel to the first L2CAP module. For example, the identifier of the Bluetooth channel is 1, and the identifier of the Wi-Fi channel is 2. The first fusion management module can send the identifier 1 to the first L2CAP module to synchronize the target channel to the Bluetooth channel.

[0168] In S605, the A2DP module reads the audio data from the A2DP audio HAL, encodes the audio data, and obtains encoded data in response to receiving the encoding instruction.

[0169] The A2DP module reads the audio data (i.e., PCM audio data) from the A2DP audio HAL, encodes the PCM audio data, and obtains encoded data in response to receiving the encoding instruction. It should be understood that the encoded data can be understood as data obtained by encoding the PCM audio data.

[0170] In an embodiment, the A2DP module can encode the PCM audio data by using sub-band coding (SBC) or advanced audio coding (ACC), but the embodiments of the present application are not limited thereto.

[0171] In S606, the A2DP module sends the encoded data to the AVDTP module.

[0172] In S607, the AVDTP module sends the encoded data to the first L2CAP module.

[0173] In S608, the first L2CAP module sends the encoded data to the first BT controller.

[0174] In an embodiment, the data from the AVDTP module is encoded data. Therefore, the first L2CAP module can determine to send the encoded data through the Bluetooth channel in response to receiving the encoded data from the AVDTP module. Accordingly, the first L2CAP module can send the encoded data to the first BT controller through the first HCI in response to receiving the encoded data from the AVDTP module.

[0175] In an embodiment, since the first L2CAP module can receive the target channel synchronized from the first convergence management module, and the first L2CAP module receives the encoded data from the AVDTP module, the first L2CAP module can determine that the target channel is a Bluetooth channel, and the first L2CAP module can send the encoded data to the first BT controller through the first HCI in response to receiving the encoded data from the AVDTP module.

[0176] S609, the first BT controller sends the encoded data to the second BT controller.

[0177] It should be understood that after the first BT controller receives the encoded data from the first L2CAP module, the first BT controller can convert the encoded data into a radio frequency signal for transmission. The embodiments of the present application do not make any further description on the processing process of the encoded data by the first BT controller, and the processing process of the data by the first BT controller in the prior art can be referred to.

[0178] S610, the second BT controller sends the encoded data to the second L2CAP module in response to the encoded data from the first BT controller.

[0179] In an embodiment, the second BT controller sends the encoded data to the second L2CAP module through the second HCI in response to the encoded data from the first BT controller.

[0180] The second BT controller can receive the encoded data from the first BT controller. For example, the second BT controller can convert the radio frequency signal into the encoded data in response to receiving the radio frequency signal from the first BT controller. The second BT controller can send the encoded data to the second L2CAP module through the second HCI.

[0181] S611, the second L2CAP module sends the encoded data to the codec module.

[0182] S612, the codec module decodes the encoded data to obtain audio data.

[0183] In an embodiment, the codec module can decode the encoded data to obtain PCM audio data.

[0184] S613, the codec module sends the audio data to the player.

[0185] In an embodiment, "S604-S613" and "S614-S619" can be steps performed alternatively, or in an embodiment, "S604-S613" and "S614-S619" can be steps performed simultaneously, which can be referred to the description below. Figure 9 and Figure 11 .

[0186] S614, in response to the target channel being a Wi-Fi channel, the first convergence management module synchronizes the target channel being a Wi-Fi channel to the first L2CAP module.

[0187] In an embodiment, the first convergence management module can synchronize the target channel to the first L2CAP module by sending an identification of the target channel to the first L2CAP module. For example, the identification of a Bluetooth channel is 1, and the identification of a Wi-Fi channel is 2. The first convergence management module can send the identification 2 to the first L2CAP module to synchronize the target channel being a Wi-Fi channel to the first L2CAP module.

[0188] S615, the first L2CAP module reads audio data from the A2DP audio HAL.

[0189] In an embodiment, the first L2CAP module can determine the target channel being a Wi-Fi channel in response to receiving the identification of the target channel, such as 2, from the first convergence management module, and then the first L2CAP module can read PCM audio data from the A2DP audio HAL.

[0190] S616, the first L2CAP module sends the audio data to the first Wi-Fi controller through the first TCP / IP module.

[0191] S617, the first Wi-Fi controller sends the audio data to the second Wi-Fi controller.

[0192] It should be understood that the first Wi-Fi controller can convert the PCM audio data into a radio frequency signal for transmission after receiving the PCM audio data from the first L2CAP module. The embodiment of the present application does not make a detailed description of the process of the first Wi-Fi controller processing the PCM audio data, and the process of the first Wi-Fi controller processing data in the prior art can be referred to.

[0193] S618, the second Wi-Fi controller sends the audio data to the second L2CAP module through the second TCP / IP module in response to the audio data from the first Wi-Fi controller.

[0194] The second Wi-Fi controller can receive the PCM audio data from the first Wi-Fi controller. For example, the second Wi-Fi controller can convert the radio frequency signal into the PCM audio data in response to the radio frequency signal from the first Wi-Fi controller. The second Wi-Fi controller can send the PCM audio data to the second L2CAP module via the second TCP / IP module.

[0195] S619, the second L2CAP module sends the audio data to the player.

[0196] As described above, after "S604-S613" or "S614-S619", the method can further include:

[0197] S620, the player plays the audio based on the audio data.

[0198] The player can play the audio based on the PCM audio data in S620. The process can refer to the process of playing the audio by the player in the prior art, and the embodiments of the present application will not be described here.

[0199] It should be understood that the audio data described in S601-S620 in the embodiments of the present application can be referred to as first audio data or second audio data transmitted after the target path is determined. The player plays the audio based on the audio data in S620 can be understood as: the electronic device plays the first audio or the second audio based on the first audio data or the second audio data.

[0200] In the embodiments of the present application, when the first device plays the audio through the second device, the first fusion management module in the first device can determine the target path for transmitting the audio data according to the target parameter. When the communication quality of the Wi-Fi path is good, the first device can send the PCM audio data to the second device through the Wi-Fi path, so that the second device can play high-definition audio. When the communication quality of the Wi-Fi path is poor, the first device can send the encoded data to the second device through the Bluetooth path to ensure that the second device plays the audio without lag. In this way, the first device in the embodiments of the present application can switch the path for transmitting the audio data according to the target parameter, which can ensure that the user can enjoy high-definition audio while ensuring the fluency of audio playing in an interference environment and avoiding audio lag, thereby improving the user experience.

[0201] The process that the first device transmits the audio data through the target channel is further described below. It should be understood that the first device can switch between the Bluetooth channel and the Wi-Fi channel according to the target parameter, and the specific process can refer to the related description of the following embodiments.

[0202] One of them:

[0203] In an embodiment, assuming that the first device transmits the audio data by using the first wireless channel, and the first fusion management module determines that the target channel is the second wireless channel according to the target parameter, the first device can switch the channel for transmitting the audio data from the first wireless channel to the second wireless channel, and then transmit the audio data by using the second wireless channel. Wherein, the first wireless channel can be a Bluetooth channel or a Wi-Fi channel, when the first wireless channel is a Bluetooth channel, the second wireless channel is a Wi-Fi channel, when the first wireless channel is a Wi-Fi channel, the second wireless channel is a Bluetooth channel.

[0204] For example, when the first wireless channel is a Bluetooth channel, after S608, if the first fusion management module executes S603 to determine that the target channel is a Wi-Fi channel, refer to Figure 7 The following steps can be performed:

[0205] S701, the first fusion management module synchronizes the first L2CAP module that the target channel is a Wi-Fi channel, and sends stop sending information to the first L2CAP module.

[0206] The first fusion management module synchronizes the first L2CAP module that the target channel is a Wi-Fi channel, which can refer to the related description in S614. In the embodiment of the application, when the first fusion management module synchronizes the first L2CAP module that the target channel is a Wi-Fi channel, it can also send stop sending information to the first L2CAP module.

[0207] S702, the first L2CAP module sends stop sending information to the first BT controller.

[0208] The stop sending information is used to instruct the first BT controller to feed back completion information to the first L2CAP module after the encoding data from the first L2CAP module is sent.

[0209] S703, the first BT controller feeds back completion information to the first L2CAP module in response to receiving the stop sending information when the encoding data is sent.

[0210] Assuming the data sent by the first device through the Bluetooth channel is first audio data, the encoded data sent by the first BT controller in S703 can be referred to as first audio data. Assuming the data sent by the first device through the Bluetooth channel is second audio data, the encoded data sent by the first BT controller in S703 can be referred to as second audio data. It should be understood that the data sent before the first device switches the target channel becomes first audio data, and the data sent after the channel is switched becomes second audio data.

[0211] The first BT controller can continue to send the encoded data received from the first L2CAP module in response to receiving the stop sending information, and feed back completion information to the first L2CAP module when the sending of the encoded data is completed.

[0212] S704, the first L2CAP module feeds back completion information to the first fusion management module.

[0213] S705, the first L2CAP module executes S615-S619 and S620 in response to receiving the completion information.

[0214] It should be understood that the audio data in "S615-S619 and S620" executed again by the first L2CAP module in the embodiments of the present application can be referred to as second audio data. It should be noted that the first audio data and the second audio data can belong to different parts of the same audio or belong to different audios.

[0215] For example, S701-S705 can be referred to as shown in Figure 8 Figure 8 The first L2CAP module sends audio data through the Bluetooth channel, as shown in a of Figure 8 The process of interaction among the first L2CAP module, the first fusion management module and the first BT controller, i.e. the process of switching the channel for transmitting audio data from the Bluetooth channel to the Wi-Fi channel by the first L2CAP module, is shown in b of Figure 8 The first L2CAP module sends audio data through the Wi-Fi channel, as shown in c of Figure 8 The modules shown in Figure 3B are part of the modules shown in

[0216] Similarly, for example, when the first wireless channel is a Wi-Fi channel, after S616 as above, if the first fusion management module executes S603 to determine that the target channel is a Bluetooth channel, the following steps can be executed:

[0217] ​S701A, the first fusion management module synchronizes the target channel to be a Bluetooth channel to the first L2CAP module, and sends stop sending information to the first L2CAP module.

[0218] S701A can refer to the description in S701.

[0219] S702A, the first L2CAP module sends stop sending information to the first Wi-Fi controller.

[0220] The stop sending information is used to instruct the first Wi-Fi controller to feed back completion information to the first L2CAP module after sending the PCM audio data from the first L2CAP module is completed.

[0221] S703A, the first Wi-Fi controller feeds back completion information to the first L2CAP module after sending the PCM audio data in response to receiving the stop sending information.

[0222] The first Wi-Fi controller can continue to send the PCM audio data received from the first L2CAP module in response to receiving the stop sending information, and feeds back completion information to the first L2CAP module after the sending of the PCM audio data is completed.

[0223] S704A, the first L2CAP module feeds back completion information to the first fusion management module.

[0224] S705A, the first L2CAP module executes S604-S613 and S620 in response to receiving the completion information.

[0225] In the embodiments of the present application, when the first L2CAP module determines to switch the channel to transmit audio data, it can send stop sending information to the controller corresponding to the first wireless channel currently in use, so that the controller corresponding to the first wireless channel feeds back completion information to the first L2CAP module after sending the audio data from the first L2CAP module is completed, and the first L2CAP module can use the second wireless channel to transmit data in response to receiving the completion information, so as to realize the switching of the wireless channel.

[0226] In the first of the above, when the first L2CAP module transmits audio data through the switching channel, because the first L2CAP module needs to send data through the target channel after the first Wi-Fi controller or the first BT controller finishes sending data, it will cause a long time between the audio data transmitted by the first wireless channel and the audio data transmitted by the second wireless channel, resulting in a pause in the second device playing and a poor user experience. In the embodiments of the present application, the problem can be solved by the method in the second of the above (i.e. Figure 9 ) to reduce the time delay of audio playing caused by channel switching:

[0227] The second of the above:

[0228] In an embodiment, for example, when the first wireless channel is a Bluetooth channel, after S608, if the first fusion management module performs S603 to determine that the target channel is a Wi-Fi channel, referring to Figure 9 , the following steps can be performed:

[0229] S901, the first fusion management module obtains audio data from the A2DP audio HAL.

[0230] The first fusion management module can obtain audio data from the buffer of the A2DP audio HAL.

[0231] S902, the first fusion management module copies the audio data into two copies, and identifies the audio data, and the two copies of the audio data have the same identification.

[0232] The first fusion management module copies the audio data obtained from the A2DP audio HAL into two copies, which are the first audio data and the second audio data. The first fusion management module can identify the first audio data and the second audio data, and the identification of the first audio data and the identification of the second audio data are the same. For example, the first fusion management module can number the first audio data and the second audio data, such as SN1, and the first fusion management module can obtain two audio data numbered SN1.

[0233] Assuming that the data sent by the first device through the Bluetooth channel is the first audio data, in an embodiment, the audio data obtained by the first fusion management module from the A2DP audio HAL can be referred to as the second audio data.

[0234] S903, for one of the audio data, perform “S604, S605A, S606-S610”, and for one of the audio data, perform “S614, S615A, S616-S618”.

[0235] S605A, the A2DP module reads the audio data from the first fusion management module in response to receiving the encoding instruction, encodes the audio data to obtain encoded data.

[0236] In the execution of "S604, S605A, S606-S610" on one of the audio data, the first fusion management module can send the identifier of the audio data to the A2DP module, and the A2DP module encodes the audio data without encoding the identifier of the audio data to obtain encoded data, and the identifier of the encoded data is the identifier of the audio data.

[0237] S615A, the first L2CAP module reads the audio data from the first fusion management module.

[0238] Different from S605 described above, because the first fusion management module duplicates the audio data in the A2DP audio HAL into two, the A2DP module in S605A needs to obtain data from the first fusion management module. Similarly, different from S615 described above, the first L2CAP module in S615A needs to obtain data from the first fusion management module.

[0239] In the execution of "S614, S615A, S616-S618" on one of the audio data, the first fusion management module can send the identifier of the audio data to the first L2CAP module, and the first L2CAP module reads the audio data from the first fusion management module, and the identifier of the audio data is the identifier of the audio data from the first fusion management module.

[0240] For example, for the first audio data numbered SN1, "S604, S605A, S606-S610" can be executed, and for the second audio data numbered SN1, "S614, S615A, S616-S618" can be executed. In this way, the second L2CAP module can receive two audio data with the same number. It should be understood that, Figure 9 The specific process of "S604, S605A, S606-S610" and "S614, S615A, S616-S618" is not shown in the embodiment, and can be referred to the related description in the above embodiment.

[0241] S904, the second L2CAP module sends the information with the same identifier to the second fusion management module in response to receiving the audio data with the same identifier.

[0242] The second L2CAP module can receive audio data from the second BT controller and the second Wi-Fi controller respectively, and thus when the second L2CAP module receives audio data with the same identification, it can determine that the first device is sending audio data through the Wi-Fi channel, and based on the identification of the audio data, it can determine that the audio data is continuous and non-packet loss, which can avoid the problem of lag and pause.

[0243] When the second L2CAP module receives audio data with the same identification, it can send information with the same identification to the second fusion management module. The information with the same identification is used to represent that the second L2CAP module receives audio data with the same identification from the Bluetooth channel and the Wi-Fi channel.

[0244] S905, the second fusion management module, in response to receiving information with the same identification, sends information for stopping using the Bluetooth channel to the first BT controller through the second L2CAP module and the second BT controller.

[0245] The information for stopping using the Bluetooth channel is used to instruct to send audio data through the Wi-Fi channel and stop using the Bluetooth channel to send audio data, so as to reduce the power consumption of the first device.

[0246] S906, the first BT controller, in response to receiving the information for stopping using the Bluetooth channel, feeds back the information for stopping using the Bluetooth channel to the first fusion management module through the first L2CAP module.

[0247] S907, the first fusion management module, in response to receiving the information for stopping using the Bluetooth channel, executes S614-S619 and S620.

[0248] In an embodiment, the second fusion management module in S905, in response to receiving information with the same identification, can also send information for stopping using the Bluetooth channel to the first Wi-Fi controller through the second L2CAP module and the second Wi-Fi controller, and then the first Wi-Fi controller can feed back the information for stopping using the Bluetooth channel to the first fusion management module through the first L2CAP module.

[0249] For example, S901-S907 can refer to Figure 10 . Figure 10 The first L2CAP module sends audio data through the Bluetooth channel as shown in a of Figure 10 The first fusion management module can send the same audio data through the Bluetooth channel and the Wi-Fi channel after determining the target channel as the Wi-Fi channel in S603 as shown in b ofFigure 10 The second L2CAP module can send information to the first BT controller to stop using the Bluetooth channel in response to receiving the audio data with the same identifier, so that the first device can send the audio data through the Wi-Fi channel.

[0250] In this embodiment, the audio data in "S614-S619, and S620" executed by the first L2CAP module again can be referred to as third audio data. It should be noted that the first audio data, the second audio data, and the second audio data can belong to different parts of the same audio or belong to different audios.

[0251] Similarly, for example, when the first wireless channel is the Wi-Fi channel, after S616 as above, if the first fusion management module executes S603 to determine that the target channel is the Bluetooth channel, the following steps can be executed:

[0252] S901A, the first fusion management module obtains the audio data from the A2DP audio HAL.

[0253] S902A, the first fusion management module copies the audio data into two copies, and identifies the audio data, and the two copies of the audio data have the same identifier.

[0254] S903A, for one of the copies of the audio data, "S604, S605A, S606-S610" is executed, and for the other copy of the audio data, "S614, S615A, S616-S618" is executed.

[0255] S904A, the second L2CAP module sends information with the same identifier to the second fusion management module in response to receiving the audio data with the same identifier.

[0256] S905A, the second fusion management module sends information to the first BT controller through the second L2CAP module and the second BT controller to stop using the Wi-Fi channel in response to receiving the information with the same identifier.

[0257] The information to stop using the Wi-Fi channel is used to instruct to send the audio data through the Bluetooth channel, and to stop using the Wi-Fi channel to send the audio data, so as to reduce the power consumption of the first device.

[0258] S906A, the first BT controller feeds back the information to stop using the Wi-Fi channel to the first fusion management module through the first L2CAP module in response to receiving the information to stop using the Wi-Fi channel.

[0259] S907A, the first fusion management module, in response to receiving the information of stopping using the Wi-Fi channel, executes S604-S613 and S620.

[0260] The steps shown in S901A-S907A above can be applied to the scenario of "the first device switches to the low power consumption mode, and the first fusion management module can determine that the target channel is the Bluetooth channel".

[0261] In an embodiment, in S905A, the second fusion management module, in response to receiving the information of identifying the same, can also send information of stopping using the Bluetooth channel to the first Wi-Fi controller through the second L2CAP module and the second Wi-Fi controller, and then the first Wi-Fi controller can feed back the information of stopping using the Bluetooth channel to the first fusion management module through the first L2CAP module.

[0262] In the embodiment of the application, when the first fusion management module determines to switch the first wireless channel to the second wireless channel to transmit the audio data according to the target parameter, the first fusion management module can copy the audio data in the A2DP audio HAL into two pieces of audio data with the same identifier, and then the second L2CAP module can notify the first device to stop using the first wireless channel to transmit the audio data after receiving the audio data with the same identifier. In this embodiment, the problem of long audio data connection time when switching two channels can be avoided, the smoothness of audio playback of the second device can be ensured, and the user experience can be improved.

[0263] As described in the embodiments of "one and two" above, the first fusion management module can determine whether to switch the channel for transmitting the audio data and determine whether the target channel is the Bluetooth channel or the Wi-Fi channel according to the target parameter, and then the first device can adaptively switch the channel for transmitting the audio data. On the basis of enabling the user to enjoy high sound quality, the smoothness of audio playback can be ensured in an interference environment, audio playback lag can be avoided, and the user experience can be improved.

[0264] In an embodiment, the embodiment of the application also provides a data transmission method. The first fusion management module does not need to determine whether the target channel is the Bluetooth channel or the Wi-Fi channel based on the target parameter, but directly takes the Bluetooth channel and the Wi-Fi channel as the target channel, copies the audio data in the A2DP audio HAL into two pieces, and transmits them through the Bluetooth channel and the Wi-Fi channel respectively. The second device can process and play based on the received audio data. For details, please refer to the related description in Figure 11 .

[0265] Figure 11FIG. 6 is a flowchart illustrating another embodiment of the data transmission method provided by the embodiments of the present application. Referring to FIG. 6, Figure 11 The data transmission method provided by the embodiments of the present application can include the following steps.

[0266] S1101, the application program transmits the audio data to the A2DP audio HAL through the Audio FWK in response to receiving the instruction of playing the audio.

[0267] S1102, the A2DP audio HAL caches the audio data.

[0268] S1103, the first fusion management module acquires the audio data from the A2DP audio HAL.

[0269] S1104, the first fusion management module copies the audio data into two copies, and identifies the audio data, and the two copies of the audio data have the same identification.

[0270] It should be understood that the following description takes the data after copying the audio data into two copies as the first data and the second data as an example for illustration.

[0271] S1105, for one of the two copies of the audio data, the steps of S604, S605A, S606-S610 are performed, and for the other copy of the audio data, the steps of S614, S615A, S616-S618 are performed.

[0272] The steps of S1101-S1102 can refer to the related description in S601-S602, and the steps of S1103-S1105 can refer to the related description in S901-S903.

[0273] S1106, the second L2CAP module stores the first data into the buffer of the second fusion management module and discards the second data in response to receiving the first data with the same identification from the second Wi-Fi controller and the second data from the second BT controller.

[0274] The second fusion management module is configured to construct and maintain the buffer, and the buffer is configured to store the audio data, which can be referred to as an audio buffer. The second fusion management module can pre-set a water flow value for the buffer to ensure the stability of audio playing. It can be understood that the water flow value can represent the minimum amount of data of the audio data stored in the buffer.

[0275] In an embodiment, if the second Wi-Fi controller is able to receive the audio data from the first Wi-Fi controller, and the second BT controller is able to receive the audio data from the first BT controller, the second L2CAP module can receive the audio data from the second Wi-Fi controller and the second BT controller. Wherein, when the second L2CAP module receives the first data from the second Wi-Fi controller and the second data from the second BT controller with the same identification, in order to enable the user to enjoy (experience) high-definition audio, the second L2CAP module can store the first data into the buffer of the second fusion management module, and discard the second data.

[0276] Wherein, because the second L2CAP module receives the first data and the second data with the same identification, that is, the audio data transmission is not packet loss, therefore, in order to enable the user to enjoy high-definition audio, the second L2CAP module can play audio with the first data, and discarding the second data will not cause audio stuttering, and can also reduce the storage pressure of the buffer.

[0277] It should be understood that the audio data in the buffer of the second fusion management module is used to enable the player to play audio. Wherein, the player can read the audio data from the buffer of the second fusion management module to play audio. The process of the player reading the audio data from the buffer of the second fusion management module can be that the player can take the audio data from the buffer of the second fusion management module to play. In this way, when the second fusion management module stores the audio data into the buffer of the second fusion management module, the player can take the data from the buffer of the second fusion management module to play. The data amount of the audio data in the buffer of the second fusion management module is not always accumulated, but is related to the speed of the second fusion management module storing audio and the speed of the player taking the audio data.

[0278] S1107, the second L2CAP module stores the audio data from the second BT controller into the buffer of the second fusion management module after decoding processing in response to the data amount of the audio data in the buffer of the second fusion management module being less than the waterline value.

[0279] It should be understood that there is no order between S1106 and S1107-S1108, and they can be executed alternatively.

[0280] When the communication quality of the Wi-Fi channel is poor, the second Wi-Fi controller cannot receive the audio data from the first Wi-Fi controller, and accordingly, the second L2CAP module cannot receive the audio data from the second Wi-Fi controller. In this case, if the second L2CAP module does not receive the audio data from the second Wi-Fi controller, the second L2CAP module will not store the audio data in the buffer of the second fusion management module, and as the player plays the audio, the amount of data of the audio data in the buffer of the second fusion management module gradually decreases. In order to ensure the smoothness of the audio playback, the second L2CAP module can decode the audio data from the second BT controller through the codec module and store the decoded audio data in the buffer of the second fusion management module to increase the amount of data in the buffer of the second fusion management module.

[0281] It should be understood that the decoding processing of the second L2CAP module on the audio data from the second BT controller can be understood as that the second L2CAP module sends the audio data from the second BT controller to the codec module to make the codec module decode the audio data from the second BT controller to obtain the PCM audio data.

[0282] S1108, the player reads the audio data from the buffer of the second fusion management module and plays the audio.

[0283] Based on the description in S1106-S1107, the buffer of the second fusion management module stores the PCM audio data. In this way, the player can read the PCM audio data from the buffer of the second fusion management module, and then play the audio based on the PCM audio data.

[0284] For example, S1101-S1108 can refer to Figure 12 . Figure 12 The first device sends the audio data to the second device through the first BT controller and the first Wi-Fi controller, respectively. Among them, the second L2CAP module, in response to receiving the first data from the second Wi-Fi controller and the second data from the second BT controller, which have the same identifier (such as number SN1), can store the first data in the buffer of the second fusion management module and discard the second data. For details, please refer to Figure 12As shown in b of FIG. 6, if the communication quality of the Wi-Fi channel is poor, the amount of audio data in the buffer of the second fusion management module gradually decreases. In order to ensure the smoothness of audio playback, the second L2CAP module stores the audio data from the second BT controller in the buffer of the second fusion management module after decoding the audio data in response to the amount of audio data in the buffer of the second fusion management module being less than the waterline value. It should be understood that, Figure 12 As shown in b of FIG. 6, if the communication quality of the Wi-Fi channel is poor, the amount of audio data in the buffer of the second fusion management module gradually decreases. In order to ensure the smoothness of audio playback, the second L2CAP module stores the audio data from the second BT controller in the buffer of the second fusion management module after decoding the audio data in response to the amount of audio data in the buffer of the second fusion management module being less than the waterline value. It should be understood that,

[0285] In an embodiment, if the communication quality of the Wi-Fi channel is poor, the first fusion management module detects that the communication quality of the Bluetooth channel is also less than the preset communication quality of the Bluetooth channel. In order to ensure the smooth transmission of audio data, the audio data can be encoded and then transmitted. In this embodiment, the Wi-Fi channel and the Bluetooth channel both transmit encoded audio data, i.e., encoded data. It should be understood that, in this embodiment, the encoding manner of the encoded data transmitted by the Wi-Fi channel and the encoded data transmitted by the Bluetooth channel can be the same or different. For example, the encoded data transmitted by the Bluetooth channel is obtained by A2DP encoding, and the encoded data transmitted by the Wi-Fi channel can be obtained by A2DP encoding or by other encoding modules in the first device. In the following embodiments, the encoding manner of the encoded data transmitted by the Wi-Fi channel and the encoded data transmitted by the Bluetooth channel is taken as an example for description.

[0286] Correspondingly, in this embodiment, S1105 can be replaced by S1105A: performing “S604, S605A, S606-S610” for one piece of audio data, and performing “S614, S604A, S605A, S606-S607, and S616A-S618A” for one piece of audio data.

[0287] S604A, the first fusion management module sends an encoding instruction to the A2DP module.

[0288] S616A, the first L2CAP module sends the encoded data to the first Wi-Fi controller through the first TCP / IP module.

[0289] S617A, the first Wi-Fi controller sends the encoded data to the second Wi-Fi controller.

[0290] S618A, the second Wi-Fi controller sends the encoded data to the second L2CAP module through the second TCP / IP module in response to the encoded data from the first Wi-Fi controller.

[0291] Thus, in this embodiment, the second L2CAP module can receive the encoded data from the second BT controller and the encoded data from the second Wi-Fi controller.

[0292] In this embodiment, the above S1106-S1108 can be replaced by S1106A-S1108A:

[0293] S1106A, the second L2CAP module stores the first data in the buffer of the second fusion management module after decoding the first data in response to receiving the first data from the second Wi-Fi controller and the second data from the second BT controller with the same identification, and discards the second data.

[0294] In the embodiment of the present application, because the encoded data is also transmitted through the Wi-Fi channel, the second L2CAP module can store the first data in the buffer of the second fusion management module after decoding the first data in response to receiving the first data and the second audio data with the same identification, and discard the second data.

[0295] S1107A, the second L2CAP module stores the audio data from the second BT controller in the buffer of the second fusion management module after decoding the audio data in response to the data amount of the audio data in the buffer of the second fusion management module being less than the waterline value.

[0296] After S1107A, S1108 can be performed.

[0297] For example, "S1101-S1104, S1105A-S1107A, and S1108" can be referred to Figure 13 The difference between the above Figure 12 is that the encoded data from the second Wi-Fi controller in Figure 13 needs to be stored in the buffer of the second fusion management module after decoding. Specifically, Figure 13The first device sends the encoded data to the second device through the first BT controller and the first Wi-Fi controller respectively, as indicated by a in FIG. 6. The second L2CAP module can store the decoded first data in the buffer of the second fusion management module and discard the second data in response to receiving the first data from the second Wi-Fi controller and the second data from the second BT controller, both of which have the same identification (e.g., number SN1). Referring to Figure 13 If the communication quality of the Wi-Fi channel is poor, the amount of audio data in the buffer of the second fusion management module gradually decreases, and the amount of audio data in the buffer of the second fusion management module is less than the waterline value, the second fusion management module stores the decoded audio data from the second BT controller in the buffer, as indicated by b in FIG. 6. It should be understood that Figure 13 In b of FIG. 6, the "X" represents that the communication quality of the Wi-Fi channel is poor, and the amount of audio data in the buffer of the second fusion management module is less than the waterline value.

[0298] In the embodiments of the present application, the second L2CAP module can store the audio data from the second Wi-Fi controller in the buffer of the second fusion management module in response to receiving the audio data with the same identification, so that the player can play audio based on the audio data from the second Wi-Fi controller, allowing the user to enjoy high-definition audio. In addition, when the communication quality of the Wi-Fi channel is poor, i.e., the amount of audio data in the buffer of the second fusion management module is less than the waterline value, the second L2CAP module can decode the audio data from the second BT controller through the codec module and store it in the buffer of the second fusion management module, so that the player can play audio based on the audio data from the second BT controller, ensuring the smoothness of audio playback and preventing audio playback from being interrupted.

[0299] In an embodiment, S1106-S1107 can be replaced by S1106B: the second L2CAP module can store the audio data from the second Wi-Fi controller into the buffer of the second fusion management module and discard the audio data from the second BT controller, according to the first identification of the audio data from the second Wi-Fi controller and the second identification of the audio data from the second BT controller, if the buffer of the second fusion management module does not contain the first identification and contains the second identification. Similarly, the second fusion management module can store the audio data from the second BT controller into the buffer of the second fusion management module and discard the audio data from the second Wi-Fi controller, if the buffer of the second fusion management module does not contain the second identification and contains the first identification.

[0300] In this embodiment, for example, the audio data numbered SN1 and the audio data numbered SN2 have been stored in the buffer of the second fusion management module, wherein the audio data numbered SN1 is from the second Wi-Fi controller and the audio data numbered SN2 is from the second BT controller. If the second L2CAP module receives the audio data numbered SN3 from the second BT controller and the audio data numbered SN2 from the second Wi-Fi controller, because the buffer of the second fusion management module does not contain the identification “numbered SN3” and contains the identification “numbered SN2”, the second L2CAP module can store the audio data numbered SN3 from the second BT controller into the buffer of the second fusion management module and discard the audio data numbered SN2 from the second Wi-Fi controller.

[0301] In the embodiments of the present application, the second L2CAP module can store the audio data with the received identification into the buffer of the second fusion management module, which can ensure the smoothness of the audio data playing.

[0302] According to Figure 3A and Figure 3B the first device and the second device, referring to Figure 14 , the data transmission method provided by the embodiments of the present application can include:

[0303] S1401, the first device sends the first audio data to the second device through the first wireless channel, and the first audio data is used for the second device to play the first audio.

[0304] The first device and the second device have established a first wireless channel and a second wireless channel, the first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is a Bluetooth channel or a Wi-Fi channel, and the first wireless channel and the second wireless channel are different. The first device can play audio through the second device. In the embodiment of the application, the first device sends first audio data to the second device through the first wireless channel. The first audio data is used for the second device to play first audio.

[0305] S1402, playing the first audio based on the first audio data.

[0306] S1403, if it is determined according to the target parameter that the target channel for data transmission is the second wireless channel, the first device sends second audio data to the second device through the second wireless channel, the target parameter is related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device, and the running mode of the second device, and the second audio data is used for the second device to play second audio.

[0307] The target parameter is related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device, and the running mode of the second device, and the second audio data is used for the second device to play second audio. The target parameter can refer to the related description in the above embodiment.

[0308] In an embodiment, the target parameter is also related to the type of audio data, and the type of audio data can be: high definition or non-high definition. The first device determines the target channel according to the target parameter. The manner can refer to the related description in S603.

[0309] If the first device determines the target channel for data transmission according to the target parameter, the first device sends second audio data to the second device through the second wireless channel. The manner can refer to the related description in the above embodiment.

[0310] The second audio data and the first audio data can be data in the same audio. For example, if the audio is a song, the first device can first send a part of audio data in the song to the second device, and then send a part of audio data in the song to the second device, so that the second device can play the song based on the audio data from the first device. Alternatively, the second audio data and the first audio data can be data in different audios. For example, the first audio data is audio data corresponding to the end of a song, and the second audio data is audio data corresponding to the beginning of another song.

[0311] It should be understood that before the first device transmits the first audio data to the second device through the first wireless channel, the first device also needs to determine the target channel for transmitting the first audio data through the target parameter, and the related description can be referred to in S603.

[0312] S1404, playing the second audio based on the second audio data.

[0313] In the embodiments of the present application, when the first device plays the audio through the second device, the first device can switch the channel for transmitting the audio data according to the target parameter, which can ensure that the user can enjoy high-definition audio while ensuring the smoothness of audio playing in an interference environment, avoiding audio lag, and improving the user experience.

[0314] In one embodiment, in S1402, before the first device transmits the second audio data to the second device through the second wireless channel, the first device can detect whether the first audio data has been transmitted through the first wireless channel, and the specific detection method can be referred to in S701-S705 and S701A-S705A. The first device transmits the second audio data to the second device through the second wireless channel in response to detecting that the first audio data has been transmitted through the first wireless channel.

[0315] In one embodiment, in order to reduce the time delay of audio playing caused by channel switching, the first device can copy the second audio data twice, as first data and second data, and mark the first data and the second data with the same identifier. The first device transmits the first data to the second device through the first wireless channel, and transmits the second data to the second device through the second wireless channel.

[0316] In this embodiment, the second device can send information to the first device to stop using the first wireless channel in response to receiving the first data and the second data with the same identifier from the first device through the two wireless channels. In addition, the second device can play the second audio based on the data from the second wireless channel.

[0317] Correspondingly, the first device can transmit third audio data to the second device through the second wireless channel in response to receiving the information to stop using the first wireless channel. It should be understood that the second device can play the third audio in response to receiving the third audio data.

[0318] In one embodiment, the first device can transmit the audio data to the second device through the first wireless channel and the second wireless channel at the same time without determining the target channel through the target parameter. In one embodiment, the first wireless channel is a Wi-Fi channel, and the second wireless channel is a Bluetooth channel. Referring to Figure 15 The data transmission method in this embodiment can include:

[0319] S1501, the first device duplicates the first audio data into two parts, as first data and second data, respectively, the first audio data being used for playing first audio by the second device.

[0320] S1502, the first device labels the first data and the second data with the same identifier.

[0321] S1503, the first device sends the first data to the second device through the first wireless channel.

[0322] S1504, the first device sends the second data to the second device through the second wireless channel.

[0323] S1501-S1504 can refer to the related description in the above Figure 11

[0324] S1505, the second device stores the first data in a cache area of the second device.

[0325] S1506, the second device plays the first audio based on the first data in the cache area.

[0326] In the embodiments of the present application, the second device can store the first data from the Wi-Fi channel in the cache area of the second device in response to receiving the first data and the second data with the same identifier from the first device, and then play the first audio based on the first data in the cache area. Because the audio data from the Wi-Fi channel is uncoded data, the user can enjoy high-definition audio.

[0327] In an embodiment, if the quality of the Wi-Fi channel deteriorates, causing the amount of audio data in the cache area of the second device to gradually decrease, in order to ensure the smoothness of audio playback, the second device stores the audio data from the Bluetooth channel in the cache area of the second device after decoding in response to the amount of audio data in the cache area of the second device being less than a waterline value.

[0328] In an embodiment, referring to the description of S1106B, in order to ensure the smoothness of audio data playback, the second device can store the audio data from the first wireless channel in the cache area of the second device according to the first identifier of the audio data from the first wireless channel and the second identifier of the audio data from the second wireless channel, and discard the audio data from the second wireless channel if the cache area of the second device does not contain the first identifier and contains the second identifier. In this way, the second device receives audio data from which channel first, and then stores the audio data from that channel in the cache area of the second device for playback, which can ensure the smoothness of audio data playback.

[0329] ​In one embodiment, this application also provides an electronic device, which can be the first device or the second device described in the above embodiments, with reference to... Figure 16 The electronic device may include a processor 161 (e.g., the Host CPU in the above embodiments), a memory 162, a Bluetooth controller 163, and a Wi-Fi controller 164. The memory 162 may include high-speed random-access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device. The memory 162 may store various instructions for the processor 161 to perform various processing functions and implement the method steps of this application, as described in the relevant descriptions in the above embodiments. The Bluetooth controller 163 and the Wi-Fi controller 164 are used to enable communication and connection between the electronic device and other devices.

[0330] Optionally, the electronic device involved in this application may further include: a power supply 165 and a communication bus 166. In the embodiments of this application, the memory 162 is used to store computer-executable program code, the program code including instructions; when the processor 161 executes the instructions, the instructions cause the processor 161 of the electronic device to perform the actions in the above method embodiments, the implementation principle and technical effect are similar, and will not be described again here.

[0331] It should be noted that the modules or components described in the above embodiments can be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs), etc. Furthermore, when a module is implemented through processing element scheduler code, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processors capable of calling program code, such as a controller. Additionally, these modules can be integrated together to implement a system-on-a-chip (SOC).

[0332] In the above embodiments, all or part of the embodiments can be implemented by software, hardware, firmware or any combination thereof. When implemented by software, all or part of the embodiments can be implemented in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions according to the embodiments of the present application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium, for example, the computer instructions can be transmitted from one website, computer, server or data center to another website, computer, server or data center through a wired (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) manner. The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server, data center, etc. containing one or more available media sets. The available media can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)) and the like.

[0333] The term "a plurality of" herein refers to two or more. The term "and / or" herein is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the three cases of A alone, A and B together, and B alone. In addition, the character " / " herein generally represents that the associated objects before and after it are in an "or" relationship; in the formula, the character " / " represents that the associated objects before and after it are in a "division" relationship. In addition, it should be understood that in the description of the present application, the terms "first", "second", etc. are only used for the purpose of distinguishing the description and should not be understood as indicating or implying relative importance or indicating or implying sequence.

[0334] It can be understood that the various numerical numbers involved in the embodiments of the present application are only for the convenience of differentiation and do not limit the scope of the embodiments of the present application.

[0335] It can be understood that in the embodiments of the present application, the size of the serial number of the above processes does not mean the order of execution, and the execution order of the processes should be determined according to their functions and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

Claims

1. A data transmission method, characterized by, The method is applied to a first device, the first device has established a first wireless channel and a second wireless channel with a second device, the first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is the Bluetooth channel or the Wi-Fi channel, the first wireless channel and the second wireless channel are different, and the method comprises the following steps: sending first audio data to the second device through the first wireless channel, the first audio data being used for the second device to play first audio; if a target parameter is used to determine that a target channel for data transmission is the second wireless channel, the target parameter being related to at least one of the following: communication quality of the first wireless channel, communication quality of the second wireless channel, running mode of the first device, and running mode of the second device, and second audio data being used for the second device to play second audio is sent to the second device through the second wireless channel; if the target parameter is used to determine that the communication quality of the first wireless channel is less than or equal to preset communication quality of the first wireless channel and the communication quality of the second wireless channel is greater than or equal to preset communication quality of the second wireless channel, the target channel is determined to be the second wireless channel; before the second audio data is sent to the second device through the second wireless channel, the following steps are further included: copying the second audio data into two parts, which are first data and second data respectively; labeling the first data and the second data with the same identifier; the second audio data is sent to the second device through the second wireless channel, comprising the following steps: sending the first data to the second device through the first wireless channel; sending the second data to the second device through the second wireless channel. before the second audio data is sent to the second device through the second wireless channel, the following steps are further included:

2. The method of claim 1, wherein, detecting whether the first audio data has been sent completely through the first wireless channel; the second audio data is sent to the second device through the second wireless channel, comprising the following steps: in response to detecting that the first audio data has been sent completely through the first wireless channel, the second audio data is sent to the second device through the second wireless channel. if the target parameter is used to determine that the communication quality of the first wireless channel is less than or equal to preset communication quality of the first wireless channel, the target channel is determined to be the second wireless channel.

3. The method according to claim 1 or 2, characterized in that, the target parameter is related to the running mode of the first device and the running mode of the second device, and the target channel for data transmission is determined to be the second wireless channel according to the target parameter, comprising the following steps: ​ 4. The method according to claim 1 or 2, characterized in that, ​ When the first wireless channel is a Wi-Fi channel, if it is detected that the running mode of the first device and / or the second device enters a low-power mode, it is determined that the target channel is a Bluetooth channel, and the Bluetooth channel is the second wireless channel.

5. The method of claim 1, wherein, After the second data is sent to the second device through the second wireless channel, the method further includes: In response to receiving information from the second device that the first wireless channel is no longer used, third audio data is sent to the second device through the second wireless channel, and the third audio data is used by the second device to play third audio.

6. The method of claim 1 or 2, wherein, Before the first audio data is sent to the second device through the first wireless channel, the method further includes: According to the target parameter, it is determined that the target channel for transmitting the first audio data is the first wireless channel.

7. The method of claim 6, wherein, The target parameter is related to the type of the first audio data, the first wireless channel is a Wi-Fi channel, and according to the target parameter, it is determined that the target channel for transmitting the first audio data is the first wireless channel, which includes: Based on the target parameter, if it is determined that the type of the first audio data is a preset type, it is determined that the target channel for transmitting the first audio data is the Wi-Fi channel, and the preset type has a mapping relationship with the Wi-Fi channel; Based on the target parameter, if it is determined that the type of the first audio data is a non-pre-set type, it is determined that the target channel for transmitting the first audio data is the Bluetooth channel, and the non-pre-set type has a mapping relationship with the Bluetooth channel.

8. A data transmission method, characterized by, The method is applied to a second device, and a first device has established a first wireless channel and a second wireless channel with the second device, the first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is the Bluetooth channel or the Wi-Fi channel, the first wireless channel and the second wireless channel are different, and the method includes: Receiving first audio data from the first device through the first wireless channel; Playing first audio based on the first audio data; Receiving second audio data from the first device through the second wireless channel; the second wireless channel is a data receiving target channel determined according to a target parameter; Playing second audio based on the second audio data; The target parameter is related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device, and the running mode of the second device; The target parameter is related to the communication quality of the first wireless channel and the communication quality of the second wireless channel, the second wireless channel is a data receiving target channel determined according to a target parameter, and the specific determination steps are as follows: If it is determined according to the target parameter that the communication quality of the first wireless channel is less than or equal to the preset communication quality of the first wireless channel, and the communication quality of the second wireless channel is greater than or equal to the preset communication quality of the second wireless channel, it is determined that the target channel is the second wireless channel; The receiving the second audio data from the first device through the second wireless channel further comprises: receiving first data from the first wireless channel and second data from the second wireless channel, the first data and the second data being obtained by duplicating the second audio data by the first device, and the first data and the second data having the same identifier; identifying the first data and the second data as the same audio data based on the identifier, and sending information to the first device to stop using the first wireless channel.

9. The method of claim 8, wherein, The receiving the second audio data from the first device through the second wireless channel comprises: receiving first data from the first device through the first wireless channel; receiving second data from the first device through the second wireless channel, the first data and the second data being obtained by duplicating the second audio data by the first device, and the first data and the second data having the same identifier; sending information to the first device to stop using the first wireless channel.

10. The method of claim 9, wherein, The receiving the second audio data from the first device through the second wireless channel further comprises: receiving third audio data from the first device through the second wireless channel; playing third audio based on the third audio data.

11. A data transmission method, characterized by, The method is applied to a first device, and the first device has established a first wireless channel and a second wireless channel with a second device, the first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is the Bluetooth channel or the Wi-Fi channel, the first wireless channel and the second wireless channel are different, and the method comprises: duplicating first audio data into first data and second data, the first audio data being used for the second device to play first audio; labeling the first data and the second data with the same identifier; sending the first data to the second device through the first wireless channel; sending the second data to the second device through the second wireless channel; if a target parameter determines that a target channel for data transmission is the second wireless channel, sending second audio data to the second device through the second wireless channel, the target parameter being related to at least one of the following: communication quality of the first wireless channel, communication quality of the second wireless channel, running mode of the first device, and running mode of the second device, the second audio data being used for the second device to play second audio; the target parameter being related to communication quality of the first wireless channel and communication quality of the second wireless channel, and the target parameter determining that the target channel for data transmission is the second wireless channel comprising: if the target parameter determines that the communication quality of the first wireless channel is less than or equal to a preset communication quality of the first wireless channel, and the communication quality of the second wireless channel is greater than or equal to a preset communication quality of the second wireless channel, determining that the target channel is the second wireless channel.

12. A data transmission method, characterized by, The method is applied to a second device, a first device and the second device have established a first wireless channel and a second wireless channel, the first wireless channel is a Bluetooth channel or a Wi-Fi channel, the second wireless channel is the Bluetooth channel or the Wi-Fi channel, the first wireless channel and the second wireless channel are different, and the method comprises: receiving first data from the first wireless channel and second data from the second wireless channel with the same identifier, the first data and the second data being obtained by copying first audio data into two parts by the first device; storing the first data in a cache area, the first wireless channel being a Wi-Fi channel; playing first audio based on the first data in the cache area; receiving second audio data from the first device through the second wireless channel, the second wireless channel being a data receiving target channel determined according to a target parameter; playing second audio based on the second audio data; the target parameter being related to at least one of the following: the communication quality of the first wireless channel, the communication quality of the second wireless channel, the running mode of the first device, and the running mode of the second device; the target parameter being related to the communication quality of the first wireless channel and the communication quality of the second wireless channel, the second wireless channel being a data receiving target channel determined according to a target parameter, and the specific determination steps being as follows: if it is determined according to the target parameter that the communication quality of the first wireless channel is less than or equal to the preset communication quality of the first wireless channel and the communication quality of the second wireless channel is greater than or equal to the preset communication quality of the second wireless channel, then the target channel is determined to be the second wireless channel.

13. The method of claim 12, wherein, The method further comprises: if the data amount of the audio data in the cache area is less than a preset data amount, then storing the data from the second wireless channel in the cache area after decoding processing, the second wireless channel being a Bluetooth channel; playing audio based on the decoded processed data in the cache area.

14. The method of claim 12, wherein, The method further comprises: if the cache area does not contain the first identifier and contains the second identifier according to the first identifier of the audio data from the first wireless channel and the second identifier of the audio data from the second wireless channel, then storing the audio data from the first wireless channel in the cache area and discarding the audio data from the second wireless channel.

15. An electronic device, comprising: comprise: a processor, a memory; the memory stores computer execution instructions; the processor executes the computer execution instructions stored in the memory, so that the processor executes the method of any one of claims 1-14.

16. A computer readable storage medium characterized by: The computer readable storage medium stores a computer program or instructions, and when the computer program or instructions are executed, the method of any one of claims 1-14 is implemented.

17. A computer program product comprising computer programs or instructions, characterized in that, The computer program or instructions are executed by the processor to implement the method of any one of claims 1-14.

Citation Information

Patent Citations

  • Seamless playback and switching for wireless communications devices

    US20210266808A1