A codec negotiation and switching method

By pre-determining a common codec category between electronic devices and audio playback devices, and directly selecting the codec in this category for transmission when audio data parameters change, the problems of audio data interruption and lag when codec switching are solved, and the user experience is improved.

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

Patent Information

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

AI Technical Summary

Technical Problem

When the electronic device negotiates the codec type with the audio playback device, if the network conditions change or the user selects higher quality sound, the audio data will be interrupted and stuck, affecting the user experience.

Method used

The electronic device and the audio playback device determine the common codec category before negotiation, and directly select the codec in the category for transmission when the audio data parameters change, avoiding re-negotiation and achieving fast switching of the codec.

Benefits of technology

This solves the audio data interruption and freeze issues when switching codecs, improving the user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115223579B_ABST
    Figure CN115223579B_ABST
Patent Text Reader

Abstract

The present application provides a codec negotiation and switching method, which is applied to a codec negotiation and switching system, and the system includes an electronic device and an audio playback device. Before transmitting audio data, the electronic device and the audio playback device divide the codec into multiple categories, and determine the codec category (for example, the first category and the second category) shared by the electronic device and the audio playback device. Afterwards, the electronic device transmits audio data with the audio playback device according to the codec in the first category. When the codec needs to be switched, the electronic device does not need to renegotiate the type of codec with the audio playback device, and directly transmits audio data according to the codec in the second category. This achieves that when the electronic device switches the encoder, there is no need to renegotiate the type of codec with the audio playback device, thereby solving the problem of audio data interruption and freeze when the electronic device switches the codec with the audio playback device, and improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of audio processing technology, and in particular to a codec negotiation and switching method. Background Art

[0002] As users' pursuit of audio experience continues to improve, audio content supporting features such as high-definition sound quality, multi-channel, and 3D Audio is becoming increasingly rich. Corresponding codec technologies are also rapidly emerging, and it has become the norm for wireless audio devices to be equipped with multiple audio codecs (Coder-Decoder, Codec).

[0003] Each time an electronic device establishes a connection with an audio playback device, the electronic device and the audio playback device negotiate and obtain the codec type supported by both parties. After that, the electronic device processes the audio data according to the codec type supported by both parties, and then the electronic device sends the encoded audio data to the audio playback device. The audio playback device receives the encoded audio data and decodes it using the corresponding decoder for playback.

[0004] When the network of an electronic device deteriorates or the user selects a higher quality sound, the electronic device needs to switch the encoder. At this time, the electronic device and the audio playback device need to renegotiate the type of codec. During the process of the electronic device and the audio playback device renegotiating the type of codec, the electronic device will pause sending audio data to the audio playback device, resulting in audio data interruption and freeze, affecting the user experience. Therefore, how to achieve fast switching of the codec between the electronic device and the audio playback device and uninterrupted audio data flow during the switching process is an urgent problem to be solved. Summary of the Invention

[0005] The present application provides a codec negotiation and switching method, which implements that when an electronic device needs to switch encoders, there is no need to renegotiate the codec type with the audio playback device. A codec in a category supported by both parties that has been previously negotiated can be directly selected for audio data transmission. This solves the problem of audio data interruption and freeze when the electronic device and the audio playback device switch codecs, and improves the user experience.

[0006] In a first aspect, the present application provides a codec negotiation and switching system, which includes an electronic device and an audio playback device, wherein: the electronic device is used to: when the first parameter information of the audio data meets the first condition, encode the audio data into first encoded audio data according to the first encoder in the first category, and send the first encoded audio data to the audio playback device; wherein the first category is that the electronic device determines the codec category shared by the electronic device and the audio playback device before obtaining the audio data; sends the identifier of the first category to the audio playback device; the audio playback device is used to: receive the identifier of the first category sent by the electronic device; decode the first encoded audio data into the first decoder in the first category through the first decoder in the first category. Play audio data; the electronic device is further used to: when the second parameter information of the audio data meets the second condition, encode the audio data into second encoded audio data according to the second encoder in the second category, and send the second encoded audio data to the audio playback device; wherein the second category is a codec category shared by the electronic device and the audio playback device, which is determined by the electronic device before obtaining the audio data; send the identifier of the second category to the audio playback device; the audio playback device is further used to: receive the identifier of the second category sent by the electronic device; decode the second encoded audio data into second playback audio data through the second decoder in the second category; wherein the first condition is different from the second condition, and the first category is different from the second category.

[0007] Through the system of the first aspect, before transmitting audio data, the electronic device and the audio playback device divide the codec into multiple categories and determine the codec category (e.g., the first category and the second category) shared by the electronic device and the audio playback device. Afterwards, the electronic device obtains the first parameter information of the audio data. When the first parameter information of the audio data meets the first condition, the codec in the first category is selected from the shared codec category to transmit the audio data. When the content of the played audio data, the application of the played audio data, the user selection, or the network conditions change, the electronic device obtains the second parameter of the audio data. When the second parameter of the audio data meets the second condition, the electronic device does not need to negotiate the codec with the audio playback device again, and directly selects the codec in the second category of the shared codec category to transmit the audio data. In this way, when the electronic device needs to switch the encoder, it does not need to renegotiate the codec type with the audio playback device. It directly selects a codec in a category from the previously negotiated codec categories supported by both parties for audio data transmission, solving the problem of audio data interruption and jamming when the electronic device and the audio playback device switch codecs, thereby improving the user experience.

[0008] With reference to the first aspect, in a possible implementation, the encoders in the first category include at least a first encoder, and the encoders in the second category include at least a second encoder.

[0009] In combination with the first aspect, in a possible implementation, the electronic device is further used to: receive an identifier of a first category and an identifier of a second category sent by an audio playback device; wherein the decoders in the first category include at least a first decoder, and the decoders in the second category include at least a second decoder. In this way, the audio playback device divides the decoders into multiple categories according to the codec classification standard. Exemplarily, the codec categories whose decoder identifiers are greater than or equal to 1 among the multiple categories are the first category and the second category. The decoders classified into the first category include at least the first decoder and may also include other decoders, such as a third decoder; the decoders classified into the second category include at least the second decoder and may also include other decoders, such as a fourth decoder.

[0010] In conjunction with the first aspect, in one possible implementation, the electronic device is further configured to: confirm that the electronic device and the audio playback device share a first category and a second category; and transmit an identifier of the first category and an identifier of the second category to the audio playback device; and the audio playback device is further configured to: receive the identifier of the first category and the identifier of the second category transmitted by the electronic device. The electronic device transmits a codec category supported by both parties to the audio playback device, so that the audio playback device knows the codec category supported by both parties.

[0011] In another possible implementation, the electronic device may not need to send the first category identifier and the second category identifier to the audio playback device. When transmitting audio data, the electronic device only needs to send the identifier of the codec category used according to the parameter information of the audio data to the audio playback device.

[0012] In conjunction with the first aspect, in one possible implementation, the encoders in the first category include only the first encoder, and the decoders in the first category include only the first decoder. After the electronic device determines that the electronic device and the audio playback device share the first and second categories, the electronic device is further configured to: when the first parameter information satisfies a first condition, encode the audio data into first encoded audio data using the first encoder in the first category, and send the first encoded audio data to the audio playback device; the audio playback device is further configured to decode the first encoded audio data into first playback audio data using the first decoder in the first category. The electronic device and the audio playback device both support the first and second categories of codecs. When the first category includes only one encoder and one decoder, the electronic device uses the encoder and decoder in the first category as the default encoder and decoder. Subsequently, when the electronic device and the audio playback device use the codec in the first category for audio data transmission, the audio data is encoded into the first encoded audio data using the default encoder in the first category. The electronic device then sends the first encoded audio data to the audio playback device, and the audio playback device decodes the first encoded audio data into the first playback audio data using the default decoder in the first category.

[0013] In conjunction with the first aspect, in one possible implementation, the encoder in the first category further includes a third encoder, and the decoder in the first category further includes a third decoder. After the electronic device determines that the electronic device and the audio playback device share the first and second categories, the electronic device is further configured to: when the first parameter information satisfies a first condition, encode the audio data into first encoded audio data using a first encoder in the first category, and transmit the first encoded audio data to the audio playback device; wherein the first encoder has lower power consumption than the third encoder, or the first encoder has a higher priority or power than the third encoder; and the audio playback device is further configured to decode the first encoded audio data into first playback audio data using a first decoder in the first category; wherein the first decoder has lower power consumption than the second decoder, or the first decoder has a higher priority or power than the second decoder. The electronic device and the audio playback device both support the first and second categories of codecs. When the first category includes multiple encoders and multiple decoders, the electronic device determines an encoder from the multiple encoders as a default encoder according to a preset rule, and determines a decoder from the multiple decoders as a default decoder according to the preset rule. The default rule may be a priority rule, an efficiency rule, a power consumption rule, or the like. It should be noted that the electronic device can determine an encoder as a default encoder from multiple encoders according to a preset rule, and determine a decoder as a default decoder from multiple decoders according to a preset rule. In another possible implementation, the electronic device only needs to determine an encoder as a default encoder from multiple encoders according to a preset rule, and the audio playback device determines a decoder as a default decoder from multiple decoders according to a preset rule. This application does not limit this.

[0014] In conjunction with the first aspect, in one possible implementation, when the encoder category shared by the electronic device and the audio playback device only includes the first category, the electronic device is further configured to: when the second parameter information satisfies the second condition, encode the audio data into third encoded audio data using the first encoder in the first category, and send the third encoded audio data to the audio playback device; the audio playback device is further configured to decode the third encoded audio data into third playback audio data using the first decoder in the first category. When the electronic device and the audio playback device only support one codec category, in this case, when the parameter information of the audio data changes from the first parameter information to the second parameter information, and the second parameter information satisfies the second condition, the electronic device cannot switch the codec, and the electronic device still uses the default codec in the first category to transmit audio data to the audio playback device.

[0015] In combination with the first aspect, in one possible implementation, the encoder category shared by the electronic device and the audio playback device only includes the first category, including: the electronic device does not receive the second category identifier sent by the audio playback device; or the number of encoders classified by the electronic device into the second category is 0.

[0016] In conjunction with the first aspect, in one possible implementation, the encoders in the first category include only the first encoder, and the decoders in the first category include only the first decoder. When the first parameter information satisfies the first condition, the electronic device is further configured to: encode audio data into first encoded audio data using the first encoder in the first category, and transmit the first encoded audio data to an audio playback device; the audio playback device is further configured to decode the first encoded audio data into first playback audio data using the first decoder in the first category. The codec category supported by both the electronic device and the audio playback device only includes the first category. When the first category includes only one encoder and one decoder, the electronic device uses the encoder and decoder in the first category as the default encoder and decoder. Subsequently, when the electronic device and the audio playback device use the codec in the first category for audio data transmission, the audio data is encoded into first encoded audio data using the default encoder in the first category. The electronic device then transmits the first encoded audio data to the audio playback device, and the audio playback device decodes the first encoded audio data into first playback audio data using the default decoder in the first category.

[0017] In conjunction with the first aspect, in one possible implementation, the encoders in the first category further include a third encoder, and the decoders in the first category further include a third decoder; when the first parameter information satisfies the first condition, the electronic device is further configured to: encode the audio data into first encoded audio data by the first encoder in the first category, and transmit the first encoded audio data to the audio playback device; wherein the first encoder has lower power consumption than the third encoder, or the first encoder has a higher priority or power than the third encoder; and the audio playback device is further configured to decode the first encoded audio data into first playback audio data using the first decoder in the first category; wherein the first decoder has lower power consumption than the third decoder, or the first decoder has a higher priority or power than the third decoder. The codec categories supported by both the electronic device and the audio playback device include only the first category. When the first category includes multiple encoders and multiple decoders, the electronic device determines an encoder from the multiple encoders as a default encoder according to preset rules, and determines a decoder from the multiple decoders as a default decoder according to preset rules. The default rules may include priority rules, efficiency rules, power consumption rules, etc. It should be noted that the electronic device can determine an encoder as a default encoder from multiple encoders according to a preset rule, and determine a decoder as a default decoder from multiple decoders according to a preset rule. In another possible implementation, the electronic device only needs to determine an encoder as a default encoder from multiple encoders according to a preset rule, and the audio playback device determines a decoder as a default decoder from multiple decoders according to a preset rule. This application does not limit this.

[0018] In combination with the first aspect, in one possible implementation, the codec in the first category is a high-definition sound quality codec, and the codec in the second category is a standard sound quality codec; or the codec in the first category is a standard sound quality codec, and the codec in the second category is a high-definition sound quality codec.

[0019] In conjunction with the first aspect, in one possible implementation, before the electronic device obtains audio data, the electronic device is further configured to: classify the first encoder into a first category based on parameter information of the first encoder and a codec classification standard, and classify the second encoder into a second category based on parameter information of the second encoder and a codec classification standard; wherein the parameter information of the first encoder and the parameter information of the second encoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; the audio playback device is further configured to: classify the first decoder into the first category based on parameter information of the first decoder and the codec classification standard, and classify the second decoder into the second category based on parameter information of the second decoder and the codec classification standard; wherein the parameter information of the first decoder and the parameter information of the second decoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; wherein the codec classification standard includes a mapping relationship between codec categories and codec parameter information. It should be noted that the parameter information of the first encoder, the parameter information of the second encoder, the parameter information of the first decoder, and the parameter information of the second decoder are all the same.

[0020] In combination with the first aspect, in one possible implementation, the sampling rate of the codec in the first category is greater than or equal to the target sampling rate, and the sampling rate of the codec in the second category is less than the target sampling rate; and / or, the bit rate of the codec in the first category is greater than or equal to the target bit rate, and the bit rate of the codec in the second category is less than the target bit rate; and / or, the number of channels of the codec in the first category is greater than or equal to the target number of channels, and the number of channels of the codec in the second category is less than the target number of channels; and / or, the quantization bit depth of the codec in the first category is greater than or equal to the target quantization bit depth, and the quantization bit depth of the codec in the second category is less than the target quantization bit depth; and / or, the audio stream format of the codec in the first category is the target audio stream format, and the audio stream format of the codec in the second category is the target audio stream format.

[0021] In combination with the first aspect, in a possible implementation, the parameter type in the first parameter information, the parameter type in the parameter information of the first encoder, the parameter type in the parameter information of the first decoder, the parameter type in the second parameter information, the parameter type in the parameter information of the second encoder, and the parameter type in the parameter information of the second decoder are the same; the first parameter information satisfies the first condition, and the second parameter information satisfies the second condition, specifically including: the sampling rate in the first parameter information is greater than or equal to the target sampling rate, and the sampling rate in the second parameter information is less than the target sampling rate; and / or, the bit rate in the first parameter information is greater than or equal to the target bit rate, and the bit rate in the second parameter information is less than the target bit rate; and / or, the quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth, and the quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or, the number of channels in the first parameter information is greater than or equal to the target number of channels, and the number of channels in the second parameter information is less than the target number of channels; and / or, the audio stream format in the first parameter information is the target audio stream format, and the audio stream format in the second parameter information is the target audio stream format.

[0022] In conjunction with the first aspect, in one possible implementation, when the first encoder and the second encoder have the same delay, the electronic device is further configured to: encode a first audio frame in the audio data into a first encoded audio frame using the first encoder and send the first encoded audio frame to the audio playback device; encode the first audio frame in the audio data into a second encoded audio frame using the second encoder and send the second encoded audio frame to the audio playback device; encode the second audio frame in the audio data into an Nth encoded audio frame using the second encoder and send the Nth encoded audio frame to the audio playback device; the audio playback device is further configured to: decode the first encoded audio frame into a first decoded audio frame using the first decoder, decode the second encoded audio frame into a second decoded audio frame using the second decoder, and decode the Nth encoded audio frame into an Nth playback audio frame using the second decoder; and smooth the first decoded audio frame and the second decoded audio frame to obtain a first playback audio frame. The electronic device 100 first plays the first playback audio frame, and then plays the Nth playback audio frame. In this way, when the latency of the first and second encoders is the same, the switch between the first and second encoders must be completed within a single frame. This frame is the first audio frame. The audio playback device smoothes the first audio frame before playing it, preventing stuttering during codec switching and achieving a smooth transition. The adjacent audio frame after the first audio frame, such as the second audio frame, does not require smoothing and is directly decoded and played by the second decoder.

[0023] In combination with the first aspect, in a possible implementation, when the delays of the first encoder and the second encoder are different, the electronic device is further used to: obtain D frames of audio data frames by using the formula D=round((max(total delay of encoder one, total delay of encoder two)+(frame length-total delay of encoder one%frame length)+frame length-1) / frame length); wherein D represents the total number of audio data frames during the switching process between the first encoder and the second encoder, max represents a maximum value operation, % represents a remainder operation, and frame length represents the duration of one frame of audio data; encode the first audio frame to the Dth audio frame in the audio data by the first encoder to obtain the third encoded audio frame to the D+2th encoded audio frame; encode the Dth audio frame in the audio data by the second encoder to obtain the D+3th encoded audio frame, The D+1th audio frame in the audio data is encoded by the second encoder to obtain the Nth encoded audio frame; the third encoded audio frame to the D+2th encoded audio frame, the D+3th encoded audio frame, and the Nth encoded audio frame are sent to the audio playback device; the audio playback device is also used to: decode the third encoded audio frame to the D+2th encoded audio frame into the second playback audio frame to the D+1th playback audio frame by the first decoder, and decode the D+3 encoded audio frame into the third decoded audio frame by the second decoder; play the second playback audio frame to the Dth playback audio frame; smooth the D+1th playback audio frame and the third decoded audio frame to obtain the target playback audio frame, and play the target playback audio frame; decode the Nth encoded audio frame into the Nth decoded audio frame by the second decoder, and play the Nth decoded audio frame. In this way, when the time delay of the first encoder is different from that of the second encoder, the switching between the first encoder and the second encoder needs to be completed within multiple frames (D frames). In this way, during the switching between the first encoder and the second encoder, the time when the audio data encoded by the first encoder reaches the audio playback device and is decoded, and the time when the audio data encoded by the second encoder reaches the audio playback device and is decoded are the same. If the encoder switching needs to be completed within D frames, the audio playback device directly decodes and plays the first audio frame to the D-1 audio frame. The audio playback device smoothes the D audio frame before playing it to prevent jamming when the codec switches and achieve a smooth transition. For the adjacent audio frames after the D audio frame, such as the N audio frame, no smoothing is required and the N decoder is directly decoded and played.

[0024] In combination with the first aspect, in one possible implementation, the audio playback device is further used to: obtain a first playback audio frame through the formula Pcm=wi*pcmA+(1-wi)*pcmB; wherein Pcm is the first playback audio frame, wi is a smoothing coefficient, wi i is greater than 0 and less than 1, pcmA is the first decoded audio frame, and pcmB is the second decoded audio frame.

[0025] In combination with the first aspect, in one possible implementation, the audio playback device is further used to: obtain a first playback audio frame through the formula Pcm=wi*pcmA+(1-wi)*pcmB; wherein Pcm is the first playback audio frame, wi is a smoothing coefficient, wi i is greater than 0 and less than 1, pcmA is the first decoded audio frame, and pcmB is the second decoded audio frame.

[0026] In combination with the first aspect, in one possible implementation, the audio playback device is further used to: obtain the target playback audio frame through the formula Pcm=wi*pcmA+(1-wi)*pcmB; wherein Pcm is the target playback audio frame, wi is the smoothing coefficient, wi i is greater than 0 and less than 1, pcmA is the D+1th playback audio frame, and pcmB is the third decoded audio frame.

[0027] In a second aspect, the present application provides another codec negotiation and switching method, the method comprising: when the first parameter information of the audio data meets the first condition, the electronic device encodes the audio data into first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein, the second category is that the electronic device determines the codec category shared by the electronic device and the audio playback device before obtaining the audio data; when the second parameter information meets the second condition, the electronic device encodes the audio data into second encoded audio data according to the second encoder in the second category, and sends the second encoded audio data to the audio playback device; wherein, the second category is that the electronic device determines the codec category shared by the electronic device and the audio playback device before obtaining the audio data; wherein, the second category is that the electronic device determines the codec category shared by the electronic device and the audio playback device before obtaining the audio data, the first condition is different from the second condition, and the first category is different from the second category.

[0028] According to the method of the first aspect, before transmitting audio data, the electronic device and the audio playback device divide the codec into multiple categories and determine the codec category (e.g., the first category and the second category) shared by the electronic device and the audio playback device. Afterwards, the electronic device obtains the first parameter information of the audio data. When the first parameter information of the audio data meets the first condition, the codec in the first category is selected from the shared codec category to transmit the audio data. When the content of the played audio data, the application of the played audio data, the user selection, or the network condition changes, the electronic device obtains the second parameter of the audio data. When the second parameter of the audio data meets the second condition, the electronic device does not need to negotiate the codec with the audio playback device again, and directly selects the codec in the second category of the shared codec category to transmit the audio data. In this way, when the electronic device needs to switch the encoder, it does not need to renegotiate the codec type with the audio playback device. It directly selects a codec in a category from the previously negotiated codec categories supported by both parties for audio data transmission, solving the problem of audio data interruption and jamming when the electronic device and the audio playback device switch codecs, thereby improving the user experience.

[0029] With reference to the first aspect, in a possible implementation, the encoders in the first category include at least a first encoder, and the encoders in the second category include at least a second encoder.

[0030] In combination with the first aspect, in a possible implementation, the method further includes: the electronic device receives an identifier of a first category and an identifier of a second category sent by an audio playback device; wherein the decoders in the first category include at least a first decoder, and the decoders in the second category include at least a second decoder. In this way, the audio playback device divides the decoders into multiple categories according to the codec classification standard. Exemplarily, the codec categories whose decoder identifiers are greater than or equal to 1 among the multiple categories are the first category and the second category. The decoders classified into the first category include at least the first decoder, and may also include other decoders, such as a third decoder; the decoders classified into the second category include at least the second decoder, and may also include other decoders, such as a fourth decoder.

[0031] In conjunction with the first aspect, in one possible implementation, the method further includes: the electronic device confirming that the electronic device and the audio playback device share a first category and a second category; the electronic device sending an identifier of the first category and an identifier of the second category to the audio playback device; and the electronic device sending a codec category supported by both the electronic device and the audio playback device to the audio playback device, so that the audio playback device knows the codec category supported by both the electronic device and the audio playback device.

