Codec Negotiation and Switching Methods
By categorizing codecs and selecting common categories, the method addresses the issue of audio interruptions during codec switching, providing a seamless audio experience.
Patent Information
- Application Number
- JP2023564200
- Authority / Receiving Office
- JP · JP
- Patent Type
- Patents
- Current Assignee / Owner
- Priority Date
- 2021-04-20
- Filing Date
- 2022-03-29
- Publication Date
- 2025-05-22
- Estimated Expiration
- 2042-03-29
AI Technical Summary
Existing audio processing technologies face challenges in seamlessly switching codecs without interrupting audio data transmission, leading to choppy or interrupted audio experiences.
A method where an electronic device classifies codecs into categories and determines common categories supported by both the device and the audio playback device, allowing direct selection of a codec category without renegotiation when switching encoders.
This approach prevents audio data interruptions during codec switching, enhancing user experience by ensuring continuous and smooth audio playback.
Smart Images

Figure 0007681720000008 
Figure 0007681720000009 
Figure 0007681720000010
Abstract
Description
[Technical field]
[0001] This application claims priority to Chinese Patent Application No. 202110423987.8, entitled “Codec Negotiation and Switching Method,” filed with the China State Intellectual Property Office on April 20, 2021, the entire contents of which are incorporated herein by reference.
[0002] The present application relates to the field of audio processing technology, and in particular to codec negotiation and switching methods. [Background technology]
[0003] As users have increasing demands for audio experience, audio content is increasingly enhanced to support high-definition audio quality, multi-channel, 3D Audio, and other features, and corresponding encoding and decoding technologies are emerging, and wireless audio devices typically include multiple audio coder-decoders (Codecs).
[0004] Each time the electronic device establishes a connection to the audio playback device, the electronic device and the audio playback device negotiate with each other to obtain the codec types supported by both the electronic device and the audio playback device. The electronic device then processes the audio data based on the codec types supported by both the electronic device and the audio playback device. The electronic device then sends the encoded audio data to the audio playback device. The audio playback device receives the encoded audio data, decodes the encoded audio data using a corresponding decoder, and plays the decoded audio data.
[0005] When the quality of the network of the electronic device is degraded or the user selects a higher sound quality, the electronic device needs to switch the encoder. In this case, the electronic device needs to renegotiate with the audio playback device regarding the codec type. In the process of the electronic device renegotiating with the audio playback device regarding the codec type, the electronic device suspends sending audio data to the audio playback device. As a result, the audio data is interrupted or choppy, which affects the user experience. Therefore, a method that enables the electronic device and the audio playback device to quickly switch codecs and avoid interruption of the audio data during switching is an issue that needs to be urgently addressed. Summary of the Invention [Means for solving the problem]
[0006] This application provides a codec negotiation and switching method. When an electronic device needs to switch encoders, the electronic device does not need to renegotiate with an audio playback device on codec type to transmit audio data, but directly selects a codec category from the codec categories supported by both the electronic device and the audio playback device and previously determined by negotiation. This solves the problem that audio data is interrupted and choppy during codec switching performed by the electronic device and the audio playback device, and improves user experience.
[0007] According to a first aspect, the present application provides a codec negotiation and switching system. The system includes an electronic device and an audio playback device. The electronic device is configured to encode the audio data into first encoded audio data based on a first encoder of a first category when first parameter information of the audio data satisfies a first condition, and transmit the first encoded audio data to the audio playback device, the first category being a common codec category supported by the electronic device and the audio playback device, the common codec category being determined by the electronic device before acquiring the audio data, and transmit an identifier of the first category to the audio playback device. The audio playback device is configured to receive the identifier of the first category transmitted by the electronic device, and decode the first encoded audio data into first reproduced audio data using a first decoder of the first category. The electronic device is further configured to encode the audio data into second encoded audio data based on a second encoder of a second category when the second parameter information of the audio data satisfies a second condition, the second category being a common codec category supported by the electronic device and the audio playback device, the common codec category being determined by the electronic device before acquiring the audio data, and to send an identifier of the second category to the audio playback device. The audio playback device is further configured to receive the identifier of the second category sent by the electronic device and decode the second encoded audio data into second reproduced audio data using a second decoder of the second category, wherein the first condition is different from the second condition and the first category is different from the second category.
[0008] In the system of the first aspect, before transmitting audio data, the electronic device and the audio playback device classify codecs into a plurality of categories and determine a common codec category (e.g., a first category and a second category) supported by the electronic device and the audio playback device. Then, the electronic device obtains first parameter information of the audio data to transmit the audio data, and selects a codec of the first category from the common codec category when the first parameter information of the audio data satisfies a first condition. After the audio data content to be played, the application for playing the audio data, the user selection, or the network condition changes, the electronic device obtains a second parameter of the audio data. When the second parameter of the audio data satisfies a second condition, the electronic device does not need to renegotiate with the audio playback device regarding the codec, but directly selects a codec of the second category from the common codec category to transmit the audio data. In this way, when the electronic device needs to switch the encoder, the electronic device does not need to renegotiate with the audio playback device on the codec type to transmit the audio data, but directly selects a codec category from the codec categories supported by both the electronic device and the audio playback device and previously determined by the negotiation, which solves the problem of audio data being interrupted and sound stuttering occurring during codec switching performed by the electronic device and the audio playback device, and improves the user experience.
[0009] In relation to the first aspect, in a possible implementation, the first category of encoders includes at least a first encoder, and the second category of encoders includes at least a second encoder.
[0010] In connection with the first aspect, in a possible implementation, the electronic device is further configured to receive an identifier of a first category and an identifier of a second category transmitted by an audio playback device, wherein the decoder of the first category includes at least a first decoder, and the decoder of the second category includes at least a second decoder. Thus, the audio playback device classifies decoders into multiple categories based on codec classification criteria. For example, the categories of codecs classified into multiple categories and corresponding to one or more decoder identifiers are the first category and the second category. The decoder classified into the first category includes at least a first decoder and may further include another decoder, such as a third decoder. The decoder classified into the second category includes at least a second decoder and may further include another decoder, such as a fourth decoder.
[0011] In connection with the first aspect, in a possible implementation, the electronic device is further configured to determine that the common categories supported by the electronic device and the audio playback device are the first category and the second category, and transmit the identifier of the first category and the identifier of the second category to the audio playback device. 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 to the audio playback device the codec categories supported by both the electronic device and the audio playback device, whereby the audio playback device knows the codec categories supported by both the electronic device and the audio playback device.
[0012] In another possible implementation, the electronic device may not need to transmit the identifier of the first category or the identifier of the second category to the audio playback device. When transmitting audio data, the electronic device only needs to transmit to the audio playback device the identifier of the codec category used based on the parameter information of the audio data.
[0013] In relation to the first aspect, in a possible implementation, the encoder of the first category includes only the first encoder, and the decoder of the first category includes only the first decoder. After the electronic device determines that the common categories supported by the electronic device and the audio playback device are the first category and the second category, the electronic device is further configured to encode the audio data into the first encoded audio data using the first encoder of the first category and transmit the first encoded audio data to the audio playback device when the first parameter information satisfies a first condition. The audio playback device is further configured to decode the first encoded audio data into the first reproduced audio data using the first decoder of the first category. 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 and one decoder, the electronic device uses the encoder and decoder of the category as the default encoder and default decoder. Then, when transmitting the audio data to the audio playback device using a codec of the first category, the electronic device encodes the audio data into first encoded audio data based on a default encoder of the first category, and then the electronic device transmits the first encoded audio data to the audio playback device, and the audio playback device decodes the first encoded audio data into first reproduced audio data using a default decoder of the first category.
[0014] In relation to the first aspect, in a possible implementation, the encoder of the first category further includes a third encoder, and the decoder of the first category further includes a third decoder. After the electronic device determines that the common categories supported by the electronic device and the audio reproduction device are the first category and the second category, the electronic device encodes the audio data into first encoded audio data using a first encoder of the first category when the first parameter information satisfies a first condition, and transmits the first encoded audio data to the audio reproduction device, and a power consumption of the first encoder is lower than a power consumption of the third encoder or the priority or efficiency The audio playback device is further configured to decode the first encoded audio data into first reproduced audio data using a first decoder of the first category, and a power consumption of the first decoder is lower than a power consumption of the second decoder, or a priority or efficiencyis higher than the second decoder. 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 a plurality of encoders and a plurality of decoders, the electronic device determines one encoder from the plurality of encoders as a default encoder according to a preset rule, and determines one decoder from the plurality of decoders as a default decoder according to a preset rule. The default rule may be a priority rule, an efficiency rule, or a power consumption rule, etc. It should be noted that the electronic device may determine one encoder from the plurality of encoders as a default encoder according to a preset rule, and determine one decoder from the plurality of decoders as a default decoder according to a preset rule. In another possible embodiment, the electronic device only needs to determine one encoder from the plurality of encoders as a default encoder according to a preset rule, and the audio playback device determines one decoder from the plurality of decoders as a default decoder according to a preset rule. This is not limited here in this application.
[0015] In relation to the first aspect, in a possible implementation, when the common encoder category supported by the electronic device and the audio playback device includes only the first category, the electronic device is further configured to encode the audio data into a third encoded audio data using a first encoder of the first category and transmit the third encoded audio data to the audio playback device when the second parameter information satisfies the second condition. The audio playback device is further configured to decode the third encoded audio data into a third reproduced audio data using a first decoder of the first category. When the electronic device and the audio playback device support only one codec category, 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 transmits the audio data to the audio playback device using a default codec of the first category.
[0016] In relation to the first aspect, in a possible implementation, the common encoder categories supported by the electronic device and the audio playback device including only the first category include the electronic device not receiving an identifier of a second category sent by the audio playback device, or the number of encoders in the electronic device that fall into the second category being zero.
[0017] In relation to the first aspect, in a possible implementation, the encoder of the first category includes only the first encoder, and the decoder of the first category includes only the first decoder. When the first parameter information satisfies a first condition, the electronic device is further configured to encode the audio data into the first encoded audio data using the first encoder of the first category and transmit 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 reproduced audio data using the first decoder of the first category. The codec categories supported by both the electronic device and the audio playback device include only the first category. When the first category includes only one encoder and one decoder, the electronic device uses the encoder and decoder of the category as a default encoder and default decoder. Then, when transmitting the audio data to the audio playback device using the codec of the first category, the electronic device encodes the audio data into the first encoded audio data based on the default encoder of 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 played audio data using a default decoder of the first category.
[0018] In relation to the first aspect, in a possible implementation, the encoder of the first category further includes a third encoder, and the decoder of the first category further includes a third decoder. When the first parameter information satisfies a first condition, the electronic device encodes the audio data into first encoded audio data based on the first encoder of the first category, and transmits the first encoded audio data to the audio playback device, and the power consumption of the first encoder is lower than the power consumption of the third encoder, or the priority or efficiencyThe audio playback device is further configured to decode the first encoded audio data into the first reproduced audio data using a first decoder of the first category, and a power consumption of the first decoder is lower than a power consumption of the third decoder or a priority or a power consumption of the first decoder is higher than a power consumption of the third decoder. efficiency is higher 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 one encoder from the multiple encoders as a default encoder according to a preset rule, and determines one decoder from the multiple decoders as a default decoder according to a preset rule. The default rule may be a priority rule, an efficiency rule, or a power consumption rule, etc. It should be noted that the electronic device may determine one encoder from the multiple encoders as a default encoder according to a preset rule, and determine one decoder from the multiple decoders as a default decoder according to a preset rule. In another possible implementation, the electronic device only needs to determine one encoder from the multiple encoders as a default encoder according to a preset rule, and the audio playback device determines one decoder from the multiple decoders as a default decoder according to a preset rule. This is not limited here in this application.
[0019] In relation to the first aspect, in a possible implementation, the first category of codecs are codecs having high-definition sound quality and the second category of codecs are codecs having standard sound quality, or the first category of codecs are codecs having standard sound quality and the second category of codecs are codecs having high-definition sound quality.
[0020] In relation to the first aspect, in a possible implementation, before the electronic device acquires the 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, the parameter information of the first encoder and the parameter information of the second encoder including one or more of a sampling rate, a bit rate, a quantization bit depth, a number of audio channels, and an audio stream format; and the audio playback device is further configured to classify the first decoder into a first category based on parameter information of the first decoder and a codec classification standard, and classify the second decoder into a second category based on parameter information of the second decoder and a codec classification standard, the parameter information of the first decoder and the parameter information of the second decoder including one or more of a sampling rate, a bit rate, a quantization bit depth, a number of audio channels, and an audio stream format; and the codec classification standard includes a mapping relationship between the codec categories and the parameter information of the codecs. It should be noted that the first encoder parameter information, the second encoder parameter information, the first decoder parameter information, and the second decoder parameter information are all the same.
[0021] In relation to the first aspect, in possible implementations, the sampling rate of the codec of the first category is equal to or greater than the target sampling rate and the sampling rate of the codec of the second category is less than the target sampling rate, and / or the bit rate of the codec of the first category is equal to or greater than the target bit rate and the bit rate of the codec of the second category is less than the target bit rate, and / or the number of audio channels of the codec of the first category is equal to or greater than the target number of audio channels and the number of audio channels of the codec of the second category is less than the target number of audio channels, and / or the quantization bit depth of the codec of the first category is equal to or greater than the target quantization bit depth and the quantization bit depth of the codec of the second category is less than the target quantization bit depth, and / or the audio stream format of the codec of the first category is the target audio stream format and the audio stream format of the codec of the second category is the target audio stream format.
[0022] In relation to the first aspect, in a possible implementation, the types of parameters in the first parameter information, the types of parameters in the parameter information of the first encoder, the types of parameters in the parameter information of the first decoder, the types of parameters in the parameter information of the second parameter, the types of parameters in the parameter information of the second encoder, and the types of parameters in the parameter information of the second decoder are the same. The first parameter information satisfying the first condition and the second parameter information satisfying the second condition specifically include: a sampling rate in the first parameter information is equal to or greater than a target sampling rate and a sampling rate in the second parameter information is less than a target sampling rate; and / or a bit rate in the first parameter information is equal to or greater than a target bit rate and a bit rate in the second parameter information is less than a target bit rate; and / or a quantization bit depth in the first parameter information is equal to or greater than a target quantization bit depth and a quantization bit depth in the second parameter information is less than a target quantization bit depth; and / or a number of audio channels in the first parameter information is equal to or greater than a target number of audio channels and a number of audio channels in the second parameter information is less than the target number of audio channels; and / or an audio stream format in the first parameter information is a target audio stream format and an audio stream format in the second parameter information is a target audio stream format.
[0023] In relation to the first aspect, in a possible implementation, when the delays of the first encoder and the second encoder are the same, 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 transmit 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 transmit the second encoded audio frame to the audio playback device; and encode the second audio frame in the audio data into an Nth encoded audio frame using the second encoder and transmit 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 a first decoder, decode the second encoded audio frame into a second decoded audio frame using a second decoder, decode the Nth encoded audio frame into an Nth played back audio frame using the second decoder, and smooth the first decoded audio frame and the second decoded audio frame to obtain the first played back audio frame. The electronic device first plays the first played back audio frame, and then the electronic device plays the Nth played back audio frame. In this way, when the delays of the first encoder and the second encoder are the same, the switching between the first encoder and the second encoder needs to be completed within one frame, and the frame is the first audio frame. The audio playback device smoothes the first audio frame and then plays the smoothed first audio frame to prevent audio dropouts and implement a smooth transition when switching codecs. The adjacent audio frame after the first audio frame, for example the second audio frame, does not need to be smoothed, and the second audio frame is directly decoded and played back using the second decoder.
[0024] In relation to the first aspect, in a possible implementation, when the delays of the first encoder and the second encoder are different, the electronic device obtains D audio data frames using the following formula: D=round((max(encoder 1 total delay, encoder 2 total delay)+(frame length-encoder 1 total delay % frame length)+frame length-1) / frame length), where D denotes the total number of audio data frames when switching between the first encoder and the second encoder, max denotes the operation to obtain the maximum value, % denotes the modulo operation, frame length denotes the duration of one frame of audio data, from the third encoded audio frame to the (D+2)th encoded audio frame. and encoding the 1st through Dth audio frames in the audio data using a first encoder to obtain a (D+3)th encoded audio frame, encoding the Dth audio frame in the audio data using a second encoder to obtain a (D+1)th audio frame in the audio data using the second encoder to obtain an Nth encoded audio frame, and transmitting the 3rd through (D+2)th encoded audio frames, the (D+3)th encoded audio frame, and the Nth encoded audio frame to the audio playback device.The audio playback device is further configured to: use the first decoder to decode the (D+2)th encoded audio frame from the third encoded audio frame to the second reproduced audio frame to the (D+1)th reproduced audio frame, use the second decoder to decode the (D+3)th encoded audio frame to the third decoded audio frame, play from the second reproduced audio frame to the Dth reproduced audio frame, smooth the (D+1)th reproduced audio frame and the third decoded audio frame to obtain a target reproduced audio frame, play the target reproduced audio frame, and use the second decoder to decode the Nth encoded audio frame to the Nth decoded audio frame, and play the Nth decoded audio frame. In this way, when the 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, when 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 encoder switching needs to be completed within D frames, the audio playback device directly decodes the first audio frame to the (D-1)th audio frame and plays the decoded audio frames, and the audio playback device smoothes the Dth audio frame and then plays the smoothed audio frame, so as to prevent sound dropouts during codec switching and to implement a smooth transition. The adjacent audio frame after the Dth audio frame, for example the Nth audio frame, does not need to be smoothed, and the Nth audio frame is directly decoded and played.
[0025] In relation to the first aspect, in a possible implementation, the audio playback device obtains the first playback audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where Pcm is the first playback audio frame, wi is a smoothing factor, and w i is Further configured such that pcmA 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 relation to the first aspect, in a possible implementation, the audio playback device is further configured to obtain the first playback audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where 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.
[0027] In relation to the first aspect, in a possible implementation, the audio playback device obtains a target playback audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where Pcm is the target playback audio frame, wi is a smoothing coefficient, and w i is Further configured such that pcmA is greater than 0 and less than 1, pcmA is the (D+1)th reproduced audio frame, and pcmB is the third decoded audio frame.
[0028] According to a second aspect, the present application provides a codec negotiation and switching method, the method including: when first parameter information of audio data satisfies a first condition, an electronic device encodes the audio data into first encoded audio data based on a first encoder of a first category, and sends the first encoded audio data to an audio playback device; 1When the second parameter information satisfies a second condition, the electronic device encodes the audio data into second encoded audio data based on a second encoder of the second category and sends the second encoded audio data to the audio playback device, the second category being a common codec category supported by the electronic device and the audio playback device and determined by the electronic device before obtaining the audio data, the second category being a common codec category supported by the electronic device and the audio playback device and determined by the electronic 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.
[0029] In the method of the second aspect, before transmitting audio data, the electronic device and the audio playback device classify codecs into a plurality of categories and determine a common codec category (e.g., a first category and a second category) supported by the electronic device and the audio playback device. Then, the electronic device obtains first parameter information of the audio data to transmit the audio data, and selects a codec of the first category from the common codec category when the first parameter information of the audio data satisfies a first condition. After the audio data content to be played, the application for playing the audio data, the user selection, or the network condition changes, the electronic device obtains a second parameter of the audio data. When the second parameter of the audio data satisfies a second condition, the electronic device does not need to renegotiate with the audio playback device regarding the codec, but directly selects a codec of the second category from the common codec category to transmit the audio data. In this way, when the electronic device needs to switch the encoder, the electronic device does not need to renegotiate with the audio playback device on the codec type to transmit the audio data, but directly selects a codec category from the codec categories supported by both the electronic device and the audio playback device and previously determined by the negotiation, which solves the problem of audio data being interrupted and sound stuttering occurring during codec switching performed by the electronic device and the audio playback device, and improves the user experience.
[0030] In relation to the second aspect, in a possible implementation, the first category of encoders includes at least a first encoder, and the second category of encoders includes at least a second encoder.
[0031] In relation to the second aspect, in a possible implementation, the method further includes: the electronic device receives a first category identifier and a second category identifier transmitted by the audio playback device, the first category decoder at least includes a first decoder, and the second category decoder at least includes a second decoder. In this way, the audio playback device classifies the decoders into a plurality of categories based on a codec classification standard. For example, the codec categories classified into a plurality of categories and corresponding to one or more decoder identifiers are a first category and a second category. The decoder classified into the first category includes at least a first decoder and may further include another decoder, for example a third decoder. The decoder classified into the second category includes at least a second decoder and may further include another decoder, for example a fourth decoder.
[0032] In relation to the second aspect, in a possible implementation, the method further includes the electronic device determining that the common categories supported by the electronic device and the audio playback device are a first category and a second category, and the electronic device sending an identifier of the first category and an identifier of the second category to the audio playback device. The electronic device sends the codec categories 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 categories supported by both the electronic device and the audio playback device.
[0033] In relation to the second aspect, in a possible implementation, the encoder of the first category includes only a first encoder, and after the electronic device determines that the common categories supported by 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 satisfies a first condition, the electronic device encodes the audio data into first encoded audio data using the first encoder of the first category, and transmits 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 determines the encoder of the category as a default encoder. Da and Then, when transmitting audio data to the audio playback device using a codec of the first category, the electronic device encodes the audio data into first encoded audio data based on the default encoder of the first category. Then, the electronic device transmits the first encoded audio data to the audio playback device.
[0034] In relation to the second aspect, in a possible implementation, the encoder of the first category further includes a third encoder, and after the electronic device determines that the common categories supported by the electronic device and the audio reproduction device are the first category and the second category, the method further comprises: when the first parameter information satisfies a first condition, the electronic device encodes the audio data into first encoded audio data using the first encoder of the first category, and transmits the first encoded audio data to the audio reproduction device, and a power consumption of the first encoder is lower than a power consumption of the third encoder or a priority or a priority of the first encoder is higher than a power consumption of the third encoder. efficiencyis higher than 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 determines one encoder from the multiple encoders as a default encoder according to a preset rule. The default rule may be a priority rule, an efficiency rule, or a power consumption rule, etc.
[0035] In relation to the second aspect, in a possible implementation, when the common encoder category supported by the electronic device and the audio playback device includes only the first category, the method further includes: when the second parameter information satisfies a second condition, the electronic device encodes the audio data into a third encoded audio data using a first encoder of 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, 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 transmits the audio data to the audio playback device using a default codec of the first category.
[0036] In relation to the second aspect, in a possible implementation, when the electronic device does not receive an identifier of the second category transmitted by the audio playback device or the number of encoders of the electronic device that fall into the second category is zero, the common encoder categories supported by the electronic device and the audio playback device include only the first category.
[0037] In connection with the second aspect, in a possible implementation, the encoder of the first category includes only the first encoder, the decoder of the first category includes only the first decoder, and when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data based on the first encoder of the first category, and transmits the first encoded audio data to the audio playback device. The codec category supported by both the electronic device and the audio playback device includes only the first category. When the first category includes only one encoder, the electronic device uses the encoder of the category as the default encoder. Next, when transmitting the audio data to the audio playback device using the codec of the first category, the electronic device encodes the audio data into first encoded audio data based on the default encoder of the first category. Next, the electronic device transmits the first encoded audio data to the audio playback device.
[0038] In connection with the second aspect, in a possible implementation, the encoder of the first category further includes a third encoder, the decoder of the first category further includes a third decoder, and when the first parameter information meets the first condition, the electronic device encodes the audio data into first encoded audio data based on the first encoder of the first category, and transmits the first encoded audio data to the audio playback device, and the power consumption of the first encoder is lower than that of the third encoder, or the priority or efficiency is higher than that of the third encoder. The codec category supported by both the electronic device and the audio playback device includes only the first category. When the first category includes multiple encoders, the electronic device determines one encoder as the default encoder from the multiple encoders according to a preset rule. The default rule can be a priority rule, an efficiency rule, a power consumption rule, etc.
[0039] In relation to the second aspect, in a possible implementation, the first category of codecs are codecs having high-definition sound quality and the second category of codecs are codecs having standard sound quality, or the first category of codecs are codecs having standard sound quality and the second category of codecs are codecs having high-definition sound quality.
[0040] In relation to the second aspect, in a possible implementation, before the electronic device acquires the audio data, the method further comprises:
[0041] The electronic device classifies the first encoder into a first category based on the parameter information of the first encoder and a codec classification standard, and classifies the second encoder into a second category based on the parameter information of the second encoder and a codec classification standard, 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 audio channels, and an audio stream format, and the codec classification standard includes a mapping relationship between the codec category and the parameter information of the codec. It should be noted that the parameter information of the first encoder and the parameter information of the second encoder are the same.
[0042] In relation to the second aspect, in possible implementations, the sampling rate of the codec of the first category is equal to or greater than the target sampling rate and the sampling rate of the codec of the second category is less than the target sampling rate, and / or the bit rate of the codec of the first category is equal to or greater than the target bit rate and the bit rate of the codec of the second category is less than the target bit rate, and / or the number of audio channels of the codec of the first category is equal to or greater than the target number of audio channels and the number of audio channels of the codec of the second category is less than the target number of audio channels, and / or the quantization bit depth of the codec of the first category is equal to or greater than the target quantization bit depth and the quantization bit depth of the codec of the second category is less than the target quantization bit depth, and / or the audio stream format of the codec of the first category is the target audio stream format and the audio stream format of the codec of the second category is the target audio stream format.
[0043] In relation to the second aspect, in a possible implementation, the types of parameters in the first parameter information, the types of parameters in the parameter information of the first encoder, the types of parameters in the parameter information of the first decoder, the types of parameters in the parameter information of the second parameter, the types of parameters in the parameter information of the second encoder, and the types of parameters in the parameter information of the second decoder are the same. The first parameter information satisfying the first condition and the second parameter information satisfying the second condition specifically include: a sampling rate in the first parameter information is equal to or greater than a target sampling rate and a sampling rate in the second parameter information is less than a target sampling rate; and / or a bit rate in the first parameter information is equal to or greater than a target bit rate and a bit rate in the second parameter information is less than a target bit rate; and / or a quantization bit depth in the first parameter information is equal to or greater than a target quantization bit depth and a quantization bit depth in the second parameter information is less than a target quantization bit depth; and / or a number of audio channels in the first parameter information is equal to or greater than a target number of audio channels and a number of audio channels in the second parameter information is less than the target number of audio channels; and / or an audio stream format in the first parameter information is a target audio stream format and an audio stream format in the second parameter information is a target audio stream format.
[0044] According to a third aspect, the present application provides an electronic device including one or more processors, one or more memories, and one or more encoders. The one or more memories and the one or more encoders are coupled to the one or more processors. The one or more memories are configured to store computer program code. The computer program code includes computer instructions. The one or more processors call the computer instructions to enable the electronic device to execute a codec negotiation and switching method according to any one of the possible embodiments of the second aspect.
[0045] According to a fourth aspect, the present application provides a computer-readable storage medium. The computer-readable storage medium stores computer-executable instructions. When the computer-executable instructions are called by a computer, the computer is enabled to execute a codec negotiation and switching method provided by any one of the possible embodiments of the second aspect.
[0046] According to a fifth aspect, the present application provides a computer program product including instructions. When the computer program product operates on a computer, the computer is enabled to execute a codec negotiation and switching method provided by any one of the possible embodiments of the second aspect.
Brief Description of the Drawings
[0047] [Figure 1] It is a schematic diagram of a process for transmitting audio data between an electronic device and an audio playback device according to an embodiment of the present application. [Diagram 2] It is a schematic diagram of a system according to an embodiment of the present application. [Diagram 3] It is a schematic diagram of a system for networking and transmission according to an embodiment of the present application. [Figure 4]2 is a schematic diagram of another process for transmitting audio data between an electronic device 100 and an audio playback device 200 according to an embodiment of the present application. [Diagram 5] 1 is a schematic diagram of the structure of an electronic device 100 according to an embodiment of the present application. [Figure 6] 1 is a block diagram of the software structure of an electronic device 100 (eg, a mobile phone) according to one embodiment of the present application. [Figure 7] 2 is a schematic diagram of a hardware structure of an audio playback device 200 according to an embodiment of the present application. [Figure 8] 2 is a schematic diagram of a negotiation by an electronic device 100 and an audio playback device 200 regarding a common codec category according to an embodiment of the present application. [Figure 9] 2 is a flowchart of a codec negotiation and switching method according to an embodiment of the present application. [Figure 9A] 1 is a diagram of a UI in which the electronic device 100 establishes a communication connection to the audio playback device 200 via Bluetooth, according to one embodiment of the present application. [Figure 9B] 1 is a diagram of a UI in which the electronic device 100 establishes a communication connection to the audio playback device 200 via Bluetooth, according to one embodiment of the present application. [Figure 9C] 1 is a diagram of a UI in which the electronic device 100 establishes a communication connection to the audio playback device 200 via Bluetooth, according to one embodiment of the present application. [Figure 10A] FIG. 13 is a diagram of another UI according to an embodiment of the present application. [Figure 10B] FIG. 13 is a diagram of another UI according to an embodiment of the present application. [Figure 10C] FIG. 13 is a diagram of another UI according to an embodiment of the present application. [Figure 10D] FIG. 13 is a diagram of another UI according to an embodiment of the present application. DETAILED DESCRIPTION OF THE PREFERRED EMBODIMENTS
[0048] The following will clearly describe the technical solutions in the embodiments of the present application in detail with reference to the accompanying drawings. In the description of the embodiments of the present application, unless otherwise specified, " / " indicates "or". For example, A / B can indicate A or B. The term "and / or" in this specification only describes the association relationship between associated objects and indicates that three relationships can exist. For example, A and / or B can indicate the following three cases: only A exists, both A and B exist, and only B exists. In addition, in the description of the embodiments of the present application, "multiple" means two or more than two.
[0049] The terms "first" and "second" used hereinafter are for descriptive purposes only and should not be construed as an indication or implication of relative importance or an implicit indication of the number of technical features indicated. Thus, a feature qualified by "first" or "second" may explicitly or implicitly include one or more features. In the description of the embodiments of this application, "plurality" means two or more than two, unless otherwise specified.
[0050] The term "user interface (UI)" in the specification, claims and accompanying drawings of this application is a medium interface for interaction and information exchange between a user and an application or an operating system, which performs conversion between an internal form of information and a form acceptable to the user. The user interface of an application is a source code written in a specific computer language, e.g., Java or extensible markup language (XML). The source code of the interface is parsed and rendered on the terminal device, and finally presented as user-perceivable content, e.g., controls, e.g., images, text, or buttons. Controls, also called widgets, are the basic elements on a user interface. Typical controls include toolbars, menu bars, input boxes, buttons, scrollbars, images, and text. The attributes and contents of controls on an interface are defined using tags or nodes. For example, the controls included in the interface are represented by nodes, e.g., <textview> 、 <imgview>,or <videoview>A web page is defined in XML using a tag. A node corresponds to a control or an attribute on the interface. After being parsed and rendered, the node is presented as user visible content. In addition, the interface of many applications, such as hybrid applications, usually further includes a web page. A web page, also called a page, can be understood as a special control embedded in the interface of an application. A web page is a source code written in a specific computer language, for example, hyper text markup language (HTML), cascading style sheets (CSS), or JavaScript (JS). The source code of a web page can be loaded and displayed as user perceivable content by a browser, or a web page display component with functionality similar to that of a browser. The specific content included in a web page is also defined using tags or nodes in the source code of the web page. For example, the elements and attributes of a web page are 、 、 <video>,or <canvas>It is defined in HTML using
[0051] A user interface, usually in the form of a graphical user interface (GUI), is a graphically displayed user interface related to computer operations. A graphical user interface can be interface elements such as windows or controls that appear on the display of an electronic device.
[0052] Currently, after an electronic device (e.g., a mobile phone) establishes a communication connection to an audio playback device (e.g., a headset), the electronic device transmits audio data to the audio playback device, and the audio playback device reproduces the audio data transmitted by the electronic device. Before the electronic device transmits audio data to the audio playback device, the electronic device negotiates with the audio playback device regarding a codec type. The electronic device selects a codec supported by both the electronic device and the audio playback device to encode the audio data, and transmits the encoded audio data to the audio playback device.
[0053] FIG. 1 is a schematic diagram of an exemplary process for transmitting audio data between an electronic device and an audio playback device.
[0054] The electronic device may be an audio signal source (Source, SRS) and the audio playing device may be an audio signal sink (Sink, SNK).
[0055] The electronic device includes an audio data acquiring unit, an audio stream decoding unit, an audio mixing and rendering unit, a wireless audio encoding unit, a capabilities negotiation unit, and a wireless transmission unit.
[0056] The audio playing device includes a wireless transmitting unit, a wireless audio decoding unit, an audio power amplifier unit, an audio playing unit, and a capabilities negotiation unit.
[0057] Before the electronic device transmits the acquired audio data to the audio playback device, the electronic device negotiates with the audio playback device to acquire the type of codec supported by both the electronic device and the audio playback device to perform data transmission. Specifically, after the electronic device establishes a communication connection to the audio playback device, the audio playback device uses a capability negotiation unit to transmit all decoder identifiers and all decoder capabilities to a wireless transmission unit on the audio playback device side, where the decoder identifiers are the numbers of the decoders, and the audio playback device may find a decoder corresponding to the decoder identifiers based on the decoder identifiers and acquire the decoder capabilities corresponding to the decoder identifiers. The wireless transmission unit on the audio playback device side transmits all decoder identifiers and all decoder capabilities to a wireless transmission unit on the electronic device side. The wireless transmission unit on the electronic device side transmits all decoder identifiers and all decoder capabilities to a capability negotiation unit on the electronic device side. The capability negotiation unit on the electronic device side obtains all encoder identifiers and all encoder capabilities on the electronic device, where the encoder identifiers are the numbers of the encoders, and the electronic device may find an encoder corresponding to the encoder identifiers based on the encoder identifiers and acquire the encoder capabilities corresponding to the encoder identifiers. The capability negotiation unit on the electronic device side obtains one or more common codec capabilities supported by the electronic device and the audio playback device based on the capabilities of all the codecs, where the codec capabilities include a sampling rate value, a quantization bit depth value, a bit rate, and a number of audio channels supported by the codec. The electronic device determines a codec identifier as a default codec from the one or more common codec capabilities supported by the electronic device and the audio playback device based on the type of audio to be played and other factors. Then, the electronic device transmits audio data to the audio playback device based on the default codec identifier.The capabilities negotiation unit of the electronic device sends a default encoder identifier to the wireless encoding unit, and in addition, the capabilities negotiation unit of the electronic device sends a default decoder identifier to the wireless transmission unit of the electronic device, which sends the default decoder identifier to the wireless transmission unit of the audio playback device, which sends the default decoder identifier to the capabilities negotiation unit of the audio playback device, and the audio playback device sends the default decoder identifier to the wireless audio decoding unit using the capabilities negotiation unit.
[0058] In some embodiments, the electronic device and the audio playback device may alternatively not include a capability negotiation unit. When the electronic device and the audio playback device do not include a capability negotiation unit, the wireless transmission units of the electronic device and the audio playback device may perform the codec capability negotiation function.
[0059] With respect to the electronic device, the audio data acquiring unit is configured to acquire an audio bitstream, and the audio bitstream may be a network audio bitstream acquired by the electronic device in real time, or may be an audio bitstream cached in the electronic device. After acquiring the audio bitstream, the audio data acquiring unit sends the audio bitstream to the audio stream decoding unit.
[0060] The audio stream decoding unit receives the audio bitstream sent by the audio data obtaining unit, and decodes the audio bitstream to obtain an uncompressed audio bitstream. Then, the audio stream decoding unit sends the uncompressed audio bitstream to the audio mixing and rendering unit.
[0061] The audio mixing and rendering unit receives the uncompressed audio bitstream sent by the audio stream decoding unit, and performs audio mixing and rendering on the uncompressed audio bitstream, and the audio bitstream obtained by the audio mixing and rendering is called audio data. The audio mixing is to mix the uncompressed audio bitstream with audio data having ambient attributes, so that the audio bitstream obtained by the audio mixing and rendering has ambient attributes. It can be understood that the electronic device may provide multiple audio data for audio mixing and rendering. For example, during dubbing and narration for a documentary, a dubbing expert records a narration audio bitstream. In order to make the audio bitstream match the footage of the documentary, the ambient attributes of the audio bitstream need to be rendered to create an enigmatic atmosphere. The rendering is to adjust the sampling rate, sampling bit depth, number of audio channels, etc. of the audio data.
[0062] It should be noted that in some embodiments, the electronic device may alternatively not include an audio mixing and rendering unit, i.e., the electronic device does not need to perform audio mixing and rendering on the audio bitstream, which is not a limitation here in this application. The audio mixing and rendering unit then transmits the audio data to the wireless audio encoding unit.
[0063] The wireless audio encoding unit receives the audio data sent by the audio mixing and rendering unit, and encodes the audio data based on the default encoder identifier. Then, the wireless audio encoding unit transmits the encoded audio data to the wireless transmission unit.
[0064] The wireless transmission unit receives the encoded audio data transmitted by the wireless audio encoding unit, and transmits the encoded audio data to the wireless transmission unit of the audio playback device via a transmission channel between the electronic device and the audio playback device.
[0065] The wireless transmission unit of the audio reproduction device receives the encoded audio data transmitted by the wireless transmission unit of the electronic device, and the wireless transmission unit of the audio reproduction device transmits the encoded audio data to the wireless audio decoding unit of the audio reproduction device.
[0066] A wireless audio decoding unit of the audio reproduction device receives the encoded audio data transmitted by the wireless transmission unit, and performs audio decoding on the encoded audio data based on the default decoder identifier to obtain uncompressed audio data. The wireless audio decoding unit of the audio reproduction device transmits the uncompressed audio data to an audio power amplifier unit of the audio reproduction device.
[0067] An audio power amplifier unit of the audio playback device receives the uncompressed audio data, performs operations on the uncompressed audio data, such as digital-to-analog conversion and power amplification, and then plays back the audio data using the audio playback unit.
[0068] When a communication connection is first established, the electronic device transmits audio data to the audio playback device based on a default codec identifier obtained by negotiation. However, when the network quality deteriorates or the electronic device performs transmission with a higher resolution sound quality, the electronic device needs to switch to an encoder suitable for network transmission or an encoder with a higher resolution sound quality. However, when the electronic device switches the encoder, the electronic device needs to renegotiate with the audio playback device regarding the codec capability. When the electronic device renegotiates with the audio playback device regarding the codec capability, the electronic device suspends transmitting audio data to the audio playback device. As a result, the audio data is interrupted during the codec switching performed by the electronic device and the audio playback device, causing sound stuttering and affecting the user experience.
[0069] Therefore, the present application provides a codec negotiation and switching method. The method includes that before the electronic device and the audio playback device establish a communication connection, the electronic device and the audio playback device classify one or more codecs into a plurality of categories based on a sampling rate, a quantization bit depth, a bit rate, a number of audio channels, and other parameters. After the electronic device and the audio playback device establish a communication connection, before the electronic device transmits audio data to the audio playback device, the audio playback device transmits a category identifier corresponding to one or more decoder identifiers to the electronic device. The electronic device obtains a common category based on the categories corresponding to the one or more decoder identifiers and the categories corresponding to the one or more encoder identifiers. Then, the electronic device selects a default codec of the category based on conditions such as a user selection, an audio data playback characteristic, whether an audio rendering capability of the electronic device is enabled, or an application type, to transmit the audio data. When conditions such as a user selection, an audio data playback characteristic, whether an audio rendering capability of the electronic device is enabled, or an application type change, the electronic device reselects a default encoder of another category for encoding and transmission, and transmits an identifier of the reselected another category to the audio playback device. The audio playback device uses the default decoder of the category to perform decoding and play the audio data. In this way, when the electronic device needs to switch the encoder, the electronic device does not need to renegotiate with the audio playback device regarding the codec type. This solves the problem of audio data being interrupted and sound stuttering occurring during codec switching performed by the electronic device and the audio playback device, and improves the user experience.
[0070] The technical solution is applicable to a wireless audio playback scenario in which a mobile phone is connected to a wireless headset in a point-to-point manner, and also applicable to a scenario in which a tablet computer, a PC, or a wearable device such as a smart watch is connected to a wireless headset in a point-to-point manner, and also applicable to a smart home scenario in which a network is established based on a mobile phone, a PC, a tablet computer, a smart TV, a set-top box, a smart speaker, or a smart router, and the audio playback device can be one or more of a speaker, an echo wall, and an intelligent TV for networking and playback.
[0071] The following describes the architecture of a wireless audio playback system according to one embodiment of the present application.
[0072] FIG. 2 is a schematic diagram of a system according to one embodiment of the present application.
[0073] Initially, electronic device 100 establishes a communication connection to audio playback device 200, and electronic device 100 can transmit audio data to the audio playback device, which plays the audio data.
[0074] The electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device, and / or a smart city device. The specific type of the electronic device 100 is not particularly limited in this embodiment of the application. The software system of the electronic device 100 includes, but is not limited to, iOS®, Android®, Harmony®, Windows®, Linux, or another operating system. Harmony® is Huawei's HarmonyOS.
[0075] The audio playback device 200 is a device that has audio playback capabilities. The audio playback device may be, but is not limited to, a headset, a speaker, a television, an AR / VR glasses device, a tablet computer, a PC, or a wearable device such as a smart watch.
[0076] In the following embodiments of the present application, an example in which the electronic device 100 is a mobile phone and the audio playback device 200 is a Bluetooth headset is used for explanation.
[0077] The electronic device 100 and the audio playing device 200 may be connected and communicate with each other by 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 called wireless fidelity peer-to-peer (Wi-Fi P2P)), and other wireless communication technologies that will appear in later development. For ease of description, the following embodiment uses an example in which the electronic device 100 and the audio playing device 200 communicate with each other by Bluetooth wireless communication technology for description.
[0078] When the audio playing device 200 is connected to the electronic device 100 by Bluetooth technology, the electronic device 100 sends time synchronization information (e.g., handshake information) to the audio playing device 200 for network synchronization. After the networking is successful and the synchronization is completed, the audio playing device 200 plays audio under the control of the electronic device 100. Specifically, the electronic device 100 sends audio data to the audio playing device 200 through the established Bluetooth channel, and the audio playing device 200 plays the audio data sent by the electronic device 100.
[0079] 2 is merely an example system. In some embodiments, the electronic device 100 may alternatively establish communication connections to multiple audio playback devices 200. In the following embodiments of the present application, an example in which the electronic device 100 establishes a connection to one audio playback device 200 is used for explanation. It should be noted that the number of audio playback devices 200 is not limited in the present application.
[0080] The following describes the architecture of a wireless audio playback system in another networking connection according to one embodiment of the present application.
[0081] As shown in FIG. 3, the electronic device 100 establishes communication connections to multiple audio playback devices 200 .
[0082] The electronic device 100 may be a mobile phone, a tablet computer, a desktop computer, a laptop computer, a handheld computer, a notebook computer, an ultra-mobile personal computer (UMPC), a netbook, a cellular phone, a personal digital assistant (PDA), an augmented reality (AR) device, a virtual reality (VR) device, an artificial intelligence (AI) device, a wearable device, an in-vehicle device, a smart home device, and / or a smart city device. The specific type of the electronic device 100 is not particularly limited in this embodiment of the application. The software system of the electronic device 100 includes, but is not limited to, iOS®, Android®, Harmony®, Windows®, Linux, or another operating system. Harmony® is Huawei's HarmonyOS.
[0083] The audio playback device 200 is a device that has audio playback capabilities. The audio playback device may be, but is not limited to, a headset, a speaker, a television, an AR / VR glasses device, a tablet computer, a PC, or a wearable device such as a smart watch.
[0084] In this embodiment of the present application, an example in which the electronic device 100 is a mobile phone, and the multiple audio playback devices 200 are a headset and a speaker is used for explanation. Specifically, the mobile phone can establish a connection to both the headset and the speaker, and the mobile phone can transmit multimedia content (e.g., audio data) to both the headset and the speaker.
[0085] When multiple audio playback devices 200 (e.g., headset and speaker) do not have delay synchronization requirements for the same audio data transmitted by electronic device 100, the connection between electronic device 100 and multiple audio playback devices may be considered to constitute multiple independent systems. Specifically, electronic device 100 negotiates with headset for common codec categories and default encoder and decoder identifiers for each category, and electronic device 100 negotiates with speaker for common codec categories and default encoder and decoder identifiers for each category. Electronic device 100 and headset may independently select one of the common codec categories supported by both electronic device 100 and headset to transmit audio data. Electronic device 100 and speaker may independently select one of the common codec categories supported by both electronic device 100 and headset to transmit audio data. The codec category selected by the electronic device 100 and the headset may be the same as or different from the codec category selected by the electronic device 100 and the speaker. In addition, the codec category switching performed by the electronic device 100 and the headset and the codec category switching performed by the electronic device 100 and the speaker do not affect each other. The method for selecting and switching the codec category by the electronic device 100 and the headset or by the electronic device 100 and the speaker is consistent with the method for selecting and switching the codec category by the electronic device 100 and the audio playback device 200 in the following embodiment. In this application, details are not described here.
[0086] When multiple audio playback devices 200 (e.g., headset and speaker) have delay synchronization requirements for the same audio data transmitted by electronic device 100, the connection between electronic device 100 and multiple audio playback devices is considered as a whole system. Specifically, when electronic device 100 and multiple audio playback devices obtain codec categories supported by electronic device 100 and all of multiple audio playback devices through negotiation, headset transmits all codec categories and decoder identifiers for each category to electronic device 100, and speaker transmits all codec categories and decoder identifiers for each category to electronic device 100. Electronic device 100 obtains all codec categories and encoder identifiers for each category on electronic device 100. Then, electronic device 100 determines a common codec category from the codec categories on electronic device 100, the codec categories transmitted by headset, and the codec categories transmitted by speaker, and the common codec category is the codec category supported by all of electronic device 100, headset, and speaker. The method for determining the codec categories supported by all of the electronic device 100, the headset, and the speaker by the electronic device 100 is consistent with the method for determining the codec categories supported by both the electronic device 100 and the audio playback device 200 in the following embodiment. Details are not described here in this application. Next, the electronic device 100 determines the default encoder and default decoder of the codec categories supported by all of the electronic device 100, the headset, and the speaker. The electronic device 100 sends the codec categories supported by all of the electronic device 100, the headset, and the speaker, and the default encoder identifier and default decoder identifier of each category to the headset and the speaker.It should be noted that the method for selecting and switching codec categories by the electronic device 100 is consistent with the method for selecting and switching codec categories by the electronic device 100 and the audio playback device 200 in the following embodiments, which will not be described in detail here in this application.
[0087] The following uses an example in which the electronic device 100 establishes a connection to one audio playback device 200 to describe the codec negotiation and switching method provided in the embodiment. The principle when the electronic device 100 establishes a connection to multiple audio playback devices 200 is the same as the principle when the electronic device 100 establishes a connection to one audio playback device 200. In this application, the details are not described here.
[0088] FIG. 4 is a schematic diagram of another exemplary process for transmitting audio data between electronic device 100 and audio playback device 200.
[0089] The electronic device 100 includes an audio data acquiring unit, an audio stream decoding unit, an audio mixing and rendering unit, a wireless audio encoding unit, a capabilities negotiation unit, an encoding control unit, and a wireless transmission unit.
[0090] The audio reproduction device 200 includes a wireless transmission unit, a wireless audio decoding unit, an audio power amplifier unit, an audio reproduction unit, a capabilities negotiation unit, and a decoding control unit.
[0091] The functions of the audio data acquiring unit, the audio stream decoding unit, the audio mixing and rendering unit, the wireless audio encoding unit and the wireless transmission unit of the electronic device 100 are the same as those of the audio data acquiring unit, the audio stream decoding unit, the audio mixing and rendering unit, the wireless audio encoding unit and the wireless transmission unit shown in Fig. 1. In this application, the details will not be described again here.
[0092] Similarly, the functions of the wireless transmission unit, the wireless audio decoding unit, the audio power amplifier unit, and the audio playback unit of the audio playback device 200 are the same as those of the wireless transmission unit, the wireless audio decoding unit, the audio power amplifier unit, and the audio playback unit shown in Fig. 1. In this application, the details will not be described again here.
[0093] With respect to the electronic device 100, the capability negotiation unit is specifically configured to obtain a codec classification standard, identifiers of all encoders in the electronic device 100, and all encoder capabilities, the encoder capabilities including sampling rate, quantization bit depth, bit rate, number of audio channels, and other parameter information of the encoders, and classify all encoders in the electronic device 100 into multiple categories based on the codec classification standard and all encoder capabilities in the electronic device 100. One encoder may belong to one or more categories. It should be noted that the codec classification standard is pre-set on the electronic device 100.
[0094] Similarly, with respect to the audio reproduction device 200, the capability negotiation unit is specifically configured to obtain a codec classification standard, identifiers of all decoders in the audio reproduction device 200, and all decoder capabilities, and classify all decoders in the audio reproduction device 200 into multiple categories based on the codec classification standard and all decoder capabilities in the electronic device 100. One decoder may belong to one or more categories. It should be noted that the codec classification standard is pre-set on the audio reproduction device 200.
[0095] Then, the audio reproduction device 200 uses the capability negotiation unit to transmit category identifiers corresponding to the one or more decoder identifiers on the audio reproduction device 200 to a wireless transmission unit of the audio reproduction device 200. The wireless transmission unit of the audio reproduction device 200 transmits category identifiers corresponding to the one or more decoder identifiers to a wireless transmission unit of the electronic device 100. A category corresponding to one or more decoder identifiers may be understood as a number of decoder identifiers included in the category being one or more.
[0096] The wireless transmission unit of the electronic device 100 receives and transmits category identifiers corresponding to the one or more decoder identifiers to a capabilities negotiation unit of the electronic device 100 .
[0097] The capabilities negotiation unit of the electronic device 100 receives a category identifier that corresponds to one or more decoder identifiers.
[0098] The capability negotiation unit of the electronic device 100 also negotiates the capabilities of one or more D A category identifier corresponding to the coder identifier is obtained.
[0099] The capability negotiation unit of the electronic device 100 sends a category identifier corresponding to one or more decoder identifiers and a category identifier corresponding to one or more encoder identifiers to the encoding control unit of the electronic device 100. The encoding control unit of the electronic device 100 determines a common category identifier from the category identifier corresponding to one or more decoder identifiers and the category identifier corresponding to one or more encoder identifiers, and determines a default encoder for each common category. Here, the method in which the encoding control unit determines the default encoder for each common category supported by the electronic device 100 and the audio playback device 200 through negotiation will be described in detail in a later embodiment. This is not limited here in this application. After the encoding control unit determines the common category and the default encoder for each common category, the encoding control unit selects an appropriate category (e.g., a first category) from the common categories based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, and the network condition of the channel, etc., to transmit the audio data, and selects a default encoder for the category. The method in which the encoding control unit selects the first category from the common categories based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, and the network condition of the channel, etc., will be described in detail in the later embodiment, which is not limited here in this application.
[0100] Then, 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 based on an encoder corresponding to the default encoder identifier of the first category.
[0101] In addition, the encoding negotiation unit transmits the identifier of the first category to the wireless transmission unit, and the electronic device 100 transmits the identifier of the first category to the wireless transmission unit of the audio reproduction device 200 using the wireless transmission unit. The wireless transmission unit of the audio reproduction device 200 transmits the identifier of the first category to the capabilities negotiation unit of the audio reproduction device 200. The capabilities negotiation unit of the audio reproduction device 200 transmits the identifier of the first category to the decoding control unit of the audio reproduction device 200. The decoding control unit of the audio reproduction device 200 transmits the identifier of the first category to the wireless audio decoding unit. The wireless audio decoding unit decodes the encoded audio data transmitted by the electronic device 100 based on a decoder corresponding to the default decoder identifier of the first category.
[0102] After the encoding negotiation unit selects an appropriate category (e.g., a first category) from the common categories and transmits audio data using a default codec of the first category, due to a change in application type, a change in audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), enabling of the audio rendering capability of the electronic device, a change in network conditions of the channel, or other factors, the electronic device 100 reselects another category using the encoding control unit and notifies the decoding control unit of the audio playback device 200 of an identifier of the category. The electronic device 100 transmits audio data to the audio playback device 200 using the default codec of the other category.
[0103] FIG. 5 is a schematic diagram of an exemplary structure of an electronic device 100.
[0104] The following describes the embodiment in detail using an example in which the electronic device 100 is a mobile phone. It should be understood that the electronic device 100 shown in Fig. 5 is only an example, and the electronic device 100 may include more or less components than those shown in Fig. 5, two or more components may be combined, or there may be a different component configuration. The components shown in the figure may be implemented in hardware, including one or more signal processing and / or application specific integrated circuits, software, or a combination of hardware and software.
[0105] 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, a headset jack 170D, a sensor module 180, buttons 190, a motor 191, an indicator 192, a camera 193, a display 194, and a subscriber identity module (SIM) card interface 195, etc. The sensor module 180 may include a pressure sensor 180A, a gyro sensor 180B, an air pressure sensor 180C, a magnetic sensor 180D, an acceleration sensor 180E, a distance sensor 180F, an optical proximity sensor 180G, a fingerprint sensor 180H, a temperature sensor 180J, a touch sensor 180K, an ambient light sensor 180L, and a bone conduction sensor 180M, among others.
[0106] It can be understood that the structure shown in this embodiment of the invention does not constitute a particular limitation on the electronic device 100. In some other embodiments of the present application, the electronic device 100 may include more or fewer components than those shown in the figures, some components may be combined, some components may be divided, or there may be a different component layout. The components shown in the figures may be implemented using hardware, software, or a combination of software and hardware.
[0107] 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 separate components or may be integrated into one or more processors.
[0108] The controller may be the brain and command center of the electronic device 100. The controller may generate operation control signals based on the instruction operation codes and time series signals to control the reading and execution of instructions.
[0109] Memory may further be disposed in the processor 110 for storing instructions and data. In some embodiments, the memory in the processor 110 is a cache. This memory may store instructions or data that are being used or are used periodically by the processor 110. When the processor 110 needs to use the instructions or data again, the processor may retrieve the instructions or data directly from the memory. This avoids repeated accesses, reduces the latency of the processor 110, and improves system efficiency.
[0110] In some embodiments, the processor 110 may include one or more interfaces, which 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, etc.
[0111] The I2C interface is a bidirectional synchronous serial bus and includes a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 110 may include multiple groups of I2C buses. The processor 110 may be separately coupled to the touch sensor 180K, the charger, the flash, the camera 193, and the like through different I2C interfaces. For example, the processor 110 may be coupled to the touch sensor 180K through an I2C interface, such that the processor 110 communicates with the touch sensor 180K through the I2C interface to implement the touch function of the electronic device 100.
[0112] The I2S interface may be used for audio communication. In some embodiments, the processor 110 may include multiple groups of I2S buses. The processor 110 may be coupled to the audio module 170 via the I2S bus to implement communication between the processor 110 and the audio module 170. In some embodiments, the audio module 170 may transmit audio signals to the wireless communication module 160 via the I2S interface to implement a function of answering a call via a Bluetooth headset.
[0113] The PCM interface may also be used for audio communication, as well as sampling, quantization, and encoding of analog signals. In some embodiments, audio module 170 may be coupled to wireless communication module 160 via the PCM interface. In some embodiments, audio module 170 may alternatively transmit audio signals to wireless communication module 160 via the PCM interface to perform functions such as answering a call via a Bluetooth headset. Both the I2S interface and the PCM interface may be used for audio communication.
[0114] The UART interface is a universal serial data bus and is used for asynchronous communication. The bus may be a bidirectional communication bus. The bus converts the transmitted data between serial and parallel communication. In some embodiments, the UART interface is generally configured to connect the processor 110 to the wireless communication module 160. For example, the processor 110 communicates with a Bluetooth module in the wireless communication module 160 via the UART interface to perform Bluetooth functions. In some embodiments, the audio module 170 may transmit audio signals to the wireless communication module 160 via the UART interface to perform a function of playing music via a Bluetooth headset.
[0115] The MIPI interface may be configured to connect the processor 110 to peripheral components such as a display 194 or a camera 193. The MIPI interface includes a camera serial interface (CSI) and a display serial interface (DSI), etc. In some embodiments, the processor 110 communicates with the camera 193 via the CSI interface to perform a capture function of the electronic device 100. The processor 110 communicates with the display 194 via the DSI interface to perform a display function of the electronic device 100.
[0116] The GPIO interface may be configured using software. The GPIO interface may be configured to transmit or receive control signals or to transmit or receive data signals. In some embodiments, the GPIO interface may be configured to connect the processor 110 to the camera 193, the display 194, the wireless communication module 160, the audio module 170, or the sensor module 180, or the like. The GPIO interface may alternatively be configured as an I2C interface, an I2S interface, a UART interface, or a MIPI interface, or the like.
[0117] The USB interface 130 is an interface that complies with the USB standard specification, and specifically may be a Mini USB interface, a Micro USB interface, a USB Type C interface, etc. The USB interface 130 may be configured to connect to a charger to charge the electronic device 100, or may be configured to transmit data between the electronic device 100 and a peripheral device, or may be configured to connect to a headset to play audio via a headset. This interface may alternatively be configured to connect to another electronic device, such as an AR device.
[0118] It can be understood that the interface connection relationships between modules in this embodiment of the present invention are merely illustrative examples and do not constitute limitations on the structure of the electronic device 100. In some other embodiments of the present application, the electronic device 100 may alternatively have an interface connection mode different from the above-described embodiment or may use a combination of multiple interface connection modes.
[0119] The charging management module 140 is configured to receive a charging input from a charger. The charger may be a wireless charger or a wired charger. In some embodiments where wired charging is used, the charging management module 140 may receive a charging input from the wired charger via the USB interface 130. In some embodiments where wireless charging is used, the charging management module 140 may receive a wireless charging input via a wireless charging coil of the electronic device 100. The charging management module 140 may further provide power to the electronic device via the power management module 141 while charging the battery 142.
[0120] The power management module 141 is connected to 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, the wireless communication module 160, and the like. The power management module 141 may be further configured to monitor parameters such as battery capacity, battery cycle count, and battery health (leakage and impedance). In some other embodiments, the power management module 141 may alternatively be located in the processor 110. In some other embodiments, the power management module 141 and the charging management module 140 may alternatively be located in the same device.
[0121] The wireless communication functions of the electronic device 100 may be implemented by antenna 1, antenna 2, mobile communication module 150, wireless communication module 160, a modem processor, a baseband processor, and the like.
[0122] Antenna 1 and Antenna 2 are configured to transmit and receive electromagnetic wave signals. Each antenna of electronic device 100 may be configured to cover one or more communication frequency bands. Different antennas may be further multiplexed to improve antenna utilization. For example, Antenna 1 may be multiplexed as a diversity antenna in a wireless local area network. In some other embodiments, the antennas may be used in combination with tuning switches.
[0123] The mobile communication module 150 may provide a solution applied to the electronic device 100 for wireless communication such as 2G / 3G / 4G / 5G. The mobile communication module 150 may include at least one filter, switch, power amplifier, and low noise amplifier (LNA), etc. The mobile communication module 150 may receive electromagnetic waves via the antenna 1, perform processing such as filtering or amplification on the received electromagnetic waves, and transmit the electromagnetic waves to the modem processor for demodulation. The mobile communication module 150 may further amplify the signal modulated by the modem processor and convert the signal to electromagnetic waves for emission via the antenna 1. In some embodiments, at least some functional modules of the mobile communication module 150 may be disposed in the processor 110. In some embodiments, at least some functional modules of the mobile communication module 150 may be disposed in the same device as at least some modules of the processor 110.
[0124] The modem processor may include a modulator and a demodulator. The modulator is configured to modulate a low-frequency baseband signal to be transmitted into a medium or high-frequency signal. The demodulator is configured to demodulate a received electromagnetic signal into a low-frequency baseband signal. The demodulator then transmits the low-frequency baseband signal obtained by demodulation to a baseband processor for processing. The low-frequency baseband signal is processed by the baseband processor and then transmitted to an application processor. The application processor outputs an audio signal via an audio device (such as but not limited to a speaker 170A and a receiver 170B) or displays an image or video on a display 194. In some embodiments, the modem processor may be an independent device. In some other embodiments, the modem processor may be independent from the processor 110 and is located in the same device as the mobile communication module 150 or another functional module.
[0125] The wireless communication module 160 may provide a solution applied to the electronic device 100 for wireless communication, such as wireless local area networks (WLAN) (e.g., wireless fidelity (Wi-Fi) networks), bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC) technology, or infrared (IR) technology. The wireless communication module 160 may be one or more devices incorporating at least one communication processor module. The wireless communication module 160 receives electromagnetic waves via the antenna 2, performs frequency modulation and filtering on the electromagnetic wave signals, and transmits the processed signals to the processor 110. The wireless communication module 160 may further receive signals to be transmitted from the processor 110, perform frequency modulation and amplification on the signals, and convert the signals into electromagnetic waves for radiation via the antenna 2.
[0126] In some embodiments, in electronic device 100, antenna 1 is coupled to mobile communication module 150 and antenna 2 is coupled to wireless communication module 160, allowing electronic device 100 to communicate with a network and other devices using wireless communication technologies. The wireless communication technologies 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 technologies, etc. GNSS may include global positioning system (GPS), global navigation satellite system (GLONASS), beidou navigation satellite system (BDS), quasi-zenith satellite system (QZSS), and / or satellite based augmentation systems (SBAS).
[0127] The electronic device 100 performs display functions by means of a GPU, a display 194, an application processor, and the like. The GPU is a microprocessor for image processing and is connected to the display 194 and the application processor. The GPU is configured to perform mathematical and geometric operations and render images. The processor 110 may include one or more GPUs that execute program instructions to generate or modify display information.
[0128] The display 194 is configured to display images, videos, or the like. The display 194 includes a display panel. The display panel may 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, MicroLed, Micro-oLed, or a quantum dot light emitting diode (QLED), or the like. In some embodiments, the electronic device 100 may include one or N displays 194, where N is a positive integer greater than 1.
[0129] The electronic device 100 may perform image capture functions via an ISP, a camera 193, a video codec, a GPU, a display 194, an application processor, and the like.
[0130] The ISP is configured to process data fed back by the camera 193. For example, when taking a picture, the shutter is pressed and light is sent through the lens to the camera's photosensitive elements. The light signal is converted into an electrical signal, which the camera's photosensitive elements transmit to the ISP for processing to convert the electrical signal into a visible image. The ISP may further perform algorithmic optimization on noise, brightness, and aspect of the image. The ISP may further optimize parameters such as exposure and color temperature for the shooting scenario. In some embodiments, the ISP may be located in the camera 193.
[0131] The camera 193 is configured to capture still images or videos. An optical image of an object is generated through a lens and projected onto a photosensitive element. The photosensitive element may be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor. The photosensitive element converts the optical signal into an electrical signal, which then transmits the electrical signal to the ISP for converting the electrical signal 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 format, for example, RGB or YUV. In some embodiments, the electronic device 100 may include one or N cameras 193, where N is a positive integer greater than 1.
[0132] The digital signal processor is configured to process digital signals and may process other digital signals in addition to the digital image signal. For example, when the electronic device 100 selects a frequency, the digital signal processor is configured to perform a Fourier transform on the frequency energy.
[0133] A video codec is configured to compress or decompress digital video. Electronic device 100 may support one or more types of video codecs. Thus, electronic device 100 may play or record video in multiple encoding formats, e.g., moving picture experts group (MPEG) 1, MPEG 2, MPEG 3, and MPEG 4.
[0134] The NPU is a neural-network (NN) computing processor. The NPU can quickly process input information by referring to the structure of biological neural networks, such as the transmission mode between human brain neurons, and can also continuously perform self-learning. Applications such as intelligent recognition of the electronic device 100, such as image recognition, face recognition, speech recognition, and text understanding, can be implemented by the NPU.
[0135] The external memory interface 120 can be connected to an external storage card, such as a Micro SD card, to expand the storage capabilities of the electronic device 100. The external storage card communicates with the processor 110 via the external memory interface 120 to perform data storage functions. For example, files such as music and videos are stored on the external storage card.
[0136] The internal memory 121 may be configured to store computer executable program code. The executable program code includes instructions. The processor 110 executes various functional applications and data processing of the electronic device 100 by operating the instructions stored in the internal memory 121. The internal memory 121 may include a program storage area and a data storage area. The program storage area may store an operating system and applications required by at least one function (e.g., a sound playback function or an image playback function), etc. The data storage area may store data (such as audio data and an address book) created during use of the electronic device 100, etc. In addition, the internal memory 121 may include a high-speed random access memory, or may include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory, or a universal flash storage (UFS).
[0137] The electronic device 100 may perform audio functions, such as music playback and recording, via an audio module 170, a speaker 170A, a receiver 170B, a microphone 170C, a headset jack 170D, and an application processor.
[0138] The audio module 170 is configured to convert digital audio information to an analog audio signal output, and is also configured to convert an analog audio input to a digital audio signal. The audio module 170 may be further configured to encode and decode the audio signal. In some embodiments, the audio module 170 may be located in the processor 110, or some functional modules of the audio module 170 are located in the processor 110.
[0139] Speaker 170A, also referred to as a "loudspeaker," is configured to convert electrical audio signals into voice signals. Electronic device 100 may listen to music or answer hands-free calls through speaker 170A.
[0140] Receiver 170B, also referred to as an "earpiece," is configured to convert electrical audio signals into speech signals. When a call is answered or audio information is listened to using electronic device 100, receiver 170B may be brought close to a human ear to listen to the voice.
[0141] The microphone 170C, also referred to as a "microphone" or "mic", is configured to convert audio signals into electrical signals. When making a call or sending a voice message, a user may speak by the user's mouth in the vicinity of the microphone 170C to input the audio signal into the microphone 170C. At least one microphone 170C may be disposed on the electronic device 100. In some other embodiments, two microphones 170C may be disposed on the electronic device 100 to capture audio signals and further perform noise reduction functions. In some other embodiments, three, four, or more microphones 170C may alternatively be disposed on the electronic device 100 to capture audio signals, perform noise reduction, identify sound sources, and perform directional recording functions, etc.
[0142] The headset jack 170D is used to connect a wired headset, and may be a USB interface 130, or a 3.5 mm open mobile terminal platform (OMTP) standard interface or a cellular telecommunications industry association of the USA (CTIA) standard interface.
[0143] The pressure sensor 180A is configured to sense a pressure signal and may convert the pressure signal into an electrical signal. In some embodiments, the pressure sensor 180A may be disposed on the display 194. There are multiple types of pressure sensors 180A, such as resistive pressure sensors, inductive pressure sensors, and capacitive pressure sensors. The capacitive pressure sensor may include at least two parallel plates made of a conductive material. When a force is applied to the pressure sensor 180A, a capacitance between the electrodes changes. The electronic device 100 determines the pressure intensity based on the change in capacitance. When a touch operation is performed on the display 194, the electronic device 100 detects the intensity of the touch operation based on the pressure sensor 180A. The electronic device 100 may calculate the touch position based on the detection signal of the pressure sensor 180A. In some embodiments, touch operations performed at the same touch position but with different touch operation intensities may correspond to different operation instructions. For example, when a touch operation with a touch operation intensity less than a first pressure threshold is performed on a message icon, an instruction to view an SMS message is executed. When a touch is performed on the message icon with a touch strength equal to or greater than a first pressure threshold, instructions are executed to compose a new SMS message.
[0144] The gyro sensor 180B may be configured to determine the motion attitude of the electronic device 100. In some embodiments, the angular velocity of the electronic device 100 around three axes (i.e., x-axis, y-axis, and z-axis) may be determined using the gyro sensor 180B. The gyro sensor 180B may be configured to perform image stabilization when taking a picture. For example, when the shutter is pressed, the gyro sensor 180B detects the angle at which the electronic device 100 is shaken, and based on this angle, calculates the distance that the lens module needs to compensate, allowing the lens to offset the shake of the electronic device 100 by the reverse motion, in order to perform image stabilization. The gyro sensor 180B may further be used in navigation scenarios and physical game scenarios.
[0145] The air pressure sensor 180C is configured to measure air pressure. In some embodiments, the electronic device 100 calculates an altitude based on the air pressure value measured by the air pressure sensor 180C to assist in positioning and navigation.
[0146] The magnetic sensor 180D includes a Hall effect sensor. The electronic device 100 may use the magnetic sensor 180D to detect the opening and closing of the flip cover. In some embodiments, when the electronic device 100 is a flip phone, the electronic device 100 may detect the opening and closing of the flip cover based on the magnetic sensor 180D. Furthermore, features such as automatic unlocking when the flip cover is opened are set based on the detected opening and closing state of the flip cover.
[0147] The acceleration sensor 180E can detect acceleration in various directions (typically on three axes) of the electronic device 100, can detect the magnitude and direction of gravity when the electronic device 100 is stationary, and can be further configured to recognize the orientation of the electronic device, which can be used for applications such as landscape / portrait mode switching and pedometer.
[0148] The distance sensor 180F is configured to measure distance. The electronic device 100 may measure distance using infrared or laser. In some embodiments, in a photography scenario, the electronic device 100 may measure distance using the distance sensor 180F to perform quick focusing.
[0149] The optical proximity 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 uses the light emitting diode to emit infrared light. The electronic device 100 uses the photodiode to detect infrared reflected light from a nearby object. When sufficient reflected light is detected, it may be determined that there is an object in the vicinity of the electronic device 100. When insufficient reflected light is detected, the electronic device 100 may determine that there is no object in the vicinity of the electronic device 100. The electronic device 100 may use the optical proximity sensor 180G to detect when a user holds the electronic device 100 close to the ear for a call in order to automatically turn off the screen to save power. The optical proximity sensor 180G may also be used in smart cover mode or pocket mode for automatic screen unlock or lock.
[0150] The ambient light sensor 180L is configured to sense the brightness of the ambient light. The electronic device 100 may adaptively adjust the brightness of the display 194 based on the sensed brightness of the ambient light. The ambient light sensor 180L may also be configured to automatically adjust the white balance when taking a picture. The ambient light sensor 180L may cooperate with the optical proximity sensor 180G to detect whether the electronic device 100 is in a pocket to avoid accidental touches.
[0151] Fingerprint sensor 180H is configured to capture a fingerprint. Electronic device 100 may use the captured fingerprint characteristics to implement fingerprint-based unlocking, application lock access, fingerprint-based photography, fingerprint-based call answering, and the like.
[0152] The temperature sensor 180J is configured to detect temperature. In some embodiments, the electronic device 100 executes a temperature handling policy using the temperature detected by the temperature sensor 180J. For example, when the temperature reported by the temperature sensor 180J exceeds a threshold, the electronic device 100 reduces the performance of the processor in the vicinity of the temperature sensor 180J to reduce power consumption and implement thermal protection. In some other embodiments, when the temperature is below another threshold, the electronic device 100 heats the battery 142 to prevent the electronic device 100 from abnormally shutting down due to low temperature. In some other embodiments, when the temperature is below yet another threshold, the electronic device 100 boosts the output voltage of the battery 142 to avoid abnormal shutdown due to low temperature.
[0153] The touch sensor 180K is also referred to as a "touch panel." The touch sensor 180K may be disposed on the display 194, and the touch sensor 180K and the display 194 constitute a touch screen, also referred to as a "touch control screen." The touch sensor 180K is configured to detect touch operations performed on or near the touch sensor. The touch sensor may transmit the detected touch operations to an application processor to determine a type of touch event. A visual output related to the touch operation may be provided using the display 194. In some other embodiments, the touch sensor 180K may alternatively be disposed on the surface of the electronic device 100 at a location different from the location of the display 194.
[0154] The bone conduction sensor 180M may obtain a vibration signal. In some embodiments, the bone conduction sensor 180M may obtain a vibration signal of the vibrating bone of the human vocal cord part. The bone conduction sensor 180M may also contact the pulse of the body to receive a blood pressure pulsation signal. In some embodiments, the bone conduction sensor 180M may alternatively be disposed in a headset to obtain a bone conduction headset. The audio module 170 may obtain a speech signal by analysis based on the vibration signal of the vibrating bone of the vocal cord part obtained by the bone conduction sensor 180M to perform a speech function. The application processor may analyze heartbeat information based on the blood pressure pulsation signal obtained by the bone conduction sensor 180M to perform a heartbeat detection function.
[0155] The buttons 190 include a power button, a volume button, etc. The buttons 190 may be mechanical buttons or touch buttons. The electronic device 100 may receive inputs to the buttons and generate button signal inputs related to user settings and function control of the electronic device 100.
[0156] The motor 191 may generate a vibration prompt. The motor 191 may be configured to provide an incoming vibration prompt or touch vibration feedback. For example, touch operations performed for different applications (e.g., taking pictures and playing audio) may correspond to different vibration feedback effects. The motor 191 may also correspond to different vibration feedback effects for touch operations performed in different areas of the display 194. Different application scenarios (e.g., time reminders, information reception, alarm clocks, and games) may also correspond to different vibration feedback effects. The touch vibration feedback effects may be further customized.
[0157] The indicator 192 may be an indicator light and may be configured to indicate charging status and battery level changes, or may be configured to indicate messages, missed calls, notifications, and the like.
[0158] The SIM card interface 195 is used to connect a SIM card. The SIM card can be inserted into or removed from the SIM card interface 195 to perform contact with or separation from the electronic device 100. The electronic device 100 can support one or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 195 can support a Nano SIM card, a Micro SIM card, and a SIM card, etc. Multiple cards can be inserted into the same SIM card interface 195 at the same time. The multiple cards can be of the same type or different types. The SIM card interface 195 is also compatible with different types of SIM cards. The SIM card interface 195 is also compatible with an external storage card. The electronic device 100 interacts with the network through the SIM card to perform functions such as calling and data communication. In some embodiments, the electronic device 100 uses an eSIM, i.e., an internal SIM card. The eSIM card may be built into the electronic device 100 and cannot be separated from the electronic device 100.
[0159] The software system of the electronic device 100 may use a layered architecture, an event-driven architecture, a microkernel architecture, a microservices architecture, or a cloud architecture. In the embodiment of the present invention, the Android system having a layered architecture is used as an example to illustrate the software structure of the electronic device 100.
[0160] FIG. 6 is a block diagram of the software architecture of an electronic device 100 (eg, a mobile phone) according to one embodiment of the present invention.
[0161] In a layered architecture, the software is divided into several layers, each of which has a clear role and task. The layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers from top to bottom: application layer, application framework layer, Android runtime and system libraries, and kernel layer.
[0162] The application layer may include a series of application packages.
[0163] As shown in FIG. 6, the application package may include applications such as camera, gallery, calendar, phone, maps, navigation, WLAN, Bluetooth, music, video, and messaging.
[0164] The application framework layer provides an application programming interface (API) and a programming framework for the applications in the application layer. The application framework layer includes some predetermined functions.
[0165] As shown in FIG. 6, the application framework layer may include a window manager, a content provider, a view system, a telephone manager, a resource manager, a notification manager, and the like.
[0166] A window manager is configured to manage window programs. The window manager may get the size of the display, determine if there is a status bar, perform screen locking, take screenshots, etc.
[0167] Content providers are configured to store and retrieve data and enable the data to be accessed by applications. Data may include video, images, audio, calls made and answered, browsing history, bookmarks, address books, and the like.
[0168] The view system includes visual controls, such as a control for displaying text and a control for displaying pictures. The view system can be configured to build applications. A display interface can include one or more views. For example, a display interface that includes an SMS message notification icon can include a text display view and a picture display view.
[0169] The telephone manager is configured to provide communication functions for the electronic device 100, such as managing call status (including answering or ending a call, etc.).
[0170] The resource manager provides various resources to an application, such as localized strings, icons, pictures, layout files, and video files.
[0171] The notification manager may be configured to allow applications to display notification information in the status bar and to communicate notification messages. The notification manager may disappear automatically after a short pause without user interaction. For example, the notification manager may be configured to indicate download completion or provide a message notification. The notification manager may alternatively be a notification that appears in the form of a graph or scrollbar text in the top status bar of the system, e.g., a notification of an application running in the background, or a notification that appears on the screen in the form of a dialog window. For example, text information may be displayed in the status bar, a prompt tone may be played, the electronic device may vibrate, or an indicator may flash.
[0172] The Android Runtime includes the kernel library and virtual machine, and schedules and manages the Android system.
[0173] The kernel library contains two parts: the functions that need to be called in java language and the android kernel library.
[0174] The application layer and the application framework layer run on a virtual machine. The virtual machine executes the java files of the application layer and the application framework layer as binary files. The virtual machine is configured to perform functions such as object life cycle management, stack management, thread management, security and exception management, and garbage collection.
[0175] The system library may include multiple functional modules, for example, a surface manager, media libraries, a three-dimensional graphics processing library (eg, OpenGL ES), and a 2D graphics engine (eg, SGL).
[0176] The surface manager is configured to manage the display subsystem and provide a blend of 2D and 3D layers for multiple applications.
[0177] The media library supports the playback and recording of multiple commonly used audio and video formats as well as still image files, etc. The media library may support multiple audio and video encoding formats, e.g., MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG.
[0178] The 3D graphics processing library is configured to perform 3D graphics drawing, image rendering, composition, layer processing, and the like.
[0179] The 2D graphics engine is a drawing engine for 2D drawing.
[0180] The kernel layer is a layer between the hardware and the software, and includes at least a display driver, a camera driver, an audio driver, and a sensor driver.
[0181] The following describes an exemplary operating process of the software and hardware of the electronic device 100 with reference to a shooting scenario.
[0182] When the touch sensor 180K receives a touch operation, a corresponding hardware interrupt is sent to the kernel layer. The kernel layer processes the touch operation into a raw input event (including information such as touch coordinates and a timestamp of the touch operation). 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 a control corresponding to the input event. For example, the touch operation is a tap operation, and the control corresponding to the tap operation is a control of an icon of a camera application. To capture a still image or video using the camera 193, the camera application calls an interface of the application framework layer to launch the camera application, and further calls the kernel layer to launch a camera driver.
[0183] FIG. 7 is a schematic diagram of an exemplary hardware structure of an audio playback device 200.
[0184] FIG. 7 is a schematic diagram of an exemplary structure of an audio playback device 200 (eg, a Bluetooth device) according to one embodiment of the present application.
[0185] The following describes the embodiment in detail using an example in which the audio playback device 200 is a Bluetooth device. It should be understood that the audio playback device 200 shown in Fig. 7 is only an example, and the audio playback device 200 may include more or less components than those shown in Fig. 7, two or more components may be combined, or there may be a different component configuration. The components shown in the figure may be implemented in hardware, including one or more signal processing and / or application specific integrated circuits, software, or a combination of hardware and software.
[0186] As shown in FIG. 7, 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.
[0187] The processor 201 may be configured to read and execute computer-readable instructions. In a specific implementation, the processor 201 may mainly include a controller, an arithmetic unit, and a register. The controller mainly decodes instructions and sends control signals for operations corresponding to the instructions. The arithmetic unit mainly stores register operands and intermediate operation results that are temporarily stored during instruction execution, etc. In a specific implementation, the hardware architecture of the processor 201 may be an application-specific integrated circuit (ASIC) architecture, a MIPS architecture, an ARM architecture, or an NP architecture, etc.
[0188] In some embodiments, the processor 201 may be configured to analyze a signal received by the Bluetooth communication module 203, such as a pairing mode change request sent by the electronic device 100. The processor 201 may be configured to perform a corresponding processing operation based on the analysis result, such as generating a pairing mode change response.
[0189] The memory 202 is coupled to the processor 201 and configured to store various software programs and / or groups of instructions. In a specific implementation, the memory 202 may include a high-speed random access memory and may also include a non-volatile memory, such as one or more magnetic disk storage devices, flash storage devices, or another non-volatile solid-state storage device. The memory 202 may store an operating system, such as an embedded operating system, such as uCOS, VxWorks, or RTLinux. The memory 202 may further store a communication program. The communication program may be used to communicate with the electronic device 100, one or more servers, or another device.
[0190] The Bluetooth communication module 203 may include a classic Bluetooth (BT) module and a Bluetooth Low Energy (BLE) module.
[0191] In some embodiments, the Bluetooth communication module 203 may obtain a signal, such as a detection request or scan signal, transmitted by another device (e.g., electronic device 100) by listening, and may transmit a response signal or scan response, etc., thereby allowing the other device (e.g., electronic device 100) to discover the audio playback device 200, and the audio playback device 200 to establish a wireless communication connection to the other device (e.g., electronic device 100) and communicate with the other device (e.g., electronic device 100) via Bluetooth.
[0192] In some other embodiments, the Bluetooth communication module 203 may alternatively transmit a signal, such as broadcasting a BLE signal, so that another device (e.g., electronic device 100) can discover the audio playback device 200, and the audio playback device 200 can establish a wireless communication connection to the other device (e.g., electronic device 100) and communicate with the other device (e.g., electronic device 100) via Bluetooth.
[0193] The wireless communication functionality of the audio playback device 200 may be implemented by an antenna 204, a Bluetooth communication module 203, a modem processor, or the like.
[0194] The antennas 204 may be configured to transmit and receive electromagnetic signals. Each antenna in the audio reproduction device 200 may be configured to cover one or more communication frequency bands.
[0195] In some embodiments, the Bluetooth communication module 203 may include one or more antennas.
[0196] The power switch 205 may be configured to control a power source to provide power to the audio reproduction device 200 .
[0197] The USB communications processing module 206 may be configured to communicate with another device via a USB interface (not shown). In some embodiments, the audio playback device 200 may alternatively not include the USB communications processing module 206.
[0198] The audio module 207 may be configured to output an audio signal via an audio output interface so that the audio playback device 200 can support audio playback. The audio module may be further configured to receive audio data via an audio input interface. The audio playback device 200 may be a media playback device such as a Bluetooth headset.
[0199] In some embodiments, the audio playback device 200 may further include a display (not shown). The display may be configured to display images, prompt information, etc. The display may be a liquid crystal display (LCD), an organic light-emitting diode (OLED) display, an active-matrix organic light-emitting diode (AMOLED) display, a flexible light-emitting diode (FLED) display, or a quantum dot light emitting diodes (QLED) display, etc.
[0200] In some embodiments, audio playback device 200 may further include a serial interface, such as an RS-232 interface, which may be connected to another device, for example an audio loudspeaker device, such as a speaker, such that audio playback device 200 and the audio loudspeaker device cooperate to play audio or video.
[0201] It can be understood that the structure shown in Figure 7 does not constitute a particular limitation on audio reproduction device 200. In some other embodiments of the present application, audio reproduction device 200 may include more or fewer components than those shown in the figure, some components may be combined, some components may be split, or there may be a different component layout. The components shown in the figure may be implemented using hardware, software, or a combination of software and hardware.
[0202] Before electronic device 100 establishes a communication connection to audio playback device 200, electronic device 100 classifies all encoders within electronic device 100 into multiple categories based on a codec classification standard, and audio playback device 200 classifies all decoders within audio playback device 200 into multiple categories.
[0203] In some embodiments, electronic device 100 and audio playback device 200 may alternatively classify one or more codecs in electronic device 100 and audio playback device 200 into multiple categories after establishing a communication connection. The time at which electronic device 100 and audio playback device 200 classify one or more codecs is not limited by this application.
[0204] The following provides a detailed description of the codec classification standard and how the electronic device 100 and the audio playback device 200 classify codecs within the electronic device 100 and the audio playback device 200 into multiple categories based on the codec classification standard.
[0205] Codec Classification Standards The codec classification standard may be obtained based on one or a combination of two or more of the following parameters: sampling rate, quantization bit depth, bit rate, and number of audio channels, etc. For example, the codec classification standard may be obtained based on one of the following parameters: sampling rate, quantization bit depth, bit rate, and number of audio channels, etc., for example, the parameter may be sampling rate, or the codec classification standard may be obtained based on two parameters, for example, the two parameters may be sampling rate and quantization bit depth, or the codec classification standard may be obtained based on three parameters, for example, the three parameters may be sampling rate, quantization bit depth, and bit rate, or the codec classification standard may be obtained based on four parameters, for example, the four parameters may be sampling rate, quantization bit depth, bit rate, and number of audio channels. The type of parameters used in the codec classification standard is not limited in this application. Another parameter, for example, audio format, may alternatively be used in the codec classification standard. This is not limited here in this application. For example, the codec classification standard is pre-configured in the electronic device 100 and the audio playback device 200 .
[0206] The sampling rate is the number of samples of an audio signal per unit of time (e.g., 1 second). A higher sampling rate indicates higher audio recovery and higher sound quality.
[0207] Quantization bit depth is the quantization precision and determines the dynamic range of digital audio. During frequency sampling, a higher quantization bit depth can provide more possible amplitude values to obtain a larger vibration range, a higher signal-to-noise ratio, and higher fidelity.
[0208] Bit rate indicates the number of bits transmitted per unit of time, measured in bits per second or gigabits per second. A higher bit rate indicates a larger amount of audio data transmitted per second and a higher resolution sound quality.
[0209] The number of audio channels is the number of speakers capable of producing the different sounds supported, including mono, dual, 2.1 channel, 5.1 channel, 7.1 channel, etc.
[0210] At present, the format of audio data is usually PCM data format. PCM (pulse code modulation) data format is an uncompressed audio data stream, which is a standard digital audio data obtained by converting an analog signal through sampling, quantization and encoding. The audio data format further includes MP3 data format, MPEG data format, MPEG-4 data format, WAVE data format, CD data format, etc.
[0211] As explained above, in the codec classification standard, codecs are classified based on the value range of one or more parameters.
[0212] For example, when a codec classification standard is obtained based on a sampling rate, the sampling rate can be divided into a plurality of segments based on the minimum sampling rate and the maximum sampling rate of the codecs frequently used in the device, and the values of the sampling rates of the segments are different. Specifically, when the value of the sampling rate of a codec is greater than or equal to a first sampling rate, the codec is classified into category 1; when the value of the sampling rate of the codec is less than the first sampling rate and greater than or equal to a second sampling rate, the codec is classified into category 2; when the value of the sampling rate of the codec is less than the second sampling rate, the codec is classified into category 3. The first sampling rate is greater than the second sampling rate.
[0213] For example, when a codec classification standard is obtained based on a sampling rate and a bit rate, the sampling rate and the bit rate can be divided into a plurality of segments based on the minimum sampling rate, the maximum sampling rate, the minimum bit rate, and the maximum bit rate of the codecs frequently used in the device. Specifically, when the value of the sampling rate of a codec is greater than or equal to a first sampling rate and the value of the bit rate of the codec is greater than or equal to a first bit rate, the codec is classified into category 1; when the value of the sampling rate of the codec is less than the first sampling rate and greater than or equal to a second sampling rate and the value of the bit rate of the codec is less than the first bit rate and greater than or equal to a second bit rate, the codec is classified into category 2; when the value of the sampling rate of the codec is less than the second sampling rate and the value of the bit rate of the codec is less than the second bit rate, the codec is classified into category 3. The first sampling rate is greater than the second sampling rate, and the first bit rate is greater than the second bit rate.
[0214] For example, when a codec classification standard is obtained based on sampling rate, bit rate, and quantization bit depth, the sampling rate, bit rate, and quantization bit depth may be divided into multiple segments based on the minimum sampling rate, maximum sampling rate, minimum bit rate, maximum bit rate, minimum quantization bit depth, and maximum quantization bit depth of the codecs frequently used in the device. Specifically, when the codec sampling rate value is equal to or greater than the first sampling rate, the codec bit rate value is equal to or greater than the first bit rate, and the codec quantization bit depth value is equal to or greater than the first quantization bit depth, the codec is classified into category 1; when the codec sampling rate value is less than the first sampling rate and equal to or greater than the second sampling rate, the codec bit rate value is less than the first bit rate and equal to or greater than the second bit rate, and the codec quantization bit depth value is less than the first quantization bit depth and equal to or greater than the second quantization bit depth, the codec is classified into category 2; and when the codec sampling rate value is less than the second sampling rate, the codec bit rate value is less than the second bit rate, and the codec quantization bit depth value is less than the second quantization bit depth, the codec is classified into category 3. 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.
[0215] For example, when a codec classification standard is obtained based on the sampling rate, bit rate, quantization bit depth, and number of audio channels, the sampling rate, bit rate, quantization bit depth, and number of audio channels may be divided into multiple segments based on the minimum sampling rate, maximum sampling rate, minimum bit rate, maximum bit rate, minimum quantization bit depth, maximum quantization bit depth, and the minimum number of audio channels commonly used (e.g., dual) of the codec frequently used in the device. Specifically, when the value of the sampling rate of the codec is equal to or greater than the first sampling rate, the value of the bit rate of the codec is equal to or greater than the first bit rate, the value of the quantization bit depth of the codec is equal to or greater than the first quantization bit depth, and the value of the number of audio channels of the codec is equal to or greater than the first number of audio channels, the codec is classified into category 1; when the value of the sampling rate of the codec is less than the first sampling rate and equal to or greater than the second sampling rate, the value of the bit rate of the codec is less than the first bit rate and equal to or greater than the second bit rate, the codec is classified into category 2; When the value of the quantization bit depth of the codec is less than the first quantization bit depth and greater than or equal to the second quantization bit depth and the value of the number of audio channels of the codec is greater than or equal to the first number of audio channels, the codec is classified into category 2, and when the value of the sampling rate of the codec is less than the second sampling rate, the value of the bit rate of the codec is less than the second bit rate, the value of the quantization bit depth of the codec is less than the second quantization bit depth and the value of the number of audio channels of the codec is greater than or equal to the first number of audio channels, the codec is classified into category 3. 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.
[0216] The above only shows some codec classification standards as examples. In specific implementation, the codec classification standards may be set according to different requirements. In this application, examples are not listed one by one.
[0217] The following describes how the electronic device 100 and the audio playback device 200 classify the encoders in the electronic device 100 and the decoders in the audio playback device 200 into multiple categories based on codec classification standards.
[0218] After obtaining the codec classification standard, the electronic device 100 classifies all the encoders into multiple categories, and the audio playback device 200 classifies all the decoders into multiple categories.
[0219] Specifically, for the electronic device 100, the electronic device 100 obtains a codec classification standard, in which codecs may be classified into multiple categories based on information about one or more parameters of the codec.
[0220] Next, the electronic device 100 obtains values of one or more parameters corresponding to all encoders in the electronic device 100. When the values of one or more parameters corresponding to an encoder in the electronic device 100 are within the range of values of one or more parameters used in the codec classification standard, the electronic device 100 classifies the encoder into one or more categories. By analogy, the electronic device 100 classifies all encoders into one or more categories according to the aforementioned method. It should be noted that one encoder may be classified into multiple categories. The electronic device 100 records an encoder identifier corresponding to each category. For example, the category obtained based on the codec classification standard is category 1, and the encoder identifier corresponding to category 1 includes encoder 1 and encoder 2.
[0221] The method for classifying all decoders into multiple categories by the audio playback device 200 is consistent with the method for classifying all encoders into multiple categories by the electronic device 100. In this application, the details will not be described again here. The audio playback device 200 records the decoder identifiers corresponding to each category. For example, the category obtained according to the codec classification standard is category 1, and the decoder identifiers corresponding to category 1 include decoder 1 and decoder 2.
[0222] With reference to a particular example, the following describes a codec classification standard and a particular implementation for classifying encoders into categories by electronic device 100 and for classifying decoders into categories by audio playback device 200.
[0223] In an optional implementation, the codec classification standard may be obtained based on the sampling rate.
[0224] Table 1 shows an exemplary codec classification standard obtained based on sampling rate.
[0225] [Table 1]
[0226] As shown in Table 1, when the value of one or more sampling rates supported by the codec is equal to or greater than 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 and equal to or greater than the second sampling rate, the codec belongs to category 2, and 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.
[0227] In specific implementation, first, the electronic device 100 obtains the values of sampling rates supported by all encoders in the electronic device 100. Based on the values of sampling rates supported by all encoders in the electronic device 100, the electronic device 100 classifies the encoders into categories shown in Table 1. It should be noted that one encoder may be classified into multiple categories.
[0228] Table 2 shows an example in which the electronic device 100 and the audio playback device 200 classify codecs within the electronic device 100 and the audio playback device 200 into categories based on sampling rate.
[0229] [Table 2]
[0230] It can be understood that the encoder and decoder identifiers shown in this embodiment of the present application may alternatively be represented in binary, for example, encoder 1 may alternatively be represented as e001, encoder 2 may alternatively be represented as e010, encoder 3 may alternatively be represented as e011, decoder 1 may alternatively be represented as d001, decoder 2 may alternatively be represented as d010, and decoder 3 may alternatively be represented as d011.
[0231] For example, the first sampling rate is 48 kHz and the second sampling rate is 24 kHz, as shown in Table 2. In this case, the encoder in electronic device 100 classified in category 1 may be referred to as an encoder having high-resolution sound quality, the encoder in electronic device 100 classified in category 2 may be referred to as an encoder having standard-resolution sound quality, and the encoder in electronic device 100 classified in category 3 may be referred to as an encoder having basic sound quality. In addition, the decoder in audio reproduction device 200 classified in category 1 may be referred to as a decoder having high-resolution sound quality, the decoder in audio reproduction device 200 classified in category 2 may be referred to as a decoder having standard-resolution sound quality, and the decoder in audio reproduction device 200 classified in category 3 may be referred to as a decoder having basic sound quality.
[0232] For example, the electronic device 100 includes three encoders, namely, Encoder 1, Encoder 2, and Encoder 3. The sampling rate values supported by Encoder 1 are 8 kHz, 16 kHz, 24 kHz, 32 kHz, 48 kHz, and 96 kHz. The sampling rate values supported by Encoder 2 are 32 kHz and 48 kHz. The sampling rate values supported by Encoder 3 are 8 kHz and 16 Hz. Based on the codec classification standard shown in Table 2, Encoder 1 belongs to category 1, Encoder 2 also belongs to category 2 and category 3, Encoder 2 belongs to category 2, and Encoder 3 belongs to category 3.
[0233] Similarly, for the audio playback device 200, the audio playback device 200 also includes a decoder 1, a decoder 2, and a decoder 3. The audio playback device 200 obtains the values of sampling rates supported by all the decoders in the audio playback device 200. Based on the values of sampling rates supported by all the decoders in the audio playback device 200, the audio playback device 200 classifies the decoders into categories obtained based on the codec classification standard shown in Table 2. The method for classifying the decoders into categories obtained based on the codec classification standard shown in Table 1 by the audio playback device 200 based on the values of sampling rates supported by all the decoders in the audio playback device 200 is the same as the method for classifying the encoders into categories obtained based on the codec classification standard shown in Table 1 by the electronic device 100 based on the values of sampling rates supported by all the encoders in the electronic device 100. Details will not be described again here in this application.
[0234] In an optional implementation, the codec classification standard may be obtained based on the sampling rate, the quantization bit depth, the bit rate, and the number of audio channels.
[0235] Table 3 shows an exemplary codec classification standard obtained based on sampling rate, quantization bit depth, bit rate, and number of audio channels.
[0236] [Table 3]
[0237] As shown in Table 3, when the value of one or more sampling rates supported by the codec is equal to or greater than the first sampling rate, the value of one or more quantization bit depths supported by the codec is equal to or greater than the first quantization bit depth, the value of one or more bit rates supported by the codec is equal to or greater than the first bit rate, and the number of audio channels supported by the codec is equal to or greater than the first number of audio 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 audio channels supported by the codec is equal to or greater than the first number of audio channels, the codec belongs to Category 2. A codec belongs to category 3 when one or more sampling rate values supported by the codec are less than the second sampling rate, one or more quantization bit depth values supported by the codec are less than the second quantization bit depth, one or more bit rate values supported by the codec are less than the second bit rate, and the number of audio channels supported by the codec is greater than or equal to the first number of audio channels.
[0238] In a specific implementation, first, the electronic device 100 obtains the values of sampling rates supported by all encoders in the electronic device 100, the values of bit rates supported by all encoders, the values of quantization bit depths supported by all encoders, and the values of the number of audio channels supported by all encoders. The electronic device 100 classifies all encoders in the electronic device 100 into categories shown in Table 3. It should be noted that one encoder may be classified into multiple categories.
[0239] Table 4 shows an example where the codecs in the electronic device 100 and the audio playback device 200 are classified into categories based on sampling rate, quantization bit depth, bit rate, and number of audio channels.
[0240] [Table 4]
[0241] For example, as shown in Table 4, the first sampling rate is 48 kHz, the second sampling rate is 24 kHz, the first quantization bit depth is 24 bits, the second quantization bit depth is 16 bits, the first bit rate is 600 kbps, the second bit rate is 300 kbps, and the first number of audio channels is 2 audio channels. In this case, the encoder in the electronic device 100 classified into category 1 may be called an encoder having high-resolution sound quality, the encoder in the electronic device 100 classified into category 2 may be called an encoder having standard-resolution sound quality, and the encoder in the electronic device 100 classified into category 3 may be called an encoder having basic sound quality.
[0242] For example, the electronic device 100 includes three encoders, namely, Encoder 1, Encoder 2, and Encoder 3. The sampling rate values supported by Encoder 1 are 8 kHz, 16 kHz, 24 kHz, 32 kHz, 48 kHz, and 96 kHz. The quantization bit depth values supported by Encoder 1 are 16 bits, 24 bits, and 32 bits. The bit rate values supported by Encoder 1 are 600 kbps, 900 kbps, and 1200 kbps. The number of audio channels supported by Encoder 1 are mono, dual, 2.1 channels, and 5.1 channels. The sampling rate values supported by Encoder 2 are 16 kHz, 32 kHz, and 48 kHz. The quantization bit depth values supported by Encoder 2 are 8 bits, 16 bits, and 24 bits. The bit rate values supported by Encoder 2 are 200 kbps, 300 kbps, 400 kbps, and 600 kbps. The number of audio channels supported by Encoder 2 are mono and dual. The sampling rate values supported by Encoder 3 are 8 kHz and 16 kHz. The quantization bit depth values supported by Encoder 3 are 8 bits and 16 bits. The bit rate values supported by Encoder 3 are 200 kbps and 300 kbps. The number of audio channels supported by Encoder 3 are mono, dual, 2.1 channels, 5.1 channels, and 7.1 channels.
[0243] Based on the codec classification standard shown in Table 4, encoder 1 belongs to category 1, encoder 2 belongs to category 2, encoder 2 also belongs to category 3, and encoder 3 belongs to category 3.
[0244] Similarly, for the audio playback device 200, the audio playback device 200 also includes a decoder 1, a decoder 2, and a decoder 3. The audio playback device 200 obtains values of sampling rates supported by all decoders in the audio playback device 200, values of bit rates supported by all decoders, values of quantization bit depths supported by all decoders, and values of the number of audio channels supported by all decoders, and classifies the decoders into categories obtained based on the codec classification standard shown in Table 4. It should be noted that one decoder may belong to multiple categories based on the codec classification standard. The method for classifying decoders into categories shown in Table 4 by the audio reproduction device 200 based on the sampling rate values supported by all decoders in the audio reproduction device 200, the bit rate values supported by all decoders, the quantization bit depth values supported by all decoders, and the number of audio channels supported by all decoders is the same as the method for classifying encoders into categories shown in Table 4 by the electronic device 100 based on the sampling rate values supported by all encoders in the electronic device 100, the bit rate values supported by all encoders, the quantization bit depth values supported by all encoders, and the number of audio channels supported by all encoders. Details will not be described again here in this application.
[0245] After the electronic device 100 classifies the encoders into multiple categories and the audio playback device 200 classifies the decoders into multiple categories, the electronic device 100 negotiates with the audio playback device 200 to obtain a common category. Then, when the electronic device 100 transmits audio data to the audio playback device 200, the electronic device 100 encodes the audio data using a default encoder of the category of the common category and sends the encoded audio data to the audio playback device 200, and the audio playback device 200 decodes the encoded audio data using a default decoder of the category and then plays the audio data.
[0246] FIG. 8 is a schematic diagram of an example of an electronic device 100 negotiating with an audio playback device 200 for a common category.
[0247] S801: The electronic device 100 establishes a communication connection to the audio playback device 200.
[0248] The electronic device 100 may establish a communication connection to the audio playing device 200 via any one of Bluetooth, Wi-Fi Direct, or a local area network, etc. A method in which the electronic device 100 establishes a communication connection to the audio playing device 200 will be described in detail below. In this application, details will not be described here. In this embodiment of the application, an example in which the electronic device 100 establishes a communication connection to the audio playing device 200 via Bluetooth technology is used for description.
[0249] S802: The audio playback device 200 classifies all decoders into multiple categories based on a codec classification standard.
[0250] The audio reproduction device 200 first obtains the codec classification standard. It can be seen that the codec category standard is pre-configured on the audio reproduction device 200.
[0251] Next, the audio playback device 200 obtains values of one or more parameters of all decoders within the audio playback device 200 .
[0252] When audio playback device 200 determines that the values of one or more parameters of a decoder are within a range of values of one or more parameters used in a codec classification standard, audio playback device 200 classifies the decoder into one or more categories.
[0253] According to this method, the audio playback device 200 classifies all decoders in the audio playback device 200 into multiple categories. It should be noted that one decoder may be classified into multiple categories. The audio playback device 200 records the decoder identifiers of each category. For example, when the category obtained based on the codec classification standard is category 1, the decoder identifiers included in category 1 include decoder 1 and decoder 2; when the category obtained based on the codec classification standard is category 2, the decoder identifiers included in category 2 include decoder 2 and decoder 3; when the category obtained based on the codec classification standard is category 3, the decoder identifiers included in category 3 include decoder 3; and when the category obtained based on the codec classification standard is category 4, the decoder identifiers included in category 4 are empty.
[0254] The codec classification standard and the method by which the audio playback device 200 classifies all decoders into multiple categories based on the values of one or more parameters of all decoders are described in detail in Tables 1 to 4. In this application, the details will not be described again here.
[0255] S803: The audio playback device 200 obtains a decoder identifier for each category.
[0256] From S802, it can be known that the audio reproduction device 200 classifies all decoders in the audio reproduction device 200 into multiple categories and then records the decoder identifiers of each category.
[0257] S804: The audio playback device 200 transmits to the electronic device 100 a category identifier corresponding to the one or more decoder identifiers.
[0258] After the audio playback device 200 obtains the decoder identifiers for each category, the audio playback device 200 need only transmit to the electronic device 100 the category identifiers that correspond to the one or more decoder identifiers.
[0259] In some embodiments, audio playback device 200 may alternatively transmit to electronic device 100 category identifiers corresponding to one or more decoder identifiers and a decoder identifier corresponding to each category.
[0260] In some embodiments, audio playback device 200 may alternatively send only all decoder identifiers and values of one or more parameters corresponding to each decoder to electronic device 100. Electronic device 100 classifies all decoders in audio playback device 200 into multiple categories based on a codec classification standard, i.e., electronic device 100 obtains a decoder identifier corresponding to each category. Specifically, in the case of electronic device 100, electronic device 100 obtains a codec classification standard. The codec category standard may be known to be pre-configured on electronic device 100.
[0261] When the electronic device 100 determines that the values of one or more parameters of the decoder are within a range of values of one or more parameters used in a codec classification standard, the electronic device 100 classifies the decoder into one or more categories.
[0262] According to this method, the electronic device 100 classifies all the decoders in the audio playback device 200 into multiple categories. It should be noted that one decoder may be classified into multiple categories. The electronic device 100 records the decoder identifiers of each category. For example, when the category obtained based on the codec classification standard is category 1, the decoder identifiers included in category 1 include decoder 1 and decoder 2; when the category obtained based on the codec classification standard is category 2, the decoder identifiers included in category 2 include decoder 2 and decoder 3; when the category obtained based on the codec classification standard is category 3, the decoder identifiers included in category 3 include decoder 3; and when the category obtained based on the codec classification standard is category 4, the decoder identifiers included in category 4 are empty.
[0263] After the electronic device 100 obtains the decoder identifiers for each category, the electronic device 100 may obtain category identifiers that correspond to one or more of the decoder identifiers.
[0264] S805: The electronic device 100 classifies all encoders into multiple categories based on a codec classification standard.
[0265] The electronic device 100 first obtains the codec classification standard. It can be seen that the codec category standard is pre-configured on the electronic device 100.
[0266] Next, the electronic device 100 obtains values of one or more parameters of all encoders within the electronic device 100 .
[0267] When the electronic device 100 determines that the values of one or more parameters of an encoder are within a range of values of one or more parameters used in a codec classification standard, the electronic device 100 classifies the encoder into one or more categories.
[0268] According to this method, the electronic device 100 classifies all the encoders into multiple categories according to the aforementioned method. It should be noted that one encoder can be classified into multiple categories. The electronic device 100 records the encoder identifiers of each category. For example, when the category obtained based on the codec classification standard is category 1, the encoder identifiers included in category 1 include encoder 1 and encoder 2; when the category obtained based on the codec classification standard is category 2, the encoder identifiers included in category 2 include encoder 2 and encoder 3; when the category obtained based on the codec classification standard is category 3, the encoder identifiers included in category 3 include encoder 3; and when the category obtained based on the codec classification standard is category 4, the encoder identifiers included in category 4 are encoder 1 and encoder 4.
[0269] The codec classification standard and the method by which the electronic device 100 classifies all encoders into multiple categories based on the values of one or more parameters of all encoders are described in detail in Tables 1 to 4. In this application, the details will not be described again here.
[0270] S806: The electronic device 100 obtains an encoder identifier for each category.
[0271] From S805, it can be known that the electronic device 100 records the encoder identifiers of each category after classifying all the encoders in the electronic device 100 into multiple categories. It can be understood that S805 and S806 may be performed before S802. This is not limited here in the present application.
[0272] S807: The electronic device 100 determines a common category from the categories corresponding to the one or more encoder identifiers and the categories corresponding to the one or more decoder identifiers.
[0273] The electronic device 100 receives categories corresponding to the one or more decoder identifiers transmitted by the audio playback device 200. For example, the categories corresponding to the one or more decoder identifiers transmitted by the audio playback device 200 may be category 1, category 2, category 3, and category 4.
[0274] After obtaining the encoder identifier for each category, the electronic device 100 determines a category corresponding to the one or more encoder identifiers. For example, the electronic device 100 determines that the categories corresponding to the one or more encoder identifiers may be category 1, category 2, and category 4.
[0275] Then, the electronic device 100 determines a common category from the categories corresponding to the one or more encoder identifiers and the categories corresponding to the one or more decoder identifiers. The common category is the intersection of the categories corresponding to the one or more encoder identifiers and the categories corresponding to the one or more decoder identifiers. The common category means that the electronic device 100 and the audio playback device 200 can transmit audio data using the encoders and decoders of the category. For example, the common category can be category 1, category 2, and category 4.
[0276] S808: The electronic device 100 determines a default encoder identifier for the common category.
[0277] 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 for the category is the default encoder identifier or the decoder identifier for the category is the default decoder identifier.
[0278] For example, when the common category is category 3, the encoder identifiers included in category 3 include encoder 3, and when the category obtained based on the codec classification standard is category 3, the decoder identifiers included in category 3 include decoder 3. Because category 3 includes only one encoder identifier, electronic device 100 determines that encoder 3 is the default encoder for category 3. Because category 3 includes only one decoder identifier, electronic device 100 determines that decoder 3 is the default decoder for category 3.
[0279] For any common category, if the number of encoder identifiers is greater than one or the number of decoder identifiers is greater than one, the electronic device 100 determines a default encoder identifier from the one or more encoder identifiers according to a preset rule, or the electronic device 100 determines a default decoder identifier from the one or more decoder identifiers according to a preset rule.
[0280] The pre-set rules may be priority rules, low power consumption rules, or high efficiency rules, etc.
[0281] In optional implementations, the electronic device 100 determines a default encoder identifier from more than one encoder identifier according to a priority rule, or the electronic device 100 determines a default decoder identifier from more than one decoder identifier according to a priority rule.
[0282] Table 5 shows an example of encoder and decoder priorities.
[0283] [Table 5]
[0284] It can be understood that the priority of the encoders and decoders may be generally accepted in the industry or may be set by the developer. The order of priority of the codecs is not limited in this application.
[0285] The electronic device 100 determines a default encoder identifier from the one or more encoder identifiers based on the codec priorities shown in Table 5, or the electronic device 100 determines a default decoder identifier from the one or more decoder identifiers according to a priority rule.
[0286] For example, with respect to category 1, the decoder identifiers included in category 1 include decoder 1 and decoder 2, and the encoder identifiers included in category 1 include encoder 1 and encoder 2. Because the priority of encoder 1 is higher than the priority of encoder 2, the electronic device 100 determines that encoder 1 is the default encoder for category 1. Because the priority of decoder 1 is higher than the priority of decoder 2, the electronic device 100 determines that decoder 1 is the default decoder for category 1.
[0287] In optional implementations, the electronic device 100 determines a default encoder identifier from more than one encoder identifier according to low power rules, or the electronic device 100 determines a default decoder identifier from more than one decoder identifier according to low power rules.
[0288] Table 6 shows an example of the power ranking of the encoder and decoder.
[0289] [Table 6]
[0290] It can be understood that the power ranking of the encoder and decoder may be generally accepted in the industry or may be set by the developer. The power ranking of the codecs is not limited in this application.
[0291] The electronic device 100 determines a default encoder identifier from the one or more encoder identifiers based on the ascending encoder power rankings shown in Table 6, or the electronic device 100 determines a default decoder identifier from the one or more decoder identifiers based on the ascending decoder power rankings.
[0292] For example, for category 1, the decoder identifiers included in category 1 include decoder 1 and decoder 2, and the encoder identifiers included in category 1 include encoder 1 and encoder 2. Because the power of encoder 1 is lower than the power of encoder 2, the electronic device 100 determines that encoder 1 is the default encoder for category 1. Because the power of decoder 1 is lower than the power of decoder 2, the electronic device 100 determines that decoder 1 is the default decoder for category 1.
[0293] In optional implementations, the electronic device 100 determines a default encoder identifier from more than one encoder identifier according to efficiency rules, or the electronic device 100 determines a default decoder identifier from more than one decoder identifier according to efficiency rules.
[0294] Table 7 shows an example of the efficiency ranking of encoders and decoders.
[0295] [Table 7]
[0296] It can be understood that the efficiency ranking of the encoders and decoders may be generally accepted in the industry or may be set by the developer. The efficiency ranking of the codecs is not limited in this application.
[0297] The electronic device 100 determines a default encoder identifier from the one or more encoder identifiers based on the encoder efficiency ranking shown in Table 6, or the electronic device 100 determines a default decoder identifier from the one or more decoder identifiers based on the decoder efficiency ranking.
[0298] For example, for category 1, the decoder identifiers included in category 1 include decoder 1 and decoder 2, and the encoder identifiers included in category 1 include encoder 1 and encoder 2. Because the efficiency of encoder 1 is higher than the efficiency of encoder 2, the electronic device 100 determines that encoder 1 is the default encoder for category 1. Because the efficiency of decoder 1 is higher than the efficiency of decoder 2, the electronic device 100 determines that decoder 1 is the default decoder for category 1.
[0299] Alternatively, the electronic device 100 may determine a default encoder identifier from more than one encoder identifier, or may determine a default decoder identifier from more than one decoder identifier according to another rule, which is not limited here in this application.
[0300] In some embodiments, the electronic device 100 determines a default encoder identifier for the common category, and the electronic device 100 must further determine a default decoder identifier for the common category.
[0301] Specifically, when the audio reproduction device 200 transmits all the 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 the decoders in the audio reproduction device 200 into a plurality of categories based on a codec classification standard, and then the electronic device 100 determines a common category supported by the electronic device 100 and the audio reproduction device 200. Alternatively, the audio reproduction device 200 classifies all the decoders in the audio reproduction device 200 into a plurality of categories based on a codec classification standard, transmits the categories corresponding to one or more decoder identifiers and the decoder identifiers corresponding to each category to the electronic device 100, and then the electronic device 100 determines a common category supported by the electronic device 100 and the audio reproduction device 200. After determining the common category, the electronic device 100 determines a default encoder identifier for each common category. The electronic device 100 also needs to determine a default decoder identifier for each common category. Specifically, when the number of decoder identifiers corresponding to a common category is 1, the electronic device 100 determines that the decoder identifier corresponding to the category is the default decoder identifier. When the number of decoder identifiers corresponding to a common category is greater than 1, the electronic device 100 may determine a default decoder identifier for the category using the embodiments shown in Tables 5 to 7. In this application, details will not be described again here.
[0302] S809: The electronic device 100 sends the common category identifier to the audio playing device 200.
[0303] After the electronic device 100 determines the common category, the electronic device 100 transmits an identifier of the common category to the audio playback device 200 .
[0304] The audio playback device 200 receives the common category identifier transmitted by the electronic device 100 .
[0305] In some embodiments, the audio playback device 200 must further determine a default decoder identifier for each common category.
[0306] For any common category, if the number of decoder identifiers is one, the audio playback device 200 determines that the decoder identifier for the category is the default decoder identifier.
[0307] For example, when the category obtained based on 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 the default decoder for category 3.
[0308] For any common category, if the number of decoder identifiers is greater than one, the audio playback device 200 determines a default decoder identifier from the one or more decoder identifiers according to preset rules.
[0309] The pre-set rules may be priority rules, low power consumption rules, or high efficiency rules, etc.
[0310] The method for determining a default decoder identifier from one or more decoder identifiers according to a priority rule, a low power consumption rule, or a high efficiency rule by the audio playback device 200 is consistent with the method for determining a default decoder identifier from one or more decoder identifiers according to a priority rule, a low power consumption rule, or a high efficiency rule by the electronic device 100. In this application, the details will not be described again here.
[0311] Alternatively, S809 may be executed after S802, which is not limited here in this application.
[0312] In some embodiments, when the electronic device 100 determines a default decoder identifier for the common category, when transmitting the identifier for the common category to the audio playback device 200, the electronic device 100 must further transmit the default decoder identifier for the common category to the audio playback device 200.
[0313] Optionally, the electronic device 100 may alternatively send to the audio playback device 200 an identifier of the common category and a default decoder identifier and a default encoder identifier for each category.
[0314] After the electronic device 100 and the audio playback device 200 determine the common categories and the default codec for each common category, the electronic device 100 selects an appropriate category from the common categories based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capabilities of the electronic device are enabled, and the network conditions of the channel, etc., to transmit the audio data, and selects a default codec for the category.
[0315] The following describes how the electronic device 100 selects an appropriate category from the common categories based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the electronic device's audio rendering capabilities are enabled, and the network conditions of the channel.
[0316] 1. Application Type: In the electronic device 100, different types of audio playback applications have different requirements for audio playback characteristics. The electronic device 100 obtains the requirements of the audio playback application for the minimum sampling rate of the audio data, the minimum quantization bit depth, and the number of audio channels, and then selects an appropriate category from the common categories according to the requirements of the audio playback application for the minimum sampling rate of the audio data, the minimum quantization bit depth, and the number of audio channels. For example, some applications have high requirements for sound quality and have high requirements for the value of the sampling rate of the audio data and the value of the quantization bit depth. For example, for a general audio playback application, the value of the sampling rate of the audio data is 32 kHz, and the value of the quantization bit depth of the audio data is 16 bits. However, an application with high requirements for sound quality requires that the minimum value of the sampling rate of the audio data is 48 kHz, and the minimum value of the quantization bit depth of the audio data is 24 bits. To transmit the audio data, the electronic device 100 may select a default codec of the category based on the condition that the value of the sampling rate includes 48 kHz and the value of the quantization bit depth includes 24 bits.
[0317] 2. Audio Playback Characteristics: In the electronic device 100, applications may play different audio data, and different audio data may have different characteristics. The electronic device 100 obtains the requirements of the minimum sampling rate, the minimum quantization bit depth, and the number of audio channels of the audio data being played, and then selects an appropriate category from the common categories according to the requirements of the minimum sampling rate, the minimum quantization bit depth, and the number of audio channels of the audio data being played. For example, some audio data has high requirements on sound quality, and high requirements are imposed on the sampling rate and quantization bit depth of the audio data. For example, the sampling rate value of common audio data is 32 kHz, and the quantization bit depth value of the audio data is 16 bits. However, the minimum sampling rate value of some pre-set audio data with high sound quality is 48 kHz, and the minimum quantization bit depth value is 24 bits. To transmit the audio data, the electronic device 100 may select a default codec of the category based on the condition that the sampling rate value includes 48 kHz and the quantization bit depth value includes 24 bits.
[0318] 3. Whether the audio rendering capability of the electronic device is enabled: the sampling rate value of the audio data currently being played by the electronic device is sampling rate 1, the quantization bit depth value is quantization bit depth 1, the bit rate value is bit rate 1, and the value of the number of audio channels is number of audio channels 1. After the audio rendering capability of the electronic device 100 is enabled, the rendering unit of the electronic device 100 may increase the sampling rate value of the audio data from sampling rate 1 to sampling rate 2, the rendering unit of the electronic device 100 may increase the quantization bit depth value of the audio data from quantization bit depth 1 to quantization bit depth 2, and the rendering unit of the electronic device 100 may increase the value of the number of audio channels of the audio data from number of audio channels 1 to number of audio channels 2. The sampling rate 2 is greater than the sampling rate 1, the quantization bit depth 2 is greater than the quantization bit depth 1, and the number of audio channels 2 is greater than the number of audio channels 1. Next, based on the fact that the sampling rate value of the audio data is sampling rate 2, the quantization bit depth value of the audio data is quantization bit depth 2, the bit rate value is bit rate 1, and the number of audio channels value of the audio data is the number of audio channels 2, the electronic device 100 selects a default codec for transmitting the audio data from the common category, in a category in which the sampling rate includes sampling rate 2, the quantization bit depth includes quantization bit depth 2, the bit rate value includes bit rate 1, and the number of audio channels includes the number of audio channels 2.
[0319] 4. Network state of channel: the sampling rate value of the audio data currently being played by the electronic device is sampling rate 1, the quantization bit depth value is quantization bit depth 1, the number of audio channels value is audio channel number 1, and the bit rate value is bit rate 1. In this case, based on that the sampling rate value of the audio data is sampling rate 1, the quantization bit depth value of the audio data is quantization bit depth 1, the number of audio channels value of the audio data is audio channel number 1, and the bit rate value of the audio data is bit rate 1, the electronic device 100 selects a category from the common categories in which the sampling rate includes sampling rate 1, the quantization bit depth includes quantization bit depth 1, the number of audio channels includes audio channel number 1, and the bit rate includes bit rate 1, and transmits the audio data using a default codec of this category.
[0320] It should be noted that the electronic device 100 may alternatively select an appropriate category from the common categories based on other parameters, including but not limited to the application type, audio playback characteristics (sampling rate, quantization bit depth, and number of audio channels) listed in the above embodiment, whether the audio rendering capability of the electronic device is enabled, and the network conditions of the channel, etc. In this application, the details will not be described again here.
[0321] After electronic device 100 and audio playback device 200 select an appropriate category from the common categories and transmit audio data using the default codec of the category, due to a change in application type, a change in audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), enabling of audio rendering capabilities of the electronic device, a change in network conditions of a channel, or other factors, electronic device 100 reselects another category and notifies audio playback device 200 of an identifier of the category. Electronic device 100 transmits audio data to audio playback device 200 using the default codec of the other category.
[0322] 1. Application type changes from application type 1 to application type 2: in the electronic device 100, different types of audio playback applications have different requirements for audio playback characteristics. When the electronic device 100 plays audio data based on application type 1, the value of the sampling rate of the audio data is sampling rate 1, the value of the quantization bit depth is quantization bit depth 1, the value of the bit rate is bit rate 1, and the value of the number of audio channels is the number of audio channels 1. After the electronic device 100 switches the audio data playback application from application 1 to application 2, if application 2 has a higher requirement for the sound quality of the audio data, when application 2 plays the audio data, the value of the sampling rate of the audio data is sampling rate 2, the value of the quantization bit depth is quantization bit depth 2, the value of the bit rate is bit rate 2, the value of the number of audio channels is the number of audio channels 1, the sampling rate 2 is greater than the sampling rate 1, the quantization bit depth 2 is greater than the quantization bit depth 1, and the bit rate 2 is greater than the bit rate 1. Due to the change of the parameters, the electronic device 100 reselects a codec category. For transmitting audio data, the electronic device 100 selects a default codec from the common category, where 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 audio channels includes audio channel number 1.
[0323] 2. Audio content switches from audio data 1 to audio data 2: In the electronic device 100, an application may play different audio data, and different audio data may have different characteristics. When the electronic device 100 plays the audio data 1 based on the application type, the value of the sampling rate of the audio data 1 is sampling rate 1, the value of the quantization bit depth is quantization bit depth 1, the value of the bit rate is bit rate 1, and the value of the number of audio channels is the number of audio channels 1. After the electronic device 100 switches the played audio content from audio data 1 to audio data 2, if the sound quality of the audio data 2 is higher, when the electronic device 100 plays the audio data 2, the value of the sampling rate of the audio data 2 is sampling rate 2, the value of the quantization bit depth is quantization bit depth 2, the value of the bit rate is bit rate 2, the value of the number of audio channels is the number of audio channels 1, the sampling rate 2 is greater than the sampling rate 1, the quantization bit depth 2 is greater than the quantization bit depth 1, and the bit rate 2 is greater than the bit rate 1. Due to the change in the parameters, the electronic device 100 reselects a codec category. The electronic device 100 selects a default codec from the common category, in which 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 audio channels includes the number of audio channels 1, for transmitting audio data.
[0324] 3. The audio rendering capability of the electronic device switches from a disabled state to an enabled state: the sampling rate value of the audio currently being played by the electronic device is sampling rate 1, the quantization bit depth value is quantization bit depth 1, the bit rate value is bit rate 1, and the number of audio channels value is number of audio channels 1. After the audio rendering capability of the electronic device 100 is enabled, the rendering unit of the electronic device 100 may increase the sampling rate value of the audio data from sampling rate 1 to sampling rate 2, the rendering unit of the electronic device 100 may increase the quantization bit depth value of the audio data from quantization bit depth 1 to quantization bit depth 2, and the rendering unit of the electronic device 100 may increase the number of audio channels value of the audio data from number of audio channels 1 to number of audio channels 2. The sampling rate 2 is greater than the sampling rate 1, the quantization bit depth 2 is greater than the quantization bit depth 1, and the number of audio channels 2 is greater than the number of audio channels 1. Due to this change in parameters, the electronic device 100 reselects a codec category. For transmitting audio data, the electronic device 100 selects a default codec from the common category, where the sampling rate includes sampling rate 2, the quantization bit depth includes quantization bit depth 2, the bit rate value includes bit rate 1, and the number of audio channels includes the number of audio channels 2.
[0325] 4. The network condition of the channel deteriorates: the sampling rate value of the audio data currently played by the electronic device is sampling rate 1, the quantization bit depth value is quantization bit depth 1, the number of audio channels value is audio channel number 1, and the bit rate value is bit rate 1. Due to strong interference and attenuation of the wireless transmission channel, etc., the bit rate supported by the wireless transmission channel decreases from bit rate 1 to bit rate 2, and bit rate 2 is less than bit rate 1. Due to this parameter change, the electronic device 100 reselects a codec category. The electronic device 100 selects a default codec of a category, in which the sampling rate includes sampling rate 1, the quantization bit depth includes quantization bit depth 1, the bit rate value includes bit rate 2, and the number of audio channels includes audio channel number 1, from the common category to transmit the audio data.
[0326] After the electronic device 100 reselects the default codec of another category, the electronic device 100 transmits audio data using the default codec of another category to the audio playback device 200. In order to reduce sound dropouts during codec switching, in an embodiment of the present application, a smooth transition during codec switching can be implemented using the following method.
[0327] The electronic device 100 switches the category obtained based on the codec classification standard from category 1 to category 2, where category 1 corresponds to a default encoder 1 and a default decoder 1, and category 2 corresponds to a default encoder 2 and a default decoder 2. In this case, the electronic device 100 switches from the encoder to the encoder 2, and the audio playback device 200 switches from the decoder 1 to the decoder 2.
[0328] When the delays of Encoder 1 and Encoder 2 are the same, the electronic device 100 needs to complete the switch from Encoder 1 to Encoder 2 within one audio data frame. The audio data frame for the transition between Encoder 1 and Encoder 2 is called the i-th audio data frame. Encoder 1 encodes the i-th audio data frame to obtain Packet A. Encoder 2 encodes the i-th audio data frame to obtain Packet B.
[0329] The electronic device 100 sends Packet A and Packet B to the audio playback device 200. The audio playback device 200 decodes Packet A using decoder 1 to obtain audio data pcmA, and the audio playback device 200 also decodes Packet B using decoder 2 to obtain audio data pcmB. Then, the audio playback device 200 smoothes the i-th audio data frame. The smoothing process is shown in Equation (1). Pcm(i)=wi×pcmA(i)+(1-wi)×pcmB(i) Equation (1)
[0330] As shown in equation (1), Pcm(i) denotes the smoothed i-th audio data frame, wi denotes a smoothing coefficient, and wi may be linear smoothing or cosine smoothing, etc. The value of wi ranges from 0 to 1. A smaller smoothing coefficient wi indicates a stronger smoothing effect and a smaller adjustment amount to the prediction result. A larger smoothing coefficient wi indicates a weaker smoothing effect and a larger adjustment amount to the prediction result. pcmA(i) denotes audio data obtained by the decoder 1 by decoding Packet A, and pcmB(i) denotes audio data obtained by the decoder 2 by decoding Packet B. The audio reproduction device 200 may obtain an audio data frame Pcm(i) obtained by smoothing the i-th audio data frame based on equation (1). In this way, the audio reproduction device 200 reproduces the audio data frame obtained by smoothing the i-th audio data frame, so that a smooth transition is implemented for the audio data frame during codec switching.
[0331] When the delays of encoder 1 and encoder 2 are different, the electronic device 100 needs to complete the switch from encoder 1 to encoder 2 within multiple frames of audio data. The process of calculating the total number D of audio data frames when switching from encoder 1 to encoder 2 is shown in equation (2). D = round ((max (Encoder 1 total delay, Encoder 2 total delay) + (frame length - Encoder 1 total delay % frame length) + frame length - 1) / frame length) Equation (2)
[0332] As shown in equation (2), max indicates the operation to obtain the maximum value, % indicates the modulo operation, and frame length indicates that the encoder 1 encodes audio data having a particular duration into a frame, and the frame of audio data having a particular duration is frame length.
[0333] With respect to the total number D of audio data frames at the transition, each frame of audio data may be encoded using encoder 1 and encoder 2, and two data packets, namely, Packet A and Packet B, may be obtained for each frame of audio data. 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 pcmB. With respect to the total number D of audio data frames at the switch, the first D-1 audio data frames are still audio data decoded by decoder 1. With respect to the Dth audio data frame, the audio playback device 200 smoothes the Dth audio data frame. The smoothing process is shown in equation (3). Pcm(i)=wi×pcmA(i)+(1-wi)×pcmB(i) Equation (3)
[0334] As shown in equation (3), Pcm(i) indicates the smoothed Dth audio data frame, wi indicates a smoothing coefficient, and wi may be linear smoothing or cosine smoothing, etc. The value of wi ranges from 0 to 1. A smaller smoothing coefficient wi indicates a stronger smoothing effect and a smaller adjustment amount to the prediction result. A larger smoothing coefficient wi indicates a weaker smoothing effect and a larger adjustment amount to the prediction result. pcmA(i) indicates audio data obtained by the decoder 1 by decoding the Dth audio data frame, and pcmB(i) indicates audio data obtained by the decoder 2 by decoding the Dth audio data frame. The audio reproduction device 200 may obtain an audio data frame Pcm(i) obtained by smoothing the Dth audio data frame based on equation (3). In this way, the audio reproduction device 200 reproduces the first D-1 audio data frames and the audio data frame obtained by smoothing the Dth audio data frame, so that a smooth transition is implemented for the audio data frames during codec switching.
[0335] FIG. 9 is a flowchart of a codec negotiation and switching method according to an embodiment of the present application.
[0336] S901: The electronic device 100 establishes a communication connection to the audio playback device 200.
[0337] The electronic device 100 may establish a communication connection to the audio playing device 200 via one or more of Bluetooth, Wi-Fi Direct, and NFC. In this embodiment of the present application, an example in which the electronic device 100 establishes a communication connection to the audio playing device 200 via Bluetooth technology is used for description.
[0338] With reference to the UI illustration, the following describes in detail how the electronic device 100 establishes a communication connection to the audio playing device 200.
[0339] Figures 9A to 9C are diagrams of an exemplary user interface for an electronic device 100 to establish a communication connection to an audio playback device 200 via Bluetooth. In addition to Bluetooth, the electronic device 100 may alternatively establish a communication connection to the audio playback device 200 via one or more of Wi-Fi Direct and NFC.
[0340] Figure 9A shows an exemplary audio playback user interface 600 on the electronic device 100. As shown in Figure 9A, the audio playback interface 600 includes a song name 601, playback controls 602, previous song controls 603, next song controls 604, a playback progress bar 605, download controls 606, share controls 607, and additional controls 608. For example, the song name 601 may be "Dream it possible". The playback controls 602 are configured to trigger the electronic device 100 to play the audio data corresponding to the song name 601. The previous song controls 603 may be configured to trigger the electronic device 100 to switch to the previous audio data in the playlist for playback. The next song controls 604 may be configured to trigger the electronic device 100 to switch to the next audio data in the playlist for playback. The playback progress bar 605 may indicate the playback progress of the current audio data. The download controls 606 may be configured to trigger the electronic device 100 to download the audio data corresponding to the song name 601 and store the audio data in a local storage medium. The share controls 607 may be configured to trigger the electronic device 100 to share the playback link of the audio data corresponding to the song name 601 with another application. The additional controls 608 may be configured to trigger the electronic device 100 to display additional function controls related to music playback.
[0341] In addition to music playback, the electronic device 100 can further play audio data played by a video application, audio data played by a game application, and audio data of a real-time call, etc. The source of the audio data played by the electronic device 100 is not limited in this application.
[0342] As shown in FIGS. 9B and 9C, when the electronic device 100 detects a swiping-down gesture on the display, the electronic device 100 displays a window 610 shown in FIG. 9C on the user interface 600 in response to the swiping gesture. As shown in FIG. 9C, a Bluetooth control 611 may be displayed in the window 610, and the Bluetooth control 611 can receive an operation (for example, a touch operation or a tap operation) to enable or disable the Bluetooth function of the electronic device 100. The presentation form of the Bluetooth control 611 may include an icon and / or text (for example, the text "cooperative projection"). On / off controls for other functions such as Wi-Fi, hotspot, flashlight, incoming call tone, auto-rotation, instant sharing, airplane mode, mobile data, location information, screenshot, icon comfort mode, screen recording, cooperative projection, and NFC may be further displayed in the window 610. That is, a user operation to enable the cooperative projection function is detected. In some embodiments, after detecting a user operation performed on the Bluetooth control 611, the electronic device 100 may change the display form of the Bluetooth control 611. For example, the electronic device 100 may add a shadow to the Bluetooth control 611.
[0343] In addition to the interface shown in FIG. 9B, the user may alternatively input a swiping-down gesture on another interface to trigger the electronic device 100 to display the window 610.
[0344] 9B and 9C, performed by the user on the Bluetooth control 611 in the window 610, in this embodiment of the present application, the user operation for enabling the Bluetooth function may alternatively be implemented in another form, which is not limited in this embodiment of the present application.
[0345] For example, electronic device 100 may alternatively display a settings interface provided by a settings application. The settings interface may include controls provided to a user for enabling or disabling Bluetooth functionality of electronic device 100. The user may enable Bluetooth functionality of electronic device 100 by inputting a user action on the control.
[0346] Upon detecting a user action to enable the Bluetooth functionality, the electronic device 100 discovers via Bluetooth other electronic devices that have Bluetooth functionality enabled and are in the vicinity of the electronic device 100. For example, the electronic device 100 may discover and connect to the nearby audio playback device 200 and other electronic devices via Bluetooth.
[0347] S902: The electronic device 100 determines whether a connection to the audio playing device 200 is established for the first time. If the electronic device 100 establishes a connection to the audio playing device 200 for the first time, the electronic device 100 executes S903; if not, the electronic device 100 executes S907.
[0348] S903: The audio playback device 200 sends to the electronic device 100 a category identifier corresponding to the one or more decoder identifiers.
[0349] Before the audio playback device 200 transmits category identifiers corresponding to one or more decoder identifiers to the electronic device 100, the audio playback device 200 classifies all decoders into multiple categories based on a codec classification standard. The method in which the audio playback device 200 classifies all decoders into multiple categories based on a codec classification standard is described in detail in the embodiment shown in S702. The details will not be described again here in this application.
[0350] For example, the audio playback device 200 transmits the first category identifier and the second category identifier to the electronic device 100, and the electronic device 100 receives the first category identifier and the second category identifier transmitted by the audio playback device 200, or the audio playback device 200 transmits the first category identifier to the electronic device 100, and the electronic device 100 receives the first category identifier transmitted by the audio playback device 200. The first category decoder includes at least a first decoder, and the second category decoder includes at least a second decoder.
[0351] Before the audio playback device 200 transmits category identifiers corresponding to the one or more decoder identifiers to the electronic device 100, the audio playback device 200 is further configured to classify the first encoder into a first category based on the parameter information of the first encoder and a codec classification standard, and classify the second encoder into a second category based on the parameter information of the second encoder and a codec classification standard, where 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 audio channels, and an audio stream format, and the audio playback device is further configured to classify the first decoder into the first category based on the parameter information of the first decoder and the codec classification standard, and classify the second decoder into the second category based on the parameter information of the second decoder and the codec classification standard, where 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 audio channels, and an audio stream format, and the codec classification standard includes a mapping relationship between the codec categories and the parameter information of the codecs. It should be noted that the first encoder parameter information, the second encoder parameter information, the first decoder parameter information, and the second decoder parameter information are all the same.
[0352] S904: The electronic device 100 determines a common category from the categories corresponding to the one or more encoder identifiers and the categories corresponding to the one or more decoder identifiers.
[0353] In response to a category identifier transmitted by the audio playback device 200 corresponding to the one or more decoder identifiers, the electronic device 100 receives a category identifier transmitted by the audio playback device 200 corresponding to the one or more decoder identifiers.
[0354] For example, the electronic device 100 determines that the common categories supported by the electronic device and the audio playback device are a first category and a second category.
[0355] Alternatively, the electronic device does not receive an identifier of the second category sent by the audio playback device, or the number of encoders of the electronic device classified into the second category is 0. In this case, the electronic device 100 determines that the common category supported by the electronic device and the audio playback device is the first category.
[0356] A common category means that electronic device 100 can transmit audio data to audio playback device 200 using a codec of the category.
[0357] It can be understood that before establishing a connection, the electronic device 100 classifies all encoders within the electronic device 100 into multiple categories based on a codec classification standard and determines a category that corresponds to one or more encoder identifiers.
[0358] In some embodiments, electronic device 100 may, alternatively, after establishing a connection, classify all encoders within electronic device 100 into multiple categories based on a pre-set codec classification standard, and audio playback device 200 may, alternatively, after establishing a connection, classify all decoders within audio playback device 200 into multiple categories according to a pre-set codec classification standard and determine a category that corresponds to one or more decoder identifiers, which is not limited herein in this application.
[0359] In some embodiments, after the electronic device 100 establishes a connection to the audio playback device 200, the audio playback device 200 transmits all decoder identifiers and values of one or more parameters corresponding to each decoder on the audio playback device 200 to the electronic device 100, and the electronic device 100 classifies all encoders in the electronic device 100 and all decoders in the audio playback device 200 into multiple categories based on a codec classification standard, and determines categories corresponding to the one or more encoder identifiers and categories corresponding to the one or more decoder identifiers, which is not limited here in this application.
[0360] The codec classification standard may be obtained based on one or a combination of two or more of the following parameters: sampling rate, quantization bit depth, bit rate, number of audio channels, and audio stream format, and so on.
[0361] For example, when a codec classification standard is obtained based on the sampling rate, the quantization bit depth, the bit rate, the number of audio channels, and the audio stream format, two categories can be obtained by classification based on the codec classification standard.
[0362] Specifically, when the sampling rate value of the codec is equal to or greater than the first sampling rate (target sampling rate), the bit rate value of the codec is equal to or greater than the first bit rate (target bit rate), the quantization bit depth value of the codec is equal to or greater than the first quantization bit depth (target quantization bit depth), the number of audio channels value of the codec is equal to or greater than the first number of audio channels (target number of audio channels), and the audio stream format is PCM (target audio stream format), the codec is classified into category 1; when the sampling rate value of the codec is less than the first sampling rate, the bit rate value of the codec is less than the first bit rate, the quantization bit depth value of the codec is less than the first quantization bit depth, the number of audio channels value of the codec is equal to or greater than the first number of audio channels, and the audio stream format is PCM, the codec is classified into category 2.
[0363] For example, the first sampling rate is 48 kHz, the first bit rate is 600 kbps, the first quantization bit depth is 24 bits, the first number of audio channels is 2, and the audio stream format is PCM. In this case, the codec classification standard of category 1 is as follows, the codec sampling rate is 48 kHz or more, the codec bit rate is 600 kbps or more, the codec quantization bit depth is 24 bits or more, the number of audio channels of the codec is 2 audio channels or more, and the audio stream format is PCM. The codec classification standard of category 2 is as follows, the codec sampling rate is less than 48 kHz, the codec bit rate is less than 600 kbps, the codec quantization bit depth is less than 24 bits, the number of audio channels of the codec is 2 audio channels or more, and the audio stream format is PCM. The codec classified in category 1 may be called a codec having high-definition sound quality, and the codec classified in category 2 may be called a codec having standard sound quality.
[0364] The audio playback device 200 includes a decoder 1, a decoder 2, and a decoder 3, where the decoder 1 belongs to category 1, and the decoder 2 and the decoder 3 belong to category 2.
[0365] The electronic device 100 includes an encoder 1, an encoder 2, and an encoder 3, where the encoder 1 belongs to category 1 and the encoder 2 and the encoder 3 belong to category 2.
[0366] In this case, the common categories supported by the electronic device 100 and the audio playback device 200 include category 1 and category 2.
[0367] The method in which the electronic device 100 classifies the encoders into corresponding categories based on the codec classification standard, and the method in which the audio playback device 200 classifies the decoders into corresponding categories based on the codec classification standard are described in detail in the embodiment shown in Figure 7. In this application, the details will not be described again here.
[0368] S905: The electronic device 100 determines a default encoder identifier and a default decoder identifier for each common category.
[0369] After electronic device 100 determines the common category supported by electronic device 100 and audio playback device 200, electronic device 100 and audio playback device 200 may transmit audio data using a codec of the common category.
[0370] If the number of encoders of a common category is greater than 1 and / or the number of decoders of a common category is greater than 1, then electronic device 100 needs to determine a default encoder identifier and a default decoder identifier for each common category. Electronic device 100 then transmits audio data to audio playback device 200 using the default encoder and default decoder for each common category.
[0371] 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 of the category is the default encoder or the decoder of the category is the default decoder.
[0372] For example, when the common category is category 1 (first category), the codecs classified into category 1 are high-definition audio codecs. The encoders of category 1 include encoder 1 (first encoder), and the decoders of category 1 include decoder 1 (first decoder). Because category 1 includes one encoder and one decoder, electronic device 100 determines that encoder 1 and decoder 1 are the default encoder and default decoder of category 1. When electronic device 100 determines that audio data should be transmitted using a codec of category 1, electronic device 100 sends an identifier of the category to be used (identifier of category 1) to audio playback device 200.
[0373] The electronic device 100 encodes audio data into first encoded audio data using a category 1 encoder 1 and transmits the first encoded audio data to the audio playback device 200. The audio playback device 200 decodes the compressed audio data into first reproduced audio data using a category 1 decoder 1 and reproduces the first reproduced audio data.
[0374] For example, when the common category is category 2, the codec classified into category 2 is a basic audio codec. The encoder of category 2 includes encoder 2 (second encoder), and the decoder of category 2 includes decoder 2 (second decoder). Because category 2 includes only one encoder and one decoder, electronic device 100 determines that encoder 2 and decoder 2 are the default encoder and default decoder of category 2. When electronic device 100 determines that audio data should be transmitted using a codec of category 2, electronic device 100 sends an identifier of the category to be used (category 2 identifier) to audio playback device 200.
[0375] The electronic device 100 packages the audio data using a category 2 encoder 2 and transmits the packaged audio data to the audio playback device 200. The audio playback device 200 decompresses the compressed audio data using a category 2 decoder 2 and plays the audio data.
[0376] For any common category, if the number of encoder identifiers is greater than one or the number of decoder identifiers is greater than one, the electronic device 100 should determine one of the multiple encoders of the category as the default encoder or one of the multiple decoders of the category as the default decoder.
[0377] For example, when the common category is category 1, the codec classified into category 1 is a high-definition audio codec. The encoder of category 1 includes encoder 1 (first encoder) and encoder 3 (third encoder), and the decoder of category 1 includes decoder 1 (first decoder) and decoder 3 (third decoder). Since category 1 includes multiple encoders and multiple decoders, the electronic device 100 determines a default encoder and a default decoder of category 1. The electronic device 100 may determine a default encoder and a default decoder of category 1 from the multiple encoders and multiple decoders according to a preset rule. The preset rule may be a priority rule, a low power consumption rule, or a high efficiency rule, etc. Specifically, for a method for the electronic device 100 to determine a default encoder (first encoder) and a default decoder (first decoder) of category 1 from the multiple encoders and multiple decoders according to a priority rule, a low power consumption rule, or a high efficiency rule, please refer to the embodiment shown in S808. In this application, details will not be described again here. After the electronic device 100 determines that encoder 1 and decoder 1 are the default encoder and default decoder for category 1, the electronic device 100 sends the default decoder identifier and / or default encoder identifier for the category to the audio playback device 200.
[0378] Next, when the electronic device 100 determines that the audio data should be transmitted using a category 1 codec, the electronic device 100 sends an identifier of the category to be used (the category 1 identifier) to the audio playback device 200.
[0379] The electronic device 100 encodes audio data into first encoded audio data using a category 1 encoder 1 and transmits the first encoded audio data to the audio playback device 200. The audio playback device 200 decodes the first encoded audio data into first reproduced audio data using a category 1 decoder 1 and reproduces the first reproduced audio data.
[0380] For example, when the common categories are category 1 and category 2, the codecs classified into category 1 are high-resolution audio codecs, and the codecs classified into category 2 are basic audio codecs. The encoder of category 1 includes encoder 1, the decoder of category 1 includes decoder 1, the encoder of category 2 includes encoder 2, and the decoder of category 2 includes decoder 2. Since category 1 includes only one encoder and one decoder, and category 2 includes only one decoder and one encoder, electronic device 100 determines that encoder 1 and decoder 1 are the default encoder and default decoder of category 1, and encoder 2 and decoder 2 are the default encoder and default decoder of category 2. When electronic device 100 transmits audio data using a codec of category 1 or category 2, electronic device 100 sends an identifier of the category used (category 1 identifier or category 2 identifier) to audio playback device 200.
[0381] Alternatively, when the common categories are category 1 and category 2, the codec classified into category 1 is a high-resolution audio codec, and the codec classified into category 2 is a basic audio codec. The encoder of category 1 includes encoder 1 and encoder 3, the decoder of category 1 includes decoder 1 and decoder 3, the encoder of category 2 includes encoder 2 and encoder 4, and the decoder of category 2 includes decoder 2 and decoder 4. Since category 1 includes multiple encoders and multiple decoders, and category 2 also includes multiple encoders and multiple decoders, the electronic device 100 may determine a default encoder and a default decoder for each of category 1 and category 2 from the multiple encoders and multiple decoders according to a preset rule. The preset rule may be a priority rule, a low power consumption rule, or a high efficiency rule, etc. Specifically, for a method for determining a default encoder and a default decoder for each of category 1 and category 2 from the multiple encoders and multiple decoders according to a priority rule, a low power consumption rule, or a high efficiency rule by the electronic device 100, please refer to the embodiment shown in S808. In this application, details will not be described again here. After the electronic device 100 determines that encoder 1 and decoder 1 are the default encoder and decoder for category 1 and that encoder 2 and decoder 2 are the default encoder and decoder for category 2, the electronic device 100 sends a default decoder identifier and / or default encoder identifier for category 1 and a default decoder identifier and / or default encoder identifier for category 2 to the audio playback device 200.
[0382] Electronic device 100 may transmit audio data using a default codec of category 1 or category 2. For example, electronic device 100 may transmit audio data using a category 1 codec, which is a high-definition audio codec. When network conditions change, or when the audio content being played changes, etc., electronic device 100 may switch from the category 1 codec to a category 2 codec and transmit the audio data using the category 2 codec.
[0383] After the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200, in an optional implementation, the electronic device 100 determines a default encoder identifier and a default decoder identifier for each common category. The method for determining the default encoder identifier and the default decoder identifier for each common category supported by the electronic device 100 and the audio playback device 200 by the electronic device 100 is described in detail in the embodiment shown in Fig. 7. The details will not be described again here in this application.
[0384] In another optional implementation, electronic device 100 only needs to determine a default encoder identifier for a common category supported by electronic device 100 and audio playback device 200. Electronic device 100 then sends the common categories supported by electronic device 100 and audio playback device 200 to audio playback device 200, and audio playback device 200 determines a default decoder identifier for the common category supported by electronic device 100 and audio playback device 200.
[0385] In some embodiments, the pre-set codec classification standard may be updated at a fixed interval (e.g., monthly). Thus, when the codec classification standard is updated periodically, electronic device 100 also needs to classify into encoder categories periodically (e.g., monthly), and audio playback device 200 also needs to classify into decoder categories periodically (e.g., monthly).
[0386] In an optional implementation, the electronic device 100 and audio playback device 200 may classify codecs into multiple categories at appropriate times based on captured user behavioral habits.
[0387] For example, during the period "24:00 to 7:00", the electronic device 100 and the audio playback device 200 may classify codecs into multiple categories during the period "24:00 to 7:00". Because the user is resting at home during the period "24:00 to 7:00", the codec classification performed during this period does not affect the user experience of using the device.
[0388] S906: The electronic device 100 sends the identifiers of the common categories and the default decoder identifiers for each common category to the audio playback device 200.
[0389] After the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200, the electronic device 100 sends to the audio playback device 200 identifiers of the common categories supported by the electronic device 100 and the audio playback device 200 (a first category identifier and a second category identifier, or a first category identifier) and a default decoder identifier for each common category.
[0390] The audio playback device 200 receives the identifiers of common categories supported by the electronic device 100 and the audio playback device 200 and the default decoder identifier for each common category transmitted by the electronic device 100. The electronic device 100 transmits audio data to the audio playback device 200 based on the common categories supported by the electronic device 100 and the audio playback device 200.
[0391] In some embodiments, if audio playback device 200 classifies all decoders in audio playback device 200 into multiple categories based on a codec classification standard, audio playback device 200 transmits each category identifier and a decoder identifier corresponding to each category to electronic device 100 before electronic device 100 negotiates regarding a common category supported by electronic device 100 and audio playback device 200. In this case, after electronic device 100 determines the common categories supported by electronic device 100 and audio playback device 200, electronic device 100 only needs to transmit the common categories supported by electronic device 100 and audio playback device 200 to audio playback device 200.
[0392] After the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200, when the audio playback device 200 determines a default decoder identifier for the common categories supported by the electronic device 100 and the audio playback device 200, the electronic device 100 only needs to send the identifier of the common category supported by the electronic device 100 and the audio playback device 200 to the audio playback device 200.
[0393] In some embodiments, when the electronic device 100 negotiates for a common category, the audio playback device 200 transmits to the electronic device 100 all decoder identifiers on the audio playback device 200 and values of one or more parameters corresponding to each decoder. The electronic device 100 classifies all encoders in the electronic device 100 and all decoders in the audio playback device 200 into multiple categories based on a codec classification standard. Then, the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200. In this case, in addition to the common categories supported by the electronic device 100 and the audio playback device 200, the electronic device 100 needs to further transmit to the audio playback device 200 the decoder identifiers of the common categories supported by the electronic device 100 and the audio playback device 200.
[0394] Furthermore, after the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200, the electronic device 100 may determine a default decoder identifier for the common categories supported by the electronic device 100 and the audio playback device 200. When the electronic device 100 determines the default decoder identifier for the common categories supported by the electronic device 100 and the audio playback device 200, when sending the identifier for the common category supported by the electronic device 100 and the audio playback device 200 to the audio playback device 200, the electronic device 100 needs to further send the default decoder identifier for the common category supported by the electronic device 100 and the audio playback device 200 to the audio playback device 200.
[0395] Alternatively, after the electronic device 100 determines the common categories supported by the electronic device 100 and the audio playback device 200, when the audio playback device 200 determines a default decoder identifier for the common categories supported by the electronic device 100 and the audio playback device 200, when sending the common categories supported by the electronic device 100 and the audio playback device 200 to the audio playback device 200, the electronic device 100 needs to further send to the audio playback device 200 a default decoder identifier for the common categories supported by the electronic device 100 and the audio playback device 200.
[0396] S907: The electronic device 100 selects a default codec of a first category from the common categories to transmit the audio data.
[0397] The electronic device 100 obtains first parameter information of the audio data, and when the first parameter information of the audio data satisfies a first condition, encodes the audio data into first encoded audio data based on a first encoder of a first category, and sends the first encoded audio data to the audio playback device.
[0398] Specifically, the electronic device 100 may select a default codec of a category (e.g., a first category) from the common categories supported by the electronic device 100 and the audio playback device 200 based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, the network status of the channel, and the audio stream format, etc., to transmit audio data. The default encoder of the first category is the first encoder, and the default decoder of the first category is the first decoder. The contents of this part have been described in detail in the preceding embodiment. In this application, the details will not be described again here.
[0399] For example, the electronic device 100 determines, based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, the network status of the channel, etc., that the first parameter information is as follows: the sampling rate is a first sampling rate, the quantization bit depth is a first quantization bit depth, the bit rate is a first bit rate, and the number of audio channels is a first number of audio channels. The electronic device 100 selects a default codec of a category, in which the sampling rate includes the first sampling rate, the quantization bit depth includes the first quantization bit depth, the bit rate includes the first bit rate, the number of audio channels includes the first number of audio channels, and the audio stream format includes PCM, from the common category to transmit the audio data.
[0400] When the electronic device 100 determines two or more categories from the common categories supported by the electronic device 100 and the audio playback device 200 based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, the network condition of the channel, and the audio stream format, etc., the electronic device 100 may select the category with the highest priority from the two or more categories as the first category, and transmit the audio data using the default codec of the category with the highest priority. It can be understood that a higher sampling rate, a higher bit rate, and a higher quantization depth specified in the codec classification standard indicate a higher sound quality of the codec classified into the category. A higher sound quality of the codec indicates a higher priority of the category to which the codec belongs.
[0401] For example, the common categories supported by the electronic device 100 and the audio playback device 200 include category 1 and category 2. It is assumed that the categories selected by the electronic device 100 based on the application type, the audio playback characteristics (sampling rate, quantization bit depth, or number of audio channels), whether the audio rendering capability of the electronic device is enabled, the network condition of the channel, and the audio stream format, etc., include category 1 and category 2. The codecs classified in category 1 are codecs with high-definition sound quality, and the codecs classified in category 2 are codecs with standard sound quality. The priority of category 1 is higher than the priority of category 2. Therefore, the electronic device 100 preferentially selects the default codec of category 1 to transmit audio data.
[0402] S908: The electronic device 100 sends the first category identifier to the audio playing device 200.
[0403] The audio playback device 200 receives the first category identifier sent by the electronic device 100, and the electronic device 100 transmits audio data to the audio playback device 200 using a default codec corresponding to the first category identifier.
[0404] S909: The electronic device 100 obtains audio data and encodes the audio data using the encoder corresponding to the first encoder identifier to obtain encoded audio data.
[0405] The first encoder identifier is the default encoder identifier for the first category.
[0406] S910: The electronic device 100 transmits the encoded audio data (the first encoded audio data) to the audio playback device 200.
[0407] Specifically, the electronic device 100 may obtain currently played audio data, such as by recording, then compress the obtained audio data, and send the compressed audio data to the audio playback device 200 via a communication connection to the audio playback device 200. For example, the electronic device 100 and the audio playback device 200 share multimedia content based on miracast. The electronic device 100 captures the audio played by the electronic device 100, compresses the audio using an advanced audio coding (AAC) algorithm, encapsulates the compressed audio data into a transport stream (TS), then encodes the TS stream according to a real-time transport protocol (RTP), and transmits the encoded data to the audio playback device 200 via a Bluetooth channel connection.
[0408] S911: To obtain audio data (first playback audio data), the audio playback device 200 receives the encoded audio data transmitted by the electronic device 100 and decodes the encoded audio data using a decoder corresponding to the first decoder identifier.
[0409] The first decoder identifier is a default decoder identifier for the first category.
[0410] The audio playback device 200 decodes the encoded audio data using a decoder corresponding to the first decoder identifier to obtain unencoded audio data and plays the audio data.
[0411] S912: The electronic device 100 switches from the first category to the second category.
[0412] When the sampling rate, bit rate, quantization bit depth, and / or number of audio channels of the audio data of the electronic device 100 change, the electronic device 100 reselects a codec of another category (i.e., a second category) to transmit the audio data, and the electronic device 100 notifies the audio reproduction device 200 of the category identifier. The electronic device 100 transmits the audio data to the audio reproduction device 200 using the codec of the second category. The contents of this part have been described in detail in the preceding embodiment. The details will not be described again here in this application.
[0413] The electronic device 100 switches from the first category to the second category when the sampling rate, bit rate, quantization bit depth, and / or number of audio channels of the audio data played by the electronic device changes due to user selection, a change in application type, a change in audio content, enabling of the electronic device's audio rendering capabilities, or deteriorating network conditions of a channel, etc.
[0414] For example, when the electronic device 100 receives a user's operation to select a high quality mode, the electronic device 100 switches from the first category to the second category, and the audio quality of the codec of the second category is higher than that of the codec of the first category, and the sampling rate, bit rate, and quantization bit depth of the codec of the second category are all greater than those of the codec of the first category.
[0415] As shown in Fig. 10A, the electronic device 100 accepts a user's tapping operation on the further control 608, and in response to the user's operation, the electronic device 100 displays a prompt box 900 shown in Fig. 10B. The prompt box 900 includes a high quality mode control 901, a stable transmission mode control 902, and an audio rendering mode enable control 903. When the user expects higher sound quality of the audio data played by the electronic device 100, the high quality mode control 901 in the prompt box 900 may accept a tapping operation performed by the user, and in response to the tapping operation performed by the user, the electronic device 100 switches from the first category to the second category, and the audio quality of the codec of the second category is higher than the audio quality of the codec of the first category.
[0416] For example, when the electronic device 100 accepts a user operation and enables the audio rendering capability, the electronic device 100 may increase a sampling rate of the played audio data from a first sampling rate to a second sampling rate, the rendering unit of the electronic device 100 may increase a quantization bit depth value of the audio data from the first quantization bit depth to a second quantization bit depth, and the rendering unit of the electronic device 100 may increase a number of audio channels value of the audio data from the first number of audio channels to a second number of audio channels, where 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 audio channels is greater than the first number of audio channels.
[0417] As shown in FIG. 10C, when a user expects the electronic device 100 to enable its audio rendering capabilities, the audio rendering mode enable control 903 in the prompt box 900 may accept a tapping operation performed by the user, and in response to the tapping operation performed by the user, the electronic device 100 switches from the first category to the second category, and the sampling rate, bit rate, quantization bit depth, and number of audio channels of the codec of the second category are all greater than those of the codec of the first category.
[0418] For example, when the network of the electronic device 100 is unstable, the electronic device 100 may accept a user operation and switch the current transmission mode of audio data to a stable transmission mode. When the user selects to enable the stable transmission mode, the electronic device 100 switches from the first category to the second category, and the bit rate of the codec of the second category is lower than the bit rate of the codec of the first type. Alternatively, the electronic device 100 may automatically switch to the stable transmission mode. This is not limited here in the present application.
[0419] As shown in FIG. 10D, when the user selects to enable the stable transmission mode, the stable transmission mode control 902 in the prompt box 900 can receive the tap operation executed by the user. In response to the tap operation executed by the user, the electronic device 100 switches from the first category to the second category, and the bit rate of the codec in the second category is lower than the bit rate of the codec in the first category.
[0420] 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 from the first category to the second category, encodes the audio data into second encoded audio data based on the second encoder in the second category, and transmits the second encoded audio data to the audio playback device.
[0421] The electronic device 100 transmits the identifier of the second category to the audio playback device 200.
[0422] When the application type of the audio data played by the electronic device 100 changes from application type 1 to application type 2, when the audio data played by the electronic device 100 switches from audio data 1 to audio data 2, or when the audio rendering capability of the electronic device is enabled, the second parameter information is as follows: the sampling rate of the audio data played by the electronic device 100 changes from a first sampling rate to a second sampling rate. In this case, the electronic device 100 selects a default codec of a category, in which 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 audio channels includes the first number of audio channels, and the audio stream format includes PCM, from the common categories supported by the electronic device 100 and the audio playback device 200 to transmit the audio data.
[0423] The first and second conditions of S907 to S912 will be explained in detail as follows.
[0424] The types of parameters in the first parameter information, the types of parameters in the parameter information of the first encoder, the types of parameters in the parameter information of the first decoder, the types of parameters in the parameter information of the second parameter, the types of parameters in the parameter information of the second encoder, and the types of parameters in the parameter information of the second decoder are the same. The first parameter information satisfying the first condition and the second parameter information satisfying the second condition specifically include: a sampling rate in the first parameter information is equal to or greater than a target sampling rate and a sampling rate in the second parameter information is less than a target sampling rate; and / or a bit rate in the first parameter information is equal to or greater than a target bit rate and a bit rate in the second parameter information is less than a target bit rate; and / or a quantization bit depth in the first parameter information is equal to or greater than a target quantization bit depth and a quantization bit depth in the second parameter information is less than a target quantization bit depth; and / or a number of audio channels in the first parameter information is equal to or greater than a target number of audio channels and a number of audio channels in the second parameter information is less than the target number of audio channels; and / or an audio stream format in the first parameter information is a target audio stream format and an audio stream format in the second parameter information is a target audio stream format.
[0425] S913: The electronic device 100 sends the second category identifier to the audio playing device 200.
[0426] The audio playback device 200 receives the second category identifier sent by the electronic device 100. The electronic device 100 transmits the audio data to the audio playback device 200 using a default codec that corresponds to the second category identifier.
[0427] Specifically, the electronic device 100 captures audio data, the electronic device 100 encodes the audio data using an encoder corresponding to the second encoder identifier to obtain encoded audio data (second encoded audio data), the electronic device 100 transmits the encoded audio data to the audio playback device 200, the audio playback device 200 decodes the audio data using a decoder corresponding to the second decoder identifier to obtain unencoded audio data (second reproduced audio data), and the audio playback device 200 reproduces the unencoded audio data (second reproduced audio data).
[0428] The second encoder identifier is a default encoder identifier for the second category, and the second decoder identifier is a default decoder identifier for the second category.
[0429] In order to avoid interruptions in the sound image during codec switching performed by the electronic device 100 and the audio playback device 200, a smooth transition is implemented for audio data during switching performed by the electronic device 100 and the audio playback device 200, improving the user experience.
[0430] When the delays of the first encoder and the second encoder are the same, the electronic device encodes a first audio frame in the audio data into a first encoded audio frame and transmits the first encoded audio frame to an audio playback device, encodes a first audio frame in the audio data into a second encoded audio frame and transmits the second encoded audio frame to an audio playback device, encodes a second audio frame in the audio data into an Nth encoded audio frame and transmits the Nth encoded audio frame to an audio playback device using a first decoder, decodes the second encoded audio frame into a second decoded audio frame using a second decoder, decodes the Nth encoded audio frame into an Nth played back audio frame using a second decoder, and smoothes the first decoded audio frame and the second decoded audio frame to obtain a first played back audio frame. The electronic device 100 first plays the first playback audio frame, and then the electronic device 100 plays the Nth playback audio frame. Thus, when the delays of the first encoder and the second encoder are the same, the switching between the first encoder and the second encoder needs to be completed within one frame, and the frame is the first audio frame. The audio playback device smoothes the first audio frame and then plays the smoothed first audio frame to prevent audio dropouts during codec switching and to implement a smooth transition. The adjacent audio frame after the first audio frame, for example the second audio frame, does not need to be smoothed, and the second audio frame is directly decoded and played using the second decoder.
[0431] The audio playback device obtains the first playback audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where Pcm is the first playback audio frame, wi is a smoothing coefficient, and w i is Greater than 0 and less than 1, pcmA is the first decoded audio frame and pcmB is the second decoded audio frame.
[0432] When the delays of the first encoder and the second encoder are different, the electronic device obtains D audio data frames using the following formula: D=round((max(encoder 1 total delay, encoder 2 total delay)+(frame length-encoder 1 total delay%frame length)+frame length-1) / frame length), where D denotes the total number of audio data frames when switching between the first encoder and the second encoder, max denotes the operation for obtaining the maximum value, % denotes the modulo operation, and frame length denotes the duration of one frame of audio data. encoding the 1st through Dth audio frames in the audio data using a first encoder to obtain a (D+3)th encoded audio frame, encoding the Dth audio frame in the audio data using a second encoder to obtain a (D+1)th audio frame in the audio data using a second encoder to obtain an Nth encoded audio frame, and transmitting the 3rd through (D+2)th encoded audio frames, the (D+3)th encoded audio frame, and the Nth encoded audio frame to the audio playback device. The audio playback device uses a first decoder to decode the (D+2)th encoded audio frame from the third encoded audio frame to the second reproduced audio frame to the (D+1)th reproduced audio frame, uses a second decoder to decode the (D+3)th encoded audio frame into a third decoded audio frame, reproduces the second reproduced audio frame to the Dth reproduced audio frame, smoothes the (D+1)th reproduced audio frame and the third decoded audio frame to obtain a target reproduced audio frame, reproduces the target reproduced audio frame, and uses the second decoder to decode the Nth encoded audio frame into the Nth decoded audio frame, and reproduces the Nth decoded audio frame.In this way, when the 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 a number of frames (D frames). In this way, when 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 switching between the encoders needs to be completed within D frames, the audio playback device directly decodes the first audio frame to the (D-1)th audio frame and plays the decoded audio frames, and the audio playback device smoothes the Dth audio frame and then plays the smoothed audio frame, in order to prevent sound dropouts during codec switching and to implement a smooth transition. The adjacent audio frame after the Dth audio frame, for example the Nth audio frame, does not need to be smoothed, and the Nth audio frame is directly decoded and played.
[0433] The audio playback device obtains the target playback audio frame using the following formula: Pcm=wi×pcmA+(1-wi)×pcmB, where 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+1)th playback audio frame, and pcmB is the third decoded audio frame.
[0434] The manner in which the electronic device 100 and the audio playback device 200 implement a smooth transition of audio data during switching has been described in detail in the preceding embodiments, and will not be described in detail again here in this application.
[0435] Alternatively, S912 and S913 may be replaced with the following operations, in which when the second parameter information satisfies the second condition, the audio data is encoded into third encoded audio data using a first encoder of the first category, and the third encoded audio data is sent to the audio playback device. The audio playback device is further configured to decode the third encoded audio data into third reproduced audio data using a first decoder of the first category. When the electronic device and the audio playback device support only one codec category (first category), 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 transmits the audio data to the audio playback device using a default codec of the first category.
[0436] Finally, the above embodiments are only for describing the technical solutions of the present application, and are not intended to limit the present application. Although the present application has been described in detail with reference to the above embodiments, those skilled in the art should understand that, without departing from the scope of the technical solutions of the embodiments of the present application, the technical solutions described in the above embodiments may be further modified, or equivalent substitutions of some technical features thereof may be made. [Explanation of symbols]
[0437] 100 Electronic Devices 110 Processor 120 External Memory Interface 121 Internal Memory 130 USB interface 140 Charging Management Module 141 Power Management Module 142 Battery 150 Mobile communication module 160 Wireless Communication Module 170 Audio Module 170A Speaker 170B Receiver 170C Microphone 170D Headset Jack 180 Sensor Module 180A Pressure Sensor 180B Gyro Sensor 180C Barometric Pressure Sensor 180D Magnetic Sensor 180E Acceleration Sensor 180F Distance Sensor 180G Optical Proximity Sensor 180H Fingerprint Sensor 180J Temperature Sensor 180K Touch Sensor 180L Ambient Light Sensor 180M Bone Conduction Sensor 190 Button 191 Motor 192 Indicator 193 Camera 194 Display 195 SIM Card Interface 200 Audio Playback Device 201 Processor 202 Memory 203 Bluetooth Communication Module 204 Antenna 205 Power Switch 206 USB Communication Processing Module 207 Audio Module 600 Audio Playback User Interface 601 Song Name 602 Playback Control 603 Previous Song Control 604 Next Song Control 605 Playback Progress Bar 606 Download Control 607 Sharing Control 608 Further Control 610 Window 611 Bluetooth Control 900 Prompt Box 901 High Quality Mode Control 902 Stable transmission mode control 903 Audio Rendering Mode Enable Control< / canvas> < / video> < / videoview> < / imgview> < / textview>
Claims
1. 1. A codec negotiation and switching system, comprising: an electronic device and an audio playback device; The electronic device comprises: When first parameter information of audio data satisfies a first condition, encode the audio data into first encoded audio data based on a first encoder of a first category, and send the first encoded audio data to the audio playback device, the first category being a common codec category supported by the electronic device and the audio playback device, the common codec category being determined by the electronic device before the electronic device obtains the audio data; Transmitting an identifier of the first category to the audio playback device. It is configured as follows: The audio playback device is receiving the identifier of the first category transmitted by the electronic device; Decoding the first encoded audio data into first reproduced audio data using a first decoder of the first category. It is configured as follows: The electronic device comprises: When second parameter information of the audio data satisfies a second condition, encode the audio data into second encoded audio data based on a second encoder of a second category, and send the second encoded audio data to the audio playback device, the second category being a common codec category supported by the electronic device and the audio playback device, the common codec category being determined by the electronic device before the electronic device obtains the audio data; Sending the second category identifier to the audio playback device The method further comprises: The audio playback device is receiving the identifier of the second category transmitted by the electronic device; Decoding the second encoded audio data into second reproduced audio data using a second decoder of the second category. The method further comprises: The codec negotiation and switching system, wherein the first condition is different from the second condition and the first category is different from the second category.
2. The system of claim 1 , wherein the first category of encoders includes at least the first encoder, and the second category of encoders includes at least the second encoder.
3. When the delays of the first encoder and the second encoder are the same, the electronic device: encoding a first audio frame in the audio data into a first encoded audio frame using the first encoder and transmitting 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 using the second encoder and transmitting the second encoded audio frame to the audio playback device. The method further comprises: The audio playback device includes: Decoding the first encoded audio frame into a first decoded audio frame using the first decoder, decoding the second encoded audio frame into a second decoded audio frame using the second decoder, and smoothing the first decoded audio frame and the second decoded audio frame to obtain a first reproduced audio frame. further comprising: The system of claim 1.
4. When the delays of the first encoder and the second encoder are different, the electronic device obtaining D audio data frames using the following formula: D=round((max(encoder 1 total delay, encoder 2 total delay)+(frame length-encoder 1 total delay % frame length)+frame length-1) / frame length), where D denotes the total number of audio data frames when switching between the first encoder and the second encoder, max denotes the operation to obtain the maximum value, % denotes the modulo operation, and frame length denotes the duration of one frame of audio data; encoding a first audio frame through a Dth audio frame in the audio data using the first encoder to obtain a third encoded audio frame through a (D+2)th encoded audio frame; encoding the D audio frame in the audio data using the second encoder to obtain a (D+3)th encoded audio frame; transmitting the third encoded audio frame through the (D+2) encoded audio frame and the (D+3) encoded audio frame to the audio playback device; The method further comprises: The audio playback device is using the first decoder to decode the (D+2) encoded audio frame from the third encoded audio frame to a second reproduced audio frame to a (D+1) reproduced audio frame, and using the second decoder to decode the (D+3) encoded audio frame to a third decoded audio frame; playing the second playback audio frame through the D playback audio frame; Smoothing the (D+1) reconstructed audio frame and the third decoded audio frame to obtain a target reconstructed audio frame. [0033] The system of claim 1.
5. The audio playback device is Obtain the first reconstructed audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where Pcm is the first reconstructed 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; [0033] The system of claim 3.
6. The audio playback device is Obtain the target playback audio frame using the following formula: Pcm=wi×pcmA+(1−wi)×pcmB, where 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+1) playback audio frame, and pcmB is the third decoded audio frame; [0033] The system of claim 4.
7. 1. A codec negotiation and switching method, the method comprising: encoding, by an electronic device, the audio data into first encoded audio data based on a first encoder of a first category when first parameter information of the audio data satisfies a first condition, and sending the first encoded audio data to an audio playback device, the first category being a common codec category supported by the electronic device and the audio playback device, the common codec category being determined by the electronic device before the electronic device obtains the audio data; encoding, by the electronic device, the audio data based on a second encoder of a second category into second encoded audio data and sending the second encoded audio data to the audio playback device when the second parameter information satisfies a second condition, the second category being a common codec category supported by the electronic device and the audio playback device and determined by the electronic device before the electronic device obtains the audio data, the second category being a common codec category supported by the electronic device and the audio playback device and determined by the electronic device before the electronic device obtains the audio data, the first condition being different from the second condition, and the first category being different from the second category; A codec negotiation and switching method comprising:
8. The method comprises: receiving, by the electronic device, the first category identifier and the second category identifier transmitted by the audio playback device, the first category decoder including at least a first decoder and the second category decoder including at least a second decoder; 8. The method of claim 7, further comprising:
9. When common encoder categories supported by the electronic device and the audio playback device include only the first category, the method further comprises: encoding, by the electronic device, the audio data using the first encoder of the first category into third encoded audio data when the second parameter information satisfies the second condition, and transmitting the third encoded audio data to the audio playback device.
8. The method of claim 7, further comprising:
10. Before the electronic device acquires the audio data, the method further comprises: classifying, by the electronic device, the first encoder into the first category based on parameter information of the first encoder and a 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, the parameter information of the first encoder and the parameter information of the second encoder including one or more of a sampling rate, a bit rate, a quantization bit depth, a number of audio channels, and an audio stream format, and the codec classification standard including a mapping relationship between codec categories and parameter information of codecs.
8. The method of claim 7, further comprising:
11. the sampling rate of the codec of the first category is equal to or greater than a target sampling rate and the sampling rate of the codec of the second category is less than the target sampling rate; and / or the bitrates of the codecs of the first category are equal to or greater than a target bitrate and the bitrates of the codecs of the second category are less than the target bitrate; and / or the number of audio channels of the codecs of the first category is equal to or greater than a target number of audio channels and the number of audio channels of the codecs of the second category is less than the target number of audio channels; and / or the quantization bit depth of the codecs of the first category is greater than or equal to a target quantization bit depth and the quantization bit depth of the codecs of the second category is less than the target quantization bit depth; and / or 11. The method of claim 10, wherein an audio stream format of the codec of the first category is a target audio stream format and an audio stream format of the codec of the second category is the target audio stream format.
12. a type of a parameter in the first parameter information, a type of a parameter in the parameter information of the first encoder, a type of a parameter in the parameter information of a first decoder, a type of a parameter in the parameter information of a second parameter, a type of a parameter in the parameter information of the second encoder, and a type of a parameter in the parameter information of a second decoder are the same; Specifically, the first parameter information satisfies the first condition and the second parameter information satisfies the second condition. 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 a quantization bit depth in the first parameter information is greater than or equal to the target quantization bit depth and a quantization bit depth in the second parameter information is less than the target quantization bit depth; and / or the number of audio channels in the first parameter information is equal to or greater than the target number of audio channels and the number of audio channels in the second parameter information is less than the target number of audio 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; The method of claim 11 , comprising:
13. 13. An electronic device comprising one or more processors, one or more memories and one or more encoders, the one or more memories being coupled to the one or more processors, the one or more memories being configured to store computer program code, the computer program code comprising computer instructions, the one or more processors invoking the computer instructions to enable the electronic device to perform a method according to any one of claims 7 to 12.
14. 13. A computer-readable storage medium having stored thereon computer-executable instructions, the computer-executable instructions being used to execute a method according to any one of claims 7 to 12 when invoked by a computer.
15. A program adapted to cause a processor to carry out the method according to any one of claims 7 to 12.
Citation Information
Patent Citations
Method and apparatus for smooth stream switching in MPEG / 3GPP-DASH
CN104509119A
Method and device for adjusting Bluetooth A2DP coding setting
CN107404339A
How to Encode and Decode Audio at Variable Rate
JP2006513457A
Method and apparatus for encoding and decoding object-based audio signals.
JP2010511189A
Signal classification method and device, and audio encoding method and device using the same
JP2017511905A