WO2023051041A1 - 数据传输方法、装置、电子设备和可读存储介质 - Google Patents

数据传输方法、装置、电子设备和可读存储介质 Download PDF

Info

Publication number
WO2023051041A1
WO2023051041A1 PCT/CN2022/111317 CN2022111317W WO2023051041A1 WO 2023051041 A1 WO2023051041 A1 WO 2023051041A1 CN 2022111317 W CN2022111317 W CN 2022111317W WO 2023051041 A1 WO2023051041 A1 WO 2023051041A1
Authority
WO
WIPO (PCT)
Prior art keywords
path
data
audio data
wireless path
audio
Prior art date
Application number
PCT/CN2022/111317
Other languages
English (en)
French (fr)
Inventor
赵曜
倪观军
王良
林健新
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2023051041A1 publication Critical patent/WO2023051041A1/zh

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L12/00Data switching networks
    • H04L12/28Data switching networks characterised by path configuration, e.g. LAN [Local Area Networks] or WAN [Wide Area Networks]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04RLOUDSPEAKERS, MICROPHONES, GRAMOPHONE PICK-UPS OR LIKE ACOUSTIC ELECTROMECHANICAL TRANSDUCERS; DEAF-AID SETS; PUBLIC ADDRESS SYSTEMS
    • H04R1/00Details of transducers, loudspeakers or microphones
    • H04R1/20Arrangements for obtaining desired frequency or directional characteristics
    • H04R1/22Arrangements for obtaining desired frequency or directional characteristics for obtaining desired frequency characteristic only 
    • H04R1/28Transducer mountings or enclosures modified by provision of mechanical or acoustic impedances, e.g. resonator, damping means
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/02Services making use of location information
    • H04W4/021Services related to particular areas, e.g. point of interest [POI] services, venue services or geofences
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W4/00Services specially adapted for wireless communication networks; Facilities therefor
    • H04W4/80Services using short range communication, e.g. near-field communication [NFC], radio-frequency identification [RFID] or low energy communication
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/10Connection setup
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W76/00Connection management
    • H04W76/30Connection release
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04WWIRELESS COMMUNICATION NETWORKS
    • H04W88/00Devices specially adapted for wireless communication networks, e.g. terminals, base stations or access point devices
    • H04W88/02Terminal devices
    • H04W88/06Terminal devices adapted for operation in multiple networks or having at least two operational modes, e.g. multi-mode terminals
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D30/00Reducing energy consumption in communication networks
    • Y02D30/70Reducing energy consumption in communication networks in wireless communication networks