[0032] In combination with the first aspect, in a possible implementation, the encoders in the first category only include the first encoder; after the electronic device confirms that the common categories of the electronic device and the audio playback device are the first category and the second category, the method further includes: when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data through the first encoder in the first category, and sends the first encoded audio data to the audio playback device. The codec categories supported by both the electronic device and the audio playback device are the first category and the second category. When the first category includes only one encoder, the electronic device uses an encoder in the category as the default encoder and decoder. Afterwards, when the electronic device and the audio playback device use the codec in the first category for audio data transmission, the audio data is encoded into first encoded audio data according to the default encoder in the first category, and then the electronic device sends the first encoded audio data to the audio playback device.

[0033] In combination with the first aspect, in a possible implementation, the encoder in the first category also includes a third encoder; after the electronic device confirms that the common categories of the electronic device and the audio playback device are the first category and the second category, the method also includes: when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data through the first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein the power consumption of the first encoder is lower than that of the third encoder, or the priority or power of the first encoder is higher than that of the third encoder. The codec categories supported by both the electronic device and the audio playback device are the first category and the second category. When the first category includes multiple encoders, the electronic device will determine an encoder from the multiple encoders as the default encoder according to preset rules. The default rules can be priority rules, efficiency rules, power consumption rules, etc.

[0034] In conjunction with the first aspect, in one possible implementation, when the electronic device and the audio playback device share only the first category of encoder categories, the method further includes: when the second parameter information satisfies a second condition, the electronic device encodes the audio data into third-encoded audio data using the first encoder in the first category, and transmits the third-encoded audio data to the audio playback device. When the electronic device and the audio playback device support only one codec category, in this case, when the parameter information of the audio data changes from the first parameter information to the second parameter information, and the second parameter information satisfies the second condition, the electronic device cannot switch codecs, and the electronic device still uses the default codec in the first category to transmit audio data to the audio playback device.

[0035] In combination with the first aspect, in one possible implementation, when the electronic device does not receive the second category identifier sent by the audio playback device or the number of encoders classified into the second category by the electronic device is 0, the encoder category shared by the electronic device and the audio playback device only includes the first category.

[0036] In combination with the first aspect, in a possible implementation, the encoders in the first category only include the first encoder, and the decoders in the first category only include the first decoder; when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device. The codec category supported by both the electronic device and the audio playback device only includes the first category. When the first category includes only one encoder, the electronic device uses an encoder in the category as the default encoder. Afterwards, when the electronic device and the audio playback device use the codec in the first category for audio data transmission, the audio data is encoded into first encoded audio data according to the default encoder in the first category, and then the electronic device sends the first encoded audio data to the audio playback device.

[0037] In combination with the first aspect, in a possible implementation, the encoder in the first category also includes a third encoder, and the decoder in the first category also includes a third decoder; when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein the power consumption of the first encoder is lower than that of the third encoder, or the priority or power of the first encoder is higher than that of the third encoder. The codec category supported by both the electronic device and the audio playback device only includes the first category. When the first category includes multiple encoders, the electronic device will determine an encoder from the multiple encoders as the default encoder according to preset rules. The default rules can be priority rules, efficiency rules, power consumption rules, etc.

[0038] In combination with the first aspect, in one possible implementation, the codec in the first category is a high-definition sound quality codec, and the codec in the second category is a standard sound quality codec; or the codec in the first category is a standard sound quality codec, and the codec in the second category is a high-definition sound quality codec.

[0039] In conjunction with the first aspect, in one possible implementation, before the electronic device obtains the audio data, the method further includes: the electronic device classifies the first encoder into a first category based on parameter information of the first encoder and a codec classification standard, and classifies the second encoder into a second category based on parameter information of the second encoder and a codec classification standard; wherein the parameter information of the first encoder and the parameter information of the second encoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; and the codec classification standard includes a mapping relationship between codec categories and codec parameter information. It should be noted that the parameter information of the first encoder and the parameter information of the second encoder are the same.

[0040] In combination with the first aspect, in one possible implementation, the sampling rate of the codec in the first category is greater than or equal to the target sampling rate, and the sampling rate of the codec in the second category is less than the target sampling rate; and / or, the bit rate of the codec in the first category is greater than or equal to the target bit rate, and the bit rate of the codec in the second category is less than the target bit rate; and / or, the number of channels of the codec in the first category is greater than or equal to the target number of channels, and the number of channels of the codec in the second category is less than the target number of channels; and / or, the quantization bit depth of the codec in the first category is greater than or equal to the target quantization bit depth, and the quantization bit depth of the codec in the second category is less than the target quantization bit depth; and / or, the audio stream format of the codec in the first category is the target audio stream format, and the audio stream format of the codec in the second category is the target audio stream format.

[0041] In combination with the first aspect, in a possible implementation, the parameter type in the first parameter information, the parameter type in the parameter information of the first encoder, the parameter type in the parameter information of the first decoder, the parameter type in the second parameter information, the parameter type in the parameter information of the second encoder, and the parameter type in the parameter information of the second decoder are the same; the first parameter information satisfies the first condition, and the second parameter information satisfies the second condition, specifically including: the sampling rate in the first parameter information is greater than or equal to the target sampling rate, and the sampling rate in the second parameter information is less than the target sampling rate; and / or, the bit rate in the first parameter information is greater than or equal to the target bit rate, and the bit rate in the second parameter information is less than the target bit rate; and / or, the quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth, and the quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or, the number of channels in the first parameter information is greater than or equal to the target number of channels, and the number of channels in the second parameter information is less than the target number of channels; and / or, the audio stream format in the first parameter information is the target audio stream format, and the audio stream format in the second parameter information is the target audio stream format.

[0042] In a third aspect, the present application provides an electronic device comprising one or more processors, one or more memories, and one or more encoders; the one or more memories, one or more encoders are coupled to one or more processors, the one or more memories are used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute a codec negotiation and switching method as in any possible implementation method of the second aspect.

[0043] In a fourth aspect, the present application provides a computer-readable storage medium, which stores computer-executable instructions. When the computer-executable instructions are called by a computer, they are used to enable the computer to execute a codec negotiation and switching method provided in any possible implementation of the second aspect above.

[0044] In a fifth aspect, the present application provides a computer program product comprising instructions, which, when executed on a computer, enables the computer to execute a codec negotiation and switching method provided in any possible implementation of the second aspect. BRIEF DESCRIPTION OF THE DRAWINGS

[0045] Figure 1 A schematic diagram of a process for transmitting audio data between an electronic device and an audio playback device provided in an embodiment of the present application;

[0046] Figure 2 A schematic diagram of a system provided in an embodiment of the present application;

[0047] Figure 3 A schematic diagram of a network transmission system provided in an embodiment of the present application;

[0048] Figure 4 A schematic diagram of a process of transmitting audio data between another electronic device 100 and an audio playback device 200 provided in an embodiment of the present application;

[0049] Figure 5 A schematic structural diagram of an electronic device 100 provided in an embodiment of the present application;

[0050] Figure 6 A software structure block diagram of an electronic device 100 (such as a mobile phone) provided in an embodiment of the present application;

[0051] Figure 7 A schematic diagram of the hardware structure of an audio playback device 200 provided in an embodiment of the present application;

[0052] Figure 8 A schematic diagram of a codec category negotiated between an electronic device 100 and an audio playback device 200 according to an embodiment of the present application;

[0053] Figure 9 A flowchart of a codec negotiation and switching method provided in an embodiment of the present application;

[0054] Figures 9A-9C A UI diagram showing a group of electronic devices 100 and an audio playback device 200 establishing a communication connection via Bluetooth provided in an embodiment of the present application;

[0055] Figures 10A-10D Another set of UI diagrams provided for an embodiment of the present application. DETAILED DESCRIPTION

[0056] The following is a clear and detailed description of the technical solutions in the embodiments of the present application in conjunction with the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " means or, for example, A / B can mean A or B; "and / or" in the text is only a description of the association relationship between related objects, indicating that there can be three relationships, for example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.

[0057] In the following, the terms "first" and "second" are used for descriptive purposes only and should not be understood to imply or suggest relative importance or implicitly indicate the number of the technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of this application, unless otherwise specified, "plurality" means two or more.

[0058] The term "user interface (UI)" in the specification, claims and drawings of this application refers to the media interface for interaction and information exchange between an application or operating system and a user, which realizes the conversion between the internal form of information and the form acceptable to the user. The user interface of an application is a source code written in a specific computer language such as Java and Extensible Markup Language (XML). The interface source code is parsed and rendered on the terminal device, and finally presented as content that the user can recognize, such as images, text, buttons and other controls. Controls, also known as widgets, are the basic elements of the user interface. Typical controls include toolbars, menu bars, input boxes, buttons, scroll bars, images and text. The properties and contents of controls in the interface are defined by tags or nodes, such as XML through <textview> 、 <imgview> 、 <videoview>The controls contained in the interface are specified by nodes such as <head> and <body>. A node corresponds to a control or attribute in the interface, and the node is presented as user-visible content after parsing and rendering. In addition, many applications, such as hybrid applications, usually also contain web pages in their interfaces. A web page, also called a page, can be understood as a special control embedded in the application interface. A web page is a source code written in a specific computer language, such as hypertext markup language (HTML), cascading style sheets (CSS), JavaScript (JS), etc. The web page source code can be loaded and displayed as user-recognizable content by a browser or a web page display component with similar functions to a browser. The specific content contained in a web page is also defined by tags or nodes in the web page source code, such as HTML through <body>. 、 、 <video> 、 <canvas>To define the elements and attributes of a web page.

[0059] A common form of user interface is a graphical user interface (GUI), which refers to a user interface related to computer operations that uses graphics to display. It can be a window, control, or other interface element displayed on the display of an electronic device.

[0060] Currently, after an electronic device (such as a mobile phone) establishes a communication connection with an audio playback device (such as headphones), the electronic device sends audio data to the audio playback device, and the audio playback device plays the audio data sent by the electronic device. Before the electronic device sends the audio data to the audio playback device, the electronic device negotiates the codec type with the audio playback device. The electronic device selects a codec supported by both parties to encode the audio data and sends the encoded audio data to the audio playback device.

[0061] like Figure 1 As shown, Figure 1 The following is a schematic diagram showing an exemplary process of transmitting audio data between an electronic device and an audio playback device.

[0062] The electronic device may be an audio signal source (Source, SRS), and the audio playback device may be an audio signal sink (Sink, SNK).

[0063] The electronic device includes an audio data acquisition unit, an audio stream decoding unit, a mixing rendering unit, a wireless audio encoding unit, a capability negotiation unit and a wireless transmission unit.

[0064] The audio playback device includes a wireless transmission unit, a wireless audio decoding unit, an audio power amplifier unit, an audio playback unit and a capability negotiation unit.

[0065] Before the electronic device sends the acquired audio data to the audio playback device, the electronic device and the audio playback device will negotiate to obtain a type of codec supported by both parties for data transmission. Specifically, after the electronic device and the audio playback device establish a communication connection, the audio playback device sends all decoder identifiers and all decoder capabilities to the wireless transmission unit on the audio playback device side through the capability negotiation unit, wherein the decoder identifier is the decoder number, and the audio playback device can find the decoder corresponding to the decoder identifier based on the decoder identifier, and obtain the capabilities of the decoder corresponding to the decoder identifier; the wireless transmission unit on the audio playback device side sends all decoder identifiers and all decoder capabilities to the wireless transmission unit on the electronic device side, and the wireless transmission unit on the electronic device side sends all decoder identifiers and all decoder capabilities to the capability negotiation unit on the electronic device side. The capability negotiation unit on the electronic device side obtains the identifiers and capabilities of all encoders in the electronic device, wherein the encoder identifier is the encoder number, and the electronic device can find the encoder corresponding to the encoder identifier based on the encoder identifier, and obtain the capabilities of the encoder corresponding to the encoder identifier. Based on the capabilities of all codecs, the electronic device's capability negotiation unit obtains one or more codecs with common capabilities shared by the electronic device and the audio playback device. Codec capabilities include supported sampling rates, quantization bit depths, bit rates, and number of channels. Based on factors such as the type of audio being played, the electronic device determines a codec identifier from the one or more codecs with common capabilities shared by the electronic device and the audio playback device as the default codec. The electronic device and the audio playback device then transmit audio data based on the default codec identifier. The electronic device's capability negotiation unit transmits the default encoder identifier to the wireless encoding unit. Simultaneously, the electronic device's capability negotiation unit transmits the default decoder identifier to the electronic device's wireless transmission unit, which in turn transmits the default decoder identifier to the audio playback device's wireless transmission unit. The audio playback device then transmits the default decoder identifier to the capability negotiation unit of the audio playback device. The audio playback device then transmits the default decoder identifier to the wireless audio decoding unit via the capability negotiation unit.

[0066] In some embodiments, the electronic device and the audio playback device may not include a capability negotiation unit. When the electronic device and the audio playback device do not have a capability negotiation unit, the wireless transmission unit in the electronic device and the audio playback device may implement the codec capability negotiation function.

[0067] For electronic devices, the audio data acquisition unit is used to obtain an audio stream, which can be a network audio stream obtained by the electronic device in real time or an audio stream cached in the electronic device. After the audio data acquires the audio stream, it sends the audio stream to the audio content decoding unit.

[0068] The audio content decoding unit receives the audio code stream sent by the audio data acquisition unit, decodes the audio code stream, and obtains an uncompressed audio code stream. Thereafter, the audio content decoding unit sends the uncompressed audio code stream to the mixing rendering unit.

[0069] The mixing and rendering unit receives the uncompressed audio stream sent by the audio content decoding unit, mixes and renders the uncompressed audio stream, and calls the mixed and rendered audio stream audio data. Mixing is to mix the uncompressed audio stream with audio data with environmental colors, so that the mixed and rendered audio stream has environmental colors. It can be understood that the electronic device can provide multiple channels of audio data for mixing and rendering. For example, in the dubbing commentary of a documentary, the dubbing artist records the audio stream of the commentary. In order to make the audio stream match the picture of the documentary, it is necessary to render the environmental colors of the audio stream to increase the mysterious atmosphere. Rendering is to render and adjust the sampling rate, sampling bit depth, number of channels, etc. of the audio data.

[0070] It should be noted that, in some embodiments, the electronic device may not include a mixing rendering unit, that is, the electronic device does not need to perform mixing rendering processing on the audio code stream. This application is not limited here. Afterwards, the mixing rendering unit sends the audio data to the wireless audio encoding unit.

[0071] The wireless audio encoding unit receives the audio data sent by the mixing rendering unit and encodes the audio data according to a default encoder identifier. Thereafter, the wireless audio encoding unit sends the encoded audio data to the wireless transmission unit.

[0072] The wireless transmission unit receives the encoded audio data sent by the wireless audio encoding unit, and sends the encoded audio data to the wireless transmission unit of the audio playback device through the transmission channel between the electronic device and the audio playback device.

[0073] The wireless transmission unit of the audio playback device receives the encoded audio data sent by the wireless transmission unit of the electronic device, and the wireless transmission unit of the audio playback device sends the encoded audio data to the wireless audio decoding unit of the audio playback device.

[0074] The wireless audio decoding unit of the audio playback device receives the encoded audio data sent by the wireless transmission unit, and decodes the encoded audio data according to the default decoder identifier to obtain uncompressed audio data. The wireless audio decoding unit of the audio playback device sends the uncompressed audio data to the audio power amplifier unit of the audio playback device.

[0075] The audio power amplifier unit of the audio playback device receives uncompressed audio data, performs digital-to-analog conversion, power amplification and other operations on the uncompressed audio data, and then plays the audio data out through the audio playback unit.

[0076] When the electronic device and the audio playback device initially establish a communication connection, the audio data will be transmitted according to the default codec identifier obtained through negotiation. However, when the network deteriorates, or the electronic device uses a higher-definition sound quality for transmission, the electronic device needs to switch to an encoder that is suitable for network transmission or an encoder with higher-definition sound quality. However, when the electronic device switches the encoder, the electronic device needs to renegotiate the codec capabilities with the audio playback device. When the electronic device renegotiates the codec capabilities with the audio playback device, the electronic device will suspend sending audio data to the audio playback device, resulting in audio data interruption and playback jamming during the codec switching process between the electronic device and the audio playback device, affecting the user experience.

[0077] Therefore, the present application provides a codec negotiation and switching method. The method includes: before an electronic device establishes a communication connection with an audio playback device, the electronic device and the audio playback device classify one or more codecs into multiple categories based on parameters such as sampling rate, quantization bit depth, bit rate, and number of channels. After the electronic device establishes a communication connection with the audio playback device, and before the electronic device sends audio data to the audio playback device, the audio playback device sends a category identifier with a number of decoder identifiers greater than or equal to 1 to the electronic device. The electronic device obtains a shared category based on the categories with a number of decoder identifiers greater than or equal to 1 and the categories with a number of encoder identifiers greater than or equal to 1. The electronic device then selects a default codec from one of the categories for audio data transmission based on conditions such as user selection, characteristics of the audio data being played, whether the electronic device's audio rendering capability is enabled, and application type. If conditions such as user selection, characteristics of the audio data being played, whether the electronic device's audio rendering capability is enabled, and application type change, the electronic device reselects a default encoder from another category for encoding and transmission, and sends the identifier of the reselected category to the audio playback device. The audio playback device then uses the default decoder from that category to decode and play the audio data. In this way, when the electronic device needs to switch the encoder, it does not need to renegotiate the codec type with the audio playback device, which solves the problem of audio data interruption and jamming when the electronic device and the audio playback device switch codecs, and improves the user experience.

[0078] This technical solution is applicable to wireless audio playback scenarios with point-to-point connection between mobile phones and wireless headphones; it is also applicable to scenarios with point-to-point connection between tablets / PCs / smart watches and other wearable devices and wireless headphones; it is also applicable to smart home scenarios with mobile phones / PCs / tablets / smart TVs / set-top boxes / smart speakers / smart routers as the center for networking, and the audio playback devices can be one or more types of speakers / soundbars / smart TVs for networked playback.

[0079] Next, a wireless audio playback system architecture provided by an embodiment of the present application is introduced.

[0080] like Figure 2 As shown, Figure 2 A schematic diagram of a system provided in an embodiment of the present application.

[0081] First, the electronic device 100 establishes a communication connection with the audio playback device 200. The electronic device 100 can send audio data to the audio playback device, and the audio playback device plays the audio data.

[0082] The electronic device 100 may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, vehicle-mounted device, smart home device and / or smart city device. The embodiment of the present application does not impose any special restrictions on the specific type of the electronic device 100. The software system of the electronic device 100 includes but is not limited to Linux or other operating systems. It is Huawei's Hongmeng system.

[0083] The audio playback device 200 refers to a device with audio playback capabilities. The audio playback device can be but is not limited to headphones, speakers, TVs, AR / VR glasses, tablets / PCs / smart watches and other wearable devices.

[0084] The following embodiments of the present application are described by taking the electronic device 100 as a mobile phone and the audio playback device 200 as a Bluetooth headset as an example.

[0085] The electronic device 100 and the audio playback device 200 can be connected and communicated via wireless communication technology. The wireless communication technology here includes but is not limited to: wireless local area network (WLAN) technology, Bluetooth, infrared, near field communication (NFC), ZigBee, wireless fidelity direct (Wi-Fi direct) (also known as wireless fidelity peer-to-peer (Wi-Fi P2P)) and other wireless communication technologies that appear in subsequent developments. For ease of description, the following embodiments will be described using the communication between the electronic device 100 and the audio playback device 200 via Bluetooth wireless communication technology as an example.

[0086] When the audio playback device 200 is connected to the electronic device 100 via Bluetooth technology, the electronic device 100 then sends synchronization information (such as handshake information) to the audio playback device 200 to synchronize with the network. After the network is successfully established and synchronization is completed, the audio playback device 200 plays audio under the control of the electronic device 100. That is, the electronic device 100 sends audio data to the audio playback device 200 through the established Bluetooth channel, and the audio playback device 200 plays the audio data sent by the electronic device 100.

[0087] Figure 2 The system diagram shown is merely an example of a system. In some embodiments, the electronic device 100 can also establish communication connections with multiple audio playback devices 200 simultaneously. The following embodiments of this application are described based on the electronic device 100 establishing a connection with one audio playback device 200. It should be noted that this application does not limit the number of audio playback devices 200.

[0088] Next, another wireless audio playback system architecture with network connection provided by an embodiment of the present application is introduced.

[0089] like Figure 3 As shown, the electronic device 100 establishes communication connections with multiple audio playback devices 200 at the same time.

[0090] The electronic device 100 may be a mobile phone, tablet computer, desktop computer, laptop computer, handheld computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, cellular phone, personal digital assistant (PDA), augmented reality (AR) device, virtual reality (VR) device, artificial intelligence (AI) device, wearable device, vehicle-mounted device, smart home device and / or smart city device. The embodiment of the present application does not impose any special restrictions on the specific type of the electronic device 100. The software system of the electronic device 100 includes but is not limited to Linux or other operating systems. It is Huawei's Hongmeng system.

[0091] The audio playback device 200 refers to a device with audio playback capabilities. The audio playback device can be but is not limited to headphones, speakers, TVs, AR / VR glasses, tablets / PCs / smart watches and other wearable devices.

[0092] In the embodiment of the present application, the electronic device 100 is a mobile phone, and the multiple audio playback devices 200 are headphones and speakers. That is, the mobile phone establishes connections with the headphones and speakers at the same time, and the mobile phone can send multimedia content (such as audio data) to the headphones and speakers at the same time.

