Data transmission method, device, electronic device and storage medium
By switching the cache unit between two image reading objects, the problem of time-consuming data transmission of electronic devices across processes is solved, and high-performance data transmission is achieved.
Patent Information
- Application Number
- CN202111271767.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-29
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-10-29
AI Technical Summary
Electronic devices take a long time to transmit data across processes, affecting performance.
By switching the cache unit that caches data to be transmitted between two image reading objects, the data copying process is avoided, thereby achieving high-performance cross-process data transmission.
Reduces the delay of data transmission and improves cross-process data transmission performance.
Smart Images

Figure CN113961484B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of electronic devices, and more specifically, to a data transmission method, device, electronic device and storage medium. Background Art
[0002] With the development of science and technology, electronic devices are used more and more widely and have more and more functions, becoming one of the necessities in people's daily life. However, at present, when electronic devices perform cross-process data transmission, it takes a long time, which affects the cross-process data transmission performance of electronic devices. Summary of the invention
[0003] In view of the above problems, the present application proposes a data transmission method, device, electronic device and storage medium to solve the above problems.
[0004] In a first aspect, an embodiment of the present application provides a data transmission method, which is applied to an electronic device, wherein the electronic device creates a first image reading object and a second image reading object, and the method includes:
[0005] Obtain a first cache queue corresponding to the first image read object, wherein the first cache queue includes multiple first cache units; take out a first target cache unit from the multiple first cache units, wherein the first target cache unit caches data to be transmitted; and add the first target cache unit to a second cache queue corresponding to the second image read object.
[0006] In a second aspect, an embodiment of the present application provides a data transmission device, which is applied to an electronic device, wherein the electronic device creates a first image reading object and a second image reading object, and the device includes: a cache queue acquisition module, used to acquire a first cache queue corresponding to the first image reading object, wherein the first cache queue includes multiple first cache units; a cache unit extraction module, used to extract a first target cache unit from the multiple first cache units, wherein the first target cache unit caches data to be transmitted; and a cache unit adding module, used to add the first target cache unit to a second cache queue corresponding to the second image reading object.
[0007] In a third aspect, an embodiment of the present application provides an electronic device, comprising a memory and a processor, wherein the memory is coupled to the processor, the memory stores instructions, and when the instructions are executed by the processor, the processor executes the above method.
[0008] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.
[0009] The data transmission method, device, electronic device and storage medium provided in the embodiments of the present application obtain a first cache queue corresponding to a first image reading object, wherein the first cache queue includes multiple first cache units, and takes out a first target cache unit from the multiple first cache units, wherein the first target cache unit caches data to be transmitted, and adds the first target cache unit to a second cache queue corresponding to a second image reading object, so that by switching the cache unit that caches the data to be transmitted between the two image reading objects, the delay of data transmission can be reduced and high-performance cross-process data transmission can be achieved. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0011] Figure 1 A block diagram of an electronic device according to an embodiment of the present application for executing a method according to an embodiment of the present application is shown;
[0012] Figure 2 A block diagram of an operating system of an electronic device provided in an embodiment of the present application is shown;
[0013] Figure 3 A schematic diagram showing a flow chart of a data transmission method provided by an embodiment of the present application;
[0014] Figure 4 A schematic diagram showing a flow chart of a data transmission method provided by an embodiment of the present application;
[0015] Figure 5 This application shows Figure 4 The flowchart of step S250 of the data transmission method shown is as follows;
[0016] Figure 6 A schematic diagram showing a flow chart of a data transmission method provided by an embodiment of the present application;
[0017] Figure 7 A schematic diagram showing a flow chart of a data transmission method provided by an embodiment of the present application;
[0018] Figure 8 This application shows Figure 7 The flowchart of step S440 of the data transmission method shown is as follows;
[0019] Fig. 9A schematic diagram showing a flow chart of a data transmission method provided by an embodiment of the present application;
[0020] Fig.10 A module block diagram of a data transmission device provided in an embodiment of the present application is shown;
[0021] Fig.11 A storage unit for storing or carrying program codes for implementing the method according to an embodiment of the present application is shown. DETAILED DESCRIPTION
[0022] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application.
[0023] In the field of image cameras in the Android system, there are many scenarios where data is transferred between two image reading objects. For example, an application installed on an electronic device first obtains a path of data through an image reading object. At this time, the application needs to first pass the data to a process for algorithm processing, and then pass the processed data to another process through another image reading object for encoding to form a video. Therefore, the data transmission performance between the two image reading objects is very critical.
[0024] At present, when electronic devices perform cross-process data transmission, they take out a cache unit from an image reading object, take out a cache unit from an image reading object, and then copy the data in one cache unit to another cache unit, and then put each cache unit back into the cache queue of the corresponding image reading object, so as to realize data transmission through this method. However, the above method will cause a copy of data, which will increase the time consumption and affect the data transmission performance.
[0025] In view of the above problems, the inventors have discovered after long-term research and proposed the data transmission method, device, electronic device and storage medium provided in the embodiments of the present application. By switching the cache unit that caches the data to be transmitted between two image reading objects, the delay of data transmission can be reduced and high-performance cross-process data transmission can be achieved. The specific data transmission method will be described in detail in the subsequent embodiments.
[0026] The following describes an application environment of the data transmission method that can be used in the embodiments of the present application.
[0027] See also Figure 1, which shows a structural block diagram of an electronic device 100 provided in an embodiment of the present application. The electronic device 100 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 100 in the present application may include one or more of the following components: a processor 110, a memory 120, and one or more applications, wherein the one or more applications may be stored in the memory 120 and configured to be executed by one or more processors 110, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.
[0028] Among them, the processor 110 may include one or more processing cores. The processor 110 uses various interfaces and lines to connect various parts of the entire electronic device 100, and executes various functions and processes data of the electronic device 100 by running or executing instructions, programs, code sets or instruction sets stored in the memory 120, and calling data stored in the memory 120. Optionally, the processor 110 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 110 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 110, but may be implemented separately through a communication chip.
[0029] The memory 120 may include a random access memory (RAM) or a read-only memory (ROM). The memory 120 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 120 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a phone book, audio and video data, chat record data) created by the electronic device 100 during use.
[0030] Taking the operating system of the electronic device 100 as the Android system as an example, the programs and data stored in the memory 120 are as follows: Figure 2 As shown, the memory 120 stores a Linux kernel layer 220, a system runtime layer 240, an application framework layer 260 and an application layer 280. The Linux kernel layer 220 provides underlying drivers for various hardware of the electronic device 100, such as display drivers, audio drivers, camera drivers, Bluetooth drivers, Wi-Fi drivers, power management, etc. The system runtime layer 240 provides the main feature support for the Android system through some C / C++ libraries. For example, the SQLite library provides database support, the OpenGL / ES library provides 3D drawing support, and the Webkit library provides browser kernel support, etc. The Android runtime library (Android Runtime) is also provided in the system runtime layer 240, which mainly provides some core libraries that allow developers to use the Java language to write Android applications. The application framework layer 260 provides various APIs that may be used when building applications, and developers can also use these APIs to build their own applications, such as activity management, window management, view management, notification management, content provider, package management, call management, resource management, and positioning management. At least one application program is running in the application layer 280. These applications can be contact programs, text message programs, clock programs, camera applications, etc. provided by the operating system; they can also be applications developed by third-party developers, such as instant messaging programs, photo beautification programs, etc.
[0031] See also Figure 3 , Figure 3 The flowchart of the data transmission method provided by an embodiment of the present application is shown. The method is used to reduce the delay of data transmission and realize high-performance cross-process data transmission by switching the cache unit that caches the data to be transmitted between two image reading objects. In a specific embodiment, the data transmission method is applied to Fig.10 The data transmission device 300 and the electronic device 100 ( Figure 1 ). The following will take an electronic device as an example to illustrate the specific process of this embodiment. Of course, it can be understood that the electronic device used in this embodiment can be a smart phone, a tablet computer, a wearable electronic device, a desktop computer, etc., which is not limited here. In this embodiment, the electronic device creates a first image reading object and a second image reading object. Figure 3 The process shown is described in detail, and the data transmission method may specifically include the following steps:
[0032] Step S110: obtaining a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units.
[0033] In this embodiment, the electronic device may create a first image reading object and a second image reading object, wherein the first image reading object is actually composed of a circular buffer queue, and the second image reading object is actually composed of a circular buffer queue.
[0034] As one way, the electronic device can create the first image reading object and the second image reading object when data transmission is required, so as to realize data transmission through the first image reading object and the second image reading object. As another way, the electronic device can create the first image reading object and the second image reading object in advance, so as to realize data transmission through the created first image reading object and the second image reading object when data transmission is required.
[0035] In some embodiments, the first image reading object may include a first pointer object pointing to the cache area, so as to read data from the cache area through the first pointer object. The second image reading object may include a second pointer object pointing to the cache area, so as to read data from the cache area through the second pointer object.
[0036] In some embodiments, the electronic device may create a first ImageReader object as a first image reading object, and create a second ImageReader object as a second image reading object. The first pointer object included in the first ImageReader object may be a first Surface, through which the cache area pointed to by the first Surface may be accessed. The second pointer object included in the second ImageReader object may be a second Surface, through which the cache area pointed to by the second Surface may be accessed.
[0037] In this embodiment, the electronic device can obtain a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units, each of which is used to cache data (such as data to be transmitted). As a mode, the first cache queue is a first circular cache queue, and the first circular cache queue includes a plurality of first cache units arranged in a circular manner.
[0038] Step S120: taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0039] In this embodiment, after obtaining the multiple first cache units corresponding to the first image reading object, the electronic device can take out the first cache unit that caches the data to be transmitted from the multiple first cache units as the first target cache unit. In some embodiments, after obtaining the multiple first cache units corresponding to the first image reading object, the electronic device can respectively detect the multiple first cache units to determine whether the multiple first cache units cache the data to be transmitted, and determine the first cache unit that caches the data to be transmitted as the first target cache unit, and take out the first target cache unit from the multiple first cache units.
[0040] As a method, if it is detected that a first cache unit among the multiple first cache units caches data to be transmitted, the first cache unit that caches the data to be transmitted can be directly determined as the first target cache unit and taken out from the multiple first cache units.
[0041] As another way, if it is detected that at least two of the multiple first cache units have cached data to be transmitted, then a first cache unit can be selected from the at least two first cache units as the first target cache unit, and the first target cache unit can be taken out from the multiple first cache units. For example, the first cache unit with the earliest cache time of the data to be transmitted can be selected from the at least two first cache units as the first target cache unit; the first cache unit with the longest cache time of the data to be transmitted can be selected from the at least two first cache units as the first target cache unit; the first cache unit with the highest priority can be taken out from the at least two first cache units as the first target cache unit, etc., which are not limited here.
[0042] As another way, if it is detected that at least two first cache units among the multiple first cache units cache data to be transmitted, the at least two first cache units can be used as first target cache units and the first target cache unit can be taken out from the multiple first cache units.
[0043] Step S130: adding the first target cache unit to a second cache queue corresponding to the second image reading object.
[0044] In some embodiments, after the electronic device takes out the first target cache unit from the first cache queue corresponding to the first image reading object, it can directly add the first target cache unit to the second cache queue corresponding to the second image reading object. Based on this, the data to be transmitted cached on the first target cache unit is also added to the second image reading object along with the first target cache unit, that is, the data to be transmitted can be directly transmitted to the second image reading object, avoiding the copy process of the data to be transmitted, reducing the delay of data transmission, and realizing high-performance cross-process data transmission.
[0045] A data transmission method provided by an embodiment of the present application obtains a first cache queue corresponding to a first image reading object, wherein the first cache queue includes multiple first cache units, takes out a first target cache unit from the multiple first cache units, wherein the first target cache unit caches data to be transmitted, and adds the first target cache unit to a second cache queue corresponding to a second image reading object, thereby reducing the delay of data transmission and achieving high-performance cross-process data transmission by switching the cache unit that caches the data to be transmitted between the two image reading objects.
[0046] See also Figure 4 , Figure 4 The flowchart of the data transmission method provided by an embodiment of the present application is shown. The method is applied to the above-mentioned electronic device, the first electronic device creates a first image reading object and a second image reading object, and the second cache queue includes a plurality of second cache units. Figure 4 The process shown is described in detail, and the data transmission method may specifically include the following steps:
[0047] Step S210: obtaining a first cache queue corresponding to the first image reading object, and obtaining a second cache queue corresponding to the second image reading object, wherein the first cache queue includes a plurality of first cache units, and the second cache queue includes a plurality of second cache units.
[0048] In this embodiment, the electronic device can obtain a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units, each of which is used to cache data (such as data to be transmitted). As a mode, the first cache queue is a first circular cache queue, and the first circular cache queue includes a plurality of first cache units arranged in a circular manner.
[0049] In this embodiment, the electronic device can obtain a second cache queue corresponding to the second image reading object, wherein the second cache queue includes a plurality of second cache units, each of which is used to cache data (such as data to be transmitted). As a method, the second cache queue is a second circular cache queue, which includes a plurality of second cache units arranged in a circular manner.
[0050] Step S220: taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0051] For the detailed description of step S220, please refer to step S120, which will not be repeated here.
[0052] Step S230: taking out a second target cache unit from the plurality of second cache units.
[0053] In this embodiment, after obtaining multiple second cache units corresponding to the second image reading object, the electronic device can determine at least one second cache unit from the multiple second cache units as the second target cache unit. In some embodiments, after obtaining multiple second cache units corresponding to the second image reading object, the electronic device can detect the multiple second cache units respectively to determine whether the multiple second cache units meet the preset conditions, determine the second cache unit that meets the preset conditions as the second target cache unit, and take the second target cache unit out of the multiple second cache units.
[0054] In some embodiments, the preset condition may include: no data to be transmitted is cached, or no data is cached. That is, when a second cache unit among the plurality of second cache units does not cache data to be transmitted, the second cache unit may be determined as the second target cache unit, or when a second cache unit among the plurality of second cache units does not cache data, the second cache unit may be determined as the second target cache unit.
[0055] As a way, the number of second cache units included in the second target cache unit is consistent with the number of first cache units included in the first target cache unit. For example, if the number of first cache units included in the first target cache unit is one, it can be determined that one second cache unit is taken out from the plurality of second cache units as the second target cache unit. For another example, if the number of first cache units included in the first target cache unit is three, it can be determined that three second cache units are taken out from the plurality of second cache units as the second target cache unit.
[0056] Step S240: adding the first target cache unit to a second cache queue corresponding to the second image reading object.
[0057] For the detailed description of step S240, please refer to step S130, which will not be repeated here.
[0058] Step S250: adding the second target cache unit to the first cache queue.
[0059] In some embodiments, after the electronic device takes out the second target cache unit from the second cache queue corresponding to the second image reading object, it can directly add the second target cache unit to the first cache queue corresponding to the first image reading object. Based on this, the first target cache unit is added to the second cache queue, and the second target cache unit is added to the first cache queue, so that the cache queues in the first image reading object and the second image reading object can be balanced, and the maximum reuse of the cache units can be achieved.
[0060] See also Figure 5 , Figure 5 This application shows Figure 4 The data transmission method shown in FIG. 1 is a flow chart of step S250. Figure 5 The process shown is described in detail, and the method may specifically include the following steps:
[0061] Step S251: Obtain the number of cache units corresponding to the plurality of second cache units as the number of first cache units.
[0062] The first cache queue and the second cache queue are circular cache queues, therefore, the number of first cache units included in the first cache queue is upper bounded, and the number of second cache units included in the second cache queue is also upper bounded, for example, the upper bounded number of first cache units included in the first cache queue is 10, 20 or 30, and the upper bounded number of second cache units included in the second cache queue is 10, 20 or 30, etc. Therefore, if the first target cache unit in the first cache queue is continuously added to the second cache queue, the first image read object will soon not include the first cache unit, and the first image read object will need to frequently apply for the first cache unit, which will cause the second cache unit in the second image read object to soon exceed the upper bounded number, and the second image read object will need to frequently release the second cache unit. Frequent application of cache units and frequent release of cache units will both cause additional performance consumption.
[0063] In this embodiment, the number of cache units corresponding to the plurality of second cache units included in the second cache queue corresponding to the second image reading object may be obtained as the first cache unit number.
[0064] Step S252: when the number of the first cache units reaches the number threshold corresponding to the second cache queue, the second target cache unit is added to the first cache queue.
[0065] In some implementations, the electronic device may pre-set and store a quantity threshold (upper limit) corresponding to the second cache queue, and the quantity threshold is used as a basis for determining the quantity of the second cache units (the first cache unit quantity) included in the second cache queue. Therefore, in this embodiment, after obtaining the first cache unit quantity, the electronic device may compare the first cache unit quantity with the quantity threshold to determine whether the first cache unit quantity reaches the quantity threshold.
[0066] Among them, when the number of the first cache units reaches the quantity threshold, it can be determined that the number of second cache units included in the second cache queue has reached the upper limit, that is, no other cache units can be added. Therefore, the second target cache unit in the second cache queue can be taken out and added to the first cache queue to free up space in the second cache queue.
[0067] Among them, when the number of first cache units does not reach the quantity threshold, it can be determined that the number of second cache units included in the second cache queue has not reached the upper limit, that is, other cache units can be added. Therefore, the second target cache unit in the second cache queue can be taken out and added to the first cache queue, or the second target cache unit in the second cache queue can be taken out and put back into the second cache queue.
[0068] The data transmission method provided by an embodiment of the present application obtains a first cache queue corresponding to a first image reading object and a second cache queue corresponding to a second image reading object, wherein the first cache queue includes a plurality of first cache units, and the second cache queue includes a plurality of second cache units, and takes out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted, takes out a second target cache unit from the plurality of second cache units, adds the first target cache unit to the second cache queue, and adds the second target cache unit to the first cache queue. Compared to Figure 3 The data transmission method shown in the figure, this embodiment also exchanges the cache units between the two image reading objects to realize the recycling of the cache units, which can avoid the frequent application and release of memory and save the memory usage.
[0069] See also Figure 6 , Figure 6 The flowchart of the data transmission method provided by an embodiment of the present application is shown. The method is applied to the above-mentioned electronic device, and the first electronic device creates a first image reading object and a second image reading object. Figure 6 The process shown is described in detail, and the data transmission method may specifically include the following steps:
[0070] Step S310: obtaining a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units.
[0071] Step S320: taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0072] For the detailed description of step S310 to step S320, please refer to step S110 to step S120, which will not be repeated here.
[0073] Step S330: Acquire the frame rate of the electronic device.
[0074] In some implementations, the frame rate of the electronic device may be acquired, wherein the frame rate of the electronic device is used to represent the number of frames transmitted per second by the electronic device.
[0075] In this embodiment, the frame rate of the electronic device can be obtained in real time, at preset time intervals, at preset times, or according to other preset conditions, etc., which is not limited here.
[0076] Step S340: when the frame rate is greater than a frame rate threshold, adding the first target cache unit to the second cache queue corresponding to the second image reading object.
[0077] In some implementations, the electronic device may pre-set and store a frame rate threshold, wherein the frame rate threshold is used as a basis for determining the frame rate of the electronic device. Therefore, in this embodiment, after obtaining the frame rate of the first electronic device, the frame rate may be compared with the frame rate threshold to determine whether the frame rate is greater than the frame rate threshold.
[0078] Among them, when it is determined that the frame rate is greater than the frame rate threshold, it can be determined that the electronic device is performing high frame rate transmission. Therefore, the transmission of the data to be transmitted needs to be accelerated, that is, the first target cache unit can be added to the second cache queue corresponding to the second image reading object.
[0079] Among them, when it is determined that the frame rate is not greater than the frame rate threshold, it can be determined that the electronic device is performing low frame rate transmission. Therefore, there is no need to speed up the transmission of the data to be transmitted, that is, the data to be transmitted can be copied from the first target cache unit to the second target cache unit.
[0080] As a method, the frame rate threshold may be 30 FPS. That is, when the frame rate of the electronic device is 60 FPS, 90 FPS, 120 FPS, or 240 FPS, it can be considered that the frame rate of the electronic device is greater than the frame rate threshold.
[0081] The data transmission method provided by an embodiment of the present application obtains a first cache queue corresponding to a first image reading object, wherein the first cache queue includes a plurality of first cache units, takes out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted, obtains a frame rate of the electronic device, and when the frame rate is greater than a frame rate threshold, adds the first target cache unit to a second cache queue corresponding to a second image reading object. Compared to Figure 3 The data transmission method shown in the figure, in this embodiment, when the frame rate of the electronic device is greater than the frame rate threshold, switches the cache unit that caches the data to be transmitted between two image reading objects to improve the performance of cross-process data transmission.
[0082] See also Figure 7 , Figure 7 The flowchart of the data transmission method provided by an embodiment of the present application is shown. The method is applied to the above-mentioned electronic device, and the first electronic device creates a first image reading object and a second image reading object. Figure 7 The process shown is described in detail, and the data transmission method may specifically include the following steps:
[0083] Step S410: obtaining a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units.
[0084] Step S420: taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0085] Step S430: adding the first target cache unit to a second cache queue corresponding to the second image reading object.
[0086] For the detailed description of step S410 to step S430 , please refer to step S110 to step S130 , which will not be repeated here.
[0087] Step S440: when the data to be transmitted is read out from the second cache queue and processed, the first target cache unit is taken out from the second cache queue.
[0088] In some embodiments, after the data to be transmitted is transmitted to the second image reading object through the first target cache unit, it can be detected whether the data to be transmitted has been read out and processed from the second image reading object. For example, it can be detected whether the data to be transmitted has been transmitted from the second image reading object to the target process for encoding. When it is determined that the data to be transmitted has been transmitted from the second image reading object to the target process for encoding, it can be determined that the data to be detected has been read out and processed from the second image reading object. When it is determined that the data to be transmitted has not been transmitted from the second image reading object to the target process for encoding, it can be determined that the data to be detected has not been read out and processed from the second image reading object.
[0089] When it is detected that the data to be transmitted has been read and processed from the second cache queue, the first target cache unit may be taken out from the second cache queue.
[0090] See also Figure 8 , Figure 8 This application shows Figure 7 The following is a flow chart of step S440 of the data transmission method shown in FIG. Figure 8 The process shown is described in detail, and the method may specifically include the following steps:
[0091] Step S441: when the data to be transmitted is read out from the second cache queue and processed, the number of cache units corresponding to the remaining first cache units in the first cache queue is obtained as the number of second cache units.
[0092] Step S442: when the number of the second cache units is less than a preset number, taking out the first target cache unit from the second cache queue.
[0093] Step S450: adding the first target cache unit to the first cache queue.
[0094] In some embodiments, after the electronic device takes out the first target cache unit from the second cache queue, it can add the first target cache unit to the first cache queue corresponding to the first image reading object. Based on this, the first target cache unit is re-added to the first cache queue, which can maintain the balance between the number of first cache units in the first cache queue and the number of second cache units in the second cache queue, and can avoid frequent application and release of memory, saving memory usage.
[0095] The data transmission method provided by an embodiment of the present application obtains a first cache queue corresponding to a first image reading object, wherein the first cache queue includes a plurality of first cache units, takes out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted, and adds the first target cache unit to a second cache queue corresponding to a second image reading object. When the data to be transmitted is read out and processed from the second cache queue, the first target cache unit is taken out from the second cache queue and added to the first cache queue. Compared to Figure 3 The data transmission method shown in the figure, in this embodiment, after the data to be processed is read out from the second image reading object, the first target cache unit is re-added to the first cache queue to realize the recycling of the cache unit, which can avoid the frequent application and release of memory and save memory occupancy.
[0096] See also Fig. 9 , Fig. 9 The schematic diagram of the data transmission method provided by an embodiment of the present application is shown in FIG. Fig. 9 The process shown is described in detail, and the data transmission method may specifically include the following steps:
[0097] Step S510: creating a first ImageReader object as the first image reading object, and creating a second ImageReader object as the second image reading object.
[0098] Step S520: obtaining a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units.
[0099] Step S530: taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0100] Step S540: adding the first target cache unit to a second cache queue corresponding to the second image reading object.
[0101] For the detailed description of step S510 to step S540, please refer to step S110 to step S130, which will not be repeated here.
[0102] Step S550: transmitting the data to be transmitted from the second image reading object to the target process.
[0103] In some embodiments, after the data to be transmitted is transmitted to the second image reading object, the data to be transmitted can be transmitted from the second image reading object to a target process through the second image reading object, wherein the target process is used to process the data to be transmitted.
[0104] Step S560: Encode the data to be transmitted through the target process to obtain data to be displayed.
[0105] In some implementations, after the data to be transmitted is transmitted from the second image reading object to the target process, the data to be transmitted may be encoded by the target process to obtain the data to be displayed.
[0106] As a method, when the data to be transmitted is audio data to be transmitted, the audio data to be transmitted can be encoded by the target process to obtain the audio data to be played.
[0107] As another way, when the data to be transmitted is picture data to be transmitted, the picture data to be transmitted can be encoded by the target process to obtain the picture data to be played.
[0108] As another way, when the data to be transmitted is video data to be transmitted, the video data to be transmitted can be encoded by the target process to obtain the video data to be played.
[0109] Step S570: Display the data to be displayed.
[0110] In some embodiments, after obtaining the data to be displayed, the electronic device may display the data to be displayed to improve the display smoothness of the data to be displayed. The electronic device may display the data to be displayed in full screen, in part screen, or in suspended display, etc., which is not limited here.
[0111] An embodiment of the present application provides a data transmission method, which creates a first ImageReader object as a first image reading object, and creates a second ImageReader object as a second image reading object, obtains a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units, takes out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted, adds the first target cache unit to a second cache queue corresponding to the second image reading object, transmits the data to be transmitted from the second image reading object to a target process, encodes the data to be transmitted by the target process, obtains the data to be displayed, and displays the data to be displayed. Compared to Figure 3The data transmission method shown in the figure, this embodiment also transmits the data to be transmitted from the second image reading object to the target process for encoding, obtains and displays the data to be displayed, so as to improve the display effect of the data.
[0112] See also Fig.10 , Fig.10 The data transmission device 300 is applied to the above electronic device, which creates a first image reading object and a second image reading object. Fig.10 The block diagram shown in FIG. 1 is used to illustrate that the data transmission device 300 includes: a cache queue acquisition module 310, a cache unit fetching module 320, and a cache unit adding module 330, wherein:
[0113] The cache queue acquisition module 310 is used to acquire a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units.
[0114] The cache unit fetching module 320 is configured to fetch a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted.
[0115] The cache unit adding module 330 is used to add the first target cache unit to the second cache queue corresponding to the second image reading object.
[0116] Furthermore, the cache unit adding module 330 includes: a frame rate acquisition submodule and a cache unit adding submodule, wherein:
[0117] The frame rate acquisition submodule is used to acquire the frame rate of the electronic device.
[0118] The cache unit adding submodule is used to add the first target cache unit to the second cache queue corresponding to the second image reading object when the frame rate is greater than a frame rate threshold.
[0119] Furthermore, the second cache queue includes a plurality of second cache units, and the data transmission device 300 further includes:
[0120] The second target cache unit fetching module is used to fetch the second target cache unit from the plurality of second cache units.
[0121] The second target cache unit adding module is used to add the second target cache unit to the first cache queue.
[0122] Furthermore, the first target cache unit adding module includes: a first cache unit quantity acquisition submodule and a first target cache unit adding submodule, wherein:
[0123] The first cache unit quantity acquisition submodule is used to acquire the cache unit quantity corresponding to the plurality of second cache units as the first cache unit quantity.
[0124] The first target cache unit adding submodule is used to add the second target cache unit to the first cache queue when the number of the first cache units reaches a number threshold corresponding to the second cache queue.
[0125] Furthermore, the data cache device 300 further includes: a first target cache unit fetching module and a first target cache unit adding module, wherein:
[0126] The first target cache unit fetching module is used to fetch the first target cache unit from the second cache queue when the data to be transmitted is read out from the second cache queue and processed.
[0127] Furthermore, the first target cache unit fetching module includes: a second cache unit data fetching submodule and a first target cache unit fetching submodule, wherein:
[0128] The second cache unit data acquisition submodule is used to acquire the number of cache units corresponding to the remaining first cache units in the first cache queue as the number of second cache units when the data to be transmitted is read out from the second cache queue and processed.
[0129] The first target cache unit fetching submodule is configured to fetch the first target cache unit from the second cache queue when the number of the second cache units is less than a preset number.
[0130] The first target cache unit adding module is used to add the first target cache unit to the first cache queue.
[0131] Furthermore, the data transmission device 300 further includes: an image reading object creation module, wherein:
[0132] The image reading object creation module is used to create a first ImageReader object as the first image reading object, and create a second ImageReader object as the second image reading object.
[0133] Furthermore, the data transmission device 300 further includes: a data reading module to be transmitted, a data processing module to be transmitted, and a data display module to be displayed, wherein:
[0134] The module for reading data to be transmitted is used for transmitting the data to be transmitted from the second image reading object to a target process.
[0135] The data processing module to be transmitted is used to encode the data to be transmitted through the target process to obtain data to be displayed.
[0136] The module for displaying data to be displayed is used to display the data to be displayed.
[0137] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.
[0138] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.
[0139] See also Fig.11 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 400 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.
[0140] The computer readable storage medium 400 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 400 includes a non-transitory computer-readable storage medium. The computer readable storage medium 400 has storage space for program code 410 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 410 can be compressed, for example, in an appropriate form.
[0141] In summary, the data transmission method, device, electronic device and storage medium provided in the embodiments of the present application obtain a first cache queue corresponding to a first image reading object, wherein the first cache queue includes multiple first cache units, and takes out a first target cache unit from the multiple first cache units, wherein the first target cache unit caches data to be transmitted, and adds the first target cache unit to the second cache queue corresponding to the second image reading object, so that by switching the cache unit that caches the data to be transmitted between the two image reading objects, the delay of data transmission can be reduced, and high-performance cross-process data transmission can be achieved.
[0142] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.
Claims
1. A data transmission method, characterized in that: Applied to an electronic device, the electronic device has a first image reading object and a second image reading object created, wherein the first image reading object and the second image reading object belong to two processes respectively, and the method includes: Acquire a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units; Taking out a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted; Adding the first target cache unit to a second cache queue corresponding to the second image reading object; The data to be transmitted is transmitted from the second image reading object to a target process.
2. The method according to claim 1, characterized in that The second cache queue includes a plurality of second cache units, and the method further includes: Taking out a second target cache unit from the plurality of second cache units; Add the second target cache unit to the first cache queue.
3. The method according to claim 2, characterized in that The adding the second target cache unit to the first cache queue comprises: Obtaining the number of cache units corresponding to the plurality of second cache units as the number of first cache units; When the number of the first cache units reaches a number threshold corresponding to the second cache queue, the second target cache unit is added to the first cache queue.
4. The method according to claim 1, characterized in that: The step of adding the first target cache unit to a second cache queue corresponding to the second image reading object includes: Acquiring a frame rate of the electronic device; When the frame rate is greater than a frame rate threshold, the first target cache unit is added to the second cache queue corresponding to the second image reading object.
5. The method according to claim 1, characterized in that After adding the first target cache unit to a second cache queue corresponding to the second image reading object, the method further includes: When the data to be transmitted is read out from the second cache queue and processed, taking out the first target cache unit from the second cache queue; Add the first target cache unit to the first cache queue.
6. The method according to claim 5, characterized in that When the data to be transmitted is read out from the second cache queue and processed, taking out the first target cache unit from the second cache queue comprises: When the data to be transmitted is read out from the second cache queue and processed, the number of cache units corresponding to the remaining first cache units in the first cache queue is obtained as the number of second cache units; When the number of the second cache units is less than a preset number, the first target cache unit is taken out from the second cache queue.
7. The method according to any one of claims 1 to 6, characterized in that: Before obtaining the first cache queue corresponding to the first image reading object, the method further includes: A first ImageReader object is created as the first image reading object, and a second ImageReader object is created as the second image reading object.
8. The method according to any one of claims 1 to 6, characterized in that: After transmitting the data to be transmitted from the second image reading object to the target process, the method further includes: Encoding the data to be transmitted through the target process to obtain data to be displayed; The data to be displayed is displayed.
9. A data transmission device, characterized in that: Applied to an electronic device, the electronic device has a first image reading object and a second image reading object created, wherein the first image reading object and the second image reading object belong to two processes respectively, and the device comprises: A cache queue acquisition module, used to acquire a first cache queue corresponding to the first image reading object, wherein the first cache queue includes a plurality of first cache units; A cache unit fetching module, used to fetch a first target cache unit from the plurality of first cache units, wherein the first target cache unit caches data to be transmitted; A cache unit adding module, used for adding the first target cache unit to a second cache queue corresponding to the second image reading object; The module for reading data to be transmitted is used for transmitting the data to be transmitted from the second image reading object to a target process.
10. An electronic device, characterized in that: The method comprises a memory and a processor, wherein the memory is coupled to the processor, and the memory stores instructions. When the instructions are executed by the processor, the processor executes the method according to any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 8.