Definitions

  • the embodiments of the present application relate to communication technologies, and in particular, to a data transmission method, device, electronic device, and readable storage medium.
  • the phone can connect to the speaker via Bluetooth and Wi-Fi. After the mobile phone and the speaker are connected via Bluetooth, the mobile phone can send audio data to the speaker through the Bluetooth channel between the mobile phone and the speaker, so that the speaker can play audio based on the audio data. When the mobile phone is connected to the speaker Wi-Fi, the mobile phone can send audio data to the speaker through the Wi-Fi channel between the mobile phone and the speaker, so that the speaker plays audio based on the audio data.
  • the mobile phone makes the speaker play audio through the Wi-Fi channel between the mobile phone and the speaker
  • the communication quality of the Wi-Fi channel is poor, the audio playback will freeze, and the user needs to manually turn off the Wi-Fi connection between the mobile phone and the speaker.
  • To connect establish a Bluetooth connection between the mobile phone and the speaker, and the mobile phone can control the speaker to play audio based on the Bluetooth channel between the mobile phone and the speaker, but the control method in the prior art is complicated to operate.
  • Embodiments of the present application provide a data transmission method, device, electronic equipment, and readable storage medium.
  • the electronic equipment can automatically switch the channel for transmitting audio data.
  • the user can enjoy High quality audio.
  • the embodiment of the present application provides a data transmission method, and the execution body of the method may be a first device or a chip in the first device, and the first device is taken as an example for description below.
  • the first device and the second device have established a first wireless path and a second wireless path, the first wireless path is a Bluetooth path or a Wi-Fi path, the second wireless path is a Bluetooth path or a Wi-Fi path, and the second wireless path is a Bluetooth path or a Wi-Fi path.
  • the first wireless path and the second wireless path are different.
  • the first device can play audio through the second device.
  • the first device can send 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, that is, the second device responds to receiving the first audio data, The first audio can be played based on the first audio data. If the first device determines that the target path of data transmission is the second wireless path according to the target parameter, the first device sends the second audio data to the second device through the second wireless path.
  • the target parameter is related to at least one of the following: the communication quality of the first wireless path, the communication quality of the second wireless path, the operating mode of the first device, and the operating mode of the second device, and the second audio data is used for the second
  • the device plays the second audio.
  • the first device determines that the target path for data transmission is the second wireless path according to the target parameter, and reference may be made to the following related descriptions.
  • the first device 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 parameters, which can ensure that the user can enjoy high-definition audio while ensuring the quality of the audio in the interference environment.
  • the smoothness of audio playback and the avoidance of audio stuttering can improve user experience.
  • the first device before sending the second audio data to the second device through the second wireless path, the first device may detect whether the first audio data has been sent through the first wireless path. The first device transmits the second audio data to the second device through the second wireless path in response to detecting that the first audio data has been sent over the first wireless path.
  • the first device may make two copies of the second audio data, namely the first data and the second data, and the first data Marked with the same identifier as the second data.
  • the first device sends first data to the second device through the first wireless path, and sends second data to the second device through the second wireless path.
  • the second device may send information to the first device to stop using the first wireless path in response to receiving the first data and the second data from the first device having the same identifier for the two wireless paths. Additionally, the second device can play a second audio based on data from the second wireless path.
  • the first device may send the third audio data to the second device through the second wireless path.
  • the second device may play the third audio in response to receiving the third audio data.
  • the following describes how the first device determines the target path as the second wireless path according to the target parameters:
  • the target parameter is related to the communication quality of the first wireless path.
  • the first device determines according to the target parameter that the communication quality of the first wireless path is less than or equal to the preset communication quality of the first wireless path, then determine that the target path is the second wireless path.
  • the parameters used to characterize the communication quality of the first wireless path may include but not limited to: packet error rate, throughput rate, etc. of the first wireless path.
  • the throughput rate as an example, when the throughput rate of the first wireless path is less than the first preset throughput rate, it can be determined that the communication quality of the first wireless path is less than or equal to the preset communication quality of the first wireless path, that is, the first The preset throughput rate is used to characterize the preset communication quality of the first wireless path.
  • the target parameter is related to the communication quality of the first wireless path and the communication quality of the second wireless path.
  • the first device determines according to the target parameter that the communication quality of the first wireless path is less than or equal to the preset communication quality of the first wireless path, and the communication quality of the second wireless path is greater than or equal to the The preset communication quality of the second wireless path determines that the target path is the second wireless path.
  • the first device when the throughput rate of the first wireless path is less than the first preset throughput rate, it may be determined that the communication quality of the first wireless path is less than or equal to the preset communication quality of the first wireless path , at this time, the first device also needs to detect whether the throughput rate of the second wireless path is greater than or equal to the second preset throughput rate, and when the throughput rate of the second wireless path is greater than or equal to the second preset throughput rate, it indicates that the first The communication quality of the second wireless path is greater than or equal to the preset communication quality of the second wireless path, then the first device may determine that the communication quality of the first wireless path is poor, but the communication quality of the second wireless path is good, then it may determine that the communication quality of the second wireless path is good.
  • the target path is the second wireless path.
  • the target parameter is related to the operation mode of the first device and the operation mode of the second device.
  • the first wireless path is a Wi-Fi path
  • the first device detects that the operation mode of the first device and/or the second device enters a low power consumption mode
  • the Bluetooth path is the second wireless path.
  • the target parameter is related to the operation mode of the first device.
  • the first wireless path is a Wi-Fi path
  • the first device detects that the operation mode of the first device has entered a low power consumption mode, it determines that the target path is a Bluetooth path, and the Bluetooth path is the second wireless path.
  • the target parameter is related to the operation mode of the second device, wherein, when the first wireless path is a Wi-Fi path, if the first device detects that the second device's When the operating mode enters a low power consumption mode, it is determined that the target path is a Bluetooth path, and the Bluetooth path is the second wireless path.
  • the first wireless path is a Wi-Fi path
  • the first device detects that the operating mode of the first device has entered a low power consumption mode, then it is determined that the target path is a Bluetooth path, and the first device also needs Detect whether the communication quality of the second wireless path is greater than or equal to the preset communication quality of the second wireless path, if the communication quality of the second wireless path is greater than or equal to the preset communication quality of the second wireless path, the first device can determine the target The path is the bluetooth path.
  • the target parameter is also related to the type of the second audio data.
  • the second audio data and the first audio data may not be data in the same audio.
  • the first device may determine that the type of the second audio data is a preset type based on the target parameter, then determine that the target path for transmitting the second audio data is the Wi-Fi path, and the The preset type has a mapping relationship with the Wi-Fi access. Similarly, based on the target parameter, if the first device determines that the type of the second audio data is a non-preset type, then determine that the target channel for transmitting the second audio data is the Bluetooth channel, and the non-preset The preset type has a mapping relationship with the Bluetooth path.
  • the preset type may be high-definition audio
  • the non-preset type may be non-high-definition audio
  • the first device may determine that the type of the second audio data is a preset type based on the target parameter, then determine that the target path for transmitting the second audio data is the Wi-Fi path, then The first device also needs to detect whether the communication quality of the Wi-Fi channel is greater than or equal to the preset communication quality of the Wi-Fi channel. If the communication quality of the Wi-Fi channel is greater than or equal to the preset communication quality of the Wi-Fi channel, the first device A device may determine that the target path is a Wi-Fi path.
  • the first device may determine that the target path for transmitting the first audio data is the first wireless path based on the target parameter, specifically, Refer to related descriptions in the above "the first device determines the target path as the second wireless path according to the target parameters".
  • the embodiment of the present application provides a data transmission method, and the execution subject of the method may be the second device or a chip in the second device, and the second device is taken as an example for description below.
  • the second device may 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 may receive second audio data from the first device through the second wireless path, and play second audio based on the second audio data.
  • the embodiment of the present application provides a data transmission method, and the execution body of the method may be the first device or a chip in the first device, and the first device is taken as an example for description below.
  • the first device may make two copies of the first audio data, namely the first data and the second data, and the first audio data is used by the second device to play the first audio.
  • the first device may 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 first data to the second device through the second wireless A channel sends the second data to the second device.
  • the embodiment of the present application provides a data transmission method.
  • the execution body of the method may be the second device or a chip in the second device.
  • the second device is taken as an example for description below.
  • the second device in response to receiving the first data and the second data with the same identifier from the first device, the second device may store the first data from the Wi-Fi path in the cache area of the second device, and then Play the first audio based on the first data in the buffer. Since the audio data from the Wi-Fi channel is unencoded data, users can enjoy high-definition audio.
  • the second device responds to the first The amount of audio data in the buffer area of the second device is less than the watermark value, and the audio data from the bluetooth channel is decoded and stored in the buffer area of the second device.
  • the second device may, according to the first identification of the audio data from the first wireless channel of the first device and the identification of the audio data from the second wireless channel, The second identification, if the buffer area of the second device does not include the first identification and contains the second identification, then store the audio data from the first wireless path into the buffer area of the second device, and discard the audio data from the second wireless path audio data. In this way, which channel of audio data the second device receives first, the second device preferentially stores the audio data of the channel in the buffer area of the second device for playback, which can ensure the smoothness of audio data playback.
  • first identifier and the second identifier may be the same or different, and when the first identifier and the second identifier are the same, the second device may store the audio data from the Wi-Fi channel in the cache area of the second device, and Discards audio data from the bluetooth channel.
  • the embodiment of the present application provides a data transmission device, including:
  • the target parameter is related to at least one of the following: The communication quality of the first wireless path, the communication quality of the second wireless path, the operating mode of the first device, and the operating mode of the second device, and the second audio data is used for playing by the second device second audio.
  • the first fusion management module is further configured to detect whether the first audio data has been sent through the first wireless path, and in response to detecting that the first audio data has been sent through the first wireless path After completing the first audio data, sending the second audio data to the second device through the second wireless path.
  • the target parameter is related to the communication quality of the first wireless path.
  • the first fusion management module is specifically configured to determine that the target path is the Second wireless access.
  • the target parameter is related to the communication quality of the first wireless path and the communication quality of the second wireless path.
  • the first fusion management module is specifically configured to determine that the communication quality of the first wireless path is less than or equal to the preset communication quality of the first wireless path according to the target parameter, and the communication quality of the second wireless path If the quality is greater than or equal to the preset communication quality of the second wireless path, then it is determined that the target path is the second wireless path.
  • the target parameter is related to the operation mode of the first device and the operation mode of the second device.
  • the first integrated management module is specifically used for:
  • the first wireless path is a Wi-Fi path
  • the target path is a Bluetooth path
  • the Bluetooth The path is the second wireless path.
  • the first fusion management module is further configured to make two copies of the second audio data, which are the first data and the second data respectively, and copy the first data and the second The data is marked with the same identifier, and the first data is sent to the second device through the first wireless path, and the second data is sent to the second device through the second wireless path.
  • the first fusion management module is further configured to, in response to receiving information about stopping using the first wireless path from the second device, communicate to the first wireless path through the second wireless path
  • the second device sends third audio data, and the third audio data is used by the second device to play the third audio.
  • the first fusion management module is further configured to determine, according to the target parameter, a target path for transmitting the first audio data as the first wireless path.
  • the target parameter is related to the type of the first audio data
  • the first wireless path is a Wi-Fi path.
  • First Converged Management Module also used for:
  • the target path for transmitting the first audio data is the Wi-Fi path, and the preset type is the same as the Wi-Fi path.
  • the -Fi path has a mapping relationship.
  • the target parameter if it is determined that the type of the first audio data is a non-preset type, then determine that the target channel for transmitting the first audio data is the Bluetooth channel, and the non-preset type is related to the Bluetooth channel.
  • Paths have a mapping relationship.
  • the embodiment of the present application provides a data transmission device, including:
  • the second fusion management module is configured to receive the first audio data from the first device through the first wireless path.
  • the player is configured to play the first audio based on the first audio data.
  • the second fusion management module is further configured to receive the second audio data from the first device through the second wireless channel.
  • the player is further configured to play the second audio based on the second audio data.
  • the second fusion management module is specifically configured to receive the first data from the first device through the first wireless path, and receive the data from the first device through the second wireless path.
  • the second data of a device, the first data and the second data are obtained by the first device duplicating the second audio data into two copies, the first data and the second data ID is the same.
  • the second fusion management module is further configured to send information about stopping using the first wireless path to the first device.
  • the second fusion management module is further configured to receive third audio data from the first device through the second wireless path.
  • the player is further configured to play the third audio based on the third audio data.
  • the embodiment of the present application provides a data transmission device, including:
  • the first fusion management module is used to make two copies of the first audio data, namely the first data and the second data, mark the first data and the second data with the same identification, and pass the first data Sending the first data to the second device through a wireless path, sending the second data to the second device through the second wireless path, and using the first audio data to be played by the second device first audio.
  • the embodiment of the present application provides a data transmission device, including:
  • the second fusion management module is configured to receive the first data from the first wireless path and the second data from the second wireless path with the same identifier, the first data and the second data are the The first device copies the first audio data into two copies, stores the first data in a cache area, and the first wireless path is a Wi-Fi path.
  • a player configured to play the first audio based on the first data in the buffer area.
  • the second fusion management module is further configured to decode and process the data from the second wireless channel if the data volume of the audio data in the buffer area is less than the preset data volume Stored in the cache area, the second wireless path is a bluetooth path.
  • the player is further configured to play audio based on the decoded data in the buffer area.
  • the second fusion management module is further configured to, according to the first identifier of the audio data from the first wireless path and the second identifier of the audio data from the second wireless path, If the buffer does not contain the first identifier and contains the second identifier, store the audio data from the first wireless path into the buffer, and discard the audio data from the second wireless path audio data.
  • the embodiment of the present application provides an electronic device, where the electronic device is the first device and the second device as above. May include: processor, memory, Bluetooth controller, and Wi-Fi controller.
  • the memory is used 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 execute the methods in the first aspect to the fourth aspect.
  • the embodiment of the present application provides an electronic device, and the electronic device may be a first device.
  • the electronic device may include a unit, module or circuit for performing the methods provided in the above first aspect to the fourth aspect.
  • the embodiments of the present application provide a computer program product containing instructions, which, when run on a computer, cause the computer to execute the methods in the first aspect to the fourth aspect above.
  • the embodiment of the present application provides a computer-readable storage medium, the computer-readable storage medium stores instructions, and when it is run on a computer, the computer executes the above-mentioned first aspect to the fourth aspect. Methods.
  • FIG. 1 is a schematic diagram of a scene applicable to an embodiment of the present application
  • Fig. 2 is a schematic diagram of an existing audio playback
  • FIG. 3A is a schematic diagram of interaction between a first device and a second device provided in an embodiment of the present application
  • FIG. 3B is another schematic diagram of interaction between the first device and the second device provided in the embodiment of the present application.
  • FIG. 4 is a schematic diagram of the process of establishing a Bluetooth channel between the first device and the second device provided in the embodiment of the present application;
  • FIG. 5 is a schematic diagram of the process of establishing a Wi-Fi path between the first device and the second device provided in the embodiment of the present application;
  • FIG. 6 is a schematic flowchart of an embodiment of a data transmission method provided in an embodiment of the present application.
  • FIG. 7 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • FIG. 8 is a schematic diagram of data transmission provided by the embodiment of the present application.
  • FIG. 9 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • FIG. 10 is another schematic diagram of data transmission provided by the embodiment of the present application.
  • FIG. 11 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • FIG. 12 is another schematic diagram of data transmission provided by the embodiment of the present application.
  • FIG. 13 is another schematic diagram of data transmission provided by the embodiment of the present application.
  • FIG. 14 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • FIG. 15 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • FIG. 16 is a schematic structural diagram of an electronic device provided by an embodiment of the present application.
  • FIG. 1 is a schematic diagram of a scene applicable to an embodiment of the present application.
  • the scene includes a first device and a second device.
  • the first device is a mobile phone and the second device is a sound box as an example.
  • the first device can be connected wirelessly with the second device, and the first device can play audio through the second device.
  • the first device may be connected to the second device via Bluetooth, the first device may transmit audio data to the second device through the Bluetooth channel between the first device and the second device, and the second device may Audio data, play audio.
  • 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 may also transmit audio data to the second device through the Wi-Fi path between the first device and the second device, and the second device may also play audio based on the audio data.
  • 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 that occupies a larger bandwidth to the second device, or 5.1 Stereo audio data, or 7.1 stereo audio data, etc.
  • the second device can play lossless audio, 5.1 stereo audio, and 7.1 stereo audio, etc. (the following uses lossless audio as an example for illustration).
  • 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.
  • the audio played by the second device is encoded audio.
  • the first device in the embodiment of the present application may include but not limited to: mobile phone, tablet computer (portable android device, PAD), smart screen, handheld device with wireless communication function, computing device, vehicle-mounted device or Wearable devices, virtual reality (virtual reality, VR) terminal equipment, augmented reality (augmented reality, AR) terminal equipment, wireless terminals in industrial control (industrial control), wireless terminals in smart home (smart home), etc.
  • the second device may include but not limited to: mobile phone, PAD, smart screen, headset, handheld device with wireless communication function, vehicle-mounted device or wearable device, VR terminal device, AR terminal device, wireless terminal in industrial control, smart An electronic device with a function of playing audio, such as a wireless terminal in a home, etc.
  • the forms of the first device and the second device are not specifically limited in this embodiment of the present application.
  • Fig. 2 is a schematic diagram of an existing audio playback.
  • the first device is connected to the second device through Wi-Fi, but not connected to Bluetooth.
  • the first device can send audio data to the second device through the Wi-Fi channel.
  • the second device can play lossless audio , a in Figure 2 represents lossless audio with the number "123".
  • the Wi-Fi connection between the first device and the second device is disturbed, that is, when the communication quality of the Wi-Fi channel deteriorates, packet loss will occur in the audio data transmitted on the Wi-Fi channel, causing the audio data of the second device to The playback is stuck, as shown in b in Figure 2.
  • the numbers "4, 5, and 8" in b in Figure 2 represent lossless audio
  • the ellipsis represents the second device playing audio freezes. If the number is not played "6 and 7".
  • 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.
  • the first device can send audio data to the second device through the Bluetooth channel, and accordingly, the second device can play the encoded audio from the Bluetooth channel, as shown in c in Figure 2 As shown, the encoded audio is represented by the number "90".
  • the process of manually disconnecting the Wi-Fi connection by the user and connecting the first device and the second device via Bluetooth is not shown in FIG. 2 , and reference may be made to the description in the prior art.
  • the audio heard by the user is coded audio, and the audio is lossy audio. And the user cannot perceive whether the communication quality of the Wi-Fi channel is getting better, so it is impossible to manually connect the first device and the second device to Wi-Fi at an appropriate time, so that the user cannot enjoy lossless audio.
  • the first device and the second device can be connected to Wi-Fi and Bluetooth at the same time, if the first device can adaptively switch and transmit audio data according to the communication quality of the Wi-Fi channel and the communication quality of the Bluetooth channel
  • the channel can not only ensure the fluency of audio playback, but also ensure that users can enjoy lossless audio in time and improve user experience.
  • the embodiment of the present application provides a data transmission method.
  • the first device can communicate based on the communication quality of the Wi-Fi channel and the Bluetooth channel. communication quality, and adaptively switch the channel for transmitting audio data to improve user experience.
  • the audio played by the first device through the second device is an example.
  • the first device can also display files through the second device.
  • the first device can send the file to the second device.
  • the second device may display the file on the interface of the second device in response to receiving the file data.
  • the embodiment of the present application does not limit the services performed by the first device through the second device, that is, does not limit the type of data sent by the first device to the second device.
  • the first device and the second device are "connected via Bluetooth and Wi-Fi" at the same time, and the first device plays audio through the second device as an example for illustration.
  • FIG. 3B is a detailed schematic diagram of FIG. 3A .
  • the first device includes: a host central processing unit (host central processing unit, Host CPU) and a wireless chip.
  • a first Bluetooth controller blue controller, BT controller
  • a first Wi-Fi controller Wi-Fi controller
  • the first Bluetooth controller may be referred to as the first BT controller or the first BT controller
  • the first Wi-Fi controller may be referred to as the first Wi-Fi controller
  • FIG. 3B it is taken as an example that the first Bluetooth controller and the first Wi-Fi controller are integrated on the wireless chip.
  • the Host CPU may include: an application processor (application processor, AP), an audio framework (audio framework, Audio FWK), an advanced Bluetooth audio transmission model protocol (advanced audio distribution profile hardware abstraction) of a hardware abstraction layer layer, A2DP audio HAL), A2DP and audio/video distribution transport protocol (audio/video distribution transport protocol, A2DP and AVDTP), the first integrated management module, quality of service (Quality of Service, QoS) module, the first logical link control and The adaptation layer module (logical link control and adaptation protocol, L2CAP) module, and the kernel layer (kernel).
  • the kernel layer includes: a first transmission control protocol/internet protocol (transmission control protocol/internet protocol, TCP/IP) module.
  • A2DP and AVDTP may include an A2DP module and an AVDTP module.
  • the AP can include at least one application program (application, APP) application package, and the application program can include but not limited to: camera, gallery, calendar, call, map, navigation, bluetooth, music, video, short message, etc., figure 3B shows audio application programs, phone application programs, and video application programs related to audio playback.
  • application application, APP
  • the application program can include but not limited to: camera, gallery, calendar, call, map, navigation, bluetooth, music, video, short message, etc.
  • figure 3B shows audio application programs, phone application programs, and video application programs related to audio playback.
  • Audio FWK used to decode the audio data from the application, and perform resampling, mixing and other processing on the decoded audio data, and send the processed audio data to the A2DP audio HAL.
  • A2DP audio HAL is used to cache audio data, such as A2DP audio HAL can cache audio data in the buffer area buffer of A2DP audio HAL.
  • the A2DP module When the audio data is transmitted through the Bluetooth channel between the first device and the second device, the A2DP module is used to read the audio data from the buffer of the A2DP audio HAL, and encode the audio data to obtain encoded audio data ( Hereinafter referred to as encoded data), the A2DP module can transmit the encoded data to the AVDTP module.
  • An AVDTP module configured to transmit the coded data to the first L2CAP module.
  • the QoS module is used to obtain the communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel.
  • the first fusion management module is used to select to transmit audio data through the Bluetooth channel or the Wi-Fi channel based on the type of audio data, and/or parameters such as the communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel acquired by the QoS module , you can refer to the related description in FIG. 6 below.
  • the first L2CAP module is used to manage the distribution of audio data, so as to realize the transmission of audio data through Bluetooth channel or Wi-Fi channel.
  • the first L2CAP module can send audio data to the first BT controller.
  • the first L2CAP module may send audio data to the first BT controller through a first host controller interface (host controller interface, HCI).
  • the first HCI is located between the Host CPU and the wireless chip, and is used to realize data transmission between the Host CPU and the wireless chip. A part of the first HCI is located at the Host CPU, and another part is located at the wireless chip Controller. The first HCI is not shown in FIG. 3B HCI.
  • the first L2CAP module can read the audio data from the A2DP audio HAL, and send the audio data to the first Wi-Fi through the first TCP/IP module.
  • Fi controller sends audio data.
  • the first TCP/IP module is also used to assist the first device and the second device to establish a Wi-Fi-based transport layer data path.
  • the above first A2DP and AVDTP, the first L2CAP module, and the first TCP/IP module may be referred to as a connection management module.
  • the second device includes: a host central processing unit (Host CPU), a second BT controller, a second Wi-Fi controller, a codec module, and a player.
  • the second BT controller and the second Wi-Fi controller can also be integrated on one chip.
  • FIG. 3B the independent setting of the second BT controller and the second Wi-Fi controller is taken as an example.
  • the codec module is used to decode the audio data and send the decoded audio data to the player.
  • Player used to play audio.
  • the Host CPU in the second device includes: a second L2CAP module and a second TCP/IP module.
  • the second L2CAP module is used to send the received audio data to the codec module, so that the codec module decodes the received audio data.
  • the second TCP/IP module is used to assist the first device and the second device to establish a Wi-Fi-based transport layer data path.
  • the Host CPU in the second device may further include: a second fusion management module.
  • the second fusion management module is used to construct and maintain a buffer, which is used to buffer audio data.
  • a buffer which is used to buffer audio data.
  • the Bluetooth path may include: a Bluetooth access layer link and an L2CAP channel corresponding to the Bluetooth path.
  • the Wi-Fi path may include: a Wi-Fi access layer link, a socket (socket) connection, and an L2CAP channel corresponding to the Wi-Fi path.
  • the process of establishing a Bluetooth channel between the first device and the second device may include:
  • Step 1 The user turns on the Bluetooth function of the mobile phone and the Bluetooth function of the speaker.
  • Step 2 The mobile phone scans and searches for the logo of the speaker, and the user operates on the mobile phone or the speaker to make the Bluetooth connection between the mobile phone and the speaker.
  • the mobile phone and the speaker can establish a Bluetooth access layer link.
  • the AVDTP module in the mobile phone can send an instruction to the first L2CAP module to establish an L2CAP channel corresponding to the Bluetooth path, and the first L2CAP module responds to the instruction to establish an L2CAP channel, and the L2CAP channel is used to transmit data from the AVDTP module.
  • the process of establishing a Wi-Fi path between the first device and the second device may include:
  • Step 1a Based on the peer-to-peer (P2P) protocol, the mobile phone acts as a GO (group owner), and sends parameters such as user name, password and encryption method to the speaker through Bluetooth messages.
  • P2P peer-to-peer
  • Step 2a The speaker acts as a GC (group client), and joins the P2P network of Mobile GO through the "user name, password, encryption method and other parameters" in the above step 1a.
  • step 1a can be replaced with step 1b: based on the peer-to-peer (P2P) protocol, the speaker does (group owner, GO), and sends parameters such as user name, password and encryption method to the cell phone.
  • step 2a can be replaced with step 2b: the mobile phone acts as a GC (group client), and joins the P2P network of the speaker GO through the "user name, password, encryption method and other parameters" in the above step 1b.
  • P2P peer-to-peer
  • the mobile phone and the sound box can successively establish a Wi-Fi access layer link and a socket connection between the first TCP/IP module and the second TCP/IP module.
  • 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 path, and the first L2CAP module responds to the instruction to establish an L2CAP channel, and the L2CAP channel is used to map the mobile phone and the speaker TCP/IP connection (socket connection) between.
  • the first device and the second device have established a Bluetooth path and a Wi-Fi path.
  • the data transmission method provided by the embodiment of the present application will be described below in combination with specific embodiments. The following several embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments.
  • FIG. 6 is a schematic flow chart of an embodiment of a data transmission method provided in an embodiment of the present application.
  • the data transmission method provided by the embodiment of the present application may include:
  • the application sends audio data to the A2DP audio HAL through the Audio FWK in response to receiving an audio playback instruction.
  • the user can operate on the first device to control the second device to play audio.
  • the user may open an audio application on the first device, select audio A, and control the second device to play audio A.
  • the application program responds to the instruction of playing audio input by the user. If the first device has audio data locally stored, the application program can obtain the audio data locally. If the first device does not store audio data, the application program can obtain the audio data from the audio class The audio data is downloaded from the server corresponding to the application program, and the process of obtaining the audio data by the application program is not described in this embodiment.
  • Audio FWK Applications can send audio data to A2DP audio HAL through Audio FWK.
  • the application 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 way of Audio FWK decoding audio data may include but not limited to: pulse code modulation (pulse code modulation, PCM), or lossless audio codec (free lossless audio codec), etc.
  • the audio data decoded by the Audio FWK is PCM audio data as an example for illustration.
  • the Audio FWK can send the PCM audio data to the A2DP audio HAL.
  • A2DP audio HAL caches audio data.
  • the A2DP audio HAL caches the PCM audio data, for example, the A2DP audio HAL can cache the PCM audio data in the buffer of the A2DP audio HAL.
  • the first fusion management module determines a target channel for transmitting audio data according to the target parameter.
  • the target parameter may be related to any of the following: the type of audio data, and/or, the communication quality of the Bluetooth channel, and/or, the communication quality of the Wi-Fi channel, the operating mode of the first device, and the communication quality of the second device. run mode.
  • the target path may be a Bluetooth path and/or a Wi-Fi path.
  • the types of audio data may include: high-definition (high-quality) audio and non-high-definition (non-high-quality) audio.
  • high-definition audio can meet conditions such as condition 1 or condition 2:
  • 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.
  • Condition 2 The sampling rate is greater than or equal to 96KHz, the bit width is greater than or equal to 16bit and less than 24bit, and the channel is greater than or equal to 2.
  • bit width in condition 1 and condition 2 is a parameter used to measure sound fluctuations in audio.
  • Audio FWK when Audio FWK sends PCM audio data to A2DP audio HAL, it can send audio parameters of PCM audio data to A2DP audio HAL, and the audio parameters include sampling rate, bit width and channel.
  • the A2DP audio HAL can send the audio parameters of the PCM audio data to the first fusion management module in response to receiving the audio parameters of the PCM audio data, so that the first fusion management module can obtain the audio parameters of the PCM audio data, that is, the audio sampling rate, The bit width and channel, and then the first fusion management module can acquire the type of audio data based on the audio parameters.
  • the Host CPU includes a QoS module
  • the QoS module is used to obtain the communication quality of the Bluetooth path and the communication quality of the Wi-Fi path. Therefore, the first fusion management module can obtain the communication quality from the QoS "Communication quality of Bluetooth channel and communication quality of Wi-Fi channel" is read in the module.
  • the communication quality of the Bluetooth channel can be characterized by at least one of the following parameters of the Bluetooth channel: packet error rate (packet error rate, PER), throughput rate. It should be understood that the smaller the packet error rate, the better the communication quality of the bluetooth channel, and the higher the throughput rate, the better the communication quality of the bluetooth channel.
  • the communication quality of the Wi-Fi channel can be characterized by at least one of the following parameters of the Wi-Fi channel: packet error rate (packet error rate, PER) and throughput rate. It should be understood that the communication quality of the Bluetooth channel and the communication quality of the Wi-Fi channel may also be characterized by other parameters, which are not limited in this embodiment of the present application.
  • the first fusion management module determines the target path according to the target parameter, which may be as follows:
  • the first fusion management module may determine the target path according to the type of audio data. Wherein, the first fusion management module may determine that the target path is a Wi-Fi path when the audio data type is high-definition audio. When the first fusion management module responds that the type of audio data is non-high-definition audio, it may determine that the target channel is a Bluetooth channel.
  • high-definition audio can be used as a preset type, and the preset type has a mapping relationship with a Wi-Fi path. Therefore, when the first fusion management module responds to the type of audio data being high-definition audio, it can determine that the target path is Wi-Fi access. Similarly, when the first fusion management module responds that the type of audio data is non-high-definition audio (ie, non-preset type), it can determine that the target channel is a Bluetooth channel, and the non-preset type has a mapping relationship with the Bluetooth channel.
  • the preset type may be other predefined audio types, which is not limited in this embodiment of the present application, and the above description is made by taking the audio data of the preset type as high-definition audio as an example. or,
  • the first fusion management module can determine the target path according to the communication quality of the Bluetooth path and the communication quality of the Wi-Fi path. Taking the packet error rate as an example, when the first fusion management module detects that the packet error rate of the Bluetooth path is greater than or equal to the first preset packet error rate, and the packet error rate of the Wi-Fi path is less than the second preset packet error rate, It may be determined that the target path is a Wi-Fi path. Wherein, the first preset packet error rate may be the same as the second preset packet error rate, or the first preset packet error rate may be greater than the second preset packet error rate.
  • the target can be determined
  • the path is the bluetooth path.
  • the packet error rate of the Bluetooth path is greater than or equal to the first preset packet error rate can be used to characterize: the communication quality of the Bluetooth path is greater than or equal to the preset communication quality of the Bluetooth path, that is, the communication is characterized by the packet error rate In terms of quality, the first preset packet error rate is used to characterize the preset communication quality of the Bluetooth channel.
  • the packet error rate of the Wi-Fi path is less than the second preset packet error rate can be used to characterize: the communication quality of the Wi-Fi path is less than the preset communication quality of the Wi-Fi path, that is to say, the communication quality is characterized by the packet error rate
  • the second preset packet error rate is used to characterize the preset communication quality of the Wi-Fi channel. It should be noted that both the first preset packet error rate and the second preset packet error rate are preset values. or,
  • the first fusion management module may determine the target path according to the communication quality of the Wi-Fi path. Taking the packet error rate as an example, when the first fusion management module detects that the packet error rate of the Wi-Fi path is less than the second preset packet error rate, it can determine that the target path is a Wi-Fi path. Alternatively, the first fusion management module may determine the target path according to the communication quality of the Bluetooth path. Taking the packet error rate as an example, when the first fusion management module detects that the packet error rate of the Bluetooth path is lower than the second preset packet error rate, it can determine that the target path is the Bluetooth path. or,
  • the first fusion management module may determine the target path according to the type of audio data, and the communication quality of the Bluetooth path and the communication quality of the Wi-Fi path.
  • the first fusion management module can determine that the path to be selected is a Wi-Fi path in response to the type of audio data being high-definition audio, and if the packet error rate of the Wi-Fi path is less than the second preset error rate packet rate, the first fusion management module determines that the target path is a Wi-Fi path.
  • the first fusion management module can determine that the path to be selected is a Bluetooth path in response to the type of audio data being non-high-definition audio. If the packet error rate of the Bluetooth path is less than the second preset packet error rate, the first fusion management module The module determines that the target channel is a Bluetooth channel.
  • the first fusion management module may determine that the target path is a Bluetooth path. That is to say, when at least one of the first device and the second device is switched to the low power consumption mode, the first fusion management module can determine that the target channel is a Bluetooth channel. It should be noted that when the second device switches to the low power consumption mode, the second device may send information to the first device, and the information is used to indicate that the operation mode of the second device is the low power consumption mode. In response to receiving the information, the first device may determine that the second device enters a low power consumption mode.
  • the first device when the first device and/or the second device enters the low power consumption mode, the first device transmits audio data through the bluetooth channel.
  • the first Wi-Fi controller in the first device when the first device enters the low power consumption mode, the first Wi-Fi controller in the first device is in a dormant state, and when the second device enters the low power consumption mode, the first Wi-Fi controller in the second device The second Wi-Fi controller is dormant.
  • the first device may determine that the target path is a Wi-Fi path.
  • the devices entering the low power consumption mode are the first device and the second device, then the first device may determine that the target path is Wi-Fi in response to detecting that both the first device and the second device have exited the low power consumption mode. path.
  • the first fusion management module sends an encoding instruction to the A2DP module.
  • the first fusion management module determines that the target path is a 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 audio data from the A2DP audio HAL and encode the audio data.
  • the first fusion management module may synchronize the target path with the first L2CAP module in response to the target path being a Bluetooth path.
  • the first fusion management module may synchronize the target path with the first L2CAP module by sending the identifier of the target path to the first L2CAP module.
  • the first fusion management module may send the identifier 1 to the first L2CAP module to synchronize the target path to the first L2CAP module as the Bluetooth path.
  • the A2DP module reads audio data from the A2DP audio HAL in response to receiving the encoding instruction, encodes the audio data, and obtains encoded data.
  • the A2DP module reads audio data (that is, PCM audio data) from the A2DP audio HAL in response to receiving the encoding instruction, and can encode the PCM audio data to obtain encoded data.
  • audio data that is, PCM audio data
  • encoded data can be understood as data after encoding PCM audio data.
  • the manner in which the A2DP module encodes PCM audio data may not be limited to: sub-band coding (sub-band coding, SBC), advanced audio coding (advanced audio coding, ACC), etc., the embodiment of the present application There is no limit to this.
  • the A2DP module sends the coded data to the AVDTP module.
  • the AVDTP module sends the coded data to the first L2CAP module.
  • the first L2CAP module sends encoded data to the first BT controller.
  • the data from the AVDTP module is encoded data
  • the first L2CAP module receives the encoded data from the AVDTP module, and can determine to send the encoded data through the bluetooth path, and accordingly the first L2CAP module responds to receiving To the coded data from the AVDTP module, the coded data can be sent to the first BT controller through the first HCI.
  • the first L2CAP module can receive the target path synchronized from the first fusion management module, the first L2CAP module receives the encoded data from the AVDTP module, and can determine that the target path is a Bluetooth path, so the first In response to receiving the encoded data from the AVDTP module, the L2CAP module may send the encoded data to the first BT controller through the first HCI.
  • the first BT controller sends encoded data to the second BT controller.
  • the first BT controller may convert the encoded data into a radio frequency signal for transmission.
  • the processing process of the encoded data by the first BT controller is not described in detail, and reference may be made to the processing process of the data by the first BT controller in the prior art.
  • the second BT controller sends the encoded data to the second L2CAP module in response to the encoded data from the first BT controller.
  • 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.
  • the second BT controller can receive encoded data from the first BT controller.
  • the second BT controller may convert the radio frequency signal to obtain coded data.
  • the second BT controller obtains the encoded data, and can send the encoded data to the second L2CAP module through the second HCI.
  • the second L2CAP module sends encoded data to the codec module.
  • the codec module decodes the coded data to obtain audio data.
  • the codec module can decode the coded data to obtain PCM audio data.
  • the codec module sends the audio data to the player.
  • S604-S613 and “S614-S619” may be performed alternatively, or in one embodiment, “S604-S613" and “S614-S619” may be performed simultaneously Steps, you can refer to the following descriptions in FIG. 9 and FIG. 11 .
  • the first fusion management module synchronizes the target path to the first L2CAP module as a Wi-Fi path.
  • the first fusion management module may synchronize the target path to the first L2CAP module by sending the identifier of the target path to the first L2CAP module.
  • the first fusion management module may send the identifier 2 to the first L2CAP module to synchronize the target path to the first L2CAP module as the Wi-Fi path .
  • the first L2CAP module reads audio data from the A2DP audio HAL.
  • the first L2CAP module can determine that the target path is a Wi-Fi path, and then the first L2CAP module can read from the A2DP audio HAL in response to receiving the identification of the target path from the first fusion management module, such as 2 Get PCM audio data.
  • the first L2CAP module sends audio data to the first Wi-Fi controller through the first TCP/IP module.
  • the first Wi-Fi controller sends audio data to the second Wi-Fi controller.
  • the first Wi-Fi controller may convert the PCM audio data into a radio frequency signal for transmission.
  • the processing process of the PCM audio data by the first Wi-Fi controller is not described in detail, and the data processing process of the first Wi-Fi controller in the prior art may be referred to.
  • the second Wi-Fi controller sends 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.
  • the second Wi-Fi controller can receive PCM audio data from the first Wi-Fi controller.
  • the second Wi-Fi controller may convert the radio frequency signal to obtain PCM audio data in response to the radio frequency signal from the first Wi-Fi controller.
  • the second Wi-Fi controller obtains the PCM audio data, and can send the PCM audio data to the second L2CAP module through the second TCP/IP module.
  • the second L2CAP module sends the audio data to the player.
  • the player plays audio based on the audio data.
  • the player may be based on the PCM audio data, and the audio playback process may refer to the existing audio player playback process, which will not be described in this embodiment of the present application.
  • the audio data described in S601-S620 in the embodiment of the present application may be referred to as first audio data or second audio data transmitted after the target path is determined.
  • the player playing the audio based on the audio data may 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.
  • the first fusion management module in the first device can determine the target path for transmitting audio data according to the target parameters, which can be used to ensure the communication of the Wi-Fi path
  • the first device sends PCM audio data to the second device through the Wi-Fi channel, so that the second device can play high-definition audio.
  • the first device can send coded data to the second device through the Bluetooth channel to ensure that the second device does not freeze when playing audio.
  • the first device can switch the channel for transmitting audio data according to the target parameters, which can ensure that the user can enjoy high-definition audio while ensuring the fluency of audio playback in an interference environment and avoiding audio stuttering. Can improve user experience.
  • the first device determines the target path and transmits the audio data through the target path.
  • the process of the first device transmitting the audio data through the target path is further introduced below. It should be understood that the first device may switch between the Bluetooth path and the Wi-Fi path according to the target parameter, and for a specific process, reference may be made to relevant descriptions in the following embodiments.
  • the first device can transfer the path for transmitting audio data from the second wireless path to A wireless path is switched to a second wireless path, and then the second wireless path is used to transmit audio data.
  • the first wireless path can be a Bluetooth path or a Wi-Fi path.
  • the second wireless path is a Wi-Fi path.
  • the first wireless path is a Wi-Fi path
  • the second wireless path is a Wi-Fi path.
  • the wireless path is a Bluetooth path.
  • the first wireless path is a Bluetooth path
  • the first fusion management module executes S603 to determine that the target path is a Wi-Fi path, referring to FIG. 7, the following steps can be performed:
  • the first fusion management module synchronizes the target path to the first L2CAP module as a Wi-Fi path, and sends stop sending information to the first L2CAP module.
  • the first fusion management module synchronizes the target path to the first L2CAP module as a Wi-Fi path.
  • the first fusion management module synchronizes the target path to the first L2CAP module as Wi-Fi During the access, it may also send stop sending information to the first L2CAP module.
  • the first L2CAP module sends stop sending information to the first BT controller.
  • the stop sending information is used to instruct the first BT controller to feed back the completion information to the first L2CAP module after sending the encoded data from the first L2CAP module.
  • the first BT controller feeds back completion information to the first L2CAP module when the encoded data is sent.
  • the encoded data sent by the first BT controller in S703 may be called the first audio data.
  • the encoded data sent by the first BT controller in S703 may be called the second audio data. It should be understood that the data sent before the first device switches the target path becomes the first audio data, and the data sent after the path is switched is the second audio data.
  • the first BT controller may continue to send the received coded data from the first L2CAP module in response to receiving the stop sending information, and when the coded data transmission is completed, feedback completion information to the first L2CAP module.
  • the first L2CAP module feeds back completion information to the first fusion management module.
  • the first L2CAP module executes S615-S619, and S620 in response to receiving the completion information.
  • the audio data in "S615-S619, and S620" executed again by the first L2CAP module in the embodiment of the present application may be referred to as second audio data. It should be noted that the first audio data and the second audio data may belong to different parts of the same audio or belong to different audio.
  • S701-S705 may refer to what is shown in FIG. 8 .
  • Shown in a in Figure 8 is that the first L2CAP module sends audio data through the bluetooth channel
  • shown in b in Figure 8 is the process of interaction between the first L2CAP module, the first fusion management module, and the first BT controller, that is A process in which the first L2CAP module switches the channel for transmitting audio data from the Bluetooth channel to the Wi-Fi channel.
  • c in FIG. 8 shows that the first L2CAP module uses the Wi-Fi channel to send audio data. It should be understood that the modules shown in Figure 8 are part of the modules shown in Figure 3B.
  • the first wireless path is a Wi-Fi path
  • the first fusion management module executes S603 to determine that the target path is a Bluetooth path
  • the following steps may be performed:
  • the first fusion management module synchronizes the target channel to the first L2CAP module as the Bluetooth channel, and sends stop sending information to the first L2CAP module.
  • the first L2CAP module sends stop sending information to the first Wi-Fi controller.
  • 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.
  • the first Wi-Fi controller responds to receiving the stop sending information, and feeds back completion information to the first L2CAP module when sending the PCM audio data.
  • the first Wi-Fi controller may continue to send the received PCM audio data from the first L2CAP module in response to receiving the stop sending information, and when the sending of the PCM audio data is completed, feedback completion information to the first L2CAP module.
  • the first L2CAP module feeds back completion information to the first fusion management module.
  • the first L2CAP module executes S604-S613 and S620 in response to receiving the completion information.
  • the first L2CAP module when the first L2CAP module determines to switch the path to transmit audio data, it may send a stop sending message to the controller corresponding to the first wireless path currently in use, so that the controller corresponding to the first wireless path will After the audio data transmission of the L2CAP module is completed, the completion information is fed back to the first L2CAP module, and the first L2CAP module can use the second wireless channel to transmit data in response to receiving the completion information, and can realize switching of wireless channels.
  • the first L2CAP module when the first L2CAP module switches channels to transmit audio data, the first L2CAP module needs to use the target channel to send data after the first Wi-Fi controller or the first BT controller sends data, which will cause The time between the audio data transmitted by the first wireless channel and the audio data transmitted by the second wireless channel is long, which causes the playback of the second device to pause and poor user experience.
  • the method in the following "second" ie, Figure 9) can be used to solve this problem and reduce the audio playback delay caused by channel switching:
  • the first wireless path is a Bluetooth path
  • the first fusion management module executes S603 to determine that the target path is a Wi-Fi path, referring to FIG. 9, the following steps can be performed :
  • the first integrated management module acquires audio data from the A2DP audio HAL.
  • the first fusion management module can obtain audio data from the buffer of the A2DP audio HAL.
  • the first fusion management module copies the audio data into two copies, and marks the audio data, and the two copies of the audio data have the same marks.
  • the first fusion management module copies the audio data obtained from the A2DP audio HAL into two copies, namely 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 is the same as the identification of the second audio data.
  • the first fusion management module can number the first audio data and the second audio data, if they are respectively numbered SN1, then the first fusion management module can obtain two audio data numbered SN1.
  • the audio data obtained by the first integration management module from the A2DP audio HAL may be called the second audio data.
  • S903 executes "S604, S605A, S606-S610" for one piece of audio data, and execute "S614, S615A, S616-S618" for one piece of audio data.
  • the A2DP module reads the audio data from the first fusion management module in response to receiving the encoding instruction, encodes the audio data, and obtains encoded data.
  • the first fusion management module can send the identification of the audio data to the A2DP module, and the A2DP module encodes the audio data without encoding the audio data.
  • the identifier is encoded to obtain encoded data, and the identifier of the encoded data is the identifier of the audio data.
  • the first L2CAP module reads audio data from the first fusion management module.
  • the A2DP module in S605A needs to obtain data from the first fusion management module.
  • the first L2CAP module in S615A needs to obtain data from the first fusion management module.
  • the first fusion management module can send the identification of the audio data to the first L2CAP module, and the first L2CAP module receives the information from the first fusion management module.
  • the audio data is read, and the identifier of the audio data is the identifier of the audio data from the first fusion management module.
  • the second L2CAP module can receive two copies of audio data with the same number. It should be understood that the specific processes of "S604, S605A, S606-S610” and “S614, S615A, S616-S618" are not shown in FIG. 9, and reference may be made to relevant descriptions in the foregoing embodiments.
  • the second L2CAP module In response to receiving the audio data with the same identifier, the second L2CAP module sends information with the same identifier to the second fusion management module.
  • the second L2CAP module can receive the audio data from the second BT controller and the second Wi-Fi controller respectively, when the second L2CAP module receives the audio data with the same identification, it can determine that the first device is passing through Wi-Fi The audio data is sent through the channel, and based on the identification of the audio data, it can be determined that the audio data is continuous without packet loss, and the problem of jamming and pause can be avoided.
  • the second L2CAP module When the second L2CAP module responds to receiving audio data with the same identifier, it may send information with the same identifier to the second fusion management module.
  • the same identification information is used to indicate that the second L2CAP module receives audio data with the same identification from the Bluetooth channel and the Wi-Fi channel.
  • the second fusion management module In response to receiving the information with the same identifier, the second fusion management module sends information to stop using the Bluetooth path to the first BT controller through the second L2CAP module and the second BT controller.
  • the information of stopping using the Bluetooth path is used to indicate to send audio data through the Wi-Fi path, and stop using the Bluetooth path to send audio data, so as to reduce power consumption of the first device.
  • the first BT controller responds to receiving the information of stopping using the Bluetooth path, and feeds back the information of stopping using the Bluetooth path to the first fusion management module through the first L2CAP module.
  • the first fusion management module executes S614-S619, and S620 in response to receiving the information of stopping using the Bluetooth channel.
  • the second fusion management module may also send information to the first Wi-Fi controller to stop using the Bluetooth channel through the second L2CAP module and the second Wi-Fi controller in response to receiving the same information , 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.
  • S901-S907 may refer to what is shown in FIG. 10 .
  • Shown in a in Figure 10 is that the first L2CAP module sends audio data through the Bluetooth channel
  • shown in b in Figure 10 is that after the first fusion management module executes S603 to determine that the target channel is a Wi-Fi channel, it can send audio data through the Bluetooth channel respectively.
  • Channel and Wi-Fi channel send the same audio data.
  • the second L2CAP module can send information to the first BT controller to stop using the Bluetooth channel after receiving the audio data with the same identifier, so that the first device can send audio through the Wi-Fi channel data.
  • the audio data in "S614-S619, and S620" executed again by the first L2CAP module may 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 may belong to different parts of the same audio or belong to different audio.
  • the first wireless path is a Wi-Fi path
  • the first fusion management module executes S603 to determine that the target path is a Bluetooth path
  • the following steps may be performed:
  • the first fusion management module acquires audio data from the A2DP audio HAL.
  • the first fusion management module copies the audio data into two copies, and marks the audio data, and the two copies of the audio data have the same marks.
  • S903A executes "S604, S605A, S606-S610" for one piece of audio data, and execute "S614, S615A, S616-S618" for one piece of audio data.
  • the second L2CAP module In response to receiving the audio data with the same identifier, the second L2CAP module sends information with the same identifier to the second fusion management module.
  • the second fusion management module In response to receiving the information with the same identifier, the second fusion management module sends information to stop using the Wi-Fi path to the first BT controller through the second L2CAP module and the second BT controller.
  • the information of stopping using the Wi-Fi path is used to indicate to send audio data through the Bluetooth path, and stop using the Wi-Fi path to send audio data, so as to reduce power consumption of the first device.
  • the first BT controller responds to receiving the information of stopping using the Wi-Fi path, and feeds back the information of stopping using the Wi-Fi path to the first fusion management module through the first L2CAP module.
  • the first fusion management module executes S604-S613, and S620 in response to receiving the information of stopping using the Wi-Fi path.
  • the steps shown in S901A-S907A above may be applicable to the scenario where "the first device switches to the low power consumption mode, and the first fusion management can determine that the target channel is the Bluetooth channel".
  • the second fusion management module in response to receiving the information with the same identification, may also send the information of stopping using the Bluetooth path 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.
  • the first fusion management module when the first fusion management module determines to switch the first wireless path to the second wireless path to transmit audio data according to the target parameters, the first fusion management module can copy the audio data in the A2DP audio HAL to have the same identification After the second L2CAP module receives the audio data with the same identifier, the second L2CAP module can then notify the first device to stop using the first wireless channel to transmit audio data. In this embodiment, the two channels can be avoided.
  • the problem of long audio data connection time ensures the smoothness of audio playback on the second device, which can improve user experience.
  • the first fusion management module can determine whether to switch the path for transmitting audio data according to the target parameter, and determine whether the target path is a Bluetooth path or a Wi-Fi path, and then the first The device can adaptively switch the transmission channel of audio data. On the basis of enabling users to enjoy high sound quality, it can also ensure the smoothness of audio playback in interference environments, avoid audio playback stuttering, and improve user experience.
  • the embodiment of the present application also provides a data transmission method.
  • the first fusion management module does not need to determine whether the target path is a Bluetooth path or a Wi-Fi path based on the target parameters, but directly connects the Bluetooth path and the Wi-Fi path.
  • the channels are all used as the target channel, and the audio data in the A2DP audio HAL is copied into two copies, which are transmitted through the Bluetooth channel and the Wi-Fi channel respectively.
  • the second device can process and play based on the received audio data.
  • FIG. 11 is a schematic flowchart of another embodiment of the data transmission method provided by the embodiment of the present application.
  • the data transmission method provided by the embodiment of the present application may include:
  • the application transmits audio data to the A2DP audio HAL through the Audio FWK in response to receiving an audio playback instruction.
  • A2DP audio HAL buffers audio data.
  • the first fusion management module acquires audio data from the A2DP audio HAL.
  • the first fusion management module copies the audio data into two copies, and marks the audio data, and the two copies of the audio data have the same marks.
  • the second L2CAP module stores the first data in the buffer of the second fusion management module 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 identifier , discarding the second data.
  • the second fusion management module is used for constructing and maintaining a buffer, and the buffer is used for storing audio data, and the buffer may be called an audio buffer.
  • the second fusion management module can pre-set a water flow value (water flow) for the buffer to ensure the stability of audio playback. It can be understood that the watermark value can represent the minimum data amount of audio data stored in the buffer.
  • the second Wi-Fi controller can receive audio data from the first Wi-Fi controller
  • the second BT controller can receive audio data from the first BT controller
  • the second L2CAP module Audio data from the second Wi-Fi controller and the second BT controller can be received.
  • the first The second L2CAP module may store the first data in the buffer of the second fusion management module, and discard the second data.
  • the second L2CAP module receives the first data and the second data with the same identification, that is, the audio data transmission is not lost, so the second L2CAP module can use the first data to play audio in order to enable users to enjoy high-definition audio , Discarding the second data will not cause audio lag, and can also reduce the storage pressure of the buffer.
  • the audio data in the buffer of the second fusion management module is used to make the player play audio.
  • the player can read the audio data from the buffer of the second fusion management module, and play the audio.
  • the process for the player to read the audio data from the buffer of the second fusion management module may be as follows: the player may take out the audio data from the buffer of the second fusion management module and play it. In this way, when the second fusion management module stores the audio data in the buffer of the second fusion management module, the player can take out the data from the buffer of the second fusion management module to play.
  • the data volume of the audio data in the buffer of the second fusion management module is not always accumulated, but is related to the speed at which the second fusion management module stores audio and the speed at which the player takes out the audio data.
  • the second L2CAP module decodes the audio data from the second BT controller and stores it in the buffer of the second fusion management module in response to the data volume of the audio data in the buffer of the second fusion management module being less than the watermark value .
  • the second Wi-Fi controller cannot receive audio data from the first Wi-Fi controller, and accordingly, the second L2CAP module cannot receive audio data from the second Wi-Fi controller .
  • the second L2CAP module does not receive the audio data from the second Wi-Fi controller, it will not store the audio data in the buffer of the second fusion management module, and the player plays the audio, causing the second The amount of audio data in the buffer of the second fusion management module gradually decreases.
  • the second L2CAP module can decode the audio data from the second BT controller through the codec module and save it. into the buffer of the second fusion management module to increase the amount of data in the buffer of the second fusion management module.
  • the second L2CAP module decodes the audio data from the second BT controller. It can be understood that the second L2CAP module sends the audio data from the second BT controller to the codec module, so that the codec module can decode the audio data from the second BT controller. The audio data of the second BT controller is decoded to obtain PCM audio data.
  • the player reads the audio data from the buffer of the second fusion management module, and plays the audio.
  • the buffer of the second fusion management module stores PCM audio data.
  • the player can read PCM audio data from the buffer of the second fusion management module, and then play audio based on the PCM audio data.
  • S1101-S1108 may refer to what is shown in FIG. 12 .
  • Shown in a in FIG. 12 is that the first device sends audio data to the second device through the first BT controller and the first Wi-Fi controller respectively.
  • the second L2CAP module can store the first data in the first In the buffer of the second fusion management module, the second data is discarded.
  • the communication quality of the Wi-Fi path is poor, the amount of audio data in the buffer of the second fusion management module will gradually decrease.
  • the second L2CAP module responds The amount of audio data in the buffer of the second fusion management module is less than the watermark value, and the audio data from the second BT controller is decoded and stored in the buffer of the second fusion management module. It should be understood that “ ⁇ ” in b of FIG. 12 indicates 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.
  • the first fusion management module detects that the communication quality of the Bluetooth channel is also lower than the preset communication quality of the Bluetooth channel.
  • the audio The data is encoded and then transmitted.
  • both the Wi-Fi channel and the Bluetooth channel transmit encoded audio data, that is, encoded data. It should be understood that, in this embodiment, the encoding manners of the encoded data transmitted over the Wi-Fi channel and the encoded data transmitted over the Bluetooth channel may be the same or different.
  • the coded data transmitted over the Bluetooth channel is obtained through A2DP encoding
  • the encoded data transmitted over the Wi-Fi channel may be obtained through A2DP encoding, or through other encoding modules in the first device, as follows
  • the encoding manner of the encoded data transmitted over the Wi-Fi channel and the encoded data transmitted over the Bluetooth channel may be the same as an example for illustration.
  • S1105 can be replaced with S1105A: execute "S604, S605A, S606-S610" for one piece of audio data, and "S614, S604A, S605A, S606-S607” for one piece of audio data. , and S616A-S618A".
  • the first fusion management module sends an encoding instruction to the A2DP module.
  • the first L2CAP module sends encoded data to the first Wi-Fi controller through the first TCP/IP module.
  • the first Wi-Fi controller sends encoded data to the second Wi-Fi controller.
  • 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.
  • the second L2CAP module can receive encoded data from the second BT controller, and encoded data from the second Wi-Fi controller.
  • S1106-S1108 can be replaced by S1106A-S1108A:
  • the second L2CAP module decodes the first data and stores it in the second fusion management In the buffer of the module, and discard the second data.
  • the second L2CAP module can decode the first data in response to receiving the first data and the second audio data with the same identifier After processing, it is stored in the buffer of the second fusion management module, and the second data is discarded.
  • the second L2CAP module responds to the data volume of the audio data in the buffer of the second fusion management module being less than the watermark value, decodes the audio data from the second BT controller and stores it in the buffer of the second fusion management module .
  • S1108 may be executed.
  • S1101-S1104, S1105A-S1107A, and S1108 can refer to what is shown in FIG. 13 .
  • the encoded data from the second Wi-Fi controller in Figure 13 needs to be decoded and stored in the buffer of the second fusion management module.
  • the first device sends encoded data to the second device through the first BT controller and the first Wi-Fi controller respectively.
  • the second L2CAP module can decode 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 identifier (such as number SN1) Store it in the buffer of the second fusion management module, and discard the second data.
  • the second L2CAP module when the second L2CAP module responds to receiving audio data with the same identifier, it can preferentially store the audio data from the second Wi-Fi controller into the buffer of the second fusion management module, so that the player can Play audio based on the audio data from the second Wi-Fi controller, so that the user can enjoy high-definition audio.
  • the second L2CAP module can edit the audio data from the second BT controller After decoding by the decoding module, it is stored 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, so as to ensure the smoothness of audio playback, and the audio playback does not freeze.
  • the above S1106-S1107 can be replaced with S1106B: the second L2CAP module 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, then the second fusion management module can store the audio data from the second Wi-Fi controller in the buffer of the second fusion management module, discard Audio data from the second BT controller. Similarly, if the buffer of the second fusion management module does not contain the second identification and contains the first identification, the second fusion management module can store the audio data from the second BT controller into the buffer of the second fusion management module , discarding audio data from the second Wi-Fi controller.
  • the audio data numbered SN1 and SN2 have been stored in the buffer of the second fusion management module, wherein the audio data numbered SN1 comes from the second Wi-Fi controller, The audio data numbered SN2 comes from the second BT controller.
  • 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 identifier "number" not included in the buffer of the second fusion management module is SN3", already contains the identification "number is SN2", then 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 from the second Wi-Fi The number of the controller is the audio data of SN2.
  • the second L2CAP module can store the audio data of the preferentially received logo into the buffer of the second fusion management module based on the logo of the received audio data, so as to ensure the fluency of audio data playback.
  • the data transmission method provided by the embodiment of the present application may include:
  • the first device sends first audio data to the second device through the first wireless channel, and the first audio data is used by the second device to play the first audio.
  • the first device and the second device have established a first wireless path and a second wireless path, the first wireless path is a Bluetooth path or a Wi-Fi path, the second wireless path is a Bluetooth path or a Wi-Fi path, the first wireless path and the The second wireless path is different.
  • the first device can play audio through the second device.
  • the first device sends the first audio data to the second device through the first wireless path.
  • the first audio data is used by the second device to play the first audio.
  • the first device sends the second audio data to the second device through the second wireless path
  • the target parameter is related to at least one of the following items: the first wireless path communication quality of the second wireless channel, the operating mode of the first device, and the operating mode of the second device, and the second audio data is used by the second device to play the second audio.
  • the target parameter is related to at least one of the following: the communication quality of the first wireless path, the communication quality of the second wireless path, the operating mode of the first device, and the operating mode of the second device, and the second audio data is used for playing by the second device
  • the target parameters can refer to the relevant descriptions in the foregoing embodiments.
  • the target parameter is also related to the type of audio data
  • the type of audio data may be: high-definition or non-high-definition, and reference may be made to relevant descriptions in the foregoing embodiments.
  • the first device determines the target path according to the target parameter, reference may be made to related descriptions in S603.
  • the first device determines that the target path of data transmission is the second wireless path according to the target parameter, the first device sends the second audio data to the second device through the second wireless path, and reference may be made to relevant descriptions in the foregoing embodiments.
  • the second audio data and the first audio data can be data in the same audio. If the audio is a song, the first device can first send a part of the audio data in the song to the second device, and then send the audio data in the song to the second device. A portion of the audio data, so that the second device can play the song based on the audio data from the first device. Or, the second audio data and the first audio data can be data in different audio, such as the first audio data is the audio data corresponding to the end of a song, and the second audio data is the audio data corresponding to the beginning of another song .
  • the first device before the first device sends the first audio data to the second device through the first wireless channel, it also needs to determine the target channel for transmitting the first audio data as the first wireless channel through the target parameter, which can be referred to in S603. related description.
  • the first device 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 parameters, which can ensure that the user can enjoy high-definition audio while ensuring the quality of the audio in the interference environment.
  • the smoothness of audio playback and the avoidance of audio stuttering can improve user experience.
  • the first device before sending the second audio data to the second device through the second wireless path, the first device may detect whether the first audio data has been sent through the first wireless path, and the specific detection For the method, please refer to the relevant descriptions in S701-S705 and S701A-S705A.
  • the first device transmits the second audio data to the second device through the second wireless path in response to detecting that the first audio data has been sent over the first wireless path.
  • the first device may make two copies of the second audio data, which are the first data and the second data respectively, and make two copies of the first data and the second data.
  • the two data are labeled with the same identifier.
  • the first device sends first data to the second device through the first wireless path, and sends second data to the second device through the second wireless path.
  • the second device in response to receiving the first data and the second data from the first device that the two wireless paths have the same identifier, may send information to the first device to stop using the first wireless path. Additionally, the second device can play a second audio based on data from the second wireless path.
  • the first device may send the third audio data to the second device through the second wireless path.
  • the second device may play the third audio in response to receiving the third audio data.
  • the first device may directly send audio data to the second device through the first wireless path and the second wireless path simultaneously without determining the target path through the target parameter.
  • the first wireless path is a Wi-Fi path
  • the second wireless path is a Bluetooth path.
  • the first device makes two copies of the first audio data, namely the first data and the second data, and the first audio data is used by the second device to play the first audio.
  • the first device marks the first data and the second data with the same identifier.
  • the first device sends the first data to the second device through the first wireless path.
  • the first device sends the second data to the second device through the second wireless path.
  • the second device stores the first data in the cache area of the second device.
  • the second device plays the first audio based on the first data in the buffer area.
  • the second device may 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 buffer. Since the audio data from the Wi-Fi channel is unencoded data, users can enjoy high-definition audio.
  • the second device responds to the second device
  • the data volume of the audio data in the buffer area of the second device is less than the watermark value, and the audio data from the bluetooth channel is decoded and stored in the buffer area of the second device.
  • the second device may, according to the first identification of the audio data of the first wireless path from the first device, and the audio data of the second wireless path
  • the second identification of the data if the buffer area of the second device does not contain the first identification and contains the second identification, the second device can store the audio data from the first wireless channel in the buffer area of the second device, discard Audio data from the second wireless channel. In this way, which channel of audio data the second device receives first, the audio data of the channel is preferentially stored in the buffer area of the second device for playback, which can ensure the smoothness of audio data playback.
  • the embodiment of the present application also provides an electronic device, which may be the first device and the second device described in the above embodiments.
  • the electronic device may include: processing A device 161 (such as the Host CPU in the above embodiment), a memory 162, a Bluetooth controller 163, and a Wi-Fi controller 164.
  • the memory 162 may include a high-speed random-access memory (random-access memory, RAM), and may also include a non-volatile memory (non-volatile memory, NVM), such as at least one disk memory, and various instructions may be stored in the memory 162
  • RAM random-access memory
  • NVM non-volatile memory
  • the Bluetooth controller 163 and the Wi-Fi controller 164 are used to realize connection and communication between the electronic device and other devices.
  • the electronic equipment involved in this application may further include: a power supply 165 and a communication bus 166 .
  • the memory 162 is used to store computer-executable program codes, and the program codes include 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-mentioned method embodiments. The principles and technical effects are similar and will not be repeated here.
  • modules or components described in the above embodiments may be one or more integrated circuits configured to implement the above method, for example: one or more application specific integrated circuits (ASIC), or , one or more microprocessors (digital signal processor, DSP), or, one or more field programmable gate arrays (field programmable gate array, FPGA), etc.
  • ASIC application specific integrated circuit
  • DSP digital signal processor
  • FPGA field programmable gate array
  • the processing element can be a general-purpose processor, such as a central processing unit (central processing unit, CPU) or other processors that can call program codes such as control device.
  • these modules can be integrated together and implemented in the form of a system-on-a-chip (SOC).
  • SOC system-on-a-chip
  • a computer program product includes one or more computer instructions.
  • Computer instructions may be stored in or transmitted from one computer-readable storage medium to another computer-readable storage medium, e.g. Coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.) to another website site, computer, server or data center.
  • DSL digital subscriber line
  • the computer-readable storage medium may be any available medium that can be accessed by a computer, or a data storage device such as a server, a data center, etc. integrated with one or more available media.
  • Available media may be magnetic media (eg, floppy disk, hard disk, magnetic tape), optical media (eg, DVD), or semiconductor media (eg, Solid State Disk (SSD)).
  • sequence numbers of the above-mentioned processes do not mean the order of execution, and the order of execution of the processes should be determined by their functions and internal logic, and should not be used in the implementation of this application.
  • the implementation of the examples constitutes no limitation.