[0093] When multiple audio playback devices 200 (such as headphones and speakers) have no synchronization delay requirements for the same audio data transmitted by the electronic device 100, in this case, the connection between the electronic device 100 and the multiple audio playback devices can be regarded as consisting of multiple independent systems. That is, the electronic device 100 and the headphones negotiate a common codec classification category, as well as a default encoder identifier and a default decoder identifier under each category. The electronic device 100 and the speakers negotiate a common codec classification category, as well as a default encoder identifier and a default decoder identifier under each category. The electronic device 100 and the headphones can independently select one category in the common codec classification category for audio data transmission. The electronic device 100 and the speakers can independently select one category in the common codec classification category for audio data transmission. The codec classification category selected by the electronic device 100 and the headphones and the codec classification category selected by the electronic device 100 and the speakers can be the same or different. Moreover, the switching of codec classification categories between the electronic device 100 and the headphones or the electronic device 100 and the speakers does not affect each other. The method for selecting and switching codec classification categories between the electronic device 100 and the earphone or the electronic device 100 and the speaker is consistent with the method for selecting and switching codec classification categories between the electronic device 100 and the audio playback device 200 described in the following embodiments, and will not be repeated in this application.

[0094] When multiple audio playback devices 200 (such as headphones and speakers) have synchronization delay requirements for the same audio data transmitted by the electronic device 100, in this case, the connection between the electronic device 100 and the multiple audio playback devices is regarded as a complete system. Specifically, when the electronic device 100 negotiates with multiple audio playback devices to obtain codec classification categories supported by all parties, the headphones send all codec classification categories and decoder identifiers under each category to the electronic device 100, and the speakers send all codec classification categories and decoder identifiers under each category to the electronic device 100. The electronic device 100 obtains all codec classification categories and encoder identifiers under each category in the electronic device 100. Afterwards, the electronic device 100 identifies a common codec classification category from the codec classification category in the electronic device 100 and the codec classification categories sent by the headphones and speakers, that is, a codec classification category supported by the electronic device 100, the headphones, and the speakers. The method by which the electronic device 100 identifies the codec classification category supported by the electronic device 100, the headphones, and the speakers is consistent with the method by which the electronic device 100 and the audio playback device 200 identify the codec classification category supported by both parties described in the following embodiments, and will not be repeated here. Then, the electronic device 100 determines a default encoder and a default decoder in the codec classification category supported by the electronic device 100, the headphones, and the speakers. The electronic device 100 sends the codec classification categories supported by the electronic device 100, the headphones, and the speakers, as well as a default encoder identifier and a default decoder identifier for each category, to the headphones and the speakers. It should be noted that the selection and switching of codec classification categories by the electronic device 100 is consistent with the method by which the electronic device 100 and the audio playback device 200 select and switch codec classification categories described in the following embodiments, and will not be repeated here.

[0095] The following describes a codec negotiation and switching method provided by this embodiment, taking the establishment of a connection between an electronic device 100 and an audio playback device 200 as an example. The connection between the electronic device 100 and two audio playback devices 200 is similar to the connection between the electronic device 100 and a single audio playback device 200, and is not further described in this application.

[0096] like Figure 4 As shown, Figure 4 The following is a schematic diagram showing another process of transmitting audio data between an electronic device 100 and an audio playback device 200.

[0097] The electronic device 100 includes an audio data acquisition unit, an audio stream decoding unit, a mixing rendering unit, a wireless audio encoding unit, a capability negotiation unit, an encoding control unit, and a wireless transmission unit.

[0098] The audio playback device 200 includes a wireless transmission unit, a wireless audio decoding unit, an audio power amplifier unit, an audio playback unit, a capability negotiation unit, and a decoding control unit.

[0099] Among them, the audio data acquisition unit, audio stream decoding unit, mixing rendering unit, wireless audio encoding unit and wireless transmission unit in the electronic device 100 are connected to the wireless audio data acquisition unit, audio stream decoding unit, mixing rendering unit and wireless audio encoding unit. Figure 1 The functions of the audio data acquisition unit, audio stream decoding unit, mixing rendering unit, wireless audio encoding unit and wireless transmission unit shown in are the same and will not be repeated in this application.

[0100] Similarly, the wireless transmission unit, wireless audio decoding unit, audio amplifier unit, audio playback unit and Figure 1 The functions of the wireless transmission unit, wireless audio decoding unit, audio amplifier unit, and audio playback unit shown in the figure are the same and will not be repeated in this application.

[0101] For electronic device 100, the capability negotiation unit is specifically used to obtain the codec classification standard, the identifiers of all encoders in electronic device 100, and all encoder capabilities. The encoder capabilities include parameter information such as the codec sampling rate, quantization bit depth, bit rate, number of channels, etc. Based on the codec classification standard and the capabilities of all encoders in electronic device 100, all encoders in electronic device 100 are divided into multiple categories. An encoder can belong to one or more categories. It should be noted that the codec classification standard is pre-set in electronic device 100.

[0102] Similarly, for audio playback device 200, the capability negotiation unit is specifically configured to obtain the codec classification standard, the identifiers of all decoders in audio playback device 200, and the capabilities of all decoders. Based on the codec classification standard and the capabilities of all decoders in electronic device 100, all decoders in audio playback device 200 are classified into multiple categories. A decoder can belong to one or more categories. It should be noted that the codec classification standard is pre-set in audio playback device 200.

[0103] Afterwards, the audio playback device 200 transmits, via the capability negotiation unit, a category identifier for which the number of decoder identifiers in the audio playback device 200 is greater than or equal to 1, to the wireless transmission unit in the audio playback device 200. The wireless transmission unit in the audio playback device 200 transmits the identifier for the category for which the number of decoder identifiers is greater than or equal to 1, to the wireless transmission unit in the electronic device 100. The category for which the number of decoder identifiers is greater than or equal to 1 can be understood as meaning that the number of decoder identifiers included in the category is greater than or equal to 1.

[0104] The wireless transmission unit in the electronic device 100 receives and sends the category identifiers whose number of decoder identifiers is greater than or equal to 1 to the capability negotiation unit in the electronic device 100 .

[0105] The capability negotiation unit in the electronic device 100 receives identifiers of categories in which the number of decoder identifiers is greater than or equal to one.

[0106] The capability negotiation unit in the electronic device 100 also obtains the category identifiers of the electronic device 100 whose number of encoder identifiers is greater than or equal to 1.

[0107] The capability negotiation unit in the electronic device 100 sends the category identifiers with a number of decoder identifiers greater than or equal to 1 and the category identifiers with a number of encoder identifiers greater than or equal to 1 to the encoding control unit in the electronic device 100. The encoding control unit in the electronic device 100 identifies the common category identifiers from the category identifiers with a number of decoder identifiers greater than or equal to 1 and the category identifiers with a number of encoder identifiers greater than or equal to 1. And determines a default encoder in each common category. Here, how the encoding control unit negotiates the default encoder in each common category between the electronic device 100 and the audio playback device 200 will be described in detail in subsequent embodiments and is not limited in this application. After the encoding control unit confirms the common category and the default encoder in each common category, the encoding control unit will select an appropriate category (e.g., the first category) from the common category based on the application type, the playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is enabled, the network conditions of the channel, etc., and transmit audio data with the default encoder in the category. How the encoding control unit selects the first category from the common categories based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the audio rendering capability of the electronic device is turned on, the network conditions of the channel, etc. will be described in detail in subsequent embodiments, and this application does not limit it here.

[0108] Afterwards, the encoding negotiation unit sends the identifier of the first category to the wireless audio encoding unit, and the wireless audio encoding unit encodes the audio data according to the encoder corresponding to the default encoder identifier in the first category.

[0109] At the same time, the encoding negotiation unit sends the first category identifier to the wireless transmission unit, the electronic device 100 sends the first category identifier to the wireless transmission unit of the audio playback device 200 through the wireless transmission unit, the wireless transmission unit of the audio playback device 200 sends the first category identifier to the capability negotiation unit in the audio playback device 200, the wireless transmission unit capability negotiation unit of the audio playback device 200 sends the first category identifier to the decoding control unit in the audio playback device 200, the decoding control unit in the audio playback device 200 sends the first category identifier to the wireless audio decoding unit, and the wireless audio decoding unit decodes the encoded audio data sent by the electronic device 100 according to the decoder corresponding to the default decoder identifier in the first category identifier.

[0110] After the coding negotiation unit selects an appropriate category (e.g., the first category) from the common categories and uses the default codec in the first category for audio data transmission, due to factors such as changes in application type, changes in playback audio characteristics (sampling rate, quantization bit depth, number of channels), activation of the electronic device's audio rendering capabilities, changes in channel network conditions, etc., the electronic device 100 will reselect another category through the coding control unit and notify the decoding control unit in the audio playback device 200 of the identifier of the category. The electronic device 100 and the audio playback device 200 will then use the default codec in the other category to transmit audio data.

[0111] like Figure 5 As shown, Figure 5 A schematic structural diagram of the electronic device 100 is exemplarily shown.

[0112] The following embodiment is specifically described by taking the electronic device 100 as a mobile phone as an example. It should be understood that Figure 5 The electronic device 100 shown is only one example, and the electronic device 100 may have more Figure 5 The more or less components shown in the figure can be combined with two or more components, or can have different component configurations. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0113] The electronic device 100 may include: a processor 110, an external memory interface 120, an internal memory 121, a universal serial bus (USB) interface 130, a charging management module 140, a power management module 141, a battery 142, an antenna 1, an antenna 2, a mobile communication module 150, a wireless communication module 160, an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, an earphone interface 170D, a sensor module 180, a button 190, a motor 191, an indicator 192, a camera 193, a display screen 194, and a subscriber identification module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyroscope sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, a proximity light sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, a bone conduction sensor 180M, etc.

[0114] It should be understood that the structure illustrated in the embodiments of the present invention does not constitute a specific limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may include more or fewer components than shown, or may combine or separate certain components, or arrange the components differently. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0115] The processor 110 may include one or more processing units. For example, the processor 110 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). The different processing units may be independent devices or integrated into one or more processors.

[0116] The controller may be the nerve center and command center of the electronic device 100. The controller may generate an operation control signal according to the instruction operation code and the timing signal to complete the control of fetching and executing instructions.

[0117] Processor 110 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 110 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 110. If processor 110 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 110 latency, and thus improves system efficiency.

[0118] In some embodiments, the processor 110 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0119] The I2C interface is a bidirectional synchronous serial bus that includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple I2C bus lines. The processor 110 may be coupled to the touch sensor 180K, the charger, the flash, the camera 193, and the like via different I2C bus interfaces. For example, the processor 110 may be coupled to the touch sensor 180K via the I2C interface, enabling communication between the processor 110 and the touch sensor 180K via the I2C bus interface, thereby implementing the touch function of the electronic device 100.

[0120] The I2S interface can be used for audio communication. In some embodiments, the processor 110 can include multiple I2S buses. The processor 110 can be coupled to the audio module 170 via the I2S bus to enable communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the I2S interface, enabling the function of answering calls through a Bluetooth headset.

[0121] The PCM interface can also be used for audio communication, sampling, quantizing, and encoding analog signals. In some embodiments, the audio module 170 and the wireless communication module 160 can be coupled via a PCM bus interface. In some embodiments, the audio module 170 can also transmit audio signals to the wireless communication module 160 via the PCM interface, enabling the function of answering calls via a Bluetooth headset. Both the I2S interface and the PCM interface can be used for audio communication.

[0122] The UART interface is a universal serial data bus used for asynchronous communication. This bus can be a bidirectional communication bus. It converts the data to be transmitted between serial communication and parallel communication. In some embodiments, the UART interface is typically used to connect the processor 110 and the wireless communication module 160. For example, the processor 110 communicates with the Bluetooth module in the wireless communication module 160 via the UART interface to implement Bluetooth functionality. In some embodiments, the audio module 170 can transmit audio signals to the wireless communication module 160 via the UART interface, enabling the function of playing music through Bluetooth headphones.

[0123] The MIPI interface can be used to connect the processor 110 to peripheral devices such as the display 194 and the camera 193. MIPI interfaces include the camera serial interface (CSI) and the display serial interface (DSI). In some embodiments, the processor 110 and the camera 193 communicate via the CSI interface to implement the camera function of the electronic device 100. The processor 110 and the display 194 communicate via the DSI interface to implement the display function of the electronic device 100.

[0124] The GPIO interface can be configured via software. The GPIO interface can be configured as either a control signal or a data signal. In some embodiments, the GPIO interface can be used to connect the processor 110 to the camera 193, display 194, wireless communication module 160, audio module 170, sensor module 180, etc. The GPIO interface can also be configured as an I2C interface, an I2S interface, a UART interface, a MIPI interface, etc.

[0125] The USB interface 130 is an interface that complies with USB standards and may be a Mini USB interface, a Micro USB interface, a USB Type-C interface, or the like. The USB interface 130 can be used to connect a charger to charge the electronic device 100, or to transfer data between the electronic device 100 and peripheral devices. It can also be used to connect headphones to play audio. This interface can also be used to connect other electronic devices, such as augmented reality devices.

[0126] It is understood that the interface connection relationship between the modules illustrated in the embodiment of the present invention is merely an illustrative illustration and does not constitute a structural limitation on the electronic device 100. In other embodiments of the present application, the electronic device 100 may also adopt different interface connection methods from the above embodiments, or a combination of multiple interface connection methods.

[0127] The charging management module 140 is configured to receive charging input from a charger. The charger can be either a wireless charger or a wired charger. In some wired charging embodiments, the charging management module 140 can receive charging input from the wired charger via the USB interface 130. In some wireless charging embodiments, the charging management module 140 can receive wireless charging input via the wireless charging coil of the electronic device 100. While charging the battery 142, the charging management module 140 can also provide power to the electronic device via the power management module 141.

[0128] The power management module 141 is used to connect the battery 142, the charging management module 140 and the processor 110. The power management module 141 receives input from the battery 142 and / or the charging management module 140, and provides power to the processor 110, the internal memory 121, the external memory, the display 194, the camera 193, and the wireless communication module 160. The power management module 141 can also be used to monitor parameters such as battery capacity, battery cycle count, and battery health status (leakage, impedance). In some other embodiments, the power management module 141 can also be set in the processor 110. In other embodiments, the power management module 141 and the charging management module 140 can also be set in the same device.

[0129] The wireless communication function of the electronic device 100 can be implemented through the antenna 1, the antenna 2, the mobile communication module 150, the wireless communication module 160, the modem processor and the baseband processor.

[0130] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in electronic device 100 can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0131] The mobile communication module 150 can provide solutions for wireless communications including 2G / 3G / 4G / 5G applied to the electronic device 100. The mobile communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), etc. The mobile communication module 150 can receive electromagnetic waves from the antenna 1, and filter, amplify, and process the received electromagnetic waves, and transmit them to the modulation and demodulation processor for demodulation. The mobile communication module 150 can also amplify the signal modulated by the modulation and demodulation processor, and convert it into electromagnetic waves for radiation through the antenna 1. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the processor 110. In some embodiments, at least some of the functional modules of the mobile communication module 150 can be set in the same device as at least some of the modules of the processor 110.

[0132] The modem processor may include a modulator and a demodulator. The modulator is used to modulate the low-frequency baseband signal to be transmitted into a medium-high frequency signal. The demodulator is used to demodulate the received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to the baseband processor for processing. After being processed by the baseband processor, the low-frequency baseband signal is passed to the application processor. The application processor outputs a sound signal through an audio device (not limited to the speaker 170A, the receiver 170B, etc.) or displays an image or video through the display screen 194. In some embodiments, the modem processor may be an independent device. In other embodiments, the modem processor may be independent of the processor 110 and be set in the same device as the mobile communication module 150 or other functional modules.

[0133] The wireless communication module 160 can provide wireless communication solutions including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), infrared (IR), etc., which are applied to the electronic device 100. The wireless communication module 160 can be one or more devices integrating at least one communication processing module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, frequency modulates and filters the electromagnetic wave signals, and sends the processed signals to the processor 110. The wireless communication module 160 can also receive the signal to be sent from the processor 110, frequency modulate it, amplify it, and convert it into electromagnetic waves for radiation through the antenna 2.

[0134] In some embodiments, the antenna 1 of the electronic device 100 is coupled to the mobile communication module 150, and the antenna 2 is coupled to the wireless communication module 160, so that the electronic device 100 can communicate with the network and other devices through wireless communication technology. The wireless communication technology may include global system for mobile communications (GSM), general packet radio service (GPRS), code division multiple access (CDMA), wideband code division multiple access (WCDMA), time-division code division multiple access (TD-SCDMA), long term evolution (LTE), BT, GNSS, WLAN, NFC, FM, and / or IR technology. The GNSS may include a global positioning system (GPS), a global navigation satellite system (GLONASS), a Beidou navigation satellite system (BDS), a quasi-zenith satellite system (QZSS) and / or a satellite based augmentation system (SBAS).

[0135] Electronic device 100 implements display functionality through a GPU, display screen 194, and an application processor. A GPU is a microprocessor for image processing that connects display screen 194 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. Processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.

[0136] Display screen 194 is used to display images, videos, and the like. Display screen 194 includes a display panel. The display panel can be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a MiniLED, a MicroLED, a Micro-oLed, or a quantum dot light-emitting diode (QLED). In some embodiments, electronic device 100 may include one or N display screens 194, where N is a positive integer greater than one.

[0137] The electronic device 100 can implement a shooting function through an ISP, a camera 193, a video codec, a GPU, a display screen 194, and an application processor.

[0138] The ISP processes data fed back by camera 193. For example, when taking a photo, the shutter is opened, and light is transmitted through the lens to the camera's photosensitive element. The light signal is converted into an electrical signal, which is then passed to the ISP for processing and converted into a visible image. The ISP can also perform algorithmic optimization on image noise, brightness, and skin tone. It can also optimize parameters such as exposure and color temperature of the captured scene. In some embodiments, the ISP can be located within camera 193.

[0139] The camera 193 is used to capture still images or videos. The object generates an optical image through the lens and projects it onto the photosensitive element. The photosensitive element can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the light signal into an electrical signal, and then passes the electrical signal to the ISP for conversion into a digital image signal. The ISP outputs the digital image signal to the DSP for processing. The DSP converts the digital image signal into an image signal in a standard RGB, YUV or other format. In some embodiments, the electronic device 100 may include 1 or N cameras 193, where N is a positive integer greater than 1.

[0140] The digital signal processor is used to process digital signals. In addition to processing digital image signals, it can also process other digital signals. For example, when the electronic device 100 selects a frequency point, the digital signal processor is used to perform Fourier transform on the frequency point energy.

[0141] Video codecs are used to compress or decompress digital video. Electronic device 100 may support one or more video codecs. This allows electronic device 100 to play or record videos in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, and MPEG4.

[0142] The NPU is a neural network (NN) computing processor. Drawing on the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, it rapidly processes input information and can continuously self-learn. The NPU can enable intelligent cognitive applications in electronic device 100, such as image recognition, face recognition, speech recognition, and text comprehension.

[0143] The external memory interface 120 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 100. The external memory card communicates with the processor 110 via the external memory interface 120 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0144] The internal memory 121 can be used to store computer executable program codes, which include instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by running the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system, an application required for at least one function (such as a sound playback function, an image playback function, etc.), etc. The data storage area can store data created during the use of the electronic device 100 (such as audio data, a phone book, etc.), etc. In addition, the internal memory 121 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, a universal flash storage (UFS), etc.

[0145] The electronic device 100 can implement audio functions such as music playback and recording through the audio module 170, the speaker 170A, the receiver 170B, the microphone 170C, the headphone jack 170D, and the application processor.

[0146] The audio module 170 is used to convert digital audio information into analog audio signal output, and is also used to convert analog audio input into digital audio signals. The audio module 170 can also be used to encode and decode audio signals. In some embodiments, the audio module 170 can be provided in the processor 110, or some functional modules of the audio module 170 can be provided in the processor 110.

[0147] The speaker 170A, also called a "speaker," is used to convert audio electrical signals into sound signals. The electronic device 100 can listen to music or make hands-free calls through the speaker 170A.

[0148] The receiver 170B, also called a "handset", is used to convert audio electrical signals into sound signals. When the electronic device 100 receives a call or voice message, the voice can be heard by placing the receiver 170B close to the human ear.

[0149] Microphone 170C, also known as "microphone" or "microphone", is used to convert sound signals into electrical signals. When making a call or sending a voice message, the user can speak by putting their mouth close to the microphone 170C to input the sound signal into the microphone 170C. The electronic device 100 can be provided with at least one microphone 170C. In other embodiments, the electronic device 100 can be provided with two microphones 170C, which can not only collect sound signals but also realize noise reduction function. In other embodiments, the electronic device 100 can also be provided with three, four or more microphones 170C to realize sound signal collection, noise reduction, and identification of sound sources, and realize directional recording function, etc.

[0150] The headphone jack 170D is used to connect a wired headphone and can be the USB interface 130 or a 3.5mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.

[0151] Pressure sensor 180A is used to sense pressure signals and convert them into electrical signals. In some embodiments, pressure sensor 180A can be located on display screen 194. There are many types of pressure sensors 180A, such as resistive, inductive, and capacitive. A capacitive pressure sensor can include at least two parallel plates made of conductive material. When force acts on pressure sensor 180A, the capacitance between the electrodes changes. Electronic device 100 determines the intensity of the pressure based on this change in capacitance. When a touch operation is applied to display screen 194, electronic device 100 detects the touch intensity based on pressure sensor 180A. Electronic device 100 can also calculate the touch location based on the detection signal from pressure sensor 180A. In some embodiments, touch operations applied to the same touch location but with different touch intensities can correspond to different operation instructions. For example, when a touch operation with an intensity less than a first pressure threshold is applied to a short message application icon, a command to view short messages is executed. When a touch operation with an intensity greater than or equal to the first pressure threshold is applied to a short message application icon, a command to create a new short message is executed.

[0152] The gyroscope sensor 180B can be used to determine the motion posture of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x, y, and z axes) can be determined by the gyroscope sensor 180B. The gyroscope sensor 180B can be used for anti-shake shooting. For example, when the shutter is pressed, the gyroscope sensor 180B detects the angle of the electronic device 100 shaking, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to offset the shaking of the electronic device 100 through reverse movement to achieve anti-shake. The gyroscope sensor 180B can also be used for navigation and somatosensory game scenes.

[0153] The air pressure sensor 180C is used to measure air pressure. In some embodiments, the electronic device 100 calculates the altitude using the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.

