Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples are not representative of all implementations consistent with the present disclosure. Rather, they are merely examples of apparatus and methods consistent with some aspects of the present disclosure as detailed in the accompanying claims.
The disclosure provides a multimedia file scanning method, a device and terminal equipment, so as to improve the scanning efficiency of multimedia files and reduce the scanning time.
The multimedia file scanning method and device provided by the disclosure can be applied to terminal equipment. For example, it can be applied to mobile phones and the like.
Several specific examples are given below to illustrate the technical aspects of the present disclosure in detail. The following embodiments may be combined with each other, and the same or similar concepts or processes may not be described in detail in some embodiments.
Fig. 1 is a flowchart of a multimedia file scanning method according to an exemplary embodiment of the present disclosure. Referring to fig. 1, the method provided in this embodiment is applied to a terminal device, and the method may include:
S101, when a multimedia file scanning request aiming at a server multimedia database on the equipment is received, determining a target file path set which needs to be scanned by the scanning request.
It should be noted that, in an embodiment, the multimedia file scan request is generated when it is detected that the album application on the device is started or returns to the foreground.
In another embodiment, the multimedia file scan request is a multimedia file scan request for an android media database on the device generated when a file creation notification reported by a third party application is detected.
It should be noted that when the third party application detects the file creation operation, a file creation notification is reported to the terminal system, and further, the terminal system generates a multimedia file scanning request for the android media database on the device based on the file creation notification reported by the third party application, so as to perform multimedia file scanning based on the multimedia file scanning request for the android media database on the device, and update the android media database.
Further, the terminal system determines the multimedia file scanning request for the android media database on the device as a multimedia scanning request for a server multimedia database on the device, so as to scan the multimedia file based on the multimedia scanning request and update the server multimedia database.
Further, in yet another embodiment, the multimedia file scan request may be generated upon detecting that an album application on the present device creates a file.
Specifically, the state of the album application may be monitored, and when the album application creates a file (for example, a user edits an original picture to generate a new picture) is monitored, a multimedia file scanning request is generated.
In addition, the target file path set is a file path that is added or deleted by the local file system compared to the server multimedia database. The specific implementation principles for determining the target file path set to be scanned by the scan request will be described in detail in the following embodiments, which are not described herein.
S102, generating a plurality of final scanning tasks according to the target file path set, wherein each final scanning task is used for indicating to scan a file under one target file path in the target file path set.
Specifically, for each target file path, it may be wrapped into a final scan task that carries the target file path for indicating to scan the files under the target file path. The specific implementation principle and implementation process of the package may refer to descriptions in the related art, and are not repeated herein.
When a final scan task is generated based on a target file path, if the file under the target file path is a newly added file, a final scan task with a new type is generated, and if the file under the target file path is a deleted file, a final scan task with a deleted type is generated.
S103, processing each final scanning task in parallel based on a plurality of scanning threads to obtain a scanning result corresponding to each final scanning task, and inserting the scanning result into the server multimedia database.
For example, in one embodiment, the number of scan threads is 4, i.e., 4 final scan tasks can be processed simultaneously at one time.
In addition, when the scan result is inserted into the service provider multimedia database, the scan result may be inserted into the service provider multimedia database in a batch process.
Optionally, in a possible implementation manner, if the file paths carried by the several final scan tasks are the same, when the final scan tasks are processed, the several final scan tasks may be combined, that is, only one of the final scan tasks may be reserved. Therefore, resources can be saved, the scanning efficiency is further improved, and the scanning time is reduced.
According to the method provided by the embodiment, when a multimedia file scanning request aiming at a service provider multimedia database on the equipment is received, a target file path set which needs to be scanned by the scanning request is determined, and then a plurality of final scanning tasks are generated according to the target file path set, so that each final scanning task is processed in parallel based on a plurality of scanning threads to obtain a scanning result corresponding to each final scanning task, and the scanning result is inserted into the service provider multimedia database. Each final scanning task is used for indicating to scan the file under one target file path in the target file path set. Therefore, the final scanning task is processed in parallel through multiple scanning threads, so that the scanning efficiency can be improved, and the scanning time can be reduced.
Fig. 2 is a flowchart of another multimedia file scanning method according to an exemplary embodiment of the present disclosure. Referring to fig. 2, based on the foregoing embodiment, the method provided in this embodiment, where the scan request carries identification information, and the determining a target file path set to be scanned by the scan request and generating a plurality of final scan tasks according to the target file path set may include:
S201, searching a processing strategy corresponding to the identification information from the corresponding relation between the preset identification information and the processing strategy according to the identification information, wherein the processing strategy comprises a candidate file path set determining strategy.
Specifically, in this embodiment, the scan request carries identification information, which is used to identify the trigger scenario of the scan request. For example, when a scan request is generated when it is detected that an album application on the device is started or returns to the foreground, the identification information carried by the scan request may be Y. When the scanning request is a multimedia file scanning request aiming at an android media database on the device, which is generated when the file creation notification reported by the third party application is detected, the identification information carried by the scanning request can be Z. When a scan request is generated when it is detected that an album application on the device creates a file, the identification information carried by the scan request may be X.
It should be noted that, when the scan request is a multimedia file scan request for an android media database on the present device, which is generated when a file creation notification reported by a third party application is detected, or when the scan request is a scan request generated when an album application creation file on the present device is detected, the scan request further carries a file path (the file path may be a file path corresponding to a newly created file).
In addition, the correspondence between the preset identification information and the processing policy is set according to the actual needs, and in this embodiment, the specific content is not limited.
For example, in an embodiment, when the identification information is Z or X, the corresponding candidate file path set determining policy may be that all file paths under the file path carried by the scan request are obtained from the local file system, and the obtained file paths are determined as the candidate file path set.
For another example, when the identification information is Y, the corresponding candidate file path set determining policy may be to determine all file paths in the local file system as candidate file path sets.
Of course, in still another embodiment, when the identification information is Y, the corresponding candidate file path set determining policy may be to determine all file paths (file paths corresponding to the third party application refer to file paths for storing data generated by the third party application) corresponding to specified third party applications (the specified third party application may be set according to actual needs, for example) existing in the local file system and all file paths under the specified file paths acquired from the local file system as the candidate file path set, where the specified file paths may be file paths currently existing in the server multimedia database and/or file paths newly added in the android media database.
S202, determining a candidate file path set corresponding to the scanning request based on the candidate file path set determination strategy.
For example, in one embodiment, the identification information carried by the scan information is Y, and at this time, based on the candidate file path determining policy given in the second example above, the candidate file path set corresponding to the scan request may be determined according to the following method:
(1) And judging whether a storage space corresponding to the third party application exists in the local file system (used for storing data generated by the third party application) aiming at any appointed third party application, and if so, determining all file paths in the local file system under the storage space as first candidate file paths.
(2) And for any file path currently existing in the service provider multimedia database, acquiring all file paths under the file path from a local file system, and determining the acquired file path as a second candidate file path.
(3) And aiming at the newly added file path of the android media database, acquiring all file paths under the file path from a local file system, and determining the acquired file path as a third candidate file path.
(4) And determining a set of the first candidate file path, the second candidate file path and the third candidate file path as a candidate file path set.
S203, comparing the file paths existing in the server multimedia database with the candidate file path sets, determining a target file path set which is newly added or deleted locally, and generating the final scanning task based on the target file path set.
In particular, the file paths currently existing in the server multimedia database can be compared with the candidate file path set to determine which paths in the candidate file path set are locally added target file paths, and determine which paths in the file paths currently existing in the server multimedia database are locally deleted target file paths.
According to the method provided by the embodiment, when the scanning request carries the identification information, the processing strategy corresponding to the identification information is searched from the corresponding relation between the preset identification information and the processing strategy according to the identification information, and then the candidate file path set corresponding to the scanning request is determined based on the candidate file path set determining strategy in the processing strategy, so that the file path which is currently existing in the server multimedia database is compared with the candidate file path set, a target file path set which is newly added or deleted locally is determined, and the final scanning task is generated based on the target file path set. Therefore, a plurality of final scanning tasks can be processed in parallel based on a plurality of scanning threads which are executed in parallel, so that the scanning efficiency can be improved, and the scanning time can be reduced.
Optionally, in a possible implementation manner of the present disclosure, the determining a locally added or deleted target file path set, and generating the final scan task based on the target file path set includes:
and executing the step of determining a local newly added or deleted target file path set based on a plurality of processing threads in parallel, and generating the final scanning task based on the target file path set.
It should be noted that, referring to the foregoing description, when determining a file path that is newly added or deleted locally, it is necessary to compare a file path that is currently existing in the server multimedia database with a file path in the candidate file path set to determine which paths in the candidate file path set are target file paths that are newly added locally, and determine which paths in the file path that is currently existing in the multimedia data path on the server are target file paths that are deleted locally.
In this embodiment, when a comparison is performed to determine a locally added or deleted target file path set, and the final scan task is generated based on the target file path set, this process may be executed in parallel based on multiple processing threads. Thus, the efficiency can be further improved and the time can be shortened.
Optionally, in a possible implementation manner of the present disclosure, the processing policy further includes a grouping policy, and after determining the candidate file path set corresponding to the scan request, the method further includes:
Dividing the candidate file path set into at least one group based on the grouping policy;
for each packet, generating an intermediate scan task based on the packet;
The step of using a plurality of processing threads to execute and determine a local newly added or deleted target file path set in parallel and generating the final scanning task based on the target file path set comprises the following steps:
And processing each intermediate scanning task in parallel by adopting a plurality of processing threads, wherein the process of processing the intermediate scanning task comprises the steps of comparing a file path existing in the service provider multimedia database currently with a packet carried by the intermediate scanning task, determining a target file path set which is newly added or deleted locally, and generating the final scanning task based on the target file path set.
Specifically, the grouping policy is set according to actual needs, and in this embodiment, the grouping policy is not limited.
For example, in one embodiment, when the identification information of the scan request is X or Z, the corresponding grouping policy is that the candidate file path set is divided into one group, and when the identification information of the scan request is Y and the candidate file path determining policy is given in the second example described above, the corresponding grouping policy may be that the first candidate file path is divided into one group, the second candidate file path is divided into one group, the file path corresponding to the video in the third candidate file path is divided into one group, and the file path corresponding to the picture in the third candidate file path is divided into one group, that is, the candidate file set is divided into four groups according to the above method.
In particular, for each packet, the packet may be encapsulated as an intermediate scan task. The specific implementation principles of the package may be referred to the description of the foregoing embodiments, and will not be repeated here.
In addition, in this embodiment, when a step of determining a locally added or deleted target file path set and generating the final scan task based on the target file path set is performed in parallel by using a plurality of processing threads, each of the intermediate scan tasks may be processed in parallel by using a plurality of processing threads. The process of processing the intermediate scanning task comprises the steps of comparing a file path existing in the server multimedia database currently with a group carried by the intermediate scanning task, determining a target file path set which is newly added or deleted locally, and generating the final scanning task based on the target file path set.
For example, in an embodiment, the candidate file path set includes 50 file paths in total, and in this embodiment, the 50 file paths may be divided into two groups, so as to obtain two intermediate scanning tasks, and further process the two intermediate scanning tasks in parallel. In this way, frequent scheduling processes can be avoided and scheduling pressure can be reduced.
The method provided by the embodiment divides the candidate file path set into at least one group, and further generates an intermediate scanning task based on each group. Thus, a plurality of processing threads can be adopted to process the intermediate scanning task in parallel, so that not only can the efficiency be improved, but also the dispatching pressure can be reduced.
In one embodiment, in processing the scan task (including the final scan task and the intermediate scan task), the priority of the scan task may be determined first, and the scan task may be processed in parallel based on the order of the priority from high to low.
In particular, when the method is implemented, the priority of the scanning task may be determined based on the generation time of the scanning task, the size of the file corresponding to the file path carried by the scanning task, and the like, which is not limited in this embodiment, for example, in an embodiment, a higher priority may be assigned to the scanning task when the generation time of the scanning task is earlier.
According to the method provided by the embodiment, before the scanning tasks are processed, the priority of each scanning task is determined, and then when the scanning tasks are processed, the scanning tasks are processed based on the priority. In this way, priority execution of certain tasks may be guaranteed.
A more specific embodiment is given below to describe in detail the technical solution of the present disclosure:
Fig. 3 is a flowchart of a multimedia file scanning method according to an exemplary embodiment of the present disclosure. Referring to fig. 3, the method provided in this embodiment may include:
S301, when a multimedia file scanning request aiming at a service provider multimedia database on the equipment is received, the scanning request is packaged into an original scanning task, wherein the original scanning task carries identification information.
For a specific implementation principle of encapsulating the scan request into the original scan task, reference may be made to the description in the related art, and will not be repeated here.
S302, searching a processing strategy corresponding to the identification information from the corresponding relation between preset identification information and the processing strategy according to the identification information carried by the original scanning task, wherein the processing strategy comprises a candidate file path determining strategy and a grouping strategy.
S303, determining a candidate file path set corresponding to the scanning request based on the candidate file path set determination strategy.
S304, dividing the candidate file path set into at least one group based on the grouping strategy.
S305, for each packet, an intermediate scan task is generated based on the packet.
S306, processing the intermediate scanning task in parallel based on a plurality of processing threads, wherein the process of processing the intermediate scanning task comprises the steps of comparing a file path existing in a service provider multimedia database on the equipment with a packet carried by the intermediate scanning task, determining a target file path set which is newly added or deleted locally, and generating a final scanning task based on the target file path set.
For example, in one embodiment, the number of processing threads is 2, i.e., two intermediate scan tasks can be processed simultaneously.
S307, processing each final scanning task in parallel based on a plurality of scanning threads to obtain a scanning result corresponding to each final scanning task, and inserting the scanning result into the server multimedia database.
For example, in one embodiment, the number of scan threads may be 4. I.e. 4 final scan tasks can be processed simultaneously.
For the specific implementation principles and implementation procedures of the above steps, reference may be made to the description in the foregoing embodiments, and no further description is given here.
According to the method provided by the embodiment, the intermediate scanning task and the final scanning task are processed in parallel, so that the scanning efficiency can be improved, and the scanning time can be reduced.
Corresponding to the foregoing embodiments of the multimedia file scanning method, the present disclosure also provides embodiments of a multimedia file scanning apparatus.
Fig. 4 is a schematic structural view of a multimedia file scanning apparatus according to an exemplary embodiment of the present disclosure. Referring to fig. 4, the apparatus provided in this embodiment is applied to a terminal device, and the apparatus includes a generating module 410 and a processing module 420, where,
The generating module 410 is configured to determine, when a multimedia file scanning request for a server multimedia database on the device is received, a target file path set that needs to be scanned by the scanning request;
The generating module 410 is further configured to generate a plurality of final scan tasks according to the target file path set, where each final scan task is configured to instruct scanning a file under one target file path in the target file path set;
The processing module 420 is configured to process each final scan task in parallel based on a plurality of scan threads, obtain a scan result corresponding to each final scan task, and insert the scan result into the server multimedia database.
The device provided in this embodiment may be used to implement the technical solution of the embodiment shown in fig. 1, and its implementation principle and technical effects are similar, and are not described here again.
Fig. 5 is a schematic structural view of another multimedia file scanning apparatus according to an exemplary embodiment of the present disclosure. Referring to fig. 5, on the basis of the foregoing embodiment, in the apparatus provided in this embodiment, the scan request carries identification information, and the generating module 410 may include a searching unit 411, a determining unit 412 and a processing unit 413, where,
The searching unit 411 is configured to search, according to the identification information, a processing policy corresponding to the identification information from a preset correspondence between the identification information and the processing policy, where the processing policy includes a candidate file path set determining rule;
the determining unit 412 is configured to determine, based on the candidate file path set determining rule, a candidate file path set corresponding to the scan request;
The processing unit 413 is configured to compare a file path currently existing in the server multimedia database with the candidate file path set, determine a target file path set that is newly added or deleted locally, and generate the final scanning task based on the target file path set.
Further, the processing unit 413 is specifically configured to perform, in parallel, searching for a locally added or deleted target file path set from the candidate file path sets based on a plurality of processing threads, and generating the final scan task based on the target file path set.
Further, the determining unit 412 is further configured to, after determining the candidate file path set corresponding to the scan request, divide the candidate file path set into at least one group based on the grouping policy, and generate an intermediate scan task based on the group for each group;
The processing unit 413 is specifically configured to process each intermediate scanning task in parallel by using a plurality of processing threads, where a process of processing the intermediate scanning task includes comparing a file path currently existing in the server multimedia database with a packet carried by the intermediate scanning task, determining a locally added or deleted target file path set, and generating the final scanning task based on the target file path set.
Further, the multimedia file scanning request is generated when the album application of the device is detected to be started or returned to the foreground;
And/or the number of the groups of groups,
The multimedia file scanning request is generated when a file creation notification reported by a third party application is detected and aims at an android media database on the device;
and/or the multimedia file scanning request is generated when the album application on the device is detected to create the file.
The specific manner in which the various modules perform the operations in the apparatus of the above embodiments have been described in detail in connection with the embodiments of the related methods, and will not be described in detail herein.
For the device embodiments, reference is made to the description of the method embodiments for the relevant points, since they essentially correspond to the method embodiments. The apparatus embodiments described above are merely illustrative, wherein the modules illustrated as separate components may or may not be physically separate, and the components shown as modules may or may not be physical, i.e., may be located in one place, or may be distributed over a plurality of network modules. Some or all of the modules may be selected according to actual needs to achieve the objectives of the disclosed solution. Those of ordinary skill in the art will understand and implement the present invention without undue burden.
The embodiment of the disclosure further provides a terminal device, including:
A processor;
a memory for storing processor-executable instructions;
wherein the processor is configured to implement the method of any of the embodiments described above.
Embodiments of the present disclosure also provide a computer-readable storage medium having stored thereon a computer program which, when executed by a processor, implements the method of any of the above embodiments.
Fig. 6 is a schematic structural diagram of a terminal device according to an exemplary embodiment of the present disclosure. For example, the terminal device 600 may be a mobile phone or the like.
Referring to fig. 6, a terminal device 600 can include one or more of a processing component 602, a memory 604, a power component 606, a multimedia component 608, an audio component 610, an input/output (I/O) interface 612, a sensor component 614, and a communication component 616.
The processing component 602 generally controls overall operation of the terminal device 600, such as operations associated with display, telephone calls, data communications, camera operations, and recording operations. The processing component 602 may include one or more processors 620 to execute instructions to perform all or part of the steps of the methods described above. Further, the processing component 602 can include one or more modules that facilitate interaction between the processing component 602 and other components. For example, the processing component 602 may include a multimedia module to facilitate interaction between the multimedia component 608 and the processing component 602.
The memory 604 is configured to store various types of data to support operations at the terminal device 600. Examples of such data include instructions for any application or method operating on terminal device 600, contact data, phonebook data, messages, pictures, video, and the like. The memory 604 may be implemented by any type or combination of volatile or nonvolatile memory devices such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic or optical disk.
The power supply component 606 provides power to the various components of the terminal device 600. The power components 606 may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power for the terminal device 600.
The multimedia component 608 comprises a screen between the terminal device 600 and the user providing an output interface. In some embodiments, the screen may include a Liquid Crystal Display (LCD) and a Touch Panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from a user. The touch panel includes one or more touch sensors to sense touches, swipes, and gestures on the touch panel. The touch sensor may sense not only the boundary of a touch or slide action, but also the duration and pressure associated with the touch or slide operation. In some embodiments, the multimedia component 1308 includes a front-facing camera and/or a rear-facing camera. The front camera and/or the rear camera may receive external multimedia data when the terminal device 600 is in an operation mode, such as a photographing mode or a video mode. Each front camera and rear camera may be a fixed optical lens system or have focal length and optical zoom capabilities.
The audio component 610 is configured to output and/or input audio signals. For example, the audio component 610 includes a Microphone (MIC) configured to receive external audio signals when the terminal device 600 is in an operational mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signals may be further stored in the memory 604 or transmitted via the communication component 616. In some embodiments, audio component 610 further includes a speaker for outputting audio signals.
The I/O interface 612 provides an interface between the processing component 602 and peripheral interface modules, which may be a keyboard, click wheel, buttons, etc. These buttons may include, but are not limited to, a home button, a volume button, an activate button, and a lock button.
The sensor assembly 614 includes one or more sensors for providing status assessment of various aspects of the terminal device 600. For example, the sensor assembly 614 may detect the on/off state of the terminal device 600, the relative positioning of the components, such as the display and keypad of the terminal device 600, the sensor assembly 614 may also detect the change in position of the terminal device 600 or a component of the terminal device 600, the presence or absence of a user's contact with the terminal device 600, the orientation or acceleration/deceleration of the terminal device 600, and the change in temperature of the terminal device 600. The sensor assembly 614 may include a proximity sensor configured to detect the presence of nearby objects in the absence of any physical contact. The sensor assembly 614 may also include a light sensor, such as a CMOS or CCD image sensor, for use in imaging applications. In some embodiments, the sensor assembly 614 may also include an acceleration sensor, a gyroscopic sensor, a magnetic sensor, a pressure sensor, or a temperature sensor.
The communication component 616 is configured to facilitate communication between the terminal device 600 and other devices, either wired or wireless. The terminal device 600 may access a wireless network based on a communication standard, such as WiFi,2G or 3G,4G LTE, 5G NR or a combination thereof. In one exemplary embodiment, the communication component 616 receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In one exemplary embodiment, the communication component 616 further includes a Near Field Communication (NFC) module to facilitate short range communications. For example, the NFC module may be implemented based on Radio Frequency Identification (RFID) technology, infrared data association (IrDA) technology, ultra Wideband (UWB) technology, bluetooth (BT) technology, and other technologies.
In an exemplary embodiment, the terminal device 600 may be implemented by one or more Application Specific Integrated Circuits (ASICs), digital Signal Processors (DSPs), digital Signal Processing Devices (DSPDs), programmable Logic Devices (PLDs), field Programmable Gate Arrays (FPGAs), controllers, microcontrollers, microprocessors or other electronic elements for executing the methods described in any one of the embodiments above.
In an exemplary embodiment, a non-transitory computer readable storage medium is also provided, such as a memory, comprising instructions executable by a processor to perform the above-described method. For example, the non-transitory computer readable storage medium may be ROM, random Access Memory (RAM), CD-ROM, magnetic tape, floppy disk, optical data storage device, etc.
Other embodiments of the disclosure will be apparent to those skilled in the art from consideration of the specification and practice of the disclosure disclosed herein. This disclosure is intended to cover any adaptations, uses, or adaptations of the disclosure following the general principles of the disclosure and including such departures from the present disclosure as come within known or customary practice within the art to which the disclosure pertains. It is intended that the specification and examples be considered as exemplary only, with a true scope and spirit of the disclosure being indicated by the following claims.
It is to be understood that the present disclosure is not limited to the precise arrangements and instrumentalities shown in the drawings, and that various modifications and changes may be effected without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.