Landscapes

  • Engineering & Computer Science (AREA)
  • Signal Processing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Health & Medical Sciences (AREA)
  • Otolaryngology (AREA)
  • Physics & Mathematics (AREA)
  • Acoustics & Sound (AREA)
  • Mobile Radio Communication Systems (AREA)

Abstract

本申请实施例提供了一种数据传输方法、装置、电子设备和可读存储介质,第一设备与第二设备已建立第一无线通路和第二无线通路,第一无线通路和第二无线通路为蓝牙通路或Wi-Fi通路,第一无线通路和第二无线通路不同,该方法中,第一设备通过第一无线通路向第二设备发送第一音频数据,若根据目标参数确定数据传输的目标通路为第二无线通路,第一设备通过第二无线通路向第二设备发送第二音频数据,目标参数与如下至少一项相关:第一无线通路的通信质量、第二无线通路的通信质量、第一设备的运行模式以及第二设备的运行模式。本申请实施例中,第一设备可以切换目标通路,保证第二设备播放音频的流畅性的前提下,使得用户可以享受高品质的音频。

Description

数据传输方法、装置、电子设备和可读存储介质
本申请要求于2021年09月30日提交中国专利局、申请号为202111166561.5、申请名称为“数据传输方法、装置、电子设备和可读存储介质”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请实施例涉及通信技术,尤其涉及一种数据传输方法、装置、电子设备和可读存储介质。
背景技术
手机可以与音箱进行蓝牙连接以及Wi-Fi连接。当手机与音箱蓝牙连接后,手机可以通过手机与音箱之间的蓝牙通路向音箱发送音频数据,使得音箱基于该音频数据播放音频。当手机与音箱Wi-Fi连接后,手机可以通过手机与音箱之间的Wi-Fi通路向音箱发送音频数据,使得音箱基于该音频数据播放音频。
目前,当手机通过手机与音箱之间的Wi-Fi通路使得音箱播放音频时,若Wi-Fi通路的通信质量差会造成音频播放卡顿,用户需要手动关闭手机和音箱之间的Wi-Fi连接,建立手机与音箱之间的蓝牙连接,手机基于手机与音箱之间的蓝牙通路可以控制音箱播放音频,但现有技术中的控制方法操作复杂。
发明内容
本申请实施例提供一种数据传输方法、装置、电子设备和可读存储介质,电子设备可以自动切换传输音频数据的通路,在保证第二设备播放音频的流畅性的前提下,使得用户可以享受高品质的音频。
第一方面,本申请实施例提供一种数据传输方法,该方法的执行主体可以为第一设备或第一设备中的芯片,下述以第一设备为例进行说明。该方法中,第一设备与第二设备已建立第一无线通路和第二无线通路,第一无线通路为蓝牙通路或Wi-Fi通路,第二无线通路为蓝牙通路或Wi-Fi通路,第一无线通路和第二无线通路不同。第一设备可以通过第二设备播放音频。
其中,第一设备可以通过第一无线通路向第二设备发送第一音频数据,第一音频数据用于第二设备播放第一音频,也就是说,第二设备响应于接收第一音频数据,可以基于第一音频数据,播放第一音频。若第一设备根据目标参数确定数据传输的目标通路为第二无线通路,则第一设备通过第二无线通路向第二设备发送第二音频数据。
其中,目标参数与如下至少一项相关:第一无线通路的通信质量、第二无线通路的通信质量、第一设备的运行模式,以及第二设备的运行模式,第二音频数据用于第二设备播放第二音频。具体第一设备根据目标参数确定数据传输的目标通路为第二无线通路,可以参照下述的相关说明。
本申请实施例中,第一设备在通过第二设备播放音频时,第一设备可以根据目标参数,切换传输音频数据的通路,可以保证用户在享受高清音频的同时,又可以在干扰环境下保证音频播放的流畅性,避免音频卡顿,可以提高用户体验。
在一种可能的实现方式中,第一设备在通过第二无线通路向第二设备发送第二音频数据之前,可以检测通过第一无线通路是否已发送完第一音频数据。第一设备响应于检测到通过第一无线通路已发送完第一音频数据,通过第二无线通路向第二设备发送第二音频数据。
在一种可能的实现方式中,为了减少因为通路切换造成的音频播放的时延,第一设备可以将第二音频数据复制两份,分别为第一数据和第二数据,且对第一数据和第二数据标注为相同的标识。第一设备通过第一无线通路向第二设备发送第一数据,以及通过第二无线通路向第二设备发送第二数据。
在该实现方式中,第二设备响应于接收来自第一设备的两个无线通路具有相同标识的第一数据和第二数据,可以向第一设备发送停止使用第一无线通路的信息。另外,第二设备可以基于来自第二无线通路的数据,播放第二音频。
相应的,第一设备响应于接收到停止使用第一无线通路的信息,可以通过第二无线通路向第二设备发送第三音频数据。第二设备响应于接收第三音频数据,可以播放第三音频。
下述对第一设备根据目标参数,确定目标通路为第二无线通路进行说明:
其一,目标参数与第一无线通路的通信质量相关。
若第一设备根据所述目标参数,确定所述第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
其中,用于表征第一无线通路的通信质量的参数可以包括但不限于为:第一无线通路的误包率、吞吐率等。以吞吐率为例,当第一无线通路的吞吐率小于第一预设吞吐率时,可以确定第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,即第一预设吞吐率用于表征第一无线通路的预设通信质量。
其二,所述目标参数与所述第一无线通路的通信质量和所述第二无线通路的通信质量相关。
若第一设备根据所述目标参数,确定所述第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,且所述第二无线通路的通信质量大于或等于所述第二无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
示例性的,以吞吐率为例,当第一无线通路的吞吐率小于第一预设吞吐率时,可以确定第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,这时第一设备还要检测第二无线通路的吞吐率是否大于或等于第二预设吞吐率,当第二无线通路的吞吐率大于或等于第二预设吞吐率时,表征所述第二无线通路的通信质量大于或等于所述第二无线通路的预设通信质量,则第一设备可以确定第一无线通路的通信质量差,但是第二无线通路的通信质量好,则可以确定所述目标通路为所述第二无线通路。
其三,所述目标参数与所述第一设备的运行模式、第二设备的运行模式相关。
其中,当所述第一无线通路为Wi-Fi通路时,若第一设备检测到所述第一设备和/或第二设备的运行模式进入低功耗模式,则确定所述目标通路为蓝牙通路,所述蓝牙通路为所述第二无线通路。当所述第一无线通路为蓝牙通路时,若检测到切换至低功耗模式的设备 均退出低功耗模式,则确定所述目标通路为所述Wi-Fi通路,所述Wi-Fi通路为所述第二无线通路。或者,
在一种实施例中,所述目标参数与所述第一设备的运行模式相关。其中,当所述第一无线通路为Wi-Fi通路时,若第一设备检测到所述第一设备的运行模式进入低功耗模,则确定所述目标通路为蓝牙通路,所述蓝牙通路为所述第二无线通路。或者,
在一种实施例中,所述目标参数与所述第二设备的运行模式相关,其中,当所述第一无线通路为Wi-Fi通路时,若第一设备检测到所述第二设备的运行模式进入低功耗模式,则确定所述目标通路为蓝牙通路,所述蓝牙通路为所述第二无线通路。
其中,“其三”和上述“其一”或“其二”可以结合,示例性的,以“其三”和上述“其一”为例:
当所述第一无线通路为Wi-Fi通路时,若第一设备检测到所述第一设备的运行模式进入低功耗模式,则确定所述目标通路为蓝牙通路,则第一设备还需要检测第二无线通路的通信质量是否大于或等于第二无线通路的预设通信质量,若第二无线通路的通信质量大于或等于第二无线通路的预设通信质量,则第一设备可以确定目标通路为所述蓝牙通路。
在一种实施例中,目标参数还与第二音频数据的类型相关。在该种实施例中,第二音频数据和第一音频数据可以不为同一音频中的数据。
其四,第一设备可以基于所述目标参数,若确定所述第二音频数据的类型为预设类型,则确定传输所述第二音频数据的目标通路为所述Wi-Fi通路,所述预设类型与所述Wi-Fi通路具有映射关系。同理的,第一设备基于所述目标参数,若确定所述第二音频数据的类型为非预设类型,则确定传输所述第二音频数据的目标通路为所述蓝牙通路,所述非预设类型与所述蓝牙通路具有映射关系。
在一种实施例中,预设类型可以为高清音频,非预设类型可以为非高清音频。
其五,“其四”和上述“其一”、“其二”以及“其三”进行结合。以“其四”和上述“其一”为例:
示例性的,第一设备可以基于所述目标参数,若确定所述第二音频数据的类型为预设类型,则确定传输所述第二音频数据的目标通路为所述Wi-Fi通路,则第一设备还需要检测Wi-Fi通路的通信质量是否大于或等于Wi-Fi通路的预设通信质量,若Wi-Fi通路的通信质量大于或等于Wi-Fi通路的预设通信质量,则第一设备可以确定目标通路为Wi-Fi通路。
在一种实施例中,在第一设备在通过第一无线通路向第二设备发送第一音频数据之前,可以基于目标参数确定传输第一音频数据的目标通路为第一无线通路,具体的可以参照上述“第一设备根据目标参数,确定目标通路为第二无线通路”中的相关说明。
第二方面,本申请实施例提供一种数据传输方法,该方法的执行主体可以为第二设备或第二设备中的芯片,下述以第二设备为例进行说明。该方法中,第二设备可以通过所述第一无线通路接收来自所述第一设备的第一音频数据,且基于所述第一音频数据,播放第一音频。第二设备可以通过所述第二无线通路接收来自所述第一设备的第二音频数据,且基于所述第二音频数据,播放第二音频。
第三方面,本申请实施例提供一种数据传输方法,该方法的执行主体可以为第一设备或第一设备中的芯片,下述以第一设备为例进行说明。该方法中,第一设备可以将第一音频数据复制两份,分别为第一数据和第二数据,所述第一音频数据用于所述第二设备播放 第一音频。
第一设备可以对所述第一数据和所述第二数据标注为相同的标识,且通过所述第一无线通路向所述第二设备发送所述第一数据,以及通过所述第二无线通路向所述第二设备发送所述第二数据。
第四方面,本申请实施例提供一种数据传输方法,该方法的执行主体可以为第二设备或第二设备中的芯片,下述以第二设备为例进行说明。该方法中,第二设备响应于接收到来自第一设备的具有相同标识的第一数据和第二数据,可以将来自Wi-Fi通路的第一数据存储在第二设备的缓存区中,进而基于缓存区中的第一数据,播放第一音频。因为来自Wi-Fi通路的音频数据为不经编码的数据,因此,用户可以享受高清音频。
在一种可能的实现方式中,若Wi-Fi通路的质量变差,导致第二设备的缓存区中的音频数据的数据量逐渐减少,为了保证音频播放的流畅性,第二设备响应于第二设备的缓存区中的音频数据的数据量小于水线值,将来自蓝牙通路的音频数据进行解码处理后存入第二设备的缓存区中。
在一种可能的实现方式中,为了保证音频数据播放的流畅性,第二设备可以根据来自第一设备的第一无线通路的音频数据的第一标识,以及来自第二无线通路的音频数据的第二标识,若第二设备的缓存区中未包括第一标识且包含第二标识,则将来自第一无线通路的音频数据存入第二设备的缓存区中,丢弃来自第二无线通路的音频数据。这样,第二设备先接收到哪个通路的音频数据,第二设备优先将该通路的音频数据存储在第二设备的缓存区中,以进行播放,可以保证音频数据播放的流畅性。应理解,第一标识和第二标识可以相同或不同,当第一标识和第二标识相同时,第二设备可以将来自Wi-Fi通路的音频数据存储在第二设备的缓存区中,且丢弃来自蓝牙通路的音频数据。
第五方面,本申请实施例提供一种数据传输装置,包括:
第一融合管理模块,用于:
通过所述第一无线通路向所述第二设备发送第一音频数据,所述第一音频数据用于所述第二设备播放第一音频。
若根据目标参数确定数据传输的目标通路为所述第二无线通路,则通过所述第二无线通路向所述第二设备发送第二音频数据,所述目标参数与如下至少一项相关:所述第一无线通路的通信质量、所述第二无线通路的通信质量、所述第一设备的运行模式,以及第二设备的运行模式,所述第二音频数据用于所述第二设备播放第二音频。
在一种可能的实现方式中,第一融合管理模块,还用于检测通过所述第一无线通路是否已发送完所述第一音频数据,响应于检测到通过所述第一无线通路已发送完所述第一音频数据,通过所述第二无线通路向所述第二设备发送所述第二音频数据。
在一种可能的实现方式中,所述目标参数与所述第一无线通路的通信质量相关。
第一融合管理模块,具体用于若根据所述目标参数,确定所述第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
在一种可能的实现方式中,所述目标参数与所述第一无线通路的通信质量和所述第二无线通路的通信质量相关。
第一融合管理模块,具体用于若根据所述目标参数,确定所述第一无线通路的通信质 量小于或等于所述第一无线通路的预设通信质量,且所述第二无线通路的通信质量大于或等于所述第二无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
在一种可能的实现方式中,所述目标参数与所述第一设备的运行模式、第二设备的运行模式相关。
第一融合管理模块,具体用于:
当所述第一无线通路为Wi-Fi通路时,若检测到所述第一设备和/或第二设备的运行模式进入低功耗模式,则确定所述目标通路为蓝牙通路,所述蓝牙通路为所述第二无线通路。
在一种可能的实现方式中,第一融合管理模块,还用于将所述第二音频数据复制两份,分别为第一数据和第二数据,对所述第一数据和所述第二数据标注为相同的标识,且通过所述第一无线通路向所述第二设备发送所述第一数据,通过所述第二无线通路向所述第二设备发送所述第二数据。
在一种可能的实现方式中,第一融合管理模块,还用于响应于接收来自所述第二设备的停止使用所述第一无线通路的信息,通过所述第二无线通路向所述第二设备发送第三音频数据,所述第三音频数据用于所述第二设备播放第三音频。
在一种可能的实现方式中,第一融合管理模块,还用于根据所述目标参数,确定传输所述第一音频数据的目标通路为所述第一无线通路。
在一种可能的实现方式中,所述目标参数与所述第一音频数据的类型相关,所述第一无线通路为Wi-Fi通路。
第一融合管理模块,还用于:
基于所述目标参数,若确定所述第一音频数据的类型为预设类型,则确定传输所述第一音频数据的目标通路为所述Wi-Fi通路,所述预设类型与所述Wi-Fi通路具有映射关系。
基于所述目标参数,若确定所述第一音频数据的类型为非预设类型,则确定传输所述第一音频数据的目标通路为所述蓝牙通路,所述非预设类型与所述蓝牙通路具有映射关系。
第六方面,本申请实施例提供一种数据传输装置,包括:
第二融合管理模块,用于通过所述第一无线通路接收来自所述第一设备的第一音频数据。
播放器,用于基于所述第一音频数据,播放第一音频。
第二融合管理模块,还用于通过所述第二无线通路接收来自所述第一设备的第二音频数据。
播放器,还用于基于所述第二音频数据,播放第二音频。
在一种可能的实现方式中,第二融合管理模块,具体用于通过所述第一无线通路接收来自所述第一设备的第一数据,以及通过所述第二无线通路接收来自所述第一设备的第二数据,所述第一数据和所述第二数据是所述第一设备将所述第二音频数据复制成两份得到的,所述第一数据和所述第二数据的标识相同。
第二融合管理模块,还用于向所述第一设备发送停止使用所述第一无线通路的信息。
在一种可能的实现方式中,第二融合管理模块,还用于通过所述第二无线通路接收来自所述第一设备的第三音频数据。
播放器,还用于基于所述第三音频数据,播放第三音频。
第七方面,本申请实施例提供一种数据传输装置,包括:
第一融合管理模块,用于将第一音频数据复制两份,分别为第一数据和第二数据,对所述第一数据和所述第二数据标注为相同的标识,以及通过所述第一无线通路向所述第二设备发送所述第一数据,通过所述第二无线通路向所述第二设备发送所述第二数据,所述第一音频数据用于所述第二设备播放第一音频。
第八方面,本申请实施例提供一种数据传输装置,包括:
第二融合管理模块,用于接收具有相同标识的来自所述第一无线通路的第一数据和来自所述第二无线通路的第二数据,所述第一数据和所述第二数据是所述第一设备将第一音频数据复制成两份得到的,将所述第一数据存储在缓存区中,所述第一无线通路为Wi-Fi通路。
播放器,用于基于所述缓存区中的所述第一数据,播放第一音频。
在一种可能的实现方式中,第二融合管理模块,还用于若所述缓存区中的音频数据的数据量小于预设数据量,将来自所述第二无线通路的数据进行解码处理后存入所述缓存区中,所述第二无线通路为蓝牙通路。
播放器,还用于基于所述缓存区中的解码处理后的数据,播放音频。
在一种可能的实现方式中,第二融合管理模块,还用于根据来自所述第一无线通路的音频数据的第一标识,以及来自所述第二无线通路的音频数据的第二标识,若所述缓存区中未包含所述第一标识且包含所述第二标识,则将来自所述第一无线通路的音频数据存入所述缓存区中,丢弃来自所述第二无线通路的音频数据。
第九方面,本申请实施例提供一种电子设备,该电子设备为如上的第一设备、第二设备。可以包括:处理器、存储器、蓝牙控制器,以及Wi-Fi控制器。存储器用于存储计算机可执行程序代码,程序代码包括指令;当处理器执行指令时,指令使所述电子设备执行如第一方面至第四方面中的方法。
第十方面,本申请实施例提供一种电子设备,该电子设备可以为第一设备。第二设备。该电子设备可以包括用于执行以上第一方面至第四方面所提供的方法的单元、模块或电路。
第十一方面,本申请实施例提供一种包含指令的计算机程序产品,当其在计算机上运行时,使得计算机执行上述第一方面至第四方面中的方法。
第十二方面,本申请实施例提供一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面至第四方面中的方法。
上述第二方面至第十二方面的各可能的实现方式,其有益效果可以参见上述第一方面所带来的有益效果,在此不加赘述。
附图说明
图1为本申请实施例适用的一种场景示意图;
图2为已有的一种音频播放示意图;
图3A为本申请实施例提供的第一设备和第二设备的一种交互示意图;
图3B为本申请实施例提供的第一设备和第二设备的另一种交互示意图;
图4为本申请实施例提供的第一设备和第二设备建立蓝牙通路的过程示意图;
图5为本申请实施例提供的第一设备和第二设备建立Wi-Fi通路的过程示意图;
图6为本申请实施例提供的数据传输方法的一种实施例的流程示意图;
图7为本申请实施例提供的数据传输方法的另一种实施例的流程示意图;
图8为本申请实施例提供的数据传输的一种示意图;
图9为本申请实施例提供的数据传输方法的另一种实施例的流程示意图;
图10为本申请实施例提供的数据传输的另一种示意图;
图11为本申请实施例提供的数据传输方法的另一种实施例的流程示意图;
图12为本申请实施例提供的数据传输的另一种示意图;
图13为本申请实施例提供的数据传输的另一种示意图;
图14为本申请实施例提供的数据传输方法的另一种实施例的流程示意图;
图15为本申请实施例提供的数据传输方法的另一种实施例的流程示意图;
图16为本申请实施例提供的电子设备的一种结构示意图。
具体实施方式
图1为本申请实施例适用的一种场景示意图。参照图1,该场景中包括第一设备和第二设备,图1中以第一设备为手机,第二设备为音箱为例。第一设备可以与第二设备无线连接,且第一设备可以通过第二设备播放音频。示例性的,第一设备可以与第二设备蓝牙连接,第一设备可以通过第一设备和第二设备之间的蓝牙通路向第二设备传输音频数据,第二设备可以基于来自第一设备的音频数据,播放音频。
在一种实施例中,第一设备支持与第二设备蓝牙连接,以及Wi-Fi连接。第一设备可以通过第一设备和第二设备之间的蓝牙通路向第二设备传输音频数据,第二设备可以基于该音频数据播放音频。第一设备也可以通过第一设备和第二设备之间的Wi-Fi通路向第二设备传输音频数据,第二设备同样可以基于音频数据播放音频。应理解,Wi-Fi通路的带宽大于蓝牙通路,因此当第一设备和第二设备Wi-Fi连接时,第一设备可以向第二设备发送占用带宽较大的无损音频的音频数据,或5.1立体声的音频数据,或7.1立体声的音频数据等,相应的,第二设备可以播放无损音频,5.1立体声的音频,以及7.1立体声的音频等(下述以无损音频为例进行说明)。而当第一设备和第二设备蓝牙连接时,因为蓝牙通路的带宽有限,因此第一设备可以将音频数据进行编码后发送给第二设备,相应的,第二设备播放的音频为经过编码后的音频。
应理解的是,本申请实施例中的第一设备可以包括但不限于为:手机、平板电脑(portable android device,PAD)、智慧屏、具有无线通信功能的手持设备、计算设备、车载设备或可穿戴设备,虚拟现实(virtual reality,VR)终端设备、增强现实(augmented reality,AR)终端设备、工业控制(industrial control)中的无线终端、智慧家庭(smart home)中的无线终端等。第二设备可以包括但不限于为:手机、PAD、智慧屏、耳机、具有无线通信功能的手持设备、车载设备或可穿戴设备,VR终端设备、AR终端设备、工业控制中的无线终端、智慧家庭中的无线终端等具有播放音频功能的电子设备等。本申请实施例中对第一设备和第二设备的形态不做具体限定。
图2为已有的一种音频播放示意图。参照图2中的a,第一设备与第二设备Wi-Fi连接,未蓝牙连接,第一设备可以通过Wi-Fi通路向第二设备发送音频数据,相应的,第二设备可以播放无损音频,图2中a以数字“123”表征无损音频。当第一设备与第二设备之间的Wi-Fi 连接受到干扰,即Wi-Fi通路的通信质量变差时,Wi-Fi通路上传输的音频数据会出现丢包,造成第二设备的音频播放出现卡顿,参照图2中的b所示,应理解,图2中的b以数字“4、5和8”表征无损音频,以省略号表征第二设备播放音频卡顿,如未播放数字“6和7”。
当用户感知第二设备的音频播放卡顿时,用户可以手动断开第一设备与第二设备的Wi-Fi连接,将第一设备和第二设备进行蓝牙连接。第一设备和第二设备蓝牙连接后,第一设备可以通过蓝牙通路向第二设备发送音频数据,相应地,第二设备可以播放来自蓝牙通路的经编码的音频,参照图2中的c所示,以数字“90”表征经编码的音频。应理解,图2中未示出用户手动断开Wi-Fi连接,以及将第一设备和第二设备蓝牙连接的过程,可以参照现有技术中的描述。
其中,当第一设备和第二设备蓝牙连接后,用户听到的音频为经编码后音频,音频为有损音频。且用户无法感知Wi-Fi通路的通信质量是否变好,因此也无法在合适的时间手动将第一设备和第二设备进行Wi-Fi连接,进而用户无法享受无损音频。
基于上述问题,可以将第一设备和第二设备同时进行Wi-Fi连接和蓝牙连接,若第一设备能够根据Wi-Fi通路的通信质量和蓝牙通路的通信质量,自适应地切换传输音频数据的通路,既能够保证音频播放的流畅度,还能够保证用户能够及时享受到无损音频,提高用户体验。据此,本申请实施例提供一种数据传输方法,在第一设备在与第二设备同时Wi-Fi连接和蓝牙连接的前提下,第一设备可以基于Wi-Fi通路的通信质量和蓝牙通路的通信质量,自适应地切换传输音频数据的通路,以提高用户体验。
上述第一设备通过第二设备播放音频为一种示例说明,在一种实施例中,第一设备还可以通过第二设备显示文件,该种实施例中,第一设备可以向第二设备发送文件数据,第二设备响应于接收到文件数据,可以在第二设备的界面上显示文件。本申请实施例不限制第一设备通过第二设备执行的业务,即不限制第一设备向第二设备发送的数据的类型。
应理解,下述实施例中以第一设备和第二设备同时“蓝牙连接和Wi-Fi连接”,且第一设备通过第二设备播放音频为例进行说明。
在介绍本申请实施例提供的数据传输方法之前,首先对第一设备和第二设备的结构进行说明。参照图3A和图3B,图3B为图3A的详细示意图。
在一种实施例中,第一设备包括:主机中央处理器(host central processing unit,Host CPU)和无线芯片。其中,无线芯片上可以集成有第一蓝牙控制器(bluetooth controller,BT controller)和第一Wi-Fi控制器(Wi-Fi controller)。在一种实施例中,第一蓝牙控制器(可以称为第一BT控制器或第一BT controller)和第一Wi-Fi控制器(可以称为第一Wi-Fi controller)可以独立设置,图3B中以第一蓝牙控制器和第一Wi-Fi控制器集成在无线芯片上设置为例。
在一种实施例中,Host CPU中可以包括:应用处理器(application processor,AP)、音频框架(audio framework,Audio FWK)、硬件抽象层的高级蓝牙音频传输模型协议(advanced audio distribution profile hardware abstraction layer,A2DP audio HAL)、A2DP和音视频蓝牙传输协议(audio/video distribution transport protocol,A2DP和AVDTP)、第一融合管理模块、服务质量(Quality of Service,QoS)模块,第一逻辑链路控制与适配层模块(logical link control and adaptation protocol,L2CAP)模块,以及内核层(kernel)。 其中,内核层中包括:第一传输控制协议/网际协议(transmission control protocol/internet protocol,TCP/IP)模块。应理解,A2DP和AVDTP可以包括A2DP模块和AVDTP模块。
其中,AP可以包括至少一个应用程序(application,APP)的应用程序包,应用程序可以包括但不限于:相机,图库,日历,通话,地图,导航,蓝牙,音乐,视频,短信息等,图3B中示出了与音频播放相关的音频类应用程序、电话应用程序,以及视频类应用程序。
Audio FWK,用于将来自应用程序的音频数据进行解码,且对解码后的音频数据进行重采样、混音等处理,向A2DP audio HAL发送处理后的音频数据。
A2DP audio HAL,用于缓存音频数据,如A2DP audio HAL可以将音频数据缓存在A2DP audio HAL的缓存区buffer中。
当音频数据通过第一设备和第二设备之间的蓝牙通路传输时,A2DP模块,用于从A2DP audio HAL的buffer中读取音频数据,且对音频数据进行编码,得到编码后的音频数据(下述简称为编码数据),A2DP模块可以将编码数据传输给AVDTP模块。
AVDTP模块,用于将编码数据传输给第一L2CAP模块。
QoS模块,用于获取蓝牙通路的通信质量,以及Wi-Fi通路的通信质量。
第一融合管理模块,用于基于音频数据的类型,和/或,QoS模块获取的蓝牙通路的通信质量、Wi-Fi通路的通信质量等参数,选择通过蓝牙通路或Wi-Fi通路传输音频数据,可以参照下述图6中的相关描述。
第一L2CAP模块,用于管理音频数据的分发,以实现音频数据通过蓝牙通路或Wi-Fi通路传输。
本申请实施例中,第一L2CAP模块,可以向第一BT controller发送音频数据。在一种实施例中,第一L2CAP模块可以通过第一主机控制器接口(host controller interface,HCI),向第一BT controller发送音频数据。第一HCI位于Host CPU和无线芯片之间,用于实现Host CPU和无线芯片之间的数据传输,第一HCI的一部分位于Host CPU,另一部分位于无线芯片Controller,图3B中未示出第一HCI。
当音频数据通过第一设备和第二设备之间的Wi-Fi通路传输时,第一L2CAP模块可以从A2DP audio HAL中读取音频数据,且通过第一TCP/IP模块,向第一Wi-Fi controller发送音频数据。
第一TCP/IP模块,还用于辅助第一设备与第二设备建立基于Wi-Fi的传输层数据通路。
在一种实施例中,如上第一A2DP和AVDTP、第一L2CAP模块、第一TCP/IP模块可以称为连接管理模块。
在一种实施例中,第二设备包括:主机中央处理器(Host CPU)、第二BT controller、第二Wi-Fi controller、编解码模块,以及播放器。在一种实施例中,第二BT controller和第二Wi-Fi controller也可以集成在一个芯片上,图3B中以第二BT controller和第二Wi-Fi controller独立设置为例。
编解码模块,用于对音频数据进行解码,且将解码后的音频数据发送至播放器。
播放器,用于播放音频。
第二设备中的Host CPU中包括:第二L2CAP模块以及第二TCP/IP模块。
第二L2CAP模块,用于将接收到的音频数据发送至编解码模块,使得编解码模块对接 收到的音频数据进行解码。
第二TCP/IP模块,用于辅助第一设备与第二设备建立基于Wi-Fi的传输层数据通路。
在一种实施例中,第二设备中的Host CPU中还可以包括:第二融合管理模块。第二融合管理模块,用于构建和维护一个buffer,该buffer用于缓存音频数据,具体可以参照图11-图13中的相关描述。
应理解,上述对第一设备和第二设备中的各模块进行简述,具体可以参照下述图6中的描述,以及现有技术中对各模块的介绍,在此不做赘述。应注意的是,图3A和图3B中以及下述附图中以虚线表征Wi-Fi通路传输音频数据,实线表征蓝牙通路传输音频数据。
在图3A和图3B所示的第一设备和第二设备的结构的基础上,下面结合图4,对第一设备和第二设备建立蓝牙通路和Wi-Fi通路的过程进行简要说明。应理解的是,蓝牙通路可以包括:蓝牙接入层链路和对应蓝牙通路的L2CAP信道。其中,Wi-Fi通路可以包括:Wi-Fi接入层链路、套接字(socket)连接,以及对应Wi-Fi通路的L2CAP信道。
以第一设备为手机,第二设备为音箱为例,参照图4,第一设备和第二设备建立蓝牙通路的过程可以包括:
步骤1:用户打开手机的蓝牙功能,以及音箱的蓝牙功能。
步骤2:手机扫描搜索音箱的标识,用户在手机或音箱上操作,使得手机和音箱蓝牙连接。
在步骤2的过程中手机和音箱可以建立蓝牙接入层链路。
然后,手机中的AVDTP模块可以向第一L2CAP模块发送建立对应蓝牙通路的L2CAP信道的指令,第一L2CAP模块响应于该指令建立L2CAP信道,该L2CAP信道用于传输来自AVDTP模块的数据。
参照图5,第一设备和第二设备建立Wi-Fi通路的过程可以包括:
步骤1a:基于点对点(peer to peer,P2P)协议,手机做GO(group owner),将用户名、密码和加密方式等参数通过蓝牙消息发送给音箱。
步骤2a:音箱做GC(group client),通过上述步骤1a中的“用户名、密码和加密方式等参数”,加入手机GO的P2P网络。
在一种实施例中,步骤1a可以替换为步骤1b:基于点对点(peer to peer,P2P)协议,音箱做(group owner,GO),将用户名、密码和加密方式等参数通过蓝牙消息发送给手机。同理的,步骤2a可以替换为步骤2b:手机做GC(group client),通过上述步骤1b中的“用户名、密码和加密方式等参数”,加入音箱GO的P2P网络。
在步骤2a和步骤2b的过程中手机和音箱可以依次建立Wi-Fi接入层链路,以及第一TCP/IP模块和第二TCP/IP模块之间的socket连接。
然后,手机中的第一融合管理模块可以向第一L2CAP模块发送建立对应Wi-Fi通路的L2CAP信道的指令,第一L2CAP模块响应于该指令建立L2CAP信道,该L2CAP信道用于映射手机和音箱之间的TCP/IP连接(socket连接)。
在图4和图5的基础上,第一设备和第二设备已经建立了蓝牙通路和Wi-Fi通路。下面结合具体的实施例对本申请实施例提供的数据传输方法进行说明。下面这几个实施例可以相 互结合,对于相同或相似的概念或过程可能在某些实施例不再赘述。
图6为本申请实施例提供的数据传输方法的一种实施例的流程示意图。参照图6,本申请实施例提供的数据传输方法可以包括:
S601,应用程序响应于接收播放音频的指令,通过Audio FWK向A2DP audio HAL发送音频数据。
第一设备和第二设备建立了蓝牙通路和Wi-Fi通路后,用户可以在第一设备上进行操作,以控制第二设备播放音频。示例性的,用户可以在第一设备中打开音频类应用程序,选择音频A,以控制第二设备播放音频A。
应用程序响应于检测到用户输入的播放音频的指令,若第一设备的本地存储有音频数据,则应用程序可以在本地获取音频数据,若第一设备未存储音频数据,应用程序可以从音频类应用程序对应的服务器中下载音频数据,本申请实施例对应用程序获取音频数据的过程不做赘述。
应用程序可以通过Audio FWK向A2DP audio HAL发送音频数据。在一种实施例中,应用程序可以将音频数据发送给Audio FWK,Audio FWK可以将音频数据进行解码、重采样、以及混音等处理,且将处理后的音频数据发送给A2DP audio HAL。其中,Audio FWK对音频数据进行解码的方式可以包括但不限于为:脉冲编码调制(pulse code modulation,PCM)、或无损音频编解码(free lossless audio codec)等。下述实施例中以Audio FWK进行解码后的音频数据为PCM音频数据为例进行说明,相应的,Audio FWK可以向A2DP audio HAL发送PCM音频数据。
S602,A2DP audio HAL缓存音频数据。
在一种实施例中,A2DP audio HAL缓存PCM音频数据,如将A2DP audio HAL可以将PCM音频数据缓存在A2DP audio HAL的buffer中。
S603,第一融合管理模块根据目标参数,确定传输音频数据的目标通路。
目标参数可以与下述任意一项相关:音频数据的类型,和/或,蓝牙通路的通信质量,和/或,Wi-Fi通路的通信质量、第一设备的运行模式,以及第二设备的运行模式。本申请实施例中,目标通路可以为蓝牙通路和/或Wi-Fi通路。
在一种实施例中,音频数据的类型可以包括:高清(高品质)音频和非高清(非高品质)音频。其中,高清音频可以满足如条件1或条件2:
条件1:采样率大于等于48KHz、位宽大于等于24bit,以及声道大于或等于2。
条件2:采样率大于等于96KHz、位宽大于或等于16bit且小于24bit,以及声道大于或等于2。
应理解,条件1和条件2中的位宽是用来衡量音频中声音波动变化的参数。位宽的数值越大,则表征音频的分辨率越好,即Audio FWK的采样频率越高。
应理解,Audio FWK向A2DP audio HAL发送PCM音频数据时,可以向A2DP audio HAL发送PCM音频数据的音频参数,音频参数中包括采样率、位宽以及声道。A2DP audio HAL响应于接收PCM音频数据的音频参数,可以向第一融合管理模块发送PCM音频数据的音频参数,如此,第一融合管理模块可以得到PCM音频数据的音频参数,即音频的采样率、位宽以及声道,进而第一融合管理模块可以基于音频参数,获取音频数据的类型。
在一种实施例中,如图3B所示,Host CPU中包括QoS模块,QoS模块用于获取蓝牙通 路的通信质量,以及Wi-Fi通路的通信质量,因此,第一融合管理模块可以从QoS模块中读取“蓝牙通路的通信质量和Wi-Fi通路的通信质量”。其中,蓝牙通路的通信质量可以以蓝牙通路的如下至少一项参数表征:误包率(packet error rate,PER)、吞吐率。应理解,误包率越小,表征蓝牙通路的通信质量越好,吞吐率越大,表征蓝牙通路的通信质量越好。同理的,Wi-Fi通路的通信质量可以以Wi-Fi通路的如下至少一项参数表征:误包率(packet error rate,PER)、吞吐率。应理解,蓝牙通路的通信质量和Wi-Fi通路的通信质量还可以以其他参数进行表征,本申请实施例对此不作限制。
第一融合管理模块根据目标参数确定目标通路,可以如下所示:
在一种实施例中,第一融合管理模块可以根据音频数据的类型,确定目标通路。其中,第一融合管理模块响应于音频数据的类型为高清音频时,可以确定目标通路为Wi-Fi通路。第一融合管理模块响应于音频数据的类型为非高清音频时,可以确定目标通路为蓝牙通路。
可以理解的是,可以将高清音频作为预设类型,该预设类型与Wi-Fi通路具有映射关系,因此,第一融合管理模块响应于音频数据的类型为高清音频时,可以确定目标通路为Wi-Fi通路。同理的,第一融合管理模块响应于音频数据的类型为非高清音频(即非预设类型)时,可以确定目标通路为蓝牙通路,非预设类型与蓝牙通路具有映射关系。应理解的是,预设类型可以为其他预先定义的音频的类型,本申请实施例对此不作限制,上述以预设类型的音频数据为高清音频为例进行说明。或者,
第一融合管理模块可以根据蓝牙通路的通信质量和Wi-Fi通路的通信质量,确定目标通路。以误包率为例,第一融合管理模块检测到蓝牙通路的误包率大于或者等于第一预设误包率,且Wi-Fi通路的误包率小于第二预设误包率时,可以确定目标通路为Wi-Fi通路。其中,第一预设误包率可以与第二预设误包率相同,或者第一预设误包率大于第二预设误包率。同理的,第一融合管理模块检测到Wi-Fi通路的误包率大于或者等于第一预设误包率,且蓝牙通路的误包率小于第二预设误包率时,可以确定目标通路为蓝牙通路。应理解,蓝牙通路的误包率大于或者等于第一预设误包率可以用于表征:蓝牙通路的通信质量大于或等于蓝牙通路的预设通信质量,也就是说,以误包率表征通信质量时,第一预设误包率用于表征蓝牙通路的预设通信质量。Wi-Fi通路的误包率小于第二预设误包率可以用于表征:Wi-Fi通路的通信质量小于Wi-Fi通路的预设通信质量,也就是说,以误包率表征通信质量时,第二预设误包率用于表征Wi-Fi通路的预设通信质量。应注意,第一预设误包率、第二预设误包率均为预先设置的值。或者,
在一种实施例中,第一融合管理模块可以根据Wi-Fi通路的通信质量,确定目标通路。以误包率为例,第一融合管理模块检测到Wi-Fi通路的误包率小于第二预设误包率时,可以确定目标通路为Wi-Fi通路。或者,第一融合管理模块可以根据蓝牙通路的通信质量,确定目标通路。以误包率为例,第一融合管理模块检测到蓝牙通路的误包率小于第二预设误包率时,可以确定目标通路为蓝牙通路。或者,
在一种实施例中,第一融合管理模块可以根据音频数据的类型,以及蓝牙通路的通信质量和Wi-Fi通路的通信质量,确定目标通路。其中,以误包率为例,第一融合管理模块响应于音频数据的类型为高清音频,可以确定待选择通路为Wi-Fi通路,若Wi-Fi通路的误包率小于第二预设误包率,则第一融合管理模块确定目标通路为Wi-Fi通路。同理的,第一融合管理模块响应于音频数据的类型为非高清音频,可以确定待选择通路为蓝牙通路,若蓝 牙通路的误包率小于第二预设误包率,则第一融合管理模块确定目标通路为蓝牙通路。
在一种实施例中,若第一设备的运行模式和/或第二设备的运行模式切换至低功耗模式,则第一融合管理模块可以确定目标通路为蓝牙通路。也就是说,第一设备和第二设备中至少有一个切换至低功耗模式,则第一融合管理模块可以确定目标通路为蓝牙通路。应注意,当第二设备切换至低功耗模式时,第二设备可以向第一设备发送信息,该信息用于表征第二设备的运行模式为低功耗模式。第一设备响应于接收到该信息,可以确定第二设备进入低功耗模式。
示例性的,当第一设备和/或第二设备进入低功耗模式时,第一设备通过蓝牙通路传输音频数据。在一种实施例中,当第一设备进入低功耗模式时,第一设备中的第一Wi-Fi控制器处于休眠状态,当第二设备进入低功耗模式时,第二设备中的第二Wi-Fi控制器处于休眠状态。
相应的,若进入低功耗模式的设备退出低功耗模式,则第一设备可以确定目标通路为Wi-Fi通路。示例性的,进入低功耗模式的设备为第一设备和第二设备,则第一设备可以响应于检测到第一设备和第二设备均退出低功耗模式,确定目标通路为Wi-Fi通路。
S604,响应于目标通路为蓝牙通路,第一融合管理模块向A2DP模块发送编码指令。
当第一融合管理模块确定目标通路为蓝牙通路时,第一融合管理模块向A2DP模块发送编码指令,编码指令用于指示A2DP模块从A2DP audio HAL读取音频数据,且对音频数据进行编码。
在一种实施例中,第一融合管理模块响应于目标通路为蓝牙通路,可以向第一L2CAP模块同步目标通路。其中,第一融合管理模块可以采用向第一L2CAP模块发送目标通路的标识的方式,向第一L2CAP模块同步目标通路。示例性的,如蓝牙通路的标识为1,Wi-Fi通路的标识为2,第一融合管理模块可以向第一L2CAP模块发送标识1,以向第一L2CAP模块同步目标通路为蓝牙通路。
S605,A2DP模块响应于接收编码指令,从A2DP audio HAL读取音频数据,对音频数据进行编码,得到编码数据。
A2DP模块响应于接收编码指令,从A2DP audio HAL读取音频数据(即PCM音频数据),可以对PCM音频数据进行编码,得到编码数据。应理解,编码数据可以理解为对PCM音频数据进行编码后的数据。
在一种实施例中,A2DP模块对PCM音频数据进行编码的方式可以不限于为:子带编码(sub-band coding,SBC)、高级音频编码(advanced audio coding,ACC)等,本申请实施例对此不作限制。
S606,A2DP模块向AVDTP模块发送编码数据。
S607,AVDTP模块向第一L2CAP模块发送编码数据。
S608,第一L2CAP模块向第一BT controller发送编码数据。
在一种实施例中,来自AVDTP模块的数据为经编码的数据,因此第一L2CAP模块接收到来自AVDTP模块的编码数据,可以确定通过蓝牙通路发送编码数据,据此第一L2CAP模块响应于接收到来自AVDTP模块的编码数据,可以通过第一HCI向第一BT controller发送编码数据。
在一种实施例中,因为第一L2CAP模块可以接收来自第一融合管理模块同步的目标通 路,因此第一L2CAP模块接收到来自AVDTP模块的编码数据,可以确定目标通路为蓝牙通路,因此第一L2CAP模块响应于接收到来自AVDTP模块的编码数据,可以通过第一HCI向第一BT controller发送编码数据。
S609,第一BT controller向第二BT controller发送编码数据。
应理解,第一BT controller接收到来自第一L2CAP模块的编码数据后,可以将编码数据转换成为射频信号进行发送。本申请实施例对第一BT controller对编码数据的处理过程不做赘述,可以参照现有技术中第一BT controller对数据的处理过程。
S610,第二BT controller响应于来自第一BT controller的编码数据,向第二L2CAP模块发送编码数据。
在一种实施例中,第二BT controller响应于来自第一BT controller的编码数据,通过第二HCI向第二L2CAP模块发送编码数据。
第二BT controller可以接收来自第一BT controller的编码数据。示例性的,第二BT controller响应于接收到来自第一BT controller的射频信号,可以对射频信号进行转换,得到编码数据。第二BT controller得到编码数据,可以通过第二HCI向第二L2CAP模块发送编码数据。
S611,第二L2CAP模块向编解码模块发送编码数据。
S612,编解码模块对编码数据进行解码,得到音频数据。
其中,编解码模块可以对编码数据进行解码,得到PCM音频数据。
S613,编解码模块向播放器发送音频数据。
在一种实施例中,“S604-S613”与“S614-S619”可以为择一执行的步骤,或者在一种实施例中,“S604-S613”与“S614-S619”可以为同时执行的步骤,可以参照下述图9和图11中的描述。
S614,响应于目标通路为Wi-Fi通路,第一融合管理模块向第一L2CAP模块同步目标通路为Wi-Fi通路。
在一种实施例中,第一融合管理模块可以采用向第一L2CAP模块发送目标通路的标识的方式,向第一L2CAP模块同步目标通路。示例性的,如蓝牙通路的标识为1,Wi-Fi通路的标识为2,第一融合管理模块可以向第一L2CAP模块发送标识2,以向第一L2CAP模块同步目标通路为Wi-Fi通路。
S615,第一L2CAP模块从A2DP audio HAL中读取音频数据。
本申请实施例中,第一L2CAP模块响应于接收来自第一融合管理模块的目标通路的标识,如2,可以确定目标通路为Wi-Fi通路,进而第一L2CAP模块可以从A2DP audio HAL中读取PCM音频数据。
S616,第一L2CAP模块通过第一TCP/IP模块,向第一Wi-Fi controller发送音频数据。
S617,第一Wi-Fi controller向第二Wi-Fi controller发送音频数据。
应理解,第一Wi-Fi controller接收到来自第一L2CAP模块的PCM音频数据后,可以将PCM音频数据转换成为射频信号进行发送。本申请实施例对第一Wi-Fi controller对PCM音频数据的处理过程不做赘述,可以参照现有技术中第一Wi-Fi controller对数据的处理过程。
S618,第二Wi-Fi controller响应于来自第一Wi-Fi controller的音频数据,通过第二TCP/IP模块向第二L2CAP模块发送音频数据。
第二Wi-Fi controller可以接收来自第一Wi-Fi controller的PCM音频数据。示例性的,第二Wi-Fi controller响应于来自第一Wi-Fi controller的射频信号,可以对射频信号进行转换,得到PCM音频数据。第二Wi-Fi controller得到PCM音频数据,可以通过第二TCP/IP模块向第二L2CAP模块发送PCM音频数据。
S619,第二L2CAP模块向播放器发送音频数据。
如上,在“S604-S613”或“S614-S619”之后,还可以包括:
S620,播放器基于音频数据,播放音频。
S620中播放器可以基于PCM音频数据,播放音频的过程可以参照现有的播放器播放音频的过程,本申请实施例对此不作赘述。
应理解,本申请实施例中S601-S620中所述的音频数据可以称为确定目标通路后传输的第一音频数据或第二音频数据。S620中播放器基于音频数据,播放音频可以理解为:电子设备基于第一音频数据或第二音频数据,播放第一音频或第二音频。
本申请实施例中,第一设备在通过第二设备播放音频时,第一设备中的第一融合管理模块可以根据目标参数,确定传输音频数据的目标通路,可以当保证Wi-Fi通路的通信质量好时,第一设备通过Wi-Fi通路向第二设备发送PCM音频数据,使得第二设备可以播放高清音频。当Wi-Fi通路的通信质量差时,第一设备可以通过蓝牙通路向第二设备发送编码数据,保证第二设备播放音频不卡顿。如此,本申请实施例中第一设备可以根据目标参数,切换传输音频数据的通路,可以保证用户在享受高清音频的同时,又可以在干扰环境下保证音频播放的流畅性,避免音频卡顿,可以提高用户体验。
如上实施例中介绍了第一设备确定目标通路,以及通过目标通路传输音频数据的过程,下述对第一设备通过目标通路传输音频数据的过程进行进一步介绍。应理解,第一设备可以根据目标参数,在蓝牙通路和Wi-Fi通路之间进行切换,具体的过程可以参照如下实施例的相关描述。
其一:
在一种实施例中,假设第一设备采用第一无线通路传输音频数据,第一融合管理模块根据目标参数确定目标通路为第二无线通路,则第一设备可以将传输音频数据的通路从第一无线通路切换至第二无线通路,进而采用第二无线通路传输音频数据。其中,第一无线通路可以为蓝牙通路或Wi-Fi通路,当第一无线通路为蓝牙通路时,第二无线通路为Wi-Fi通路,当第一无线通路为Wi-Fi通路时,第二无线通路为蓝牙通路。
其中,示例性的,当第一无线通路为蓝牙通路时,在如上S608之后若第一融合管理模块执行S603确定目标通路为Wi-Fi通路,参照图7,可以执行如下步骤:
S701,第一融合管理模块向第一L2CAP模块同步目标通路为Wi-Fi通路,且向第一L2CAP模块发送停止发送信息。
第一融合管理模块向第一L2CAP模块同步目标通路为Wi-Fi通路可以参照S614中的相关描述,本申请实施例中,第一融合管理模块在向第一L2CAP模块同步目标通路为Wi-Fi通路时,还可以向第一L2CAP模块发送停止发送信息。
S702,第一L2CAP模块向第一BT controller发送停止发送信息。
停止发送信息用于指示第一BT controller将来自第一L2CAP模块的编码数据发送完成 后,向第一L2CAP模块反馈完成信息。
S703,第一BT controller响应于接收停止发送信息,在发送完编码数据时,向第一L2CAP模块反馈完成信息。
假设第一设备通过蓝牙通路发送的数据为第一音频数据,则S703中第一BT controller发送的编码数据可以称为第一音频数据。假设第一设备通过蓝牙通路发送的数据为第二音频数据,则S703中第一BT controller发送的编码数据可以称为第二音频数据。应理解的是,在第一设备切换目标通路前发送的数据成为第一音频数据,切换通路后发送的数据为第二音频数据。
第一BT controller响应于接收停止发送信息,可以继续发送已经接收到的来自第一L2CAP模块的编码数据,且在编码数据发送完成时,向第一L2CAP模块反馈完成信息。
S704,第一L2CAP模块向第一融合管理模块反馈完成信息。
S705,第一L2CAP模块响应于接收完成信息,执行S615-S619,以及S620。
应理解,本申请实施例中第一L2CAP模块再次执行的“S615-S619,以及S620”中的音频数据可以称为第二音频数据。应注意,第一音频数据、第二音频数据可以属于同一音频中的不同部分或者属于不同的音频。
示例性的,S701-S705可以参照图8所示。图8中的a所示的为第一L2CAP模块通过蓝牙通路发送音频数据,图8中的b所示的为第一L2CAP模块、第一融合管理模块,以及第一BT controller交互的过程,即第一L2CAP模块将传输音频数据的通路从蓝牙通路切换至Wi-Fi通路的过程。图8中的c所示的为第一L2CAP模块采用Wi-Fi通路发送音频数据。应理解,图8中所示的模块为图3B所示的模块中的部分。
同理的,示例性的,当第一无线通路为Wi-Fi通路时,在如上S616之后,若第一融合管理模块执行S603确定目标通路为蓝牙通路,可以执行如下步骤:
S701A,第一融合管理模块向第一L2CAP模块同步目标通路为蓝牙通路,且向第一L2CAP模块发送停止发送信息。
S701A可以参照上述S701中的描述。
S702A,第一L2CAP模块向第一Wi-Fi controller发送停止发送信息。
停止发送信息用于指示第一Wi-Fi controller将来自第一L2CAP模块的PCM音频数据发送完成后,向第一L2CAP模块反馈完成信息。
S703A,第一Wi-Fi controller响应于接收停止发送信息,在发送完PCM音频数据时,向第一L2CAP模块反馈完成信息。
第一Wi-Fi controller响应于接收停止发送信息,可以继续发送已经接收到的来自第一L2CAP模块的PCM音频数据,且在PCM音频数据发送完成时,向第一L2CAP模块反馈完成信息。
S704A,第一L2CAP模块向第一融合管理模块反馈完成信息。
S705A,第一L2CAP模块响应于接收完成信息,执行S604-S613,以及S620。
本申请实施例中,第一L2CAP模块在确定切换通路传输音频数据时,可以向当前正在使用的第一无线通路对应的controller发送停止发送信息,使得第一无线通路对应的controller在将来自第一L2CAP模块的音频数据发送完成后向第一L2CAP模块反馈完成信息,第一L2CAP模块响应于接收完成信息,可以采用第二无线通路传输数据,能够实现无 线通路的切换。
在如上其一中,第一L2CAP模块在切换通路传输音频数据时,因为需要在第一Wi-Fi controller或者第一BT controller发送完数据后,第一L2CAP模块才采用目标通路发送数据,会造成第一无线通路传输的音频数据与第二无线通路传输的音频数据之间的时间长,导致第二设备播放停顿,用户体验差。本申请实施例中,可以采用如下“其二”(即图9)中的方法解决该问题,减少因为通路切换造成的音频播放的时延:
其二:
在一种实施例中,示例性的,当第一无线通路为蓝牙通路时,在如上S608之后若第一融合管理模块执行S603确定目标通路为Wi-Fi通路,参照图9,可以执行如下步骤:
S901,第一融合管理模块从A2DP audio HAL中获取音频数据。
第一融合管理模块可以从A2DP audio HAL的buffer中获取音频数据。
S902,第一融合管理模块将音频数据复制为两份,且对音频数据进行标识,两份音频数据的标识相同。
第一融合管理模块将从A2DP audio HAL中获取的音频数据复制为两份,分别为第一音频数据和第二音频数据。第一融合管理模块可以对第一音频数据和第二音频数据进行标识,第一音频数据的标识和第二音频数据的标识相同。示例性的,第一融合管理模块可以对第一音频数据和第二音频数据进行编号,如分别编号为SN1,则第一融合管理模块可以得到两个编号为SN1的音频数据。
假设第一设备通过蓝牙通路发送的数据为第一音频数据,则在一种实施例中,第一融合管理模块从A2DP audio HAL中获取的音频数据可以称为第二音频数据。
S903,对于其中一份音频数据执行“S604、S605A、S606-S610”,对于其中一份音频数据执行“S614、S615A、S616-S618”。
S605A,A2DP模块响应于接收编码指令,从第一融合管理模块读取音频数据,对音频数据进行编码,得到编码数据。
其中,在对其中一份音频数据执行“S604、S605A、S606-S610”时,第一融合管理模块可以将音频数据的标识发送给A2DP模块,A2DP模块对音频数据进行编码,而不对音频数据的标识进行编码,得到编码数据,该编码数据的标识为音频数据的标识。
S615A,第一L2CAP模块从第一融合管理模块中读取音频数据。
与上述S605不同的是,因为第一融合管理模块将A2DP audio HAL中的音频数据复制成两份,因此S605A中A2DP模块需要从第一融合管理模块中获取数据。同理的,与上述S615不同的是,S615A中第一L2CAP模块需要从第一融合管理模块中获取数据。
其中,在对于其中一份音频数据执行“S614、S615A、S616-S618”时,第一融合管理模块可以将音频数据的标识发送给第一L2CAP模块,第一L2CAP模块从第一融合管理模块中读取音频数据,该音频数据的标识即为来自第一融合管理模块的音频数据的标识。
示例性的,对于编号为SN1的第一音频数据,可以执行“S604、S605A、S606-S610”,对于编号为SN1的第二音频数据,可以执行“S614、S615A、S616-S618”。如此,第二L2CAP模块可以接收到两份编号相同的音频数据。应理解,图9中未示出“S604、S605A、S606-S610”和“S614、S615A、S616-S618”的具体过程,可以参照上述实施例中的相关描述。
S904,第二L2CAP模块响应于接收到相同标识的音频数据,向第二融合管理模块发送标识相同的信息。
第二L2CAP模块因为可以分别接收到来自第二BT controller和第二Wi-Fi controller的音频数据,因此当第二L2CAP模块接收到相同标识的音频数据时,可以确定第一设备正在通过Wi-Fi通路发送音频数据,且基于音频数据的标识,可以确定音频数据是连续不丢包的,可以避免卡顿和停顿问题。
当第二L2CAP模块响应于接收到相同标识的音频数据,可以向第二融合管理模块发送标识相同的信息。标识相同的信息用于表征第二L2CAP模块接收到来自蓝牙通路和Wi-Fi通路相同的标识的音频数据。
S905,第二融合管理模块响应于接收标识相同的信息,通过第二L2CAP模块、第二BT controller向第一BT controller发送停止使用蓝牙通路的信息。
其中,停止使用蓝牙通路的信息用于指示通过Wi-Fi通路发送音频数据,停止使用蓝牙通路发送音频数据,以减小第一设备的功耗。
S906,第一BT controller响应于接收停止使用蓝牙通路的信息,通过第一L2CAP模块向第一融合管理模块反馈停止使用蓝牙通路的信息。
S907,第一融合管理模块响应于接收停止使用蓝牙通路的信息,执行S614-S619,以及S620。
在一种实施例中,S905中第二融合管理模块响应于接收标识相同的信息,也可以通过第二L2CAP模块、第二Wi-Fi controller向第一Wi-Fi controller发送停止使用蓝牙通路的信息,进而第一Wi-Fi controller可以通过第一L2CAP模块向第一融合管理模块反馈停止使用蓝牙通路的信息。
示例性的,S901-S907可以参照图10所示。图10中的a所示的为第一L2CAP模块通过蓝牙通路发送音频数据,图10中的b所示的为第一融合管理模块执行S603确定目标通路为Wi-Fi通路后,可以分别通过蓝牙通路和Wi-Fi通路发送相同的音频数据。图10中的c所示的为第二L2CAP模块响应于接收到相同标识的音频数据后,可以向第一BT controller发送停止使用蓝牙通路的信息,使得第一设备可以通过Wi-Fi通路发送音频数据。
在该实施例中,第一L2CAP模块再次执行的“S614-S619,以及S620”中的音频数据可以称为第三音频数据。应注意,第一音频数据、第二音频数据与第二音频数据可以属于同一音频中的不同部分或者属于不同的音频。
同理的,示例性的,当第一无线通路为Wi-Fi通路时,在如上S616之后,若第一融合管理模块执行S603确定目标通路为蓝牙通路,可以执行如下步骤:
S901A,第一融合管理模块从A2DP audio HAL中获取音频数据。
S902A,第一融合管理模块将音频数据复制为两份,且对音频数据进行标识,两份音频数据的标识相同。
S903A,对于其中一份音频数据执行“S604、S605A、S606-S610”,对于其中一份音频数据执行“S614、S615A、S616-S618”。
S904A,第二L2CAP模块响应于接收到相同标识的音频数据,向第二融合管理模块发送标识相同的信息。
S905A,第二融合管理模块响应于接收标识相同的信息,通过第二L2CAP模块、第二 BT controller向第一BT controller发送停止使用Wi-Fi通路的信息。
其中,停止使用Wi-Fi通路的信息用于指示通过蓝牙通路发送音频数据,停止使用Wi-Fi通路发送音频数据,以减小第一设备的功耗。
S906A,第一BT controller响应于接收停止使用Wi-Fi通路的信息,通过第一L2CAP模块向第一融合管理模块反馈停止使用Wi-Fi通路的信息。
S907A,第一融合管理模块响应于接收停止使用Wi-Fi通路的信息,执行S604-S613,以及S620。
如上S901A-S907A所示的步骤可以适用于“第一设备切换至低功耗模式,第一融合管理可以确定目标通路为蓝牙通路”的场景中。
在一种实施例中,S905A中第二融合管理模块响应于接收标识相同的信息,也可以通过第二L2CAP模块、第二Wi-Fi controller向第一Wi-Fi controller发送停止使用蓝牙通路的信息,进而第一Wi-Fi controller可以通过第一L2CAP模块向第一融合管理模块反馈停止使用蓝牙通路的信息。
本申请实施例中,第一融合管理模块根据目标参数,确定将第一无线通路切换至第二无线通路传输音频数据时,第一融合管理模块可以将A2DP audio HAL中的音频数据复制成标识相同的两份音频数据,待第二L2CAP模块接收到相同标识的音频数据,进而第二L2CAP模块可以通知第一设备停止使用第一无线通路传输音频数据,该实施例中可以避免两个通路切换时音频数据衔接时间长的问题,保证了第二设备音频播放的流畅性,可以提高用户体验。
如上“其一和其二”所述的实施例中,第一融合管理模块可以根据目标参数,确定是否切换传输音频数据的通路,以及确定目标通路是蓝牙通路还是Wi-Fi通路,进而第一设备可以适应性地切换音频数据的传输的通路,在能够使得用户享受高音质的基础上,又可以在干扰环境下保证音频播放的流畅性,还能够避免音频播放卡顿,提高用户体验。
在一种实施例中,本申请实施例还提供一种数据传输方法,第一融合管理模块无需基于目标参数确定目标通路是蓝牙通路还是Wi-Fi通路,而是直接将蓝牙通路和Wi-Fi通路均作为目标通路,将A2DP audio HAL中的音频数据复制成两份,分别通过蓝牙通路和Wi-Fi通路进行传输,第二设备可以基于接收到的音频数据进行处理、播放,具体可以参照下述图11中的相关描述。
图11为本申请实施例提供的数据传输方法的另一种实施例的流程示意图。参照图11,本申请实施例提供的数据传输方法可以包括:
S1101,应用程序响应于接收播放音频的指令,通过Audio FWK向A2DP audio HAL传输音频数据。
S1102,A2DP audio HAL缓存音频数据。
S1103,第一融合管理模块从A2DP audio HAL中获取音频数据。
S1104,第一融合管理模块将音频数据复制为两份,且对音频数据进行标识,两份音频数据的标识相同。
应理解,下述以将音频数据复制成两份后的数据分别为第一数据和第二数据为例进行说明。
S1105,对于其中一份音频数据执行“S604、S605A、S606-S610”,对于其中一份音频数据执行“S614、S615A、S616-S618”。
如上S1101-S1102可以参照S601-S602中的相关描述,S1103-S1105可以参照S901-S903中的相关描述。
S1106,第二L2CAP模块响应于接收到具有相同标识的来自第二Wi-Fi controller的第一数据和来自第二BT controller的第二数据,将第一数据存入第二融合管理模块的buffer中,丢弃第二数据。
第二融合管理模块用于构建和维护buffer,buffer用于存储音频数据,该buffer可以称为音频buffer。第二融合管理模块可以预先为buffer预先设置有一个水线值(water flow),保证音频播放的稳定性。可以理解的是,水线值可以表征buffer中存储的音频数据的最小数据量。
在一种实施例中,若第二Wi-Fi controller能够接收到来自第一Wi-Fi controller的音频数据,以及第二BT controller能够接收到来自第一BT controller的音频数据,则第二L2CAP模块可以接收到来自第二Wi-Fi controller和第二BT controller的音频数据。其中,当第二L2CAP模块接收到具有相同标识的来自第二Wi-Fi controller的第一数据,以及来自第二BT controller的第二数据时,为了使得用户可以享受(体验)到高清音频,第二L2CAP模块可以将第一数据存入第二融合管理模块的buffer中,丢弃第二数据。
其中,因为第二L2CAP模块接收到具有相同标识的第一数据和第二数据,即音频数据传输未丢包,因此第二L2CAP模块为了使得用户可以享受到高清音频,可以采用第一数据播放音频,丢弃第二数据也不会造成音频的卡顿,还能够减小buffer的存储压力。
应理解的是,第二融合管理模块的buffer中的音频数据用于使得播放器播放音频。其中,播放器可以从第二融合管理模块的buffer中读取音频数据,播放音频。播放器从第二融合管理模块的buffer中读取音频数据的过程可以为:播放器可以从第二融合管理模块的buffer中取出音频数据,进行播放。这样,第二融合管理模块在将音频数据存储至第二融合管理模块的buffer时,播放器可以从第二融合管理模块的buffer中取出数据进行播放。第二融合管理模块的buffer中的音频数据的数据量并不是一直累加的,而是与第二融合管理模块存储音频的速度和播放器取出音频数据的速度相关。
S1107,第二L2CAP模块响应于第二融合管理模块的buffer中的音频数据的数据量小于水线值,将来自第二BT controller的音频数据进行解码处理后存入第二融合管理模块的buffer中。
应理解,S1106和S1107-S1108之间没有先后顺序的区分,可以择一执行。
当Wi-Fi通路的通信质量差,第二Wi-Fi controller无法接收到来自第一Wi-Fi controller的音频数据,相应的,第二L2CAP模块也不能接收来自第二Wi-Fi controller的音频数据。在该种情况下,若第二L2CAP模块未接收到来自第二Wi-Fi controller的音频数据,则不会向第二融合管理模块的buffer中存储音频数据,随着播放器播放音频,导致第二融合管理模块的buffer中的音频数据的数据量逐渐减少,第二L2CAP模块为了保证音频播放的流畅性,第二L2CAP模块可以将来自第二BT controller的音频数据经编解码模块解码后,存入第二融合管理模块的buffer中,以增加第二融合管理模块的buffer中的数据量。
应理解,第二L2CAP模块将来自第二BT controller的音频数据进行解码处理,可以理解 为,第二L2CAP模块将来自第二BT controller的音频数据发送给编解码模块,以使编解码模块对来自第二BT controller的音频数据进行解码处理,得到PCM音频数据。
S1108,播放器从第二融合管理模块的buffer中读取音频数据,播放音频。
基于S1106-S1107中的描述,第二融合管理模块的buffer中存入的均是PCM音频数据。如此,播放器可以从第二融合管理模块的buffer中读取PCM音频数据,进而基于PCM音频数据,播放音频。
示例性的,S1101-S1108可以参照图12所示。图12中的a所示的为第一设备分别通过第一BT controller、第一Wi-Fi controller向第二设备发送音频数据。其中,第二L2CAP模块响应于接收到具有相同标识(如编号SN1)的来自第二Wi-Fi controller的第一数据,以及来自第二BT controller的第二数据,可以将第一数据存入第二融合管理模块的buffer中,丢弃第二数据。参照图12中的b所示,若Wi-Fi通路的通信质量差,导致第二融合管理模块的buffer中的音频数据的数据量逐渐减少,为了保证音频播放的流畅性,第二L2CAP模块响应于第二融合管理模块的buffer中的音频数据的数据量小于水线值,将来自第二BT controller的音频数据进行解码处理后存入第二融合管理模块的buffer中。应理解,图12的b中以“×”表征Wi-Fi通路的通信质量差,第二融合管理模块的buffer中的音频数据的数据量小于水线值。
在一种实施例中,若Wi-Fi通路的通信质量差,第一融合管理模块检测到蓝牙通路的通信质量也小于蓝牙通路的预设通信质量,为了保证音频数据的顺利传输,可以将音频数据进行编码后传输,在该种实施例中,Wi-Fi通路和蓝牙通路传输的均为编码后的音频数据,即编码数据。应理解,在该种实施例中,Wi-Fi通路传输的编码数据和蓝牙通路传输的编码数据的编码方式可以相同或不同。示例性的,蓝牙通路传输的编码数据是经A2DP编码得到的,Wi-Fi通路传输的编码数据可以是经A2DP编码得到的,或者经第一设备中的其他按编码模块编码得到的,下述实施例中以Wi-Fi通路传输的编码数据和蓝牙通路传输的编码数据的编码方式可以相同为例进行说明。
相应的,在该种实施例中,S1105可以替换为S1105A:对于其中一份音频数据执行“S604、S605A、S606-S610”,对于其中一份音频数据执行“S614、S604A、S605A、S606-S607,以及S616A-S618A”。
S604A,第一融合管理模块向A2DP模块发送编码指令。
S616A,第一L2CAP模块通过第一TCP/IP模块,向第一Wi-Fi controller发送编码数据。
S617A,第一Wi-Fi controller向第二Wi-Fi controller发送编码数据。
S618A,第二Wi-Fi controller响应于来自第一Wi-Fi controller的编码数据,经过第二TCP/IP模块向第二L2CAP模块发送编码数据。
如此,在该种实施例中,第二L2CAP模块可以接收来自第二BT controller的编码数据,以及来自第二Wi-Fi controller的编码数据。
在该种实施例中,上述S1106-S1108可以替换为S1106A-S1108A:
S1106A,第二L2CAP模块响应于接收到具有相同标识的来自第二Wi-Fi controller的第一数据和来自第二BT controller的第二数据,将第一数据进行解码处理后存入第二融合管理模块的buffer中,且丢弃第二数据。
其中,本申请实施例中,因为Wi-Fi通路上传输的也为编码数据,因此第二L2CAP模块响应于接收到具有相同标识的第一数据和第二音频数据,可以将第一数据进行解码处理后 存入第二融合管理模块的buffer中,丢弃第二数据。
S1107A,第二L2CAP模块响应于第二融合管理模块的buffer中的音频数据的数据量小于水线值,将来自第二BT controller的音频数据进行解码处理后存入第二融合管理模块的buffer中。
在S1107A之后,可以执行S1108。
示例性的,“S1101-S1104、S1105A-S1107A,以及S1108”可以参照图13所示。与上述图12不同的是,图13中的来自第二Wi-Fi controller的编码数据需要经过解码后存入第二融合管理模块的buffer中。具体的,图13中的a所示的为第一设备分别通过第一BT controller、第一Wi-Fi controller向第二设备发送编码数据。其中,第二L2CAP模块响应于接收到具有相同标识(如编号SN1)的来自第二Wi-Fi controller的第一数据,以及来自第二BT controller的第二数据,可以将第一数据经解码后存入第二融合管理模块的buffer中,丢弃第二数据。参照图13中的b所示,若Wi-Fi通路的通信质量差,导致第二融合管理模块的buffer中的音频数据的数据量逐渐减少,第二融合管理模块的buffer中的音频数据的数据量小于水线值,将来自第二BT controller的音频数据进行解码处理后存入第二融合管理模块的buffer中。应理解,图13的b中以“×”表征Wi-Fi通路的通信质量差,第二融合管理模块的buffer中的音频数据的数据量小于水线值。
本申请实施例中,第二L2CAP模块响应于接收到具有相同标识的音频数据时,可以优先将来自第二Wi-Fi controller的音频数据存入第二融合管理模块的buffer中,使得播放器可以基于来自第二Wi-Fi controller的音频数据播放音频,以使得用户可以享受到高清音频。另外,在Wi-Fi通路的通信质量差时,即第二融合管理模块的buffer中的音频数据的数据量低于水线值,第二L2CAP模块可以将来自第二BT controller的音频数据经编解码模块解码后,存入第二融合管理模块的buffer中,使得播放器可以基于来自第二BT controller的音频数据播放音频,以保证音频播放的流畅性,音频播放不卡顿。
在一种实施例中,上述S1106-S1107可以替换为S1106B:第二L2CAP模块根据来自第二Wi-Fi controller的音频数据的第一标识,以及来自第二BT controller的音频数据的第二标识,若第二融合管理模块的buffer中未包含第一标识且包含第二标识,则第二融合管理模块可以将来自第二Wi-Fi controller的音频数据存入第二融合管理模块的buffer中,丢弃来自第二BT controller的音频数据。同理的,若第二融合管理模块的buffer中未包含第二标识且包含第一标识,则第二融合管理模块可以将来自第二BT controller的音频数据存入第二融合管理模块的buffer中,丢弃来自第二Wi-Fi controller的音频数据。
在该种实施例中,示例性的,若第二融合管理模块的buffer中已经存入编号为SN1和编号为SN2的音频数据,其中,编号为SN1的音频数据来自第二Wi-Fi controller,编号为SN2的音频数据来自第二BT controller。若第二L2CAP模块接收到来自第二BT controller的编号为SN3音频数据,以及来自第二Wi-Fi controller的编号为SN2的音频数据,因为第二融合管理模块的buffer中未包含的标识“编号为SN3”,已包含标识“编号为SN2”,则第二L2CAP模块可以将来自第二BT controller的编号为SN3的音频数据存入第二融合管理模块的buffer中,丢弃来自第二Wi-Fi controller的编号为SN2的音频数据。
本申请实施例中,第二L2CAP模块可以基于接收到的音频数据的标识,将优先接收到 的标识的音频数据存入第二融合管理模块的buffer中,可以保证音频数据播放的流畅性。
根据图3A和图3B所示的第一设备和第二设备,对于第一设备和第二设备来说,参照图14,本申请实施例提供的数据传输方法可以包括:
S1401,第一设备通过第一无线通路向第二设备发送第一音频数据,第一音频数据用于第二设备播放第一音频。
第一设备与第二设备已建立第一无线通路和第二无线通路,第一无线通路为蓝牙通路或Wi-Fi通路,第二无线通路为蓝牙通路或Wi-Fi通路,第一无线通路和第二无线通路不同。第一设备可以通过第二设备播放音频。本申请实施例中,第一设备通过第一无线通路向第二设备发送第一音频数据。其中,第一音频数据用于第二设备播放第一音频。
S1402,基于第一音频数据,播放第一音频。
S1403,若根据目标参数确定数据传输的目标通路为第二无线通路,则第一设备通过第二无线通路向第二设备发送第二音频数据,目标参数与如下至少一项相关:第一无线通路的通信质量、第二无线通路的通信质量、第一设备的运行模式,以及第二设备的运行模式,第二音频数据用于第二设备播放第二音频。
目标参数与如下至少一项相关:第一无线通路的通信质量、第二无线通路的通信质量、第一设备的运行模式,以及第二设备的运行模式,第二音频数据用于第二设备播放第二音频,目标参数可以参照上述实施例中的相关描述。
在一种实施例中,目标参数还与音频数据的类型相关,音频数据的类型可以为:高清或非高清,可以参照上述实施例中的相关描述。第一设备根据目标参数确定目标通路的方式可以参照S603中的相关描述。
若第一设备根据目标参数确定数据传输的目标通路为第二无线通路,则第一设备通过第二无线通路向第二设备发送第二音频数据,可以参照上述实施例中的相关描述。
第二音频数据与第一音频数据可以为同一音频中的数据,如音频为歌曲,则第一设备可以先向第二设备发送该歌曲中的一部分音频数据,再向第二设备发送该歌曲中的一部分音频数据,使得第二设备可以基于来自第一设备的音频数据,播放该歌曲。或者,第二音频数据与第一音频数据可以为不同音频中的数据,如第一音频数据为一首歌曲的结尾对应的音频数据,第二音频数据为另一首歌曲开头部分对应的音频数据。
应理解的是,第一设备在通过第一无线通路向第二设备发送第一音频数据之前,也需要通过目标参数确定传输第一音频数据的目标通路为第一无线通路,可以参照S603中的相关描述。
S1404,基于第二音频数据,播放第二音频。
本申请实施例中,第一设备在通过第二设备播放音频时,第一设备可以根据目标参数,切换传输音频数据的通路,可以保证用户在享受高清音频的同时,又可以在干扰环境下保证音频播放的流畅性,避免音频卡顿,可以提高用户体验。
在一种实施例中,在S1402中,第一设备在通过第二无线通路向第二设备发送第二音频数据之前,可以检测通过第一无线通路是否已发送完第一音频数据,具体的检测方式可以参照S701-S705,以及S701A-S705A中的相关描述。第一设备响应于检测到通过第一无线通路已发送完第一音频数据,通过第二无线通路向第二设备发送第二音频数据。
在一种实施例中,为了减少因为通路切换造成的音频播放的时延,第一设备可以将第二音频数据复制两份,分别为第一数据和第二数据,且对第一数据和第二数据标注为相同的标识。第一设备通过第一无线通路向第二设备发送第一数据,以及通过第二无线通路向第二设备发送第二数据。
在该实施例中,第二设备响应于接收来自第一设备的两个无线通路具有相同标识的第一数据和第二数据,可以向第一设备发送停止使用第一无线通路的信息。另外,第二设备可以基于来自第二无线通路的数据,播放第二音频。
相应的,第一设备响应于接收到停止使用第一无线通路的信息,可以通过第二无线通路向第二设备发送第三音频数据。应理解,第二设备响应于接收第三音频数据,可以播放第三音频。
在一种实施例中,第一设备可以无需通过目标参数确定目标通路,而是直接同时通过第一无线通路和第二无线通路向第二设备发送音频数据。在一种实施例中,第一无线通路为Wi-Fi通路,第二无线通路为蓝牙通路。参照图15,该种实施例中的数据传输方法可以包括:
S1501,第一设备将第一音频数据复制两份,分别为第一数据和第二数据,第一音频数据用于第二设备播放第一音频。
S1502,第一设备对第一数据和第二数据标注为相同的标识。
S1503,第一设备通过第一无线通路向第二设备发送第一数据。
S1504,第一设备通过第二无线通路向第二设备发送第二数据。
S1501-S1504可以参照上述图11中的相关描述。
S1505,第二设备将第一数据存储在第二设备的缓存区中。
S1506,第二设备基于缓存区中的第一数据,播放第一音频。
本申请实施例中,第二设备响应于接收到来自第一设备的具有相同标识的第一数据和第二数据,可以将来自Wi-Fi通路的第一数据存储在第二设备的缓存区中,进而基于缓存区中的第一数据,播放第一音频。因为来自Wi-Fi通路的音频数据为不经编码的数据,因此,用户可以享受高清音频。
在一种实施例中,若Wi-Fi通路的质量变差,导致第二设备的缓存区中的音频数据的数据量逐渐减少,为了保证音频播放的流畅性,第二设备响应于第二设备的缓存区中的音频数据的数据量小于水线值,将来自蓝牙通路的音频数据进行解码处理后存入第二设备的缓存区中。
在一种实施例中,参照S1106B的描述,为了保证音频数据播放的流畅性,第二设备可以根据来自第一设备的第一无线通路的音频数据的第一标识,以及第二无线通路的音频数据的第二标识,若第二设备的缓存区中未包含第一标识且包含第二标识,则第二设备可以将来自第一无线通路的音频数据存入第二设备的缓存区中,丢弃来自第二无线通路的音频数据。这样,第二设备先接收到哪个通路的音频数据,则优先将该通路的音频数据存储在第二设备的缓存区中进行播放,可以保证音频数据播放的流畅性。
在一种实施例中,本申请实施例还提供一种电子设备,该电子设备可以为上述实施例 中所述的第一设备、第二设备,参照图16,该电子设备中可以包括:处理器161(例如上述实施例中的Host CPU)、存储器162、蓝牙控制器163以及Wi-Fi控制器164。存储器162可能包含高速随机存取存储器(random-access memory,RAM),也可能还包括非易失性存储器(non-volatile memory,NVM),例如至少一个磁盘存储器,存储器162中可以存储各种指令,以用于处理器161完成各种处理功能以及实现本申请的方法步骤,可以参照上述实施例中的相关描述。蓝牙控制器163以及Wi-Fi控制器164用于实现电子设备与其他设备之间进行连接通信。
可选的,本申请涉及的电子设备还可以包括:电源165、通信总线166。在本申请实施例中,存储器162用于存储计算机可执行程序代码,程序代码包括指令;当处理器161执行指令时,指令使电子设备的处理器161执行上述方法实施例中的动作,其实现原理和技术效果类似,在此不再赘述。
需要说明的是,上述实施例中所述的模块或部件可以是被配置成实施以上方法的一个或多个集成电路,例如:一个或多个专用集成电路(application specific integrated circuit,ASIC),或,一个或多个微处理器(digital signal processor,DSP),或,一个或者多个现场可编程门阵列(field programmable gate array,FPGA)等。再如,当以上某个模块通过处理元件调度程序代码的形式实现时,该处理元件可以是通用处理器,例如中央处理器(central processing unit,CPU)或其它可以调用程序代码的处理器如控制器。再如,这些模块可以集成在一起,以片上系统(system-on-a-chip,SOC)的形式实现。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行计算机程序指令时,全部或部分地产生按照本申请实施例的流程或功能。计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一个计算机可读存储介质传输,例如,计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。计算机可读存储介质可以是计算机能够存取的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
本文中的术语“多个”是指两个或两个以上。本文中术语“和/或”,仅仅是一种描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B这三种情况。另外,本文中字符“/”,一般表示前后关联对象是一种“或”的关系;在公式中,字符“/”,表示前后关联对象是一种“相除”的关系。另外,需要理解的是,在本申请的描述中,“第一”、“第二”等词汇,仅用于区分描述的目的,而不能理解为指示或暗示相对重要性,也不能理解为指示或暗示顺序。
可以理解的是,在本申请的实施例中涉及的各种数字编号仅为描述方便进行的区分,并不用来限制本申请的实施例的范围。
可以理解的是,在本申请的实施例中,上述各过程的序号的大小并不意味着执行顺序 的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请的实施例的实施过程构成任何限定。