[0154] The magnetic sensor 180D includes a Hall sensor. The electronic device 100 can use the magnetic sensor 180D to detect the opening and closing of the flip case. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 can detect the opening and closing of the flip cover based on the magnetic sensor 180D. Based on the detected opening and closing status of the case or flip cover, features such as automatic unlocking of the flip cover can be configured.

[0155] Accelerometer 180E can detect the magnitude of acceleration of electronic device 100 in all directions (generally three axes). It can also detect the magnitude and direction of gravity when electronic device 100 is stationary. It can also be used to identify the electronic device's posture, enabling applications such as switching between landscape and portrait modes and pedometers.

[0156] The distance sensor 180F is used to measure distance. The electronic device 100 can measure distance using infrared or laser. In some embodiments, when shooting a scene, the electronic device 100 can use the distance sensor 180F to measure distance to achieve fast focusing.

[0157] The proximity light sensor 180G may include, for example, a light emitting diode (LED) and a light detector, such as a photodiode. The light emitting diode may be an infrared light emitting diode. The electronic device 100 emits infrared light outward through the light emitting diode. The electronic device 100 uses a photodiode to detect infrared reflected light from nearby objects. When sufficient reflected light is detected, it can be determined that there is an object near the electronic device 100. When insufficient reflected light is detected, the electronic device 100 can determine that there is no object near the electronic device 100. The electronic device 100 can use the proximity light sensor 180G to detect that the user is holding the electronic device 100 close to the ear to talk, so as to automatically turn off the screen to save power. The proximity light sensor 180G can also be used in leather case mode and pocket mode to automatically unlock and lock the screen.

[0158] Ambient light sensor 180L is used to sense ambient light brightness. Electronic device 100 can adaptively adjust the brightness of display screen 194 based on the perceived ambient light. Ambient light sensor 180L can also be used to automatically adjust white balance when taking photos. Ambient light sensor 180L can also work with proximity light sensor 180G to detect whether electronic device 100 is in a pocket to prevent accidental touches.

[0159] The fingerprint sensor 180H is used to collect fingerprints. The electronic device 100 can use the collected fingerprint characteristics to implement fingerprint unlocking, access application locks, fingerprint photography, fingerprint call answering, etc.

[0160] The temperature sensor 180J is used to detect temperature. In some embodiments, the electronic device 100 uses the temperature detected by the temperature sensor 180J to execute a temperature processing strategy. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor located near the temperature sensor 180J to reduce power consumption and implement thermal protection. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 heats the battery 142 to prevent the electronic device 100 from shutting down abnormally due to low temperature. In other embodiments, when the temperature is lower than another threshold, the electronic device 100 boosts the output voltage of the battery 142 to prevent abnormal shutdown due to low temperature.

[0161] The touch sensor 180K is also called a "touch panel." The touch sensor 180K can be disposed on the display screen 194. The touch sensor 180K and the display screen 194 form a touch screen, also called a "touch screen." The touch sensor 180K is used to detect touch operations applied thereto or in the vicinity thereof. The touch sensor can transmit the detected touch operations to the application processor to determine the type of touch event. Visual output related to the touch operations can be provided via the display screen 194. In other embodiments, the touch sensor 180K can also be disposed on the surface of the electronic device 100, in a location different from that of the display screen 194.

[0162] The bone conduction sensor 180M can obtain vibration signals. In some embodiments, the bone conduction sensor 180M can obtain vibration signals from the vibrating bones of the human body. The bone conduction sensor 180M can also contact the human pulse to receive blood pressure pulse signals. In some embodiments, the bone conduction sensor 180M can also be set in headphones to form bone conduction headphones. The audio module 170 can parse out voice signals based on the vibration signals of the vibrating bones of the human body obtained by the bone conduction sensor 180M to implement voice functions. The application processor can parse heart rate information based on the blood pressure pulse signals obtained by the bone conduction sensor 180M to implement heart rate detection functions.

[0163] The buttons 190 include a power button, a volume button, and the like. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive key inputs and generate key signal inputs related to user settings and function control of the electronic device 100.

[0164] Motor 191 can generate vibration prompts. Motor 191 can be used for incoming call vibration prompts, and can also be used for touch vibration feedback. For example, touch operations acting on different applications (such as taking pictures, audio playback, etc.) can correspond to different vibration feedback effects. For touch operations acting on different areas of the display screen 194, motor 191 can also correspond to different vibration feedback effects. Different application scenarios (for example: time reminders, receiving messages, alarm clocks, games, etc.) can also correspond to different vibration feedback effects. The touch vibration feedback effect can also support customization.

[0165] The indicator 192 may be an indicator light, which may be used to indicate the charging status, power level changes, messages, missed calls, notifications, etc.

[0166] The SIM card interface 195 is used to connect a SIM card. The SIM card can be connected to or disconnected from the electronic device 100 by inserting it into or removing it from the SIM card interface 195. The electronic device 100 can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support Nano SIM cards, Micro SIM cards, SIM cards, and the like. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The types of the multiple cards can be the same or different. The SIM card interface 195 can also be compatible with different types of SIM cards. The SIM card interface 195 can also be compatible with external memory cards. The electronic device 100 interacts with the network through the SIM card to implement functions such as calls and data communications. In some embodiments, the electronic device 100 uses an eSIM, i.e., an embedded SIM card. The eSIM card can be embedded in the electronic device 100 and cannot be separated from the electronic device 100.

[0167] The software system of the electronic device 100 can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. In the embodiment of the present invention, the Android system with a layered architecture is used as an example to illustrate the software structure of the electronic device 100.

[0168] Figure 6 It is a software structure block diagram of the electronic device 100 (eg, a mobile phone) according to an embodiment of the present invention.

[0169] A layered architecture divides software into several layers, each with distinct roles and responsibilities. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers: the application layer, the application framework layer, the Android runtime and system libraries, and the kernel layer.

[0170] The application layer can include a series of application packages.

[0171] like Figure 6 As shown, the application package may include applications such as camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, short message, etc.

[0172] The application framework layer provides an application programming interface (API) and programming framework for the applications in the application layer. The application framework layer includes some predefined functions.

[0173] like Figure 6 As shown, the application framework layer may include a window manager, a content provider, a view system, a phone manager, a resource manager, a notification manager, and the like.

[0174] The window manager is used to manage window programs. The window manager can obtain the display size, determine whether there is a status bar, lock the screen, take screenshots, etc.

[0175] Content providers are used to store and retrieve data and make it accessible to applications. The data may include videos, images, audio, calls made and received, browsing history and bookmarks, phone books, etc.

[0176] The view system includes visual controls, such as those for displaying text and images. The view system is used to build applications. A display interface can consist of one or more views. For example, a display interface containing a text notification icon might include a view for displaying text and a view for displaying images.

[0177] The phone manager is used to provide communication functions of the electronic device 100, such as management of call status (including answering, hanging up, etc.).

[0178] The resource manager provides various resources for applications, such as localized strings, icons, images, layout files, video files, and so on.

[0179] The Notification Manager allows applications to display notifications in the status bar. These messages can be displayed briefly and then disappear automatically without user interaction. For example, the Notification Manager is used to notify users of completed downloads and message reminders. The Notification Manager can also display notifications in the top status bar of the system as icons or scrolling text, such as notifications from background applications, or as dialog windows on the screen. Examples include text messages in the status bar, beeps, vibrations on electronic devices, and flashing indicator lights.

[0180] Android Runtime includes core libraries and a virtual machine. Android runtime is responsible for scheduling and management of the Android system.

[0181] The core library consists of two parts: one is the function that needs to be called by the Java language, and the other is the Android core library.

[0182] The application layer and application framework layer run in a virtual machine. The virtual machine executes Java files in the application layer and application framework layer as binary files. The virtual machine manages object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0183] The system library can include multiple functional modules, such as surface manager, media library, 3D graphics processing library (such as OpenGL ES), 2D graphics engine (such as SGL), etc.

[0184] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0185] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as: MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0186] The 3D graphics processing library is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0187] A 2D graphics engine is a drawing engine for 2D drawings.

[0188] The kernel layer is the layer between hardware and software. The kernel layer includes at least display driver, camera driver, audio driver, and sensor driver.

[0189] The following describes the workflow of the software and hardware of the electronic device 100 in conjunction with capturing a photo scene.

[0190] When the touch sensor 180K receives a touch operation, the corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including touch coordinates, touch operation timestamp, and other information). The raw input event is stored in the kernel layer. The application framework layer obtains the raw input event from the kernel layer and identifies the control corresponding to the input event. For example, if the touch operation is a touch single-click operation and the control corresponding to the single-click operation is the control of the camera application icon, the camera application calls the interface of the application framework layer to start the camera application, and then starts the camera driver by calling the kernel layer to capture a still image or video through the camera 193.

[0191] like Figure 7 As shown, Figure 7 The hardware structure diagram of the audio playback device 200 is exemplarily shown.

[0192] Figure 7 The structural diagram of the audio playback device 200 (eg, a Bluetooth device) provided in an embodiment of the present application is exemplarily shown.

[0193] The following embodiment is specifically described by taking the audio playback device 200 as a Bluetooth device as an example. It should be understood that Figure 7 The audio playback device 200 shown is only an example, and the audio playback device 200 may have more Figure 7 The more or less components shown in the figure can be combined with two or more components, or can have different component configurations. The various components shown in the figure can be implemented in hardware, software, or a combination of hardware and software including one or more signal processing and / or application specific integrated circuits.

[0194] like Figure 7 As shown, the audio playback device 200 may include: a processor 201, a memory 202, a Bluetooth communication module 203, an antenna 204, a power switch 205, a USB communication processing module 206, and an audio module 207.

[0195] Processor 201 can be used to read and execute computer-readable instructions. In a specific implementation, processor 201 may primarily include a controller, an arithmetic unit (ALU), and registers. The controller is primarily responsible for decoding instructions and issuing control signals for operations corresponding to the instructions. The ALU is primarily responsible for storing register operands and intermediate operation results temporarily stored during instruction execution. In a specific implementation, the hardware architecture of processor 201 may be an application-specific integrated circuit (ASIC), MIPS, ARM, or NP architecture, among others.

[0196] In some embodiments, the processor 201 may be configured to parse signals received by the Bluetooth communication module 203, such as a pairing mode modification request sent by the terminal 100, etc. The processor 201 may be configured to perform corresponding processing operations based on the parsing results, such as generating a pairing mode modification response, etc.

[0197] Memory 202 is coupled to processor 201 and is used to store various software programs and / or multiple sets of instructions. In a specific implementation, memory 202 may include high-speed random access memory and may also include non-volatile memory, such as one or more disk storage devices, flash memory devices, or other non-volatile solid-state storage devices. Memory 202 can store an operating system, such as embedded operating systems such as uCOS, VxWorks, and RTLinux. Memory 202 may also store communication programs that can be used to communicate with terminal 100, one or more servers, or other devices.

[0198] The Bluetooth communication module 203 may include a classic Bluetooth (BT) module and a Bluetooth Low Energy (BLE) module.

[0199] In some embodiments, the Bluetooth communication module 203 can monitor signals transmitted by other devices (such as terminal 100), such as detection requests, scanning signals, etc., and can send response signals, scanning responses, etc., so that other devices (such as terminal 100) can discover the audio playback device 200, and establish wireless communication connections with other devices (such as terminal 100), and communicate with other devices (such as terminal 100) via Bluetooth.

[0200] In other embodiments, the Bluetooth communication module 203 can also transmit signals, such as broadcasting BLE signals, so that other devices (such as terminal 100) can discover the audio playback device 200, establish wireless communication connections with other devices (such as terminal 100), and communicate with other devices (such as terminal 100) via Bluetooth.

[0201] The wireless communication function of the audio playback device 200 can be implemented through the antenna 204, the Bluetooth communication module 203, the modem processor, etc.

[0202] The antenna 204 can be used to transmit and receive electromagnetic wave signals. Each antenna in the audio playback device 200 can be used to cover a single or multiple communication frequency bands.

[0203] In some embodiments, the Bluetooth communication module 203 may have one or more antennas.

[0204] The power switch 205 may be used to control the power supply to the audio playback device 200 .

[0205] The USB communication processing module 206 may be used to communicate with other devices via a USB interface (not shown). In some embodiments, the audio playback device 200 may not include the USB communication processing module 206 .

[0206] The audio module 207 can be used to output audio signals through the audio output interface, so that the audio playback device 200 can support audio playback. The audio module can also be used to receive audio data through the audio input interface. The audio playback device 200 can be a media playback device such as a Bluetooth headset.

[0207] In some embodiments, the audio playback device 200 may further include a display screen (not shown), wherein the display screen may be used to display images, prompt information, etc. The display screen may be a liquid crystal display (LCD), an organic light-emitting diode (OLED) display screen, an active-matrix organic light-emitting diode (AMOLED) display screen, a flexible light-emitting diode (FLED) display screen, a quantum dot light-emitting diode (QLED) display screen, and the like.

[0208] In some embodiments, the audio playback device 200 may further include a serial interface such as an RS-232 interface. The serial interface can be connected to other devices, such as an audio external player such as a speaker, so that the audio playback device 200 and the audio external player can play audio and video in collaboration.

[0209] It is understandable that Figure 7 The illustrated structure does not constitute a specific limitation on the audio playback device 200. In other embodiments of the present application, the audio playback device 200 may include more or fewer components than shown, or may combine or separate certain components, or may have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0210] Before the electronic device 100 establishes a communication connection with the audio playback device 200, the electronic device 100 classifies all encoders in the electronic device 100 into multiple categories according to the codec classification standard, and the audio playback device 200 classifies all decoders in the audio playback device 200 into multiple categories.

[0211] In some embodiments, the electronic device 100 and the audio playback device 200 may also classify one or more codecs of the electronic device 100 and the audio playback device 200 into multiple categories after establishing a communication connection. This application does not limit the time when the codec 100 and the audio playback device 200 classify one or more codecs.

[0212] Next, the codec classification standard will be described in detail, as well as how the electronic device 100 and the audio playback device 200 classify the encoders in the electronic device 100 and the audio playback device 200 into multiple categories according to the codec classification standard.

[0213] Codec classification standard.

[0214] The codec classification standard can be obtained based on a combination of one or two or more parameters such as sampling rate, quantization bit depth, bit rate, number of channels, etc. Exemplarily, the codec classification standard can be obtained based on one parameter such as sampling rate, quantization bit depth, bit rate, number of channels, etc. For example, one parameter can be the sampling rate; the codec classification standard can also be obtained based on two parameters, for example, the two parameters can be the sampling rate and quantization bit depth; the codec classification standard can also be obtained based on three parameters, for example, the three parameters can be the sampling rate, quantization bit depth and bit rate; the codec classification standard can also be obtained based on four parameters, for example, the four parameters can be the sampling rate, quantization bit depth, bit rate, number of channels. This application does not limit the types of parameters used in the codec classification standard. The codec classification standard can also refer to other parameters, such as audio format, etc., which are not limited in this application. Exemplarily, the codec classification standard is pre-existing in the electronic device 100 and the audio playback device 200.

[0215] The sampling rate is the number of times the sound signal is sampled per unit time (e.g., one second). The higher the sampling rate, the more realistic the sound restoration and the better the sound quality.

[0216] Quantization bit depth is the quantization accuracy, which determines the dynamic range of digital audio. When performing frequency sampling, a higher quantization bit depth can provide more possible amplitude values, resulting in a larger vibration range, a higher signal-to-noise ratio, and improved fidelity.

[0217] Bitrate refers to the bit rate, which indicates the number of bits transmitted per unit time, measured in bits per second or kilobits per second. The higher the bitrate, the more audio data is transmitted per second, resulting in clearer sound quality.

[0218] The number of channels refers to the number of speakers that can produce different sounds. Channels include mono, dual, 2.1, 5.1, 7.1, and so on.

[0219] The most commonly used audio data format is PCM. PCM (Pulse Code Modulation) is an uncompressed audio data stream. It is a standard digital audio data format converted from an analog signal through sampling, quantization, and encoding. Other audio data formats include MP3, MPEG, MPEG-4, WAVE, and CD.

[0220] As mentioned above, the codec classification standard classifies codecs according to the value ranges of one or more parameters.

[0221] For example, when the codec classification standard is based on sampling rate, the sampling rate can be divided into multiple segments according to the lowest and highest sampling rates of the codecs frequently used in the device, with the sampling rate values ​​of each segment being different. Specifically, when the sampling rate value of the codec is greater than or equal to the first sampling rate, the codec is classified into category one; when the sampling rate value of the codec is less than the first sampling rate but greater than or equal to the second sampling rate, the codec is classified into category two; and when the sampling rate value of the codec is less than the second sampling rate, the codec is classified into category three. The first sampling rate is greater than the second sampling rate.

[0222] Exemplarily, when the codec classification standard is obtained based on the sampling rate and the bit rate, the sampling rate and the bit rate can be divided into multiple segments according to the lowest sampling rate and the highest sampling rate, and the lowest bit rate and the highest bit rate of the codecs frequently used in the device. Specifically, when the value of the codec's sampling rate is greater than or equal to the first sampling rate, and the value of the codec's bit rate is greater than or equal to the first bit rate, the codec is classified into category one; when the value of the codec's sampling rate is less than the first sampling rate and greater than or equal to the second sampling rate, and the value of the codec's bit rate is less than the first bit rate and greater than or equal to the second bit rate, the codec is classified into category two; when the value of the codec's sampling rate is less than the second sampling rate, and the value of the codec's bit rate is less than the second bit rate, the codec is classified into category three. Among them, the first sampling rate is greater than the second sampling rate, and the first bit rate is greater than the second bit rate.

[0223] Exemplarily, when the codec classification standard is obtained based on sampling rate, bit rate, and quantization bit depth, the sampling rate, bit rate, and quantization bit depth can be divided into multiple segments according to the lowest sampling rate and highest sampling rate, the lowest bit rate and highest bit rate, and the lowest quantization bit depth and highest quantization bit depth of the codecs frequently used in the device. Specifically, when the value of the codec's sampling rate is greater than or equal to the first sampling rate, the value of the codec's bit rate is greater than or equal to the first bit rate, and the value of the codec's quantization bit depth is greater than or equal to the first quantization bit depth, the codec is classified into category one; when the value of the codec's sampling rate is less than the first sampling rate and greater than or equal to the second sampling rate, the value of the codec's bit rate is less than the first bit rate and greater than or equal to the second bit rate, and the value of the codec's quantization bit depth is less than the first quantization bit depth and greater than or equal to the second quantization bit depth, the codec is classified into category two; when the value of the codec's sampling rate is less than the second sampling rate, the value of the codec's bit rate is less than the second bit rate, and the value of the codec's quantization bit depth is less than the second quantization bit depth, the codec is classified into category three. The first sampling rate is greater than the second sampling rate, the first bit rate is greater than the second bit rate, and the first quantization bit depth is greater than the second quantization bit depth.

[0224] For example, when the codec classification standard is obtained based on sampling rate, bit rate, quantization bit depth and number of channels, the sampling rate can be divided into multiple segments according to the lowest sampling rate and highest sampling rate, the lowest bit rate and the highest bit rate, the lowest quantization bit depth and the highest quantization bit depth of the codecs frequently used in the device, and the most commonly used minimum number of channels (for example, dual channels). Specifically, when the value of the codec sampling rate is greater than or equal to the first sampling rate, the value of the codec bit rate is greater than or equal to the first bit rate, the value of the codec quantization bit depth is greater than or equal to the first quantization bit depth, and the value of the codec channel number is greater than or equal to the first channel number, the codec is classified into category one; when the value of the codec sampling rate is less than the first sampling rate and greater than or equal to the second sampling rate, the value of the codec bit rate is less than the first bit rate and greater than or equal to the second bit rate, the value of the codec quantization bit depth is less than the first quantization bit depth and greater than or equal to the second quantization bit depth, and the value of the codec channel number is greater than or equal to the first channel number, the codec is classified into category two; when the value of the codec sampling rate is less than the second sampling rate, the value of the codec bit rate is less than the second bit rate, the value of the codec quantization bit depth is less than the second quantization bit depth, and the value of the codec channel number is greater than or equal to the first channel number, the codec is classified into category three. In which, the first sampling rate is greater than the second sampling rate, the first bit rate is greater than the second bit rate, and the first quantization bit depth is greater than the second quantization bit depth.

[0225] The above is only an example of some codec classification standards. In specific implementation, codec classification standards can be set according to different requirements, and this application will not list them one by one here.

[0226] Next, it will be described how the electronic device 100 and the audio playback device 200 are classified into multiple categories according to the codec classification standard.

[0227] After obtaining the classification standard of codecs, the electronic device 100 classifies all encoders into multiple categories, and the audio playback device 200 classifies all decoders into multiple categories.

[0228] Specifically, the electronic device 100 will obtain a codec classification standard, wherein the codec classification standard can classify codecs into multiple categories based on information about one or more parameters of the codec.

[0229] Afterwards, the electronic device 100 will obtain the numerical values ​​of one or more parameters corresponding to all encoders in the electronic device 100. When the numerical values ​​of one or more parameters corresponding to the encoder in the electronic device 100 are within the value range of one or more parameters adopted by the classification standard of the codec, the electronic device 100 will classify the encoder into one or more categories. Similarly, the electronic device 100 classifies all encoders into one or more categories according to the above method. It should be noted that an encoder can be divided into multiple categories. The electronic device 100 records the identifier of the encoder corresponding to each category. For example, when the category of the codec classification standard is category one, the identifiers of the encoders corresponding to category one include encoder one and encoder two.

[0230] The audio playback device 200 divides all decoders into multiple categories, which is consistent with the method used by the electronic device 100 to divide all encoders into multiple categories. This application will not repeat it here. The audio playback device 200 records the identifiers of the decoders corresponding to each category. For example, when the category of the codec classification standard is Category 1, the identifiers of the decoders corresponding to Category 2 include Decoder 1 and Decoder 2.

[0231] Next, the codec classification standard and the specific implementation of the electronic device 100 classifying encoders and the audio playback device 200 classifying decoders into multiple categories are introduced with reference to specific examples.

[0232] In an optional implementation, the codec classification standard may be obtained according to the sampling rate.

[0233] As shown in Table 1, Table 1 exemplarily shows the codec classification standard obtained according to the sampling rate.

