Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
The embodiment of the application provides a method and a device for loading and providing image data, which are used for solving the problems of failure in resource request and too slow loading caused in a scene of multi-party image collaborative consultation and improving the resource acquisition efficiency of the image data.
The method and the device are based on the same application concept, and because the principles of solving the problems of the method and the device are similar, the implementation of the device and the method can be mutually referred, and repeated parts are not repeated.
Various embodiments of the present application will be described in detail below with reference to the accompanying drawings. It should be noted that the display sequence of the embodiment of the present application only represents the sequence of the embodiment, and does not represent the merits of the technical solutions provided by the embodiments.
According to the technical scheme provided by the embodiment of the application, the problems are solved through a strategy of combining multi-source loading and image data division. Specifically, the image data division, for example: firstly, dividing image data to be requested into 10 equal parts (the 10 equal parts are determined according to the number of participants and the size of data volume in the image collaborative consultation scene, and the following description takes the 10 equal parts as an example, which can be determined according to actual needs in the actual implementation process); then, the 10 equal parts of image data are not requested from a single S terminal any more, but are randomly requested to the client terminals C of other participantsiAnd the purpose of multi-source loading is achieved. The following describes the implementation of the multi-source loading strategy and the image data dividing and controlling strategy.
Firstly, a multi-source loading strategy:
1. definition of multi-source loading strategy:
referring to fig. 1, a so-called multi-source loading policy is different from a traditional manner of loading image data from a single S-side, and allows participating clients to load image data from clients C of other participating partiesiThe terminal and the S terminal request data simultaneously, and the concurrent request mode can solve the problem of overlarge instantaneous load of a single server and can greatly accelerate the loading speed of image data.
2. Referring to fig. 2, the working modes of the multi-source loading strategy include:
obtaining image data requests of 10 equal parts through an image data dividing and controlling strategy, and defining a request array and a resource state array, wherein the request array is as follows:
reque stData=[slice0,slice1,...,slice9]
wherein, sliceiThe value of the (i + 1) th equal part representing the image data to be requested is 0 or 1, wherein 0 represents that the slice is not loaded on the current clientiData; otherwise, 1 indicates that the current client has loaded the slice completediAnd (4) data.
The resource state array is:
dataS tate=[state0,state1,...,state9]
wherein, state _ i indicates whether the local client has finished loading the (i + 1) th slice, specifically, 1 indicates loaded, and 0 indicates unloaded; different from slice _ i in requestData, slice _ i in requestData indicates whether i +1 th slice of other clients completes loading, which is described in detail in the following DataStates two-dimensional matrix.
Each C-terminal stores a list of all C-terminals currently establishing connection with the S-terminal, defined as: p ═ S, C1,...,Cn]Wherein n is the number of all C terminals. The array P can be updated in real time according to the online and offline conditions of the C terminal.
CiThe process of end-loading image data is as follows:
first step, CiThe terminal needs to broadcast the resource state array request information to all terminals in the P array, when C in the P arraytEnd receives CiWhen the resource state array of the terminal requests information, C is immediately senttThe dataS tate array in the end returns to CiEnd, last CiThe client will generate the two-dimensional array DataS tables of the resource request state as shown in the following table:
| slice0 | slice1 | slice2 | slice3 | slice4 | slice5 | slice6 | slice7 | slice8 | slice9 |
| S | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
| C1 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 0 |
| C2 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 |
| C3 | 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 |
| … | … | … | … | … | … | … | … | … | … | … |
| Cn | 1 | 1 | 0 | 0 | 0 | 0 | 0 | 0 | 0 | 1 |
the value of the two-dimensional array is 0 or 1, and 0 represents that the slice is loaded at the endiOtherwise, 1 means that the slice is not loaded on the terminali. For example, according to the above table, the S terminal has all the image data loaded, C1Loaded slice2、slice7。
That is, CiThe terminal can know the current terminals (including the terminal S and the terminal C) through the two-dimensional array1~CnEnd) for each partial image data slice0~slice9The loading state of (c).
Second step, CiThe terminal acquires the C according to the own database state arrayiIf the loading condition of the image data is detected by the end, a certain slice is foundiIf the loading is not finished, acquiring which ends currently contain slice according to the two-dimensional array DataS tagsi(i.e., loaded slice)i) Then send out slice to the endiThe data resource request of completing the loading of the image resourceAnd meanwhile, updating the data state array of the user.
In the above process, assume sliceiIs currently already at the S terminal, CjTerminal, CkTerminal, CmThe terminals are loaded, and n terminals are not loaded to the sliceiThen the desired scene is n slices from these n endsiResource request is uniformly transmitted by the S terminal and the C terminaljTerminal, CkTerminal, CmEnd receiving is carried out, so that the situation that a single certain end simultaneously receives the slices of the n ends is avoidediResource blocking caused by resource requests. In addition, it should be considered that if one of the terminals CiThe multiple slice data resource requests sent to the same end still cause resource blocking. Then, in order to ensure that the data resource requests can be uniformly distributed, rather than uniformly requesting to the S-side, a reasonable sampling scheme must be adopted.
According to the above analysis, sampling needs to satisfy two requirements:
the first aspect is to select a slice to be selected from among 10 image data segments at a current equal probabilityi;
The second aspect is selected sliceiTo a certain target C with equal probabilityjI.e. to select a request source with equal probability.
The sampling process is as follows: firstly, a random sampling method is adopted, and one slice is randomly selected from unloaded slices in a database state arrayj;
Then inquiring the loaded completion slice in the DataS tatesjSet ofcSetcThe system can comprise a client and a server;
from set by means of random samplingcIn randomly selecting one end Ck,CkCan be a client, CkOr the server side, so that the sampling process is completed.
Third step, CiThe terminal obtains image data slice to be requested according to the last sampling stepjAnd request target CkLoading image data, synchronously updating the data S date array after loading,so that the other end is requesting slicejWhen image data is available, CiThe terminal can bear part of the responsibilities of the server and provide slice for other clientsjImage data.
And fourthly, circularly inquiring the database state array, if the unloaded image data still exist, repeating the first step to the third step until the image data are completely loaded, and exiting the circulation of the fourth step.
Secondly, image data dividing and treating strategy:
the data dividing and controlling strategy is an auxiliary strategy for realizing a multi-source loading strategy, and the core is data slicing processing, namely, carrying out average segmentation on a complete image data resource request to form a plurality of slices. For example, a complete image data resource request contains 300 images, and if 10 equal slices are performed, each slice contains 30 images. And each C end maintains the state of data recorded by a data array, and once a slice is loaded, the data array is updated to realize division and treatment of the image data.
Fig. 3 is a flowchart of an upper layer application in the method provided by the embodiment of the present application, and describes an application scenario of the method provided by the embodiment of the present application.
In addition, the working mode of the multi-source loading strategy adopts a random sampling method to generate the data slice to be requestedjAnd request target CkAll requests are distributed equally to the client as well as to the server. In an actual application scenario, the server often has better performance than a common client and can bear more load, and therefore, the data to be requested and the request target can also be generated in a weighted sampling manner, so that the server bears more load, and the specific weight can be determined by combining the performance of the server, the performance of the client and the like, which is not limited in the embodiment of the present application. The weighted sampling means that a server is given a larger weight. For example: currently, there are 10 clients and one server, and then the weight of the server may be given by 0.5, and the weight of other clients may be given by 0.05, so that the total weight of each client and server is guaranteed to be 1. Described by geometric thinking in a length of 1The server occupies an interval length of 0.5, the other clients occupy an interval length of 0.05, and if a point randomly falls on the interval with the length of 1, the probability that the point falls on the interval where the server is located is 50%, and the probability that the point falls on a certain client is 5%. In this way, the server with better performance can obtain more image resource loading requests.
In summary, referring to fig. 4, at the data request end, the method for loading image data provided in the embodiment of the present application includes:
s101, determining the current loading state of a plurality of terminals participating in a network virtual conference on image data fragments, wherein the image data fragments are obtained by dividing the whole image data to be discussed in the network virtual conference in advance;
the image data segment, e.g. slice as described abovei。
S102, determining image data segments which are not loaded at the local end currently;
s103, according to the current loading state of the plurality of terminals on the image data fragments, sending a data resource request aiming at the image data fragments which are not loaded currently, and completing the loading of the image data fragments.
By the method, the current loading state of a plurality of terminals participating in the network virtual conference on the image data segment is determined, wherein the image data segment is obtained by dividing the whole image data to be discussed of the network virtual conference in advance; determining the image data segment which is not loaded at the current end; according to the current loading state of the image data fragments by the plurality of terminals, sending a data resource request aiming at the image data fragments which are not loaded currently, and completing the loading of the image data fragments, thereby solving the problems of resource request failure and slow loading caused in the scene of multi-party image collaborative consultation, and improving the resource acquisition efficiency of the image data.
Optionally, the determining the current loading state of the plurality of terminals participating in the network virtual conference on the image data segment specifically includes:
and determining a resource request state two-dimensional array, wherein the resource request state two-dimensional array comprises the loading state of each image data fragment currently loaded by a plurality of terminals participating in the network virtual conference.
Optionally, the determining a resource request state two-dimensional array specifically includes:
broadcasting resource state array request information to a plurality of terminals participating in the network virtual conference;
receiving any end C participating in the network virtual conferencetThe end C of transmissiontA data state array maintained including the terminal CtStatus information indicating whether each of the image data segments has been loaded;
according to said CtAnd the maintained data state array determines a resource request state two-dimensional array.
Optionally, the determining the currently unloaded image data segment at the local end specifically includes:
and determining the current unloaded image data segments according to a data state array maintained by the home terminal, wherein the data state array comprises state information of whether each image data segment is loaded by the home terminal.
Optionally, after each loading of an image data segment is completed, the method further includes:
and updating the data state array maintained by the local terminal.
Optionally, the sending a data resource request for a currently unloaded image data fragment specifically includes:
randomly selecting an unloaded image data segment slice from a plurality of image data segments which are not loaded at the present time of the local terminalj;
Determining that the slice has been loadedjSet ofc;
Set from the SetcIn randomly selecting one end CkTo the end CkSending a data resource request for acquiring the slicej。
The data request end according to the embodiment of the present application may be, for example, any client participating in a network virtual conference.
Accordingly, at the data providing end, referring to fig. 5, the method for providing image data provided by the embodiment of the present application includes:
s201, receiving a data resource request sent by an opposite terminal participating in a network virtual conference and aiming at an image data fragment which is not loaded at the opposite terminal currently, wherein the image data fragment is an image data fragment obtained by dividing the whole image data which needs to be discussed in the network virtual conference in advance;
s202, according to the data resource request, providing the requested image data segment to the opposite terminal.
The data provider according to the embodiment of the present application may be, for example, any client participating in a network virtual conference, or may be a server.
Referring to fig. 6, an embodiment of the present application provides a computing device, which includes amemory 11 and aprocessor 12, where the memory is used to store program instructions, and the processor is used to call the program instructions stored in the memory, and perform any one of the above methods according to the obtained program.
The computing device described in the present application may be a server, or may be a client, and may be any user device or network device with computing capability. For example, a computer, a mobile phone, a television, a tablet computer, etc.
Specifically, if the computing device is used as a data request end, the processor is configured to call the program instructions stored in the memory, and execute, according to the obtained program:
determining the current loading state of a plurality of terminals participating in the network virtual conference on image data fragments, wherein the image data fragments are obtained by dividing the whole image data to be discussed of the network virtual conference in advance;
determining the image data segment which is not loaded at the current end;
and sending a data resource request aiming at the image data fragment which is not loaded currently according to the loading state of the plurality of terminals to the image data fragment currently, and completing the loading of the image data fragment.
Optionally, the determining the current loading state of the plurality of terminals participating in the network virtual conference on the image data segment specifically includes:
and determining a resource request state two-dimensional array, wherein the resource request state two-dimensional array comprises the loading state of each image data fragment currently loaded by a plurality of terminals participating in the network virtual conference.
Optionally, the determining a resource request state two-dimensional array specifically includes:
broadcasting resource state array request information to a plurality of terminals participating in the network virtual conference;
receiving any end C participating in the network virtual conferencetThe end C of transmissiontA data state array maintained including the terminal CtStatus information indicating whether each of the image data segments has been loaded;
according to said CtAnd the maintained data state array determines a resource request state two-dimensional array.
Optionally, the determining the currently unloaded image data segment at the local end specifically includes:
and determining the current unloaded image data segments according to a data state array maintained by the home terminal, wherein the data state array comprises state information of whether each image data segment is loaded by the home terminal.
Optionally, after each loading of an image data segment, the processor is further configured to:
and updating the data state array maintained by the local terminal.
Optionally, the sending a data resource request for a currently unloaded image data fragment specifically includes:
randomly selecting an unloaded image data segment slice from a plurality of image data segments which are not loaded at the present time of the local terminalj;
Determining that the slice has been loadedjSet ofc;
Set from the SetcIn randomly selecting one end CkTo the end CkSendingA data resource request for obtaining the slicej。
If the computing device is used as a data providing end, the processor is used for calling the program instructions stored in the memory and executing the following steps according to the obtained program:
receiving a data resource request sent by an opposite terminal participating in a network virtual conference and aiming at an image data fragment which is not loaded at the opposite terminal currently, wherein the image data fragment is an image data fragment obtained by dividing the whole image data which needs to be discussed in the network virtual conference in advance;
and providing the requested image data fragment to the opposite terminal according to the data resource request.
Referring to fig. 7, another image data loading apparatus provided in the embodiment of the present application includes:
afirst unit 21, configured to determine a current loading state of a plurality of terminals participating in a network virtual conference on an image data segment, where the image data segment is an image data segment obtained by dividing overall image data that needs to be discussed in the network virtual conference in advance;
asecond unit 22, configured to determine an image data segment that is not currently loaded at the local end;
athird unit 23, configured to send a data resource request for a currently unloaded image data segment according to a current loading state of the image data segment by the multiple terminals, and complete loading of the image data segment.
Optionally, the determining the current loading state of the plurality of terminals participating in the network virtual conference on the image data segment specifically includes:
and determining a resource request state two-dimensional array, wherein the resource request state two-dimensional array comprises the loading state of each image data fragment currently loaded by a plurality of terminals participating in the network virtual conference.
Optionally, the determining a resource request state two-dimensional array specifically includes:
broadcasting resource state array request information to a plurality of terminals participating in the network virtual conference;
receiving participation in the networkEither end of the virtual conference CtThe end C of transmissiontA data state array maintained including the terminal CtStatus information indicating whether each of the image data segments has been loaded;
according to said CtAnd the maintained data state array determines a resource request state two-dimensional array.
Optionally, the determining the currently unloaded image data segment at the local end specifically includes:
and determining the current unloaded image data segments according to a data state array maintained by the home terminal, wherein the data state array comprises state information of whether each image data segment is loaded by the home terminal.
Optionally, after each loading of an image data segment, thethird unit 23 is further configured to:
and updating the data state array maintained by the local terminal.
Optionally, the sending a data resource request for a currently unloaded image data fragment specifically includes:
randomly selecting an unloaded image data segment slice from a plurality of image data segments which are not loaded at the present time of the local terminalj;
Determining that the slice has been loadedjSet ofc;
Set from the SetcIn randomly selecting one end CkTo the end CkSending a data resource request for acquiring the slicej。
The loading device of the image data can be a server or a client.
Referring to fig. 8, another image data providing device according to an embodiment of the present application includes:
a receivingunit 31, configured to receive a data resource request sent by an opposite end participating in a network virtual conference and sent for an image data fragment that is not currently loaded by the opposite end, where the image data fragment is an image data fragment obtained by dividing, in advance, overall image data that needs to be discussed in the network virtual conference;
a providingunit 32, configured to provide the requested image data segment to the peer end according to the data resource request.
The device for providing the image data can be a server or a client.
It should be noted that the division of the unit in the embodiment of the present application is schematic, and is only a logic function division, and there may be another division manner in actual implementation. In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, a network device, or the like) or a processor (processor) to execute all or part of the steps of the method according to the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The embodiment of the present application provides a computing device, which may specifically be a desktop computer, a portable computer, a smart phone, a tablet computer, a Personal Digital Assistant (PDA), and the like. The computing device may include a Central Processing Unit (CPU), memory, input/output devices, etc., the input devices may include a keyboard, mouse, touch screen, etc., and the output devices may include a Display device, such as a Liquid Crystal Display (LCD), a Cathode Ray Tube (CRT), etc.
The memory may include Read Only Memory (ROM) and Random Access Memory (RAM), and provides the processor with program instructions and data stored in the memory. In the embodiments of the present application, the memory may be used for storing a program of any one of the methods provided by the embodiments of the present application.
The processor is used for executing any one of the methods provided by the embodiment of the application according to the obtained program instructions by calling the program instructions stored in the memory.
Embodiments of the present application provide a computer storage medium for storing computer program instructions for an apparatus provided in the embodiments of the present application, which includes a program for executing any one of the methods provided in the embodiments of the present application.
The computer storage media may be any available media or data storage device that can be accessed by a computer, including, but not limited to, magnetic memory (e.g., floppy disks, hard disks, magnetic tape, magneto-optical disks (MOs), etc.), optical memory (e.g., CDs, DVDs, BDs, HVDs, etc.), and semiconductor memory (e.g., ROMs, EPROMs, EEPROMs, non-volatile memory (NAND FLASH), Solid State Disks (SSDs)), etc.
The above method process flow may be implemented by a software program, which may be stored in a storage medium, and when the stored software program is called, the above method steps are performed.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, system, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present application without departing from the spirit and scope of the application. Thus, if such modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is intended to include such modifications and variations as well.