Claims (20)

  1. 一种数据传输方法,其特征在于,应用于第一设备,所述第一设备与第二设备已建立第一无线通路和第二无线通路,所述第一无线通路为蓝牙通路或Wi-Fi通路,所述第二无线通路为所述蓝牙通路或所述Wi-Fi通路,所述第一无线通路和所述第二无线通路不同,所述方法包括:
    通过所述第一无线通路向所述第二设备发送第一音频数据,所述第一音频数据用于所述第二设备播放第一音频;
    若根据目标参数确定数据传输的目标通路为所述第二无线通路,则通过所述第二无线通路向所述第二设备发送第二音频数据,所述目标参数与如下至少一项相关:所述第一无线通路的通信质量、所述第二无线通路的通信质量、所述第一设备的运行模式,以及所述第二设备的运行模式,所述第二音频数据用于所述第二设备播放第二音频。
  2. 根据权利要求1所述的方法,其特征在于,所述通过所述第二无线通路向所述第二设备发送第二音频数据之前,还包括:
    检测通过所述第一无线通路是否已发送完所述第一音频数据;
    所述通过所述第二无线通路向所述第二设备发送第二音频数据,包括:
    响应于检测到通过所述第一无线通路已发送完所述第一音频数据,通过所述第二无线通路向所述第二设备发送所述第二音频数据。
  3. 根据权利要求1或2所述的方法,其特征在于,所述目标参数与所述第一无线通路的通信质量相关,所述根据目标参数确定数据传输的目标通路为所述第二无线通路,包括:
    若根据所述目标参数,确定所述第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
  4. 根据权利要求1或2所述的方法,其特征在于,所述目标参数与所述第一无线通路的通信质量和所述第二无线通路的通信质量相关,所述根据目标参数确定数据传输的目标通路为所述第二无线通路,包括:
    若根据所述目标参数,确定所述第一无线通路的通信质量小于或等于所述第一无线通路的预设通信质量,且所述第二无线通路的通信质量大于或等于所述第二无线通路的预设通信质量,则确定所述目标通路为所述第二无线通路。
  5. 根据权利要求1或2所述的方法,其特征在于,所述目标参数与所述第一设备的运行模式、所述第二设备的运行模式相关,所述根据目标参数确定数据传输的目标通路为所述第二无线通路,包括:
    当所述第一无线通路为Wi-Fi通路时,若检测到所述第一设备和/或所述第二设备的运行模式进入低功耗模式,则确定所述目标通路为蓝牙通路,所述蓝牙通路为所述第二无线通路。
  6. 根据权利要求1-5中任一项所述的方法,其特征在于,所述通过所述第二无线通路向所述第二设备发送第二音频数据之前,还包括:
    将所述第二音频数据复制两份,分别为第一数据和第二数据;
    对所述第一数据和所述第二数据标注为相同的标识;
    所述通过所述第二无线通路向所述第二设备发送第二音频数据,包括:
    通过所述第一无线通路向所述第二设备发送所述第一数据;
    通过所述第二无线通路向所述第二设备发送所述第二数据。
  7. 根据权利要求6所述的方法,其特征在于,所述通过所述第二无线通路向所述第二设备发送所述第二数据之后,还包括:
    响应于接收来自所述第二设备的停止使用所述第一无线通路的信息,通过所述第二无线通路向所述第二设备发送第三音频数据,所述第三音频数据用于所述第二设备播放第三音频。
  8. 根据权利要求1-7中任一项所述的方法,其特征在于,所述通过所述第一无线通路向所述第二设备发送第一音频数据之前,还包括:
    根据所述目标参数,确定传输所述第一音频数据的目标通路为所述第一无线通路。
  9. 根据权利要求8所述的方法,其特征在于,所述目标参数与所述第一音频数据的类型相关,所述第一无线通路为Wi-Fi通路,所述根据所述目标参数,确定传输所述第一音频数据的目标通路为所述第一无线通路,包括:
    基于所述目标参数,若确定所述第一音频数据的类型为预设类型,则确定传输所述第一音频数据的目标通路为所述Wi-Fi通路,所述预设类型与所述Wi-Fi通路具有映射关系;
    基于所述目标参数,若确定所述第一音频数据的类型为非预设类型,则确定传输所述第一音频数据的目标通路为所述蓝牙通路,所述非预设类型与所述蓝牙通路具有映射关系。
  10. 一种数据传输方法,其特征在于,应用于第二设备,第一设备与所述第二设备已建立第一无线通路和第二无线通路,所述第一无线通路为蓝牙通路或Wi-Fi通路,所述第二无线通路为所述蓝牙通路或所述Wi-Fi通路,所述第一无线通路和所述第二无线通路不同,所述方法包括:
    通过所述第一无线通路接收来自所述第一设备的第一音频数据;
    基于所述第一音频数据,播放第一音频;
    通过所述第二无线通路接收来自所述第一设备的第二音频数据;
    基于所述第二音频数据,播放第二音频。
  11. 根据权利要求10所述的方法,其特征在于,所述通过所述第二无线通路接收来自所述第一设备的第二音频数据,包括:
    通过所述第一无线通路接收来自所述第一设备的第一数据;
    通过所述第二无线通路接收来自所述第一设备的第二数据,所述第一数据和所述第二数据是所述第一设备将所述第二音频数据复制成两份得到的,所述第一数据和所述第二数据的标识相同;
    向所述第一设备发送停止使用所述第一无线通路的信息。
  12. 根据权利要求11所述的方法,其特征在于,所述向所述第一设备发送停止使用所述第一无线通路的信息之后,还包括:
    通过所述第二无线通路接收来自所述第一设备的第三音频数据;
    基于所述第三音频数据,播放第三音频。
  13. 一种数据传输方法,其特征在于,应用于第一设备,所述第一设备与第二设备已建立第一无线通路和第二无线通路,所述第一无线通路为蓝牙通路或Wi-Fi通路,所述第二无线通路为所述蓝牙通路或所述Wi-Fi通路,所述第一无线通路和所述第二无线通路不 同,所述方法包括:
    将第一音频数据复制两份,分别为第一数据和第二数据,所述第一音频数据用于所述第二设备播放第一音频;
    对所述第一数据和所述第二数据标注为相同的标识;
    通过所述第一无线通路向所述第二设备发送所述第一数据;
    通过所述第二无线通路向所述第二设备发送所述第二数据。
  14. 一种数据传输方法,其特征在于,应用于第二设备,第一设备与所述第二设备已建立第一无线通路和第二无线通路,所述第一无线通路为蓝牙通路或Wi-Fi通路,所述第二无线通路为所述蓝牙通路或所述Wi-Fi通路,所述第一无线通路和所述第二无线通路不同,所述方法包括:
    接收具有相同标识的来自所述第一无线通路的第一数据和来自所述第二无线通路的第二数据,所述第一数据和所述第二数据是所述第一设备将第一音频数据复制成两份得到的;
    将所述第一数据存储在缓存区中,所述第一无线通路为Wi-Fi通路;
    基于所述缓存区中的所述第一数据,播放第一音频。
  15. 根据权利要求14所述的方法,其特征在于,所述方法还包括:
    若所述缓存区中的音频数据的数据量小于预设数据量,将来自所述第二无线通路的数据进行解码处理后存入所述缓存区中,所述第二无线通路为蓝牙通路;
    基于所述缓存区中的解码处理后的数据,播放音频。
  16. 根据权利要求14所述的方法,其特征在于,所述方法还包括:
    根据来自所述第一无线通路的音频数据的第一标识,以及来自所述第二无线通路的音频数据的第二标识,若所述缓存区中未包含所述第一标识且包含所述第二标识,则将来自所述第一无线通路的音频数据存入所述缓存区中,丢弃来自所述第二无线通路的音频数据。
  17. 一种电子设备,其特征在于,包括:处理器、存储器;
    所述存储器存储计算机执行指令;
    所述处理器执行所述存储器存储的计算机执行指令,使得所述处理器执行如权利要求1-16中任一项所述的方法。
  18. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质中存储有计算机程序或指令,当所述计算机程序或指令被运行时,实现如权利要求1-16中任一项所述的方法。
  19. 一种计算机程序产品,包括计算机程序或指令,其特征在于,所述计算机程序或指令被处理器执行时,实现权利要求1-16中任一项所述的方法。
  20. 一种程序产品,其特征在于,所述程序产品包括计算机程序,所述计算机程序存储在可读存储介质中,通信装置的至少一个处理器可以从所述可读存储介质读取所述计算机程序,所述至少一个处理器执行所述计算机程序使得通信装置实施如权利要求1-16任意一项所述的方法。