[0234] Table 1

[0235]

[0236]

[0237] As shown in Table 1, when the value of one or more sampling rates supported by the codec is greater than or equal to the first sampling rate, the codec belongs to category 1; when the value of one or more sampling rates supported by the codec is less than the first sampling rate but greater than or equal to the second sampling rate, the codec belongs to category 2; when the value of one or more sampling rates supported by the codec is less than the second sampling rate, the codec belongs to category 3. The second sampling rate is less than the first sampling rate.

[0238] In a specific implementation, the electronic device 100 first obtains the sampling rate values ​​supported by all encoders in the electronic device 100. The electronic device 100 classifies the encoders into the categories shown in Table 1 based on the sampling rate values ​​supported by all encoders in the electronic device 100. It should be noted that the same encoder can be classified into multiple categories.

[0239] As shown in Table 2, Table 2 exemplarily shows that the electronic device 100 and the audio playback device 200 classify the codecs in the electronic device 100 and the audio playback device 200 into multiple categories according to the sampling rates.

[0240] Table 2

[0241]

[0242] It can be understood that the identifiers of the codecs shown in the embodiments of the present application can also be expressed in binary. For example, encoder one can be expressed as e001, encoder two can be expressed as e010, encoder three can be expressed as e011, decoder one can be expressed as d001, encoder one can be expressed as d010, and encoder one can be expressed as d011.

[0243] As shown in Table 2, for example, the first sampling rate is 48kHz and the second sampling rate is 24kHz. The encoder in the electronic device 100 that is classified into category one can be called a high-definition sound quality encoder, the encoder in the electronic device 100 that is classified into category two can be called a standard-definition sound quality encoder, and the encoder in the electronic device 100 that is classified into category three can be called a basic sound quality encoder. At the same time, the decoder in the audio playback device 200 that is classified into category one can be called a high-definition sound quality decoder, the decoder in the audio playback device 200 that is classified into category two can be called a standard-definition sound quality decoder, and the decoder in the audio playback device 200 that is classified into category three can be called a basic sound quality decoder.

[0244] For example, the electronic device 100 includes three encoders, namely encoder 1, encoder 2, and encoder 3. Encoder 1 supports sampling rates of 8 kHz, 16 kHz, 24 kHz, 32 kHz, 48 kHz, and 96 kHz. Encoder 2 supports sampling rates of 32 kHz and 48 kHz. Encoder 3 supports sampling rates of 8 kHz and 16 Hz. According to the codec classification standard shown in Table 2, encoder 1 belongs to category 1, and also belongs to category 2 and category 3. Encoder 2 belongs to category 2, and encoder 3 belongs to category 3.

[0245] Similarly, for the audio playback device 200, when the audio playback device 200 also has decoder one, decoder two, and decoder three. The audio playback device 200 obtains the numerical values ​​of the sampling rates supported by all decoders in the audio playback device 200. The audio playback device 200 classifies the decoders into the categories of the codec classification standard shown in Table 2 according to the numerical values ​​of the sampling rates supported by all decoders in the audio playback device 200. The method in which the audio playback device 200 classifies the decoders into the categories of the codec classification standard shown in Table 1 according to the numerical values ​​of the sampling rates supported by all decoders in the audio playback device 200 is the same as the method in which the electronic device 100 classifies the encoders into the categories of the codec classification standard shown in Table 1 according to the numerical values ​​of the sampling rates supported by all encoders in the electronic device 100, and will not be repeated in this application.

[0246] In an optional implementation, the codec classification standard can be obtained according to the sampling rate, quantization bit depth, bit rate and number of channels.

[0247] As shown in Table 3, Table 3 exemplifies the codec classification standard obtained according to sampling rate, quantization bit depth, bit rate and number of channels.

[0248] Table 3

[0249]

[0250] As shown in Table 3, when the value of one or more sampling rates supported by the codec is greater than or equal to the first sampling rate, the value of one or more quantization bit depths supported by the codec is greater than or equal to the first quantization bit depth, the value of one or more bit rates supported by the codec is greater than or equal to the first bit rate, and the number of channels supported by the codec is greater than or equal to the first number of channels, the codec belongs to Category 1. When the value of one or more sampling rates supported by the codec is less than the first sampling rate and greater than or equal to the second sampling rate, the value of one or more quantization bit depths supported by the codec is less than the first quantization bit depth and greater than or equal to the second quantization bit depth, the value of one or more bit rates supported by the codec is less than the first bit rate and greater than or equal to the second bit rate, and the number of channels supported by the codec is greater than or equal to the first number of channels, the codec belongs to Category 2. When the value of one or more sampling rates supported by the codec is less than the second sampling rate, the value of one or more quantization bit depths supported by the codec is less than the second quantization bit depth, the value of one or more bit rates supported by the codec is less than the second bit rate, and the number of channels supported by the codec is greater than or equal to the first number of channels, the codec belongs to Category 3.

[0251] In a specific implementation, the electronic device 100 first obtains the values ​​of the sampling rates, bit rates, quantization bit depths, and number of channels supported by all encoders in the electronic device 100. The electronic device 100 then classifies all encoders in the electronic device 100 into the categories shown in Table 3. It should be noted that the same encoder can be classified into multiple categories.

[0252] As shown in Table 4, Table 4 exemplarily shows that the codecs in the electronic device 100 and the audio playback device 200 are classified into multiple categories according to the sampling rate, the quantization bit depth, the bit rate and the number of channels.

[0253] Table 4

[0254]

[0255] As shown in Table 4, for example, when the first sampling rate is 48kHz, the second sampling rate is 24kHz, the first quantization bit depth is 24 bits, the second quantization bit depth is 16 bits, the first bit rate is 600kbps, the second bit rate is 300kbps, and the first number of channels is two, the encoder in electronic device 100 classified into category 1 can be called a high-definition audio quality encoder, the encoder in electronic device 100 classified into category 2 can be called a standard-definition audio quality encoder, and the encoder in electronic device 100 classified into category 3 can be called a basic audio quality encoder.

[0256] For example, the electronic device 100 includes three encoders, namely encoder 1, encoder 2, and encoder 3. Encoder 1 supports sampling rates of 8 kHz, 16 kHz, 24 kHz, 32 kHz, 48 kHz, and 96 kHz, supports quantization bit depths of 16 bits, 24 bits, and 32 bits, supports bit rates of 600 kbps, 900 kbps, and 1200 kbps, and supports mono, stereo, 2.1, and 5.1 channels. Encoder 2 supports sampling rates of 16 bits, 32 kHz, and 48 kHz, supports quantization bit depths of 8 bits, 16 bits, and 24 bits, supports bit rates of 200 kbps, 300 kbps, 400 kbps, and 600 kbps, and supports mono and stereo channels. Encoder 3 supports sampling rates of 8kHz and 16kHz, quantization bit depths of 8 bits and 16 bits, bit rates of 200kbps and 300kbps, and mono, stereo, 2.1, 5.1, and 7.1 channels.

[0257] According to the codec classification standard shown in Table 4, encoder 1 belongs to category 1. Encoder 2 belongs to category 2. At the same time, encoder 2 also belongs to category 3. Encoder 3 belongs to category 3.

[0258] Similarly, for audio playback device 200, when audio playback device 200 also has decoder 1, decoder 2, and decoder 3, audio playback device 200 obtains the values ​​of the sampling rates supported by all decoders in audio playback device 200, the values ​​of the bit rates supported by all decoders, the values ​​of the quantization bit depths supported by all decoders, and the values ​​of the number of channels supported by all decoders, and classifies the decoders into the categories of the codec classification standard shown in Table 4. It should be noted that the same decoder can belong to multiple categories of the codec classification standard. The audio playback device 200 classifies the decoders into the categories shown in Table 4 based on the values ​​of the sampling rates supported by all decoders, the values ​​of the bit rates supported by all decoders, the values ​​of the quantization bit depths supported by all decoders, and the values ​​of the number of channels supported by all decoders in audio playback device 200. This is the same as the method by which electronic device 100 classifies encoders into the categories shown in Table 4 based on the values ​​of the sampling rates supported by all encoders, the values ​​of the bit rates supported by all encoders, the values ​​of the quantization bit depths supported by all encoders, and the values ​​of the number of channels supported by all encoders in electronic device 100, and this application will not repeat it here.

[0259] After the electronic device 100 classifies the encoders and the audio playback device 200 classifies the decoders into multiple categories, the electronic device 100 and the audio playback device 200 negotiate to arrive at a common category. Thereafter, when transmitting audio data between the electronic device 100 and the audio playback device 200, the electronic device 100 uses the default encoder in one of the common categories to encode the audio data and sends it to the audio playback device 200. The audio playback device 200 then decodes the encoded audio data using the default decoder in that category and then plays the audio data.

[0260] like Figure 8 As shown, Figure 8 The diagram exemplarily shows a diagram of the electronic device 100 and the audio playback device 200 negotiating a common category.

[0261] S801 : The electronic device 100 establishes a communication connection with the audio playback device 200 .

[0262] The electronic device 100 can establish a communication connection with the audio playback device 200 via any one of Bluetooth, Wi-Fi Direct, and a local area network. How the electronic device 100 and the audio playback device 200 establish a communication connection will be described in detail later and will not be repeated in this application. The embodiment of this application is described by taking the example of the electronic device 100 and the audio playback device 200 establishing a communication connection via Bluetooth technology as an example.

[0263] S802: The audio playback device 200 classifies all decoders into multiple categories according to a codec classification standard.

[0264] The audio playback device 200 first obtains the codec classification standard. It is understandable that the codec classification standard is pre-existing in the audio playback device 200.

[0265] Afterwards, the audio playback device 200 obtains the values ​​of one or more parameters of all decoders in the audio playback device 200 .

[0266] The audio playback device 200 determines that the values ​​of one or more parameters of the decoder are within the value range of the one or more parameters adopted by the codec classification standard, and then the audio playback device 200 classifies the decoder into one or more categories.

[0267] According to this method, the audio playback device 200 divides all decoders in the audio playback device 200 into multiple categories. It should be noted that a decoder can be divided into multiple categories. The audio playback device 200 records the identifiers of the decoders in each category. For example, when the category of the codec classification standard is category one, the identifiers of the decoders included in category one include decoder one and decoder two; when the category of the codec classification standard is category two, the identifiers of the decoders included in category two include decoder two and decoder three; when the category of the codec classification standard is category three, the identifiers of the decoders included in category three include decoder three; when the category of the codec classification standard is category four, the identifiers of the decoders included in category four are empty.

[0268] The codec classification standard and how the audio playback device 200 divides all decoders into multiple categories based on the values ​​of one or more parameters of all decoders have been described in detail in Tables 1 to 4, and will not be repeated here in this application.

[0269] S803: The audio playback device 200 obtains a decoder identifier for each category.

[0270] As can be seen from S802 , the audio playback device 200 divides all decoders in the audio playback device 200 into multiple categories and records the identifiers of the decoders in each category.

[0271] S804 : The audio playback device 200 sends the category identifiers whose number of decoder identifiers is greater than or equal to 1 to the electronic device 100 .

[0272] After the audio playback device 200 obtains the decoder identifier of each category, the audio playback device 200 only needs to send the category identifiers whose number of decoder identifiers is greater than or equal to 1 to the electronic device 100 .

[0273] In some embodiments, the audio playback device 200 may also send category identifiers whose number of decoder identifiers is greater than or equal to 1, and the decoder identifier corresponding to each category to the electronic device 100 .

[0274] In some embodiments, the audio playback device 200 may also only send all decoder identifiers and the numerical values ​​of one or more parameters corresponding to each decoder to the electronic device 100. The electronic device 100 classifies all decoders in the audio playback device 200 into multiple categories based on the codec classification standard. That is, the electronic device 100 obtains the decoder identifier corresponding to each category. Specifically, for the electronic device 100, the electronic device 100 will obtain the codec classification standard. It is understood that the codec classification standard is pre-existing in the electronic device 100.

[0275] The electronic device 100 determines that the values ​​of one or more parameters of the decoder are within the value range of the one or more parameters adopted by the codec classification standard, and then the electronic device 100 classifies the decoder into one or more categories.

[0276] According to this method, the electronic device 100 divides all decoders in the audio electronic device 100 into multiple categories. It should be noted that a decoder can be divided into multiple categories. The electronic device 100 records the identifiers of the decoders in each category. Exemplarily, when the category of the codec classification standard is category one, the identifiers of the decoders included in category one include decoder one and decoder two; when the category of the codec classification standard is category two, the identifiers of the decoders included in category two include decoder two and decoder three; when the category of the codec classification standard is category three, the identifiers of the decoders included in category three include decoder three; when the category of the codec classification standard is category four, the identifiers of the decoders included in category four are empty.

[0277] After the electronic device 100 obtains the decoder identifier of each category, the audio playback device 200 can obtain the category identifier whose number of decoder identifiers is greater than or equal to 1.

[0278] S805 : The electronic device 100 classifies all encoders into multiple categories according to the codec classification standard.

[0279] The electronic device 100 first obtains the codec classification standard. It is understandable that the codec classification standard is pre-existing in the audio playback device 200.

[0280] Afterwards, the electronic device 100 obtains the values ​​of one or more parameters of all encoders in the electronic device 100 .

[0281] If the electronic device 100 determines that the values ​​of one or more parameters of the encoder are within the value range of the one or more parameters adopted by the codec classification standard, the audio playback device 200 classifies the encoder into one or more categories.

[0282] According to this method, the electronic device 100 divides all encoders into multiple categories according to the above method. It should be noted that an encoder can be divided into multiple categories. The electronic device 100 records the identifier of the encoder under each category. Exemplarily, when the category of the codec classification standard is category one, the identifiers of the encoders included in category one include encoder one and encoder two; when the category of the codec classification standard is category two, the identifiers of the encoders included in category two include encoder two and encoder three; when the category of the codec classification standard is category three, the identifiers of the encoders included in category three include encoder three; when the category of the codec classification standard is category four, the identifiers of the encoders included in category four include encoder one and encoder four.

[0283] The codec classification standard and how the electronic device 100 divides all encoders into multiple categories according to the values ​​of one or more parameters of all encoders have been described in detail in Tables 1 to 4, and will not be repeated here in this application.

[0284] S806: The electronic device 100 obtains an encoder identifier for each category.

[0285] As can be seen from S805, the electronic device 100 divides all encoders in the electronic device 100 into multiple categories and records the identifiers of the encoders in each category. It is understandable that S705-S706 can be executed before S702, and this application does not limit this.

[0286] S807: The electronic device 100 identifies a common category among the categories whose number of encoder identifiers is greater than or equal to 1 and the categories whose number of decoder identifiers is greater than or equal to 1.

[0287] The electronic device 100 receives the categories with the number of encoder identifiers greater than or equal to 1 sent by the audio playback device 200. For example, the categories with the number of encoder identifiers greater than or equal to 1 sent by the audio playback device 200 may be category 1, category 2, category 3, and category 4.

[0288] After obtaining the encoder identifiers for each category, the electronic device 100 identifies the category with the number of encoder identifiers greater than or equal to 1. For example, the categories identified by the electronic device 100 as category 1, category 2, and category 4 may be category 1, category 2, and category 4.

[0289] Afterwards, the electronic device 100 identifies shared categories from the categories with a number of encoder identifiers greater than or equal to 1 and the categories with a number of decoder identifiers greater than or equal to 1. Shared categories are the intersection of the categories with a number of encoder identifiers greater than or equal to 1 and the categories with a number of decoder identifiers greater than or equal to 1. Shared categories are categories in which the electronic device 100 can transmit audio data to the audio playback device 200 using the encoders and decoders in these categories. For example, shared categories may be Category 1, Category 2, and Category 4.

[0290] S808: The electronic device 100 determines a default encoder identifier in the common category.

[0291] For any common category, if the number of encoder identifiers is 1 or the number of decoder identifiers is 1, the electronic device 100 determines that the encoder identifier under this category is a default encoder identifier, or the decoder identifier under this category is a default decoder identifier.

[0292] For example, when the shared category is category 3, the encoder identifier included in category 3 includes encoder 3. When the category of the codec classification standard is category 3, the decoder identifier included in category 3 includes decoder 3. Because category 3 includes only one encoder identifier, the electronic device 100 determines that encoder 3 is the default encoder under category 3. Because category 3 includes only one decoder identifier, the electronic device 100 determines that decoder 3 is the default decoder under category 3.

[0293] For any common category, if the number of encoder identifiers is greater than 1 or the number of decoder identifiers is greater than 1, the electronic device 100 will identify a default encoder identifier from more than 1 encoder identifiers according to a preset rule, or the electronic device 100 will identify a default decoder identifier from more than 1 decoder identifiers according to a preset rule.

[0294] The preset rules may be priority rules, low power rules, high efficiency rules, and the like.

[0295] In an optional implementation, the electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to a priority rule, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to a priority rule.

[0296] As shown in Table 5, Table 5 exemplarily shows the priority rankings of the encoder and decoder.

[0297] Table 5

[0298]

[0299] It is understandable that the priority of encoders and decoders can be common in the industry or set by developers. This application does not limit the priority order of codecs.

[0300] The electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to the codec priorities shown in Table 5, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to the priority rule.

[0301] For example, for category 1, the identifiers of decoders included in category 1 include decoder 1 and decoder 2, and the identifiers of encoders included in category 1 include encoder 1 and encoder 2. Since the priority ranking of encoder 1 is higher than the priority ranking of encoder 2, the electronic device 100 determines that encoder 1 is the default encoder for category 1. Since the priority ranking of decoder 1 is higher than the priority ranking of decoder 2, the electronic device 100 determines that decoder 1 is the default decoder for category 1.

[0302] In an optional implementation, the electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to the low power rule, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to the low power rule.

[0303] As shown in Table 6, Table 6 exemplarily shows the power ranking of encoders and decoders.

[0304] Table 6

[0305]

[0306] It is understandable that the power levels of the encoder and decoder can be common in the industry or set by the developer. This application does not limit the power levels of the codec.

[0307] The electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to the encoder power ranking from low to high shown in Table 6, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to the encoder power ranking from low to high.

[0308] For example, for category 1, the identifiers of decoders included in category 1 include decoder 1 and decoder 2, and the identifiers of encoders included in category 1 include encoder 1 and encoder 2. Since the power of encoder 1 is lower than the power of encoder 2, the electronic device 100 determines that encoder 1 is a default encoder for category 1. Since the power of decoder 1 is lower than the power of decoder 2, the electronic device 100 determines that decoder 1 is a default decoder for category 1.

[0309] In an optional implementation, the electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to an efficiency rule, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to an efficiency rule.

[0310] As shown in Table 7, Table 7 exemplarily shows the efficiency ranking of encoders and decoders.

[0311] Table 7

[0312]

[0313] It is understandable that the efficiency of the encoder and decoder can be common in the industry or set by the developer. This application does not limit the efficiency of the codec.

[0314] The electronic device 100 identifies a default encoder identifier from more than one encoder identifier according to the encoder efficiency ranking shown in Table 6, or the electronic device 100 identifies a default decoder identifier from more than one decoder identifier according to the encoder efficiency.

[0315] For example, for category 1, the identifiers of decoders included in category 1 include decoder 1 and decoder 2, and the identifiers of encoders included in category 1 include encoder 1 and encoder 2. Since the efficiency of encoder 1 is higher than the efficiency of encoder 2, the electronic device 100 determines that encoder 1 is a default encoder for category 1. Since the efficiency of decoder 1 is higher than the efficiency of decoder 2, the electronic device 100 determines that decoder 1 is a default decoder for category 1.

[0316] The electronic device 100 may also identify a default encoder identifier from more than one encoder identifier, or identify a default decoder identifier from more than one decoder identifier according to other rules, which is not limited in this application.

[0317] In some embodiments, the electronic device 100 determines the default encoder identifier in the common category, and the electronic device 100 also needs to confirm the default decoder identifier in the common category.

[0318] Specifically, when the audio playback device 200 sends all decoder identifiers and the values ​​of one or more parameters corresponding to each decoder to the electronic device 100, the electronic device 100 classifies all decoders in the audio playback device 200 into multiple categories according to the codec classification standard. The electronic device 100 then identifies the categories shared by the electronic device 100 and the audio playback device 200. Alternatively, when the audio playback device 200 classifies all decoders in the audio playback device 200 into multiple categories according to the codec classification standard and sends the categories with a decoder identifier greater than or equal to one, as well as the decoder identifier corresponding to each category, the electronic device 100 then identifies the categories shared by the electronic device 100 and the audio playback device 200. After identifying the shared categories, the electronic device 100 also identifies a default encoder identifier for each shared category. The electronic device 100 also needs to identify a default decoder identifier for each shared category. Specifically, if the number of corresponding decoder identifiers for some shared categories is one, the electronic device 100 identifies the decoder identifier corresponding to that category as the default decoder identifier. When the number of corresponding decoder identifiers for some common categories is greater than 1, the electronic device 100 can use the embodiments shown in Tables 5 to 7 to identify the default decoder identifier for the category.

[0319] S809 : The electronic device 100 sends the shared category identifier to the audio playback device 200 .

[0320] After the electronic device 100 identifies the common category, the electronic device 100 sends the common category identifier to the audio playback device 200 .

[0321] The audio playback device 200 receives the shared category identifier sent by the electronic device 100 .

[0322] In some embodiments, the audio playback device 200 further needs to identify the default decoder identifier in each common category.

[0323] For any common category, if the number of decoder identifiers is 1, the audio playback device 200 determines that the identifier of the decoder under this category is a default decoder identifier.

[0324] For example, when the codec classification standard is category 3, the decoder identifiers included in category 3 include decoder 3. Because category 3 includes only one decoder identifier, the audio playback device 200 determines that encoder 3 is a default decoder under category 3.

[0325] For any common category, if the number of decoder identifiers is greater than 1, the audio playback device 200 will identify a default decoder identifier from more than one encoder identifiers according to a preset rule.

[0326] The preset rules may be priority rules, low power rules, high efficiency rules, and the like.

[0327] The method by which the audio playback device 200 identifies a default decoder identifier from more than one encoder identifier according to a priority rule, a low power rule, or a high efficiency rule is consistent with the method by which the aforementioned electronic device 100 identifies a default decoder identifier from more than one encoder identifier according to a priority rule, a low power rule, or a high efficiency rule, and is not repeated herein in this application.

