This application relates to the field of wireless communication technologies, and in particular, to a video transmission method and apparatus, and an electronic device.
With rapid development of wireless communication technologies, wireless networks greatly improve convenience of people's life and work. However, due to limited resources of a wireless network, some troubles may also be brought when the wireless network is used. For example, when video data is transmitted in the wireless network, because the wireless network fluctuates, and a quantity of users accessing the wireless network is random, a capacity of the wireless network that can be used by each user accessing the wireless network is not constant and fluctuates. Consequently, a delay of video data transmission is varying, and a video receive end cannot obtain the video data in time when the delay is long. When the video receive end cannot obtain the video data in time, a phenomenon, for example, frame skipping, erratic display, and frame freezing, usually occurs at the video receive end, so that the user cannot watch a video smoothly, and experience is poor.
Embodiments of this disclosure provide a video transmission method and apparatus, and an electronic device, to dynamically adjust a quantity of layers for layered coding of video data based on a change trend of an available channel capacity on a video data transmission channel, so that when the available channel capacity is changed, it can be ensured that data included in at least one frame of data in the video data can be transmitted. This ensures that a video receive end can smoothly play the video data, avoids a phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end, and improves user experience.
According to a first aspect, this application provides a video transmission method. The method may include: obtaining a change trend of an available channel capacity on a first channel, where the first channel is used to transmit video data; adjusting, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data; performing layered coding on the at least one frame of data based on a quantity of layers obtained after adjustment; and outputting coded data obtained through layered coding. In this way, when the change trend of the available channel capacity on the video data transmission channel is obtained, the quantity of layers during layered coding of the video data is dynamically adjusted based on the change trend of the available channel capacity, so that when the available channel capacity is changed, it can be ensured that at least data included in a base layer of the at least one frame of data in the video data can be transmitted. This ensures that a video receive end can smoothly play the video data, avoids a phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end, and improves user experience.
In a possible implementation, the adjusting, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data specifically includes: when the available channel capacity trends to decrease, increasing the quantity of layers during layered coding of the at least one frame of data; and when the available channel capacity trends to increase, decreasing the quantity of layers during layered coding of the at least one frame of data, or keeping the quantity of layers during layered coding of the at least one frame of data unchanged. In this way, when the available channel capacity trends to decrease, the quantity of layers during layered coding is increased, to decrease a data amount of a base layer, thereby ensuring that the base layer can be successfully transmitted, and meeting a requirement of basic image transmission without a frame loss. When the available channel capacity tends to increase, the quantity of layers during layered coding is decreased, to decrease a total data amount of the at least one frame of data, and improve transmission efficiency of the video data. Because each layer of data obtained by performing layered coding on the at least one frame of data includes data such as matching control information and some redundant information, after the quantity of layers for layered coding of the at least one frame of data is decreased, as the quantity of layers is decreased, the data such as the matching control information and the some redundant information is also removed, thereby decreasing the total data amount of the at least one frame of data. In addition, when the available channel capacity tends to increase, the quantity of layers during layered coding of the at least one frame of data may also be kept unchanged, to improve stability during layered coding.
In a possible implementation, the method further includes: increasing or decreasing, based on a preset adjustment amount, the quantity of layers during layered coding of the at least one frame of data. In this way, in a process of adjusting the quantity of layers during layered coding, adjustment may be performed based on the preset adjustment amount, thereby improving adjustment efficiency.
In a possible implementation, the method further includes: adding identification information to each layer of layered coded data obtained through layered coding. The identification information is used to distinguish between different layered coded data. In this way, different layered coded data is distinguished by using the identification information, so that each layer of coded data may be independently encapsulated into a data packet (which may also be referred to as a data frame unit) subsequently.
In a possible implementation, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data. In this way, different layers of layered coded data may be distinguished by using the layer identifier, and after the layer identifier is obtained, statistics may be collected on an obtained data amount of data by using the first data amount. When the obtained data amount is the same as the first data amount, it may be determined that one layer of layered coded data has been obtained, and the layer of layered coded data may be independently encapsulated.
In a possible implementation, the identification information includes a header identifier and a tail identifier of the layered coded data. In this way, after the header identifier and the tail identifier are obtained, it may be determined that one layer of layered coded data has been obtained, so that data (namely, the layer of layered coded data) obtained between the header identifier and the tail identifier may be independently encapsulated.
In a possible implementation, the outputting coded data obtained through layered coding specifically includes: writing the coded data obtained through layered coding into preset storage space. The preset storage space may be accessed by a channel coding apparatus. In this way, after a source coding apparatus completes data coding, the channel coding apparatus may obtain the layered coded video data.
In a possible implementation, the outputting coded data obtained through layered coding specifically includes: sending the coded data obtained through layered coding to a data cache apparatus. The data cache apparatus may be accessed by a channel coding apparatus. In this way, after a source coding apparatus completes data coding, the channel coding apparatus may obtain the layered coded video data.
In a possible implementation, the outputting coded data obtained through layered coding specifically includes: directly sending the coded data obtained through layered coding to a source coding apparatus. In this way, after the source coding apparatus completes data coding, a channel coding apparatus may obtain the layered coded video data.
According to a second aspect, this application provides a video transmission method. The method may include: obtaining coded data obtained by performing layered coding on video data, where the coded video data includes at least one layer of layered coded data, each layer of the at least one layer of layered coded data includes identification information, and the identification information is used to distinguish between different layered coded data; independently encapsulating, into a first data packet based on the identification information, coded data belonging to a same layer of coded data; and sending the first data packet. In this way, after the coded data obtained by performing layered coding on the video data is obtained, each layer of coded data may be independently encapsulated into a data packet (which may also be referred to as a data frame unit), and the data packet is separately sent. This can ensure that cross-layer packet composition does not occur between different layered coded data, and can also ensure that cross-frame packet composition does not occur between different frames. Further, it can be ensured that each layer of coded data can be separately sent, and a channel needs to be contended for only once when one layer of layered coded data is sent. This avoids a case in which total transmission duration of one layer of layered coded data is excessively large because the channel needs to be contended for a plurality of times when one layer of layered coded data is sent during cross-layer packet composition, and reduces a probability of data sending timeout. In addition, because each layer of layered coded data is sent as an independent data packet, a pressure of a receive buffer of a video receive end is reduced, so that a case in which the video receive end receives some data at a layer first and then receives remaining data at an interval of an unspecified delay does not exist. This improves buffer utilization. In addition, each layer of layered coded data obtained through layered coding is independently encapsulated and sent. This avoids a case in which a failure of sending one layer of data causes a failure of sending data at another layer during synchronous sending of different layers of data. In this way, a data sending success rate is improved, and it is further ensured that the video receive end can smoothly play the video data.
In a possible implementation, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data. The independently encapsulating, into a first data packet based on the identification information, coded data belonging to a same layer of layered coded data specifically includes: after the layer identifier is obtained, when a data amount of first coded data obtained after the layer identifier reaches the first data amount, independently encapsulating, into the first data packet, the first coded data obtained after the layer identifier. In this way, different layered coded data is distinguished by using the identification information, so that each layer of coded data may be independently encapsulated into a data packet (which may also be referred to as a data frame unit) subsequently, to obtain the first data packet. For example, when the first coded data is independently encapsulated into the first data packet, the layer identifier may be encapsulated together, or the layer identifier may not be encapsulated together. This may be specifically determined according to an actual situation, and is not limited herein.
In a possible implementation, the identification information includes a header identifier and a tail identifier of the layered coded data. The independently encapsulating, into a first data packet based on the identification information, coded data belonging to a same layer of layered coded data specifically includes: after the header identifier and the tail identifier are obtained, independently encapsulating, into the first data packet, coded data obtained after the header identifier is obtained and before the tail identifier is obtained. In this way, after the header identifier and the tail identifier are obtained, it may be determined that one layer of layered coded data has been obtained, so that data (namely, the layer of layered coded data) obtained between the header identifier and the tail identifier may be independently encapsulated, to obtain the first data packet. For example, when the obtained coded data is independently encapsulated into the first data packet, the corresponding header identifier and the corresponding tail identifier may be encapsulated together, or the corresponding header identifier and the corresponding tail identifier may not be encapsulated together. This may be specifically determined according to an actual situation, and is not limited herein.
In a possible implementation, the method further includes: when the channel is obtained through contention, if remaining duration for sending a first frame of data to which the first data packet belongs ends, discarding to-be-sent data in the first frame of data, and sending a next frame of data of the first frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data. In this way, when the channel is obtained through contention, if the remaining duration for sending the first frame data to which the first data packet belongs ends, the to-be-sent data that is in the first frame of data and that is subsequently sent is considered as invalid data. Therefore, if the to-be-sent data in the first frame of data continues to be sent in this case, the channel is invalidly occupied. Therefore, in this case, the to-be-sent data in the first frame of data may be discarded, and the next frame of data of the first frame of data is sent through the channel obtained through contention, so that invalid occupation of the channel can be avoided, and the next frame of data may be sent earlier. This avoids timeout of sending the next frame of data and improves data transmission efficiency.
In a possible implementation, the method further includes: when the channel is obtained through contention and the next frame of data of the first frame of data is obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discarding the to-be-sent data in the first frame of data, and sending the next frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data. In this way, when the channel is obtained through contention, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than the duration for sending the to-be-sent data in the first frame of data, the to-be-sent data that is in the first frame of data and that is subsequently sent definitely times out. Consequently, data sent after timeout is invalid data, and the channel is invalidly occupied when the to-be-sent data in the first frame of data is sent. Therefore, in this case, when the next frame of data of the first frame of data has been obtained, the to-be-sent data in the first frame of data may be discarded, and the next frame of data of the first frame of data is sent through the channel obtained through contention, so that invalid occupation of the channel can be avoided, and the next frame of data may be sent earlier. This avoids timeout of sending the next frame of data and improves data transmission efficiency.
In a possible implementation, the method further includes: when the channel is obtained through contention and the next frame of data of the first frame of data is not obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discarding the to-be-sent data in the first frame of data, and abandoning the channel obtained through contention this time. In this way, when the channel is obtained through contention, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than the duration for sending the to-be-sent data in the first frame of data, the to-be-sent data that is in the first frame of data and that is subsequently sent definitely times out. Consequently, data sent after timeout is invalid data, and the channel is invalidly occupied when the to-be-sent data in the first frame of data is sent. Therefore, in this case, when the next frame of data of the first frame of data is not obtained, the to-be-sent data in the first frame of data may be discarded. However, after the to-be-sent data in the first frame of data is discarded, because the next frame of data of the first frame of data is not obtained, the channel is wasted. Therefore, the channel obtained through contention may be discarded, that is, a channel resource is allocated to another user. This improves data transmission efficiency on the channel.
According to a third aspect, this application provides a video transmission apparatus. The apparatus may include: a first processing module, configured to obtain a change trend of an available channel capacity on a first channel, where the first channel is used to transmit video data; adjust, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data; and perform layered coding on the at least one frame of data based on a quantity of layers obtained after adjustment; and a first communication module, configured to output coded data obtained through layered coding.
In a possible implementation, the first processing module is further configured to: when the available channel capacity trends to decrease, increase the quantity of layers during layered coding of the at least one frame of data; and when the available channel capacity trends to increase, decrease the quantity of layers during layered coding of the at least one frame of data, or keep the quantity of layers during layered coding of the at least one frame of data unchanged.
In a possible implementation, the first processing module is further configured to increase or decrease, based on a preset adjustment amount, the quantity of layers during layered coding of the at least one frame of data.
In a possible implementation, the first processing module is further configured to add identification information to each layer of layered coded data obtained through layered coding. The identification information is used to distinguish between different layered coded data.
In a possible implementation, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data; or the identification information includes a header identifier and a tail identifier of the layered coded data.
According to a fourth aspect, this application provides a video transmission apparatus. The apparatus may include: a second processing module, configured to obtain coded data obtained by performing layered coding on video data, where the layered coded video data includes at least one layer of layered coded data, each layer of the at least one layer of layered coded data includes identification information, and the identification information is used to distinguish between different layered coded data; and independently encapsulate, into a first data packet based on the identification information, coded data belonging to a same layer of layered coded data; and a second communication module, configured to send a first data packet.
In a possible implementation, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data. The second processing module is further configured to: after the layer identifier is obtained, when a data volume of first coded data obtained after the layer identifier reaches the first data amount, independently encapsulate, into the first data packet, the first coded data obtained after the layer identifier.
In a possible implementation, the identification information includes a header identifier and a tail identifier of layered coded data. The second processing module is further configured to: after the header identifier and the tail identifier are obtained, independently encapsulate, into the first data packet, coded data obtained after the header identifier is obtained and before the tail identifier is obtained.
In a possible implementation, the second processing module is further configured to: when a channel is obtained through contention, if remaining duration for sending a first frame of data to which the first data packet belongs ends, discard to-be-sent data in the first frame of data, and send a next frame of data of the first frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In a possible implementation, the second processing module is further configured to: when the channel is obtained through contention and the next frame of data of the first frame of data is obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discard the to-be-sent data in the first frame of data, and send the next frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In a possible implementation, the second processing module is further configured to: when the channel is obtained through contention and the next frame of data of the first frame of data is not obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discard the to-be-sent data in the first frame of data, and abandon the channel obtained through contention this time.
According to a fifth aspect, this application provides a video transmission method. The method may include: obtaining a change trend of an available channel capacity on a first channel, where the first channel is used to transmit video data; adjusting, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data; performing layered coding on the at least one frame of data based on a quantity of layers obtained after adjustment; and outputting at least one frame of data obtained through layered coding.
In a possible implementation, the obtaining a change trend of an available channel capacity on a first channel specifically includes: collecting statistics on a data sending success rate in a video data transmission process; and obtaining the change trend of the available channel capacity based on the success rate.
In a possible implementation, the adjusting, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data specifically includes: when the available channel capacity trends to decrease, increasing the quantity of layers during layered coding of the at least one frame of data; and when the available channel capacity trends to increase, decreasing the quantity of layers during layered coding of the at least one frame of data, or keeping the quantity of layers during layered coding of the at least one frame of data unchanged.
In a possible implementation, the method further includes: increasing or decreasing, based on a preset adjustment amount, the quantity of layers during layered coding of the at least one frame of data.
In a possible implementation, the outputting at least one frame of data obtained through layered coding specifically includes: encapsulating each layer of layered coded data in the first frame of data into an independent data frame unit, and separately outputting the data frame unit corresponding to each layer of layered coded data in the first frame of data. The first frame of data is any frame of data in the video data.
In a possible implementation, the method further includes: when a channel is obtained through contention, if remaining duration for sending a first frame of data to which the first data packet belongs ends, discarding to-be-sent data in the first frame of data, and sending a next frame of data of the first frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In a possible implementation, the method further includes: when the channel is obtained through contention and the next frame of data of the first frame of data is obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discarding the to-be-sent data in the first frame of data, and sending the next frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In a possible implementation, the method further includes: when the channel is obtained through contention and the next frame of data of the first frame of data is not obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discarding the to-be-sent data in the first frame of data, and abandoning the channel obtained through contention this time.
In a possible implementation, the method further includes: when layered coding is performed on the at least one frame of data, adding identification information to each layer of layered coded data obtained through layered coding. The identification information is used to distinguish between different layered coded data.
In a possible implementation, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data; or the identification information includes a header identifier and a tail identifier of the layered coded data.
According to a sixth aspect, this application provides a video transmission apparatus, including at least one processor and an interface. The at least one processor obtains program instructions or data through the interface. The at least one processor is configured to execute the program instructions, to implement the method provided in the first aspect, or implement the method provided in the second aspect, or implement the method provided in the fifth aspect.
According to a seventh aspect, this application provides an electronic device, including: at least one memory, configured to store a program; and at least one processor, configured to invoke the program stored in the memory, to perform the method provided in the first aspect and/or the second aspect, or perform the method provided in the fifth aspect.
According to an eighth aspect, this application provides a computer storage medium. The computer storage medium stores instructions. When the instructions are run on a computer, the computer is enabled to perform the method provided in the first aspect, or perform the method provided in the second aspect, or perform the method provided in the fifth aspect.
According to a ninth aspect, this application provides a computer program product including instructions. When the instructions are run on a computer, the computer is enabled to perform the method provided in the first aspect, or perform the method provided in the second aspect, or perform the method provided in the fifth aspect.
It may be understood that, for beneficial effect of the third aspect to the ninth aspect, refer to the related descriptions in the first aspect and the second aspect. Details are not described herein again.
The following briefly describes the accompanying drawings that need to be used in the descriptions of embodiments or a conventional technology.
(A) in
(B) in
To make objectives, technical solutions, and advantages of embodiments of this application clearer, the following describes the technical solutions in embodiments of this application with reference to the accompanying drawings.
In the descriptions of this embodiment of this application, words such as “example”, “for example”, or “exemplary” are used to represent giving an example, an illustration, or a description. Any embodiment or design scheme described as an “example”, “for example”, or “exemplary” in embodiments of this application should not be explained as being more preferred or having more advantages than another embodiment or design scheme. Exactly, use of the word “example”, “for example”, “exemplary”, or the like is intended to present a relative concept in a specific manner.
In the descriptions of embodiments of this application, the term “and/or” describes only an association relationship for describing associated objects and represents that three relationships may exist. For example, A and/or B may represent the following three cases: Only A exists, both A and B exist, and only B exists. In addition, unless otherwise specified, the term “a plurality” means two or more. For example, a plurality of systems refers to at least two systems, and a plurality of terminals refers to at least two terminals.
Moreover, the terms “first” and “second” are merely intended for a purpose of description, and shall not be understood as an indication or implication of relative importance or implicit indication of an indicated technical feature. Therefore, a feature limited by “first” or “second” may explicitly or implicitly include one or more features. The terms “include”, “have”, and their variants all mean “include but are not limited to”, unless otherwise specifically emphasized in another manner.
For ease of understanding the technical solutions of this application, technical terms in this application are first described.
The available channel capacity is a data amount that can be transmitted by a device or may be referred to as a capacity of a channel that can be used by a device when the device transmits data on the channel.
The following describes scenarios that may be involved in this application. It may be understood that the following scenarios are merely examples for description. In some embodiments, the following scenarios may be replaced with another scenario in which the available channel capacity is changed, and solutions obtained after replacement still falls within the protection scope of this application.
For example,
Usually, a video coding technology, for example, scalable video coding (SVC) may be used to perform layered coding on each frame of data in the video data transmitted by the video transmit end 100, to obtain one or more layers of data. Then, each layer of data is transmitted. The data obtained through layered coding may include a base layer, an enhancement layer 1, an enhancement layer 2, . . . , and an enhancement layer n. Data at the base layer may enable the video receive end 200 to obtain basic video content completely and normally through decoding, but the video image obtained based on the data at the base layer may have a low frame rate, a low resolution, or low quality. When a channel is limited or a channel environment is complex, the data at the base layer can ensure that the video receive end 200 can receive a smooth video image that can be watched. The enhancement layer extracts, on the basis of the base layer, other image data that can improve basic video content included in the base layer, where the other image data is a type of data attached to image data at the base layer. When the channel environment is good or channel resources are abundant, data at the enhancement layer may be transferred, to improve a frame rate, a resolution, video quality, or the like of the basic video content included in the base layer. There may be a plurality of enhancement layers, and each layer is accumulated and combined based on previous several layers for use. The base layer is overlaid with the n enhancement layers to form a frame of clear image data. It may be understood that a larger data amount at the base layer indicates a clearer image formed by data included in the base layer. On the contrary, a smaller base layer indicates a hazier image formed by data included in the base layer. In addition, in a data transmission process, sorting of the layers has priorities. A priority of the base layer is the highest, and priorities of the enhancement layer 1 to the enhancement layer n are in descending order. It may be understood that an objective of performing layered coding on the video data is to improve a data transmission success rate and efficiency. Because an entire frame of image data is usually of a large data amount, and cannot be transmitted at a time, the entire frame of image data needs to be divided into several groups of data for transmission. However, this layered coding manner ensures that a basic requirement of image transmission without a frame loss can be met if transmission at the base layer succeeds. In an example, each layer of data may also be referred to as each layer of layered coded data.
For example, as shown in
Further, to avoid the phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end 200 when the available channel capacity of the video transmit end 100 is small, an embodiment of this application further provides a solution. In this solution, the video transmit end 100 may dynamically adjust, based on a change of the available channel capacity of the video transmit end 100 in a wireless network, a quantity of layers existing when layered coding is performed on each frame of data in video data, so that when the available channel capacity of the video transmit end 100 is changed, it can be ensured that at least data included in a base layer of each frame of data can be sent, and the video receive end 200 can play the video data smoothly when the available channel capacity of the video transmit end 100 is poor. This avoids a phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end 200 when the available channel capacity of the video transmit end 100 is poor.
It may be understood that, in embodiments of this application, the video transmit end 100 may be an electronic device having a video sending function, for example, a smartphone, a tablet computer, or a notebook computer, and the video receive end 200 may be an electronic device having a video receiving function, for example, a smartphone, a tablet computer, a notebook computer, or a smart television. This is not limited in this application.
For example,
The processor 110 is a computing core and a control core of the video transmit end 100. The processor 110 may include one or more processing units. For example, the processor 110 may include one or more of an application processor (AP), a modem, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and/or a neural network processing unit (NPU). Different processing units may be independent components, or may be integrated into one or more processors. For example, the processor 110 may be understood as a source, and may provide video data that needs to be transmitted by the video transmit end 100.
The memory 120 may store a program, and the program may be run by the processor 110, so that the processor 110 executes instructions related to the program. The memory 120 may further store data. The processor 110 may read the data stored in the memory 120. The memory 120 and the processor 110 may be separately disposed. Optionally, the memory 120 may alternatively be integrated into the processor 110.
The source coding apparatus 130 may be configured to code the video data provided by the processor 110, to compress redundancy of the video data, and improve transmission efficiency of the video data. For example, the source coding apparatus 130 may perform layered coding on the video data by using a video coding technology, for example, SVC. For example, when performing layered coding on the video data, the source coding apparatus 130 may add an independent header identifier and/or an independent tail identifier to each layer of data obtained through layered coding, to implement layer differentiation. For example, the source coding apparatus 130 and the processor 110 may be separately disposed. Optionally, the source coding apparatus 130 may alternatively be integrated into the processor 110.
The channel coding apparatus 140 may be configured to re-code the video data coded by the source coding apparatus 130, so that obtained video data can be better transmitted on a channel. For example, the channel coding apparatus 140 may encapsulate, into an independent data frame unit, each layer of data obtained after the source coding apparatus 130 performs layered coding, to ensure that cross-layer composition does not occur in a same frame of data. For example, the channel coding apparatus 140 and the processor 110 may be separately disposed. Optionally, the channel coding apparatus 140 may also be integrated into the processor 110.
In an example, the source coding apparatus 130 may directly send the coded data to the channel coding apparatus 140. In addition, the source coding apparatus 130 may alternatively send the coded data to a data cache apparatus. Then, the channel coding apparatus 140 may read the coded data from the data cache apparatus. In addition, the source coding apparatus 130 may alternatively write the coded data into preset storage space. Then, the channel coding apparatus 140 may access the storage space to obtain the coded data.
The communication module 150 may include at least one of a mobile communication module and a wireless communication module. When the communication module 150 includes the mobile communication module, the communication module 150 may provide a wireless communication solution that includes 2G/3G/4G/5G, for example, a global system for mobile communications (GSM), a 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), and new radio (NR) and that is applied to the video transmit end 100.
When the communication module 150 includes the wireless communication module, the communication module 150 may provide a wireless communication solution that includes a wireless local area network (WLAN) (for example, a wireless fidelity (Wi-Fi) network), Bluetooth (BT), a global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), an infrared (IR) technology, or the like and that is applied to the video transmit end 100.
In addition, the communication module 150 may include at least one filter, a switch, a power amplifier, a low noise amplifier (LNA), and the like. The communication module 150 may receive an electromagnetic wave through at least one antenna, perform processing such as filtering and amplification on the received electromagnetic wave, and transmit the electromagnetic wave to a modem for demodulation. The communication module 150 may further amplify a signal modulated by the modem, and convert the signal into an electromagnetic wave through the antenna and radiate the electromagnetic wave. In some examples, at least some function modules of the communication module 150 may be disposed in the processor 110. In some examples, at least some function modules of the communication module 150 and at least some modules of the processor 110 may be disposed in a same component. The communication module 150 may be one or more components integrating at least one communication processor module. The communication module 150 receives an electromagnetic wave through the antenna, performs frequency modulation and filtering processing on the electromagnetic wave signal, and sends the processed signal to the processor 110. The communication module 150 may further receive a to-be-sent signal from the processor 110, perform frequency modulation and amplification on the to-be-sent signal, and convert the signal into an electromagnetic wave through the antenna and radiate the signal. For example, the video transmit end 100 may send, to the outside by using the communication module 150, the video data coded by the channel coding apparatus 140.
It may be understood that the structure shown in
In an implementation of this application, the video receive end 200 may also have a hardware structure similar to that of the video transmit end 100 shown in
Based on the foregoing described content and with reference to
S401: Obtain a change trend of an available channel capacity on the channel A, where the channel A is used to transmit video data.
Specifically, the video transmit end 100 may detect the channel A in real time or periodically, to obtain the change trend of the available channel capacity of the video transmit end 100 on the channel A. The channel A may be used to transmit video data. In an example, the channel A may be referred to as a first channel.
In a possible implementation, the video transmit end 100 may collect, in an entire service process (namely, a video data transmission process), statistics on a data sending success rate in a period of time (for example, 1 second or 5 seconds) in real time. When it is detected that the data sending success rate is decreased, it may be determined that the available channel capacity of the video transmit end 100 on the channel A is decreased; or when it is detected that the data sending success rate is increased, it may be determined that the available channel capacity of the video transmit end 100 on the channel A is increased.
For example, still refer to
S402: Adjust, based on the obtained change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data.
Specifically, after obtaining the change trend of the available channel capacity of the video data transmit end 100 on the channel A, the video data transmit end 100 may dynamically adjust, based on the capacity change trend, the quantity of layers during layered coding of the at least one frame of data in the video data, to improve a transmission success rate and efficiency of the video data.
In a possible implementation, when the available channel capacity is decreased, the quantity of layers during layered coding of the at least one frame of data in the video data may be increased, that is, the at least one frame of data is divided into more layers, to decrease a data amount of a base layer. This ensures that the base layer can be successfully transmitted, and meets a requirement of basic image transmission without a frame loss.
For example, still refer to
When the available channel capacity is increased, the quantity of layers during layered coding of the at least one frame of data in the video data may be decreased, that is, the at least one frame of data is divided into fewer layers, to decrease a total data amount of the at least one frame of data, and improve transmission efficiency of the video data. It may be understood that, after the at least one frame of data is layered, each layer of data has data such as matched control information and some redundant information. After the quantity of layers of the at least one frame of data is decreased, as the quantity of layers is decreased, data such as control information that match a decreased quantity of layers and some redundant information is also removed, thereby decreasing the total data amount of the at least one frame of data. In an example, when frame data is not layered, the frame data that is not layered may be understood as a base layer of the frame data, that is, in this case, the frame data does not include an enhancement layer.
For example, still refer to
When the available channel capacity does not change, a quantity of layers during layered coding of each frame of data in the video data may remain unchanged, that is, the quantity of layers during layered coding of each frame of data is not adjusted, to ensure stability of video data transmission. In addition, when the available channel capacity is increased, the quantity of layers during layered coding of each frame of data in the video data may also remain unchanged. This may be specifically determined according to an actual situation, and is not limited herein.
In an example, when the quantity of layers during layered coding of the at least one frame of data in the video data is adjusted, the quantity of layers may be adjusted based on a preconfigured adjustment value. For example, when it is detected for the first time that the available channel capacity is decreased, the quantity of layers may be increased by 1, when it is detected again that the available channel capacity is decreased, the quantity of layers may be increased by 1 or 2, and so on. Similarly, when it is detected for the first time that the available channel capacity is increased, the quantity of layers may be decreased by 1, when it is detected again that the available channel capacity is increased, the quantity of layers may be decreased by 1 or 2, and so on. This is not specifically limited herein.
S403: Perform layered coding on the at least one frame of data based on a quantity of layers obtained after adjustment.
Specifically, after the quantity of layers is adjusted, layered coding may be performed on the at least one frame of data based on the adjusted quantity of layers. For example, if a current quantity of layers is 3 and the adjusted quantity of layers is 5, the quantity of layers during layered coding of each frame of data is adjusted from 3 to 5. In an example, each frame of data obtained through layered coding may include at least a base layer. In this way, after the available channel capacity of the video transmit end 100 is decreased, it can be ensured that the base layer of each frame of data can be successfully sent. This meets a basic requirement of image transmission without a frame loss, and enables the video receive end to smoothly play the video data.
S404: Output at least one frame of data obtained through layered coding.
Specifically, after layered coding is performed on the at least one frame of data based on the adjusted quantity of layers, the at least one frame of data obtained through layered coding may be output. In an example, the at least one frame of data may be formed by one layer of coded data or coded data obtained through a plurality of times of layered coding.
Therefore, when transmitting the video data, the video transmit end 100 may dynamically adjust, based on a change of the available channel capacity of the video transmit end 100 on the channel, the quantity of layers for layered coding of the at least one frame of data, so that when the available channel capacity is changed, it can be ensured that at least data included in a base layer of the at least one frame of data can be sent, and the video receive end can play the video data smoothly when the available channel capacity of the video transmit end is poor. This avoids a phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end when the available channel capacity of the video transmit end is poor.
For ease of understanding the technical solution described in
For example,
As shown in (A) in
As shown in (B) in
It can be learned from the comparison between (A) and (B) in
For example,
As shown in
In the time period T2, because a frame loss is detected, it may be predicted that the available channel capacity is decreased. In this case, the quantity of layers of the at least one frame of data during layered coding may be dynamically adjusted to 5. In this case, an overall data amount of each frame of data is increased, but a data amount of each layer is decreased. Therefore, it can be ensured that both data at a layer 1 of a frame 3 and data at a layer 1 of a frame 4 can be successfully transmitted in the T2 time period, that is, a frame loss problem is resolved. In this case, because the quantity of layers during layered coding is increased, and data such as control information and some redundant information included in layered coded data of each increased layer enables the total data amount of each frame of data to be increased, a total data amount of the frame 3 and the frame 4 is greater than a total data amount of the frame 1.
In the time period T3, it is detected that the available channel capacity is increased, and the quantity of layers of the at least one frame of data during layered coding may be decreased to 3. In this case, the overall data amount of each frame of data is decreased, and a requirement for smooth transmission of at least a base layer may be met. In addition, data at a layer 2 of a frame 6 may also be smoothly transmitted in the time period. In this case, because the quantity of layers during layered coding is decreased, and data such as control information and some redundant information of layered coded data of each decreased layer is also removed, a total data amount of a frame 5 and a frame 6 is less than a total data amount of the frame 4.
In the time period T4, if it is detected that the available channel capacity keeps good, layered coding may be not performed on the at least one frame of data (that is, the quantity of layers is adjusted to 1). In this case, the overall data amount of each frame of data continues to be decreased. Because layered coding is not performed on the data, a calculation amount of a related layered algorithm used when layered coding is performed on the at least one frame of data may be decreased. This reduces system power consumption.
The foregoing is a related description of the video transmission method provided in this application. It may be understood that, after layered coding is performed on the at least one frame of data, each layer of data obtained through layered coding may be encapsulated into an independent data frame unit according to a specific framing policy, and is independently sent on the channel. In this way, a data amount of data sent each time can be decreased, and transmission efficiency can be improved. For example, a data amount of one frame of data is j. If data obtained through layered coding of the frame of data is not separately encapsulated, when the frame of data is sent, the frame of data whose data amount is j needs to be sent at a time. However, due to an impact of the available channel capacity, it is generally difficult to successfully send the frame of data at a time. If each layer of data obtained through layered coding is separately encapsulated and then sent, a data amount of data sent each time is decreased, for example, is changed to j/3, the separately encapsulated data may be successfully sent at a time. In an example, the data frame unit may also be referred to as a data packet.
For example, as shown in
Further, still refer to
Specifically, still refer to
When a data frame unit 3 is transmitted, if a life cycle of the frame 1 ends when transmission of the data frame unit 3 is completed, subsequently sent data of the frame 1 is considered as invalid data. In addition, because data at the layer 3 included in a data frame unit 2 and data at the layer 3 included in the data frame unit 3 are not all data at the layer 3, after receiving the data frame unit 3, the receive end cannot obtain, through decoding, related data by using the data frame unit 3. As a result, the data frame unit is also considered as invalid data, and the data frame unit occupies a channel resource needlessly. This causes a waste of the channel resource. In addition, when the layer 1 of the frame 2 is subsequently transmitted, because some data at the layer 1 of the frame 2 and some data at the layer 3 of the frame 1 are aggregated into one data frame unit for sending, when the layer 1 of the frame 2 is transmitted, some data at the layer 3 of the frame 1 is also transmitted, but the life cycle of the frame 1 has ended currently. Therefore, some data that is at the layer 3 of the frame 1 and that is transmitted this time is considered invalid data, that is, some data that is at the layer 3 of the frame 1 and that is transmitted this time occupies a channel resource. This causes a waste of the channel resource.
It may be understood that, in a data transmission process, a life cycle may be set for each frame of data, to ensure that each piece of data can be fairly sent, and a case in which a piece of data continuously occupies a channel does not occur. This improves data transmission efficiency. For example, the life cycle of each frame of data may be determined through negotiation between the video transmit end and the video receive end. For example, the life cycle of each frame of data may be 20 milliseconds or 30 milliseconds.
To avoid the problem described in
For example, when a video coding technology, for example, scalable video coding (SVC), is used to perform layered coding on each frame of data in the video data transmitted by the video transmit end 100, a joint source channel coding (JSCC) technology may be used to add an independent header identifier to each layer of data in each frame of data to implement layer differentiation, so that each layer of data in each frame of data can be conveniently encapsulated into an independent data frame unit. The header identifier corresponding to each layer of data may include a layer identifier and a data amount of the layer of data, to distinguish between each layer of data. In an example, an independent header identifier and an independent tail identifier may be added to each layer of data in each frame of data to implement layer differentiation, so that each layer of data in each frame of data can be conveniently encapsulated into an independent data frame unit. The header identifier corresponding to each layer of data may identify a start of the layer of data, and the tail identifier corresponding to the layer of data may identify an end of the layer of data, to distinguish between each layer of data.
For example, as shown in
It may be understood that, in this solution, each layer of data in each frame of data is sent as an independent data frame unit. Therefore, when a data amount of a layer is small, a data frame unit corresponding to the layer is also small. In this case, it is easier to ensure that data at the layer is successfully sent. When a data amount of a layer is large, a data frame unit corresponding to the layer is also large, and transmission duration of the data frame unit on the channel is also long. In this solution, data of each layer is sent as an independent data frame unit. Therefore, the data frame unit corresponding to each layer is sent only once on the channel. When the data of each layer is sent, channel contention needs to be performed only once, instead of performing channel contention for a plurality of times, as shown in (B) in
For ease of understanding, the following uses an example to describe a process of encapsulating each layer of data in each frame of data into an independent data frame unit for sending.
For example, as shown in
Still refer to
Further, still refer to
For ease of understanding, the following uses an example for description.
For example, as shown in
Still refer to
For example, as shown in
Still refer to
For example, as shown in
Still refer to
It may be understood that, when the channel is obtained through contention, it may be estimated in advance whether remaining duration of a life cycle of frame data to which the data frame unit belongs is less than data sending duration of the data frame unit. If the remaining duration of the life cycle of the frame data to which the data frame unit belongs is less than the data sending duration of the data frame unit, the data frame unit may be discarded, a data frame unit that is after the data frame unit and that belongs to the same frame data as the previous data frame unit is discarded, and the channel source obtained through contention is reserved for the next frame of data to use, to save data sending duration and the channel resource, and improve data transmission efficiency.
For example, as shown in
As shown in (a) in
However, in (b) in
In an example, in a data sending process, when the channel is not obtained through contention, but a life cycle of a frame ends, and there is still unsent data in the frame, the unsent data may be discarded, that is, the unsent data is no longer sent. For example, still refer to (a) in
The foregoing is a related description of the video transmission method provided in this application. Based on the content described above, the following describes another video transmission method provided in an embodiment of this application.
For example,
S1401: Obtain a change trend of an available channel capacity on a first channel, where the first channel is used to transmit video data.
Specifically, in a process of sending the video data, the change trend of the available channel capacity on the first channel may be obtained in real time or periodically, where the first channel may be used to transmit the video data.
For example, in an entire service process, statistics about a data sending success rate in a period of time may be collected in real time, to obtain the change trend of the available channel capacity on the first channel. For details, refer to the foregoing descriptions in
In addition, the change trend of the available channel capacity on the first channel may alternatively be obtained by using another apparatus (for example, a processor) for determining the change trend of the available channel capacity on the first channel. This may be specifically determined according to an actual situation, and is not limited herein.
S1402: Adjust, based on the change trend of the available channel capacity, a quantity of layers during layered coding of at least one frame of data in the video data.
Specifically, after the change trend of the available channel capacity is obtained, the quantity of layers during layered coding of the at least one frame of data in the video data may be dynamically adjusted, to improve a transmission success rate and efficiency of the video data.
In a possible implementation, when the available channel capacity is decreased, the quantity of layers during layered coding of the at least one frame of data in the video data may be increased, that is, the at least one frame of data is divided into more layers, to decrease a data amount of a base layer. This ensures that the base layer can be successfully transmitted, and meets a requirement of basic image transmission without a frame loss.
When the available channel capacity is increased, the quantity of layers during layered coding of the at least one frame of data in the video data may be decreased, that is, the at least one frame of data is divided into fewer layers, to decrease a total data amount of the at least one frame of data, and improve transmission efficiency of the video data. In addition, when the available channel capacity is increased, the quantity of layers during layered coding of the at least one frame of data in the video data may also remain unchanged.
When the available channel capacity does not change, a quantity of layers during layered coding of each frame of data in the video data may remain unchanged, that is, the quantity of layers during layered coding of each frame of data is not adjusted, to ensure stability of video data transmission.
In an example, when the quantity of layers is adjusted, the quantity of layers during layered coding of the at least one frame of data may be increased or decreased based on a preset adjustment amount.
S1403: Perform layered coding on the at least one frame of data based on a quantity of layers obtained after adjustment.
Specifically, after the quantity of layers is adjusted, a technology, for example, SVC, may be used to perform layered coding on the at least one frame of data based on the adjusted quantity of layers. For example, when the adjusted quantity of layers is 5, the at least one frame of data is coded into five layers.
In addition, in order to distinguish between different layers of layered coded data, when layered coding is performed on the at least one frame of data, identification information may be added to each layer of layered coded data obtained through layered coding. The identification information may be used to distinguish between different layered coded data.
In an example, the identification information may include a layer identifier of the layered coded data and a first data amount of the layered coded data. A layer of data that is currently obtained may be determined based on the layer identifier, and that coded data whose data amount is the first data amount and that is obtained after the layer identifier is used as layered coded data of a same layer may be learned based on the first data amount.
In an example, the identification information may include a header identifier and a tail identifier of the layered coded data. The header identifier may identify a data start end of the layered coded data, the tail identifier may identify a data end of the layered coded data, and data between the header identifier and the tail identifier is coded data included in the layered coded data.
S1404: Output coded data obtained through layered coding.
Specifically, after layered coding is performed on the video data, the coded data obtained through layered coding may be output.
In an example, when the method is performed by the source coding apparatus 130 in the video transmit end 100 shown in
Therefore, when the change trend of the available channel capacity on the video data transmission channel is obtained, a quantity of layers during layered coding of the video data is dynamically adjusted based on the change trend of the available channel capacity, so that when the available channel capacity is changed, it can be ensured that at least data included in a base layer in at least one frame of data in the video data can be transmitted. This ensures that the video receive end can smoothly play the video data, avoids a phenomenon, for example, frame skipping, erratic display, or frame freezing that occurs at the video receive end, and improves user experience.
For example,
S1501: Obtain coded data obtained by performing layered coding on video data, where the layered coded video data includes at least one layer of layered coded data, each layer of layered coded data in the at least one layer of layered coded data includes identification information, and the identification information is used to distinguish between different layered coded data.
Specifically, after layered coding is performed on the video data, the coded data obtained by performing layered coding on the video data may be obtained. The layered coded video data may include the at least one layer of layered coded data, each layer of layered coded data in the at least one layer of layered coded data may include the identification information, and the identification information is used to distinguish between different layered coded data. For example, the obtained coded data may be the coded data that is output in
In an example, when the method is performed by the channel coding apparatus 140 in the video transmit end 100 shown in
S1502: Independently encapsulate, into a first data packet based on the identification information, coded data belonging to a same layer of layered coded data.
Specifically, after the coded data obtained by performing layered coding on the video data is obtained, the identification information may be obtained from the coded data including the identification information, so that the coded data belonging to the same layer of coded data is determined based on the identification information, and the coded data belonging to the same layer of layered coded data is independently encapsulated into the first data packet. In an example, the first data packet may also be referred to as a data frame unit.
In an example, when the identification information includes the layer identifier of the layered coded data and a first data amount of the layered coded data, when the layer identifier is obtained, statistics on a data amount of subsequently obtained coded data may be collected, to obtain a second data amount. When the second data amount is the same as the first data amount, all coded data corresponding to the second data amount is independently encapsulated into the first data packet. It may be understood that, because the first data amount is a data amount of the layered coded data, when the second data amount is equal to the first data amount, it may be determined that all coded data included in the layered coded data is obtained. In this case, the layered coded data may be encapsulated. That is, after the layer identifier is obtained, when a data amount of first coded data obtained after the layer identifier reaches the first data amount, the first coded data obtained after the layer identifier is independently encapsulated into the first data packet. For example, when the first coded data is independently encapsulated into the first data packet, the layer identifier may be encapsulated together, or the layer identifier may not be encapsulated together. This may be specifically determined according to an actual situation, and is not limited herein.
In an example, when the identification information includes the header identifier and the tail identifier of the layered coded data, after the header identifier and the tail identifier are obtained, coded data obtained after the header identifier is obtained and before the tail identifier is obtained may be independently encapsulated into the first data packet. It may be understood that, because the header identifier may identify the data start end of the layered coded data, and the tail identifier may identify the data end of the layered coded data, after the header identifier and the tail identifier are obtained, it may be determined that all the coded data included in the layered coded data is obtained. In this case, the layered coded data may be encapsulated. For example, when the obtained coded data is independently encapsulated into the first data packet, the corresponding header identifier and the corresponding tail identifier may be encapsulated together, or the corresponding header identifier and the corresponding tail identifier may not be encapsulated together. This may be specifically determined according to an actual situation, and is not limited herein.
S1503: Send the first data packet.
Specifically, after the layered coded data is independently encapsulated into the first data packet, the first data packet obtained through independent encapsulation may be sent.
Therefore, after the coded data obtained by performing layered coding on the video data is obtained, the coded data of each layer may be independently encapsulated into a data packet (which may also be referred to as a data frame unit), and the data packet is separately sent. This can ensure that cross-layer packet composition does not occur between coded data of different layers, and can also ensure that cross-frame packet composition does not occur between different frames. Further, it can be ensured that the coded data of each layer can be separately sent, and the channel needs to be contended for only once when one layer of layered coded data is sent. This avoids a case in which total transmission duration of one layer of layered coded data is excessively large because the channel needs to be contended for a plurality of times when one layer of layered coded data is sent during cross-layer packet composition, and reduces a probability of data sending timeout. In addition, because each layer of layered coded data is sent as an independent data packet, a pressure of a receive buffer of a video receive end is reduced, so that a case in which the video receive end receives some data at a layer first and then receives remaining data at an interval of an unspecified delay does not exist. This improves buffer utilization. In addition, each layer of layered coded data obtained through layered coding is independently encapsulated and sent. This avoids a case in which a failure of sending one layer of data causes a failure of sending data at another layer during synchronous sending of different layers of data. In this way, a data sending success rate is improved, and it is further ensured that the video receive end can smoothly play the video data.
In an example, when the channel is obtained through contention, if remaining duration for sending a first frame of data to which the first data packet belongs ends, to-be-sent data in the first frame of data is discarded, and a next frame of data of the first frame of data is sent through the channel obtained through contention. The first frame of data is any frame of data in the video data. When the channel is obtained through contention, if the remaining duration for sending the first frame data to which the first data packet belongs ends, the to-be-sent data that is in the first frame of data and that is subsequently sent is considered as invalid data. Therefore, if the to-be-sent data in the first frame of data continues to be sent in this case, the channel is invalidly occupied. Therefore, in this case, the to-be-sent data in the first frame of data may be discarded, and the next frame of data of the first frame of data is sent through the channel obtained through contention, so that invalid occupation of the channel can be avoided, and the next frame of data may be sent earlier. This avoids timeout of sending the next frame of data and improves data transmission efficiency.
In an example, when the channel is obtained through contention and the next frame of data of the first frame of data is obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, the to-be-sent data in the first frame of data is discarded, and the next frame of data is sent through the channel obtained through contention. The first frame of data is any frame data in the video data. When the channel is obtained through contention, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than the duration for sending the to-be-sent data in the first frame of data, the to-be-sent data that is in the first frame of data and that is subsequently sent definitely times out. Consequently, data sent after timeout is invalid data, and the channel is invalidly occupied when the to-be-sent data in the first frame of data is sent. Therefore, in this case, when the next frame of data of the first frame of data has been obtained, the to-be-sent data in the first frame of data may be discarded, and the next frame of data of the first frame of data is sent through the channel obtained through contention, so that invalid occupation of the channel can be avoided, and the next frame of data may be sent earlier. This avoids timeout of sending the next frame of data and improves data transmission efficiency.
In an example, when the channel is obtained through contention and the next frame of data of the first frame of data is not obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, the to-be-sent data in the first frame of data is discarded, and the channel obtained through contention this time is abandoned. When the channel is obtained through contention, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than the duration for sending the to-be-sent data in the first frame of data, the to-be-sent data that is in the first frame of data and that is subsequently sent definitely times out. Consequently, data sent after timeout is invalid data, and the channel is invalidly occupied when the to-be-sent data in the first frame of data is sent. Therefore, in this case, when the next frame of data of the first frame of data is not obtained, the to-be-sent data in the first frame of data may be discarded. However, after the to-be-sent data in the first frame of data is discarded, because the next frame of data of the first frame of data is not obtained, the channel is wasted. Therefore, the channel obtained through contention may be discarded, that is, a channel resource is allocated to another user. This improves data transmission efficiency on the channel.
Based on the methods in the foregoing embodiments, an embodiment of this application further provides a video transmission apparatus.
The processor 1601 may be an integrated circuit chip with a signal processing capability. In an implementation process, the steps of the foregoing methods may be implemented by using an integrated logic circuit of hardware in the processor 1601, or by using instructions in a form of software. The processor 1601 may be a general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or another programmable logic device, a discrete gate or transistor logic device, or a discrete hardware component, and may implement or perform the methods and steps that are disclosed in embodiments of this application. The general-purpose processor may be a microprocessor, or the processor may be any conventional processor or the like.
The interface circuit 1602 may complete sending or receiving of data, an instruction, or information. The processor 1601 may perform processing by using the data, the instruction, or other information received by the interface circuit 1602, and send processed information by using the interface circuit 1602.
Optionally, the video transmission apparatus 1600 further includes a memory. The memory may include a read-only memory and a random access memory, and provide operation instructions and data for the processor. A part of the memory may further include a non-volatile random access memory (NVRAM).
Optionally, the memory stores an executable software module or a data structure, and the processor may perform a corresponding operation by invoking the operation instructions (the operation instructions may be stored in an operating system) stored in the memory.
Optionally, the interface circuit 1602 may be configured to output an execution result of the processor 1601.
It should be noted that functions corresponding to each of the processor 1601 and the interface circuit 1602 may be implemented by using hardware design, may be implemented by using software design, or may be implemented by using a combination of software and hardware. This is not limited herein.
It should be understood that the steps in the foregoing method embodiments may be completed by using a logic circuit in a form of hardware or instructions in a form of software in the processor.
Based on the method in the foregoing embodiments, an embodiment of this application further provides a video transmission apparatus.
In an example, the first processing module 1701 is further configured to: when the available channel capacity trends to decrease, increase the quantity of layers during layered coding of the at least one frame of data; and when the available channel capacity trends to increase, decrease the quantity of layers during layered coding of the at least one frame of data, or keep the quantity of layers during layered coding of the at least one frame of data unchanged.
In an example, the first processing module 1701 is further configured to increase or decrease, based on a preset adjustment amount, the quantity of layers during layered coding of the at least one frame of data.
In an example, the first processing module 1701 is further configured to add identification information to each layer of layered coded data obtained through layered coding. The identification information is used to distinguish between different layered coded data.
In an example, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data; or the identification information includes a header identifier and a tail identifier of the layered coded data.
It should be understood that the foregoing apparatus is configured to perform the methods in the foregoing embodiments, and an implementation principle and technical effect of a corresponding program module in the apparatus are similar to the descriptions in the foregoing methods. For a working process of the apparatus, refer to a corresponding process in the foregoing methods. Details are not described herein again.
Based on the methods in the foregoing embodiments, an embodiment of this application further provides a video transmission apparatus.
In an example, the identification information includes a layer identifier of the layered coded data and a first data amount of the layered coded data. The second processing module 1801 is further configured to: after the layer identifier is obtained, when a data volume of first coded data obtained after the layer identifier reaches the first data amount, independently encapsulate, into the first data packet, the first coded data obtained after the layer identifier.
In an example, the identification information includes a header identifier and a tail identifier of layered coded data. The second processing module 1801 is further configured to: after the header identifier and the tail identifier are obtained, independently encapsulate, into the first data packet, coded data obtained after the header identifier is obtained and before the tail identifier is obtained.
In an example, the second processing module 1801 is further configured to: when a channel is obtained through contention, if remaining duration for sending a first frame of data to which the first data packet belongs ends, discard to-be-sent data in the first frame of data, and send a next frame of data of the first frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In an example, the second processing module 1801 is further configured to: when the channel is obtained through contention and the next frame of data of the first frame of data is obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discard the to-be-sent data in the first frame of data, and send the next frame of data through the channel obtained through contention. The first frame of data is any frame of data in the video data.
In an example, the second processing module 1801 is further configured to: when the channel is obtained through contention and the next frame of data of the first frame of data is not obtained, if the remaining duration for sending the first frame of data to which the first data packet belongs is less than duration for sending the to-be-sent data in the first frame of data, discard the to-be-sent data in the first frame of data, and abandon the channel obtained through contention this time.
It should be understood that the foregoing apparatus is configured to perform the methods in the foregoing embodiments, and an implementation principle and technical effect of a corresponding program module in the apparatus are similar to the descriptions in the foregoing methods. For a working process of the apparatus, refer to a corresponding process in the foregoing methods. Details are not described herein again.
It may be understood that the processor in embodiments of this application may be a central processing unit (CPU), or may be another general-purpose processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or another programmable logic device, a transistor logic device, a hardware component, or any combination thereof. The general purpose processor may be a microprocessor or any conventional processor or the like.
The method steps in embodiments of this application may be implemented in a hardware manner, or may be implemented in a manner of executing software instructions by the processor. The software instructions may include corresponding software modules. The software modules may be stored in a random access memory (RAM), a flash memory, a read-only memory (ROM), a programmable read-only memory (programmable ROM, PROM), an erasable programmable read-only memory (erasable PROM, EPROM), an electrically erasable programmable read-only memory (electrically EPROM, EEPROM), a register, a hard disk, a removable hard disk, a CD-ROM, or any other form of storage medium well-known in the art. For example, a storage medium is coupled to a processor, so that the processor can read information from the storage medium and write information into the storage medium. Certainly, the storage medium may be a component of the processor. The processor and the storage medium may be disposed in an ASIC.
All or some of the foregoing embodiments may be implemented by using software, hardware, firmware, or any combination thereof. When software is used to implement the embodiments, all or a part of the embodiments may be implemented in a form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on the computer, the procedure or functions according to embodiments of this application are all or partially generated. The computer may be a general-purpose computer, a dedicated computer, a computer network, or other programmable apparatuses. The computer instruction may be stored in a computer-readable storage medium, or may be transmitted by using the computer-readable storage medium. The computer instructions may be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired (for example, a coaxial cable, an optical fiber, or a digital subscriber line (DSL)) or wireless (for example, infrared, radio, or microwave) manner. The computer-readable storage medium may be any usable medium accessible by the computer, or a data storage device, for example, a server or a data center, integrating one or more usable media. The usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, or a magnetic tape), an optical medium (for example, a DVD), a semiconductor medium (for example, a solid-state drive (SSD)), or the like.
It may be understood that various numbers in embodiments of this application are merely used for differentiation for ease of description, and are not used to limit the scope of embodiments of this application.
This application is a continuation of International Application No. PCT/CN2021/114468, filed on Aug. 25, 2021, the disclosure of which is hereby incorporated by reference in its entirety.
Number | Date | Country | |
---|---|---|---|
Parent | PCT/CN2021/114468 | Aug 2021 | WO |
Child | 18585844 | US |