PCT/CN2022/111317 2021-09-30 2022-08-10 数据传输方法、装置、电子设备和可读存储介质 WO2023051041A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111166561.5 2021-09-30
CN202111166561.5A CN115915481A (zh) 2021-09-30 2021-09-30 数据传输方法、装置、电子设备和可读存储介质

Publications (1)

Publication Number Publication Date
WO2023051041A1 true WO2023051041A1 (zh) 2023-04-06

Family

ID=85732300

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/111317 WO2023051041A1 (zh) 2021-09-30 2022-08-10 数据传输方法、装置、电子设备和可读存储介质

Country Status (2)

Country Link
CN (1) CN115915481A (zh)
WO (1) WO2023051041A1 (zh)

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006345158A (ja) * 2005-06-08 2006-12-21 Nec Infrontia Corp 無線lan端末装置、無線lanシステム及びプログラム
CN104285425A (zh) * 2012-05-15 2015-01-14 高通股份有限公司 通过经由多个信道进行服务来限制故障率的方法、系统和装置
CN108471638A (zh) * 2018-02-08 2018-08-31 深圳魔耳智能声学科技有限公司 无线耳机控制方法、装置、控制装置及存储介质
CN111224693A (zh) * 2019-11-27 2020-06-02 展讯通信(上海)有限公司 用于无线耳机的音频数据传输方法及装置、存储介质、终端

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JP2006345158A (ja) * 2005-06-08 2006-12-21 Nec Infrontia Corp 無線lan端末装置、無線lanシステム及びプログラム
CN104285425A (zh) * 2012-05-15 2015-01-14 高通股份有限公司 通过经由多个信道进行服务来限制故障率的方法、系统和装置
CN108471638A (zh) * 2018-02-08 2018-08-31 深圳魔耳智能声学科技有限公司 无线耳机控制方法、装置、控制装置及存储介质
CN111224693A (zh) * 2019-11-27 2020-06-02 展讯通信(上海)有限公司 用于无线耳机的音频数据传输方法及装置、存储介质、终端