[0328] S809 may also be executed after S802, which is not limited in this application.

[0329] In some embodiments, when the electronic device 100 identifies a default decoder identifier in a shared category, the electronic device 100 sends the shared category identifier to the audio playback device 200 and also sends the default decoder identifier in the shared category to the audio playback device 200 .

[0330] Optionally, the electronic device 100 may also send the common category identifier and the default decoder identifier and default encoder identifier under each category to the audio playback device 200 .

[0331] After the electronic device 100 and the audio playback device 200 confirm the common categories and the default codecs under each common category, the electronic device 100 will select an appropriate category from the common categories based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is enabled, the network conditions of the channel, etc., and transmit audio data using the default codec in the category.

[0332] Next, it is introduced how the electronic device 100 selects an appropriate category from the common categories based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is enabled, channel network conditions, etc.

[0333] 1. Application Type: Different audio playback applications on the electronic device 100 have different requirements for audio playback characteristics. The electronic device 100 will obtain the audio application's requirements for the minimum sampling rate, minimum quantization bit depth, and number of channels for the audio data. Based on these requirements, the electronic device 100 will select an appropriate category from the common categories. For example, some applications have high audio quality requirements and require high audio data sampling rate and quantization bit depth. For example, typical audio playback applications require a sampling rate of 32kHz and a quantization bit depth of 16 bits. However, applications with higher audio quality requirements may require a minimum sampling rate of 48kHz and a minimum quantization bit depth of 24 bits. Based on the conditions that the sampling rate includes 48kHz and the quantization bit depth includes 24 bits, the electronic device 100 may select the default codec for that category for audio data transmission.

[0334] 2. Audio Playback Characteristics: The electronic device 100 may have different characteristics for the different audio data that can be played by applications. The electronic device 100 will obtain the minimum sampling rate, minimum quantization bit depth, and number of channels required for the audio data being played. Then, based on these requirements, the electronic device 100 will select an appropriate category from the shared categories. For example, some audio data may have higher sound quality requirements, requiring higher sampling rates and quantization bit depths. For example, the sampling rate of typical audio data is 32kHz, and the quantization bit depth is 16 bits. However, some preset audio data with higher sound quality has a minimum sampling rate of 48kHz and a minimum quantization bit depth of 24 bits. Based on the conditions that the sampling rate includes 48kHz and the quantization bit depth includes 24 bits, the electronic device 100 may select the default codec for that category for audio data transmission.

[0335] 3. Whether the audio rendering capability of the electronic device is enabled: The sampling rate of the audio currently played by the electronic device is sampling rate one, the quantization bit depth is quantization bit depth one, the bit rate is bit rate one, and the number of channels is channel one. When the audio rendering capability of the electronic device 100 is enabled, the rendering unit of the electronic device 100 can increase the sampling rate of the audio data from sampling rate one to sampling rate two, the rendering unit of the electronic device 100 can increase the quantization bit depth of the audio data from quantization bit depth one to quantization bit depth two, and the rendering unit of the electronic device 100 can increase the number of channels of the audio data from channel one to channel two. Among them, sampling rate two is greater than sampling rate one, quantization bit depth two is greater than quantization bit depth one, and number of channels two is greater than number of channels one. Afterwards, the electronic device 100 selects a default codec under a category including sampling rate 2, quantization bit depth 2, bit rate 1, and number of channels 2 from the common categories based on the sampling rate of the audio data being sampling rate 2, the quantization bit depth of the audio data being quantization bit depth 2, the bit rate being bit rate 1, and the number of channels of the audio data being channel number 2, to transmit the audio data.

[0336] 4. Channel network conditions: The sampling rate of the audio data currently played by the electronic device is sampling rate 1, the quantization bit depth is quantization bit depth 1, the number of channels is channel number 1, and the bit rate is bit rate 1. The electronic device 100 selects a category including sampling rate 1, quantization bit depth 1, number of channels 1, and bit rate 1 from the common categories based on the sampling rate of the audio data being sampling rate 1, the quantization bit depth of the audio data being quantization bit depth 1, the number of channels being channel number 1, and the bit rate of the audio data being bit rate 1, and uses the default codec in the category to transmit the audio data.

[0337] It should be noted that the electronic device 100 can also select an appropriate category from the common categories based on other parameters, not limited to the application type listed in the above embodiments, the playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is turned on, the network conditions of the channel, etc., and this application will not go into details here.

[0338] After the electronic device 100 and the audio playback device 200 select an appropriate category from the shared categories and use the default codec in the category for audio data transmission, due to factors such as changes in application type, changes in playback audio characteristics (sampling rate, quantization bit depth, number of channels), activation of the electronic device's audio rendering capabilities, changes in channel network conditions, etc., the electronic device 100 will reselect another category and notify the audio playback device 200 of the category identifier. The electronic device 100 and the audio playback device 200 use the default codec in the other category for audio data transmission.

[0339] 1. Application type changes from application type 1 to application type 2: Different audio playback applications in electronic device 100 have different requirements for audio playback characteristics. When electronic device 100 plays audio data according to application type 1, the audio data's sampling rate is sample rate 1, the quantization bit depth is quantization bit depth 1, the bit rate is bit rate 1, and the number of channels is channel number 1. After electronic device 100 switches the audio data playback application from application 1 to application 2, if application 2 has higher audio data quality requirements, when application type 2 plays audio data, the audio data's sampling rate is sample rate 2, the quantization bit depth is quantization bit depth 2, the bit rate is bit rate 2, and the number of channels is channel number 1. Sample rate 2 is greater than sample rate 1, quantization bit depth 2 is greater than quantization bit depth 1, and bit rate 2 is greater than bit rate 1. Due to the parameter changes, electronic device 100 will reselect the codec classification category. The electronic device 100 selects a default codec from the common categories, wherein the sampling rate includes sampling rate 2, the quantization bit depth includes quantization bit depth 2, the bit rate value includes bit rate 2, and the number of channels includes channel number 1, to transmit audio data.

[0340] 2. The audio content switches from audio data 1 to audio data 2: In the electronic device 100, the application can play different audio data, and the characteristics of different audio data may be different. When the electronic device 100 plays audio data 1 according to the application type, the sampling rate of audio data 1 is sampling rate 1, the quantization bit depth is quantization bit depth 1, the bit rate is bit rate 1, and the number of channels is channel number 1. After the electronic device 100 switches the audio content played from audio data 1 to audio data 2, if the sound quality of audio data 2 is higher, when the electronic device 100 plays audio data 2, the sampling rate of audio data 2 is sampling rate 2, the quantization bit depth is quantization bit depth 2, the bit rate is bit rate 2, and the number of channels is channel number 1, where sampling rate 2 is greater than sampling rate 1, quantization bit depth 2 is greater than quantization bit depth 1, and bit rate 2 is greater than bit rate 1. Due to the parameter changes, the electronic device 100 will reselect the codec classification category. The electronic device 100 selects a default codec from the common categories, wherein the sampling rate includes sampling rate 2, the quantization bit depth includes quantization bit depth 2, the bit rate value includes bit rate 2, and the number of channels includes channel number 1, to transmit audio data.

[0341] 3. The audio rendering capability of the electronic device changes from off to on: the sampling rate of the audio currently played by the electronic device is sampling rate one, the quantization bit depth is quantization bit depth one, the bit rate is bit rate one, and the number of channels is channel one. When the audio rendering capability of the electronic device 100 is turned on, the rendering unit of the electronic device 100 can increase the sampling rate of the audio data from sampling rate one to sampling rate two, the rendering unit of the electronic device 100 can increase the quantization bit depth of the audio data from quantization bit depth one to quantization bit depth two, and the rendering unit of the electronic device 100 can increase the number of channels of the audio data from channel one to channel two. Among them, sampling rate two is greater than sampling rate one, quantization bit depth two is greater than quantization bit depth one, and number of channels two is greater than number of channels one. Due to the parameter changes, the electronic device 100 will reselect the codec classification category. The electronic device 100 selects a default codec from a category including sampling rate 2, quantization bit depth 2, bit rate 1, and number of channels 2 from the common categories to transmit audio data.

[0342] 4. The network conditions of the channel deteriorate: the sampling rate of the audio data currently played by the electronic device is sampling rate one, the quantization bit depth is quantization bit depth one, the number of channels is channel number one, and the bit rate is bit rate one. Due to strong interference and attenuation of the wireless transmission channel, the bit rate supported by the wireless transmission channel is reduced from bit rate one to bit rate two, where bit rate two is less than bit rate one. Due to parameter changes, the electronic device 100 will reselect the codec classification category. The electronic device 100 will select the default codec under a category including sampling rate one, quantization bit depth two including quantization bit depth one, bit rate values ​​including bit rate two, and number of channels including channel number one from the common categories to transmit audio data.

[0343] After the electronic device 100 reselects the default codec under another category, the electronic device 100 and the audio playback device 200 use the default codec under another category to transmit audio data. In order to reduce the occurrence of stuck segments when switching codecs, the embodiment of the present application can use the following method to achieve a smooth transition when switching codecs.

[0344] When the electronic device 100 switches the codec classification standard from Category 1 to Category 2, Category 1 corresponds to the default encoder 1 and decoder 1, and Category 2 corresponds to the default encoder 2 and decoder 2. The electronic device 100 switches from encoder 1 to encoder 2, and the audio playback device 200 switches from decoder 1 to decoder 2.

[0345] When the delays of encoder 1 and encoder 2 are the same, electronic device 100 needs to complete the switch from encoder 1 to encoder 2 within one frame of audio data. The frame of audio data during the transition from encoder 1 to encoder 2 is called the i-th frame of audio data. Encoder 1 encodes the i-th frame of audio data, generating packet A. Encoder 2 encodes the i-th frame of audio data, generating packet B.

[0346] Electronic device 100 sends packet A and packet B to audio playback device 200. Audio playback device 200 decodes packet A using decoder 1 to obtain audio data pcmA. Audio playback device 200 also decodes packet A using decoder 2 to obtain audio data pcmB. Then, audio playback device 200 smoothes the i-th frame of audio data. The smoothing process is shown in formula (1):

[0347] Pcm(i)=wi*pcmA(i)+(1-wi)*pcmB(i) Formula (1)

[0348] As shown in formula (1), Pcm(i) represents the audio data of the i-th frame after smoothing, and wi represents the smoothing coefficient. wi can be linear smoothing or cosine smoothing, etc. The value range of wi is between 0 and 1. The smaller the smoothing coefficient wi, the stronger the smoothing effect, and the smaller the adjustment to the prediction result; the larger the smoothing coefficient wi, the weaker the smoothing effect, and the greater the adjustment to the prediction result. pcmA(i) represents the audio data obtained by decoder 1 decoding packet A, and pcmB(i) represents the audio data obtained by decoder 2 decoding packet B. Through formula (1), the audio playback device 200 can obtain the audio data frame Pcm(i) after smoothing the i-th frame audio data. In this way, the audio playback device 200 plays the audio data frame after smoothing the i-th frame audio data, which can make the audio data frame transition smoothly during the codec switching process.

[0349] When the delays of encoder 1 and encoder 2 are different, the electronic device 100 needs to switch from encoder 1 to encoder 2 within multiple audio data frames. The calculation process of the total number of audio data frames D during the switching process between encoder 1 and encoder 2 is shown in formula (2):

[0350] D = round ((max (total delay of encoder 1, total delay of encoder 2) + (frame length - total delay of encoder 1% frame length) + frame length - 1) / frame length) Formula (2)

[0351] As shown in formula (2), max represents the maximum value operation, % represents the remainder operation, and the frame length represents that the encoder encodes a certain length of audio data into a frame, and the frame length is the frame length.

[0352] For the total number of audio data frames D during the transition process, each frame of audio data is encoded using encoder 1 and encoder 2, and two data packets can be obtained for each frame of audio data, namely packet A and packet B. The electronic device 100 sends packet A and packet B to the audio playback device 200. The audio playback device receives packet A and packet B, decodes packet A using decoder 1 to obtain audio data pcmA, and decodes packet B using decoder 2 to obtain audio data pcm B. For the total number of audio data frames D during the switching process, the first D-1 audio data frames are still the audio data decoded by decoder 1. For the D-th audio data frame, the audio playback device 200 performs smoothing on the D-th audio data frame. The smoothing process is shown in formula (3):

[0353] Pcm(i)=wi*pcmA(i)+(1-wi)*pcmB(i) Formula (3)

[0354] As shown in formula (3), Pcm(i) represents the Dth audio data frame after smoothing, and wi represents the smoothing coefficient, which can be linear smoothing or cosine smoothing, etc. The value range of wi is between 0 and 1. The smaller the smoothing coefficient wi, the stronger the smoothing effect and the smaller the adjustment to the prediction result; the larger the smoothing coefficient wi, the weaker the smoothing effect and the greater the adjustment to the prediction result. pcmA(i) represents the audio data obtained by decoder 1 decoding the Dth audio data frame, and pcmB(i) represents the audio data obtained by decoder 2 decoding the Dth audio data frame. Through formula (3), the audio playback device 200 can obtain the audio data frame Pcm(i) after smoothing the Dth audio data frame. In this way, the audio playback device 200 plays the audio data frame after smoothing the first D-1 audio data frames and the Dth frame audio data, which can make the audio data frame transition smoothly during the codec switching process.

[0355] like Figure 9 As shown, Figure 9 A flowchart of a codec negotiation and switching method provided in an embodiment of the present application.

[0356] S901 : The electronic device 100 establishes a communication connection with the audio playback device 200 .

[0357] The electronic device 100 can establish a communication connection with the audio playback device 200 via one or more of Bluetooth, Wi-Fi Direct, and NFC. The embodiment of the present application takes the example of the electronic device 100 and the audio playback device 200 establishing a communication connection via Bluetooth technology as an example.

[0358] The following describes in detail how the electronic device 100 and the audio playback device 200 establish a communication connection with each other in conjunction with the UI diagram.

[0359] Figures 9A-9C The UI diagram exemplifies the establishment of a communication connection between the electronic device 100 and the audio playback device 200 via Bluetooth. The electronic device 100 is not limited to establishing a communication connection with the audio playback device 200 via Bluetooth. The electronic device 100 can also establish a communication connection with the audio playback device 200 via one or more of Wi-Fi Direct and NFC.

[0360] Figure 9A FIG. 6 shows an exemplary audio playback user interface 600 on the electronic device 100. Figure 9A As shown, the audio playback interface 600 includes a music title 601, a play control 602, a previous song control 603, a next song control 604, a play progress bar 605, a download control 606, a share control 607, and a more button 608, among other features. For example, the music title 601 may be "Dreamit possible." The play control 602 is used to trigger the terminal 100 to play the audio data corresponding to the music title 601. The previous song control 603 can be used to trigger the electronic device 100 to switch to playing the previous audio data in the playlist. The next song control 604 can be used to trigger the electronic device 100 to switch to playing the next audio data in the playlist. The play progress bar 605 can be used to indicate the playback progress of the current audio data. The download control 606 can be used to trigger the electronic device 100 to download and save the audio data of the music title 601 to a local storage medium. The share control 607 can be used to trigger the electronic device 100 to share the playback link of the audio data corresponding to the music title 601 to other applications. The more control 608 can be used to trigger the electronic device 100 to display more functional controls related to music playback.

[0361] Not limited to music playback, the electronic device 100 can also play audio data played by video applications, audio data played by game applications, audio data of real-time calls, etc. This application does not limit the source of the audio data played by the electronic device 100.

[0362] like Figure 9B and Figure 9C As shown, when the electronic device 100 detects a downward sliding gesture on the display screen, in response to the sliding gesture, the electronic device 100 displays on the user interface 20 as shown in FIG. Figure 9C Window 610 is shown. Figure 9C As shown, a Bluetooth control 611 may be displayed in window 610, and the Bluetooth control 611 may receive an operation (such as a touch operation, a click operation) to turn on / off the Bluetooth function of the electronic device 100. The expression of the Bluetooth control 611 may include an icon and / or text (such as the text "collaborative screen projection"). Other functions such as Wi-Fi, hotspot, flashlight, ringing, automatic rotation, instant sharing, flight mode, mobile data, location information, screenshot, eye protection mode, screen recording, collaborative screen projection, NFC and other switch controls may also be displayed in window 610, that is, a user operation to turn on the collaborative screen projection function is detected. In some embodiments, after the electronic device 100 detects a user operation acting on the Bluetooth control 611, it can change the display form of the Bluetooth control 611, such as adding a shadow to the Bluetooth control 611.

[0363] Not limited to Figure 9B On the interface shown, the user can also input a downward sliding gesture on other interfaces to trigger the electronic device 100 to display window 610.

[0364] Not limited to Figure 9B and Figure 9C The user operation shown is the user operation on the Bluetooth control 611 in the window 610. In the embodiment of the present application, the user operation of turning on the Bluetooth function can also be implemented in other forms, which is not limited by the embodiment of the present application.

[0365] For example, the electronic device 100 can also display a settings interface provided by a settings application, which may include controls provided to the user for turning on / off the Bluetooth function of the electronic device 100. The user can turn on the Bluetooth function of the electronic device 100 by inputting user operations on the control.

[0366] Upon detecting a user operation to enable the Bluetooth function, the electronic device 100 discovers other Bluetooth-enabled electronic devices near the electronic device 100 via Bluetooth. For example, the electronic device 100 can discover and connect to nearby audio playback devices 200 and other electronic devices via Bluetooth.

[0367] S902: The electronic device 100 determines whether it is the first time to establish a connection with the audio playback device 200. If it is the first time to establish a connection between the electronic device 100 and the audio playback device 200, the electronic device 100 executes S903; otherwise, the electronic device 100 executes S907.

[0368] S903 : The audio playback device 200 sends the category identifiers whose number of decoder identifiers is greater than or equal to 1 to the electronic device 100 .

[0369] Before the audio playback device 200 sends the category identifiers containing one or more decoder identifiers to the electronic device 100, the audio playback device 200 classifies all decoders into multiple categories according to the codec classification standard. How the audio playback device 200 classifies all decoders into multiple categories according to the codec classification standard has been described in detail in the embodiment shown in S702 and will not be further described herein.

[0370] Exemplarily, the audio playback device 200 sends the identifier of the first category and the identifier of the second category to the electronic device 100, and the electronic device 100 receives the identifier of the first category and the identifier of the second category sent by the audio playback device 200; or, the audio playback device 200 sends the identifier of the first category to the electronic device 100, and the electronic device 100 receives the identifier of the first category sent by the audio playback device 200. The decoders in the first category include at least the first decoder, and the decoders in the second category include at least the second decoder.

[0371] Before the audio playback device 200 sends a category identifier with a number of decoder identifiers greater than or equal to 1 to the electronic device 100, the audio playback device 200 classifies the first encoder into a first category based on parameter information of the first encoder and a codec classification standard, and classifies the second encoder into a second category based on parameter information of the second encoder and a codec classification standard; wherein the parameter information of the first encoder and the parameter information of the second encoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; the audio playback device is further configured to: classify the first decoder into the first category based on parameter information of the first decoder and the codec classification standard, and classify the second decoder into the second category based on parameter information of the second decoder and the codec classification standard; wherein the parameter information of the first decoder and the parameter information of the second decoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; wherein the codec classification standard includes a mapping relationship between codec categories and codec parameter information. It should be noted that the parameter information of the first encoder, the parameter information of the second encoder, the parameter information of the first decoder, and the parameter information of the second decoder are all the same.

[0372] S904: The electronic device 100 identifies a common category from the categories whose number of encoder identifiers is greater than or equal to 1 and the categories whose number of decoder identifiers is greater than or equal to 1.

[0373] In response to the category identification in which the number of decoder identifications sent by the audio playback device 200 is greater than or equal to 1, the electronic device 100 receives the category identification in which the number of decoder identifications sent by the audio playback device 200 is greater than or equal to 1.

[0374] Exemplarily, the electronic device 100 determines that the common categories of the electronic device and the audio playback device are the first category and the second category.

[0375] Or the electronic device does not receive the second category identifier sent by the audio playback device; or the number of encoders classified into the second category by the electronic device is 0, and the electronic device 100 determines that the common category of the electronic device and the audio playback device is the first category.

[0376] The shared category means that the electronic device 100 can transmit audio data with the audio playback device 200 through the codec under this category.

[0377] It is understandable that, before establishing the connection, the electronic device 100 has divided all encoders in the electronic device 100 into multiple categories according to the codec classification standard, and identified a category with a number of encoder identifiers greater than or equal to 1.

[0378] In some embodiments, after establishing a connection, the electronic device 100 may also classify all encoders in the electronic device 100 into multiple categories based on a preset codec classification standard. The audio playback device 200 may also classify all decoders in the audio playback device 200 into multiple categories based on a preset codec classification standard after establishing a connection, and identify a category with a decoder identifier greater than or equal to 1. This is not intended to be limiting.

[0379] In some embodiments, after the electronic device 100 establishes a connection with the audio playback device 200, the audio playback device 200 sends all decoder identifiers in the audio playback device 200 and the values ​​of one or more parameters corresponding to each decoder to the electronic device 100. The electronic device 100 classifies all encoders in the electronic device 100 and all decoders in the audio playback device 200 into multiple categories according to the codec classification standard, and identifies the categories with greater than or equal to 1 encoder identifiers and the categories with greater than or equal to 1 decoder identifiers. This is not a limitation.

[0380] The codec classification standard can be obtained based on one or a combination of two or more parameters such as sampling rate, quantization bit depth, bit rate, number of channels, audio stream format, etc.

[0381] Exemplarily, when the codec classification standard is obtained according to sampling rate, quantization bit depth, bit rate, number of channels, and audio stream format, the codec classification standard can be divided into two categories.

[0382] Specifically, when the value of the sampling rate of the codec is greater than or equal to the first sampling rate (target sampling rate), the value of the codec bit rate is greater than or equal to the first bit rate (target bit rate), the value of the quantization bit depth of the codec is greater than or equal to the first quantization bit depth (target quantization bit depth), the value of the number of channels of the codec is greater than or equal to the first number of channels (target number of channels), and the audio stream format is PCM (target audio stream format), the codec is classified into category one; when the value of the sampling rate of the codec is less than the first sampling rate, the value of the codec bit rate is less than the first bit rate, the value of the quantization bit depth of the codec is less than the first quantization bit depth, and the value of the number of channels of the codec is greater than or equal to the first number of channels, and the audio stream format is PCM, the codec is classified into category two.

[0383] For example, the first sampling rate is 48khz, the first bit rate is 600kps, the first quantization bit depth is 24 bits, the first number of channels is 2, and the audio stream format is PCM. Then the classification criteria for codecs in category one are: the sampling rate of the codec is greater than or equal to 48khz, the bit rate of the codec is greater than or equal to 600kps, the quantization bit depth of the codec is greater than or equal to 24 bits, the number of channels of the codec is greater than or equal to 2 channels, and the audio stream format is PCM. The classification criteria for codecs in category two are: the sampling rate of the codec is less than 48khz, the bit rate of the codec is less than or equal to 600kps, the quantization bit depth of the codec is less than 24 bits, the number of channels of the codec is greater than or equal to 2 channels, and the audio stream format is PCM. Codecs classified as category one can be called high-definition sound quality codecs, and codecs classified as category two can be called standard sound quality codecs.

[0384] The audio playback device 200 includes a decoder 1, a decoder 2, and a decoder 3, wherein the decoder 1 belongs to category 1, and the decoder 2 and the decoder 3 belong to category 2.

[0385] The electronic device 100 includes an encoder 1, an encoder 2, and an encoder 3, wherein the encoder 1 belongs to category 1, and the encoder 2 and the encoder 3 belong to category 2.

[0386] The categories shared by the electronic device 100 and the audio playback device 200 include category one and category two.

[0387] How the electronic device 100 classifies the encoder into the corresponding category of the codec classification standard, and how the audio playback device 200 classifies the decoder into the corresponding category of the codec classification standard, the above Figure 7 The illustrated embodiments have been described in detail and will not be described in detail herein.

[0388] S905: The electronic device 100 identifies a default encoder identifier and a default decoder identifier in each common category.

[0389] After the electronic device 100 identifies the common category between the electronic device 100 and the audio playback device 200 , the electronic device 100 and the audio playback device 200 may transmit audio data using codecs classified in the common category.

[0390] If the number of encoders and / or decoders in a shared category is greater than one, the electronic device 100 needs to identify a default encoder identifier and a default decoder identifier for each shared category. The electronic device 100 and the audio playback device 200 then use the default encoder and decoder for each shared category to transmit audio data.

[0391] For any common category, if the number of encoder identifiers is 1 or the number of decoder identifiers is 1, the electronic device 100 determines that the encoder under this category is a default encoder, or the identifier of the decoder under this category is a default decoder.

[0392] Exemplarily, when the shared category is category one (first category), the codec classified into category one is a high-definition audio codec. The encoder in category one includes encoder one (first encoder), and the decoder in category one includes decoder one (first decoder). Because category one only includes one encoder and one decoder, the electronic device 100 confirms that encoder one and decoder one are the default encoder and decoder for the category one. When the electronic device 100 confirms that the codec in category one is used for transmitting audio data, the electronic device 100 sends the adopted category identifier (category one identifier) ​​to the audio playback device 200.

[0393] The electronic device 100 uses encoder 1 in category 1 to encode the audio data into first encoded audio data and sends it to the audio playback device 200. The audio playback device 200 uses decoder 1 in category 1 to decode the compressed audio data into (first playback audio data) and plays the first playback audio data.

[0394] Exemplarily, when the shared category is category two, the codec classified into category two is a basic audio codec. The encoder in category two includes encoder two (second encoder), and the decoder in category two includes decoder two (second decoder). Because category two only includes one encoder and one decoder, the electronic device 100 confirms that encoder two and decoder two are the default encoder and the default decoder under category two. When the electronic device 100 confirms that the codec in category two is used for the transmission of audio data, the electronic device 100 sends the adopted category identifier (category two identifier) ​​to the audio playback device 200.

[0395] The electronic device 100 uses the encoder 2 in category 2 to package the audio data and send it to the audio playback device 200. The audio playback device 200 uses the decoder 2 in category 2 to decompress the compressed audio data and play the audio data.

[0396] For any common category, if the number of encoder identifiers is greater than 1 or the number of decoder identifiers is greater than 1, the electronic device 100 needs to confirm that one of the multiple encoders under the category is used as the default encoder, or one of the multiple decoders under the category is used as the default decoder.

[0397] Exemplarily, when the shared category is category one, the codec classified into category one is a high-definition audio codec. The encoders in category one include encoder one (first encoder) and encoder three (third encoder), and the decoders in category one include decoder one (first decoder) and decoder three (third decoder). Because category one includes multiple encoders and multiple decoders, the electronic device 100 identifies a default encoder and a default decoder in the category below. The electronic device 100 can identify a default encoder and a default decoder in the category below from multiple encoders and multiple decoders according to preset rules. The preset rules can be priority rules, low power rules, high efficiency rules, and the like. Specifically, the method by which the electronic device 100 identifies a default encoder (first encoder) and a default decoder (first decoder) in the category below from multiple encoders and multiple decoders according to priority rules, low power rules, and high efficiency rules, please refer to the embodiment shown in S808, which will not be repeated in this application. After the electronic device 100 confirms that the encoder 1 and the decoder 1 are a default encoder and a default decoder of the category, the electronic device 100 sends the default decoder identifier and / or encoder identifier of the category to the audio playback device 200 .

[0398] Afterwards, when the electronic device 100 determines that a codec in category one is used to transmit the audio data, the electronic device 100 sends the adopted category identifier (category one identifier) ​​to the audio playback device 200 .

[0399] The electronic device 100 uses encoder 1 in category 1 to encode the audio data into first encoded audio data and sends it to the audio playback device 200. The audio playback device 200 uses decoder 1 in category 1 to decode the first encoded audio data into first playback audio data and plays the first playback audio data.

[0400] Exemplarily, when the common categories are category one and category two, the codec classified into category one is a high-definition audio codec, and the codec classified into category two is a basic audio codec. The encoder in category one includes encoder one, the decoder in category one includes decoder one, the encoder in category two includes encoder two, and the decoder in category two includes decoder two. Because category one includes one encoder and one decoder, and category two includes only one decoder and one encoder, the electronic device 100 confirms that encoder one and decoder one are the default encoder and default decoder under category one, and encoder two and decoder two are the default encoder and default decoder under category two. When the electronic device 100 can use the codec in category one or category two to transmit audio data, the electronic device 100 sends the adopted category identifier (category one identifier or category two identifier) ​​to the audio playback device 200.

[0401] Alternatively, when the shared categories are Category 1 and Category 2, the codec classified into Category 1 is a high-definition audio codec, and the codec classified into Category 2 is a basic audio codec. Encoders in Category 1 include Encoder 1 and Encoder 3, decoders in Category 1 include Decoder 1 and Decoder 3, encoders in Category 2 include Encoder 2 and Encoder 4, and decoders in Category 2 include Decoder 5 and Decoder 4. Because Category 1 includes multiple encoders and decoders, Category 2 also includes multiple encoders and decoders. The electronic device 100 can identify a default encoder and a default decoder for Category 1 and Category 2 from among the multiple encoders and decoders based on preset rules. The preset rules can include priority rules, low power rules, high efficiency rules, and so on. Specifically, the method by which the electronic device 100 identifies a default encoder and a default decoder for Category 1 and Category 2 from among the multiple encoders and decoders based on priority rules, low power rules, and high efficiency rules is described in the embodiment shown in S808, and this application will not elaborate further here. When the electronic device 100 confirms that encoder 1 and decoder 1 are the default encoder and decoder of category 1, and encoder 2 and decoder 2 are the default encoder and decoder of category 2, the electronic device 100 sends the default decoder identifier and / or encoder identifier of category 1 and the default decoder identifier and / or encoder identifier of category 2 to the audio playback device 200.

[0402] The electronic device 100 can use the default codec in category 1 or category 2 to transmit audio data. For example, the electronic device 100 can use the codec in category 1 to transmit audio data. The codec in category 1 is a high-definition audio codec. When network conditions change or the audio content being played changes, the electronic device 100 can switch the codec in category 1 to a codec in category 2. The codec in category 2 is then used to transmit audio data.

[0403] After the electronic device 100 identifies the common category between the electronic device 100 and the audio playback device 200, in an optional implementation, the electronic device 100 identifies the default encoder identifier and the default decoder identifier in each common category. The method for the electronic device 100 to identify the default encoder identifier and the default decoder identifier in each common category between the electronic device 100 and the audio playback device 200 is as follows: Figure 7 The embodiments shown have been described in detail and will not be described again in detail in this application.

[0404] In another optional implementation, the electronic device 100 only needs to identify the default encoder identifier in the category shared by the electronic device 100 and the audio playback device 200. Afterwards, the electronic device 100 sends the shared category to the audio playback device 200, and the audio playback device 200 identifies the default decoder identifier in the shared category.

[0405] In some embodiments, the preset codec classification standard may be updated at regular intervals (e.g., once a month). Therefore, when the codec classification standard is updated periodically, the electronic device 100 also needs to periodically (e.g., once a month) classify encoders into multiple categories, and the audio playback device 200 also needs to periodically (e.g., once a month) classify decoders into multiple categories.

[0406] In an optional implementation, the electronic device 100 and the audio playback device 200 may classify the codecs into multiple categories at appropriate times based on the collected user behavior habits.

[0407] For example, during the time period "24:00-7:00", the electronic device 100 and the audio playback device 200 can classify codecs into multiple categories during the time period "24:00-7:00". Because during the time period "24:00-7:00", the user is resting at home. At this time, when the codecs are classified during this time period, it will not affect the user's experience of using the device.

[0408] S906 : The electronic device 100 sends the shared category identifiers and a default decoder identifier in each shared category to the audio playback device 200 .

[0409] After the electronic device 100 confirms the shared category between the electronic device 100 and the audio playback device 200, the electronic device 100 sends the shared category identifier (the first category identifier and the second category identifier, or the first category identifier) ​​and a default decoder identifier in each shared category to the audio playback device 200.

[0410] The audio playback device 200 receives the shared category identifiers of the electronic device 100 and the audio playback device 200, as well as a default decoder identifier for each shared category, from the electronic device 100. Thereafter, the electronic device 100 and the audio playback device 200 transmit audio data using the shared category.

[0411] In some embodiments, if the audio playback device 200 classifies all decoders in the audio playback device 200 into multiple categories according to a codec classification standard, the electronic device 100 sends each category identifier and the corresponding decoder identifier under each category to the electronic device 100 before the electronic device 100 and the audio playback device 200 negotiate the shared categories. Then, after the electronic device 100 confirms the shared categories of the electronic device 100, the electronic device 100 only needs to send the shared categories between the electronic device 100 and the audio playback device 200 to the audio playback device 200.

[0412] After the electronic device 100 identifies the common category between the electronic device 100 and the audio playback device 200, when the audio playback device 200 identifies the default decoder identifier in the common category between the electronic device 100 and the audio playback device 200, the electronic device 100 only needs to send the common category identifier between the electronic device 100 and the audio playback device 200 to the audio playback device 200.

[0413] In some embodiments, when the electronic device 100 negotiates a shared category, the audio playback device 200 sends all decoder identifiers in the audio playback device 200 and the numerical values ​​of one or more parameters corresponding to each decoder to the electronic device 100, and the electronic device 100 divides all encoders in the electronic device 100 and all decoders in the audio playback device 200 into multiple categories according to the codec classification standard. Afterwards, the electronic device 100 confirms the shared category of the electronic device 100 and the audio playback device 200. In this case, in addition to sending the shared category of the electronic device 100 and the audio playback device 200 to the audio playback device 200, the electronic device 100 also needs to send the decoder identifier under the shared category of the electronic device 100 and the audio playback device 200 to the audio playback device 200.

[0414] Furthermore, after the electronic device 100 confirms the shared category between the electronic device 100 and the audio playback device 200, the electronic device 100 may confirm the default decoder identifier in the shared category between the electronic device 100 and the audio playback device 200. When the electronic device 100 confirms the default decoder identifier in the shared category between the electronic device 100 and the audio playback device 200, the electronic device 100 sends the shared category identifier to the audio playback device 200 and also sends the default decoder identifier in the shared category between the electronic device 100 and the audio playback device 200 to the audio playback device 200.

[0415] Alternatively, after the electronic device 100 identifies the shared category between the electronic device 100 and the audio playback device 200, and when the audio playback device 200 identifies the default decoder identifier in the shared category between the electronic device 100 and the audio playback device 200, the electronic device 100 sends the shared category between the electronic device 100 and the audio playback device 200 to the audio playback device 200, and also sends the decoder identifier under the shared category between the electronic device 100 and the audio playback device 200 to the audio playback device 200.

[0416] S907 : The electronic device 100 selects a default codec in the first category from the common categories to transmit audio data.

[0417] The electronic device 100 obtains first parameter information of the audio data, and when the first parameter information of the audio data meets the first condition, encodes the audio data into first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device.

[0418] Specifically, the electronic device 100 can select a default codec in a category (for example, the first category) from the categories shared by the electronic device 100 and the audio playback device 200 based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is turned on, the network conditions of the channel, the audio stream format, etc. to transmit audio data. The default encoder in the first category is the first encoder, and the default decoder in the first category is the first decoder. This part of the content has been described in detail in the aforementioned embodiment and will not be repeated in this application.

[0419] Exemplarily, the electronic device 100 determines the first parameter information as follows based on the application type, the playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is enabled, the network conditions of the channel, etc.: the sampling rate is the first sampling rate, the quantization bit depth is the first quantization bit depth, the bit rate is the first bit rate, and the number of channels is the first number of channels. The electronic device 100 selects the default codec in the category including the first sampling rate, the first quantization bit depth, the first bit rate, the first number of channels, and the PCM audio stream format from the common categories for audio data transmission.

[0420] When the electronic device 100 identifies two or more categories from the categories shared by the electronic device 100 and the audio playback device 200 based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is turned on, the network conditions of the channel, the audio stream format, etc., the electronic device 100 can select a category with the highest priority from the two or more categories as the first category, and use the default codec in the category with the highest priority to transmit audio data. It is understandable that the higher the sampling rate, the higher the bit rate, and the higher the quantization depth specified in the codec classification standard, the better the sound quality of the codec classified into this category. The better the sound quality of the codec, the higher the priority of the category to which the codec belongs.

[0421] Exemplarily, the categories shared by the electronic device 100 and the audio playback device 20 include category one and category two. If the categories selected by the electronic device 100 based on the application type, playback audio characteristics (sampling rate, quantization bit depth, number of channels), whether the electronic device audio rendering capability is turned on, the network conditions of the channel, the audio stream format, etc. include category one and category two. Since the codec classified into category one is a high-definition sound quality codec, the codec classified into category two is a standard sound quality codec. Category one has a higher priority than category two. Therefore, the electronic device 100 will give priority to the default codec in category one for transmitting audio data.

[0422] S908 : The electronic device 100 sends the first category identifier to the audio playback device 200 .

[0423] The audio playback device 200 receives the first category identifier sent by the electronic device 100 , and the electronic device 100 and the audio playback device 200 use the default codec in the first category identifier to transmit audio data.

[0424] S909: The electronic device 100 obtains audio data, and encodes the audio data using an encoder corresponding to the first encoder identifier to obtain encoded audio data.

[0425] The first encoder identifier is the default encoder identifier in the first category.

[0426] S910 : The electronic device 100 sends the encoded audio data (first encoded audio data) to the audio playback device 200 .

[0427] Specifically, the electronic device 100 can obtain the currently played audio data through recording or other methods, and then compress the obtained audio data and send it to the audio playback device 200 through the communication connection between the electronic device 100 and the audio playback device 200. Taking the electronic device 100 and the audio playback device 200 sharing multimedia content based on miracast as an example, the electronic device 100 collects the audio played by the electronic device 100 and compresses the audio using the advanced audio coding (AAC) algorithm; then the compressed audio data is encapsulated into a transport stream (TS), and the TS stream is encoded according to the real-time transport protocol (RTP) and the encoded data is sent to the audio playback device 200 via a Bluetooth channel connection.

[0428] S911 : The audio playback device 200 receives the encoded audio data sent by the electronic device 100 , and decodes the encoded audio data using a decoder corresponding to the first decoder identifier to obtain audio data (first playback audio data).

[0429] The first decoder identifier is a default decoder identifier in the first category.

[0430] The audio playback device 200 decodes the encoded audio data using the decoder corresponding to the first decoder identifier to obtain unencoded audio data, and plays the audio data.

[0431] S912: The electronic device 100 switches the first category to the second category.

[0432] When the sampling rate and / or bit rate and / or quantization bit depth and / or number of channels of the audio data of the electronic device 100 changes, the electronic device 100 will reselect a codec in another category (i.e., the second category) for audio data transmission. The electronic device 100 notifies the audio playback device 200 of the identifier of the category. The electronic device 100 and the audio playback device 200 use the codec in the second category to transmit audio data. This part has been described in detail in the previous embodiment and will not be repeated here in this application.

[0433] When the sampling rate and / or bit rate and / or quantization bit depth and / or number of channels of the audio data played by the electronic device changes due to reasons such as user selection, application type change, audio content change, activation of the electronic device's audio rendering capability, and deterioration of the channel's network conditions, the electronic device 100 switches the first category to the second category.

[0434] Exemplarily, when the electronic device 100 receives a user selection of the high-quality audio mode, the electronic device 100 switches the first codec category to the second category, wherein the audio quality of the codec in the second category is higher than the audio quality of the codec in the first category. The sampling rate, bit rate, and quantization bit depth of the codec in the second category are all greater than the sampling rate, bit rate, and quantization bit depth of the codec in the first category.

[0435] like Figure 10A As shown, the electronic device 100 receives the user's operation of clicking more controls 608, and in response to the user's operation, the electronic device 100 will display the following Figure 10B The prompt box 900 is shown. The prompt box 900 includes a high-quality sound mode control 901, a stable transmission mode control 902, and an audio rendering mode start control 903. When the user wants the audio data played by the electronic device 100 to have better sound quality, the high-quality sound mode control 901 in the prompt box 900 can receive a click operation from the user. In response to the user's click operation, the electronic device 100 switches the first category to the second category, where the audio quality of the codec in the second category is higher than the audio quality of the codec classification in the first category.

[0436] For example, when the electronic device 100 receives a user operation to enable audio rendering capability, the electronic device 100 increases the sampling rate of the played audio data from the first sampling rate to the second sampling rate, the rendering unit of the electronic device 100 may increase the value of the quantization bit depth of the audio data from the first quantization bit depth to the second quantization bit depth, and the rendering unit of the electronic device 100 may increase the value of the number of channels of the audio data from the first number of channels to the second number of channels. The second sampling rate is greater than the first sampling rate, the second quantization bit depth is greater than the first quantization bit depth, and the second number of channels is greater than the first number of channels.

[0437] like Figure 10C As shown, when the user wants the electronic device 100 to turn on the audio rendering capability, the audio rendering mode turn-on control 903 in the prompt box 900 can receive the user's click operation. In response to the user's click operation, the electronic device 100 switches the first category to the second category, wherein the sampling rate, bit rate, quantization bit depth, and number of channels of the codec in the second category are all greater than the sampling rate, bit rate, quantization bit depth, and number of channels of the codec in the first category.

[0438] For example, when the network of the electronic device 100 is unstable, the electronic device 100 can receive a user operation to switch the current audio data transmission mode to a stable transmission mode. When the user chooses to turn on the stable transmission mode, the electronic device 100 switches from the first category to the second category, wherein the bit rate of the codec in the second category is lower than the bit rate of the codec in the first category. Alternatively, the electronic device 100 can automatically switch to the stable transmission mode. This application is not limited to this.

[0439] like Figure 10D As shown, when the user chooses to turn on the stable transmission mode, the stable transmission mode control 902 in the prompt box 900 can receive the user's click operation. In response to the user's click operation, the electronic device 100 switches the first category to the second category, wherein the bit rate of the codec in the second category is lower than the bit rate of the codec in the first category.

[0440] The electronic device 100 obtains second parameter information of the audio data. When the second parameter information of the audio data meets the second condition, the electronic device 100 switches the first category to the second category, encodes the audio data into second encoded audio data according to the second encoder in the second category, and sends the second encoded audio data to the audio playback device.

[0441] The electronic device 100 sends the identifier of the second category to the audio playing device 200 .

[0442] When the application type of the audio data played by the electronic device 100 is changed from application type one to application type two, or the audio data audio data one played by the electronic device 100 is switched to audio data two, or the audio rendering capability of the electronic device is turned on or turned on, so that the second parameter information is: the sampling rate of the audio data played by the electronic device 100 changes from the first sampling rate to the second sampling rate, then the electronic device 100 selects the default codec in the category shared by the electronic device 100 and the audio playback device 200, and the sampling rate includes the second sampling rate, the quantization bit depth includes the first quantization bit depth, the bit rate includes the first bit rate, the number of channels includes the first number of channels, and the audio stream format includes PCM to transmit the audio data.

[0443] Specific explanation of the first and second conditions in S907-S912:

[0444] The parameter type in the first parameter information, the parameter type in the parameter information of the first encoder, the parameter type in the parameter information of the first decoder, the parameter type in the second parameter information, the parameter type in the parameter information of the second encoder, and the parameter type in the parameter information of the second decoder are the same; the first parameter information satisfies the first condition and the second parameter information satisfies the second condition, specifically including: the sampling rate in the first parameter information is greater than or equal to the target sampling rate, and the sampling rate in the second parameter information is less than the target sampling rate; and / or, the bit rate in the first parameter information is greater than or equal to the target bit rate, and the bit rate in the second parameter information is less than the target bit rate; and / or, the quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth, and the quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or, the number of channels in the first parameter information is greater than or equal to the target number of channels, and the number of channels in the second parameter information is less than the target number of channels; and / or, the audio stream format in the first parameter information is the target audio stream format, and the audio stream format in the second parameter information is the target audio stream format.

[0445] S913 : The electronic device 100 sends the identifier of the second category to the audio playback device 200 .

[0446] The audio playback device 200 receives the second category identifier sent by the electronic device 100. The electronic device 100 and the audio playback device 200 transmit audio data using the default codec in the second category identifier.

[0447] Specifically, the electronic device 100 collects audio data, and the electronic device 100 will use the encoder corresponding to the second encoder identifier to encode the audio data to obtain encoded audio data (second encoded audio data). The electronic device 100 sends the encoded audio data to the audio playback device 200, and the audio playback device 200 will use the decoder corresponding to the second decoder identifier to decode the audio data to obtain unencoded audio data (second playback audio data). The audio playback device 200 will play the unencoded audio data (second playback audio data).

[0448] The second encoder identifier is a default encoder identifier in the second category; and the second decoder identifier is a default decoder identifier in the second category.

[0449] In order to avoid screen freeze when the electronic device 100 and the audio playback device 200 switch codecs, the audio data in the switching process between the electronic device 100 and the audio playback device 200 will be smoothly transitioned to improve the user experience.

[0450] When the time delays of the first encoder and the second encoder are the same, the electronic device encodes the first audio frame in the audio data into a first encoded audio frame through the first encoder and sends the first encoded audio frame to the audio playback device; encodes the first audio frame in the audio data into a second encoded audio frame through the second encoder and sends the second encoded audio frame to the audio playback device; encodes the second audio frame in the audio data into an Nth encoded audio frame through the second encoder and sends the Nth encoded audio frame to the audio playback device; the audio playback device decodes the first encoded audio frame into a first decoded audio frame through the first decoder, decodes the second encoded audio frame into a second decoded audio frame through the second decoder, and decodes the Nth encoded audio frame into an Nth playback audio frame through the second decoder; and smoothes the first decoded audio frame and the second decoded audio frame to obtain a first playback audio frame. The electronic device 100 first plays the first playback audio frame and then plays the Nth playback audio frame. In this way, when the latency of the first and second encoders is the same, the switch between the first and second encoders must be completed within a single frame. This frame is the first audio frame. The audio playback device smoothes the first audio frame before playing it, preventing stuttering during codec switching and achieving a smooth transition. The adjacent audio frame after the first audio frame, such as the second audio frame, does not require smoothing and is directly decoded and played by the second decoder.

[0451] The audio playback device obtains the first playback audio frame through the formula Pcm=wi*pcmA+(1-wi)*pcmB; wherein Pcm is the first playback audio frame, wi is the smoothing coefficient, wi i is greater than 0 and less than 1, pcmA is the first decoded audio frame, and pcmB is the second decoded audio frame.

[0452] When the time delay of the first encoder is different from that of the second encoder, the electronic device obtains D frames of audio data frames through the formula D = rounding ((max (total time delay of encoder one, total time delay of encoder two) + (frame length - total time delay of encoder one % frame length) + frame length - 1) / frame length); wherein D represents the total number of audio data frames during the switching process between the first encoder and the second encoder, max represents the maximum value operation, % represents the remainder operation, and frame length represents the duration of one frame of audio data; the first encoder encodes the first audio frame to the Dth audio frame in the audio data to obtain the third encoded audio frame to the D+2th encoded audio frame; the second encoder encodes the Dth audio frame in the audio data to obtain the D+3th encoded audio frame, and the second encoder encodes the audio frame to the D+4th encoded audio frame. The method further comprises encoding the D+1th audio frame in the audio data to obtain the Nth encoded audio frame; sending the third to D+2th encoded audio frames, the D+3th encoded audio frame, and the Nth encoded audio frame to an audio playback device; the audio playback device decodes the third to D+2th encoded audio frames into second to D+1th playback audio frames through a first decoder, and decodes the D+3th encoded audio frame into a third decoded audio frame through a second decoder; and plays the second to Dth playback audio frames; smoothing the D+1th playback audio frame and the third decoded audio frame to obtain a target playback audio frame, and playing the target playback audio frame; and decoding the Nth encoded audio frame into an Nth decoded audio frame through a second decoder, and playing the Nth decoded audio frame. Thus, when the time delays of the first encoder and the second encoder are different, the switching between the first encoder and the second encoder needs to be completed within multiple frames (D frames). In this way, during the switching between the first encoder and the second encoder, the time when the audio data encoded by the first encoder arrives at the audio playback device and is decoded is the same as the time when the audio data encoded by the second encoder arrives at the audio playback device and is decoded. If the codec switch needs to be completed within D frames, the audio playback device directly decodes and plays audio frames 1 to D-1. The audio playback device smoothes the Dth audio frame before playing it to prevent stuttering during codec switching and achieve a smooth transition. The adjacent audio frames after the Dth audio frame, such as the Nth audio frame, do not require smoothing and are directly decoded and played using the Nth decoder.

[0453] The audio playback device obtains the target playback audio frame through the formula Pcm=wi*pcmA+(1-wi)*pcmB; wherein Pcm is the target playback audio frame, wi is the smoothing coefficient, wi i is greater than 0 and less than 1, pcmA is the D+1th playback audio frame, and pcmB is the third decoded audio frame.

[0454] How the electronic device 100 and the audio playback device 200 smoothly transition the audio data during the switching process has been described in detail in the aforementioned embodiment and will not be repeated here.

[0455] S912-S913 can also be replaced by, when the second parameter information meets the second condition, encoding the audio data into third encoded audio data through the first encoder in the first category, and sending the third encoded audio data to the audio playback device; the audio playback device is further used to decode the third encoded audio data into third playback audio data through the first decoder in the first category. When the electronic device and the audio playback device only support one codec category (first category), in this case, when the parameter information of the audio data changes from the first parameter information to the second parameter information, and the second parameter information meets the second condition, the electronic device cannot switch the codec, and the electronic device still uses the default codec in the first category to transmit audio data to the audio playback device.

[0456] As described above, the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present application.< / canvas> < / video> < / videoview> < / imgview> < / textview>

Claims

1. A codec negotiation and switching system, characterized in that: The system includes an electronic device and an audio playback device, wherein: The audio playback device is used to: classifying the first decoder into a first category based on parameter information of the first decoder and a codec classification standard, and classifying the second decoder into a second category based on parameter information of the second decoder and the codec classification standard; sending the identifier of the first category and the identifier of the second category to the electronic device; The electronic device is used for: Classifying the first encoder into the first category based on parameter information of the first encoder and the codec classification standard, and classifying the second encoder into the second category based on parameter information of the second encoder and the codec classification standard; confirming, based on the first category identifier and the second category identifier sent by the audio playback device, that the common categories of the electronic device and the audio playback device are the first category and the second category; Sending the identifier of the first category and the identifier of the second category to the audio playback device; The electronic device is further used for: When the first parameter information of the audio data satisfies a first condition, encoding the audio data into first encoded audio data according to a first encoder in the first category, and sending the first encoded audio data to the audio playback device; wherein the first category is a codec category determined by the electronic device before acquiring the audio data to be shared by the electronic device and the audio playback device; sending the identifier of the first category to the audio playback device; The audio playback device is used for: receiving an identifier of the first category sent by the electronic device; decoding the first encoded audio data into first playback audio data by a first decoder in the first category; The electronic device is also used for: When the second parameter information of the audio data satisfies a second condition, encoding the audio data into second encoded audio data according to a second encoder in the second category, and sending the second encoded audio data to the audio playback device; wherein the second category is a codec category shared by the electronic device and the audio playback device, determined by the electronic device before acquiring the audio data; sending the identifier of the second category to the audio playback device; The audio playback device is further used for: receiving an identifier of the second category sent by the electronic device; decoding the second encoded audio data into second playback audio data by a second decoder in the second category; The first condition is different from the second condition, the first category is different from the second category, and the value range of the parameter information corresponding to the codec in the first category is different from the value range of the parameter information corresponding to the codec in the second category.

2. The system according to claim 1, wherein: The encoders in the first category include at least the first encoder, and the encoders in the second category include at least the second encoder.

3. The system according to claim 2, characterized in that The decoders in the first category include at least the first decoder, and the decoders in the second category include at least the second decoder.

4. The system according to claim 1, wherein: The encoders in the first category include only the first encoders, and the decoders in the first category include only the first decoders; After the electronic device determines that the common categories of the electronic device and the audio playback device are the first category and the second category, the electronic device is further configured to: When the first parameter information satisfies the first condition, encoding the audio data into first encoded audio data by the first encoder in the first category, and sending the first encoded audio data to the audio playback device; The audio playback device is further configured to decode the first encoded audio data into the first playback audio data by using the first decoder in the first category.

5. The system according to claim 1, wherein: The encoders in the first category further include a third encoder, and the decoders in the first category further include a third decoder; After the electronic device determines that the common categories of the electronic device and the audio playback device are the first category and the second category, the electronic device is further configured to: When the first parameter information satisfies the first condition, encoding the audio data into the first encoded audio data by the first encoder in the first category, and sending the first encoded audio data to the audio playback device; wherein the power consumption of the first encoder is lower than that of the third encoder, or the priority or power of the first encoder is higher than that of the third encoder; The audio playback device is further used to decode the first encoded audio data into the first playback audio data through the first decoder in the first category; wherein the power consumption of the first decoder is lower than that of the third decoder, or the priority or power of the first decoder is higher than that of the third decoder.

6. The system according to claim 1, wherein: When the electronic device and the audio playback device share only the first category of encoder categories, the electronic device is further configured to: When the second parameter information satisfies the second condition, encoding the audio data into third encoded audio data by the first encoder in the first category, and sending the third encoded audio data to the audio playback device; The audio playback device is further configured to decode the third encoded audio data into third playback audio data using the first decoder in the first category.

7. The system according to claim 6, characterized in that The encoder categories shared by the electronic device and the audio playback device only include the first category, including: The electronic device does not receive the identifier of the second category sent by the audio playback device, or the number of encoders classified by the electronic device into the second category is 0.

8. The system according to claim 6, wherein: The encoders in the first category include only the first encoders, and the decoders in the first category include only the first decoders; When the first parameter information satisfies the first condition, the electronic device is further configured to: encoding the audio data into first encoded audio data according to the first encoder in the first category, and sending the first encoded audio data to the audio playback device; The audio playback device is further configured to decode the first encoded audio data into the first playback audio data by using the first decoder in the first category.

9. The system according to claim 8, characterized in that The encoders in the first category further include a third encoder, and the decoders in the first category further include a third decoder; When the first parameter information satisfies the first condition, the electronic device is further configured to: encoding the audio data into first encoded audio data according to the first encoder in the first category, and sending the first encoded audio data to the audio playback device; wherein the first encoder has lower power consumption than the third encoder, or the first encoder has higher priority or power than the third encoder; The audio playback device is further used to decode the first encoded audio data into the first playback audio data through the first decoder in the first category; wherein the power consumption of the first decoder is lower than that of the third decoder, or the priority or power of the first decoder is higher than that of the third decoder.

10. The system according to any one of claims 1 to 9, characterized in that: The codecs in the first category are high-definition quality codecs, and the codecs in the second category are standard quality codecs; or The codecs in the first category are standard-quality codecs, and the codecs in the second category are high-definition-quality codecs.

11. The system according to claim 1, wherein: The parameter information of the first encoder and the parameter information of the second encoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; The parameter information of the first decoder and the parameter information of the second decoder include one or more of a sampling rate, a bit rate, a quantization bit depth, a number of channels, and an audio stream format; The codec classification standard includes a mapping relationship between codec categories and codec parameter information.

12. The system according to claim 11, wherein: The sampling rate of the codecs in the first category is greater than or equal to the target sampling rate, and the sampling rate of the codecs in the second category is less than the target sampling rate; and / or, The code rate of the codecs in the first category is greater than or equal to the target code rate, and the code rate of the codecs in the second category is less than the target code rate; and / or, The number of channels of the codecs in the first category is greater than or equal to the target number of channels, and the number of channels of the codecs in the second category is less than the target number of channels; and / or, The quantization bit depth of the codecs in the first category is greater than or equal to the target quantization bit depth, and the quantization bit depth of the codecs in the second category is less than the target quantization bit depth; and / or, The audio stream format of the codec in the first category is a target audio stream format, and the audio stream format of the codec in the second category is the target audio stream format.

13. The system according to claim 12, wherein: The parameter types in the first parameter information, the parameter types in the parameter information of the first encoder, the parameter types in the parameter information of the first decoder, the parameter types in the second parameter information, the parameter types in the parameter information of the second encoder, and the parameter types in the parameter information of the second decoder are the same; The first parameter information satisfies the first condition, and the second parameter information satisfies the second condition, specifically including: The sampling rate in the first parameter information is greater than or equal to the target sampling rate, and the sampling rate in the second parameter information is less than the target sampling rate; and / or, The bit rate in the first parameter information is greater than or equal to the target bit rate, and the bit rate in the second parameter information is less than the target bit rate; and / or, The quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth, and the quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or, The number of channels in the first parameter information is greater than or equal to the target number of channels, and the number of channels in the second parameter information is less than the target number of channels; and / or, The audio stream format in the first parameter information is the target audio stream format, and the audio stream format in the second parameter information is the target audio stream format.

14. The system according to claim 1, wherein: When the time delays of the first encoder and the second encoder are the same, the electronic device is further configured to: encoding a first audio frame in the audio data into a first encoded audio frame by the first encoder, and sending the first encoded audio frame to the audio playback device; encoding the first audio frame in the audio data into a second encoded audio frame by the second encoder, and sending the second encoded audio frame to the audio playback device; The audio playback device is further used for: Decoding the first encoded audio frame into a first decoded audio frame by the first decoder, and decoding the second encoded audio frame into a second decoded audio frame by the second decoder; Smoothing is performed on the first decoded audio frame and the second decoded audio frame to obtain a first played audio frame.

15. The system according to claim 1, wherein: When the time delays of the first encoder and the second encoder are different, the electronic device is further configured to: Obtain D frames of audio data using the formula D = round((max(total delay of encoder one, total delay of encoder two) + (frame length - total delay of encoder one % frame length) + frame length - 1) / frame length); where D represents the total number of audio data frames during the switching process between the first encoder and the second encoder, max represents a maximum value operation, % represents a modulo operation, and frame length represents the duration of one frame of audio data. Encode the first audio frame to the Dth audio frame in the audio data by the first encoder to obtain the third encoded audio frame to the D+2th encoded audio frame; encoding the Dth audio frame in the audio data by the second encoder to obtain a D+3th encoded audio frame; Sending the third encoded audio frame to the D+2th encoded audio frame and the D+3th encoded audio frame to the audio playback device; The audio playback device is further used for: Decoding the third to D+2 th encoded audio frames into second to D+1 th playback audio frames through the first decoder, and decoding the D+3 th encoded audio frame into a third decoded audio frame through the second decoder; Play the second playback audio frame to the Dth playback audio frame; Smoothing is performed on the D+1th playback audio frame and the third decoded audio frame to obtain a target playback audio frame.

16. The system according to claim 14, wherein: The audio playback device is further used for: The first playback audio frame is obtained by the formula Pcm= wi * pcmA + (1 - wi) * pcmB; wherein Pcm is the first playback audio frame, wi is a smoothing coefficient, wi is greater than 0 and less than 1, pcmA is the first decoded audio frame, and pcmB is the second decoded audio frame.

17. The system according to claim 15, wherein: The audio playback device is further used for: The target playback audio frame is obtained by the formula Pcm = wi * pcmA + (1 - wi) * pcmB; wherein Pcm is the target playback audio frame, wi is a smoothing coefficient, wi is greater than 0 and less than 1, pcmA is the D+1th playback audio frame, and pcmB is the third decoded audio frame.

18. A codec negotiation and switching method, characterized in that: The method comprises: The electronic device receives a first category and a second category sent by an audio playback device, where the first category and the second category are sent after the audio playback device classifies the first decoder into the first category based on parameter information of the first decoder and a codec classification standard, and classifies the second decoder into the second category based on parameter information of the second decoder and the codec classification standard; The electronic device classifies the first encoder into the first category based on parameter information of the first encoder and the codec classification standard, and classifies the second encoder into the second category based on parameter information of the second encoder and the codec classification standard; The electronic device determines, based on the first category identifier and the second category identifier sent by the audio playback device, that the common categories of the electronic device and the audio playback device are the first category and the second category; The electronic device sends the identifier of the first category and the identifier of the second category to the audio playback device; When the first parameter information of the audio data satisfies a first condition, the electronic device encodes the audio data into first encoded audio data according to a first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein the second category is a codec category shared by the electronic device and the audio playback device, determined by the electronic device before acquiring the audio data; When the second parameter information of the audio data meets the second condition, the electronic device encodes the audio data into second encoded audio data according to the second encoder in the second category, and sends the second encoded audio data to the audio playback device; wherein, the second category is the codec category shared by the electronic device and the audio playback device, determined by the electronic device before obtaining the audio data; wherein, the second category is the codec category shared by the electronic device and the audio playback device, determined by the electronic device before obtaining the audio data, the first condition is different from the second condition, the first category is different from the second category, and the value range of the parameter information corresponding to the codec in the first category is different from the value range of the parameter information corresponding to the codec in the second category.

19. The method according to claim 18, characterized in that The encoders in the first category include at least the first encoder, and the encoders in the second category include at least the second encoder.

20. The method according to claim 19, characterized in that The decoders in the first category include at least the first decoder, and the decoders in the second category include at least the second decoder.

21. The method according to claim 18, wherein The encoders in the first category include only the first encoder; after the electronic device determines that the electronic device and the audio playback device share the first category and the second category, the method further includes: When the first parameter information satisfies the first condition, the electronic device encodes the audio data into the first encoded audio data by using the first encoder in the first category, and sends the first encoded audio data to the audio playback device.

22. The method according to claim 21, characterized in that The encoder in the first category further includes a third encoder; after the electronic device determines that the electronic device and the audio playback device share the first category and the second category, the method further includes: When the first parameter information satisfies the first condition, the electronic device encodes the audio data into first encoded audio data through a first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein the power consumption of the first encoder is lower than that of the third encoder, or the priority or power of the first encoder is higher than that of the third encoder.

23. The method according to claim 18, wherein When the electronic device and the audio playback device share only the first category of encoder categories, the method further includes: When the second parameter information satisfies the second condition, the electronic device encodes the audio data into third encoded audio data by using the first encoder in the first category, and sends the third encoded audio data to the audio playback device.

24. The method according to claim 23, wherein The encoder categories shared by the electronic device and the audio playback device only include the first category, including: the electronic device does not receive the identifier of the second category sent by the audio playback device; or the number of encoders classified into the second category by the electronic device is 0.

25. The method according to claim 23, characterized in that The encoders in the first category include only the first encoders, and the decoders in the first category include only the first decoders; When the first parameter information satisfies the first condition, the electronic device encodes the audio data into the first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device.

26. The method according to claim 23, wherein The encoders in the first category further include a third encoder, and the decoders in the first category further include a third decoder; When the first parameter information satisfies the first condition, the electronic device encodes the audio data into the first encoded audio data according to the first encoder in the first category, and sends the first encoded audio data to the audio playback device; wherein the power consumption of the first encoder is lower than that of the third encoder, or the priority or power of the first encoder is higher than that of the third encoder.

27. The method according to any one of claims 19 to 26, characterized in that The codecs in the first category are high-definition quality codecs, and the codecs in the second category are standard quality codecs; or The codecs in the first category are standard-quality codecs, and the codecs in the second category are high-definition-quality codecs.

28. The method according to claim 18, wherein The parameter information of the first encoder and the parameter information of the second encoder include one or more of sampling rate, bit rate, quantization bit depth, number of channels and audio stream format; the codec classification standard includes a mapping relationship between codec category and codec parameter information.

29. The method according to claim 28, characterized in that The sampling rate of the codecs in the first category is greater than or equal to the target sampling rate, and the sampling rate of the codecs in the second category is less than the target sampling rate; and / or, The code rate of the codecs in the first category is greater than or equal to the target code rate, and the code rate of the codecs in the second category is less than the target code rate; and / or, The number of channels of the codecs in the first category is greater than or equal to the target number of channels, and the number of channels of the codecs in the second category is less than the target number of channels; and / or, The quantization bit depth of the codecs in the first category is greater than or equal to the target quantization bit depth, and the quantization bit depth of the codecs in the second category is less than the target quantization bit depth; and / or, The audio stream format of the codec in the first category is a target audio stream format, and the audio stream format of the codec in the second category is the target audio stream format.

30. The method according to claim 29, wherein The parameter types in the first parameter information, the parameter types in the parameter information of the first encoder, the parameter types in the parameter information of the first decoder, the parameter types in the second parameter information, the parameter types in the parameter information of the second encoder, and the parameter types in the parameter information of the second decoder are the same; The first parameter information satisfies the first condition, and the second parameter information satisfies the second condition, specifically including: The sampling rate in the first parameter information is greater than or equal to the target sampling rate, and the sampling rate in the second parameter information is less than the target sampling rate; and / or, The bit rate in the first parameter information is greater than or equal to the target bit rate, and the bit rate in the second parameter information is less than the target bit rate; and / or, The quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth, and the quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or, The number of channels in the first parameter information is greater than or equal to the target number of channels, and the number of channels in the second parameter information is less than the target number of channels; and / or, The audio stream format in the first parameter information is the target audio stream format, and the audio stream format in the second parameter information is the target audio stream format.

31. An electronic device, characterized in that: The electronic device comprises one or more processors, one or more memories, and one or more encoders; the one or more memories, the one or more encoders are coupled to the one or more processors, the one or more memories are used to store computer program code, the computer program code includes computer instructions, and the one or more processors call the computer instructions to enable the electronic device to execute the method according to any one of claims 18 to 30.

32. A computer-readable storage medium, characterized in that The computer-readable storage medium stores computer-executable instructions, which are used to execute the method according to any one of claims 18 to 30 when called by the computer.

33. A computer program product comprising instructions, characterized in that When the computer program product is run on a computer, the computer is caused to perform the method according to any one of claims 18 to 30.

Citation Information

Patent Citations

  • Method and apparatus for smooth stream switching in MPEG / 3GPP-DASH

    CN104509119A

  • Audio Communication Method And Device

    US20070223660A1