Also Published As

Publication number Publication date
CN115915481A (zh) 2023-04-04

Similar Documents

Publication Publication Date Title
JP7302006B2 (ja) Bluetoothデバイスを操作するための方法
US10007479B2 (en) User terminal, method for playing audio data via bluetooth, and digital signal processor
US20220263883A1 (en) Adaptive audio processing method, device, computer program, and recording medium thereof in wireless communication system
US20080019440A1 (en) Apparatus and method for transmitting and receiving moving pictures using near field communication
WO2022143034A1 (zh) 投屏音视频数据的传输方法以及相关设备
US11800337B2 (en) Method and apparatus for establishing Bluetooth data channel
US9509947B2 (en) Method and apparatus for transmitting file during video call in electronic device
CA2731847C (en) Method and apparatus for wirelessly distributing multiplex signal comprising multimedia data over a local area network
TW201635740A (zh) 用於廣播自適應位元率串流之延遲補償
US8510461B2 (en) Network selection for streaming media among multiple devices
WO2023124587A1 (zh) 一种媒体文件的传输方法和设备
US20070287486A1 (en) Content reproduction system, content reproduction apparatus and content reproduction method
WO2023051041A1 (zh) 数据传输方法、装置、电子设备和可读存储介质
JP2011087070A (ja) ネットワーク機器、情報処理装置、ストリーム切替方法、情報処理方法、プログラムおよびコンテンツ配信システム
EP3979679A1 (en) Method, apparatus and computer program for broadcast discovery service in wireless communication system, and recording medium therefor
JP2014131142A (ja) 受信装置、受信方法、及びプログラム、撮像装置、撮像方法、及びプログラム、送信装置、送信方法、及びプログラム
WO2022222556A1 (zh) 一种蓝牙设备中编解码能力的获取方法及电子设备
TW201009823A (en) Recording apparatus, recording method, recording medium, and recording system
CN115174538A (zh) 数据传输方法、装置、电子设备及计算机可读介质
KR100918571B1 (ko) 통화중 배경음악을 P2P 방식으로 제공하는 VoIP통신 시스템
WO2024007998A1 (zh) 一种数据传输的方法、电子设备和通信系统
KR20130050815A (ko) 컨텐츠 제공 서버 및 방법
WO2022252842A1 (zh) 一种媒体文件传输方法及装置
JP2017225164A (ja) 受信装置、受信方法、送信装置、送信方法、及びプログラム
WO2024007133A1 (zh) 一种传输方法、装置和终端

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22874437

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE